Debian Codegraph @

Xpjproject/pjsip-apps/src/python/_pjsua.h

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