blob: 7147e2ef0f52f59ec1a6ffe6319c0c4a0404a9b4 [file] [log] [blame]
Benny Prijono9c461142008-07-10 22:41:20 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
Benny Prijono9c461142008-07-10 22:41:20 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PY_PJSUA_H__
21#define __PY_PJSUA_H__
22
23#define _CRT_SECURE_NO_DEPRECATE
24
25#include <Python.h>
26#include <structmember.h>
27#include <pjsua-lib/pjsua.h>
28
29
Benny Prijono55040452008-07-21 18:20:57 +000030PJ_INLINE(pj_str_t) PyString_ToPJ(const PyObject *obj)
Benny Prijono9c461142008-07-10 22:41:20 +000031{
32 pj_str_t str;
33
Benny Prijono55040452008-07-21 18:20:57 +000034 if (obj && PyString_Check(obj)) {
Benny Prijono9c461142008-07-10 22:41:20 +000035 str.ptr = PyString_AS_STRING(obj);
36 str.slen = PyString_GET_SIZE(obj);
37 } else {
38 str.ptr = NULL;
39 str.slen = 0;
40 }
41
42 return str;
43}
44
Benny Prijono55040452008-07-21 18:20:57 +000045PJ_INLINE(PyObject*) PyString_FromPJ(const pj_str_t *str)
Benny Prijono9c461142008-07-10 22:41:20 +000046{
Benny Prijono55040452008-07-21 18:20:57 +000047 return PyString_FromStringAndSize(str->ptr, str->slen);
48}
Benny Prijono9c461142008-07-10 22:41:20 +000049
50//////////////////////////////////////////////////////////////////////////////
51/*
52 * PyObj_pjsip_cred_info
53 */
54typedef struct
55{
56 PyObject_HEAD
57
58 /* Type-specific fields go here. */
59 PyObject *realm;
60 PyObject *scheme;
61 PyObject *username;
62 int data_type;
63 PyObject *data;
64
65} PyObj_pjsip_cred_info;
66
67/*
68 * cred_info_dealloc
69 * deletes a cred info from memory
70 */
71static void PyObj_pjsip_cred_info_delete(PyObj_pjsip_cred_info* self)
72{
73 Py_XDECREF(self->realm);
74 Py_XDECREF(self->scheme);
75 Py_XDECREF(self->username);
76 Py_XDECREF(self->data);
77 self->ob_type->tp_free((PyObject*)self);
78}
79
80
81static void PyObj_pjsip_cred_info_import(PyObj_pjsip_cred_info *obj,
82 const pjsip_cred_info *cfg)
83{
84 Py_XDECREF(obj->realm);
Benny Prijono55040452008-07-21 18:20:57 +000085 obj->realm = PyString_FromPJ(&cfg->realm);
Benny Prijono9c461142008-07-10 22:41:20 +000086 Py_XDECREF(obj->scheme);
Benny Prijono55040452008-07-21 18:20:57 +000087 obj->scheme = PyString_FromPJ(&cfg->scheme);
Benny Prijono9c461142008-07-10 22:41:20 +000088 Py_XDECREF(obj->username);
Benny Prijono55040452008-07-21 18:20:57 +000089 obj->username = PyString_FromPJ(&cfg->username);
Benny Prijono9c461142008-07-10 22:41:20 +000090 obj->data_type = cfg->data_type;
91 Py_XDECREF(obj->data);
Benny Prijono55040452008-07-21 18:20:57 +000092 obj->data = PyString_FromPJ(&cfg->data);
Benny Prijono9c461142008-07-10 22:41:20 +000093}
94
95static void PyObj_pjsip_cred_info_export(pjsip_cred_info *cfg,
96 PyObj_pjsip_cred_info *obj)
97{
Benny Prijono55040452008-07-21 18:20:57 +000098 cfg->realm = PyString_ToPJ(obj->realm);
99 cfg->scheme = PyString_ToPJ(obj->scheme);
100 cfg->username = PyString_ToPJ(obj->username);
Benny Prijono9c461142008-07-10 22:41:20 +0000101 cfg->data_type = obj->data_type;
Benny Prijono55040452008-07-21 18:20:57 +0000102 cfg->data = PyString_ToPJ(obj->data);
Benny Prijono9c461142008-07-10 22:41:20 +0000103}
104
105
106/*
107 * cred_info_new
108 * constructor for cred_info object
109 */
110static PyObject * PyObj_pjsip_cred_info_new(PyTypeObject *type,
111 PyObject *args,
112 PyObject *kwds)
113{
114 PyObj_pjsip_cred_info *self;
115
116 PJ_UNUSED_ARG(args);
117 PJ_UNUSED_ARG(kwds);
118
119 self = (PyObj_pjsip_cred_info *)type->tp_alloc(type, 0);
Benny Prijono55040452008-07-21 18:20:57 +0000120 if (self != NULL) {
Benny Prijono9c461142008-07-10 22:41:20 +0000121 self->realm = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +0000122 self->scheme = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +0000123 self->username = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +0000124 self->data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
125 self->data = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +0000126 }
127
128 return (PyObject *)self;
129}
130
131
132/*
133 * PyObj_pjsip_cred_info_members
134 */
135static PyMemberDef PyObj_pjsip_cred_info_members[] =
136{
137 {
138 "realm", T_OBJECT_EX,
139 offsetof(PyObj_pjsip_cred_info, realm), 0,
140 "Realm"
141 },
142 {
143 "scheme", T_OBJECT_EX,
144 offsetof(PyObj_pjsip_cred_info, scheme), 0,
145 "Scheme"
146 },
147 {
148 "username", T_OBJECT_EX,
149 offsetof(PyObj_pjsip_cred_info, username), 0,
150 "User name"
151 },
152 {
153 "data", T_OBJECT_EX,
154 offsetof(PyObj_pjsip_cred_info, data), 0,
155 "The data, which can be a plaintext password or a hashed digest, "
156 "depending on the value of data_type"
157 },
158 {
159 "data_type", T_INT,
160 offsetof(PyObj_pjsip_cred_info, data_type), 0,
161 "Type of data"
162 },
163
164 {NULL} /* Sentinel */
165};
166
167/*
168 * PyTyp_pjsip_cred_info
169 */
170static PyTypeObject PyTyp_pjsip_cred_info =
171{
172 PyObject_HEAD_INIT(NULL)
173 0, /*ob_size*/
174 "_pjsua.Pjsip_Cred_Info", /*tp_name*/
175 sizeof(PyObj_pjsip_cred_info), /*tp_basicsize*/
176 0, /*tp_itemsize*/
177 (destructor)PyObj_pjsip_cred_info_delete,/*tp_dealloc*/
178 0, /*tp_print*/
179 0, /*tp_getattr*/
180 0, /*tp_setattr*/
181 0, /*tp_compare*/
182 0, /*tp_repr*/
183 0, /*tp_as_number*/
184 0, /*tp_as_sequence*/
185 0, /*tp_as_mapping*/
186 0, /*tp_hash */
187 0, /*tp_call*/
188 0, /*tp_str*/
189 0, /*tp_getattro*/
190 0, /*tp_setattro*/
191 0, /*tp_as_buffer*/
192 Py_TPFLAGS_DEFAULT, /*tp_flags*/
193 "PJSIP credential information", /* tp_doc */
194 0, /* tp_traverse */
195 0, /* tp_clear */
196 0, /* tp_richcompare */
197 0, /* tp_weaklistoffset */
198 0, /* tp_iter */
199 0, /* tp_iternext */
200 0, /* tp_methods */
Benny Prijono55040452008-07-21 18:20:57 +0000201 PyObj_pjsip_cred_info_members, /* tp_members */
Benny Prijono9c461142008-07-10 22:41:20 +0000202 0, /* tp_getset */
203 0, /* tp_base */
204 0, /* tp_dict */
205 0, /* tp_descr_get */
206 0, /* tp_descr_set */
207 0, /* tp_dictoffset */
208 0, /* tp_init */
209 0, /* tp_alloc */
Benny Prijono55040452008-07-21 18:20:57 +0000210 PyObj_pjsip_cred_info_new, /* tp_new */
Benny Prijono9c461142008-07-10 22:41:20 +0000211
212};
213
214
215//////////////////////////////////////////////////////////////////////////////
216/*
Benny Prijono9c461142008-07-10 22:41:20 +0000217 * PyObj_pjsua_callback
218 * C/python typewrapper for callback struct
219 */
220typedef struct PyObj_pjsua_callback
221{
222 PyObject_HEAD
223 /* Type-specific fields go here. */
224 PyObject * on_call_state;
225 PyObject * on_incoming_call;
226 PyObject * on_call_media_state;
227 PyObject * on_dtmf_digit;
228 PyObject * on_call_transfer_request;
229 PyObject * on_call_transfer_status;
230 PyObject * on_call_replace_request;
231 PyObject * on_call_replaced;
232 PyObject * on_reg_state;
Benny Prijonoe6787ec2008-07-18 23:00:56 +0000233 PyObject * on_incoming_subscribe;
Benny Prijono9c461142008-07-10 22:41:20 +0000234 PyObject * on_buddy_state;
235 PyObject * on_pager;
236 PyObject * on_pager_status;
237 PyObject * on_typing;
238} PyObj_pjsua_callback;
239
240
241/*
242 * PyObj_pjsua_callback_delete
243 * destructor function for callback struct
244 */
245static void PyObj_pjsua_callback_delete(PyObj_pjsua_callback* self)
246{
247 Py_XDECREF(self->on_call_state);
248 Py_XDECREF(self->on_incoming_call);
249 Py_XDECREF(self->on_call_media_state);
250 Py_XDECREF(self->on_dtmf_digit);
251 Py_XDECREF(self->on_call_transfer_request);
252 Py_XDECREF(self->on_call_transfer_status);
253 Py_XDECREF(self->on_call_replace_request);
254 Py_XDECREF(self->on_call_replaced);
255 Py_XDECREF(self->on_reg_state);
Benny Prijonoe6787ec2008-07-18 23:00:56 +0000256 Py_XDECREF(self->on_incoming_subscribe);
Benny Prijono9c461142008-07-10 22:41:20 +0000257 Py_XDECREF(self->on_buddy_state);
258 Py_XDECREF(self->on_pager);
259 Py_XDECREF(self->on_pager_status);
260 Py_XDECREF(self->on_typing);
261 self->ob_type->tp_free((PyObject*)self);
262}
263
264
265/*
266 * PyObj_pjsua_callback_new
267 * * declares constructor for callback struct
268 */
269static PyObject * PyObj_pjsua_callback_new(PyTypeObject *type,
270 PyObject *args,
271 PyObject *kwds)
272{
273 PyObj_pjsua_callback *self;
274
275 PJ_UNUSED_ARG(args);
276 PJ_UNUSED_ARG(kwds);
277
278 self = (PyObj_pjsua_callback *)type->tp_alloc(type, 0);
Benny Prijono55040452008-07-21 18:20:57 +0000279 if (self != NULL) {
280 self->on_call_state = Py_BuildValue("");
281 self->on_incoming_call = Py_BuildValue("");
282 self->on_call_media_state = Py_BuildValue("");
283 self->on_dtmf_digit = Py_BuildValue("");
284 self->on_call_transfer_request = Py_BuildValue("");
285 self->on_call_transfer_status = Py_BuildValue("");
286 self->on_call_replace_request = Py_BuildValue("");
287 self->on_call_replaced = Py_BuildValue("");
288 self->on_reg_state = Py_BuildValue("");
289 self->on_incoming_subscribe = Py_BuildValue("");
290 self->on_buddy_state = Py_BuildValue("");
291 self->on_pager = Py_BuildValue("");
292 self->on_pager_status = Py_BuildValue("");
293 self->on_typing = Py_BuildValue("");
Benny Prijono9c461142008-07-10 22:41:20 +0000294 }
295
296 return (PyObject *)self;
297}
298
299
300/*
301 * PyObj_pjsua_callback_members
302 * declares available functions for callback object
303 */
304static PyMemberDef PyObj_pjsua_callback_members[] =
305{
306 {
307 "on_call_state", T_OBJECT_EX,
308 offsetof(PyObj_pjsua_callback, on_call_state), 0,
309 "Notify application when invite state has changed. Application may "
310 "then query the call info to get the detail call states."
311 },
312 {
313 "on_incoming_call", T_OBJECT_EX,
314 offsetof(PyObj_pjsua_callback, on_incoming_call), 0,
315 "Notify application on incoming call."
316 },
317 {
318 "on_call_media_state", T_OBJECT_EX,
319 offsetof(PyObj_pjsua_callback, on_call_media_state), 0,
320 "Notify application when media state in the call has changed. Normal "
321 "application would need to implement this callback, e.g. to connect "
322 "the call's media to sound device."
323 },
324 {
325 "on_dtmf_digit", T_OBJECT_EX,
326 offsetof(PyObj_pjsua_callback, on_dtmf_digit), 0,
327 "Notify application upon receiving incoming DTMF digit."
328 },
329 {
330 "on_call_transfer_request", T_OBJECT_EX,
331 offsetof(PyObj_pjsua_callback, on_call_transfer_request), 0,
332 "Notify application on call being transfered. "
333 "Application can decide to accept/reject transfer request "
334 "by setting the code (default is 200). When this callback "
335 "is not defined, the default behavior is to accept the "
336 "transfer."
337 },
338 {
339 "on_call_transfer_status", T_OBJECT_EX,
340 offsetof(PyObj_pjsua_callback, on_call_transfer_status), 0,
341 "Notify application of the status of previously sent call "
342 "transfer request. Application can monitor the status of the "
343 "call transfer request, for example to decide whether to "
344 "terminate existing call."
345 },
346 {
347 "on_call_replace_request", T_OBJECT_EX,
348 offsetof(PyObj_pjsua_callback, on_call_replace_request), 0,
349 "Notify application about incoming INVITE with Replaces header. "
350 "Application may reject the request by setting non-2xx code."
351 },
352 {
353 "on_call_replaced", T_OBJECT_EX,
354 offsetof(PyObj_pjsua_callback, on_call_replaced), 0,
355 "Notify application that an existing call has been replaced with "
356 "a new call. This happens when PJSUA-API receives incoming INVITE "
357 "request with Replaces header."
358 " "
359 "After this callback is called, normally PJSUA-API will disconnect "
360 "old_call_id and establish new_call_id."
361 },
362 {
363 "on_reg_state", T_OBJECT_EX,
364 offsetof(PyObj_pjsua_callback, on_reg_state), 0,
365 "Notify application when registration status has changed. Application "
366 "may then query the account info to get the registration details."
367 },
368 {
Benny Prijonoe6787ec2008-07-18 23:00:56 +0000369 "on_incoming_subscribe", T_OBJECT_EX,
370 offsetof(PyObj_pjsua_callback, on_incoming_subscribe), 0,
371 "Notification when incoming SUBSCRIBE request is received."
372 },
373 {
Benny Prijono9c461142008-07-10 22:41:20 +0000374 "on_buddy_state", T_OBJECT_EX,
375 offsetof(PyObj_pjsua_callback, on_buddy_state), 0,
376 "Notify application when the buddy state has changed. Application may "
377 "then query the buddy into to get the details."
378 },
379 {
380 "on_pager", T_OBJECT_EX,
381 offsetof(PyObj_pjsua_callback, on_pager), 0,
382 "Notify application on incoming pager (i.e. MESSAGE request). "
383 "Argument call_id will be -1 if MESSAGE request is not related to an "
384 "existing call."
385 },
386 {
387 "on_pager_status", T_OBJECT_EX,
388 offsetof(PyObj_pjsua_callback, on_pager_status), 0,
389 "Notify application about the delivery status of outgoing pager "
390 "request."
391 },
392 {
393 "on_typing", T_OBJECT_EX,
394 offsetof(PyObj_pjsua_callback, on_typing), 0,
395 "Notify application about typing indication."
396 },
397 {NULL} /* Sentinel */
398};
399
400
401/*
402 * PyTyp_pjsua_callback
403 * callback class definition
404 */
405static PyTypeObject PyTyp_pjsua_callback =
406{
407 PyObject_HEAD_INIT(NULL)
408 0, /*ob_size*/
409 "_pjsua.Callback", /*tp_name*/
410 sizeof(PyObj_pjsua_callback), /*tp_basicsize*/
411 0, /*tp_itemsize*/
412 (destructor)PyObj_pjsua_callback_delete, /*tp_dealloc*/
413 0, /*tp_print*/
414 0, /*tp_getattr*/
415 0, /*tp_setattr*/
416 0, /*tp_compare*/
417 0, /*tp_repr*/
418 0, /*tp_as_number*/
419 0, /*tp_as_sequence*/
420 0, /*tp_as_mapping*/
421 0, /*tp_hash */
422 0, /*tp_call*/
423 0, /*tp_str*/
424 0, /*tp_getattro*/
425 0, /*tp_setattro*/
426 0, /*tp_as_buffer*/
427 Py_TPFLAGS_DEFAULT, /*tp_flags*/
428 "This structure describes application callback "
429 "to receive various event notifications from "
430 "PJSUA-API", /* tp_doc */
431 0, /* tp_traverse */
432 0, /* tp_clear */
433 0, /* tp_richcompare */
434 0, /* tp_weaklistoffset */
435 0, /* tp_iter */
436 0, /* tp_iternext */
437 0, /* tp_methods */
438 PyObj_pjsua_callback_members, /* tp_members */
439 0, /* tp_getset */
440 0, /* tp_base */
441 0, /* tp_dict */
442 0, /* tp_descr_get */
443 0, /* tp_descr_set */
444 0, /* tp_dictoffset */
445 0, /* tp_init */
446 0, /* tp_alloc */
447 PyObj_pjsua_callback_new, /* tp_new */
448
449};
450
451
452//////////////////////////////////////////////////////////////////////////////
453/*
454 * PyObj_pjsua_media_config
455 * C/Python wrapper for pjsua_media_config object
456 */
457typedef struct
458{
459 PyObject_HEAD
460 /* Type-specific fields go here. */
461 unsigned clock_rate;
462 unsigned snd_clock_rate;
463 unsigned channel_count;
464 unsigned audio_frame_ptime;
465 int snd_auto_close_time;
466 unsigned max_media_ports;
467 int has_ioqueue;
468 unsigned thread_cnt;
469 unsigned quality;
470 unsigned ptime;
471 int no_vad;
472 unsigned ilbc_mode;
473 unsigned tx_drop_pct;
474 unsigned rx_drop_pct;
475 unsigned ec_options;
476 unsigned ec_tail_len;
477 int jb_min;
478 int jb_max;
479 int enable_ice;
480 int enable_turn;
481 PyObject *turn_server;
482 int turn_conn_type;
483 PyObject *turn_realm;
484 PyObject *turn_username;
485 int turn_passwd_type;
486 PyObject *turn_passwd;
487} PyObj_pjsua_media_config;
488
489
490/*
491 * PyObj_pjsua_media_config_members
492 * declares attributes accessible from both C and Python for media_config file
493 */
494static PyMemberDef PyObj_pjsua_media_config_members[] =
495{
496 {
497 "clock_rate", T_INT,
498 offsetof(PyObj_pjsua_media_config, clock_rate), 0,
499 "Clock rate to be applied to the conference bridge. If value is zero, "
500 "default clock rate will be used (16KHz)."
501 },
502 {
503 "snd_clock_rate", T_INT,
504 offsetof(PyObj_pjsua_media_config, snd_clock_rate), 0,
505 "Specify different clock rate of sound device, otherwise 0."
506 },
507 {
508 "channel_count", T_INT,
509 offsetof(PyObj_pjsua_media_config, channel_count), 0,
510 "Specify channel count (default 1)."
511 },
512 {
513 "audio_frame_ptime", T_INT,
514 offsetof(PyObj_pjsua_media_config, audio_frame_ptime), 0,
515 "Audio frame length in milliseconds."
516 },
517 {
518 "snd_auto_close_time", T_INT,
519 offsetof(PyObj_pjsua_media_config, snd_auto_close_time), 0,
520 "Sound idle time before it's closed."
521 },
522 {
523 "max_media_ports", T_INT,
524 offsetof(PyObj_pjsua_media_config, max_media_ports), 0,
525 "Specify maximum number of media ports to be created in the "
526 "conference bridge. Since all media terminate in the bridge (calls, "
527 "file player, file recorder, etc), the value must be large enough to "
528 "support all of them. However, the larger the value, the more "
529 "computations are performed."
530 },
531 {
532 "has_ioqueue", T_INT,
533 offsetof(PyObj_pjsua_media_config, has_ioqueue), 0,
534 "Specify whether the media manager should manage its own ioqueue for "
535 "the RTP/RTCP sockets. If yes, ioqueue will be created and at least "
536 "one worker thread will be created too. If no, the RTP/RTCP sockets "
537 "will share the same ioqueue as SIP sockets, and no worker thread is "
538 "needed."
539 },
540 {
541 "thread_cnt", T_INT,
542 offsetof(PyObj_pjsua_media_config, thread_cnt), 0,
543 "Specify the number of worker threads to handle incoming RTP packets. "
544 "A value of one is recommended for most applications."
545 },
546 {
547 "quality", T_INT,
548 offsetof(PyObj_pjsua_media_config, quality), 0,
549 "The media quality also sets speex codec quality/complexity to the "
550 "number."
551 },
552 {
553 "ptime", T_INT,
554 offsetof(PyObj_pjsua_media_config, ptime), 0,
555 "Specify default ptime."
556 },
557 {
558 "no_vad", T_INT,
559 offsetof(PyObj_pjsua_media_config, no_vad), 0,
560 "Disable VAD?"
561 },
562 {
563 "ilbc_mode", T_INT,
564 offsetof(PyObj_pjsua_media_config, ilbc_mode), 0,
565 "iLBC mode (20 or 30)."
566 },
567 {
568 "tx_drop_pct", T_INT,
569 offsetof(PyObj_pjsua_media_config, tx_drop_pct), 0,
570 "Percentage of RTP packet to drop in TX direction (to simulate packet "
571 "lost)."
572 },
573 {
574 "rx_drop_pct", T_INT,
575 offsetof(PyObj_pjsua_media_config, rx_drop_pct), 0,
576 "Percentage of RTP packet to drop in RX direction (to simulate packet "
577 "lost)."},
578 {
579 "ec_options", T_INT,
580 offsetof(PyObj_pjsua_media_config, ec_options), 0,
581 "Echo canceller options (see pjmedia_echo_create())"
582 },
583 {
584 "ec_tail_len", T_INT,
585 offsetof(PyObj_pjsua_media_config, ec_tail_len), 0,
586 "Echo canceller tail length, in miliseconds."
587 },
588 {
589 "jb_min", T_INT,
590 offsetof(PyObj_pjsua_media_config, jb_min), 0,
591 "Jitter buffer minimum size in milliseconds."
592 },
593 {
594 "jb_max", T_INT,
595 offsetof(PyObj_pjsua_media_config, jb_max), 0,
596 "Jitter buffer maximum size in milliseconds."
597 },
598 {
599 "enable_ice", T_INT,
600 offsetof(PyObj_pjsua_media_config, enable_ice), 0,
601 "Enable ICE."
602 },
603 {
604 "enable_turn", T_INT,
605 offsetof(PyObj_pjsua_media_config, enable_turn), 0,
606 "Enable TURN."
607 },
608 {
609 "turn_server", T_OBJECT_EX,
610 offsetof(PyObj_pjsua_media_config, turn_server), 0,
611 "Specify the TURN server."
612 },
613 {
614 "turn_conn_type", T_INT,
615 offsetof(PyObj_pjsua_media_config, turn_conn_type), 0,
616 "Specify TURN connection type."
617 },
618 {
619 "turn_realm", T_OBJECT_EX,
620 offsetof(PyObj_pjsua_media_config, turn_realm), 0,
621 "Specify the TURN realm."
622 },
623 {
624 "turn_username", T_OBJECT_EX,
625 offsetof(PyObj_pjsua_media_config, turn_username), 0,
626 "Specify the TURN username."
627 },
628 {
629 "turn_passwd_type", T_INT,
630 offsetof(PyObj_pjsua_media_config, turn_passwd_type), 0,
631 "Specify TURN password type."
632 },
633 {
Benny Prijono55040452008-07-21 18:20:57 +0000634 "turn_passwd", T_OBJECT_EX,
Benny Prijono9c461142008-07-10 22:41:20 +0000635 offsetof(PyObj_pjsua_media_config, turn_passwd), 0,
636 "Specify the TURN password."
637 },
638
639 {NULL} /* Sentinel */
640};
641
642
643static PyObject *PyObj_pjsua_media_config_new(PyTypeObject *type,
644 PyObject *args,
645 PyObject *kwds)
646{
647 PyObj_pjsua_media_config *self;
648
649 PJ_UNUSED_ARG(args);
650 PJ_UNUSED_ARG(kwds);
651
652 self = (PyObj_pjsua_media_config*)type->tp_alloc(type, 0);
Benny Prijono55040452008-07-21 18:20:57 +0000653 if (self != NULL) {
Benny Prijono9c461142008-07-10 22:41:20 +0000654 self->turn_server = PyString_FromString("");
655 self->turn_realm = PyString_FromString("");
656 self->turn_username = PyString_FromString("");
657 self->turn_passwd = PyString_FromString("");
658 }
659
660 return (PyObject *)self;
661}
662
663static void PyObj_pjsua_media_config_delete(PyObj_pjsua_media_config * self)
664{
665 Py_XDECREF(self->turn_server);
666 Py_XDECREF(self->turn_realm);
667 Py_XDECREF(self->turn_username);
668 Py_XDECREF(self->turn_passwd);
669 self->ob_type->tp_free((PyObject*)self);
670}
671
672static void PyObj_pjsua_media_config_import(PyObj_pjsua_media_config *obj,
673 const pjsua_media_config *cfg)
674{
675 obj->clock_rate = cfg->clock_rate;
676 obj->snd_clock_rate = cfg->snd_clock_rate;
677 obj->channel_count = cfg->channel_count;
678 obj->audio_frame_ptime = cfg->audio_frame_ptime;
679 obj->snd_auto_close_time= cfg->snd_auto_close_time;
680 obj->max_media_ports = cfg->max_media_ports;
681 obj->has_ioqueue = cfg->has_ioqueue;
682 obj->thread_cnt = cfg->thread_cnt;
683 obj->quality = cfg->quality;
684 obj->ptime = cfg->ptime;
685 obj->no_vad = cfg->no_vad;
686 obj->ilbc_mode = cfg->ilbc_mode;
687 obj->jb_min = cfg->jb_min_pre;
688 obj->jb_max = cfg->jb_max;
689 obj->tx_drop_pct = cfg->tx_drop_pct;
690 obj->rx_drop_pct = cfg->rx_drop_pct;
691 obj->ec_options = cfg->ec_options;
692 obj->ec_tail_len = cfg->ec_tail_len;
693 obj->enable_ice = cfg->enable_ice;
694 obj->enable_turn = cfg->enable_turn;
695 Py_XDECREF(obj->turn_server);
Benny Prijono55040452008-07-21 18:20:57 +0000696 obj->turn_server = PyString_FromPJ(&cfg->turn_server);
Benny Prijono9c461142008-07-10 22:41:20 +0000697 obj->turn_conn_type = cfg->turn_conn_type;
698 if (cfg->turn_auth_cred.type == PJ_STUN_AUTH_CRED_STATIC) {
699 const pj_stun_auth_cred *cred = &cfg->turn_auth_cred;
700
701 Py_XDECREF(obj->turn_realm);
Benny Prijono55040452008-07-21 18:20:57 +0000702 obj->turn_realm = PyString_FromPJ(&cred->data.static_cred.realm);
Benny Prijono9c461142008-07-10 22:41:20 +0000703 Py_XDECREF(obj->turn_username);
Benny Prijono55040452008-07-21 18:20:57 +0000704 obj->turn_username = PyString_FromPJ(&cred->data.static_cred.username);
Benny Prijono9c461142008-07-10 22:41:20 +0000705 obj->turn_passwd_type = cred->data.static_cred.data_type;
706 Py_XDECREF(obj->turn_passwd);
Benny Prijono55040452008-07-21 18:20:57 +0000707 obj->turn_passwd = PyString_FromPJ(&cred->data.static_cred.data);
Benny Prijono9c461142008-07-10 22:41:20 +0000708 } else {
709 Py_XDECREF(obj->turn_realm);
710 obj->turn_realm = PyString_FromString("");
711 Py_XDECREF(obj->turn_username);
712 obj->turn_username = PyString_FromString("");
713 obj->turn_passwd_type = 0;
714 Py_XDECREF(obj->turn_passwd);
715 obj->turn_passwd = PyString_FromString("");
716 }
717}
718
719static void PyObj_pjsua_media_config_export(pjsua_media_config *cfg,
720 const PyObj_pjsua_media_config *obj)
721{
722 cfg->clock_rate = obj->clock_rate;
723 cfg->snd_clock_rate = obj->snd_clock_rate;
724 cfg->channel_count = obj->channel_count;
725 cfg->audio_frame_ptime = obj->audio_frame_ptime;
726 cfg->snd_auto_close_time=obj->snd_auto_close_time;
727 cfg->max_media_ports = obj->max_media_ports;
728 cfg->has_ioqueue = obj->has_ioqueue;
729 cfg->thread_cnt = obj->thread_cnt;
730 cfg->quality = obj->quality;
731 cfg->ptime = obj->ptime;
732 cfg->no_vad = obj->no_vad;
733 cfg->jb_min_pre = obj->jb_min;
734 cfg->jb_max = obj->jb_max;
735 cfg->ilbc_mode = obj->ilbc_mode;
736 cfg->tx_drop_pct = obj->tx_drop_pct;
737 cfg->rx_drop_pct = obj->rx_drop_pct;
738 cfg->ec_options = obj->ec_options;
739 cfg->ec_tail_len = obj->ec_tail_len;
740 cfg->enable_ice = obj->enable_ice;
741 cfg->enable_turn = obj->enable_turn;
742
743 if (cfg->enable_turn) {
Benny Prijono55040452008-07-21 18:20:57 +0000744 cfg->turn_server = PyString_ToPJ(obj->turn_server);
Benny Prijono9c461142008-07-10 22:41:20 +0000745 cfg->turn_conn_type = obj->turn_conn_type;
746 cfg->turn_auth_cred.type = PJ_STUN_AUTH_CRED_STATIC;
Benny Prijono55040452008-07-21 18:20:57 +0000747 cfg->turn_auth_cred.data.static_cred.realm = PyString_ToPJ(obj->turn_realm);
748 cfg->turn_auth_cred.data.static_cred.username = PyString_ToPJ(obj->turn_username);
Benny Prijono9c461142008-07-10 22:41:20 +0000749 cfg->turn_auth_cred.data.static_cred.data_type= obj->turn_passwd_type;
Benny Prijono55040452008-07-21 18:20:57 +0000750 cfg->turn_auth_cred.data.static_cred.data = PyString_ToPJ(obj->turn_passwd);
Benny Prijono9c461142008-07-10 22:41:20 +0000751 }
752}
753
754
755/*
756 * PyTyp_pjsua_media_config
757 */
758static PyTypeObject PyTyp_pjsua_media_config =
759{
760 PyObject_HEAD_INIT(NULL)
761 0, /*ob_size*/
762 "_pjsua.Media_Config", /*tp_name*/
763 sizeof(PyObj_pjsua_media_config),/*tp_basicsize*/
764 0, /*tp_itemsize*/
765 (destructor)PyObj_pjsua_media_config_delete,/*tp_dealloc*/
766 0, /*tp_print*/
767 0, /*tp_getattr*/
768 0, /*tp_setattr*/
769 0, /*tp_compare*/
770 0, /*tp_repr*/
771 0, /*tp_as_number*/
772 0, /*tp_as_sequence*/
773 0, /*tp_as_mapping*/
774 0, /*tp_hash */
775 0, /*tp_call*/
776 0, /*tp_str*/
777 0, /*tp_getattro*/
778 0, /*tp_setattro*/
779 0, /*tp_as_buffer*/
780 Py_TPFLAGS_DEFAULT, /*tp_flags*/
781 "Media Config objects", /*tp_doc*/
782 0, /*tp_traverse*/
783 0, /*tp_clear*/
784 0, /*tp_richcompare*/
785 0, /* tp_weaklistoffset */
786 0, /* tp_iter */
787 0, /* tp_iternext */
788 0, /* tp_methods */
789 PyObj_pjsua_media_config_members, /* tp_members */
790 0, /* tp_getset */
791 0, /* tp_base */
792 0, /* tp_dict */
793 0, /* tp_descr_get */
794 0, /* tp_descr_set */
795 0, /* tp_dictoffset */
796 0, /* tp_init */
797 0, /* tp_alloc */
798 PyObj_pjsua_media_config_new, /* tp_new */
799};
800
801
802//////////////////////////////////////////////////////////////////////////////
803/*
804 * PyObj_pjsua_config
805 * attribute list for config object
806 */
807typedef struct
808{
809 PyObject_HEAD
810 /* Type-specific fields go here. */
811 unsigned max_calls;
812 unsigned thread_cnt;
813 PyObject *outbound_proxy;
814 PyObject *stun_domain;
815 PyObject *stun_host;
816 PyListObject *nameserver;
817 PyObj_pjsua_callback *cb;
818 PyObject *user_agent;
819} PyObj_pjsua_config;
820
821
822static void PyObj_pjsua_config_delete(PyObj_pjsua_config* self)
823{
824 Py_XDECREF(self->outbound_proxy);
825 Py_XDECREF(self->stun_domain);
826 Py_XDECREF(self->stun_host);
827 Py_XDECREF(self->nameserver);
828 Py_XDECREF(self->cb);
829 Py_XDECREF(self->user_agent);
830 self->ob_type->tp_free((PyObject*)self);
831}
832
833
834static void PyObj_pjsua_config_import(PyObj_pjsua_config *obj,
835 const pjsua_config *cfg)
836{
837 unsigned i;
838
839 obj->max_calls = cfg->max_calls;
840 obj->thread_cnt = cfg->thread_cnt;
841 Py_XDECREF(obj->outbound_proxy);
Benny Prijono55040452008-07-21 18:20:57 +0000842 if (cfg->outbound_proxy_cnt)
843 obj->outbound_proxy = PyString_FromPJ(&cfg->outbound_proxy[0]);
844 else
845 obj->outbound_proxy = PyString_FromString("");
846
Benny Prijono9c461142008-07-10 22:41:20 +0000847 Py_XDECREF(obj->stun_domain);
Benny Prijono55040452008-07-21 18:20:57 +0000848 obj->stun_domain = PyString_FromPJ(&cfg->stun_domain);
Benny Prijono9c461142008-07-10 22:41:20 +0000849 Py_XDECREF(obj->stun_host);
Benny Prijono55040452008-07-21 18:20:57 +0000850 obj->stun_host = PyString_FromPJ(&cfg->stun_host);
Benny Prijono9c461142008-07-10 22:41:20 +0000851 Py_XDECREF(obj->nameserver);
852 obj->nameserver = (PyListObject *)PyList_New(0);
853 for (i=0; i<cfg->nameserver_count; ++i) {
854 PyObject * str;
Benny Prijono55040452008-07-21 18:20:57 +0000855 str = PyString_FromPJ(&cfg->nameserver[i]);
Benny Prijono9c461142008-07-10 22:41:20 +0000856 PyList_Append((PyObject *)obj->nameserver, str);
857 }
858 Py_XDECREF(obj->user_agent);
Benny Prijono55040452008-07-21 18:20:57 +0000859 obj->user_agent = PyString_FromPJ(&cfg->user_agent);
Benny Prijono9c461142008-07-10 22:41:20 +0000860}
861
862
863static void PyObj_pjsua_config_export(pjsua_config *cfg,
864 PyObj_pjsua_config *obj)
865{
866 unsigned i;
867
868 cfg->max_calls = obj->max_calls;
869 cfg->thread_cnt = obj->thread_cnt;
870 if (PyString_Size(obj->outbound_proxy) > 0) {
871 cfg->outbound_proxy_cnt = 1;
Benny Prijono55040452008-07-21 18:20:57 +0000872 cfg->outbound_proxy[0] = PyString_ToPJ(obj->outbound_proxy);
Benny Prijono9c461142008-07-10 22:41:20 +0000873 } else {
874 cfg->outbound_proxy_cnt = 0;
875 }
876 cfg->nameserver_count = PyList_Size((PyObject*)obj->nameserver);
877 if (cfg->nameserver_count > PJ_ARRAY_SIZE(cfg->nameserver))
878 cfg->nameserver_count = PJ_ARRAY_SIZE(cfg->nameserver);
879 for (i = 0; i < cfg->nameserver_count; i++) {
Benny Prijono55040452008-07-21 18:20:57 +0000880 PyObject *item = PyList_GetItem((PyObject *)obj->nameserver,i);
881 cfg->nameserver[i] = PyString_ToPJ(item);
Benny Prijono9c461142008-07-10 22:41:20 +0000882 }
Benny Prijono55040452008-07-21 18:20:57 +0000883 cfg->stun_domain = PyString_ToPJ(obj->stun_domain);
884 cfg->stun_host = PyString_ToPJ(obj->stun_host);
885 cfg->user_agent = PyString_ToPJ(obj->user_agent);
Benny Prijono9c461142008-07-10 22:41:20 +0000886
887}
888
889
890static PyObject *PyObj_pjsua_config_new(PyTypeObject *type,
891 PyObject *args,
892 PyObject *kwds)
893{
894 PyObj_pjsua_config *self;
895
896 PJ_UNUSED_ARG(args);
897 PJ_UNUSED_ARG(kwds);
898
899 self = (PyObj_pjsua_config *)type->tp_alloc(type, 0);
Benny Prijono55040452008-07-21 18:20:57 +0000900 if (self != NULL) {
Benny Prijono9c461142008-07-10 22:41:20 +0000901 self->user_agent = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +0000902 self->outbound_proxy = PyString_FromString("");
Benny Prijono55040452008-07-21 18:20:57 +0000903 self->stun_domain = PyString_FromString("");
904 self->stun_host = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +0000905 self->cb = (PyObj_pjsua_callback *)
906 PyType_GenericNew(&PyTyp_pjsua_callback, NULL, NULL);
Benny Prijono9c461142008-07-10 22:41:20 +0000907 }
908 return (PyObject *)self;
909}
910
911
912/*
913 * PyObj_pjsua_config_members
914 * attribute list accessible from Python/C
915 */
916static PyMemberDef PyObj_pjsua_config_members[] =
917{
918 {
919 "max_calls", T_INT,
920 offsetof(PyObj_pjsua_config, max_calls), 0,
921 "Maximum calls to support (default: 4) "
922 },
923 {
924 "thread_cnt", T_INT,
925 offsetof(PyObj_pjsua_config, thread_cnt), 0,
926 "Number of worker threads. Normally application will want to have at "
927 "least one worker thread, unless when it wants to poll the library "
928 "periodically, which in this case the worker thread can be set to "
929 "zero."
930 },
931 {
932 "outbound_proxy", T_OBJECT_EX,
933 offsetof(PyObj_pjsua_config, outbound_proxy), 0,
934 "SIP URL of the outbound proxy (optional)"
935 },
936 {
937 "stun_domain", T_OBJECT_EX,
938 offsetof(PyObj_pjsua_config, stun_domain), 0,
939 "Domain of the STUN server (optional). STUN server will be resolved "
940 "using DNS SRV resolution only when nameserver is configured. "
941 "Alternatively, if DNS SRV resolution for STUN is not desired, "
942 "application can specify the STUN server hostname or IP address "
943 "in stun_host attribute."
944 },
945 {
946 "stun_host", T_OBJECT_EX,
947 offsetof(PyObj_pjsua_config, stun_host), 0,
948 "Hostname or IP address of the STUN server (optional)."
949 },
950 {
951 "nameserver", T_OBJECT_EX,
952 offsetof(PyObj_pjsua_config, nameserver), 0,
953 "IP address of the nameserver."
954 },
955 {
956 "cb", T_OBJECT_EX, offsetof(PyObj_pjsua_config, cb), 0,
957 "Application callback."
958 },
959 {
960 "user_agent", T_OBJECT_EX, offsetof(PyObj_pjsua_config, user_agent), 0,
961 "User agent string (default empty)"
962 },
963 {NULL} /* Sentinel */
964};
965
966
967/*
968 * PyTyp_pjsua_config
969 * type wrapper for config class
970 */
971static PyTypeObject PyTyp_pjsua_config =
972{
973 PyObject_HEAD_INIT(NULL)
974 0, /*ob_size*/
975 "_pjsua.Config", /*tp_name*/
976 sizeof(PyObj_pjsua_config),/*tp_basicsize*/
977 0, /*tp_itemsize*/
978 (destructor)PyObj_pjsua_config_delete,/*tp_dealloc*/
979 0, /*tp_print*/
980 0, /*tp_getattr*/
981 0, /*tp_setattr*/
982 0, /*tp_compare*/
983 0, /*tp_repr*/
984 0, /*tp_as_number*/
985 0, /*tp_as_sequence*/
986 0, /*tp_as_mapping*/
987 0, /*tp_hash */
988 0, /*tp_call*/
989 0, /*tp_str*/
990 0, /*tp_getattro*/
991 0, /*tp_setattro*/
992 0, /*tp_as_buffer*/
993 Py_TPFLAGS_DEFAULT, /*tp_flags*/
994 "Config object", /* tp_doc */
995 0, /* tp_traverse */
996 0, /* tp_clear */
997 0, /* tp_richcompare */
998 0, /* tp_weaklistoffset */
999 0, /* tp_iter */
1000 0, /* tp_iternext */
1001 0, /* tp_methods */
1002 PyObj_pjsua_config_members,/* tp_members */
1003 0, /* tp_getset */
1004 0, /* tp_base */
1005 0, /* tp_dict */
1006 0, /* tp_descr_get */
1007 0, /* tp_descr_set */
1008 0, /* tp_dictoffset */
1009 0, /* tp_init */
1010 0, /* tp_alloc */
1011 PyObj_pjsua_config_new, /* tp_new */
1012
1013};
1014
1015//////////////////////////////////////////////////////////////////////////////
1016/*
1017 * PyObj_pjsua_logging_config
1018 * configuration class for logging_config object
1019 */
1020typedef struct
1021{
1022 PyObject_HEAD
1023 /* Type-specific fields go here. */
1024 int msg_logging;
1025 unsigned level;
1026 unsigned console_level;
1027 unsigned decor;
1028 PyObject *log_filename;
1029 PyObject *cb;
1030} PyObj_pjsua_logging_config;
1031
1032
1033/*
1034 * PyObj_pjsua_logging_config_delete
1035 * deletes a logging config from memory
1036 */
1037static void PyObj_pjsua_logging_config_delete(PyObj_pjsua_logging_config* self)
1038{
1039 Py_XDECREF(self->log_filename);
1040 Py_XDECREF(self->cb);
1041 self->ob_type->tp_free((PyObject*)self);
1042}
1043
1044
1045static void PyObj_pjsua_logging_config_import(PyObj_pjsua_logging_config *obj,
1046 const pjsua_logging_config *cfg)
1047{
1048 obj->msg_logging = cfg->msg_logging;
1049 obj->level = cfg->level;
1050 obj->console_level = cfg->console_level;
1051 obj->decor = cfg->decor;
Benny Prijono55040452008-07-21 18:20:57 +00001052 Py_XDECREF(obj->log_filename);
1053 obj->log_filename = PyString_FromPJ(&cfg->log_filename);
Benny Prijono9c461142008-07-10 22:41:20 +00001054}
1055
1056static void PyObj_pjsua_logging_config_export(pjsua_logging_config *cfg,
1057 PyObj_pjsua_logging_config *obj)
1058{
1059 cfg->msg_logging = obj->msg_logging;
1060 cfg->level = obj->level;
1061 cfg->console_level = obj->console_level;
1062 cfg->decor = obj->decor;
Benny Prijono55040452008-07-21 18:20:57 +00001063 cfg->log_filename = PyString_ToPJ(obj->log_filename);
Benny Prijono9c461142008-07-10 22:41:20 +00001064}
1065
1066
1067/*
1068 * PyObj_pjsua_logging_config_new
1069 * constructor for logging_config object
1070 */
1071static PyObject * PyObj_pjsua_logging_config_new(PyTypeObject *type,
1072 PyObject *args,
1073 PyObject *kwds)
1074{
1075 PyObj_pjsua_logging_config *self;
1076
1077 PJ_UNUSED_ARG(args);
1078 PJ_UNUSED_ARG(kwds);
1079
1080 self = (PyObj_pjsua_logging_config *)type->tp_alloc(type, 0);
Benny Prijono55040452008-07-21 18:20:57 +00001081 if (self != NULL) {
Benny Prijono9c461142008-07-10 22:41:20 +00001082 self->log_filename = PyString_FromString("");
Benny Prijono55040452008-07-21 18:20:57 +00001083 self->cb = Py_BuildValue("");
Benny Prijono9c461142008-07-10 22:41:20 +00001084 }
1085
1086 return (PyObject *)self;
1087}
1088
1089
1090/*
1091 * PyObj_pjsua_logging_config_members
1092 */
1093static PyMemberDef PyObj_pjsua_logging_config_members[] =
1094{
1095 {
1096 "msg_logging", T_INT,
1097 offsetof(PyObj_pjsua_logging_config, msg_logging), 0,
1098 "Log incoming and outgoing SIP message? Yes!"
1099 },
1100 {
1101 "level", T_INT,
1102 offsetof(PyObj_pjsua_logging_config, level), 0,
1103 "Input verbosity level. Value 5 is reasonable."
1104 },
1105 {
1106 "console_level", T_INT,
1107 offsetof(PyObj_pjsua_logging_config, console_level),
1108 0, "Verbosity level for console. Value 4 is reasonable."
1109 },
1110 {
1111 "decor", T_INT,
1112 offsetof(PyObj_pjsua_logging_config, decor), 0,
1113 "Log decoration"
1114 },
1115 {
1116 "log_filename", T_OBJECT_EX,
1117 offsetof(PyObj_pjsua_logging_config, log_filename), 0,
1118 "Optional log filename"
1119 },
1120 {
1121 "cb", T_OBJECT_EX,
1122 offsetof(PyObj_pjsua_logging_config, cb), 0,
1123 "Optional callback function to be called to write log to application "
1124 "specific device. This function will be called forlog messages on "
1125 "input verbosity level."
1126 },
1127 {NULL} /* Sentinel */
1128};
1129
1130
1131
1132
1133/*
1134 * PyTyp_pjsua_logging_config
1135 */
1136static PyTypeObject PyTyp_pjsua_logging_config =
1137{
1138 PyObject_HEAD_INIT(NULL)
1139 0, /*ob_size*/
1140 "_pjsua.Logging_Config", /*tp_name*/
1141 sizeof(PyObj_pjsua_logging_config), /*tp_basicsize*/
1142 0, /*tp_itemsize*/
1143 (destructor)PyObj_pjsua_logging_config_delete,/*tp_dealloc*/
1144 0, /*tp_print*/
1145 0, /*tp_getattr*/
1146 0, /*tp_setattr*/
1147 0, /*tp_compare*/
1148 0, /*tp_repr*/
1149 0, /*tp_as_number*/
1150 0, /*tp_as_sequence*/
1151 0, /*tp_as_mapping*/
1152 0, /*tp_hash */
1153 0, /*tp_call*/
1154 0, /*tp_str*/
1155 0, /*tp_getattro*/
1156 0, /*tp_setattro*/
1157 0, /*tp_as_buffer*/
1158 Py_TPFLAGS_DEFAULT, /*tp_flags*/
1159 "Logging Config objects", /* tp_doc */
1160 0, /* tp_traverse */
1161 0, /* tp_clear */
1162 0, /* tp_richcompare */
1163 0, /* tp_weaklistoffset */
1164 0, /* tp_iter */
1165 0, /* tp_iternext */
1166 0, /* tp_methods */
1167 PyObj_pjsua_logging_config_members,/* tp_members */
1168 0, /* tp_getset */
1169 0, /* tp_base */
1170 0, /* tp_dict */
1171 0, /* tp_descr_get */
1172 0, /* tp_descr_set */
1173 0, /* tp_dictoffset */
1174 0, /* tp_init */
1175 0, /* tp_alloc */
1176 PyObj_pjsua_logging_config_new, /* tp_new */
1177
1178};
1179
1180
1181//////////////////////////////////////////////////////////////////////////////
1182/*
1183 * PyObj_pjsua_msg_data
1184 * typewrapper for MessageData class
1185 * !modified @ 061206
1186 */
1187typedef struct
1188{
1189 PyObject_HEAD
1190 /* Type-specific fields go here. */
1191 PyObject * hdr_list;
1192 PyObject * content_type;
1193 PyObject * msg_body;
1194} PyObj_pjsua_msg_data;
1195
1196
1197/*
1198 * PyObj_pjsua_msg_data_delete
1199 * deletes a msg_data
1200 * !modified @ 061206
1201 */
1202static void PyObj_pjsua_msg_data_delete(PyObj_pjsua_msg_data* self)
1203{
1204 Py_XDECREF(self->hdr_list);
1205 Py_XDECREF(self->content_type);
1206 Py_XDECREF(self->msg_body);
1207 self->ob_type->tp_free((PyObject*)self);
1208}
1209
1210
1211/*
1212 * PyObj_pjsua_msg_data_new
1213 * constructor for msg_data object
1214 * !modified @ 061206
1215 */
1216static PyObject * PyObj_pjsua_msg_data_new(PyTypeObject *type,
1217 PyObject *args,
1218 PyObject *kwds)
1219{
1220 PyObj_pjsua_msg_data *self;
1221
1222 PJ_UNUSED_ARG(args);
1223 PJ_UNUSED_ARG(kwds);
1224
1225 self = (PyObj_pjsua_msg_data *)type->tp_alloc(type, 0);
Benny Prijono55040452008-07-21 18:20:57 +00001226 if (self != NULL) {
1227 self->hdr_list = PyList_New(0);
Benny Prijono9c461142008-07-10 22:41:20 +00001228 self->content_type = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001229 self->msg_body = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001230 }
1231
1232 return (PyObject *)self;
1233}
1234
1235
1236/*
1237 * PyObj_pjsua_msg_data_members
1238 * !modified @ 061206
1239 */
1240static PyMemberDef PyObj_pjsua_msg_data_members[] =
1241{
1242 {
1243 "hdr_list", T_OBJECT_EX,
1244 offsetof(PyObj_pjsua_msg_data, hdr_list), 0,
1245 "Additional message headers as linked list of strings."
1246 },
1247 {
1248 "content_type", T_OBJECT_EX,
1249 offsetof(PyObj_pjsua_msg_data, content_type), 0,
1250 "MIME type of optional message body."
1251 },
1252 {
1253 "msg_body", T_OBJECT_EX,
1254 offsetof(PyObj_pjsua_msg_data, msg_body), 0,
1255 "Optional message body."
1256 },
1257 {NULL} /* Sentinel */
1258};
1259
1260
1261/*
1262 * PyTyp_pjsua_msg_data
1263 */
1264static PyTypeObject PyTyp_pjsua_msg_data =
1265{
1266 PyObject_HEAD_INIT(NULL)
1267 0, /*ob_size*/
1268 "_pjsua.Msg_Data", /*tp_name*/
1269 sizeof(PyObj_pjsua_msg_data), /*tp_basicsize*/
1270 0, /*tp_itemsize*/
1271 (destructor)PyObj_pjsua_msg_data_delete,/*tp_dealloc*/
1272 0, /*tp_print*/
1273 0, /*tp_getattr*/
1274 0, /*tp_setattr*/
1275 0, /*tp_compare*/
1276 0, /*tp_repr*/
1277 0, /*tp_as_number*/
1278 0, /*tp_as_sequence*/
1279 0, /*tp_as_mapping*/
1280 0, /*tp_hash */
1281 0, /*tp_call*/
1282 0, /*tp_str*/
1283 0, /*tp_getattro*/
1284 0, /*tp_setattro*/
1285 0, /*tp_as_buffer*/
1286 Py_TPFLAGS_DEFAULT, /*tp_flags*/
1287 "msg_data objects", /* tp_doc */
1288 0, /* tp_traverse */
1289 0, /* tp_clear */
1290 0, /* tp_richcompare */
1291 0, /* tp_weaklistoffset */
1292 0, /* tp_iter */
1293 0, /* tp_iternext */
1294 0, /* tp_methods */
1295 PyObj_pjsua_msg_data_members, /* tp_members */
1296 0, /* tp_getset */
1297 0, /* tp_base */
1298 0, /* tp_dict */
1299 0, /* tp_descr_get */
1300 0, /* tp_descr_set */
1301 0, /* tp_dictoffset */
1302 0, /* tp_init */
1303 0, /* tp_alloc */
1304 PyObj_pjsua_msg_data_new, /* tp_new */
1305
1306};
1307
1308
1309//////////////////////////////////////////////////////////////////////////////
1310/*
1311 * PyObj_pjsua_transport_config
1312 * Transport configuration for creating UDP transports for both SIP
1313 * and media.
1314 */
1315typedef struct
1316{
1317 PyObject_HEAD
1318 /* Type-specific fields go here. */
1319 unsigned port;
1320 PyObject *public_addr;
1321 PyObject *bound_addr;
1322} PyObj_pjsua_transport_config;
1323
1324
1325/*
1326 * PyObj_pjsua_transport_config_delete
1327 * deletes a transport config from memory
1328 */
1329static void PyObj_pjsua_transport_config_delete(PyObj_pjsua_transport_config* self)
1330{
1331 Py_XDECREF(self->public_addr);
1332 Py_XDECREF(self->bound_addr);
1333 self->ob_type->tp_free((PyObject*)self);
1334}
1335
1336
1337static void PyObj_pjsua_transport_config_export(pjsua_transport_config *cfg,
1338 PyObj_pjsua_transport_config *obj)
1339{
Benny Prijono55040452008-07-21 18:20:57 +00001340 cfg->public_addr = PyString_ToPJ(obj->public_addr);
1341 cfg->bound_addr = PyString_ToPJ(obj->bound_addr);
Benny Prijono9c461142008-07-10 22:41:20 +00001342 cfg->port = obj->port;
1343
1344}
1345
1346static void PyObj_pjsua_transport_config_import(PyObj_pjsua_transport_config *obj,
1347 const pjsua_transport_config *cfg)
1348{
1349 Py_XDECREF(obj->public_addr);
Benny Prijono55040452008-07-21 18:20:57 +00001350 obj->public_addr = PyString_FromPJ(&cfg->public_addr);
Benny Prijono9c461142008-07-10 22:41:20 +00001351
1352 Py_XDECREF(obj->bound_addr);
Benny Prijono55040452008-07-21 18:20:57 +00001353 obj->bound_addr = PyString_FromPJ(&cfg->bound_addr);
Benny Prijono9c461142008-07-10 22:41:20 +00001354
1355 obj->port = cfg->port;
1356}
1357
1358
1359/*
1360 * PyObj_pjsua_transport_config_new
1361 * constructor for transport_config object
1362 */
1363static PyObject * PyObj_pjsua_transport_config_new(PyTypeObject *type,
1364 PyObject *args,
1365 PyObject *kwds)
1366{
1367 PyObj_pjsua_transport_config *self;
1368
1369 PJ_UNUSED_ARG(args);
1370 PJ_UNUSED_ARG(kwds);
1371
1372 self = (PyObj_pjsua_transport_config *)type->tp_alloc(type, 0);
1373 if (self != NULL) {
1374 self->public_addr = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001375 self->bound_addr = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001376 }
1377
1378 return (PyObject *)self;
1379}
1380
1381
1382/*
1383 * PyObj_pjsua_transport_config_members
1384 */
1385static PyMemberDef PyObj_pjsua_transport_config_members[] =
1386{
1387 {
1388 "port", T_INT,
1389 offsetof(PyObj_pjsua_transport_config, port), 0,
1390 "UDP port number to bind locally. This setting MUST be specified "
1391 "even when default port is desired. If the value is zero, the "
1392 "transport will be bound to any available port, and application "
1393 "can query the port by querying the transport info."
1394 },
1395 {
1396 "public_addr", T_OBJECT_EX,
1397 offsetof(PyObj_pjsua_transport_config, public_addr), 0,
1398 "Optional address to advertise as the address of this transport. "
1399 "Application can specify any address or hostname for this field, "
1400 "for example it can point to one of the interface address in the "
1401 "system, or it can point to the public address of a NAT router "
1402 "where port mappings have been configured for the application."
1403 },
1404 {
1405 "bound_addr", T_OBJECT_EX,
1406 offsetof(PyObj_pjsua_transport_config, bound_addr), 0,
1407 "Optional address where the socket should be bound to. This option "
1408 "SHOULD only be used to selectively bind the socket to particular "
1409 "interface (instead of 0.0.0.0), and SHOULD NOT be used to set the "
1410 "published address of a transport (the public_addr field should be "
1411 "used for that purpose)."
1412 },
1413 {NULL} /* Sentinel */
1414};
1415
1416
1417
1418
1419/*
1420 * PyTyp_pjsua_transport_config
1421 */
1422static PyTypeObject PyTyp_pjsua_transport_config =
1423{
1424 PyObject_HEAD_INIT(NULL)
1425 0, /*ob_size*/
1426 "_pjsua.Transport_Config", /*tp_name*/
1427 sizeof(PyObj_pjsua_transport_config), /*tp_basicsize*/
1428 0, /*tp_itemsize*/
1429 (destructor)PyObj_pjsua_transport_config_delete,/*tp_dealloc*/
1430 0, /*tp_print*/
1431 0, /*tp_getattr*/
1432 0, /*tp_setattr*/
1433 0, /*tp_compare*/
1434 0, /*tp_repr*/
1435 0, /*tp_as_number*/
1436 0, /*tp_as_sequence*/
1437 0, /*tp_as_mapping*/
1438 0, /*tp_hash */
1439 0, /*tp_call*/
1440 0, /*tp_str*/
1441 0, /*tp_getattro*/
1442 0, /*tp_setattro*/
1443 0, /*tp_as_buffer*/
1444 Py_TPFLAGS_DEFAULT, /*tp_flags*/
1445 "Transport setting", /* tp_doc */
1446 0, /* tp_traverse */
1447 0, /* tp_clear */
1448 0, /* tp_richcompare */
1449 0, /* tp_weaklistoffset */
1450 0, /* tp_iter */
1451 0, /* tp_iternext */
1452 0, /* tp_methods */
1453 PyObj_pjsua_transport_config_members,/* tp_members */
1454 0, /* tp_getset */
1455 0, /* tp_base */
1456 0, /* tp_dict */
1457 0, /* tp_descr_get */
1458 0, /* tp_descr_set */
1459 0, /* tp_dictoffset */
1460 0, /* tp_init */
1461 0, /* tp_alloc */
1462 PyObj_pjsua_transport_config_new,/* tp_new */
1463};
1464
1465
1466//////////////////////////////////////////////////////////////////////////////
1467/*
1468 * PyObj_pjsua_transport_info
1469 * Transport info
1470 */
1471typedef struct
1472{
1473 PyObject_HEAD
1474 /* Type-specific fields go here. */
1475 int id;
1476 int type;
1477 PyObject *type_name;
1478 PyObject *info;
1479 unsigned flag;
1480 PyObject *addr;
1481 unsigned port;
1482 unsigned usage_count;
1483} PyObj_pjsua_transport_info;
1484
1485
1486/*
1487 * PyObj_pjsua_transport_info_delete
1488 * deletes a transport info from memory
1489 */
1490static void PyObj_pjsua_transport_info_delete(PyObj_pjsua_transport_info* self)
1491{
1492 Py_XDECREF(self->type_name);
1493 Py_XDECREF(self->info);
1494 Py_XDECREF(self->addr);
1495 self->ob_type->tp_free((PyObject*)self);
1496}
1497
1498
1499static void PyObj_pjsua_transport_info_import(PyObj_pjsua_transport_info *obj,
1500 const pjsua_transport_info *info)
1501{
1502 obj->id = info->id;
1503 obj->type = info->type;
Benny Prijono55040452008-07-21 18:20:57 +00001504 obj->type_name = PyString_FromPJ(&info->type_name);
1505 obj->info = PyString_FromPJ(&info->info);
Benny Prijono9c461142008-07-10 22:41:20 +00001506 obj->flag = info->flag;
Benny Prijono55040452008-07-21 18:20:57 +00001507 obj->addr = PyString_FromPJ(&info->local_name.host);
Benny Prijono9c461142008-07-10 22:41:20 +00001508 obj->port = info->local_name.port;
1509 obj->usage_count= info->usage_count;
1510}
1511
1512/*
1513 * PyObj_pjsua_transport_info_new
1514 * constructor for transport_info object
1515 */
1516static PyObject * PyObj_pjsua_transport_info_new(PyTypeObject *type,
1517 PyObject *args,
1518 PyObject *kwds)
1519{
1520 PyObj_pjsua_transport_info *self;
1521
1522 PJ_UNUSED_ARG(args);
1523 PJ_UNUSED_ARG(kwds);
1524
1525 self = (PyObj_pjsua_transport_info *)type->tp_alloc(type, 0);
1526 if (self != NULL)
1527 {
1528 self->type_name = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001529 self->info = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001530 self->addr = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001531 }
1532
1533 return (PyObject *)self;
1534}
1535
1536
1537/*
1538 * PyObj_pjsua_transport_info_members
1539 */
1540static PyMemberDef PyObj_pjsua_transport_info_members[] =
1541{
1542 {
1543 "id", T_INT,
1544 offsetof(PyObj_pjsua_transport_info, id), 0,
1545 "PJSUA transport identification."
1546 },
1547 {
1548 "type", T_INT,
Benny Prijono55040452008-07-21 18:20:57 +00001549 offsetof(PyObj_pjsua_transport_info, type), 0,
Benny Prijono9c461142008-07-10 22:41:20 +00001550 "Transport type."
1551 },
1552 {
1553 "type_name", T_OBJECT_EX,
1554 offsetof(PyObj_pjsua_transport_info, type_name), 0,
1555 "Transport type name."
1556 },
1557 {
1558 "info", T_OBJECT_EX,
1559 offsetof(PyObj_pjsua_transport_info, info), 0,
1560 "Transport string info/description."
1561 },
1562 {
1563 "flag", T_INT,
1564 offsetof(PyObj_pjsua_transport_info, flag), 0,
1565 "Transport flag (see ##pjsip_transport_flags_e)."
1566 },
1567 {
1568 "addr", T_OBJECT_EX,
1569 offsetof(PyObj_pjsua_transport_info, addr), 0,
1570 "Published address (or transport address name)."
1571 },
1572 {
1573 "port", T_INT,
1574 offsetof(PyObj_pjsua_transport_info, port), 0,
1575 "Published port number."
1576 },
1577 {
1578 "usage_count", T_INT,
1579 offsetof(PyObj_pjsua_transport_info, usage_count), 0,
1580 "Current number of objects currently referencing this transport."
1581 },
1582 {NULL} /* Sentinel */
1583};
1584
1585
1586/*
1587 * PyTyp_pjsua_transport_info
1588 */
1589static PyTypeObject PyTyp_pjsua_transport_info =
1590{
1591 PyObject_HEAD_INIT(NULL)
1592 0, /*ob_size*/
1593 "_pjsua.Transport_Info", /*tp_name*/
1594 sizeof(PyObj_pjsua_transport_info), /*tp_basicsize*/
1595 0, /*tp_itemsize*/
1596 (destructor)PyObj_pjsua_transport_info_delete,/*tp_dealloc*/
1597 0, /*tp_print*/
1598 0, /*tp_getattr*/
1599 0, /*tp_setattr*/
1600 0, /*tp_compare*/
1601 0, /*tp_repr*/
1602 0, /*tp_as_number*/
1603 0, /*tp_as_sequence*/
1604 0, /*tp_as_mapping*/
1605 0, /*tp_hash */
1606 0, /*tp_call*/
1607 0, /*tp_str*/
1608 0, /*tp_getattro*/
1609 0, /*tp_setattro*/
1610 0, /*tp_as_buffer*/
1611 Py_TPFLAGS_DEFAULT, /*tp_flags*/
1612 "Transport Info objects", /* tp_doc */
1613 0, /* tp_traverse */
1614 0, /* tp_clear */
1615 0, /* tp_richcompare */
1616 0, /* tp_weaklistoffset */
1617 0, /* tp_iter */
1618 0, /* tp_iternext */
1619 0, /* tp_methods */
1620 PyObj_pjsua_transport_info_members, /* tp_members */
1621 0, /* tp_getset */
1622 0, /* tp_base */
1623 0, /* tp_dict */
1624 0, /* tp_descr_get */
1625 0, /* tp_descr_set */
1626 0, /* tp_dictoffset */
1627 0, /* tp_init */
1628 0, /* tp_alloc */
1629 PyObj_pjsua_transport_info_new, /* tp_new */
1630
1631};
1632
1633
1634//////////////////////////////////////////////////////////////////////////////
1635
1636/*
1637 * PyObj_pjsua_acc_config
1638 * Acc Config
1639 */
1640typedef struct
1641{
1642 PyObject_HEAD
1643 /* Type-specific fields go here. */
1644 int priority;
1645 PyObject *id;
1646 PyObject *reg_uri;
1647 int publish_enabled;
1648 PyObject *force_contact;
Benny Prijono9c461142008-07-10 22:41:20 +00001649 PyListObject *proxy;
1650 unsigned reg_timeout;
Benny Prijono9c461142008-07-10 22:41:20 +00001651 PyListObject *cred_info;
1652 int transport_id;
Benny Prijono9c461142008-07-10 22:41:20 +00001653 int auth_initial_send;
1654 PyObject *auth_initial_algorithm;
1655 PyObject *pidf_tuple_id;
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001656 PyObject *contact_params;
1657 PyObject *contact_uri_params;
Benny Prijono9c461142008-07-10 22:41:20 +00001658 int require_100rel;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001659 int require_timer;
1660 unsigned timer_se;
1661 unsigned timer_min_se;
Benny Prijono9c461142008-07-10 22:41:20 +00001662 int allow_contact_rewrite;
1663 int ka_interval;
1664 PyObject *ka_data;
1665 unsigned use_srtp;
1666 unsigned srtp_secure_signaling;
1667} PyObj_pjsua_acc_config;
1668
1669
1670/*
1671 * PyObj_pjsua_acc_config_delete
1672 * deletes a acc_config from memory
1673 */
1674static void PyObj_pjsua_acc_config_delete(PyObj_pjsua_acc_config* self)
1675{
1676 Py_XDECREF(self->id);
1677 Py_XDECREF(self->reg_uri);
1678 Py_XDECREF(self->force_contact);
1679 Py_XDECREF(self->proxy);
1680 Py_XDECREF(self->cred_info);
1681 Py_XDECREF(self->auth_initial_algorithm);
1682 Py_XDECREF(self->pidf_tuple_id);
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001683 Py_XDECREF(self->contact_params);
1684 Py_XDECREF(self->contact_uri_params);
Benny Prijono9c461142008-07-10 22:41:20 +00001685 Py_XDECREF(self->ka_data);
1686 self->ob_type->tp_free((PyObject*)self);
1687}
1688
1689
1690static void PyObj_pjsua_acc_config_import(PyObj_pjsua_acc_config *obj,
1691 const pjsua_acc_config *cfg)
1692{
1693 unsigned i;
1694
1695 obj->priority = cfg->priority;
1696 Py_XDECREF(obj->id);
Benny Prijono55040452008-07-21 18:20:57 +00001697 obj->id = PyString_FromPJ(&cfg->id);
Benny Prijono9c461142008-07-10 22:41:20 +00001698 Py_XDECREF(obj->reg_uri);
Benny Prijono55040452008-07-21 18:20:57 +00001699 obj->reg_uri = PyString_FromPJ(&cfg->reg_uri);
Benny Prijono9c461142008-07-10 22:41:20 +00001700 obj->publish_enabled = cfg->publish_enabled;
1701 Py_XDECREF(obj->force_contact);
Benny Prijono55040452008-07-21 18:20:57 +00001702 obj->force_contact = PyString_FromPJ(&cfg->force_contact);
Benny Prijono9c461142008-07-10 22:41:20 +00001703 Py_XDECREF(obj->proxy);
1704 obj->proxy = (PyListObject *)PyList_New(0);
1705 for (i=0; i<cfg->proxy_cnt; ++i) {
1706 PyObject * str;
Benny Prijono55040452008-07-21 18:20:57 +00001707 str = PyString_FromPJ(&cfg->proxy[i]);
Benny Prijono9c461142008-07-10 22:41:20 +00001708 PyList_Append((PyObject *)obj->proxy, str);
1709 }
1710
1711 obj->reg_timeout = cfg->reg_timeout;
1712
1713 Py_XDECREF(obj->cred_info);
1714 obj->cred_info = (PyListObject *)PyList_New(0);
1715 for (i=0; i<cfg->cred_count; ++i) {
1716 PyObj_pjsip_cred_info * ci;
1717
1718 ci = (PyObj_pjsip_cred_info *)
1719 PyObj_pjsip_cred_info_new(&PyTyp_pjsip_cred_info,NULL,NULL);
1720 PyObj_pjsip_cred_info_import(ci, &cfg->cred_info[i]);
1721 PyList_Append((PyObject *)obj->cred_info, (PyObject *)ci);
1722 }
1723
1724 obj->transport_id = cfg->transport_id;
1725
1726 obj->auth_initial_send = cfg->auth_pref.initial_auth;
1727 Py_XDECREF(obj->auth_initial_algorithm);
Benny Prijono55040452008-07-21 18:20:57 +00001728 obj->auth_initial_algorithm = PyString_FromPJ(&cfg->auth_pref.algorithm);
Benny Prijono9c461142008-07-10 22:41:20 +00001729 Py_XDECREF(obj->pidf_tuple_id);
Benny Prijono55040452008-07-21 18:20:57 +00001730 obj->pidf_tuple_id = PyString_FromPJ(&cfg->pidf_tuple_id);
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001731 Py_XDECREF(obj->contact_params);
1732 obj->contact_params = PyString_FromPJ(&cfg->contact_params);
1733 Py_XDECREF(obj->contact_uri_params);
1734 obj->contact_uri_params = PyString_FromPJ(&cfg->contact_uri_params);
Benny Prijono9c461142008-07-10 22:41:20 +00001735 obj->require_100rel = cfg->require_100rel;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001736 obj->require_timer = cfg->require_timer;
Nanang Izzuddin65add622009-08-11 16:26:20 +00001737 obj->timer_se = cfg->timer_setting.sess_expires;
1738 obj->timer_min_se = cfg->timer_setting.min_se;
Benny Prijono9c461142008-07-10 22:41:20 +00001739 obj->allow_contact_rewrite = cfg->allow_contact_rewrite;
1740 obj->ka_interval = cfg->ka_interval;
1741 Py_XDECREF(obj->ka_data);
Benny Prijono55040452008-07-21 18:20:57 +00001742 obj->ka_data = PyString_FromPJ(&cfg->ka_data);
Benny Prijono9c461142008-07-10 22:41:20 +00001743 obj->use_srtp = cfg->use_srtp;
1744 obj->srtp_secure_signaling = cfg->srtp_secure_signaling;
1745}
1746
1747static void PyObj_pjsua_acc_config_export(pjsua_acc_config *cfg,
1748 PyObj_pjsua_acc_config *obj)
1749{
1750 unsigned i;
1751
1752 cfg->priority = obj->priority;
Benny Prijono55040452008-07-21 18:20:57 +00001753 cfg->id = PyString_ToPJ(obj->id);
1754 cfg->reg_uri = PyString_ToPJ(obj->reg_uri);
Benny Prijono9c461142008-07-10 22:41:20 +00001755 cfg->publish_enabled = obj->publish_enabled;
Benny Prijono55040452008-07-21 18:20:57 +00001756 cfg->force_contact = PyString_ToPJ(obj->force_contact);
Benny Prijono9c461142008-07-10 22:41:20 +00001757
1758 cfg->proxy_cnt = PyList_Size((PyObject*)obj->proxy);
Benny Prijono55040452008-07-21 18:20:57 +00001759 if (cfg->proxy_cnt > PJ_ARRAY_SIZE(cfg->proxy))
1760 cfg->proxy_cnt = PJ_ARRAY_SIZE(cfg->proxy);
Benny Prijono9c461142008-07-10 22:41:20 +00001761 for (i = 0; i < cfg->proxy_cnt; i++) {
Benny Prijono55040452008-07-21 18:20:57 +00001762 PyObject *item = PyList_GetItem((PyObject *)obj->proxy, i);
1763 cfg->proxy[i] = PyString_ToPJ(item);
Benny Prijono9c461142008-07-10 22:41:20 +00001764 }
1765
1766 cfg->reg_timeout = obj->reg_timeout;
1767
1768 cfg->cred_count = PyList_Size((PyObject*)obj->cred_info);
Benny Prijono55040452008-07-21 18:20:57 +00001769 if (cfg->cred_count > PJ_ARRAY_SIZE(cfg->cred_info))
1770 cfg->cred_count = PJ_ARRAY_SIZE(cfg->cred_info);
Benny Prijono9c461142008-07-10 22:41:20 +00001771 for (i = 0; i < cfg->cred_count; i++) {
Benny Prijono9c461142008-07-10 22:41:20 +00001772 PyObj_pjsip_cred_info *ci;
1773 ci = (PyObj_pjsip_cred_info*)
Benny Prijono55040452008-07-21 18:20:57 +00001774 PyList_GetItem((PyObject *)obj->cred_info, i);
Benny Prijono9c461142008-07-10 22:41:20 +00001775 PyObj_pjsip_cred_info_export(&cfg->cred_info[i], ci);
1776 }
1777
1778 cfg->transport_id = obj->transport_id;
1779 cfg->auth_pref.initial_auth = obj->auth_initial_send;
Benny Prijono55040452008-07-21 18:20:57 +00001780 cfg->auth_pref.algorithm = PyString_ToPJ(obj->auth_initial_algorithm);
1781 cfg->pidf_tuple_id = PyString_ToPJ(obj->pidf_tuple_id);
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001782 cfg->contact_params = PyString_ToPJ(obj->contact_params);
1783 cfg->contact_uri_params = PyString_ToPJ(obj->contact_uri_params);
Benny Prijono9c461142008-07-10 22:41:20 +00001784 cfg->require_100rel = obj->require_100rel;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001785 cfg->require_timer = obj->require_timer;
Nanang Izzuddin65add622009-08-11 16:26:20 +00001786 cfg->timer_setting.sess_expires = obj->timer_se;
1787 cfg->timer_setting.min_se = obj->timer_min_se;
Benny Prijono9c461142008-07-10 22:41:20 +00001788 cfg->allow_contact_rewrite = obj->allow_contact_rewrite;
1789 cfg->ka_interval = obj->ka_interval;
Benny Prijono55040452008-07-21 18:20:57 +00001790 cfg->ka_data = PyString_ToPJ(obj->ka_data);
Benny Prijono9c461142008-07-10 22:41:20 +00001791 cfg->use_srtp = obj->use_srtp;
1792 cfg->srtp_secure_signaling = obj->srtp_secure_signaling;
1793}
1794
1795
1796/*
1797 * PyObj_pjsua_acc_config_new
1798 * constructor for acc_config object
1799 */
1800static PyObject * PyObj_pjsua_acc_config_new(PyTypeObject *type,
1801 PyObject *args,
1802 PyObject *kwds)
1803{
1804 PyObj_pjsua_acc_config *self;
1805
1806 PJ_UNUSED_ARG(args);
1807 PJ_UNUSED_ARG(kwds);
1808
1809 self = (PyObj_pjsua_acc_config *)type->tp_alloc(type, 0);
1810 if (self != NULL) {
1811 self->id = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001812 self->reg_uri = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001813 self->force_contact = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001814 self->proxy = (PyListObject *)PyList_New(0);
Benny Prijono9c461142008-07-10 22:41:20 +00001815 self->cred_info = (PyListObject *)PyList_New(0);
Benny Prijono9c461142008-07-10 22:41:20 +00001816 self->auth_initial_algorithm = PyString_FromString("");
1817 self->pidf_tuple_id = PyString_FromString("");
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001818 self->contact_params = PyString_FromString("");
1819 self->contact_uri_params = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00001820 self->ka_data = PyString_FromString("");
1821 }
1822
1823 return (PyObject *)self;
1824}
1825
1826
1827
1828/*
1829 * PyObj_pjsua_acc_config_members
1830 */
1831static PyMemberDef PyObj_pjsua_acc_config_members[] =
1832{
1833 {
1834 "priority", T_INT, offsetof(PyObj_pjsua_acc_config, priority), 0,
1835 "Account priority, which is used to control the order of matching "
1836 "incoming/outgoing requests. The higher the number means the higher "
1837 "the priority is, and the account will be matched first. "
1838 },
1839 {
1840 "id", T_OBJECT_EX,
1841 offsetof(PyObj_pjsua_acc_config, id), 0,
1842 "The full SIP URL for the account. "
1843 "The value can take name address or URL format, "
1844 "and will look something like 'sip:account@serviceprovider'. "
1845 "This field is mandatory."
1846 },
1847 {
1848 "reg_uri", T_OBJECT_EX,
1849 offsetof(PyObj_pjsua_acc_config, reg_uri), 0,
1850 "This is the URL to be put in the request URI for the registration, "
1851 "and will look something like 'sip:serviceprovider'. "
1852 "This field should be specified if registration is desired. "
1853 "If the value is empty, no account registration will be performed. "
1854 },
1855 {
1856 "publish_enabled", T_INT,
1857 offsetof(PyObj_pjsua_acc_config, publish_enabled), 0,
1858 "Publish presence? "
1859 },
1860 {
1861 "force_contact", T_OBJECT_EX,
1862 offsetof(PyObj_pjsua_acc_config, force_contact), 0,
1863 "Optional URI to be put as Contact for this account. "
1864 "It is recommended that this field is left empty, "
1865 "so that the value will be calculated automatically "
1866 "based on the transport address. "
1867 },
1868 {
1869 "proxy", T_OBJECT_EX,
1870 offsetof(PyObj_pjsua_acc_config, proxy), 0,
1871 "Optional URI of the proxies to be visited for all outgoing requests "
1872 "that are using this account (REGISTER, INVITE, etc). Application need "
1873 "to specify these proxies if the service provider requires "
1874 "that requests destined towards its network should go through certain "
1875 "proxies first (for example, border controllers)."
1876 },
1877 {
Benny Prijono55040452008-07-21 18:20:57 +00001878 "reg_timeout", T_INT,
1879 offsetof(PyObj_pjsua_acc_config, reg_timeout), 0,
Benny Prijono9c461142008-07-10 22:41:20 +00001880 "Optional interval for registration, in seconds. "
1881 "If the value is zero, default interval will be used "
1882 "(PJSUA_REG_INTERVAL, 55 seconds). "
1883 },
1884 {
1885 "cred_info", T_OBJECT_EX,
1886 offsetof(PyObj_pjsua_acc_config, cred_info), 0,
1887 "Array of credentials. If registration is desired, normally there "
1888 "should be at least one credential specified, to successfully "
1889 "authenticate against the service provider. More credentials can "
1890 "be specified, for example when the requests are expected to be "
1891 "challenged by the proxies in the route set."
1892 },
1893 {
1894 "transport_id", T_INT,
1895 offsetof(PyObj_pjsua_acc_config, transport_id), 0,
1896 "Optionally bind this account to specific transport. This normally is"
1897 " not a good idea, as account should be able to send requests using"
1898 " any available transports according to the destination. But some"
1899 " application may want to have explicit control over the transport to"
1900 " use, so in that case it can set this field."
1901 },
Benny Prijono9c461142008-07-10 22:41:20 +00001902 {
1903 "auth_initial_send", T_INT,
1904 offsetof(PyObj_pjsua_acc_config, auth_initial_send), 0,
1905 "Send empty initial authorization header."
1906 },
1907 {
1908 "auth_initial_algorithm", T_OBJECT_EX,
1909 offsetof(PyObj_pjsua_acc_config, auth_initial_algorithm), 0,
1910 "Specify algorithm in empty initial authorization header."
1911 },
1912 {
1913 "pidf_tuple_id", T_OBJECT_EX,
1914 offsetof(PyObj_pjsua_acc_config, pidf_tuple_id), 0,
1915 "PIDF tuple id."
1916 },
1917 {
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001918 "contact_params", T_OBJECT_EX,
1919 offsetof(PyObj_pjsua_acc_config, contact_params), 0,
1920 "Additional parameters for Contact header."
1921 },
1922 {
1923 "contact_uri_params", T_OBJECT_EX,
1924 offsetof(PyObj_pjsua_acc_config, contact_uri_params), 0,
1925 "Additional parameters for Contact URI."
1926 },
1927 {
Benny Prijono9c461142008-07-10 22:41:20 +00001928 "require_100rel", T_INT,
1929 offsetof(PyObj_pjsua_acc_config, require_100rel), 0,
1930 "Require reliable provisional response."
1931 },
1932 {
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001933 "require_timer", T_INT,
1934 offsetof(PyObj_pjsua_acc_config, require_timer), 0,
1935 "Require session timer."
1936 },
1937 {
1938 "timer_se", T_INT,
1939 offsetof(PyObj_pjsua_acc_config, timer_se), 0,
1940 "Session timer expiration period, in seconds."
1941 },
1942 {
1943 "timer_min_se", T_INT,
1944 offsetof(PyObj_pjsua_acc_config, timer_min_se), 0,
1945 "Session timer minimum expiration period, in seconds."
1946 },
1947 {
Benny Prijono9c461142008-07-10 22:41:20 +00001948 "allow_contact_rewrite", T_INT,
1949 offsetof(PyObj_pjsua_acc_config, allow_contact_rewrite), 0,
1950 "Re-REGISTER if behind symmetric NAT."
1951 },
1952 {
1953 "ka_interval", T_INT,
1954 offsetof(PyObj_pjsua_acc_config, ka_interval), 0,
1955 "Keep-alive interval."
1956 },
1957 {
1958 "ka_data", T_OBJECT_EX,
1959 offsetof(PyObj_pjsua_acc_config, ka_data), 0,
1960 "Keep-alive data."
1961 },
1962 {
1963 "use_srtp", T_INT,
1964 offsetof(PyObj_pjsua_acc_config, use_srtp), 0,
1965 "Specify SRTP usage."
1966 },
1967 {
1968 "srtp_secure_signaling", T_INT,
1969 offsetof(PyObj_pjsua_acc_config, srtp_secure_signaling), 0,
1970 "Specify if SRTP requires secure signaling to be used."
1971 },
1972
1973 {NULL} /* Sentinel */
1974};
1975
1976
1977
1978
1979/*
1980 * PyTyp_pjsua_acc_config
1981 */
1982static PyTypeObject PyTyp_pjsua_acc_config =
1983{
1984 PyObject_HEAD_INIT(NULL)
1985 0, /*ob_size*/
Benny Prijono55040452008-07-21 18:20:57 +00001986 "_pjsua.Acc_Config", /*tp_name*/
1987 sizeof(PyObj_pjsua_acc_config), /*tp_basicsize*/
Benny Prijono9c461142008-07-10 22:41:20 +00001988 0, /*tp_itemsize*/
1989 (destructor)PyObj_pjsua_acc_config_delete,/*tp_dealloc*/
1990 0, /*tp_print*/
1991 0, /*tp_getattr*/
1992 0, /*tp_setattr*/
1993 0, /*tp_compare*/
1994 0, /*tp_repr*/
1995 0, /*tp_as_number*/
1996 0, /*tp_as_sequence*/
1997 0, /*tp_as_mapping*/
1998 0, /*tp_hash */
1999 0, /*tp_call*/
2000 0, /*tp_str*/
2001 0, /*tp_getattro*/
2002 0, /*tp_setattro*/
2003 0, /*tp_as_buffer*/
2004 Py_TPFLAGS_DEFAULT, /*tp_flags*/
Benny Prijono55040452008-07-21 18:20:57 +00002005 "Account settings", /* tp_doc */
Benny Prijono9c461142008-07-10 22:41:20 +00002006 0, /* tp_traverse */
2007 0, /* tp_clear */
2008 0, /* tp_richcompare */
2009 0, /* tp_weaklistoffset */
2010 0, /* tp_iter */
2011 0, /* tp_iternext */
Benny Prijono55040452008-07-21 18:20:57 +00002012 0, /* tp_methods */
2013 PyObj_pjsua_acc_config_members, /* tp_members */
Benny Prijono9c461142008-07-10 22:41:20 +00002014 0, /* tp_getset */
2015 0, /* tp_base */
2016 0, /* tp_dict */
2017 0, /* tp_descr_get */
2018 0, /* tp_descr_set */
2019 0, /* tp_dictoffset */
2020 0, /* tp_init */
2021 0, /* tp_alloc */
Benny Prijono55040452008-07-21 18:20:57 +00002022 PyObj_pjsua_acc_config_new, /* tp_new */
Benny Prijono9c461142008-07-10 22:41:20 +00002023
2024};
2025
2026
2027//////////////////////////////////////////////////////////////////////////////
2028/*
2029 * PyObj_pjsua_acc_info
2030 * Acc Info
2031 */
2032typedef struct
2033{
2034 PyObject_HEAD
2035 /* Type-specific fields go here. */
2036 int id;
2037 int is_default;
2038 PyObject *acc_uri;
2039 int has_registration;
2040 int expires;
2041 int status;
2042 PyObject *status_text;
2043 int online_status;
2044 PyObject *online_status_text;
2045} PyObj_pjsua_acc_info;
2046
2047
2048/*
2049 * PyObj_pjsua_acc_info_delete
2050 * deletes a acc_info from memory
2051 */
2052static void PyObj_pjsua_acc_info_delete(PyObj_pjsua_acc_info* self)
2053{
2054 Py_XDECREF(self->acc_uri);
2055 Py_XDECREF(self->status_text);
2056 Py_XDECREF(self->online_status_text);
2057 self->ob_type->tp_free((PyObject*)self);
2058}
2059
2060
2061static void PyObj_pjsua_acc_info_import(PyObj_pjsua_acc_info *obj,
2062 const pjsua_acc_info *info)
2063{
2064 obj->id = info->id;
2065 obj->is_default = info->is_default;
Benny Prijono55040452008-07-21 18:20:57 +00002066 Py_XDECREF(obj->acc_uri);
2067 obj->acc_uri = PyString_FromPJ(&info->acc_uri);
Benny Prijono9c461142008-07-10 22:41:20 +00002068 obj->has_registration = info->has_registration;
2069 obj->expires = info->expires;
2070 obj->status = info->status;
Benny Prijono55040452008-07-21 18:20:57 +00002071 Py_XDECREF(obj->status_text);
2072 obj->status_text= PyString_FromPJ(&info->status_text);
Benny Prijono9c461142008-07-10 22:41:20 +00002073 obj->online_status = info->online_status;
Benny Prijono55040452008-07-21 18:20:57 +00002074 Py_XDECREF(obj->online_status_text);
2075 obj->online_status_text = PyString_FromPJ(&info->online_status_text);
Benny Prijono9c461142008-07-10 22:41:20 +00002076}
2077
2078
2079/*
2080 * PyObj_pjsua_acc_info_new
2081 * constructor for acc_info object
2082 */
2083static PyObject * PyObj_pjsua_acc_info_new(PyTypeObject *type,
2084 PyObject *args,
2085 PyObject *kwds)
2086{
2087 PyObj_pjsua_acc_info *self;
2088
2089 PJ_UNUSED_ARG(args);
2090 PJ_UNUSED_ARG(kwds);
2091
2092 self = (PyObj_pjsua_acc_info *)type->tp_alloc(type, 0);
2093 if (self != NULL) {
2094 self->acc_uri = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00002095 self->status_text = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00002096 self->online_status_text = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00002097 }
2098
2099 return (PyObject *)self;
2100}
2101
2102/*
2103 * acc_info_members
2104 */
2105static PyMemberDef acc_info_members[] =
2106{
2107 {
2108 "id", T_INT,
2109 offsetof(PyObj_pjsua_acc_info, id), 0,
2110 "The account ID."
2111 },
2112 {
2113 "is_default", T_INT,
2114 offsetof(PyObj_pjsua_acc_info, is_default), 0,
2115 "Flag to indicate whether this is the default account. "
2116 },
2117 {
2118 "acc_uri", T_OBJECT_EX,
2119 offsetof(PyObj_pjsua_acc_info, acc_uri), 0,
2120 "Account URI"
2121 },
2122 {
2123 "has_registration", T_INT,
2124 offsetof(PyObj_pjsua_acc_info, has_registration), 0,
2125 "Flag to tell whether this account has registration setting "
2126 "(reg_uri is not empty)."
2127 },
2128 {
2129 "expires", T_INT,
2130 offsetof(PyObj_pjsua_acc_info, expires), 0,
2131 "An up to date expiration interval for account registration session."
2132 },
2133 {
2134 "status", T_INT,
2135 offsetof(PyObj_pjsua_acc_info, status), 0,
2136 "Last registration status code. If status code is zero, "
2137 "the account is currently not registered. Any other value indicates "
2138 "the SIP status code of the registration. "
2139 },
2140 {
2141 "status_text", T_OBJECT_EX,
2142 offsetof(PyObj_pjsua_acc_info, status_text), 0,
2143 "String describing the registration status."
2144 },
2145 {
2146 "online_status", T_INT,
2147 offsetof(PyObj_pjsua_acc_info, online_status), 0,
2148 "Presence online status for this account. "
2149 },
2150 {
2151 "online_status_text", T_OBJECT_EX,
2152 offsetof(PyObj_pjsua_acc_info, online_status_text), 0,
2153 "Presence online status text."
2154 },
2155 {NULL} /* Sentinel */
2156};
2157
2158
2159
2160
2161/*
2162 * PyTyp_pjsua_acc_info
2163 */
2164static PyTypeObject PyTyp_pjsua_acc_info =
2165{
2166 PyObject_HEAD_INIT(NULL)
2167 0, /*ob_size*/
Benny Prijono55040452008-07-21 18:20:57 +00002168 "_pjsua.Acc_Info", /*tp_name*/
2169 sizeof(PyObj_pjsua_acc_info), /*tp_basicsize*/
Benny Prijono9c461142008-07-10 22:41:20 +00002170 0, /*tp_itemsize*/
2171 (destructor)PyObj_pjsua_acc_info_delete,/*tp_dealloc*/
2172 0, /*tp_print*/
2173 0, /*tp_getattr*/
2174 0, /*tp_setattr*/
2175 0, /*tp_compare*/
2176 0, /*tp_repr*/
2177 0, /*tp_as_number*/
2178 0, /*tp_as_sequence*/
2179 0, /*tp_as_mapping*/
2180 0, /*tp_hash */
2181 0, /*tp_call*/
2182 0, /*tp_str*/
2183 0, /*tp_getattro*/
2184 0, /*tp_setattro*/
2185 0, /*tp_as_buffer*/
2186 Py_TPFLAGS_DEFAULT, /*tp_flags*/
Benny Prijono55040452008-07-21 18:20:57 +00002187 "Account info", /* tp_doc */
Benny Prijono9c461142008-07-10 22:41:20 +00002188 0, /* tp_traverse */
2189 0, /* tp_clear */
2190 0, /* tp_richcompare */
2191 0, /* tp_weaklistoffset */
2192 0, /* tp_iter */
2193 0, /* tp_iternext */
2194 NULL, /* tp_methods */
2195 acc_info_members, /* tp_members */
2196 0, /* tp_getset */
2197 0, /* tp_base */
2198 0, /* tp_dict */
2199 0, /* tp_descr_get */
2200 0, /* tp_descr_set */
2201 0, /* tp_dictoffset */
2202 0, /* tp_init */
2203 0, /* tp_alloc */
2204 PyObj_pjsua_acc_info_new, /* tp_new */
2205
2206};
2207
2208
2209//////////////////////////////////////////////////////////////////////////////
2210
2211/*
2212 * PyObj_pjsua_buddy_config
2213 * Buddy Config
2214 */
2215typedef struct
2216{
2217 PyObject_HEAD
2218 /* Type-specific fields go here. */
2219 PyObject *uri;
2220 int subscribe;
2221} PyObj_pjsua_buddy_config;
2222
2223
2224/*
2225 * PyObj_pjsua_buddy_config_delete
2226 * deletes a buddy_config from memory
2227 */
2228static void PyObj_pjsua_buddy_config_delete(PyObj_pjsua_buddy_config* self)
2229{
2230 Py_XDECREF(self->uri);
2231 self->ob_type->tp_free((PyObject*)self);
2232}
2233
2234
2235static void PyObj_pjsua_buddy_config_import(PyObj_pjsua_buddy_config *obj,
2236 const pjsua_buddy_config *cfg)
2237{
2238 Py_XDECREF(obj->uri);
Benny Prijono55040452008-07-21 18:20:57 +00002239 obj->uri = PyString_FromPJ(&cfg->uri);
Benny Prijono9c461142008-07-10 22:41:20 +00002240 obj->subscribe = cfg->subscribe;
2241}
2242
2243
2244static void PyObj_pjsua_buddy_config_export(pjsua_buddy_config *cfg,
2245 PyObj_pjsua_buddy_config *obj)
2246{
Benny Prijono55040452008-07-21 18:20:57 +00002247 cfg->uri = PyString_ToPJ(obj->uri);
Benny Prijono9c461142008-07-10 22:41:20 +00002248 cfg->subscribe = obj->subscribe;
Benny Prijono55040452008-07-21 18:20:57 +00002249 cfg->user_data = NULL;
Benny Prijono9c461142008-07-10 22:41:20 +00002250}
2251
2252
Benny Prijono9c461142008-07-10 22:41:20 +00002253/*
2254 * PyObj_pjsua_buddy_config_new
2255 * constructor for buddy_config object
2256 */
2257static PyObject *PyObj_pjsua_buddy_config_new(PyTypeObject *type,
2258 PyObject *args,
2259 PyObject *kwds)
2260{
2261 PyObj_pjsua_buddy_config *self;
2262
2263 PJ_UNUSED_ARG(args);
2264 PJ_UNUSED_ARG(kwds);
2265
2266 self = (PyObj_pjsua_buddy_config *)type->tp_alloc(type, 0);
2267 if (self != NULL) {
2268 self->uri = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00002269 }
2270 return (PyObject *)self;
2271}
2272
2273/*
2274 * PyObj_pjsua_buddy_config_members
2275 */
2276static PyMemberDef PyObj_pjsua_buddy_config_members[] =
2277{
2278
2279 {
2280 "uri", T_OBJECT_EX,
2281 offsetof(PyObj_pjsua_buddy_config, uri), 0,
2282 "TBuddy URL or name address."
2283 },
2284
2285 {
2286 "subscribe", T_INT,
2287 offsetof(PyObj_pjsua_buddy_config, subscribe), 0,
2288 "Specify whether presence subscription should start immediately. "
2289 },
2290
2291 {NULL} /* Sentinel */
2292};
2293
2294
2295
2296
2297/*
2298 * PyTyp_pjsua_buddy_config
2299 */
2300static PyTypeObject PyTyp_pjsua_buddy_config =
2301{
2302 PyObject_HEAD_INIT(NULL)
2303 0, /*ob_size*/
2304 "_pjsua.Buddy_Config", /*tp_name*/
2305 sizeof(PyObj_pjsua_buddy_config),/*tp_basicsize*/
2306 0, /*tp_itemsize*/
2307 (destructor)PyObj_pjsua_buddy_config_delete,/*tp_dealloc*/
2308 0, /*tp_print*/
2309 0, /*tp_getattr*/
2310 0, /*tp_setattr*/
2311 0, /*tp_compare*/
2312 0, /*tp_repr*/
2313 0, /*tp_as_number*/
2314 0, /*tp_as_sequence*/
2315 0, /*tp_as_mapping*/
2316 0, /*tp_hash */
2317 0, /*tp_call*/
2318 0, /*tp_str*/
2319 0, /*tp_getattro*/
2320 0, /*tp_setattro*/
2321 0, /*tp_as_buffer*/
2322 Py_TPFLAGS_DEFAULT, /*tp_flags*/
Benny Prijono55040452008-07-21 18:20:57 +00002323 "Buddy config", /* tp_doc */
Benny Prijono9c461142008-07-10 22:41:20 +00002324 0, /* tp_traverse */
2325 0, /* tp_clear */
2326 0, /* tp_richcompare */
2327 0, /* tp_weaklistoffset */
2328 0, /* tp_iter */
2329 0, /* tp_iternext */
2330 0, /* tp_methods */
Benny Prijono55040452008-07-21 18:20:57 +00002331 PyObj_pjsua_buddy_config_members,/* tp_members */
Benny Prijono9c461142008-07-10 22:41:20 +00002332 0, /* tp_getset */
2333 0, /* tp_base */
2334 0, /* tp_dict */
2335 0, /* tp_descr_get */
2336 0, /* tp_descr_set */
2337 0, /* tp_dictoffset */
2338 0, /* tp_init */
2339 0, /* tp_alloc */
2340 PyObj_pjsua_buddy_config_new, /* tp_new */
2341
2342};
2343
2344//////////////////////////////////////////////////////////////////////////////
2345/*
2346 * PyObj_pjsua_buddy_info
2347 * Buddy Info
2348 */
2349typedef struct
2350{
2351 PyObject_HEAD
2352 /* Type-specific fields go here. */
2353 int id;
2354 PyObject *uri;
2355 PyObject *contact;
2356 int status;
2357 PyObject *status_text;
2358 int monitor_pres;
2359 int activity;
Benny Prijonoe6787ec2008-07-18 23:00:56 +00002360 int sub_state;
2361 PyObject *sub_term_reason;
Benny Prijono9c461142008-07-10 22:41:20 +00002362} PyObj_pjsua_buddy_info;
2363
2364
2365/*
2366 * PyObj_pjsua_buddy_info_delete
2367 * deletes a buddy_info from memory
2368 * !modified @ 071206
2369 */
2370static void PyObj_pjsua_buddy_info_delete(PyObj_pjsua_buddy_info* self)
2371{
2372 Py_XDECREF(self->uri);
2373 Py_XDECREF(self->contact);
2374 Py_XDECREF(self->status_text);
Benny Prijonoe6787ec2008-07-18 23:00:56 +00002375 Py_XDECREF(self->sub_term_reason);
Benny Prijono9c461142008-07-10 22:41:20 +00002376
2377 self->ob_type->tp_free((PyObject*)self);
2378}
2379
2380
2381static void PyObj_pjsua_buddy_info_import(PyObj_pjsua_buddy_info *obj,
2382 const pjsua_buddy_info *info)
2383{
2384 obj->id = info->id;
2385 Py_XDECREF(obj->uri);
Benny Prijono55040452008-07-21 18:20:57 +00002386 obj->uri = PyString_FromPJ(&info->uri);
Benny Prijono9c461142008-07-10 22:41:20 +00002387 Py_XDECREF(obj->contact);
Benny Prijono55040452008-07-21 18:20:57 +00002388 obj->contact = PyString_FromPJ(&info->contact);
Benny Prijono9c461142008-07-10 22:41:20 +00002389 obj->status = info->status;
2390 Py_XDECREF(obj->status_text);
Benny Prijono55040452008-07-21 18:20:57 +00002391 obj->status_text = PyString_FromPJ(&info->status_text);
Benny Prijono9c461142008-07-10 22:41:20 +00002392 obj->monitor_pres = info->monitor_pres;
2393 obj->activity = info->rpid.activity;
Benny Prijonoe6787ec2008-07-18 23:00:56 +00002394 obj->sub_state = info->sub_state;
2395 Py_XDECREF(obj->sub_term_reason);
Benny Prijono55040452008-07-21 18:20:57 +00002396 obj->sub_term_reason = PyString_FromPJ(&info->sub_term_reason);
Benny Prijono9c461142008-07-10 22:41:20 +00002397}
2398
2399
2400/*
2401 * PyObj_pjsua_buddy_info_new
2402 * constructor for buddy_info object
2403 * !modified @ 071206
2404 */
2405static PyObject * PyObj_pjsua_buddy_info_new(PyTypeObject *type,
2406 PyObject *args,
2407 PyObject *kwds)
2408{
2409 PyObj_pjsua_buddy_info *self;
2410
2411 PJ_UNUSED_ARG(args);
2412 PJ_UNUSED_ARG(kwds);
2413
2414 self = (PyObj_pjsua_buddy_info *)type->tp_alloc(type, 0);
2415 if (self != NULL) {
2416 self->uri = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00002417 self->contact = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00002418 self->status_text = PyString_FromString("");
Benny Prijonoe6787ec2008-07-18 23:00:56 +00002419 self->sub_term_reason = PyString_FromString("");
Benny Prijono9c461142008-07-10 22:41:20 +00002420 }
2421 return (PyObject *)self;
2422}
2423
2424/*
2425 * PyObj_pjsua_buddy_info_members
2426 * !modified @ 071206
2427 */
2428static PyMemberDef PyObj_pjsua_buddy_info_members[] =
2429{
2430 {
2431 "id", T_INT,
2432 offsetof(PyObj_pjsua_buddy_info, id), 0,
2433 "The buddy ID."
2434 },
2435 {
2436 "uri", T_OBJECT_EX,
2437 offsetof(PyObj_pjsua_buddy_info, uri), 0,
2438 "The full URI of the buddy, as specified in the configuration. "
2439 },
2440 {
2441 "contact", T_OBJECT_EX,
2442 offsetof(PyObj_pjsua_buddy_info, contact), 0,
2443 "Buddy's Contact, only available when presence subscription "
2444 "has been established to the buddy."
2445 },
2446 {
2447 "status", T_INT,
2448 offsetof(PyObj_pjsua_buddy_info, status), 0,
2449 "Buddy's online status. "
2450 },
2451 {
2452 "status_text", T_OBJECT_EX,
2453 offsetof(PyObj_pjsua_buddy_info, status_text), 0,
2454 "Text to describe buddy's online status."
2455 },
2456 {
2457 "monitor_pres", T_INT,
2458 offsetof(PyObj_pjsua_buddy_info, monitor_pres), 0,
2459 "Flag to indicate that we should monitor the presence information "
2460 "for this buddy (normally yes, unless explicitly disabled). "
2461 },
2462 {
2463 "activity", T_INT,
2464 offsetof(PyObj_pjsua_buddy_info, activity), 0,
2465 "Activity type. "
2466 },
Benny Prijonoe6787ec2008-07-18 23:00:56 +00002467 {
2468 "sub_state", T_INT,
2469 offsetof(PyObj_pjsua_buddy_info, sub_state), 0,
2470 "Subscription state."
2471 },
2472 {
2473 "sub_term_reason", T_INT,
2474 offsetof(PyObj_pjsua_buddy_info, sub_term_reason), 0,
2475 "Subscription termination reason."
2476 },
Benny Prijono9c461142008-07-10 22:41:20 +00002477
2478
2479 {NULL} /* Sentinel */
2480};
2481
2482
2483
2484
2485/*
2486 * PyTyp_pjsua_buddy_info
2487 */
2488static PyTypeObject PyTyp_pjsua_buddy_info =
2489{
2490 PyObject_HEAD_INIT(NULL)
2491 0, /*ob_size*/
Benny Prijono55040452008-07-21 18:20:57 +00002492 "_pjsua.Buddy_Info", /*tp_name*/
2493 sizeof(PyObj_pjsua_buddy_info), /*tp_basicsize*/
Benny Prijono9c461142008-07-10 22:41:20 +00002494 0, /*tp_itemsize*/
2495 (destructor)PyObj_pjsua_buddy_info_delete,/*tp_dealloc*/
2496 0, /*tp_print*/
2497 0, /*tp_getattr*/
2498 0, /*tp_setattr*/
2499 0, /*tp_compare*/
2500 0, /*tp_repr*/
2501 0, /*tp_as_number*/
2502 0, /*tp_as_sequence*/
2503 0, /*tp_as_mapping*/
2504 0, /*tp_hash */
2505 0, /*tp_call*/
2506 0, /*tp_str*/
2507 0, /*tp_getattro*/
2508 0, /*tp_setattro*/
2509 0, /*tp_as_buffer*/
2510 Py_TPFLAGS_DEFAULT, /*tp_flags*/
Benny Prijono55040452008-07-21 18:20:57 +00002511 "Buddy Info object", /* tp_doc */
Benny Prijono9c461142008-07-10 22:41:20 +00002512 0, /* tp_traverse */
2513 0, /* tp_clear */
2514 0, /* tp_richcompare */
2515 0, /* tp_weaklistoffset */
2516 0, /* tp_iter */
2517 0, /* tp_iternext */
2518 0, /* tp_methods */
Benny Prijono55040452008-07-21 18:20:57 +00002519 PyObj_pjsua_buddy_info_members, /* tp_members */
Benny Prijono9c461142008-07-10 22:41:20 +00002520 0, /* tp_getset */
2521 0, /* tp_base */
2522 0, /* tp_dict */
2523 0, /* tp_descr_get */
2524 0, /* tp_descr_set */
2525 0, /* tp_dictoffset */
2526 0, /* tp_init */
2527 0, /* tp_alloc */
Benny Prijono55040452008-07-21 18:20:57 +00002528 PyObj_pjsua_buddy_info_new, /* tp_new */
Benny Prijono9c461142008-07-10 22:41:20 +00002529
2530};
2531
2532
Benny Prijono55040452008-07-21 18:20:57 +00002533//////////////////////////////////////////////////////////////////////////////
2534
2535/*
2536 * PyObj_pjsua_codec_info
2537 * Codec Info
2538 */
2539typedef struct
2540{
2541 PyObject_HEAD
2542 /* Type-specific fields go here. */
2543
2544 PyObject * codec_id;
2545 pj_uint8_t priority;
2546} PyObj_pjsua_codec_info;
2547
2548
2549/*
2550 * codec_info_dealloc
2551 * deletes a codec_info from memory
2552 */
2553static void codec_info_dealloc(PyObj_pjsua_codec_info* self)
2554{
2555 Py_XDECREF(self->codec_id);
2556 self->ob_type->tp_free((PyObject*)self);
2557}
2558
2559
2560/*
2561 * codec_info_new
2562 * constructor for codec_info object
2563 */
2564static PyObject * codec_info_new(PyTypeObject *type, PyObject *args,
2565 PyObject *kwds)
2566{
2567 PyObj_pjsua_codec_info *self;
2568
2569 PJ_UNUSED_ARG(args);
2570 PJ_UNUSED_ARG(kwds);
2571
2572 self = (PyObj_pjsua_codec_info *)type->tp_alloc(type, 0);
2573 if (self != NULL) {
2574 self->codec_id = PyString_FromString("");
2575 }
2576 return (PyObject *)self;
2577}
2578
2579/*
2580 * codec_info_members
2581 * !modified @ 071206
2582 */
2583static PyMemberDef codec_info_members[] =
2584{
2585 {
2586 "codec_id", T_OBJECT_EX,
2587 offsetof(PyObj_pjsua_codec_info, codec_id), 0,
2588 "Codec unique identification."
2589 },
2590 {
2591 "priority", T_INT,
2592 offsetof(PyObj_pjsua_codec_info, priority), 0,
2593 "Codec priority (integer 0-255)."
2594 },
2595
2596 {NULL} /* Sentinel */
2597};
2598
2599/*
2600 * PyTyp_pjsua_codec_info
2601 */
2602static PyTypeObject PyTyp_pjsua_codec_info =
2603{
2604 PyObject_HEAD_INIT(NULL)
2605 0, /*ob_size*/
2606 "_pjsua.Codec_Info", /*tp_name*/
2607 sizeof(PyObj_pjsua_codec_info), /*tp_basicsize*/
2608 0, /*tp_itemsize*/
2609 (destructor)codec_info_dealloc, /*tp_dealloc*/
2610 0, /*tp_print*/
2611 0, /*tp_getattr*/
2612 0, /*tp_setattr*/
2613 0, /*tp_compare*/
2614 0, /*tp_repr*/
2615 0, /*tp_as_number*/
2616 0, /*tp_as_sequence*/
2617 0, /*tp_as_mapping*/
2618 0, /*tp_hash */
2619 0, /*tp_call*/
2620 0, /*tp_str*/
2621 0, /*tp_getattro*/
2622 0, /*tp_setattro*/
2623 0, /*tp_as_buffer*/
2624 Py_TPFLAGS_DEFAULT, /*tp_flags*/
2625 "Codec Info", /* tp_doc */
2626 0, /* tp_traverse */
2627 0, /* tp_clear */
2628 0, /* tp_richcompare */
2629 0, /* tp_weaklistoffset */
2630 0, /* tp_iter */
2631 0, /* tp_iternext */
2632 0, /* tp_methods */
2633 codec_info_members, /* tp_members */
2634 0, /* tp_getset */
2635 0, /* tp_base */
2636 0, /* tp_dict */
2637 0, /* tp_descr_get */
2638 0, /* tp_descr_set */
2639 0, /* tp_dictoffset */
2640 0, /* tp_init */
2641 0, /* tp_alloc */
2642 codec_info_new, /* tp_new */
2643
2644};
2645
2646
2647//////////////////////////////////////////////////////////////////////////////
2648
2649/*
2650 * PyObj_pjsua_conf_port_info
2651 * Conf Port Info
2652 */
2653typedef struct
2654{
2655 PyObject_HEAD
2656 /* Type-specific fields go here. */
2657
2658 int slot_id;
2659 PyObject *name;
2660 unsigned clock_rate;
2661 unsigned channel_count;
2662 unsigned samples_per_frame;
2663 unsigned bits_per_sample;
2664 PyObject *listeners;
2665
2666} PyObj_pjsua_conf_port_info;
2667
2668
2669/*
2670 * conf_port_info_dealloc
2671 * deletes a conf_port_info from memory
2672 */
2673static void conf_port_info_dealloc(PyObj_pjsua_conf_port_info* self)
2674{
2675 Py_XDECREF(self->name);
2676 Py_XDECREF(self->listeners);
2677 self->ob_type->tp_free((PyObject*)self);
2678}
2679
2680
2681/*
2682 * conf_port_info_new
2683 * constructor for conf_port_info object
2684 */
2685static PyObject * conf_port_info_new(PyTypeObject *type, PyObject *args,
2686 PyObject *kwds)
2687{
2688 PyObj_pjsua_conf_port_info *self;
2689
2690 PJ_UNUSED_ARG(args);
2691 PJ_UNUSED_ARG(kwds);
2692
2693 self = (PyObj_pjsua_conf_port_info *)type->tp_alloc(type, 0);
2694 if (self != NULL) {
2695 self->name = PyString_FromString("");
2696 self->listeners = PyList_New(0);
2697 }
2698 return (PyObject *)self;
2699}
2700
2701/*
2702 * conf_port_info_members
2703 */
2704static PyMemberDef conf_port_info_members[] =
2705{
2706 {
2707 "slot_id", T_INT,
2708 offsetof(PyObj_pjsua_conf_port_info, slot_id), 0,
2709 "Conference port number."
2710 },
2711 {
2712 "name", T_OBJECT_EX,
2713 offsetof(PyObj_pjsua_conf_port_info, name), 0,
2714 "Port name"
2715 },
2716 {
2717 "clock_rate", T_INT,
2718 offsetof(PyObj_pjsua_conf_port_info, clock_rate), 0,
2719 "Clock rate"
2720 },
2721 {
2722 "channel_count", T_INT,
2723 offsetof(PyObj_pjsua_conf_port_info, channel_count), 0,
2724 "Number of channels."
2725 },
2726 {
2727 "samples_per_frame", T_INT,
2728 offsetof(PyObj_pjsua_conf_port_info, samples_per_frame), 0,
2729 "Samples per frame "
2730 },
2731 {
2732 "bits_per_sample", T_INT,
2733 offsetof(PyObj_pjsua_conf_port_info, bits_per_sample), 0,
2734 "Bits per sample"
2735 },
2736 {
2737 "listeners", T_OBJECT_EX,
2738 offsetof(PyObj_pjsua_conf_port_info, listeners), 0,
2739 "Array of listeners (in other words, ports where this port "
2740 "is transmitting to"
2741 },
2742
2743 {NULL} /* Sentinel */
2744};
2745
2746
Benny Prijono9c461142008-07-10 22:41:20 +00002747
2748
Benny Prijono55040452008-07-21 18:20:57 +00002749/*
2750 * PyTyp_pjsua_conf_port_info
2751 */
2752static PyTypeObject PyTyp_pjsua_conf_port_info =
2753{
2754 PyObject_HEAD_INIT(NULL)
2755 0, /*ob_size*/
2756 "_pjsua.Conf_Port_Info", /*tp_name*/
2757 sizeof(PyObj_pjsua_conf_port_info), /*tp_basicsize*/
2758 0, /*tp_itemsize*/
2759 (destructor)conf_port_info_dealloc,/*tp_dealloc*/
2760 0, /*tp_print*/
2761 0, /*tp_getattr*/
2762 0, /*tp_setattr*/
2763 0, /*tp_compare*/
2764 0, /*tp_repr*/
2765 0, /*tp_as_number*/
2766 0, /*tp_as_sequence*/
2767 0, /*tp_as_mapping*/
2768 0, /*tp_hash */
2769 0, /*tp_call*/
2770 0, /*tp_str*/
2771 0, /*tp_getattro*/
2772 0, /*tp_setattro*/
2773 0, /*tp_as_buffer*/
2774 Py_TPFLAGS_DEFAULT, /*tp_flags*/
2775 "Conf Port Info objects", /* tp_doc */
2776 0, /* tp_traverse */
2777 0, /* tp_clear */
2778 0, /* tp_richcompare */
2779 0, /* tp_weaklistoffset */
2780 0, /* tp_iter */
2781 0, /* tp_iternext */
2782 0, /* tp_methods */
2783 conf_port_info_members, /* tp_members */
2784 0, /* tp_getset */
2785 0, /* tp_base */
2786 0, /* tp_dict */
2787 0, /* tp_descr_get */
2788 0, /* tp_descr_set */
2789 0, /* tp_dictoffset */
2790 0, /* tp_init */
2791 0, /* tp_alloc */
2792 conf_port_info_new, /* tp_new */
2793
2794};
2795
2796//////////////////////////////////////////////////////////////////////////////
2797
2798/*
2799 * PyObj_pjmedia_snd_dev_info
2800 * PJMedia Snd Dev Info
2801 */
2802typedef struct
2803{
2804 PyObject_HEAD
2805 /* Type-specific fields go here. */
2806
2807 unsigned input_count;
2808 unsigned output_count;
2809 unsigned default_samples_per_sec;
2810 PyObject *name;
2811
2812} PyObj_pjmedia_snd_dev_info;
2813
2814/*
2815 * pjmedia_snd_dev_info_dealloc
2816 * deletes a pjmedia_snd_dev_info from memory
2817 */
2818static void pjmedia_snd_dev_info_dealloc(PyObj_pjmedia_snd_dev_info* self)
2819{
2820 Py_XDECREF(self->name);
2821 self->ob_type->tp_free((PyObject*)self);
2822}
2823
2824/*
2825 * pjmedia_snd_dev_info_new
2826 * constructor for pjmedia_snd_dev_info object
2827 */
2828static PyObject * pjmedia_snd_dev_info_new(PyTypeObject *type,
2829 PyObject *args,
2830 PyObject *kwds)
2831{
2832 PyObj_pjmedia_snd_dev_info *self;
2833
2834 PJ_UNUSED_ARG(args);
2835 PJ_UNUSED_ARG(kwds);
2836
2837 self = (PyObj_pjmedia_snd_dev_info *)type->tp_alloc(type, 0);
2838 if (self != NULL) {
2839 self->name = PyString_FromString("");
2840 }
2841 return (PyObject *)self;
2842}
2843
2844/*
2845 * pjmedia_snd_dev_info_members
2846 */
2847static PyMemberDef pjmedia_snd_dev_info_members[] =
2848{
2849 {
2850 "input_count", T_INT,
2851 offsetof(PyObj_pjmedia_snd_dev_info, input_count), 0,
2852 "Max number of input channels"
2853 },
2854 {
2855 "output_count", T_INT,
2856 offsetof(PyObj_pjmedia_snd_dev_info, output_count), 0,
2857 "Max number of output channels"
2858 },
2859 {
2860 "default_samples_per_sec", T_INT,
2861 offsetof(PyObj_pjmedia_snd_dev_info, default_samples_per_sec), 0,
2862 "Default sampling rate."
2863 },
2864 {
2865 "name", T_OBJECT_EX,
2866 offsetof(PyObj_pjmedia_snd_dev_info, name), 0,
2867 "Device name"
2868 },
2869
2870 {NULL} /* Sentinel */
2871};
2872
2873
2874/*
2875 * PyTyp_pjmedia_snd_dev_info
2876 */
2877static PyTypeObject PyTyp_pjmedia_snd_dev_info =
2878{
2879 PyObject_HEAD_INIT(NULL)
2880 0, /*ob_size*/
2881 "_pjsua.PJMedia_Snd_Dev_Info", /*tp_name*/
2882 sizeof(PyObj_pjmedia_snd_dev_info), /*tp_basicsize*/
2883 0, /*tp_itemsize*/
2884 (destructor)pjmedia_snd_dev_info_dealloc,/*tp_dealloc*/
2885 0, /*tp_print*/
2886 0, /*tp_getattr*/
2887 0, /*tp_setattr*/
2888 0, /*tp_compare*/
2889 0, /*tp_repr*/
2890 0, /*tp_as_number*/
2891 0, /*tp_as_sequence*/
2892 0, /*tp_as_mapping*/
2893 0, /*tp_hash */
2894 0, /*tp_call*/
2895 0, /*tp_str*/
2896 0, /*tp_getattro*/
2897 0, /*tp_setattro*/
2898 0, /*tp_as_buffer*/
2899 Py_TPFLAGS_DEFAULT, /*tp_flags*/
2900 "PJMedia Snd Dev Info object", /* tp_doc */
2901 0, /* tp_traverse */
2902 0, /* tp_clear */
2903 0, /* tp_richcompare */
2904 0, /* tp_weaklistoffset */
2905 0, /* tp_iter */
2906 0, /* tp_iternext */
2907 0, /* tp_methods */
2908 pjmedia_snd_dev_info_members, /* tp_members */
2909 0, /* tp_getset */
2910 0, /* tp_base */
2911 0, /* tp_dict */
2912 0, /* tp_descr_get */
2913 0, /* tp_descr_set */
2914 0, /* tp_dictoffset */
2915 0, /* tp_init */
2916 0, /* tp_alloc */
2917 pjmedia_snd_dev_info_new, /* tp_new */
2918
2919};
2920
2921//////////////////////////////////////////////////////////////////////////////
2922
2923/*
2924 * PyObj_pjmedia_codec_param_info
2925 * PJMedia Codec Param Info
2926 */
2927typedef struct
2928{
2929 PyObject_HEAD
2930 /* Type-specific fields go here. */
2931
2932 unsigned clock_rate;
2933 unsigned channel_cnt;
2934 pj_uint32_t avg_bps;
2935 pj_uint16_t frm_ptime;
2936 pj_uint8_t pcm_bits_per_sample;
2937 pj_uint8_t pt;
2938
2939} PyObj_pjmedia_codec_param_info;
2940
2941
2942
2943/*
2944 * pjmedia_codec_param_info_members
2945 */
2946static PyMemberDef pjmedia_codec_param_info_members[] =
2947{
2948 {
2949 "clock_rate", T_INT,
2950 offsetof(PyObj_pjmedia_codec_param_info, clock_rate), 0,
2951 "Sampling rate in Hz"
2952 },
2953 {
2954 "channel_cnt", T_INT,
2955 offsetof(PyObj_pjmedia_codec_param_info, channel_cnt), 0,
2956 "Channel count"
2957 },
2958 {
2959 "avg_bps", T_INT,
2960 offsetof(PyObj_pjmedia_codec_param_info, avg_bps), 0,
2961 "Average bandwidth in bits/sec"
2962 },
2963 {
2964 "frm_ptime", T_INT,
2965 offsetof(PyObj_pjmedia_codec_param_info, frm_ptime), 0,
2966 "Base frame ptime in msec."
2967 },
2968 {
2969 "pcm_bits_per_sample", T_INT,
2970 offsetof(PyObj_pjmedia_codec_param_info, pcm_bits_per_sample), 0,
2971 "Bits/sample in the PCM side"
2972 },
2973 {
2974 "pt", T_INT,
2975 offsetof(PyObj_pjmedia_codec_param_info, pt), 0,
2976 "Payload type"
2977 },
2978
2979 {NULL} /* Sentinel */
2980};
2981
2982
2983/*
2984 * PyTyp_pjmedia_codec_param_info
2985 */
2986static PyTypeObject PyTyp_pjmedia_codec_param_info =
2987{
2988 PyObject_HEAD_INIT(NULL)
2989 0, /*ob_size*/
2990 "_pjsua.PJMedia_Codec_Param_Info", /*tp_name*/
2991 sizeof(PyObj_pjmedia_codec_param_info), /*tp_basicsize*/
2992 0, /*tp_itemsize*/
2993 0, /*tp_dealloc*/
2994 0, /*tp_print*/
2995 0, /*tp_getattr*/
2996 0, /*tp_setattr*/
2997 0, /*tp_compare*/
2998 0, /*tp_repr*/
2999 0, /*tp_as_number*/
3000 0, /*tp_as_sequence*/
3001 0, /*tp_as_mapping*/
3002 0, /*tp_hash */
3003 0, /*tp_call*/
3004 0, /*tp_str*/
3005 0, /*tp_getattro*/
3006 0, /*tp_setattro*/
3007 0, /*tp_as_buffer*/
3008 Py_TPFLAGS_DEFAULT, /*tp_flags*/
3009 "PJMedia Codec Param Info objects",/* tp_doc */
3010 0, /* tp_traverse */
3011 0, /* tp_clear */
3012 0, /* tp_richcompare */
3013 0, /* tp_weaklistoffset */
3014 0, /* tp_iter */
3015 0, /* tp_iternext */
3016 0, /* tp_methods */
3017 pjmedia_codec_param_info_members,/* tp_members */
3018};
3019
3020
3021//////////////////////////////////////////////////////////////////////////////
3022
3023/*
3024 * PyObj_pjmedia_codec_param_setting
3025 * PJMedia Codec Param Setting
3026 */
3027typedef struct
3028{
3029 PyObject_HEAD
3030 /* Type-specific fields go here. */
3031 pj_uint8_t frm_per_pkt;
3032 unsigned vad;
3033 unsigned cng;
3034 unsigned penh;
3035 unsigned plc;
Benny Prijonoc8215b32008-09-04 07:37:30 +00003036#if 0
Benny Prijono55040452008-07-21 18:20:57 +00003037 pj_uint8_t enc_fmtp_mode;
3038 pj_uint8_t dec_fmtp_mode;
Benny Prijonoc8215b32008-09-04 07:37:30 +00003039#endif
Benny Prijono55040452008-07-21 18:20:57 +00003040
3041} PyObj_pjmedia_codec_param_setting;
3042
3043
3044
3045/*
3046 * pjmedia_codec_param_setting_members
3047 */
3048static PyMemberDef pjmedia_codec_param_setting_members[] =
3049{
3050 {
3051 "frm_per_pkt", T_INT,
3052 offsetof(PyObj_pjmedia_codec_param_setting, frm_per_pkt), 0,
3053 "Number of frames per packet"
3054 },
3055 {
3056 "vad", T_INT,
3057 offsetof(PyObj_pjmedia_codec_param_setting, vad), 0,
3058 "Voice Activity Detector"
3059 },
3060 {
3061 "cng", T_INT,
3062 offsetof(PyObj_pjmedia_codec_param_setting, cng), 0,
3063 "Comfort Noise Generator"
3064 },
3065 {
3066 "penh", T_INT,
3067 offsetof(PyObj_pjmedia_codec_param_setting, penh), 0,
3068 "Perceptual Enhancement"
3069 },
3070 {
3071 "plc", T_INT,
3072 offsetof(PyObj_pjmedia_codec_param_setting, plc), 0,
3073 "Packet loss concealment"
3074 },
Benny Prijonoc8215b32008-09-04 07:37:30 +00003075#if 0 // no longer valid with latest modification in codec
Benny Prijono55040452008-07-21 18:20:57 +00003076 {
3077 "enc_fmtp_mode", T_INT,
3078 offsetof(PyObj_pjmedia_codec_param_setting, enc_fmtp_mode), 0,
3079 "Mode param in fmtp (def:0)"
3080 },
3081 {
3082 "dec_fmtp_mode", T_INT,
3083 offsetof(PyObj_pjmedia_codec_param_setting, dec_fmtp_mode), 0,
3084 "Mode param in fmtp (def:0)"
3085 },
Benny Prijonoc8215b32008-09-04 07:37:30 +00003086#endif
Benny Prijono55040452008-07-21 18:20:57 +00003087
3088 {NULL} /* Sentinel */
3089};
3090
3091
3092/*
3093 * PyTyp_pjmedia_codec_param_setting
3094 */
3095static PyTypeObject PyTyp_pjmedia_codec_param_setting =
3096{
3097 PyObject_HEAD_INIT(NULL)
3098 0, /*ob_size*/
3099 "_pjsua.PJMedia_Codec_Param_Setting",/*tp_name*/
3100 sizeof(PyObj_pjmedia_codec_param_setting), /*tp_basicsize*/
3101 0, /*tp_itemsize*/
3102 0, /*tp_dealloc*/
3103 0, /*tp_print*/
3104 0, /*tp_getattr*/
3105 0, /*tp_setattr*/
3106 0, /*tp_compare*/
3107 0, /*tp_repr*/
3108 0, /*tp_as_number*/
3109 0, /*tp_as_sequence*/
3110 0, /*tp_as_mapping*/
3111 0, /*tp_hash */
3112 0, /*tp_call*/
3113 0, /*tp_str*/
3114 0, /*tp_getattro*/
3115 0, /*tp_setattro*/
3116 0, /*tp_as_buffer*/
3117 Py_TPFLAGS_DEFAULT, /*tp_flags*/
3118 "PJMedia Codec Param Setting", /* tp_doc */
3119 0, /* tp_traverse */
3120 0, /* tp_clear */
3121 0, /* tp_richcompare */
3122 0, /* tp_weaklistoffset */
3123 0, /* tp_iter */
3124 0, /* tp_iternext */
3125 0, /* tp_methods */
3126 pjmedia_codec_param_setting_members,/* tp_members */
3127};
3128
3129//////////////////////////////////////////////////////////////////////////////
3130
3131
3132/*
3133 * PyObj_pjmedia_codec_param
3134 * PJMedia Codec Param
3135 */
3136typedef struct
3137{
3138 PyObject_HEAD
3139 /* Type-specific fields go here. */
3140
3141 PyObj_pjmedia_codec_param_info * info;
3142 PyObj_pjmedia_codec_param_setting * setting;
3143
3144} PyObj_pjmedia_codec_param;
3145
3146/*
3147 * pjmedia_codec_param_dealloc
3148 * deletes a pjmedia_codec_param from memory
3149 */
3150static void pjmedia_codec_param_dealloc(PyObj_pjmedia_codec_param* self)
3151{
3152 Py_XDECREF(self->info);
3153 Py_XDECREF(self->setting);
3154 self->ob_type->tp_free((PyObject*)self);
3155}
3156
3157/*
3158 * pjmedia_codec_param_new
3159 * constructor for pjmedia_codec_param object
3160 */
3161static PyObject * pjmedia_codec_param_new(PyTypeObject *type,
3162 PyObject *args,
3163 PyObject *kwds)
3164{
3165 PyObj_pjmedia_codec_param *self;
3166
3167 PJ_UNUSED_ARG(args);
3168 PJ_UNUSED_ARG(kwds);
3169
3170 self = (PyObj_pjmedia_codec_param *)type->tp_alloc(type, 0);
3171 if (self != NULL) {
3172 self->info = (PyObj_pjmedia_codec_param_info *)
3173 PyType_GenericNew(&PyTyp_pjmedia_codec_param_info,
3174 NULL, NULL);
3175 self->setting = (PyObj_pjmedia_codec_param_setting *)
3176 PyType_GenericNew(&PyTyp_pjmedia_codec_param_setting,
3177 NULL, NULL);
3178 }
3179 return (PyObject *)self;
3180}
3181
3182/*
3183 * pjmedia_codec_param_members
3184 */
3185static PyMemberDef pjmedia_codec_param_members[] =
3186{
3187
3188 {
3189 "info", T_OBJECT_EX,
3190 offsetof(PyObj_pjmedia_codec_param, info), 0,
3191 "The 'info' part of codec param describes the capability of the codec,"
3192 " and the value should NOT be changed by application."
3193 },
3194 {
3195 "setting", T_OBJECT_EX,
3196 offsetof(PyObj_pjmedia_codec_param, setting), 0,
3197 "The 'setting' part of codec param describes various settings to be "
3198 "applied to the codec. When the codec param is retrieved from the "
3199 "codec or codec factory, the values of these will be filled by "
3200 "the capability of the codec. Any features that are supported by "
3201 "the codec (e.g. vad or plc) will be turned on, so that application "
3202 "can query which capabilities are supported by the codec. "
3203 "Application may change the settings here before instantiating "
3204 "the codec/stream."
3205 },
3206
3207 {NULL} /* Sentinel */
3208};
3209
3210/*
3211 * PyTyp_pjmedia_codec_param
3212 */
3213static PyTypeObject PyTyp_pjmedia_codec_param =
3214{
3215 PyObject_HEAD_INIT(NULL)
3216 0, /*ob_size*/
3217 "_pjsua.PJMedia_Codec_Param", /*tp_name*/
3218 sizeof(PyObj_pjmedia_codec_param),/*tp_basicsize*/
3219 0, /*tp_itemsize*/
3220 (destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/
3221 0, /*tp_print*/
3222 0, /*tp_getattr*/
3223 0, /*tp_setattr*/
3224 0, /*tp_compare*/
3225 0, /*tp_repr*/
3226 0, /*tp_as_number*/
3227 0, /*tp_as_sequence*/
3228 0, /*tp_as_mapping*/
3229 0, /*tp_hash */
3230 0, /*tp_call*/
3231 0, /*tp_str*/
3232 0, /*tp_getattro*/
3233 0, /*tp_setattro*/
3234 0, /*tp_as_buffer*/
3235 Py_TPFLAGS_DEFAULT, /*tp_flags*/
3236 "PJMedia Codec Param", /* tp_doc */
3237 0, /* tp_traverse */
3238 0, /* tp_clear */
3239 0, /* tp_richcompare */
3240 0, /* tp_weaklistoffset */
3241 0, /* tp_iter */
3242 0, /* tp_iternext */
3243 0, /* tp_methods */
3244 pjmedia_codec_param_members, /* tp_members */
3245 0, /* tp_getset */
3246 0, /* tp_base */
3247 0, /* tp_dict */
3248 0, /* tp_descr_get */
3249 0, /* tp_descr_set */
3250 0, /* tp_dictoffset */
3251 0, /* tp_init */
3252 0, /* tp_alloc */
3253 pjmedia_codec_param_new, /* tp_new */
3254
3255};
3256
3257//////////////////////////////////////////////////////////////////////////////
3258
3259/*
3260 * PyObj_pjsua_call_info
3261 * Call Info
3262 */
3263typedef struct
3264{
3265 PyObject_HEAD
3266 /* Type-specific fields go here. */
3267
3268 int id;
3269 int role;
3270 int acc_id;
3271 PyObject *local_info;
3272 PyObject *local_contact;
3273 PyObject *remote_info;
3274 PyObject *remote_contact;
3275 PyObject *call_id;
3276 int state;
3277 PyObject *state_text;
3278 int last_status;
3279 PyObject *last_status_text;
3280 int media_status;
3281 int media_dir;
3282 int conf_slot;
3283 int connect_duration;
3284 int total_duration;
3285
3286} PyObj_pjsua_call_info;
3287
3288
3289/*
3290 * call_info_dealloc
3291 * deletes a call_info from memory
3292 */
3293static void call_info_dealloc(PyObj_pjsua_call_info* self)
3294{
3295 Py_XDECREF(self->local_info);
3296 Py_XDECREF(self->local_contact);
3297 Py_XDECREF(self->remote_info);
3298 Py_XDECREF(self->remote_contact);
3299 Py_XDECREF(self->call_id);
3300 Py_XDECREF(self->state_text);
3301 Py_XDECREF(self->last_status_text);
3302 self->ob_type->tp_free((PyObject*)self);
3303}
3304
3305
3306/*
3307 * call_info_new
3308 * constructor for call_info object
3309 */
3310static PyObject * call_info_new(PyTypeObject *type, PyObject *args,
3311 PyObject *kwds)
3312{
3313 PyObj_pjsua_call_info *self;
3314
3315 PJ_UNUSED_ARG(args);
3316 PJ_UNUSED_ARG(kwds);
3317
3318 self = (PyObj_pjsua_call_info *)type->tp_alloc(type, 0);
3319 if (self != NULL) {
3320 self->local_info = PyString_FromString("");
3321 self->local_contact = PyString_FromString("");
3322 self->remote_info = PyString_FromString("");
3323 self->remote_contact = PyString_FromString("");
3324 self->call_id = PyString_FromString("");
3325 self->state_text = PyString_FromString("");
3326 self->last_status_text = PyString_FromString("");
3327 }
3328 return (PyObject *)self;
3329}
3330
3331/*
3332 * call_info_members
3333 */
3334static PyMemberDef call_info_members[] =
3335{
3336 {
3337 "id", T_INT,
3338 offsetof(PyObj_pjsua_call_info, id), 0,
3339 "Call identification"
3340 },
3341 {
3342 "role", T_INT,
3343 offsetof(PyObj_pjsua_call_info, role), 0,
3344 "Initial call role (UAC == caller)"
3345 },
3346 {
3347 "acc_id", T_INT,
3348 offsetof(PyObj_pjsua_call_info, acc_id), 0,
3349 "The account ID where this call belongs."
3350 },
3351 {
3352 "local_info", T_OBJECT_EX,
3353 offsetof(PyObj_pjsua_call_info, local_info), 0,
3354 "Local URI"
3355 },
3356 {
3357 "local_contact", T_OBJECT_EX,
3358 offsetof(PyObj_pjsua_call_info, local_contact), 0,
3359 "Local Contact"
3360 },
3361 {
3362 "remote_info", T_OBJECT_EX,
3363 offsetof(PyObj_pjsua_call_info, remote_info), 0,
3364 "Remote URI"
3365 },
3366 {
3367 "remote_contact", T_OBJECT_EX,
3368 offsetof(PyObj_pjsua_call_info, remote_contact), 0,
3369 "Remote Contact"
3370 },
3371 {
3372 "call_id", T_OBJECT_EX,
3373 offsetof(PyObj_pjsua_call_info, call_id), 0,
3374 "Dialog Call-ID string"
3375 },
3376 {
3377 "state", T_INT,
3378 offsetof(PyObj_pjsua_call_info, state), 0,
3379 "Call state"
3380 },
3381 {
3382 "state_text", T_OBJECT_EX,
3383 offsetof(PyObj_pjsua_call_info, state_text), 0,
3384 "Text describing the state "
3385 },
3386 {
3387 "last_status", T_INT,
3388 offsetof(PyObj_pjsua_call_info, last_status), 0,
3389 "Last status code heard, which can be used as cause code"
3390 },
3391 {
3392 "last_status_text", T_OBJECT_EX,
3393 offsetof(PyObj_pjsua_call_info, last_status_text), 0,
3394 "The reason phrase describing the status."
3395 },
3396 {
3397 "media_status", T_INT,
3398 offsetof(PyObj_pjsua_call_info, media_status), 0,
3399 "Call media status."
3400 },
3401 {
3402 "media_dir", T_INT,
3403 offsetof(PyObj_pjsua_call_info, media_dir), 0,
3404 "Media direction"
3405 },
3406 {
3407 "conf_slot", T_INT,
3408 offsetof(PyObj_pjsua_call_info, conf_slot), 0,
3409 "The conference port number for the call"
3410 },
3411 {
3412 "connect_duration", T_INT,
3413 offsetof(PyObj_pjsua_call_info, connect_duration), 0,
3414 "Up-to-date call connected duration(zero when call is not established)"
3415 },
3416 {
3417 "total_duration", T_INT,
3418 offsetof(PyObj_pjsua_call_info, total_duration), 0,
3419 "Total call duration, including set-up time"
3420 },
3421
3422 {NULL} /* Sentinel */
3423};
3424
3425
3426
3427
3428/*
3429 * PyTyp_pjsua_call_info
3430 */
3431static PyTypeObject PyTyp_pjsua_call_info =
3432{
3433 PyObject_HEAD_INIT(NULL)
3434 0, /*ob_size*/
3435 "_pjsua.Call_Info", /*tp_name*/
3436 sizeof(PyObj_pjsua_call_info), /*tp_basicsize*/
3437 0, /*tp_itemsize*/
3438 (destructor)call_info_dealloc, /*tp_dealloc*/
3439 0, /*tp_print*/
3440 0, /*tp_getattr*/
3441 0, /*tp_setattr*/
3442 0, /*tp_compare*/
3443 0, /*tp_repr*/
3444 0, /*tp_as_number*/
3445 0, /*tp_as_sequence*/
3446 0, /*tp_as_mapping*/
3447 0, /*tp_hash */
3448 0, /*tp_call*/
3449 0, /*tp_str*/
3450 0, /*tp_getattro*/
3451 0, /*tp_setattro*/
3452 0, /*tp_as_buffer*/
3453 Py_TPFLAGS_DEFAULT, /*tp_flags*/
3454 "Call Info", /* tp_doc */
3455 0, /* tp_traverse */
3456 0, /* tp_clear */
3457 0, /* tp_richcompare */
3458 0, /* tp_weaklistoffset */
3459 0, /* tp_iter */
3460 0, /* tp_iternext */
3461 0, /* tp_methods */
3462 call_info_members, /* tp_members */
3463 0, /* tp_getset */
3464 0, /* tp_base */
3465 0, /* tp_dict */
3466 0, /* tp_descr_get */
3467 0, /* tp_descr_set */
3468 0, /* tp_dictoffset */
3469 0, /* tp_init */
3470 0, /* tp_alloc */
3471 call_info_new, /* tp_new */
3472
3473};
3474
3475
3476
3477//////////////////////////////////////////////////////////////////////////////
Benny Prijono9c461142008-07-10 22:41:20 +00003478
3479#endif /* __PY_PJSUA_H__ */
3480