blob: 2766d17a51b2da49a32819980fcc971480a892b9 [file] [log] [blame]
Alexandre Lision8af73cb2013-12-10 14:11:20 -05001/* $Id$ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#include "py_pjsua.h"
21
22#define THIS_FILE "main.c"
23#define POOL_SIZE 4000
24#define SND_DEV_NUM 64
25#define SND_NAME_LEN 64
26
27/* LIB BASE */
28
29static PyObject* obj_log_cb;
30static long thread_id;
31
32#define ENTER_PYTHON() PyGILState_STATE state = PyGILState_Ensure()
33#define LEAVE_PYTHON() PyGILState_Release(state)
34
35/*
36 * cb_log_cb
37 * declares method for reconfiguring logging process for callback struct
38 */
39static void cb_log_cb(int level, const char *data, int len)
40{
41
42 /* Ignore if this callback is called from alien thread context,
43 * or otherwise it will crash Python.
44 */
45 if (pj_thread_local_get(thread_id) == 0)
46 return;
47
48 if (PyCallable_Check(obj_log_cb))
49 {
50 ENTER_PYTHON();
51
52 PyObject_CallFunctionObjArgs(
53 obj_log_cb, Py_BuildValue("i",level),
54 PyString_FromString(data), Py_BuildValue("i",len), NULL
55 );
56
57 LEAVE_PYTHON();
58 }
59}
60
61
62
63/*
64 * The global callback object.
65 */
66static PyObj_pjsua_callback * g_obj_callback;
67
68
69/*
70 * cb_on_call_state
71 * declares method on_call_state for callback struct
72 */
73static void cb_on_call_state(pjsua_call_id call_id, pjsip_event *e)
74{
75 if (PyCallable_Check(g_obj_callback->on_call_state))
76 {
77 PyObj_pjsip_event * obj;
78
79 ENTER_PYTHON();
80
81 obj = (PyObj_pjsip_event *)PyType_GenericNew(&PyTyp_pjsip_event,
82 NULL, NULL);
83
84 obj->event = e;
85
86 PyObject_CallFunctionObjArgs(
87 g_obj_callback->on_call_state,
88 Py_BuildValue("i",call_id),
89 obj,
90 NULL
91 );
92
93 LEAVE_PYTHON();
94 }
95}
96
97
98/*
99 * cb_on_incoming_call
100 * declares method on_incoming_call for callback struct
101 */
102static void cb_on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
103 pjsip_rx_data *rdata)
104{
105 if (PyCallable_Check(g_obj_callback->on_incoming_call))
106 {
107 PyObj_pjsip_rx_data * obj;
108
109 ENTER_PYTHON();
110
111 obj = (PyObj_pjsip_rx_data *)PyType_GenericNew(&PyTyp_pjsip_rx_data,
112 NULL, NULL);
113 obj->rdata = rdata;
114
115 PyObject_CallFunctionObjArgs(
116 g_obj_callback->on_incoming_call,
117 Py_BuildValue("i",acc_id),
118 Py_BuildValue("i",call_id),
119 obj,
120 NULL
121 );
122
123 LEAVE_PYTHON();
124 }
125}
126
127
128/*
129 * cb_on_call_media_state
130 * declares method on_call_media_state for callback struct
131 */
132static void cb_on_call_media_state(pjsua_call_id call_id)
133{
134 if (PyCallable_Check(g_obj_callback->on_call_media_state))
135 {
136 ENTER_PYTHON();
137
138 PyObject_CallFunction(
139 g_obj_callback->on_call_media_state,
140 "i",
141 call_id,
142 NULL
143 );
144
145 LEAVE_PYTHON();
146 }
147}
148
149
150/*
151 * cb_on_dtmf_digit()
152 * Callback from PJSUA-LIB on receiving DTMF digit
153 */
154static void cb_on_dtmf_digit(pjsua_call_id call_id, int digit)
155{
156 if (PyCallable_Check(g_obj_callback->on_dtmf_digit))
157 {
158 char digit_str[10];
159
160 ENTER_PYTHON();
161
162 pj_ansi_snprintf(digit_str, sizeof(digit_str), "%c", digit);
163
164 PyObject_CallFunctionObjArgs(
165 g_obj_callback->on_dtmf_digit,
166 Py_BuildValue("i",call_id),
167 PyString_FromString(digit_str),
168 NULL
169 );
170
171 LEAVE_PYTHON();
172 }
173}
174
175
176/*
177 * Notify application on call being transfered.
178 * !modified @061206
179 */
180static void cb_on_call_transfer_request(pjsua_call_id call_id,
181 const pj_str_t *dst,
182 pjsip_status_code *code)
183{
184 if (PyCallable_Check(g_obj_callback->on_call_transfer_request))
185 {
186 PyObject * ret;
187 int cd;
188
189 ENTER_PYTHON();
190
191 ret = PyObject_CallFunctionObjArgs(
192 g_obj_callback->on_call_transfer_request,
193 Py_BuildValue("i",call_id),
194 PyString_FromStringAndSize(dst->ptr, dst->slen),
195 Py_BuildValue("i",*code),
196 NULL
197 );
198 if (ret != NULL) {
199 if (ret != Py_None) {
200 if (PyArg_Parse(ret,"i",&cd)) {
201 *code = cd;
202 }
203 }
204 }
205
206 LEAVE_PYTHON();
207 }
208}
209
210
211/*
212 * Notify application of the status of previously sent call
213 * transfer request. Application can monitor the status of the
214 * call transfer request, for example to decide whether to
215 * terminate existing call.
216 * !modified @061206
217 */
218static void cb_on_call_transfer_status( pjsua_call_id call_id,
219 int status_code,
220 const pj_str_t *status_text,
221 pj_bool_t final,
222 pj_bool_t *p_cont)
223{
224 if (PyCallable_Check(g_obj_callback->on_call_transfer_status))
225 {
226 PyObject * ret;
227 int cnt;
228
229 ENTER_PYTHON();
230
231 ret = PyObject_CallFunctionObjArgs(
232 g_obj_callback->on_call_transfer_status,
233 Py_BuildValue("i",call_id),
234 Py_BuildValue("i",status_code),
235 PyString_FromStringAndSize(status_text->ptr, status_text->slen),
236 Py_BuildValue("i",final),
237 Py_BuildValue("i",*p_cont),
238 NULL
239 );
240 if (ret != NULL) {
241 if (ret != Py_None) {
242 if (PyArg_Parse(ret,"i",&cnt)) {
243 *p_cont = cnt;
244 }
245 }
246 }
247
248 LEAVE_PYTHON();
249 }
250}
251
252
253/*
254 * Notify application about incoming INVITE with Replaces header.
255 * Application may reject the request by setting non-2xx code.
256 * !modified @061206
257 */
258static void cb_on_call_replace_request( pjsua_call_id call_id,
259 pjsip_rx_data *rdata,
260 int *st_code,
261 pj_str_t *st_text)
262{
263 if (PyCallable_Check(g_obj_callback->on_call_replace_request))
264 {
265 PyObject * ret;
266 PyObject * txt;
267 int cd;
268 PyObj_pjsip_rx_data * obj;
269
270 ENTER_PYTHON();
271
272 obj = (PyObj_pjsip_rx_data *)PyType_GenericNew(&PyTyp_pjsip_rx_data,
273 NULL, NULL);
274 obj->rdata = rdata;
275
276 ret = PyObject_CallFunctionObjArgs(
277 g_obj_callback->on_call_replace_request,
278 Py_BuildValue("i",call_id),
279 obj,
280 Py_BuildValue("i",*st_code),
281 PyString_FromStringAndSize(st_text->ptr, st_text->slen),
282 NULL
283 );
284 if (ret != NULL) {
285 if (ret != Py_None) {
286 if (PyArg_ParseTuple(ret,"iO",&cd, &txt)) {
287 *st_code = cd;
288 st_text->ptr = PyString_AsString(txt);
289 st_text->slen = strlen(PyString_AsString(txt));
290 }
291 }
292 }
293
294 LEAVE_PYTHON();
295 }
296}
297
298
299/*
300 * Notify application that an existing call has been replaced with
301 * a new call. This happens when PJSUA-API receives incoming INVITE
302 * request with Replaces header.
303 */
304static void cb_on_call_replaced(pjsua_call_id old_call_id,
305 pjsua_call_id new_call_id)
306{
307 if (PyCallable_Check(g_obj_callback->on_call_replaced))
308 {
309 ENTER_PYTHON();
310
311 PyObject_CallFunctionObjArgs(
312 g_obj_callback->on_call_replaced,
313 Py_BuildValue("i",old_call_id),
314 Py_BuildValue("i",new_call_id),
315 NULL
316 );
317
318 LEAVE_PYTHON();
319 }
320}
321
322
323/*
324 * cb_on_reg_state
325 * declares method on_reg_state for callback struct
326 */
327static void cb_on_reg_state(pjsua_acc_id acc_id)
328{
329 if (PyCallable_Check(g_obj_callback->on_reg_state))
330 {
331 ENTER_PYTHON();
332
333 PyObject_CallFunction(
334 g_obj_callback->on_reg_state,
335 "i",
336 acc_id,
337 NULL
338 );
339
340 LEAVE_PYTHON();
341 }
342}
343
344
345/*
346 * cb_on_buddy_state
347 * declares method on_buddy state for callback struct
348 */
349static void cb_on_buddy_state(pjsua_buddy_id buddy_id)
350{
351 if (PyCallable_Check(g_obj_callback->on_buddy_state))
352 {
353 ENTER_PYTHON();
354
355 PyObject_CallFunction(
356 g_obj_callback->on_buddy_state,
357 "i",
358 buddy_id,
359 NULL
360 );
361
362 LEAVE_PYTHON();
363 }
364}
365
366/*
367 * cb_on_pager
368 * declares method on_pager for callback struct
369 */
370static void cb_on_pager(pjsua_call_id call_id, const pj_str_t *from,
371 const pj_str_t *to, const pj_str_t *contact,
372 const pj_str_t *mime_type, const pj_str_t *body)
373{
374 if (PyCallable_Check(g_obj_callback->on_pager))
375 {
376 ENTER_PYTHON();
377
378 PyObject_CallFunctionObjArgs(
379 g_obj_callback->on_pager,Py_BuildValue("i",call_id),
380 PyString_FromStringAndSize(from->ptr, from->slen),
381 PyString_FromStringAndSize(to->ptr, to->slen),
382 PyString_FromStringAndSize(contact->ptr, contact->slen),
383 PyString_FromStringAndSize(mime_type->ptr, mime_type->slen),
384 PyString_FromStringAndSize(body->ptr, body->slen),
385 NULL
386 );
387
388 LEAVE_PYTHON();
389 }
390}
391
392
393/*
394 * cb_on_pager_status
395 * declares method on_pager_status for callback struct
396 */
397static void cb_on_pager_status(pjsua_call_id call_id, const pj_str_t *to,
398 const pj_str_t *body, void *user_data,
399 pjsip_status_code status,
400 const pj_str_t *reason)
401{
402 if (PyCallable_Check(g_obj_callback->on_pager))
403 {
404 PyObject * obj_user_data;
405
406 ENTER_PYTHON();
407
408 obj_user_data = Py_BuildValue("i", user_data);
409
410 PyObject_CallFunctionObjArgs(
411 g_obj_callback->on_pager_status,
412 Py_BuildValue("i",call_id),
413 PyString_FromStringAndSize(to->ptr, to->slen),
414 PyString_FromStringAndSize(body->ptr, body->slen),
415 obj_user_data,
416 Py_BuildValue("i",status),
417 PyString_FromStringAndSize(reason->ptr,reason->slen),
418 NULL
419 );
420
421 LEAVE_PYTHON();
422 }
423}
424
425
426/*
427 * cb_on_typing
428 * declares method on_typing for callback struct
429 */
430static void cb_on_typing(pjsua_call_id call_id, const pj_str_t *from,
431 const pj_str_t *to, const pj_str_t *contact,
432 pj_bool_t is_typing)
433{
434 if (PyCallable_Check(g_obj_callback->on_typing))
435 {
436 ENTER_PYTHON();
437
438 PyObject_CallFunctionObjArgs(
439 g_obj_callback->on_typing,Py_BuildValue("i",call_id),
440 PyString_FromStringAndSize(from->ptr, from->slen),
441 PyString_FromStringAndSize(to->ptr, to->slen),
442 PyString_FromStringAndSize(contact->ptr, contact->slen),
443 Py_BuildValue("i",is_typing),
444 NULL
445 );
446
447 LEAVE_PYTHON();
448 }
449}
450
451
452
453/*
454 * translate_hdr
455 * internal function
456 * translate from hdr_list to pjsip_generic_string_hdr
457 */
458void translate_hdr(pj_pool_t *pool, pjsip_hdr *hdr, PyObject *py_hdr_list)
459{
460 pj_list_init(hdr);
461
462 if (PyList_Check(py_hdr_list)) {
463 int i;
464
465 for (i = 0; i < PyList_Size(py_hdr_list); i++)
466 {
467 pj_str_t hname, hvalue;
468 pjsip_generic_string_hdr * new_hdr;
469 PyObject * tuple = PyList_GetItem(py_hdr_list, i);
470
471 if (PyTuple_Check(tuple))
472 {
473 hname.ptr = PyString_AsString(PyTuple_GetItem(tuple,0));
474 hname.slen = strlen(PyString_AsString
475 (PyTuple_GetItem(tuple,0)));
476 hvalue.ptr = PyString_AsString(PyTuple_GetItem(tuple,1));
477 hvalue.slen = strlen(PyString_AsString
478 (PyTuple_GetItem(tuple,1)));
479 } else {
480 hname.ptr = "";
481 hname.slen = 0;
482 hvalue.ptr = "";
483 hvalue.slen = 0;
484 }
485 new_hdr = pjsip_generic_string_hdr_create(pool, &hname, &hvalue);
486 pj_list_push_back((pj_list_type *)hdr, (pj_list_type *)new_hdr);
487 }
488 }
489}
490
491/*
492 * translate_hdr_rev
493 * internal function
494 * translate from pjsip_generic_string_hdr to hdr_list
495 */
496
497void translate_hdr_rev(pjsip_generic_string_hdr *hdr, PyObject *py_hdr_list)
498{
499 int i;
500 int len;
501 pjsip_generic_string_hdr * p_hdr;
502
503 len = pj_list_size(hdr);
504
505 if (len > 0)
506 {
507 p_hdr = hdr;
508 Py_XDECREF(py_hdr_list);
509 py_hdr_list = PyList_New(len);
510
511 for (i = 0; i < len && p_hdr != NULL; i++)
512 {
513 PyObject * tuple;
514 PyObject * str;
515
516 tuple = PyTuple_New(2);
517
518 str = PyString_FromStringAndSize(p_hdr->name.ptr, p_hdr->name.slen);
519 PyTuple_SetItem(tuple, 0, str);
520 str = PyString_FromStringAndSize
521 (hdr->hvalue.ptr, p_hdr->hvalue.slen);
522 PyTuple_SetItem(tuple, 1, str);
523 PyList_SetItem(py_hdr_list, i, tuple);
524 p_hdr = p_hdr->next;
525 }
526 }
527
528
529}
530
531/*
532 * py_pjsua_thread_register
533 * !added @ 061206
534 */
535static PyObject *py_pjsua_thread_register(PyObject *pSelf, PyObject *pArgs)
536{
537
538 pj_status_t status;
539 const char *name;
540 PyObject *py_desc;
541 pj_thread_t *thread;
542 void *thread_desc;
543#if 0
544 int size;
545 int i;
546 int *td;
547#endif
548
549 PJ_UNUSED_ARG(pSelf);
550
551 if (!PyArg_ParseTuple(pArgs, "sO", &name, &py_desc))
552 {
553 return NULL;
554 }
555#if 0
556 size = PyList_Size(py_desc);
557 td = (int *)malloc(size * sizeof(int));
558 for (i = 0; i < size; i++)
559 {
560 if (!PyArg_Parse(PyList_GetItem(py_desc,i),"i", td[i]))
561 {
562 return NULL;
563 }
564 }
565 thread_desc = td;
566#else
567 thread_desc = malloc(sizeof(pj_thread_desc));
568#endif
569 status = pj_thread_register(name, thread_desc, &thread);
570
571 if (status == PJ_SUCCESS)
572 status = pj_thread_local_set(thread_id, (void*)1);
573 return Py_BuildValue("i",status);
574}
575
576/*
577 * py_pjsua_logging_config_default
578 * !modified @ 051206
579 */
580static PyObject *py_pjsua_logging_config_default(PyObject *pSelf,
581 PyObject *pArgs)
582{
583 PyObj_pjsua_logging_config *obj;
584 pjsua_logging_config cfg;
585
586 PJ_UNUSED_ARG(pSelf);
587
588 if (!PyArg_ParseTuple(pArgs, ""))
589 {
590 return NULL;
591 }
592
593 pjsua_logging_config_default(&cfg);
594 obj = (PyObj_pjsua_logging_config *) PyObj_pjsua_logging_config_new
595 (&PyTyp_pjsua_logging_config,NULL,NULL);
596 PyObj_pjsua_logging_config_import(obj, &cfg);
597
598 return (PyObject *)obj;
599}
600
601
602/*
603 * py_pjsua_config_default
604 * !modified @ 051206
605 */
606static PyObject *py_pjsua_config_default(PyObject *pSelf, PyObject *pArgs)
607{
608 PyObj_pjsua_config *obj;
609 pjsua_config cfg;
610
611 PJ_UNUSED_ARG(pSelf);
612
613 if (!PyArg_ParseTuple(pArgs, ""))
614 {
615 return NULL;
616 }
617 pjsua_config_default(&cfg);
618 obj = (PyObj_pjsua_config *) PyObj_pjsua_config_new(&PyTyp_pjsua_config, NULL, NULL);
619 PyObj_pjsua_config_import(obj, &cfg);
620
621 return (PyObject *)obj;
622}
623
624
625/*
626 * py_pjsua_media_config_default
627 * !modified @ 051206
628 */
629static PyObject * py_pjsua_media_config_default(PyObject *pSelf,
630 PyObject *pArgs)
631{
632 PyObj_pjsua_media_config *obj;
633 pjsua_media_config cfg;
634
635 PJ_UNUSED_ARG(pSelf);
636
637 if (!PyArg_ParseTuple(pArgs, ""))
638 {
639 return NULL;
640 }
641 pjsua_media_config_default(&cfg);
642 obj = (PyObj_pjsua_media_config *)
643 PyType_GenericNew(&PyTyp_pjsua_media_config, NULL, NULL);
644 PyObj_pjsua_media_config_import(obj, &cfg);
645 return (PyObject *)obj;
646}
647
648
649/*
650 * py_pjsua_msg_data_init
651 * !modified @ 051206
652 */
653static PyObject *py_pjsua_msg_data_init(PyObject *pSelf, PyObject *pArgs)
654{
655 PyObj_pjsua_msg_data *obj;
656 pjsua_msg_data msg;
657
658 PJ_UNUSED_ARG(pSelf);
659
660 if (!PyArg_ParseTuple(pArgs, ""))
661 {
662 return NULL;
663 }
664 pjsua_msg_data_init(&msg);
665 obj = (PyObj_pjsua_msg_data *)PyObj_pjsua_msg_data_new(&PyTyp_pjsua_msg_data, NULL, NULL);
666 Py_XDECREF(obj->content_type);
667 obj->content_type = PyString_FromStringAndSize(
668 msg.content_type.ptr, msg.content_type.slen
669 );
670 Py_XDECREF(obj->msg_body);
671 obj->msg_body = PyString_FromStringAndSize(
672 msg.msg_body.ptr, msg.msg_body.slen
673 );
674
675 translate_hdr_rev((pjsip_generic_string_hdr *)&msg.hdr_list,obj->hdr_list);
676
677 return (PyObject *)obj;
678}
679
680
681/*
682 * py_pjsua_reconfigure_logging
683 */
684static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, PyObject *pArgs)
685{
686 PyObject * logObj;
687 PyObj_pjsua_logging_config *log;
688 pjsua_logging_config cfg;
689 pj_status_t status;
690
691 PJ_UNUSED_ARG(pSelf);
692
693 if (!PyArg_ParseTuple(pArgs, "O", &logObj))
694 {
695 return NULL;
696 }
697 if (logObj != Py_None)
698 {
699 log = (PyObj_pjsua_logging_config *)logObj;
700 cfg.msg_logging = log->msg_logging;
701 cfg.level = log->level;
702 cfg.console_level = log->console_level;
703 cfg.decor = log->decor;
704 cfg.log_filename.ptr = PyString_AsString(log->log_filename);
705 cfg.log_filename.slen = strlen(cfg.log_filename.ptr);
706 Py_XDECREF(obj_log_cb);
707 obj_log_cb = log->cb;
708 Py_INCREF(obj_log_cb);
709 cfg.cb = &cb_log_cb;
710 status = pjsua_reconfigure_logging(&cfg);
711 } else {
712 status = pjsua_reconfigure_logging(NULL);
713 }
714 return Py_BuildValue("i",status);
715}
716
717
718/*
719 * py_pjsua_pool_create
720 */
721static PyObject *py_pjsua_pool_create(PyObject *pSelf, PyObject *pArgs)
722{
723 pj_size_t init_size;
724 pj_size_t increment;
725 const char * name;
726 pj_pool_t *p;
727 PyObj_pj_pool *pool;
728
729 PJ_UNUSED_ARG(pSelf);
730
731 if (!PyArg_ParseTuple(pArgs, "sII", &name, &init_size, &increment))
732 {
733 return NULL;
734 }
735
736 p = pjsua_pool_create(name, init_size, increment);
737 pool = (PyObj_pj_pool *)PyType_GenericNew(&PyTyp_pj_pool_t, NULL, NULL);
738 pool->pool = p;
739 return (PyObject *)pool;
740
741}
742
743
744/*
745 * py_pjsua_get_pjsip_endpt
746 */
747static PyObject *py_pjsua_get_pjsip_endpt(PyObject *pSelf, PyObject *pArgs)
748{
749 PyObj_pjsip_endpoint *endpt;
750 pjsip_endpoint *e;
751
752 PJ_UNUSED_ARG(pSelf);
753
754 if (!PyArg_ParseTuple(pArgs, ""))
755 {
756 return NULL;
757 }
758 e = pjsua_get_pjsip_endpt();
759 endpt = (PyObj_pjsip_endpoint *)PyType_GenericNew(
760 &PyTyp_pjsip_endpoint, NULL, NULL
761 );
762 endpt->endpt = e;
763 return (PyObject *)endpt;
764}
765
766
767/*
768 * py_pjsua_get_pjmedia_endpt
769 */
770static PyObject *py_pjsua_get_pjmedia_endpt(PyObject *pSelf, PyObject *pArgs)
771{
772 PyObj_pjmedia_endpt *endpt;
773 pjmedia_endpt *e;
774
775 PJ_UNUSED_ARG(pSelf);
776
777 if (!PyArg_ParseTuple(pArgs, ""))
778 {
779 return NULL;
780 }
781 e = pjsua_get_pjmedia_endpt();
782 endpt = (PyObj_pjmedia_endpt *)PyType_GenericNew(
783 &PyTyp_pjmedia_endpt, NULL, NULL
784 );
785 endpt->endpt = e;
786 return (PyObject *)endpt;
787}
788
789
790/*
791 * py_pjsua_get_pool_factory
792 */
793static PyObject *py_pjsua_get_pool_factory(PyObject *pSelf, PyObject *pArgs)
794{
795 PyObj_pj_pool_factory *pool;
796 pj_pool_factory *p;
797
798 PJ_UNUSED_ARG(pSelf);
799
800 if (!PyArg_ParseTuple(pArgs, ""))
801 {
802 return NULL;
803 }
804 p = pjsua_get_pool_factory();
805 pool = (PyObj_pj_pool_factory *)PyType_GenericNew(
806 &PyTyp_pj_pool_factory, NULL, NULL
807 );
808 pool->pool_fact = p;
809 return (PyObject *)pool;
810}
811
812
813/*
814 * py_pjsua_perror
815 */
816static PyObject *py_pjsua_perror(PyObject *pSelf, PyObject *pArgs)
817{
818 const char *sender;
819 const char *title;
820 pj_status_t status;
821
822 PJ_UNUSED_ARG(pSelf);
823
824 if (!PyArg_ParseTuple(pArgs, "ssi", &sender, &title, &status))
825 {
826 return NULL;
827 }
828
829 pjsua_perror(sender, title, status);
830 Py_INCREF(Py_None);
831 return Py_None;
832}
833
834
835/*
836 * py_pjsua_create
837 */
838static PyObject *py_pjsua_create(PyObject *pSelf, PyObject *pArgs)
839{
840 pj_status_t status;
841
842 PJ_UNUSED_ARG(pSelf);
843
844 if (!PyArg_ParseTuple(pArgs, ""))
845 {
846 return NULL;
847 }
848 status = pjsua_create();
849
850 if (status == PJ_SUCCESS)
851 {
852 status = pj_thread_local_alloc(&thread_id);
853 if (status == PJ_SUCCESS)
854 status = pj_thread_local_set(thread_id, (void*)1);
855 }
856
857 return Py_BuildValue("i",status);
858}
859
860
861/*
862 * py_pjsua_init
863 */
864static PyObject *py_pjsua_init(PyObject *pSelf, PyObject *pArgs)
865{
866 pj_status_t status;
867 PyObject *o_ua_cfg, *o_log_cfg, *o_media_cfg;
868 pjsua_config cfg_ua, *p_cfg_ua;
869 pjsua_logging_config cfg_log, *p_cfg_log;
870 pjsua_media_config cfg_media, *p_cfg_media;
871
872 PJ_UNUSED_ARG(pSelf);
873
874 if (!PyArg_ParseTuple(pArgs, "OOO", &o_ua_cfg, &o_log_cfg, &o_media_cfg))
875 {
876 return NULL;
877 }
878
879 pjsua_config_default(&cfg_ua);
880 pjsua_logging_config_default(&cfg_log);
881 pjsua_media_config_default(&cfg_media);
882
883 if (o_ua_cfg != Py_None)
884 {
885 PyObj_pjsua_config *obj_ua_cfg = (PyObj_pjsua_config*)o_ua_cfg;
886
887 PyObj_pjsua_config_export(&cfg_ua, obj_ua_cfg);
888
889 g_obj_callback = obj_ua_cfg->cb;
890 Py_INCREF(g_obj_callback);
891
892 cfg_ua.cb.on_call_state = &cb_on_call_state;
893 cfg_ua.cb.on_incoming_call = &cb_on_incoming_call;
894 cfg_ua.cb.on_call_media_state = &cb_on_call_media_state;
895 cfg_ua.cb.on_dtmf_digit = &cb_on_dtmf_digit;
896 cfg_ua.cb.on_call_transfer_request = &cb_on_call_transfer_request;
897 cfg_ua.cb.on_call_transfer_status = &cb_on_call_transfer_status;
898 cfg_ua.cb.on_call_replace_request = &cb_on_call_replace_request;
899 cfg_ua.cb.on_call_replaced = &cb_on_call_replaced;
900 cfg_ua.cb.on_reg_state = &cb_on_reg_state;
901 cfg_ua.cb.on_buddy_state = &cb_on_buddy_state;
902 cfg_ua.cb.on_pager = &cb_on_pager;
903 cfg_ua.cb.on_pager_status = &cb_on_pager_status;
904 cfg_ua.cb.on_typing = &cb_on_typing;
905
906 p_cfg_ua = &cfg_ua;
907
908 } else {
909 p_cfg_ua = NULL;
910 }
911
912 if (o_log_cfg != Py_None)
913 {
914 PyObj_pjsua_logging_config * obj_log;
915
916 obj_log = (PyObj_pjsua_logging_config *)o_log_cfg;
917
918 PyObj_pjsua_logging_config_export(&cfg_log, obj_log);
919
920 Py_XDECREF(obj_log_cb);
921 obj_log_cb = obj_log->cb;
922 Py_INCREF(obj_log_cb);
923
924 cfg_log.cb = &cb_log_cb;
925 p_cfg_log = &cfg_log;
926
927 } else {
928 p_cfg_log = NULL;
929 }
930
931 if (o_media_cfg != Py_None)
932 {
933 PyObj_pjsua_media_config_export(&cfg_media,
934 (PyObj_pjsua_media_config*)o_media_cfg);
935 p_cfg_media = &cfg_media;
936
937 } else {
938 p_cfg_media = NULL;
939 }
940
941 status = pjsua_init(p_cfg_ua, p_cfg_log, p_cfg_media);
942 return Py_BuildValue("i",status);
943}
944
945
946/*
947 * py_pjsua_start
948 */
949static PyObject *py_pjsua_start(PyObject *pSelf, PyObject *pArgs)
950{
951 pj_status_t status;
952
953 PJ_UNUSED_ARG(pSelf);
954
955 if (!PyArg_ParseTuple(pArgs, ""))
956 {
957 return NULL;
958 }
959 status = pjsua_start();
960
961 return Py_BuildValue("i",status);
962}
963
964
965/*
966 * py_pjsua_destroy
967 */
968static PyObject *py_pjsua_destroy(PyObject *pSelf, PyObject *pArgs)
969{
970 pj_status_t status;
971
972 PJ_UNUSED_ARG(pSelf);
973
974 if (!PyArg_ParseTuple(pArgs, ""))
975 {
976 return NULL;
977 }
978 status = pjsua_destroy();
979
980 return Py_BuildValue("i",status);
981}
982
983
984/*
985 * py_pjsua_handle_events
986 */
987static PyObject *py_pjsua_handle_events(PyObject *pSelf, PyObject *pArgs)
988{
989 int ret;
990 unsigned msec;
991
992 PJ_UNUSED_ARG(pSelf);
993
994 if (!PyArg_ParseTuple(pArgs, "i", &msec))
995 {
996 return NULL;
997 }
998
999 /* Since handle_events() will block, we must wrap it with ALLOW_THREADS
1000 * construct, or otherwise many Python blocking functions (such as
1001 * time.sleep(), readline(), etc.) may hang/block indefinitely.
1002 * See http://www.python.org/doc/current/api/threads.html for more info.
1003 */
1004 Py_BEGIN_ALLOW_THREADS
1005 ret = pjsua_handle_events(msec);
1006 Py_END_ALLOW_THREADS
1007
1008 return Py_BuildValue("i",ret);
1009}
1010
1011
1012/*
1013 * py_pjsua_verify_sip_url
1014 */
1015static PyObject *py_pjsua_verify_sip_url(PyObject *pSelf, PyObject *pArgs)
1016{
1017 pj_status_t status;
1018 const char *url;
1019
1020 PJ_UNUSED_ARG(pSelf);
1021
1022 if (!PyArg_ParseTuple(pArgs, "s", &url))
1023 {
1024 return NULL;
1025 }
1026 status = pjsua_verify_sip_url(url);
1027
1028 return Py_BuildValue("i",status);
1029}
1030
1031
1032/*
1033 * function doc
1034 */
1035
1036static char pjsua_thread_register_doc[] =
1037 "int py_pjsua.thread_register(string name, int[] desc)";
1038static char pjsua_perror_doc[] =
1039 "void py_pjsua.perror (string sender, string title, int status) "
1040 "Display error message for the specified error code. Parameters: "
1041 "sender: The log sender field; "
1042 "title: Message title for the error; "
1043 "status: Status code.";
1044
1045static char pjsua_create_doc[] =
1046 "int py_pjsua.create (void) "
1047 "Instantiate pjsua application. Application "
1048 "must call this function before calling any other functions, to make sure "
1049 "that the underlying libraries are properly initialized. Once this "
1050 "function has returned success, application must call pjsua_destroy() "
1051 "before quitting.";
1052
1053static char pjsua_init_doc[] =
1054 "int py_pjsua.init (py_pjsua.Config obj_ua_cfg, "
1055 "py_pjsua.Logging_Config log_cfg, py_pjsua.Media_Config media_cfg) "
1056 "Initialize pjsua with the specified settings. All the settings are "
1057 "optional, and the default values will be used when the config is not "
1058 "specified. Parameters: "
1059 "obj_ua_cfg : User agent configuration; "
1060 "log_cfg : Optional logging configuration; "
1061 "media_cfg : Optional media configuration.";
1062
1063static char pjsua_start_doc[] =
1064 "int py_pjsua.start (void) "
1065 "Application is recommended to call this function after all "
1066 "initialization is done, so that the library can do additional checking "
1067 "set up additional";
1068
1069static char pjsua_destroy_doc[] =
1070 "int py_pjsua.destroy (void) "
1071 "Destroy pjsua This function must be called once PJSUA is created. To "
1072 "make it easier for application, application may call this function "
1073 "several times with no danger.";
1074
1075static char pjsua_handle_events_doc[] =
1076 "int py_pjsua.handle_events (int msec_timeout) "
1077 "Poll pjsua for events, and if necessary block the caller thread for the "
1078 "specified maximum interval (in miliseconds) Parameters: "
1079 "msec_timeout: Maximum time to wait, in miliseconds. "
1080 "Returns: The number of events that have been handled during the poll. "
1081 "Negative value indicates error, and application can retrieve the error "
1082 "as (err = -return_value).";
1083
1084static char pjsua_verify_sip_url_doc[] =
1085 "int py_pjsua.verify_sip_url (string c_url) "
1086 "Verify that valid SIP url is given Parameters: "
1087 "c_url: The URL, as NULL terminated string.";
1088
1089static char pjsua_pool_create_doc[] =
1090 "py_pjsua.Pj_Pool py_pjsua.pool_create (string name, int init_size, "
1091 "int increment) "
1092 "Create memory pool Parameters: "
1093 "name: Optional pool name; "
1094 "init_size: Initial size of the pool; "
1095 "increment: Increment size.";
1096
1097static char pjsua_get_pjsip_endpt_doc[] =
1098 "py_pjsua.Pjsip_Endpoint py_pjsua.get_pjsip_endpt (void) "
1099 "Internal function to get SIP endpoint instance of pjsua, which is needed "
1100 "for example to register module, create transports, etc. Probably is only "
1101 "valid after pjsua_init() is called.";
1102
1103static char pjsua_get_pjmedia_endpt_doc[] =
1104 "py_pjsua.Pjmedia_Endpt py_pjsua.get_pjmedia_endpt (void) "
1105 "Internal function to get media endpoint instance. Only valid after "
1106 "pjsua_init() is called.";
1107
1108static char pjsua_get_pool_factory_doc[] =
1109 "py_pjsua.Pj_Pool_Factory py_pjsua.get_pool_factory (void) "
1110 "Internal function to get PJSUA pool factory. Only valid after "
1111 "pjsua_init() is called.";
1112
1113static char pjsua_reconfigure_logging_doc[] =
1114 "int py_pjsua.reconfigure_logging (py_pjsua.Logging_Config c) "
1115 "Application can call this function at any time (after pjsua_create(), of "
1116 "course) to change logging settings. Parameters: "
1117 "c: Logging configuration.";
1118
1119static char pjsua_logging_config_default_doc[] =
1120 "py_pjsua.Logging_Config py_pjsua.logging_config_default () "
1121 "Use this function to initialize logging config.";
1122
1123static char pjsua_config_default_doc[] =
1124 "py_pjsua.Config py_pjsua.config_default (). Use this function to "
1125 "initialize pjsua config. ";
1126
1127static char pjsua_media_config_default_doc[] =
1128 "py_pjsua.Media_Config py_pjsua.media_config_default (). "
1129 "Use this function to initialize media config.";
1130
1131static char pjsua_msg_data_init_doc[] =
1132 "py_pjsua.Msg_Data void py_pjsua.msg_data_init () "
1133 "Initialize message data ";
1134
1135
1136/* END OF LIB BASE */
1137
1138/* LIB TRANSPORT */
1139
1140/*
1141 * py_pjsua_transport_config_default
1142 * !modified @ 051206
1143 */
1144static PyObject *py_pjsua_transport_config_default(PyObject *pSelf,
1145 PyObject *pArgs)
1146{
1147 PyObj_pjsua_transport_config *obj;
1148 pjsua_transport_config cfg;
1149
1150 PJ_UNUSED_ARG(pSelf);
1151
1152 if (!PyArg_ParseTuple(pArgs, "")) {
1153 return NULL;
1154 }
1155
1156 pjsua_transport_config_default(&cfg);
1157 obj = (PyObj_pjsua_transport_config*)
1158 PyObj_pjsua_transport_config_new(&PyTyp_pjsua_transport_config,
1159 NULL, NULL);
1160 PyObj_pjsua_transport_config_import(obj, &cfg);
1161
1162 return (PyObject *)obj;
1163}
1164
1165/*
1166 * py_pjsua_transport_create
1167 * !modified @ 051206
1168 */
1169static PyObject *py_pjsua_transport_create(PyObject *pSelf, PyObject *pArgs)
1170{
1171 pj_status_t status;
1172 int type;
1173 PyObject * tmpObj;
1174 pjsua_transport_config cfg;
1175 pjsua_transport_id id;
1176
1177 PJ_UNUSED_ARG(pSelf);
1178
1179 if (!PyArg_ParseTuple(pArgs, "iO", &type, &tmpObj)) {
1180 return NULL;
1181 }
1182
1183 if (tmpObj != Py_None) {
1184 PyObj_pjsua_transport_config *obj;
1185 obj = (PyObj_pjsua_transport_config*)tmpObj;
1186 PyObj_pjsua_transport_config_export(&cfg, obj);
1187 status = pjsua_transport_create(type, &cfg, &id);
1188 } else {
1189 status = pjsua_transport_create(type, NULL, &id);
1190 }
1191
1192
1193 return Py_BuildValue("ii", status, id);
1194}
1195
1196/*
1197 * py_pjsua_enum_transports
1198 * !modified @ 261206
1199 */
1200static PyObject *py_pjsua_enum_transports(PyObject *pSelf, PyObject *pArgs)
1201{
1202 pj_status_t status;
1203 PyObject *list;
1204
1205 pjsua_transport_id id[PJSIP_MAX_TRANSPORTS];
1206 unsigned c, i;
1207
1208 PJ_UNUSED_ARG(pSelf);
1209
1210 if (!PyArg_ParseTuple(pArgs, ""))
1211 {
1212 return NULL;
1213 }
1214
1215 c = PJ_ARRAY_SIZE(id);
1216 status = pjsua_enum_transports(id, &c);
1217
1218 list = PyList_New(c);
1219 for (i = 0; i < c; i++)
1220 {
1221 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
1222 if (ret == -1)
1223 {
1224 return NULL;
1225 }
1226 }
1227
1228 return Py_BuildValue("O",list);
1229}
1230
1231/*
1232 * py_pjsua_transport_get_info
1233 * !modified @ 051206
1234 */
1235static PyObject *py_pjsua_transport_get_info(PyObject *pSelf, PyObject *pArgs)
1236{
1237 pj_status_t status;
1238 int id;
1239 pjsua_transport_info info;
1240
1241 PJ_UNUSED_ARG(pSelf);
1242
1243 if (!PyArg_ParseTuple(pArgs, "i", &id)) {
1244 return NULL;
1245 }
1246
1247 status = pjsua_transport_get_info(id, &info);
1248 if (status == PJ_SUCCESS) {
1249 PyObj_pjsua_transport_info *obj;
1250 obj = (PyObj_pjsua_transport_info *)
1251 PyObj_pjsua_transport_info_new(&PyTyp_pjsua_transport_info,
1252 NULL, NULL);
1253 PyObj_pjsua_transport_info_import(obj, &info);
1254 return Py_BuildValue("O", obj);
1255 } else {
1256 Py_INCREF(Py_None);
1257 return Py_None;
1258 }
1259}
1260
1261/*
1262 * py_pjsua_transport_set_enable
1263 */
1264static PyObject *py_pjsua_transport_set_enable
1265(PyObject *pSelf, PyObject *pArgs)
1266{
1267 pj_status_t status;
1268 int id;
1269 int enabled;
1270
1271 PJ_UNUSED_ARG(pSelf);
1272
1273 if (!PyArg_ParseTuple(pArgs, "ii", &id, &enabled))
1274 {
1275 return NULL;
1276 }
1277 status = pjsua_transport_set_enable(id, enabled);
1278
1279 return Py_BuildValue("i",status);
1280}
1281
1282/*
1283 * py_pjsua_transport_close
1284 */
1285static PyObject *py_pjsua_transport_close(PyObject *pSelf, PyObject *pArgs)
1286{
1287 pj_status_t status;
1288 int id;
1289 int force;
1290
1291 PJ_UNUSED_ARG(pSelf);
1292
1293 if (!PyArg_ParseTuple(pArgs, "ii", &id, &force))
1294 {
1295 return NULL;
1296 }
1297 status = pjsua_transport_close(id, force);
1298
1299 return Py_BuildValue("i",status);
1300}
1301
1302static char pjsua_transport_config_default_doc[] =
1303 "py_pjsua.Transport_Config py_pjsua.transport_config_default () "
1304 "Call this function to initialize UDP config with default values.";
1305static char pjsua_transport_create_doc[] =
1306 "int, int py_pjsua.transport_create (int type, "
1307 "py_pjsua.Transport_Config cfg) "
1308 "Create SIP transport.";
1309static char pjsua_enum_transports_doc[] =
1310 "int[] py_pjsua.enum_transports () "
1311 "Enumerate all transports currently created in the system.";
1312static char pjsua_transport_get_info_doc[] =
1313 "void py_pjsua.transport_get_info "
1314 "(py_pjsua.Transport_ID id, py_pjsua.Transport_Info info) "
1315 "Get information about transports.";
1316static char pjsua_transport_set_enable_doc[] =
1317 "void py_pjsua.transport_set_enable "
1318 "(py_pjsua.Transport_ID id, int enabled) "
1319 "Disable a transport or re-enable it. "
1320 "By default transport is always enabled after it is created. "
1321 "Disabling a transport does not necessarily close the socket, "
1322 "it will only discard incoming messages and prevent the transport "
1323 "from being used to send outgoing messages.";
1324static char pjsua_transport_close_doc[] =
1325 "void py_pjsua.transport_close (py_pjsua.Transport_ID id, int force) "
1326 "Close the transport. If transport is forcefully closed, "
1327 "it will be immediately closed, and any pending transactions "
1328 "that are using the transport may not terminate properly. "
1329 "Otherwise, the system will wait until all transactions are closed "
1330 "while preventing new users from using the transport, and will close "
1331 "the transport when it is safe to do so.";
1332
1333/* END OF LIB TRANSPORT */
1334
1335/* LIB ACCOUNT */
1336
1337
1338/*
1339 * py_pjsua_acc_config_default
1340 * !modified @ 051206
1341 */
1342static PyObject *py_pjsua_acc_config_default(PyObject *pSelf, PyObject *pArgs)
1343{
1344 PyObj_pjsua_acc_config *obj;
1345 pjsua_acc_config cfg;
1346
1347 PJ_UNUSED_ARG(pSelf);
1348
1349 if (!PyArg_ParseTuple(pArgs, "")) {
1350 return NULL;
1351 }
1352
1353 pjsua_acc_config_default(&cfg);
1354 obj = (PyObj_pjsua_acc_config *)
1355 PyObj_pjsua_acc_config_new(&PyTyp_pjsua_acc_config,
1356 NULL, NULL);
1357 PyObj_pjsua_acc_config_import(obj, &cfg);
1358 return (PyObject *)obj;
1359}
1360
1361/*
1362 * py_pjsua_acc_get_count
1363 */
1364static PyObject *py_pjsua_acc_get_count(PyObject *pSelf, PyObject *pArgs)
1365{
1366 int count;
1367
1368 PJ_UNUSED_ARG(pSelf);
1369
1370 if (!PyArg_ParseTuple(pArgs, "")) {
1371 return NULL;
1372 }
1373
1374 count = pjsua_acc_get_count();
1375 return Py_BuildValue("i",count);
1376}
1377
1378/*
1379 * py_pjsua_acc_is_valid
1380 */
1381static PyObject *py_pjsua_acc_is_valid(PyObject *pSelf, PyObject *pArgs)
1382{
1383 int id;
1384 int is_valid;
1385
1386 PJ_UNUSED_ARG(pSelf);
1387
1388 if (!PyArg_ParseTuple(pArgs, "i", &id)) {
1389 return NULL;
1390 }
1391
1392 is_valid = pjsua_acc_is_valid(id);
1393 return Py_BuildValue("i", is_valid);
1394}
1395
1396/*
1397 * py_pjsua_acc_set_default
1398 */
1399static PyObject *py_pjsua_acc_set_default(PyObject *pSelf, PyObject *pArgs)
1400{
1401 int id;
1402 int status;
1403
1404 PJ_UNUSED_ARG(pSelf);
1405
1406 if (!PyArg_ParseTuple(pArgs, "i", &id)) {
1407 return NULL;
1408 }
1409 status = pjsua_acc_set_default(id);
1410
1411 return Py_BuildValue("i", status);
1412}
1413
1414/*
1415 * py_pjsua_acc_get_default
1416 */
1417static PyObject *py_pjsua_acc_get_default(PyObject *pSelf, PyObject *pArgs)
1418{
1419 int id;
1420
1421 PJ_UNUSED_ARG(pSelf);
1422
1423 if (!PyArg_ParseTuple(pArgs, "")) {
1424 return NULL;
1425 }
1426
1427 id = pjsua_acc_get_default();
1428
1429 return Py_BuildValue("i", id);
1430}
1431
1432/*
1433 * py_pjsua_acc_add
1434 * !modified @ 051206
1435 */
1436static PyObject *py_pjsua_acc_add(PyObject *pSelf, PyObject *pArgs)
1437{
1438 int is_default;
1439 PyObject * acObj;
1440 PyObj_pjsua_acc_config * ac;
1441 int acc_id;
1442 int status;
1443
1444 PJ_UNUSED_ARG(pSelf);
1445
1446 if (!PyArg_ParseTuple(pArgs, "Oi", &acObj, &is_default)) {
1447 return NULL;
1448 }
1449
1450 if (acObj != Py_None) {
1451 pjsua_acc_config cfg;
1452
1453 pjsua_acc_config_default(&cfg);
1454 ac = (PyObj_pjsua_acc_config *)acObj;
1455 PyObj_pjsua_acc_config_export(&cfg, ac);
1456 status = pjsua_acc_add(&cfg, is_default, &acc_id);
1457 } else {
1458 status = PJ_EINVAL;
1459 acc_id = PJSUA_INVALID_ID;
1460 }
1461
1462 return Py_BuildValue("ii", status, acc_id);
1463}
1464
1465/*
1466 * py_pjsua_acc_add_local
1467 * !modified @ 051206
1468 */
1469static PyObject *py_pjsua_acc_add_local(PyObject *pSelf, PyObject *pArgs)
1470{
1471 int is_default;
1472 int tid;
1473 int p_acc_id;
1474 int status;
1475
1476 PJ_UNUSED_ARG(pSelf);
1477
1478 if (!PyArg_ParseTuple(pArgs, "ii", &tid, &is_default)) {
1479 return NULL;
1480 }
1481
1482
1483 status = pjsua_acc_add_local(tid, is_default, &p_acc_id);
1484
1485 return Py_BuildValue("ii", status, p_acc_id);
1486}
1487
1488/*
1489 * py_pjsua_acc_del
1490 */
1491static PyObject *py_pjsua_acc_del(PyObject *pSelf, PyObject *pArgs)
1492{
1493 int acc_id;
1494 int status;
1495
1496 PJ_UNUSED_ARG(pSelf);
1497
1498 if (!PyArg_ParseTuple(pArgs, "i", &acc_id))
1499 {
1500 return NULL;
1501 }
1502
1503
1504 status = pjsua_acc_del(acc_id);
1505 return Py_BuildValue("i", status);
1506}
1507
1508/*
1509 * py_pjsua_acc_modify
1510 */
1511static PyObject *py_pjsua_acc_modify(PyObject *pSelf, PyObject *pArgs)
1512{
1513 PyObject * acObj;
1514 PyObj_pjsua_acc_config * ac;
1515 int acc_id;
1516 int status;
1517
1518 PJ_UNUSED_ARG(pSelf);
1519
1520 if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &acObj)) {
1521 return NULL;
1522 }
1523
1524 if (acObj != Py_None) {
1525 pjsua_acc_config cfg;
1526
1527 pjsua_acc_config_default(&cfg);
1528 ac = (PyObj_pjsua_acc_config *)acObj;
1529 PyObj_pjsua_acc_config_export(&cfg, ac);
1530
1531 status = pjsua_acc_modify(acc_id, &cfg);
1532 } else {
1533 status = PJ_EINVAL;
1534 }
1535 return Py_BuildValue("i", status);
1536}
1537
1538/*
1539 * py_pjsua_acc_set_online_status
1540 */
1541static PyObject *py_pjsua_acc_set_online_status(PyObject *pSelf,
1542 PyObject *pArgs)
1543{
1544 int is_online;
1545 int acc_id;
1546 int status;
1547
1548 PJ_UNUSED_ARG(pSelf);
1549
1550 if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &is_online)) {
1551 return NULL;
1552 }
1553
1554 status = pjsua_acc_set_online_status(acc_id, is_online);
1555
1556 return Py_BuildValue("i", status);
1557}
1558
1559/*
1560 * py_pjsua_acc_set_online_status2
1561 */
1562static PyObject *py_pjsua_acc_set_online_status2(PyObject *pSelf,
1563 PyObject *pArgs)
1564{
1565 int is_online;
1566 int acc_id;
1567 int activity_id;
1568 const char *activity_text;
1569 pjrpid_element rpid;
1570 pj_status_t status;
1571
1572 PJ_UNUSED_ARG(pSelf);
1573
1574 if (!PyArg_ParseTuple(pArgs, "iiis", &acc_id, &is_online,
1575 &activity_id, &activity_text)) {
1576 return NULL;
1577 }
1578
1579 pj_bzero(&rpid, sizeof(rpid));
1580 rpid.activity = activity_id;
1581 rpid.note = pj_str((char*)activity_text);
1582
1583 status = pjsua_acc_set_online_status2(acc_id, is_online, &rpid);
1584
1585 return Py_BuildValue("i", status);
1586}
1587
1588/*
1589 * py_pjsua_acc_set_registration
1590 */
1591static PyObject *py_pjsua_acc_set_registration(PyObject *pSelf,
1592 PyObject *pArgs)
1593{
1594 int renew;
1595 int acc_id;
1596 int status;
1597
1598 PJ_UNUSED_ARG(pSelf);
1599
1600 if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &renew)) {
1601 return NULL;
1602 }
1603
1604 status = pjsua_acc_set_registration(acc_id, renew);
1605
1606 return Py_BuildValue("i", status);
1607}
1608
1609/*
1610 * py_pjsua_acc_get_info
1611 * !modified @ 051206
1612 */
1613static PyObject *py_pjsua_acc_get_info(PyObject *pSelf, PyObject *pArgs)
1614{
1615 int acc_id;
1616 PyObj_pjsua_acc_info * obj;
1617 pjsua_acc_info info;
1618 int status;
1619
1620 PJ_UNUSED_ARG(pSelf);
1621
1622 if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) {
1623 return NULL;
1624 }
1625
1626 status = pjsua_acc_get_info(acc_id, &info);
1627 if (status == PJ_SUCCESS) {
1628 obj = (PyObj_pjsua_acc_info *)
1629 PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info,NULL, NULL);
1630 PyObj_pjsua_acc_info_import(obj, &info);
1631 return Py_BuildValue("O", obj);
1632 } else {
1633 Py_INCREF(Py_None);
1634 return Py_None;
1635 }
1636}
1637
1638/*
1639 * py_pjsua_enum_accs
1640 * !modified @ 241206
1641 */
1642static PyObject *py_pjsua_enum_accs(PyObject *pSelf, PyObject *pArgs)
1643{
1644 pj_status_t status;
1645 PyObject *list;
1646
1647 pjsua_acc_id id[PJSUA_MAX_ACC];
1648 unsigned c, i;
1649
1650 PJ_UNUSED_ARG(pSelf);
1651
1652 if (!PyArg_ParseTuple(pArgs, ""))
1653 {
1654 return NULL;
1655 }
1656 c = PJ_ARRAY_SIZE(id);
1657
1658 status = pjsua_enum_accs(id, &c);
1659
1660 list = PyList_New(c);
1661 for (i = 0; i < c; i++)
1662 {
1663 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
1664 if (ret == -1)
1665 {
1666 return NULL;
1667 }
1668 }
1669
1670 return Py_BuildValue("O",list);
1671}
1672
1673/*
1674 * py_pjsua_acc_enum_info
1675 * !modified @ 241206
1676 */
1677static PyObject *py_pjsua_acc_enum_info(PyObject *pSelf, PyObject *pArgs)
1678{
1679 pj_status_t status;
1680 PyObject *list;
1681 pjsua_acc_info info[PJSUA_MAX_ACC];
1682 unsigned c, i;
1683
1684 PJ_UNUSED_ARG(pSelf);
1685
1686 if (!PyArg_ParseTuple(pArgs, "")) {
1687 return NULL;
1688 }
1689
1690 c = PJ_ARRAY_SIZE(info);
1691 status = pjsua_acc_enum_info(info, &c);
1692
1693 list = PyList_New(c);
1694 for (i = 0; i < c; i++) {
1695 PyObj_pjsua_acc_info *obj;
1696 obj = (PyObj_pjsua_acc_info *)
1697 PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info, NULL, NULL);
1698
1699 PyObj_pjsua_acc_info_import(obj, &info[i]);
1700
1701 PyList_SetItem(list, i, (PyObject *)obj);
1702 }
1703
1704 return Py_BuildValue("O",list);
1705}
1706
1707/*
1708 * py_pjsua_acc_find_for_outgoing
1709 */
1710static PyObject *py_pjsua_acc_find_for_outgoing(PyObject *pSelf,
1711 PyObject *pArgs)
1712{
1713 int acc_id;
1714 PyObject * url;
1715 pj_str_t str;
1716
1717 PJ_UNUSED_ARG(pSelf);
1718
1719 if (!PyArg_ParseTuple(pArgs, "O", &url))
1720 {
1721 return NULL;
1722 }
1723 str.ptr = PyString_AsString(url);
1724 str.slen = strlen(PyString_AsString(url));
1725
1726 acc_id = pjsua_acc_find_for_outgoing(&str);
1727
1728 return Py_BuildValue("i", acc_id);
1729}
1730
1731/*
1732 * py_pjsua_acc_find_for_incoming
1733 */
1734static PyObject *py_pjsua_acc_find_for_incoming(PyObject *pSelf,
1735 PyObject *pArgs)
1736{
1737 int acc_id;
1738 PyObject * tmpObj;
1739 PyObj_pjsip_rx_data * obj;
1740 pjsip_rx_data * rdata;
1741
1742 PJ_UNUSED_ARG(pSelf);
1743
1744 if (!PyArg_ParseTuple(pArgs, "O", &tmpObj))
1745 {
1746 return NULL;
1747 }
1748 if (tmpObj != Py_None)
1749 {
1750 obj = (PyObj_pjsip_rx_data *)tmpObj;
1751 rdata = obj->rdata;
1752 acc_id = pjsua_acc_find_for_incoming(rdata);
1753 } else {
1754 acc_id = pjsua_acc_find_for_incoming(NULL);
1755 }
1756 return Py_BuildValue("i", acc_id);
1757}
1758
1759/*
1760 * py_pjsua_acc_create_uac_contact
1761 * !modified @ 061206
1762 */
1763static PyObject *py_pjsua_acc_create_uac_contact(PyObject *pSelf,
1764 PyObject *pArgs)
1765{
1766 int status;
1767 int acc_id;
1768 PyObject * pObj;
1769 PyObj_pj_pool * p;
1770 pj_pool_t * pool;
1771 PyObject * strc;
1772 pj_str_t contact;
1773 PyObject * stru;
1774 pj_str_t uri;
1775
1776 PJ_UNUSED_ARG(pSelf);
1777
1778 if (!PyArg_ParseTuple(pArgs, "OiO", &pObj, &acc_id, &stru))
1779 {
1780 return NULL;
1781 }
1782 if (pObj != Py_None)
1783 {
1784 p = (PyObj_pj_pool *)pObj;
1785 pool = p->pool;
1786 uri.ptr = PyString_AsString(stru);
1787 uri.slen = strlen(PyString_AsString(stru));
1788 status = pjsua_acc_create_uac_contact(pool, &contact, acc_id, &uri);
1789 } else {
1790 status = pjsua_acc_create_uac_contact(NULL, &contact, acc_id, &uri);
1791 }
1792 strc = PyString_FromStringAndSize(contact.ptr, contact.slen);
1793
1794 return Py_BuildValue("O", strc);
1795}
1796
1797/*
1798 * py_pjsua_acc_create_uas_contact
1799 * !modified @ 061206
1800 */
1801static PyObject *py_pjsua_acc_create_uas_contact(PyObject *pSelf,
1802 PyObject *pArgs)
1803{
1804 int status;
1805 int acc_id;
1806 PyObject * pObj;
1807 PyObj_pj_pool * p;
1808 pj_pool_t * pool;
1809 PyObject * strc;
1810 pj_str_t contact;
1811 PyObject * rObj;
1812 PyObj_pjsip_rx_data * objr;
1813 pjsip_rx_data * rdata;
1814
1815 PJ_UNUSED_ARG(pSelf);
1816
1817 if (!PyArg_ParseTuple(pArgs, "OiO", &pObj, &acc_id, &rObj))
1818 {
1819 return NULL;
1820 }
1821 if (pObj != Py_None)
1822 {
1823 p = (PyObj_pj_pool *)pObj;
1824 pool = p->pool;
1825 } else {
1826 pool = NULL;
1827 }
1828 if (rObj != Py_None)
1829 {
1830 objr = (PyObj_pjsip_rx_data *)rObj;
1831 rdata = objr->rdata;
1832 } else {
1833 rdata = NULL;
1834 }
1835 status = pjsua_acc_create_uas_contact(pool, &contact, acc_id, rdata);
1836 strc = PyString_FromStringAndSize(contact.ptr, contact.slen);
1837
1838 return Py_BuildValue("O", strc);
1839}
1840
1841static char pjsua_acc_config_default_doc[] =
1842 "py_pjsua.Acc_Config py_pjsua.acc_config_default () "
1843 "Call this function to initialize account config with default values.";
1844static char pjsua_acc_get_count_doc[] =
1845 "int py_pjsua.acc_get_count () "
1846 "Get number of current accounts.";
1847static char pjsua_acc_is_valid_doc[] =
1848 "int py_pjsua.acc_is_valid (int acc_id) "
1849 "Check if the specified account ID is valid.";
1850static char pjsua_acc_set_default_doc[] =
1851 "int py_pjsua.acc_set_default (int acc_id) "
1852 "Set default account to be used when incoming "
1853 "and outgoing requests doesn't match any accounts.";
1854static char pjsua_acc_get_default_doc[] =
1855 "int py_pjsua.acc_get_default () "
1856 "Get default account.";
1857static char pjsua_acc_add_doc[] =
1858 "int, int py_pjsua.acc_add (py_pjsua.Acc_Config cfg, "
1859 "int is_default) "
1860 "Add a new account to pjsua. PJSUA must have been initialized "
1861 "(with pjsua_init()) before calling this function.";
1862static char pjsua_acc_add_local_doc[] =
1863 "int,int py_pjsua.acc_add_local (int tid, "
1864 "int is_default) "
1865 "Add a local account. A local account is used to identify "
1866 "local endpoint instead of a specific user, and for this reason, "
1867 "a transport ID is needed to obtain the local address information.";
1868static char pjsua_acc_del_doc[] =
1869 "int py_pjsua.acc_del (int acc_id) "
1870 "Delete account.";
1871static char pjsua_acc_modify_doc[] =
1872 "int py_pjsua.acc_modify (int acc_id, py_pjsua.Acc_Config cfg) "
1873 "Modify account information.";
1874static char pjsua_acc_set_online_status_doc[] =
1875 "int py_pjsua.acc_set_online_status2(int acc_id, int is_online) "
1876 "Modify account's presence status to be advertised "
1877 "to remote/presence subscribers.";
1878static char pjsua_acc_set_online_status2_doc[] =
1879 "int py_pjsua.acc_set_online_status (int acc_id, int is_online, "
1880 "int activity_id, string activity_text) "
1881 "Modify account's presence status to be advertised "
1882 "to remote/presence subscribers.";
1883static char pjsua_acc_set_registration_doc[] =
1884 "int py_pjsua.acc_set_registration (int acc_id, int renew) "
1885 "Update registration or perform unregistration.";
1886static char pjsua_acc_get_info_doc[] =
1887 "py_pjsua.Acc_Info py_pjsua.acc_get_info (int acc_id) "
1888 "Get account information.";
1889static char pjsua_enum_accs_doc[] =
1890 "int[] py_pjsua.enum_accs () "
1891 "Enum accounts all account ids.";
1892static char pjsua_acc_enum_info_doc[] =
1893 "py_pjsua.Acc_Info[] py_pjsua.acc_enum_info () "
1894 "Enum accounts info.";
1895static char pjsua_acc_find_for_outgoing_doc[] =
1896 "int py_pjsua.acc_find_for_outgoing (string url) "
1897 "This is an internal function to find the most appropriate account "
1898 "to used to reach to the specified URL.";
1899static char pjsua_acc_find_for_incoming_doc[] =
1900 "int py_pjsua.acc_find_for_incoming (PyObj_pjsip_rx_data rdata) "
1901 "This is an internal function to find the most appropriate account "
1902 "to be used to handle incoming calls.";
1903static char pjsua_acc_create_uac_contact_doc[] =
1904 "string py_pjsua.acc_create_uac_contact (PyObj_pj_pool pool, "
1905 "int acc_id, string uri) "
1906 "Create a suitable URI to be put as Contact based on the specified "
1907 "target URI for the specified account.";
1908static char pjsua_acc_create_uas_contact_doc[] =
1909 "string py_pjsua.acc_create_uas_contact (PyObj_pj_pool pool, "
1910 "int acc_id, PyObj_pjsip_rx_data rdata) "
1911 "Create a suitable URI to be put as Contact based on the information "
1912 "in the incoming request.";
1913
1914/* END OF LIB ACCOUNT */
1915
1916/* LIB BUDDY */
1917
1918
1919
1920/*
1921 * py_pjsua_buddy_config_default
1922 */
1923static PyObject *py_pjsua_buddy_config_default(PyObject *pSelf,
1924 PyObject *pArgs)
1925{
1926 PyObj_pjsua_buddy_config *obj;
1927 pjsua_buddy_config cfg;
1928
1929 PJ_UNUSED_ARG(pSelf);
1930
1931 if (!PyArg_ParseTuple(pArgs, "")) {
1932 return NULL;
1933 }
1934
1935 pjsua_buddy_config_default(&cfg);
1936 obj = (PyObj_pjsua_buddy_config *)
1937 PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_config, NULL, NULL);
1938 PyObj_pjsua_buddy_config_import(obj, &cfg);
1939
1940 return (PyObject *)obj;
1941}
1942
1943/*
1944 * py_pjsua_get_buddy_count
1945 */
1946static PyObject *py_pjsua_get_buddy_count(PyObject *pSelf, PyObject *pArgs)
1947{
1948 int ret;
1949
1950 PJ_UNUSED_ARG(pSelf);
1951
1952 if (!PyArg_ParseTuple(pArgs, "")) {
1953 return NULL;
1954 }
1955 ret = pjsua_get_buddy_count();
1956
1957 return Py_BuildValue("i", ret);
1958}
1959
1960/*
1961 * py_pjsua_buddy_is_valid
1962 */
1963static PyObject *py_pjsua_buddy_is_valid(PyObject *pSelf, PyObject *pArgs)
1964{
1965 int id;
1966 int is_valid;
1967
1968 PJ_UNUSED_ARG(pSelf);
1969
1970 if (!PyArg_ParseTuple(pArgs, "i", &id)) {
1971 return NULL;
1972 }
1973 is_valid = pjsua_buddy_is_valid(id);
1974
1975 return Py_BuildValue("i", is_valid);
1976}
1977
1978/*
1979 * py_pjsua_enum_buddies
1980 * !modified @ 241206
1981 */
1982static PyObject *py_pjsua_enum_buddies(PyObject *pSelf, PyObject *pArgs)
1983{
1984 pj_status_t status;
1985 PyObject *list;
1986
1987 pjsua_buddy_id id[PJSUA_MAX_BUDDIES];
1988 unsigned c, i;
1989
1990 PJ_UNUSED_ARG(pSelf);
1991
1992 if (!PyArg_ParseTuple(pArgs, "")) {
1993 return NULL;
1994 }
1995 c = PJ_ARRAY_SIZE(id);
1996 status = pjsua_enum_buddies(id, &c);
1997 list = PyList_New(c);
1998 for (i = 0; i < c; i++) {
1999 PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
2000 }
2001
2002 return Py_BuildValue("O",list);
2003}
2004
2005/*
2006 * py_pjsua_buddy_get_info
2007 * !modified @ 071206
2008 */
2009static PyObject *py_pjsua_buddy_get_info(PyObject *pSelf, PyObject *pArgs)
2010{
2011 int buddy_id;
2012 PyObj_pjsua_buddy_info * obj;
2013 pjsua_buddy_info info;
2014 int status;
2015
2016 PJ_UNUSED_ARG(pSelf);
2017
2018 if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) {
2019 return NULL;
2020 }
2021
2022 status = pjsua_buddy_get_info(buddy_id, &info);
2023 if (status == PJ_SUCCESS) {
2024 obj = (PyObj_pjsua_buddy_info *)
2025 PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_info,NULL,NULL);
2026 PyObj_pjsua_buddy_info_import(obj, &info);
2027 return Py_BuildValue("O", obj);
2028 } else {
2029 Py_INCREF(Py_None);
2030 return Py_None;
2031 }
2032}
2033
2034/*
2035 * py_pjsua_buddy_add
2036 * !modified @ 061206
2037 */
2038static PyObject *py_pjsua_buddy_add(PyObject *pSelf, PyObject *pArgs)
2039{
2040 PyObject * bcObj;
2041 int buddy_id;
2042 int status;
2043
2044 PJ_UNUSED_ARG(pSelf);
2045
2046 if (!PyArg_ParseTuple(pArgs, "O", &bcObj)) {
2047 return NULL;
2048 }
2049
2050 if (bcObj != Py_None) {
2051 pjsua_buddy_config cfg;
2052 PyObj_pjsua_buddy_config * bc;
2053
2054 bc = (PyObj_pjsua_buddy_config *)bcObj;
2055
2056 pjsua_buddy_config_default(&cfg);
2057 PyObj_pjsua_buddy_config_export(&cfg, bc);
2058
2059 status = pjsua_buddy_add(&cfg, &buddy_id);
2060 } else {
2061 status = PJ_EINVAL;
2062 buddy_id = PJSUA_INVALID_ID;
2063 }
2064 return Py_BuildValue("ii", status, buddy_id);
2065}
2066
2067/*
2068 * py_pjsua_buddy_del
2069 */
2070static PyObject *py_pjsua_buddy_del(PyObject *pSelf, PyObject *pArgs)
2071{
2072 int buddy_id;
2073 int status;
2074
2075 PJ_UNUSED_ARG(pSelf);
2076
2077 if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) {
2078 return NULL;
2079 }
2080
2081
2082 status = pjsua_buddy_del(buddy_id);
2083 return Py_BuildValue("i", status);
2084}
2085
2086/*
2087 * py_pjsua_buddy_subscribe_pres
2088 */
2089static PyObject *py_pjsua_buddy_subscribe_pres(PyObject *pSelf, PyObject *pArgs)
2090{
2091 int buddy_id;
2092 int status;
2093 int subscribe;
2094
2095 PJ_UNUSED_ARG(pSelf);
2096
2097 if (!PyArg_ParseTuple(pArgs, "ii", &buddy_id, &subscribe)) {
2098 return NULL;
2099 }
2100
2101
2102 status = pjsua_buddy_subscribe_pres(buddy_id, subscribe);
2103 return Py_BuildValue("i", status);
2104}
2105
2106/*
2107 * py_pjsua_pres_dump
2108 */
2109static PyObject *py_pjsua_pres_dump(PyObject *pSelf, PyObject *pArgs)
2110{
2111 int verbose;
2112
2113 PJ_UNUSED_ARG(pSelf);
2114
2115 if (!PyArg_ParseTuple(pArgs, "i", &verbose)) {
2116 return NULL;
2117 }
2118
2119
2120 pjsua_pres_dump(verbose);
2121 Py_INCREF(Py_None);
2122 return Py_None;
2123}
2124
2125/*
2126 * py_pjsua_im_send
2127 * !modified @ 071206
2128 */
2129static PyObject *py_pjsua_im_send(PyObject *pSelf, PyObject *pArgs)
2130{
2131 int status;
2132 int acc_id;
2133 pj_str_t * mime_type, tmp_mime_type;
2134 pj_str_t to, content;
2135 PyObject * st;
2136 PyObject * smt;
2137 PyObject * sc;
2138 pjsua_msg_data msg_data;
2139 PyObject * omdObj;
2140 PyObj_pjsua_msg_data * omd;
2141
2142 int user_data;
2143 pj_pool_t *pool;
2144
2145 PJ_UNUSED_ARG(pSelf);
2146
2147 if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id,
2148 &st, &smt, &sc, &omdObj, &user_data))
2149 {
2150 return NULL;
2151 }
2152 if (smt != Py_None) {
2153 mime_type = &tmp_mime_type;
2154 tmp_mime_type = PyString_to_pj_str(smt);
2155 } else {
2156 mime_type = NULL;
2157 }
2158 to = PyString_to_pj_str(st);
2159 content = PyString_to_pj_str(sc);
2160
2161 if (omdObj != Py_None) {
2162
2163 omd = (PyObj_pjsua_msg_data *)omdObj;
2164 msg_data.content_type = PyString_to_pj_str(omd->content_type);
2165 msg_data.msg_body = PyString_to_pj_str(omd->msg_body);
2166 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
2167
2168 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
2169 status = pjsua_im_send(acc_id, &to, mime_type,
2170 &content, &msg_data, (void *)user_data);
2171 pj_pool_release(pool);
2172 } else {
2173
2174 status = pjsua_im_send(acc_id, &to, mime_type,
2175 &content, NULL, NULL);
2176 }
2177
2178 return Py_BuildValue("i",status);
2179}
2180
2181/*
2182 * py_pjsua_im_typing
2183 */
2184static PyObject *py_pjsua_im_typing(PyObject *pSelf, PyObject *pArgs)
2185{
2186 int status;
2187 int acc_id;
2188 pj_str_t to;
2189 PyObject * st;
2190 int is_typing;
2191 pjsua_msg_data msg_data;
2192 PyObject * omdObj;
2193 PyObj_pjsua_msg_data * omd;
2194 pj_pool_t * pool;
2195
2196 PJ_UNUSED_ARG(pSelf);
2197
2198 if (!PyArg_ParseTuple(pArgs, "iOiO", &acc_id, &st, &is_typing, &omdObj)) {
2199 return NULL;
2200 }
2201
2202 to = PyString_to_pj_str(st);
2203
2204 if (omdObj != Py_None) {
2205 omd = (PyObj_pjsua_msg_data *)omdObj;
2206 msg_data.content_type = PyString_to_pj_str(omd->content_type);
2207 msg_data.msg_body = PyString_to_pj_str(omd->msg_body);
2208 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
2209
2210 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
2211 status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data);
2212 pj_pool_release(pool);
2213 } else {
2214 status = pjsua_im_typing(acc_id, &to, is_typing, NULL);
2215 }
2216 return Py_BuildValue("i",status);
2217}
2218
2219static char pjsua_buddy_config_default_doc[] =
2220 "py_pjsua.Buddy_Config py_pjsua.buddy_config_default () "
2221 "Set default values to the buddy config.";
2222static char pjsua_get_buddy_count_doc[] =
2223 "int py_pjsua.get_buddy_count () "
2224 "Get total number of buddies.";
2225static char pjsua_buddy_is_valid_doc[] =
2226 "int py_pjsua.buddy_is_valid (int buddy_id) "
2227 "Check if buddy ID is valid.";
2228static char pjsua_enum_buddies_doc[] =
2229 "int[] py_pjsua.enum_buddies () "
2230 "Enum buddy IDs.";
2231static char pjsua_buddy_get_info_doc[] =
2232 "py_pjsua.Buddy_Info py_pjsua.buddy_get_info (int buddy_id) "
2233 "Get detailed buddy info.";
2234static char pjsua_buddy_add_doc[] =
2235 "int,int py_pjsua.buddy_add (py_pjsua.Buddy_Config cfg) "
2236 "Add new buddy.";
2237static char pjsua_buddy_del_doc[] =
2238 "int py_pjsua.buddy_del (int buddy_id) "
2239 "Delete buddy.";
2240static char pjsua_buddy_subscribe_pres_doc[] =
2241 "int py_pjsua.buddy_subscribe_pres (int buddy_id, int subscribe) "
2242 "Enable/disable buddy's presence monitoring.";
2243static char pjsua_pres_dump_doc[] =
2244 "void py_pjsua.pres_dump (int verbose) "
2245 "Dump presence subscriptions to log file.";
2246static char pjsua_im_send_doc[] =
2247 "int py_pjsua.im_send (int acc_id, string to, string mime_type, "
2248 "string content, py_pjsua.Msg_Data msg_data, int user_data) "
2249 "Send instant messaging outside dialog, using the specified account "
2250 "for route set and authentication.";
2251static char pjsua_im_typing_doc[] =
2252 "int py_pjsua.im_typing (int acc_id, string to, int is_typing, "
2253 "py_pjsua.Msg_Data msg_data) "
2254 "Send typing indication outside dialog.";
2255
2256/* END OF LIB BUDDY */
2257
2258/* LIB MEDIA */
2259
2260
2261
2262/*
2263 * PyObj_pjsua_codec_info
2264 * Codec Info
2265 * !modified @ 071206
2266 */
2267typedef struct
2268{
2269 PyObject_HEAD
2270 /* Type-specific fields go here. */
2271
2272 PyObject * codec_id;
2273 pj_uint8_t priority;
2274 char buf_[32];
2275} PyObj_pjsua_codec_info;
2276
2277
2278/*
2279 * codec_info_dealloc
2280 * deletes a codec_info from memory
2281 * !modified @ 071206
2282 */
2283static void codec_info_dealloc(PyObj_pjsua_codec_info* self)
2284{
2285 Py_XDECREF(self->codec_id);
2286
2287 self->ob_type->tp_free((PyObject*)self);
2288}
2289
2290
2291/*
2292 * codec_info_new
2293 * constructor for codec_info object
2294 * !modified @ 071206
2295 */
2296static PyObject * codec_info_new(PyTypeObject *type, PyObject *args,
2297 PyObject *kwds)
2298{
2299 PyObj_pjsua_codec_info *self;
2300
2301 PJ_UNUSED_ARG(args);
2302 PJ_UNUSED_ARG(kwds);
2303
2304 self = (PyObj_pjsua_codec_info *)type->tp_alloc(type, 0);
2305 if (self != NULL)
2306 {
2307 self->codec_id = PyString_FromString("");
2308 if (self->codec_id == NULL)
2309 {
2310 Py_DECREF(self);
2311 return NULL;
2312 }
2313
2314
2315 }
2316 return (PyObject *)self;
2317}
2318
2319/*
2320 * codec_info_members
2321 * !modified @ 071206
2322 */
2323static PyMemberDef codec_info_members[] =
2324{
2325 {
2326 "codec_id", T_OBJECT_EX,
2327 offsetof(PyObj_pjsua_codec_info, codec_id), 0,
2328 "Codec unique identification."
2329 },
2330
2331 {
2332 "priority", T_INT,
2333 offsetof(PyObj_pjsua_codec_info, priority), 0,
2334 "Codec priority (integer 0-255)."
2335 },
2336
2337
2338
2339 {NULL} /* Sentinel */
2340};
2341
2342
2343
2344
2345/*
2346 * PyTyp_pjsua_codec_info
2347 */
2348static PyTypeObject PyTyp_pjsua_codec_info =
2349{
2350 PyObject_HEAD_INIT(NULL)
2351 0, /*ob_size*/
2352 "py_pjsua.Codec_Info", /*tp_name*/
2353 sizeof(PyObj_pjsua_codec_info), /*tp_basicsize*/
2354 0, /*tp_itemsize*/
2355 (destructor)codec_info_dealloc,/*tp_dealloc*/
2356 0, /*tp_print*/
2357 0, /*tp_getattr*/
2358 0, /*tp_setattr*/
2359 0, /*tp_compare*/
2360 0, /*tp_repr*/
2361 0, /*tp_as_number*/
2362 0, /*tp_as_sequence*/
2363 0, /*tp_as_mapping*/
2364 0, /*tp_hash */
2365 0, /*tp_call*/
2366 0, /*tp_str*/
2367 0, /*tp_getattro*/
2368 0, /*tp_setattro*/
2369 0, /*tp_as_buffer*/
2370 Py_TPFLAGS_DEFAULT, /*tp_flags*/
2371 "Codec Info objects", /* tp_doc */
2372 0, /* tp_traverse */
2373 0, /* tp_clear */
2374 0, /* tp_richcompare */
2375 0, /* tp_weaklistoffset */
2376 0, /* tp_iter */
2377 0, /* tp_iternext */
2378 0, /* tp_methods */
2379 codec_info_members, /* tp_members */
2380 0, /* tp_getset */
2381 0, /* tp_base */
2382 0, /* tp_dict */
2383 0, /* tp_descr_get */
2384 0, /* tp_descr_set */
2385 0, /* tp_dictoffset */
2386 0, /* tp_init */
2387 0, /* tp_alloc */
2388 codec_info_new, /* tp_new */
2389
2390};
2391
2392/*
2393 * PyObj_pjsua_conf_port_info
2394 * Conf Port Info
2395 */
2396typedef struct
2397{
2398 PyObject_HEAD
2399 /* Type-specific fields go here. */
2400
2401 int slot_id;
2402 PyObject * name;
2403 unsigned clock_rate;
2404 unsigned channel_count;
2405 unsigned samples_per_frame;
2406 unsigned bits_per_sample;
2407 PyListObject * listeners;
2408
2409} PyObj_pjsua_conf_port_info;
2410
2411
2412/*
2413 * conf_port_info_dealloc
2414 * deletes a conf_port_info from memory
2415 */
2416static void conf_port_info_dealloc(PyObj_pjsua_conf_port_info* self)
2417{
2418 Py_XDECREF(self->name);
2419 Py_XDECREF(self->listeners);
2420 self->ob_type->tp_free((PyObject*)self);
2421}
2422
2423
2424/*
2425 * conf_port_info_new
2426 * constructor for conf_port_info object
2427 */
2428static PyObject * conf_port_info_new(PyTypeObject *type, PyObject *args,
2429 PyObject *kwds)
2430{
2431 PyObj_pjsua_conf_port_info *self;
2432
2433 PJ_UNUSED_ARG(args);
2434 PJ_UNUSED_ARG(kwds);
2435
2436 self = (PyObj_pjsua_conf_port_info *)type->tp_alloc(type, 0);
2437 if (self != NULL)
2438 {
2439 self->name = PyString_FromString("");
2440 if (self->name == NULL)
2441 {
2442 Py_DECREF(self);
2443 return NULL;
2444 }
2445
2446 self->listeners = (PyListObject *)PyList_New(0);
2447 if (self->listeners == NULL)
2448 {
2449 Py_DECREF(self);
2450 return NULL;
2451 }
2452 }
2453 return (PyObject *)self;
2454}
2455
2456/*
2457 * conf_port_info_members
2458 */
2459static PyMemberDef conf_port_info_members[] =
2460{
2461 {
2462 "slot_id", T_INT,
2463 offsetof(PyObj_pjsua_conf_port_info, slot_id), 0,
2464 "Conference port number."
2465 },
2466 {
2467 "name", T_OBJECT_EX,
2468 offsetof(PyObj_pjsua_conf_port_info, name), 0,
2469 "Port name"
2470 },
2471 {
2472 "clock_rate", T_INT,
2473 offsetof(PyObj_pjsua_conf_port_info, clock_rate), 0,
2474 "Clock rate"
2475 },
2476 {
2477 "channel_count", T_INT,
2478 offsetof(PyObj_pjsua_conf_port_info, channel_count), 0,
2479 "Number of channels."
2480 },
2481 {
2482 "samples_per_frame", T_INT,
2483 offsetof(PyObj_pjsua_conf_port_info, samples_per_frame), 0,
2484 "Samples per frame "
2485 },
2486 {
2487 "bits_per_sample", T_INT,
2488 offsetof(PyObj_pjsua_conf_port_info, bits_per_sample), 0,
2489 "Bits per sample"
2490 },
2491 {
2492 "listeners", T_OBJECT_EX,
2493 offsetof(PyObj_pjsua_conf_port_info, listeners), 0,
2494 "Array of listeners (in other words, ports where this port "
2495 "is transmitting to"
2496 },
2497
2498 {NULL} /* Sentinel */
2499};
2500
2501
2502
2503
2504/*
2505 * PyTyp_pjsua_conf_port_info
2506 */
2507static PyTypeObject PyTyp_pjsua_conf_port_info =
2508{
2509 PyObject_HEAD_INIT(NULL)
2510 0, /*ob_size*/
2511 "py_pjsua.Conf_Port_Info", /*tp_name*/
2512 sizeof(PyObj_pjsua_conf_port_info), /*tp_basicsize*/
2513 0, /*tp_itemsize*/
2514 (destructor)conf_port_info_dealloc,/*tp_dealloc*/
2515 0, /*tp_print*/
2516 0, /*tp_getattr*/
2517 0, /*tp_setattr*/
2518 0, /*tp_compare*/
2519 0, /*tp_repr*/
2520 0, /*tp_as_number*/
2521 0, /*tp_as_sequence*/
2522 0, /*tp_as_mapping*/
2523 0, /*tp_hash */
2524 0, /*tp_call*/
2525 0, /*tp_str*/
2526 0, /*tp_getattro*/
2527 0, /*tp_setattro*/
2528 0, /*tp_as_buffer*/
2529 Py_TPFLAGS_DEFAULT, /*tp_flags*/
2530 "Conf Port Info objects", /* tp_doc */
2531 0, /* tp_traverse */
2532 0, /* tp_clear */
2533 0, /* tp_richcompare */
2534 0, /* tp_weaklistoffset */
2535 0, /* tp_iter */
2536 0, /* tp_iternext */
2537 0, /* tp_methods */
2538 conf_port_info_members, /* tp_members */
2539 0, /* tp_getset */
2540 0, /* tp_base */
2541 0, /* tp_dict */
2542 0, /* tp_descr_get */
2543 0, /* tp_descr_set */
2544 0, /* tp_dictoffset */
2545 0, /* tp_init */
2546 0, /* tp_alloc */
2547 conf_port_info_new, /* tp_new */
2548
2549};
2550
2551/*
2552 * PyObj_pjmedia_port
2553 */
2554typedef struct
2555{
2556 PyObject_HEAD
2557 /* Type-specific fields go here. */
2558 pjmedia_port * port;
2559} PyObj_pjmedia_port;
2560
2561
2562/*
2563 * PyTyp_pjmedia_port
2564 */
2565static PyTypeObject PyTyp_pjmedia_port =
2566{
2567 PyObject_HEAD_INIT(NULL)
2568 0, /*ob_size*/
2569 "py_pjsua.PJMedia_Port", /*tp_name*/
2570 sizeof(PyObj_pjmedia_port), /*tp_basicsize*/
2571 0, /*tp_itemsize*/
2572 0, /*tp_dealloc*/
2573 0, /*tp_print*/
2574 0, /*tp_getattr*/
2575 0, /*tp_setattr*/
2576 0, /*tp_compare*/
2577 0, /*tp_repr*/
2578 0, /*tp_as_number*/
2579 0, /*tp_as_sequence*/
2580 0, /*tp_as_mapping*/
2581 0, /*tp_hash */
2582 0, /*tp_call*/
2583 0, /*tp_str*/
2584 0, /*tp_getattro*/
2585 0, /*tp_setattro*/
2586 0, /*tp_as_buffer*/
2587 Py_TPFLAGS_DEFAULT, /*tp_flags*/
2588 "pjmedia_port objects", /* tp_doc */
2589
2590};
2591
2592/*
2593 * PyObj_pjmedia_snd_dev_info
2594 * PJMedia Snd Dev Info
2595 */
2596typedef struct
2597{
2598 PyObject_HEAD
2599 /* Type-specific fields go here. */
2600
2601
2602 unsigned input_count;
2603 unsigned output_count;
2604 unsigned default_samples_per_sec;
2605 PyObject * name;
2606
2607} PyObj_pjmedia_snd_dev_info;
2608
2609
2610/*
2611 * pjmedia_snd_dev_info_dealloc
2612 * deletes a pjmedia_snd_dev_info from memory
2613 */
2614static void pjmedia_snd_dev_info_dealloc(PyObj_pjmedia_snd_dev_info* self)
2615{
2616 Py_XDECREF(self->name);
2617 self->ob_type->tp_free((PyObject*)self);
2618}
2619
2620
2621/*
2622 * pjmedia_snd_dev_info_new
2623 * constructor for pjmedia_snd_dev_info object
2624 */
2625static PyObject * pjmedia_snd_dev_info_new(PyTypeObject *type, PyObject *args,
2626 PyObject *kwds)
2627{
2628 PyObj_pjmedia_snd_dev_info *self;
2629
2630 PJ_UNUSED_ARG(args);
2631 PJ_UNUSED_ARG(kwds);
2632
2633 self = (PyObj_pjmedia_snd_dev_info *)type->tp_alloc(type, 0);
2634 if (self != NULL)
2635 {
2636 self->name = PyString_FromString("");
2637 if (self->name == NULL)
2638 {
2639 Py_DECREF(self);
2640 return NULL;
2641 }
2642
2643 }
2644 return (PyObject *)self;
2645}
2646
2647/*
2648 * pjmedia_snd_dev_info_members
2649 */
2650static PyMemberDef pjmedia_snd_dev_info_members[] =
2651{
2652
2653 {
2654 "name", T_OBJECT_EX,
2655 offsetof(PyObj_pjmedia_snd_dev_info, name), 0,
2656 "Device name"
2657 },
2658 {
2659 "input_count", T_INT,
2660 offsetof(PyObj_pjmedia_snd_dev_info, input_count), 0,
2661 "Max number of input channels"
2662 },
2663 {
2664 "output_count", T_INT,
2665 offsetof(PyObj_pjmedia_snd_dev_info, output_count), 0,
2666 "Max number of output channels"
2667 },
2668 {
2669 "default_samples_per_sec", T_INT,
2670 offsetof(PyObj_pjmedia_snd_dev_info, default_samples_per_sec), 0,
2671 "Default sampling rate."
2672 },
2673
2674
2675 {NULL} /* Sentinel */
2676};
2677
2678
2679
2680
2681/*
2682 * PyTyp_pjmedia_snd_dev_info
2683 */
2684static PyTypeObject PyTyp_pjmedia_snd_dev_info =
2685{
2686 PyObject_HEAD_INIT(NULL)
2687 0, /*ob_size*/
2688 "py_pjsua.PJMedia_Snd_Dev_Info", /*tp_name*/
2689 sizeof(PyObj_pjmedia_snd_dev_info), /*tp_basicsize*/
2690 0, /*tp_itemsize*/
2691 (destructor)pjmedia_snd_dev_info_dealloc,/*tp_dealloc*/
2692 0, /*tp_print*/
2693 0, /*tp_getattr*/
2694 0, /*tp_setattr*/
2695 0, /*tp_compare*/
2696 0, /*tp_repr*/
2697 0, /*tp_as_number*/
2698 0, /*tp_as_sequence*/
2699 0, /*tp_as_mapping*/
2700 0, /*tp_hash */
2701 0, /*tp_call*/
2702 0, /*tp_str*/
2703 0, /*tp_getattro*/
2704 0, /*tp_setattro*/
2705 0, /*tp_as_buffer*/
2706 Py_TPFLAGS_DEFAULT, /*tp_flags*/
2707 "PJMedia Snd Dev Info objects", /* tp_doc */
2708 0, /* tp_traverse */
2709 0, /* tp_clear */
2710 0, /* tp_richcompare */
2711 0, /* tp_weaklistoffset */
2712 0, /* tp_iter */
2713 0, /* tp_iternext */
2714 0, /* tp_methods */
2715 pjmedia_snd_dev_info_members, /* tp_members */
2716 0, /* tp_getset */
2717 0, /* tp_base */
2718 0, /* tp_dict */
2719 0, /* tp_descr_get */
2720 0, /* tp_descr_set */
2721 0, /* tp_dictoffset */
2722 0, /* tp_init */
2723 0, /* tp_alloc */
2724 pjmedia_snd_dev_info_new, /* tp_new */
2725
2726};
2727
2728/*
2729 * PyObj_pjmedia_codec_param_info
2730 * PJMedia Codec Param Info
2731 */
2732typedef struct
2733{
2734 PyObject_HEAD
2735 /* Type-specific fields go here. */
2736
2737 unsigned clock_rate;
2738 unsigned channel_cnt;
2739 pj_uint32_t avg_bps;
2740 pj_uint16_t frm_ptime;
2741 pj_uint8_t pcm_bits_per_sample;
2742 pj_uint8_t pt;
2743
2744} PyObj_pjmedia_codec_param_info;
2745
2746
2747
2748/*
2749 * pjmedia_codec_param_info_members
2750 */
2751static PyMemberDef pjmedia_codec_param_info_members[] =
2752{
2753
2754 {
2755 "clock_rate", T_INT,
2756 offsetof(PyObj_pjmedia_codec_param_info, clock_rate), 0,
2757 "Sampling rate in Hz"
2758 },
2759 {
2760 "channel_cnt", T_INT,
2761 offsetof(PyObj_pjmedia_codec_param_info, channel_cnt), 0,
2762 "Channel count"
2763 },
2764 {
2765 "avg_bps", T_INT,
2766 offsetof(PyObj_pjmedia_codec_param_info, avg_bps), 0,
2767 "Average bandwidth in bits/sec"
2768 },
2769 {
2770 "frm_ptime", T_INT,
2771 offsetof(PyObj_pjmedia_codec_param_info, frm_ptime), 0,
2772 "Base frame ptime in msec."
2773 },
2774 {
2775 "pcm_bits_per_sample", T_INT,
2776 offsetof(PyObj_pjmedia_codec_param_info, pcm_bits_per_sample), 0,
2777 "Bits/sample in the PCM side"
2778 },
2779 {
2780 "pt", T_INT,
2781 offsetof(PyObj_pjmedia_codec_param_info, pt), 0,
2782 "Payload type"
2783 },
2784
2785 {NULL} /* Sentinel */
2786};
2787
2788
2789
2790
2791/*
2792 * PyTyp_pjmedia_codec_param_info
2793 */
2794static PyTypeObject PyTyp_pjmedia_codec_param_info =
2795{
2796 PyObject_HEAD_INIT(NULL)
2797 0, /*ob_size*/
2798 "py_pjsua.PJMedia_Codec_Param_Info", /*tp_name*/
2799 sizeof(PyObj_pjmedia_codec_param_info), /*tp_basicsize*/
2800 0, /*tp_itemsize*/
2801 0,/*tp_dealloc*/
2802 0, /*tp_print*/
2803 0, /*tp_getattr*/
2804 0, /*tp_setattr*/
2805 0, /*tp_compare*/
2806 0, /*tp_repr*/
2807 0, /*tp_as_number*/
2808 0, /*tp_as_sequence*/
2809 0, /*tp_as_mapping*/
2810 0, /*tp_hash */
2811 0, /*tp_call*/
2812 0, /*tp_str*/
2813 0, /*tp_getattro*/
2814 0, /*tp_setattro*/
2815 0, /*tp_as_buffer*/
2816 Py_TPFLAGS_DEFAULT, /*tp_flags*/
2817 "PJMedia Codec Param Info objects", /* tp_doc */
2818 0, /* tp_traverse */
2819 0, /* tp_clear */
2820 0, /* tp_richcompare */
2821 0, /* tp_weaklistoffset */
2822 0, /* tp_iter */
2823 0, /* tp_iternext */
2824 0, /* tp_methods */
2825 pjmedia_codec_param_info_members, /* tp_members */
2826
2827
2828};
2829
2830/*
2831 * PyObj_pjmedia_codec_param_setting
2832 * PJMedia Codec Param Setting
2833 */
2834typedef struct
2835{
2836 PyObject_HEAD
2837 /* Type-specific fields go here. */
2838 pj_uint8_t frm_per_pkt;
2839 unsigned vad;
2840 unsigned cng;
2841 unsigned penh;
2842 unsigned plc;
2843 unsigned reserved;
2844 pj_uint8_t enc_fmtp_mode;
2845 pj_uint8_t dec_fmtp_mode;
2846
2847} PyObj_pjmedia_codec_param_setting;
2848
2849
2850
2851/*
2852 * pjmedia_codec_param_setting_members
2853 */
2854static PyMemberDef pjmedia_codec_param_setting_members[] =
2855{
2856
2857 {
2858 "frm_per_pkt", T_INT,
2859 offsetof(PyObj_pjmedia_codec_param_setting, frm_per_pkt), 0,
2860 "Number of frames per packet"
2861 },
2862 {
2863 "vad", T_INT,
2864 offsetof(PyObj_pjmedia_codec_param_setting, vad), 0,
2865 "Voice Activity Detector"
2866 },
2867 {
2868 "penh", T_INT,
2869 offsetof(PyObj_pjmedia_codec_param_setting, penh), 0,
2870 "Perceptual Enhancement"
2871 },
2872 {
2873 "plc", T_INT,
2874 offsetof(PyObj_pjmedia_codec_param_setting, plc), 0,
2875 "Packet loss concealment"
2876 },
2877 {
2878 "reserved", T_INT,
2879 offsetof(PyObj_pjmedia_codec_param_setting, reserved), 0,
2880 "Reserved, must be zero"
2881 },
2882 {
2883 "cng", T_INT,
2884 offsetof(PyObj_pjmedia_codec_param_setting, cng), 0,
2885 "Comfort Noise Generator"
2886 },
2887 {
2888 "enc_fmtp_mode", T_INT,
2889 offsetof(PyObj_pjmedia_codec_param_setting, enc_fmtp_mode), 0,
2890 "Mode param in fmtp (def:0)"
2891 },
2892 {
2893 "dec_fmtp_mode", T_INT,
2894 offsetof(PyObj_pjmedia_codec_param_setting, dec_fmtp_mode), 0,
2895 "Mode param in fmtp (def:0)"
2896 },
2897
2898 {NULL} /* Sentinel */
2899};
2900
2901
2902
2903
2904/*
2905 * PyTyp_pjmedia_codec_param_setting
2906 */
2907static PyTypeObject PyTyp_pjmedia_codec_param_setting =
2908{
2909 PyObject_HEAD_INIT(NULL)
2910 0, /*ob_size*/
2911 "py_pjsua.PJMedia_Codec_Param_Setting", /*tp_name*/
2912 sizeof(PyObj_pjmedia_codec_param_setting), /*tp_basicsize*/
2913 0, /*tp_itemsize*/
2914 0,/*tp_dealloc*/
2915 0, /*tp_print*/
2916 0, /*tp_getattr*/
2917 0, /*tp_setattr*/
2918 0, /*tp_compare*/
2919 0, /*tp_repr*/
2920 0, /*tp_as_number*/
2921 0, /*tp_as_sequence*/
2922 0, /*tp_as_mapping*/
2923 0, /*tp_hash */
2924 0, /*tp_call*/
2925 0, /*tp_str*/
2926 0, /*tp_getattro*/
2927 0, /*tp_setattro*/
2928 0, /*tp_as_buffer*/
2929 Py_TPFLAGS_DEFAULT, /*tp_flags*/
2930 "PJMedia Codec Param Setting objects", /* tp_doc */
2931 0, /* tp_traverse */
2932 0, /* tp_clear */
2933 0, /* tp_richcompare */
2934 0, /* tp_weaklistoffset */
2935 0, /* tp_iter */
2936 0, /* tp_iternext */
2937 0, /* tp_methods */
2938 pjmedia_codec_param_setting_members, /* tp_members */
2939
2940
2941};
2942
2943/*
2944 * PyObj_pjmedia_codec_param
2945 * PJMedia Codec Param
2946 */
2947typedef struct
2948{
2949 PyObject_HEAD
2950 /* Type-specific fields go here. */
2951
2952 PyObj_pjmedia_codec_param_info * info;
2953 PyObj_pjmedia_codec_param_setting * setting;
2954
2955} PyObj_pjmedia_codec_param;
2956
2957
2958/*
2959 * pjmedia_codec_param_dealloc
2960 * deletes a pjmedia_codec_param from memory
2961 */
2962static void pjmedia_codec_param_dealloc(PyObj_pjmedia_codec_param* self)
2963{
2964 Py_XDECREF(self->info);
2965 Py_XDECREF(self->setting);
2966 self->ob_type->tp_free((PyObject*)self);
2967}
2968
2969
2970/*
2971 * pjmedia_codec_param_new
2972 * constructor for pjmedia_codec_param object
2973 */
2974static PyObject * pjmedia_codec_param_new(PyTypeObject *type, PyObject *args,
2975 PyObject *kwds)
2976{
2977 PyObj_pjmedia_codec_param *self;
2978
2979 PJ_UNUSED_ARG(args);
2980 PJ_UNUSED_ARG(kwds);
2981
2982 self = (PyObj_pjmedia_codec_param *)type->tp_alloc(type, 0);
2983 if (self != NULL)
2984 {
2985 self->info = (PyObj_pjmedia_codec_param_info *)
2986 PyType_GenericNew(&PyTyp_pjmedia_codec_param_info, NULL, NULL);
2987 if (self->info == NULL)
2988 {
2989 Py_DECREF(self);
2990 return NULL;
2991 }
2992 self->setting = (PyObj_pjmedia_codec_param_setting *)
2993 PyType_GenericNew(&PyTyp_pjmedia_codec_param_setting, NULL, NULL);
2994 if (self->setting == NULL)
2995 {
2996 Py_DECREF(self);
2997 return NULL;
2998 }
2999 }
3000 return (PyObject *)self;
3001}
3002
3003/*
3004 * pjmedia_codec_param_members
3005 */
3006static PyMemberDef pjmedia_codec_param_members[] =
3007{
3008
3009 {
3010 "info", T_OBJECT_EX,
3011 offsetof(PyObj_pjmedia_codec_param, info), 0,
3012 "The 'info' part of codec param describes the capability of the codec,"
3013 " and the value should NOT be changed by application."
3014 },
3015 {
3016 "setting", T_OBJECT_EX,
3017 offsetof(PyObj_pjmedia_codec_param, setting), 0,
3018 "The 'setting' part of codec param describes various settings to be "
3019 "applied to the codec. When the codec param is retrieved from the "
3020 "codec or codec factory, the values of these will be filled by "
3021 "the capability of the codec. Any features that are supported by "
3022 "the codec (e.g. vad or plc) will be turned on, so that application "
3023 "can query which capabilities are supported by the codec. "
3024 "Application may change the settings here before instantiating "
3025 "the codec/stream."
3026 },
3027
3028 {NULL} /* Sentinel */
3029};
3030
3031
3032
3033
3034/*
3035 * PyTyp_pjmedia_codec_param
3036 */
3037static PyTypeObject PyTyp_pjmedia_codec_param =
3038{
3039 PyObject_HEAD_INIT(NULL)
3040 0, /*ob_size*/
3041 "py_pjsua.PJMedia_Codec_Param", /*tp_name*/
3042 sizeof(PyObj_pjmedia_codec_param), /*tp_basicsize*/
3043 0, /*tp_itemsize*/
3044 (destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/
3045 0, /*tp_print*/
3046 0, /*tp_getattr*/
3047 0, /*tp_setattr*/
3048 0, /*tp_compare*/
3049 0, /*tp_repr*/
3050 0, /*tp_as_number*/
3051 0, /*tp_as_sequence*/
3052 0, /*tp_as_mapping*/
3053 0, /*tp_hash */
3054 0, /*tp_call*/
3055 0, /*tp_str*/
3056 0, /*tp_getattro*/
3057 0, /*tp_setattro*/
3058 0, /*tp_as_buffer*/
3059 Py_TPFLAGS_DEFAULT, /*tp_flags*/
3060 "PJMedia Codec Param objects", /* tp_doc */
3061 0, /* tp_traverse */
3062 0, /* tp_clear */
3063 0, /* tp_richcompare */
3064 0, /* tp_weaklistoffset */
3065 0, /* tp_iter */
3066 0, /* tp_iternext */
3067 0, /* tp_methods */
3068 pjmedia_codec_param_members, /* tp_members */
3069 0, /* tp_getset */
3070 0, /* tp_base */
3071 0, /* tp_dict */
3072 0, /* tp_descr_get */
3073 0, /* tp_descr_set */
3074 0, /* tp_dictoffset */
3075 0, /* tp_init */
3076 0, /* tp_alloc */
3077 pjmedia_codec_param_new, /* tp_new */
3078
3079};
3080
3081/*
3082 * py_pjsua_conf_get_max_ports
3083 */
3084static PyObject *py_pjsua_conf_get_max_ports
3085(PyObject *pSelf, PyObject *pArgs)
3086{
3087 int ret;
3088
3089 PJ_UNUSED_ARG(pSelf);
3090
3091 if (!PyArg_ParseTuple(pArgs, ""))
3092 {
3093 return NULL;
3094 }
3095 ret = pjsua_conf_get_max_ports();
3096
3097 return Py_BuildValue("i", ret);
3098}
3099
3100/*
3101 * py_pjsua_conf_get_active_ports
3102 */
3103static PyObject *py_pjsua_conf_get_active_ports
3104(PyObject *pSelf, PyObject *pArgs)
3105{
3106 int ret;
3107
3108 PJ_UNUSED_ARG(pSelf);
3109
3110 if (!PyArg_ParseTuple(pArgs, ""))
3111 {
3112 return NULL;
3113 }
3114 ret = pjsua_conf_get_active_ports();
3115
3116 return Py_BuildValue("i", ret);
3117}
3118
3119/*
3120 * py_pjsua_enum_conf_ports
3121 * !modified @ 241206
3122 */
3123static PyObject *py_pjsua_enum_conf_ports(PyObject *pSelf, PyObject *pArgs)
3124{
3125 pj_status_t status;
3126 PyObject *list;
3127
3128 pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS];
3129 unsigned c, i;
3130
3131 PJ_UNUSED_ARG(pSelf);
3132
3133 if (!PyArg_ParseTuple(pArgs, ""))
3134 {
3135 return NULL;
3136 }
3137
3138 c = PJ_ARRAY_SIZE(id);
3139 status = pjsua_enum_conf_ports(id, &c);
3140
3141 list = PyList_New(c);
3142 for (i = 0; i < c; i++)
3143 {
3144 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
3145 if (ret == -1)
3146 {
3147 return NULL;
3148 }
3149 }
3150
3151 return Py_BuildValue("O",list);
3152}
3153
3154/*
3155 * py_pjsua_conf_get_port_info
3156 */
3157static PyObject *py_pjsua_conf_get_port_info
3158(PyObject *pSelf, PyObject *pArgs)
3159{
3160 int id;
3161 PyObj_pjsua_conf_port_info * obj;
3162 pjsua_conf_port_info info;
3163 int status;
3164 unsigned i;
3165
3166 PJ_UNUSED_ARG(pSelf);
3167
3168 if (!PyArg_ParseTuple(pArgs, "i", &id))
3169 {
3170 return NULL;
3171 }
3172
3173
3174 status = pjsua_conf_get_port_info(id, &info);
3175 obj = (PyObj_pjsua_conf_port_info *)conf_port_info_new
3176 (&PyTyp_pjsua_conf_port_info,NULL,NULL);
3177 obj->bits_per_sample = info.bits_per_sample;
3178 obj->channel_count = info.bits_per_sample;
3179 obj->clock_rate = info.clock_rate;
3180 obj->name = PyString_FromStringAndSize(info.name.ptr, info.name.slen);
3181 obj->samples_per_frame = info.samples_per_frame;
3182 obj->slot_id = info.slot_id;
3183
3184 obj->listeners = (PyListObject *)PyList_New(info.listener_cnt);
3185 for (i = 0; i < info.listener_cnt; i++) {
3186 PyObject * item = Py_BuildValue("i",info.listeners[i]);
3187 PyList_SetItem((PyObject *)obj->listeners, i, item);
3188 }
3189 return Py_BuildValue("O", obj);
3190}
3191
3192/*
3193 * py_pjsua_conf_add_port
3194 */
3195static PyObject *py_pjsua_conf_add_port
3196(PyObject *pSelf, PyObject *pArgs)
3197{
3198 int p_id;
3199 PyObject * oportObj;
3200 PyObj_pjmedia_port * oport;
3201 pjmedia_port * port;
3202 PyObject * opoolObj;
3203 PyObj_pj_pool * opool;
3204 pj_pool_t * pool;
3205
3206 int status;
3207
3208 PJ_UNUSED_ARG(pSelf);
3209
3210 if (!PyArg_ParseTuple(pArgs, "OO", &opoolObj, &oportObj))
3211 {
3212 return NULL;
3213 }
3214 if (opoolObj != Py_None)
3215 {
3216 opool = (PyObj_pj_pool *)opoolObj;
3217 pool = opool->pool;
3218 } else {
3219 opool = NULL;
3220 pool = NULL;
3221 }
3222 if (oportObj != Py_None)
3223 {
3224 oport = (PyObj_pjmedia_port *)oportObj;
3225 port = oport->port;
3226 } else {
3227 oport = NULL;
3228 port = NULL;
3229 }
3230
3231 status = pjsua_conf_add_port(pool, port, &p_id);
3232
3233
3234 return Py_BuildValue("ii", status, p_id);
3235}
3236
3237/*
3238 * py_pjsua_conf_remove_port
3239 */
3240static PyObject *py_pjsua_conf_remove_port
3241(PyObject *pSelf, PyObject *pArgs)
3242{
3243 int id;
3244 int status;
3245
3246 PJ_UNUSED_ARG(pSelf);
3247
3248 if (!PyArg_ParseTuple(pArgs, "i", &id))
3249 {
3250 return NULL;
3251 }
3252
3253 status = pjsua_conf_remove_port(id);
3254
3255
3256 return Py_BuildValue("i", status);
3257}
3258
3259/*
3260 * py_pjsua_conf_connect
3261 */
3262static PyObject *py_pjsua_conf_connect
3263(PyObject *pSelf, PyObject *pArgs)
3264{
3265 int source, sink;
3266 int status;
3267
3268 PJ_UNUSED_ARG(pSelf);
3269
3270 if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink))
3271 {
3272 return NULL;
3273 }
3274
3275 status = pjsua_conf_connect(source, sink);
3276
3277
3278 return Py_BuildValue("i", status);
3279}
3280
3281/*
3282 * py_pjsua_conf_disconnect
3283 */
3284static PyObject *py_pjsua_conf_disconnect
3285(PyObject *pSelf, PyObject *pArgs)
3286{
3287 int source, sink;
3288 int status;
3289
3290 PJ_UNUSED_ARG(pSelf);
3291
3292 if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink))
3293 {
3294 return NULL;
3295 }
3296
3297 status = pjsua_conf_disconnect(source, sink);
3298
3299
3300 return Py_BuildValue("i", status);
3301}
3302
3303/*
3304 * py_pjsua_player_create
3305 */
3306static PyObject *py_pjsua_player_create
3307(PyObject *pSelf, PyObject *pArgs)
3308{
3309 int id;
3310 int options;
3311 PyObject * filename;
3312 pj_str_t str;
3313 int status;
3314
3315 PJ_UNUSED_ARG(pSelf);
3316
3317 if (!PyArg_ParseTuple(pArgs, "Oi", &filename, &options))
3318 {
3319 return NULL;
3320 }
3321 str.ptr = PyString_AsString(filename);
3322 str.slen = strlen(PyString_AsString(filename));
3323 status = pjsua_player_create(&str, options, &id);
3324
3325 return Py_BuildValue("ii", status, id);
3326}
3327
3328/*
3329 * py_pjsua_player_get_conf_port
3330 */
3331static PyObject *py_pjsua_player_get_conf_port
3332(PyObject *pSelf, PyObject *pArgs)
3333{
3334
3335 int id, port_id;
3336
3337 PJ_UNUSED_ARG(pSelf);
3338
3339 if (!PyArg_ParseTuple(pArgs, "i", &id))
3340 {
3341 return NULL;
3342 }
3343
3344 port_id = pjsua_player_get_conf_port(id);
3345
3346
3347 return Py_BuildValue("i", port_id);
3348}
3349
3350/*
3351 * py_pjsua_player_set_pos
3352 */
3353static PyObject *py_pjsua_player_set_pos
3354(PyObject *pSelf, PyObject *pArgs)
3355{
3356 int id;
3357 pj_uint32_t samples;
3358 int status;
3359
3360 PJ_UNUSED_ARG(pSelf);
3361
3362 if (!PyArg_ParseTuple(pArgs, "iI", &id, &samples))
3363 {
3364 return NULL;
3365 }
3366
3367 status = pjsua_player_set_pos(id, samples);
3368
3369
3370 return Py_BuildValue("i", status);
3371}
3372
3373/*
3374 * py_pjsua_player_destroy
3375 */
3376static PyObject *py_pjsua_player_destroy
3377(PyObject *pSelf, PyObject *pArgs)
3378{
3379 int id;
3380 int status;
3381
3382 PJ_UNUSED_ARG(pSelf);
3383
3384 if (!PyArg_ParseTuple(pArgs, "i", &id))
3385 {
3386 return NULL;
3387 }
3388
3389 status = pjsua_player_destroy(id);
3390
3391
3392 return Py_BuildValue("i", status);
3393}
3394
3395/*
3396 * py_pjsua_recorder_create
3397 * !modified @ 261206
3398 */
3399static PyObject *py_pjsua_recorder_create
3400(PyObject *pSelf, PyObject *pArgs)
3401{
3402 int p_id;
3403 int options;
3404 int max_size;
3405 PyObject * filename;
3406 pj_str_t str;
3407 PyObject * enc_param;
3408 pj_str_t strparam;
3409 int enc_type;
3410
3411 int status;
3412
3413 PJ_UNUSED_ARG(pSelf);
3414
3415 if (!PyArg_ParseTuple(pArgs, "OiOii", &filename,
3416 &enc_type, &enc_param, &max_size, &options))
3417 {
3418 return NULL;
3419 }
3420 str.ptr = PyString_AsString(filename);
3421 str.slen = strlen(PyString_AsString(filename));
3422 if (enc_param != Py_None)
3423 {
3424 strparam.ptr = PyString_AsString(enc_param);
3425 strparam.slen = strlen(PyString_AsString(enc_param));
3426 status = pjsua_recorder_create
3427 (&str, enc_type, NULL, max_size, options, &p_id);
3428 } else {
3429 status = pjsua_recorder_create
3430 (&str, enc_type, NULL, max_size, options, &p_id);
3431 }
3432 return Py_BuildValue("ii", status, p_id);
3433}
3434
3435/*
3436 * py_pjsua_recorder_get_conf_port
3437 */
3438static PyObject *py_pjsua_recorder_get_conf_port
3439(PyObject *pSelf, PyObject *pArgs)
3440{
3441
3442 int id, port_id;
3443
3444 PJ_UNUSED_ARG(pSelf);
3445
3446 if (!PyArg_ParseTuple(pArgs, "i", &id))
3447 {
3448 return NULL;
3449 }
3450
3451 port_id = pjsua_recorder_get_conf_port(id);
3452
3453
3454 return Py_BuildValue("i", port_id);
3455}
3456
3457/*
3458 * py_pjsua_recorder_destroy
3459 */
3460static PyObject *py_pjsua_recorder_destroy
3461(PyObject *pSelf, PyObject *pArgs)
3462{
3463 int id;
3464 int status;
3465
3466 PJ_UNUSED_ARG(pSelf);
3467
3468 if (!PyArg_ParseTuple(pArgs, "i", &id))
3469 {
3470 return NULL;
3471 }
3472
3473 status = pjsua_recorder_destroy(id);
3474
3475
3476 return Py_BuildValue("i", status);
3477}
3478
3479/*
3480 * py_pjsua_enum_snd_devs
3481 */
3482static PyObject *py_pjsua_enum_snd_devs(PyObject *pSelf, PyObject *pArgs)
3483{
3484 pj_status_t status;
3485 PyObject *list;
3486
3487 pjmedia_snd_dev_info info[SND_DEV_NUM];
3488 unsigned c, i;
3489
3490 PJ_UNUSED_ARG(pSelf);
3491
3492 if (!PyArg_ParseTuple(pArgs, ""))
3493 {
3494 return NULL;
3495 }
3496
3497 c = PJ_ARRAY_SIZE(info);
3498 status = pjsua_enum_snd_devs(info, &c);
3499
3500 list = PyList_New(c);
3501 for (i = 0; i < c; i++)
3502 {
3503 int ret;
3504 int j;
3505 char * str;
3506
3507 PyObj_pjmedia_snd_dev_info * obj;
3508 obj = (PyObj_pjmedia_snd_dev_info *)pjmedia_snd_dev_info_new
3509 (&PyTyp_pjmedia_snd_dev_info, NULL, NULL);
3510 obj->default_samples_per_sec = info[i].default_samples_per_sec;
3511 obj->input_count = info[i].input_count;
3512 obj->output_count = info[i].output_count;
3513 str = (char *)malloc(SND_NAME_LEN * sizeof(char));
3514 memset(str, 0, SND_NAME_LEN);
3515 for (j = 0; j < SND_NAME_LEN; j++)
3516 {
3517 str[j] = info[i].name[j];
3518 }
3519 obj->name = PyString_FromStringAndSize(str, SND_NAME_LEN);
3520 free(str);
3521 ret = PyList_SetItem(list, i, (PyObject *)obj);
3522 if (ret == -1)
3523 {
3524 return NULL;
3525 }
3526 }
3527
3528 return Py_BuildValue("O",list);
3529}
3530
3531/*
3532 * py_pjsua_get_snd_dev
3533 */
3534static PyObject *py_pjsua_get_snd_dev
3535(PyObject *pSelf, PyObject *pArgs)
3536{
3537 int capture_dev, playback_dev;
3538 int status;
3539
3540 PJ_UNUSED_ARG(pSelf);
3541
3542 if (!PyArg_ParseTuple(pArgs, ""))
3543 {
3544 return NULL;
3545 }
3546
3547 status = pjsua_get_snd_dev(&capture_dev, &playback_dev);
3548
3549
3550 return Py_BuildValue("ii", capture_dev, playback_dev);
3551}
3552
3553/*
3554 * py_pjsua_set_snd_dev
3555 */
3556static PyObject *py_pjsua_set_snd_dev
3557(PyObject *pSelf, PyObject *pArgs)
3558{
3559 int capture_dev, playback_dev;
3560 int status;
3561
3562 PJ_UNUSED_ARG(pSelf);
3563
3564 if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev))
3565 {
3566 return NULL;
3567 }
3568
3569 status = pjsua_set_snd_dev(capture_dev, playback_dev);
3570
3571
3572 return Py_BuildValue("i", status);
3573}
3574
3575/*
3576 * py_pjsua_set_null_snd_dev
3577 */
3578static PyObject *py_pjsua_set_null_snd_dev
3579(PyObject *pSelf, PyObject *pArgs)
3580{
3581
3582 int status;
3583
3584 PJ_UNUSED_ARG(pSelf);
3585
3586 if (!PyArg_ParseTuple(pArgs, ""))
3587 {
3588 return NULL;
3589 }
3590
3591 status = pjsua_set_null_snd_dev();
3592
3593
3594 return Py_BuildValue("i", status);
3595}
3596
3597/*
3598 * py_pjsua_set_no_snd_dev
3599 */
3600static PyObject *py_pjsua_set_no_snd_dev
3601(PyObject *pSelf, PyObject *pArgs)
3602{
3603
3604 PyObj_pjmedia_port * obj;
3605
3606 PJ_UNUSED_ARG(pSelf);
3607
3608 if (!PyArg_ParseTuple(pArgs, ""))
3609 {
3610 return NULL;
3611 }
3612
3613 obj = (PyObj_pjmedia_port *)PyType_GenericNew
3614 (&PyTyp_pjmedia_port, NULL, NULL);
3615 obj->port = pjsua_set_no_snd_dev();
3616 return Py_BuildValue("O", obj);
3617}
3618
3619/*
3620 * py_pjsua_set_ec
3621 */
3622static PyObject *py_pjsua_set_ec
3623(PyObject *pSelf, PyObject *pArgs)
3624{
3625 int options;
3626 int tail_ms;
3627 int status;
3628
3629 PJ_UNUSED_ARG(pSelf);
3630
3631 if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options))
3632 {
3633 return NULL;
3634 }
3635
3636 status = pjsua_set_ec(tail_ms, options);
3637
3638
3639 return Py_BuildValue("i", status);
3640}
3641
3642/*
3643 * py_pjsua_get_ec_tail
3644 */
3645static PyObject *py_pjsua_get_ec_tail
3646(PyObject *pSelf, PyObject *pArgs)
3647{
3648
3649 int status;
3650 unsigned p_tail_ms;
3651
3652 PJ_UNUSED_ARG(pSelf);
3653
3654 if (!PyArg_ParseTuple(pArgs, ""))
3655 {
3656 return NULL;
3657 }
3658
3659 status = pjsua_get_ec_tail(&p_tail_ms);
3660
3661
3662 return Py_BuildValue("i", p_tail_ms);
3663}
3664
3665/*
3666 * py_pjsua_enum_codecs
3667 * !modified @ 261206
3668 */
3669static PyObject *py_pjsua_enum_codecs(PyObject *pSelf, PyObject *pArgs)
3670{
3671 pj_status_t status;
3672 PyObject *list;
3673
3674 pjsua_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS];
3675 unsigned c, i;
3676
3677 PJ_UNUSED_ARG(pSelf);
3678
3679 if (!PyArg_ParseTuple(pArgs, ""))
3680 {
3681 return NULL;
3682 }
3683
3684 c = PJ_ARRAY_SIZE(info);
3685 status = pjsua_enum_codecs(info, &c);
3686
3687 list = PyList_New(c);
3688 for (i = 0; i < c; i++)
3689 {
3690 int ret;
3691 int j;
3692 PyObj_pjsua_codec_info * obj;
3693 obj = (PyObj_pjsua_codec_info *)codec_info_new
3694 (&PyTyp_pjsua_codec_info, NULL, NULL);
3695 obj->codec_id = PyString_FromStringAndSize
3696 (info[i].codec_id.ptr, info[i].codec_id.slen);
3697 obj->priority = info[i].priority;
3698 for (j = 0; j < 32; j++)
3699 {
3700 obj->buf_[j] = info[i].buf_[j];
3701 }
3702 ret = PyList_SetItem(list, i, (PyObject *)obj);
3703 if (ret == -1) {
3704 return NULL;
3705 }
3706 }
3707
3708
3709 return Py_BuildValue("O",list);
3710}
3711
3712/*
3713 * py_pjsua_codec_set_priority
3714 */
3715static PyObject *py_pjsua_codec_set_priority
3716(PyObject *pSelf, PyObject *pArgs)
3717{
3718
3719 int status;
3720 PyObject * id;
3721 pj_str_t str;
3722 pj_uint8_t priority;
3723
3724 PJ_UNUSED_ARG(pSelf);
3725
3726 if (!PyArg_ParseTuple(pArgs, "OB", &id, &priority))
3727 {
3728 return NULL;
3729 }
3730 str.ptr = PyString_AsString(id);
3731 str.slen = strlen(PyString_AsString(id));
3732 status = pjsua_codec_set_priority(&str, priority);
3733
3734
3735 return Py_BuildValue("i", status);
3736}
3737
3738/*
3739 * py_pjsua_codec_get_param
3740 */
3741static PyObject *py_pjsua_codec_get_param
3742(PyObject *pSelf, PyObject *pArgs)
3743{
3744
3745 int status;
3746 PyObject * id;
3747 pj_str_t str;
3748 pjmedia_codec_param param;
3749 PyObj_pjmedia_codec_param *obj;
3750
3751 PJ_UNUSED_ARG(pSelf);
3752
3753 if (!PyArg_ParseTuple(pArgs, "O", &id))
3754 {
3755 return NULL;
3756 }
3757 str.ptr = PyString_AsString(id);
3758 str.slen = strlen(PyString_AsString(id));
3759 status = pjsua_codec_get_param(&str, &param);
3760 obj = (PyObj_pjmedia_codec_param *)pjmedia_codec_param_new
3761 (&PyTyp_pjmedia_codec_param, NULL, NULL);
3762 obj->info->avg_bps = param.info.avg_bps;
3763 obj->info->channel_cnt = param.info.channel_cnt;
3764 obj->info->clock_rate = param.info.clock_rate;
3765 obj->info->frm_ptime = param.info.frm_ptime;
3766 obj->info->pcm_bits_per_sample = param.info.pcm_bits_per_sample;
3767 obj->info->pt = param.info.pt;
3768 obj->setting->cng = param.setting.cng;
3769 //deprecated:
3770 //obj->setting->dec_fmtp_mode = param.setting.dec_fmtp_mode;
3771 //obj->setting->enc_fmtp_mode = param.setting.enc_fmtp_mode;
3772 obj->setting->frm_per_pkt = param.setting.frm_per_pkt;
3773 obj->setting->penh = param.setting.penh;
3774 obj->setting->plc = param.setting.plc;
3775 obj->setting->reserved = param.setting.reserved;
3776 obj->setting->vad = param.setting.vad;
3777
3778 return Py_BuildValue("O", obj);
3779}
3780/*
3781 * py_pjsua_codec_set_param
3782 */
3783static PyObject *py_pjsua_codec_set_param
3784(PyObject *pSelf, PyObject *pArgs)
3785{
3786
3787 int status;
3788 PyObject * id;
3789 pj_str_t str;
3790 pjmedia_codec_param param;
3791 PyObject * tmpObj;
3792 PyObj_pjmedia_codec_param *obj;
3793
3794 PJ_UNUSED_ARG(pSelf);
3795
3796 if (!PyArg_ParseTuple(pArgs, "OO", &id, &tmpObj))
3797 {
3798 return NULL;
3799 }
3800
3801 str.ptr = PyString_AsString(id);
3802 str.slen = strlen(PyString_AsString(id));
3803 if (tmpObj != Py_None)
3804 {
3805 obj = (PyObj_pjmedia_codec_param *)tmpObj;
3806 param.info.avg_bps = obj->info->avg_bps;
3807 param.info.channel_cnt = obj->info->channel_cnt;
3808 param.info.clock_rate = obj->info->clock_rate;
3809 param.info.frm_ptime = obj->info->frm_ptime;
3810 param.info.pcm_bits_per_sample = obj->info->pcm_bits_per_sample;
3811 param.info.pt = obj->info->pt;
3812 param.setting.cng = obj->setting->cng;
3813 //Deprecated:
3814 //param.setting.dec_fmtp_mode = obj->setting->dec_fmtp_mode;
3815 //param.setting.enc_fmtp_mode = obj->setting->enc_fmtp_mode;
3816 param.setting.frm_per_pkt = obj->setting->frm_per_pkt;
3817 param.setting.penh = obj->setting->penh;
3818 param.setting.plc = obj->setting->plc;
3819 param.setting.reserved = obj->setting->reserved;
3820 param.setting.vad = obj->setting->vad;
3821 status = pjsua_codec_set_param(&str, &param);
3822 } else {
3823 status = pjsua_codec_set_param(&str, NULL);
3824 }
3825 return Py_BuildValue("i", status);
3826}
3827
3828static char pjsua_conf_get_max_ports_doc[] =
3829 "int py_pjsua.conf_get_max_ports () "
3830 "Get maxinum number of conference ports.";
3831static char pjsua_conf_get_active_ports_doc[] =
3832 "int py_pjsua.conf_get_active_ports () "
3833 "Get current number of active ports in the bridge.";
3834static char pjsua_enum_conf_ports_doc[] =
3835 "int[] py_pjsua.enum_conf_ports () "
3836 "Enumerate all conference ports.";
3837static char pjsua_conf_get_port_info_doc[] =
3838 "py_pjsua.Conf_Port_Info py_pjsua.conf_get_port_info (int id) "
3839 "Get information about the specified conference port";
3840static char pjsua_conf_add_port_doc[] =
3841 "int, int py_pjsua.conf_add_port "
3842 "(py_pjsua.Pj_Pool pool, py_pjsua.PJMedia_Port port) "
3843 "Add arbitrary media port to PJSUA's conference bridge. "
3844 "Application can use this function to add the media port "
3845 "that it creates. For media ports that are created by PJSUA-LIB "
3846 "(such as calls, file player, or file recorder), PJSUA-LIB will "
3847 "automatically add the port to the bridge.";
3848static char pjsua_conf_remove_port_doc[] =
3849 "int py_pjsua.conf_remove_port (int id) "
3850 "Remove arbitrary slot from the conference bridge. "
3851 "Application should only call this function "
3852 "if it registered the port manually.";
3853static char pjsua_conf_connect_doc[] =
3854 "int py_pjsua.conf_connect (int source, int sink) "
3855 "Establish unidirectional media flow from souce to sink. "
3856 "One source may transmit to multiple destinations/sink. "
3857 "And if multiple sources are transmitting to the same sink, "
3858 "the media will be mixed together. Source and sink may refer "
3859 "to the same ID, effectively looping the media. "
3860 "If bidirectional media flow is desired, application "
3861 "needs to call this function twice, with the second "
3862 "one having the arguments reversed.";
3863static char pjsua_conf_disconnect_doc[] =
3864 "int py_pjsua.conf_disconnect (int source, int sink) "
3865 "Disconnect media flow from the source to destination port.";
3866static char pjsua_player_create_doc[] =
3867 "int, int py_pjsua.player_create (string filename, int options) "
3868 "Create a file player, and automatically connect "
3869 "this player to the conference bridge.";
3870static char pjsua_player_get_conf_port_doc[] =
3871 "int py_pjsua.player_get_conf_port (int) "
3872 "Get conference port ID associated with player.";
3873static char pjsua_player_set_pos_doc[] =
3874 "int py_pjsua.player_set_pos (int id, int samples) "
3875 "Set playback position.";
3876static char pjsua_player_destroy_doc[] =
3877 "int py_pjsua.player_destroy (int id) "
3878 "Close the file, remove the player from the bridge, "
3879 "and free resources associated with the file player.";
3880static char pjsua_recorder_create_doc[] =
3881 "int, int py_pjsua.recorder_create (string filename, "
3882 "int enc_type, int enc_param, int max_size, int options) "
3883 "Create a file recorder, and automatically connect this recorder "
3884 "to the conference bridge. The recorder currently supports recording "
3885 "WAV file, and on Windows, MP3 file. The type of the recorder to use "
3886 "is determined by the extension of the file (e.g. '.wav' or '.mp3').";
3887static char pjsua_recorder_get_conf_port_doc[] =
3888 "int py_pjsua.recorder_get_conf_port (int id) "
3889 "Get conference port associated with recorder.";
3890static char pjsua_recorder_destroy_doc[] =
3891 "int py_pjsua.recorder_destroy (int id) "
3892 "Destroy recorder (this will complete recording).";
3893static char pjsua_enum_snd_devs_doc[] =
3894 "py_pjsua.PJMedia_Snd_Dev_Info[] py_pjsua.enum_snd_devs (int count) "
3895 "Enum sound devices.";
3896static char pjsua_get_snd_dev_doc[] =
3897 "int, int py_pjsua.get_snd_dev () "
3898 "Get currently active sound devices. "
3899 "If sound devices has not been created "
3900 "(for example when pjsua_start() is not called), "
3901 "it is possible that the function returns "
3902 "PJ_SUCCESS with -1 as device IDs.";
3903static char pjsua_set_snd_dev_doc[] =
3904 "int py_pjsua.set_snd_dev (int capture_dev, int playback_dev) "
3905 "Select or change sound device. Application may call this function "
3906 "at any time to replace current sound device.";
3907static char pjsua_set_null_snd_dev_doc[] =
3908 "int py_pjsua.set_null_snd_dev () "
3909 "Set pjsua to use null sound device. The null sound device only "
3910 "provides the timing needed by the conference bridge, and will not "
3911 "interract with any hardware.";
3912static char pjsua_set_no_snd_dev_doc[] =
3913 "py_pjsua.PJMedia_Port py_pjsua.set_no_snd_dev () "
3914 "Disconnect the main conference bridge from any sound devices, "
3915 "and let application connect the bridge to it's "
3916 "own sound device/master port.";
3917static char pjsua_set_ec_doc[] =
3918 "int py_pjsua.set_ec (int tail_ms, int options) "
3919 "Configure the echo canceller tail length of the sound port.";
3920static char pjsua_get_ec_tail_doc[] =
3921 "int py_pjsua.get_ec_tail () "
3922 "Get current echo canceller tail length.";
3923static char pjsua_enum_codecs_doc[] =
3924 "py_pjsua.Codec_Info[] py_pjsua.enum_codecs () "
3925 "Enum all supported codecs in the system.";
3926static char pjsua_codec_set_priority_doc[] =
3927 "int py_pjsua.codec_set_priority (string id, int priority) "
3928 "Change codec priority.";
3929static char pjsua_codec_get_param_doc[] =
3930 "py_pjsua.PJMedia_Codec_Param py_pjsua.codec_get_param (string id) "
3931 "Get codec parameters";
3932static char pjsua_codec_set_param_doc[] =
3933 "int py_pjsua.codec_set_param (string id, "
3934 "py_pjsua.PJMedia_Codec_Param param) "
3935 "Set codec parameters.";
3936
3937/* END OF LIB MEDIA */
3938
3939/* LIB CALL */
3940
3941/*
3942 * PyObj_pj_time_val
3943 * PJ Time Val
3944 */
3945typedef struct
3946{
3947 PyObject_HEAD
3948 /* Type-specific fields go here. */
3949 long sec;
3950 long msec;
3951
3952} PyObj_pj_time_val;
3953
3954
3955
3956/*
3957 * pj_time_val_members
3958 */
3959static PyMemberDef pj_time_val_members[] =
3960{
3961
3962 {
3963 "sec", T_INT,
3964 offsetof(PyObj_pj_time_val, sec), 0,
3965 "The seconds part of the time"
3966 },
3967 {
3968 "msec", T_INT,
3969 offsetof(PyObj_pj_time_val, sec), 0,
3970 "The milliseconds fraction of the time"
3971 },
3972
3973
3974 {NULL} /* Sentinel */
3975};
3976
3977
3978
3979
3980/*
3981 * PyTyp_pj_time_val
3982 */
3983static PyTypeObject PyTyp_pj_time_val =
3984{
3985 PyObject_HEAD_INIT(NULL)
3986 0, /*ob_size*/
3987 "py_pjsua.PJ_Time_Val", /*tp_name*/
3988 sizeof(PyObj_pj_time_val), /*tp_basicsize*/
3989 0, /*tp_itemsize*/
3990 0,/*tp_dealloc*/
3991 0, /*tp_print*/
3992 0, /*tp_getattr*/
3993 0, /*tp_setattr*/
3994 0, /*tp_compare*/
3995 0, /*tp_repr*/
3996 0, /*tp_as_number*/
3997 0, /*tp_as_sequence*/
3998 0, /*tp_as_mapping*/
3999 0, /*tp_hash */
4000 0, /*tp_call*/
4001 0, /*tp_str*/
4002 0, /*tp_getattro*/
4003 0, /*tp_setattro*/
4004 0, /*tp_as_buffer*/
4005 Py_TPFLAGS_DEFAULT, /*tp_flags*/
4006 "PJ Time Val objects", /* tp_doc */
4007 0, /* tp_traverse */
4008 0, /* tp_clear */
4009 0, /* tp_richcompare */
4010 0, /* tp_weaklistoffset */
4011 0, /* tp_iter */
4012 0, /* tp_iternext */
4013 0, /* tp_methods */
4014 pj_time_val_members, /* tp_members */
4015
4016
4017};
4018
4019/*
4020 * PyObj_pjsua_call_info
4021 * Call Info
4022 */
4023typedef struct
4024{
4025 PyObject_HEAD
4026 /* Type-specific fields go here. */
4027
4028 int id;
4029 int role;
4030 int acc_id;
4031 PyObject * local_info;
4032 PyObject * local_contact;
4033 PyObject * remote_info;
4034 PyObject * remote_contact;
4035 PyObject * call_id;
4036 int state;
4037 PyObject * state_text;
4038 int last_status;
4039 PyObject * last_status_text;
4040 int media_status;
4041 int media_dir;
4042 int conf_slot;
4043 PyObj_pj_time_val * connect_duration;
4044 PyObj_pj_time_val * total_duration;
4045 struct {
4046 char local_info[128];
4047 char local_contact[128];
4048 char remote_info[128];
4049 char remote_contact[128];
4050 char call_id[128];
4051 char last_status_text[128];
4052 } buf_;
4053
4054} PyObj_pjsua_call_info;
4055
4056
4057/*
4058 * call_info_dealloc
4059 * deletes a call_info from memory
4060 */
4061static void call_info_dealloc(PyObj_pjsua_call_info* self)
4062{
4063 Py_XDECREF(self->local_info);
4064 Py_XDECREF(self->local_contact);
4065 Py_XDECREF(self->remote_info);
4066 Py_XDECREF(self->remote_contact);
4067 Py_XDECREF(self->call_id);
4068 Py_XDECREF(self->state_text);
4069 Py_XDECREF(self->last_status_text);
4070 Py_XDECREF(self->connect_duration);
4071 Py_XDECREF(self->total_duration);
4072 self->ob_type->tp_free((PyObject*)self);
4073}
4074
4075
4076/*
4077 * call_info_new
4078 * constructor for call_info object
4079 */
4080static PyObject * call_info_new(PyTypeObject *type, PyObject *args,
4081 PyObject *kwds)
4082{
4083 PyObj_pjsua_call_info *self;
4084
4085 PJ_UNUSED_ARG(args);
4086 PJ_UNUSED_ARG(kwds);
4087
4088 self = (PyObj_pjsua_call_info *)type->tp_alloc(type, 0);
4089 if (self != NULL)
4090 {
4091 self->local_info = PyString_FromString("");
4092 if (self->local_info == NULL)
4093 {
4094 Py_DECREF(self);
4095 return NULL;
4096 }
4097 self->local_contact = PyString_FromString("");
4098 if (self->local_contact == NULL)
4099 {
4100 Py_DECREF(self);
4101 return NULL;
4102 }
4103 self->remote_info = PyString_FromString("");
4104 if (self->remote_info == NULL)
4105 {
4106 Py_DECREF(self);
4107 return NULL;
4108 }
4109 self->remote_contact = PyString_FromString("");
4110 if (self->remote_contact == NULL)
4111 {
4112 Py_DECREF(self);
4113 return NULL;
4114 }
4115 self->call_id = PyString_FromString("");
4116 if (self->call_id == NULL)
4117 {
4118 Py_DECREF(self);
4119 return NULL;
4120 }
4121 self->state_text = PyString_FromString("");
4122 if (self->state_text == NULL)
4123 {
4124 Py_DECREF(self);
4125 return NULL;
4126 }
4127 self->last_status_text = PyString_FromString("");
4128 if (self->last_status_text == NULL)
4129 {
4130 Py_DECREF(self);
4131 return NULL;
4132 }
4133 self->connect_duration = (PyObj_pj_time_val *)PyType_GenericNew
4134 (&PyTyp_pj_time_val,NULL,NULL);
4135 if (self->connect_duration == NULL)
4136 {
4137 Py_DECREF(self);
4138 return NULL;
4139 }
4140 self->total_duration = (PyObj_pj_time_val *)PyType_GenericNew
4141 (&PyTyp_pj_time_val,NULL,NULL);
4142 if (self->total_duration == NULL)
4143 {
4144 Py_DECREF(self);
4145 return NULL;
4146 }
4147 }
4148 return (PyObject *)self;
4149}
4150
4151/*
4152 * call_info_members
4153 */
4154static PyMemberDef call_info_members[] =
4155{
4156 {
4157 "id", T_INT,
4158 offsetof(PyObj_pjsua_call_info, id), 0,
4159 "Call identification"
4160 },
4161 {
4162 "role", T_INT,
4163 offsetof(PyObj_pjsua_call_info, role), 0,
4164 "Initial call role (UAC == caller)"
4165 },
4166 {
4167 "acc_id", T_INT,
4168 offsetof(PyObj_pjsua_call_info, acc_id), 0,
4169 "The account ID where this call belongs."
4170 },
4171 {
4172 "local_info", T_OBJECT_EX,
4173 offsetof(PyObj_pjsua_call_info, local_info), 0,
4174 "Local URI"
4175 },
4176 {
4177 "local_contact", T_OBJECT_EX,
4178 offsetof(PyObj_pjsua_call_info, local_contact), 0,
4179 "Local Contact"
4180 },
4181 {
4182 "remote_info", T_OBJECT_EX,
4183 offsetof(PyObj_pjsua_call_info, remote_info), 0,
4184 "Remote URI"
4185 },
4186 {
4187 "remote_contact", T_OBJECT_EX,
4188 offsetof(PyObj_pjsua_call_info, remote_contact), 0,
4189 "Remote Contact"
4190 },
4191 {
4192 "call_id", T_OBJECT_EX,
4193 offsetof(PyObj_pjsua_call_info, call_id), 0,
4194 "Dialog Call-ID string"
4195 },
4196 {
4197 "state", T_INT,
4198 offsetof(PyObj_pjsua_call_info, state), 0,
4199 "Call state"
4200 },
4201 {
4202 "state_text", T_OBJECT_EX,
4203 offsetof(PyObj_pjsua_call_info, state_text), 0,
4204 "Text describing the state "
4205 },
4206 {
4207 "last_status", T_INT,
4208 offsetof(PyObj_pjsua_call_info, last_status), 0,
4209 "Last status code heard, which can be used as cause code"
4210 },
4211 {
4212 "last_status_text", T_OBJECT_EX,
4213 offsetof(PyObj_pjsua_call_info, last_status_text), 0,
4214 "The reason phrase describing the status."
4215 },
4216 {
4217 "media_status", T_INT,
4218 offsetof(PyObj_pjsua_call_info, media_status), 0,
4219 "Call media status."
4220 },
4221 {
4222 "media_dir", T_INT,
4223 offsetof(PyObj_pjsua_call_info, media_dir), 0,
4224 "Media direction"
4225 },
4226 {
4227 "conf_slot", T_INT,
4228 offsetof(PyObj_pjsua_call_info, conf_slot), 0,
4229 "The conference port number for the call"
4230 },
4231 {
4232 "connect_duration", T_OBJECT_EX,
4233 offsetof(PyObj_pjsua_call_info, connect_duration), 0,
4234 "Up-to-date call connected duration(zero when call is not established)"
4235 },
4236 {
4237 "total_duration", T_OBJECT_EX,
4238 offsetof(PyObj_pjsua_call_info, total_duration), 0,
4239 "Total call duration, including set-up time"
4240 },
4241
4242 {NULL} /* Sentinel */
4243};
4244
4245
4246
4247
4248/*
4249 * PyTyp_pjsua_call_info
4250 */
4251static PyTypeObject PyTyp_pjsua_call_info =
4252{
4253 PyObject_HEAD_INIT(NULL)
4254 0, /*ob_size*/
4255 "py_pjsua.Call_Info", /*tp_name*/
4256 sizeof(PyObj_pjsua_call_info), /*tp_basicsize*/
4257 0, /*tp_itemsize*/
4258 (destructor)call_info_dealloc,/*tp_dealloc*/
4259 0, /*tp_print*/
4260 0, /*tp_getattr*/
4261 0, /*tp_setattr*/
4262 0, /*tp_compare*/
4263 0, /*tp_repr*/
4264 0, /*tp_as_number*/
4265 0, /*tp_as_sequence*/
4266 0, /*tp_as_mapping*/
4267 0, /*tp_hash */
4268 0, /*tp_call*/
4269 0, /*tp_str*/
4270 0, /*tp_getattro*/
4271 0, /*tp_setattro*/
4272 0, /*tp_as_buffer*/
4273 Py_TPFLAGS_DEFAULT, /*tp_flags*/
4274 "Call Info objects", /* tp_doc */
4275 0, /* tp_traverse */
4276 0, /* tp_clear */
4277 0, /* tp_richcompare */
4278 0, /* tp_weaklistoffset */
4279 0, /* tp_iter */
4280 0, /* tp_iternext */
4281 0, /* tp_methods */
4282 call_info_members, /* tp_members */
4283 0, /* tp_getset */
4284 0, /* tp_base */
4285 0, /* tp_dict */
4286 0, /* tp_descr_get */
4287 0, /* tp_descr_set */
4288 0, /* tp_dictoffset */
4289 0, /* tp_init */
4290 0, /* tp_alloc */
4291 call_info_new, /* tp_new */
4292
4293};
4294
4295/*
4296 * py_pjsua_call_get_max_count
4297 */
4298static PyObject *py_pjsua_call_get_max_count
4299(PyObject *pSelf, PyObject *pArgs)
4300{
4301 int count;
4302
4303 PJ_UNUSED_ARG(pSelf);
4304
4305 if (!PyArg_ParseTuple(pArgs, ""))
4306 {
4307 return NULL;
4308 }
4309
4310 count = pjsua_call_get_max_count();
4311
4312
4313 return Py_BuildValue("i", count);
4314}
4315
4316/*
4317 * py_pjsua_call_get_count
4318 */
4319static PyObject *py_pjsua_call_get_count
4320(PyObject *pSelf, PyObject *pArgs)
4321{
4322
4323 int count;
4324
4325 PJ_UNUSED_ARG(pSelf);
4326
4327 if (!PyArg_ParseTuple(pArgs, ""))
4328 {
4329 return NULL;
4330 }
4331
4332 count = pjsua_call_get_count();
4333
4334
4335 return Py_BuildValue("i", count);
4336}
4337
4338/*
4339 * py_pjsua_enum_calls
4340 */
4341static PyObject *py_pjsua_enum_calls(PyObject *pSelf, PyObject *pArgs)
4342{
4343 pj_status_t status;
4344 PyObject *list;
4345
4346 pjsua_transport_id id[PJSUA_MAX_CALLS];
4347 unsigned c, i;
4348
4349 PJ_UNUSED_ARG(pSelf);
4350
4351 if (!PyArg_ParseTuple(pArgs, ""))
4352 {
4353 return NULL;
4354 }
4355
4356 c = PJ_ARRAY_SIZE(id);
4357 status = pjsua_enum_calls(id, &c);
4358
4359 list = PyList_New(c);
4360 for (i = 0; i < c; i++)
4361 {
4362 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
4363 if (ret == -1)
4364 {
4365 return NULL;
4366 }
4367 }
4368
4369 return Py_BuildValue("O",list);
4370}
4371
4372/*
4373 * py_pjsua_call_make_call
4374 */
4375static PyObject *py_pjsua_call_make_call
4376(PyObject *pSelf, PyObject *pArgs)
4377{
4378 int status;
4379 int acc_id;
4380 pj_str_t dst_uri;
4381 PyObject * sd;
4382 unsigned options;
4383 pjsua_msg_data msg_data;
4384 PyObject * omdObj;
4385 PyObj_pjsua_msg_data * omd;
4386 int user_data;
4387 int call_id;
4388 pj_pool_t * pool;
4389
4390 PJ_UNUSED_ARG(pSelf);
4391
4392 if (!PyArg_ParseTuple
4393 (pArgs, "iOIiO", &acc_id, &sd, &options, &user_data, &omdObj))
4394 {
4395 return NULL;
4396 }
4397
4398 dst_uri.ptr = PyString_AsString(sd);
4399 dst_uri.slen = strlen(PyString_AsString(sd));
4400 if (omdObj != Py_None)
4401 {
4402 omd = (PyObj_pjsua_msg_data *)omdObj;
4403 msg_data.content_type.ptr = PyString_AsString(omd->content_type);
4404 msg_data.content_type.slen = strlen
4405 (PyString_AsString(omd->content_type));
4406 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
4407 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
4408 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
4409 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
4410 status = pjsua_call_make_call(acc_id, &dst_uri,
4411 options, (void*)user_data, &msg_data, &call_id);
4412 pj_pool_release(pool);
4413 } else {
4414
4415 status = pjsua_call_make_call(acc_id, &dst_uri,
4416 options, (void*)user_data, NULL, &call_id);
4417 }
4418
4419 return Py_BuildValue("ii",status, call_id);
4420
4421}
4422
4423/*
4424 * py_pjsua_call_is_active
4425 */
4426static PyObject *py_pjsua_call_is_active
4427(PyObject *pSelf, PyObject *pArgs)
4428{
4429 int call_id;
4430 int isActive;
4431
4432 PJ_UNUSED_ARG(pSelf);
4433
4434 if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4435 {
4436 return NULL;
4437 }
4438
4439 isActive = pjsua_call_is_active(call_id);
4440
4441
4442 return Py_BuildValue("i", isActive);
4443}
4444
4445/*
4446 * py_pjsua_call_has_media
4447 */
4448static PyObject *py_pjsua_call_has_media
4449(PyObject *pSelf, PyObject *pArgs)
4450{
4451 int call_id;
4452 int hasMedia;
4453
4454 PJ_UNUSED_ARG(pSelf);
4455
4456 if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4457 {
4458 return NULL;
4459 }
4460
4461 hasMedia = pjsua_call_has_media(call_id);
4462
4463
4464 return Py_BuildValue("i", hasMedia);
4465}
4466
4467/*
4468 * py_pjsua_call_get_conf_port
4469 */
4470static PyObject *py_pjsua_call_get_conf_port
4471(PyObject *pSelf, PyObject *pArgs)
4472{
4473 int call_id;
4474 int port_id;
4475
4476 PJ_UNUSED_ARG(pSelf);
4477
4478 if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4479 {
4480 return NULL;
4481 }
4482
4483 port_id = pjsua_call_get_conf_port(call_id);
4484
4485
4486 return Py_BuildValue("i", port_id);
4487}
4488
4489/*
4490 * py_pjsua_call_get_info
4491 */
4492static PyObject *py_pjsua_call_get_info
4493(PyObject *pSelf, PyObject *pArgs)
4494{
4495 int call_id;
4496 int status;
4497 PyObj_pjsua_call_info * oi;
4498 pjsua_call_info info;
4499
4500 PJ_UNUSED_ARG(pSelf);
4501
4502 if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4503 {
4504 return NULL;
4505 }
4506
4507
4508 status = pjsua_call_get_info(call_id, &info);
4509 if (status == PJ_SUCCESS)
4510 {
4511 oi = (PyObj_pjsua_call_info *)call_info_new(&PyTyp_pjsua_call_info, NULL, NULL);
4512 oi->acc_id = info.acc_id;
4513 pj_ansi_snprintf(oi->buf_.call_id, sizeof(oi->buf_.call_id),
4514 "%.*s", (int)info.call_id.slen, info.call_id.ptr);
4515 pj_ansi_snprintf(oi->buf_.last_status_text,
4516 sizeof(oi->buf_.last_status_text),
4517 "%.*s", (int)info.last_status_text.slen, info.last_status_text.ptr);
4518 pj_ansi_snprintf(oi->buf_.local_contact, sizeof(oi->buf_.local_contact),
4519 "%.*s", (int)info.local_contact.slen, info.local_contact.ptr);
4520 pj_ansi_snprintf(oi->buf_.local_info, sizeof(oi->buf_.local_info),
4521 "%.*s", (int)info.local_info.slen, info.local_info.ptr);
4522 pj_ansi_snprintf(oi->buf_.remote_contact,
4523 sizeof(oi->buf_.remote_contact),
4524 "%.*s", (int)info.remote_contact.slen, info.remote_contact.ptr);
4525 pj_ansi_snprintf(oi->buf_.remote_info, sizeof(oi->buf_.remote_info),
4526 "%.*s", (int)info.remote_info.slen, info.remote_info.ptr);
4527
4528 oi->call_id = PyString_FromStringAndSize(info.call_id.ptr,
4529 info.call_id.slen);
4530 oi->conf_slot = info.conf_slot;
4531 oi->connect_duration->sec = info.connect_duration.sec;
4532 oi->connect_duration->msec = info.connect_duration.msec;
4533 oi->total_duration->sec = info.total_duration.sec;
4534 oi->total_duration->msec = info.total_duration.msec;
4535 oi->id = info.id;
4536 oi->last_status = info.last_status;
4537 oi->last_status_text = PyString_FromStringAndSize(
4538 info.last_status_text.ptr, info.last_status_text.slen);
4539 oi->local_contact = PyString_FromStringAndSize(
4540 info.local_contact.ptr, info.local_contact.slen);
4541 oi->local_info = PyString_FromStringAndSize(
4542 info.local_info.ptr, info.local_info.slen);
4543 oi->remote_contact = PyString_FromStringAndSize(
4544 info.remote_contact.ptr, info.remote_contact.slen);
4545 oi->remote_info = PyString_FromStringAndSize(
4546 info.remote_info.ptr, info.remote_info.slen);
4547 oi->media_dir = info.media_dir;
4548 oi->media_status = info.media_status;
4549 oi->role = info.role;
4550 oi->state = info.state;
4551 oi->state_text = PyString_FromStringAndSize(
4552 info.state_text.ptr, info.state_text.slen);
4553
4554 return Py_BuildValue("O", oi);
4555 } else {
4556 Py_INCREF(Py_None);
4557 return Py_None;
4558 }
4559}
4560
4561/*
4562 * py_pjsua_call_set_user_data
4563 */
4564static PyObject *py_pjsua_call_set_user_data
4565(PyObject *pSelf, PyObject *pArgs)
4566{
4567 int call_id;
4568 int user_data;
4569 int status;
4570
4571 PJ_UNUSED_ARG(pSelf);
4572
4573 if (!PyArg_ParseTuple(pArgs, "ii", &call_id, &user_data))
4574 {
4575 return NULL;
4576 }
4577
4578 status = pjsua_call_set_user_data(call_id, (void*)user_data);
4579
4580
4581 return Py_BuildValue("i", status);
4582}
4583
4584/*
4585 * py_pjsua_call_get_user_data
4586 */
4587static PyObject *py_pjsua_call_get_user_data
4588(PyObject *pSelf, PyObject *pArgs)
4589{
4590 int call_id;
4591 void * user_data;
4592
4593 PJ_UNUSED_ARG(pSelf);
4594
4595 if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4596 {
4597 return NULL;
4598 }
4599
4600 user_data = pjsua_call_get_user_data(call_id);
4601
4602
4603 return Py_BuildValue("i", (int)user_data);
4604}
4605
4606/*
4607 * py_pjsua_call_answer
4608 */
4609static PyObject *py_pjsua_call_answer
4610(PyObject *pSelf, PyObject *pArgs)
4611{
4612 int status;
4613 int call_id;
4614 pj_str_t * reason, tmp_reason;
4615 PyObject * sr;
4616 unsigned code;
4617 pjsua_msg_data msg_data;
4618 PyObject * omdObj;
4619 PyObj_pjsua_msg_data * omd;
4620 pj_pool_t * pool;
4621
4622 PJ_UNUSED_ARG(pSelf);
4623
4624 if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omdObj))
4625 {
4626 return NULL;
4627 }
4628 if (sr == Py_None)
4629 {
4630 reason = NULL;
4631 } else {
4632 reason = &tmp_reason;
4633 tmp_reason.ptr = PyString_AsString(sr);
4634 tmp_reason.slen = strlen(PyString_AsString(sr));
4635 }
4636 if (omdObj != Py_None)
4637 {
4638 omd = (PyObj_pjsua_msg_data *)omdObj;
4639 msg_data.content_type.ptr = PyString_AsString(omd->content_type);
4640 msg_data.content_type.slen = strlen
4641 (PyString_AsString(omd->content_type));
4642 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
4643 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
4644 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
4645 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
4646
4647 status = pjsua_call_answer(call_id, code, reason, &msg_data);
4648
4649 pj_pool_release(pool);
4650 } else {
4651
4652 status = pjsua_call_answer(call_id, code, reason, NULL);
4653
4654 }
4655
4656 return Py_BuildValue("i",status);
4657}
4658
4659/*
4660 * py_pjsua_call_hangup
4661 */
4662static PyObject *py_pjsua_call_hangup
4663(PyObject *pSelf, PyObject *pArgs)
4664{
4665 int status;
4666 int call_id;
4667 pj_str_t * reason, tmp_reason;
4668 PyObject * sr;
4669 unsigned code;
4670 pjsua_msg_data msg_data;
4671 PyObject * omdObj;
4672 PyObj_pjsua_msg_data * omd;
4673 pj_pool_t * pool = NULL;
4674
4675 PJ_UNUSED_ARG(pSelf);
4676
4677 if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omdObj))
4678 {
4679 return NULL;
4680 }
4681 if (sr == Py_None)
4682 {
4683 reason = NULL;
4684 } else {
4685 reason = &tmp_reason;
4686 tmp_reason.ptr = PyString_AsString(sr);
4687 tmp_reason.slen = strlen(PyString_AsString(sr));
4688 }
4689 if (omdObj != Py_None)
4690 {
4691 omd = (PyObj_pjsua_msg_data *)omdObj;
4692 msg_data.content_type.ptr = PyString_AsString(omd->content_type);
4693 msg_data.content_type.slen = strlen
4694 (PyString_AsString(omd->content_type));
4695 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
4696 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
4697 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
4698 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
4699 status = pjsua_call_hangup(call_id, code, reason, &msg_data);
4700 pj_pool_release(pool);
4701 } else {
4702 status = pjsua_call_hangup(call_id, code, reason, NULL);
4703 }
4704
4705 return Py_BuildValue("i",status);
4706}
4707
4708/*
4709 * py_pjsua_call_set_hold
4710 */
4711static PyObject *py_pjsua_call_set_hold
4712(PyObject *pSelf, PyObject *pArgs)
4713{
4714 int status;
4715 int call_id;
4716 pjsua_msg_data msg_data;
4717 PyObject * omdObj;
4718 PyObj_pjsua_msg_data * omd;
4719 pj_pool_t * pool;
4720
4721 PJ_UNUSED_ARG(pSelf);
4722
4723 if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omdObj))
4724 {
4725 return NULL;
4726 }
4727
4728 if (omdObj != Py_None)
4729 {
4730 omd = (PyObj_pjsua_msg_data *)omdObj;
4731 msg_data.content_type.ptr = PyString_AsString(omd->content_type);
4732 msg_data.content_type.slen = strlen
4733 (PyString_AsString(omd->content_type));
4734 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
4735 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
4736 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
4737 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
4738 status = pjsua_call_set_hold(call_id, &msg_data);
4739 pj_pool_release(pool);
4740 } else {
4741 status = pjsua_call_set_hold(call_id, NULL);
4742 }
4743 return Py_BuildValue("i",status);
4744}
4745
4746/*
4747 * py_pjsua_call_reinvite
4748 */
4749static PyObject *py_pjsua_call_reinvite
4750(PyObject *pSelf, PyObject *pArgs)
4751{
4752 int status;
4753 int call_id;
4754 int unhold;
4755 pjsua_msg_data msg_data;
4756 PyObject * omdObj;
4757 PyObj_pjsua_msg_data * omd;
4758 pj_pool_t * pool;
4759
4760 PJ_UNUSED_ARG(pSelf);
4761
4762 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omdObj))
4763 {
4764 return NULL;
4765 }
4766
4767 if (omdObj != Py_None)
4768 {
4769 omd = (PyObj_pjsua_msg_data *)omdObj;
4770 msg_data.content_type.ptr = PyString_AsString(omd->content_type);
4771 msg_data.content_type.slen = strlen
4772 (PyString_AsString(omd->content_type));
4773 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
4774 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
4775 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
4776 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
4777 status = pjsua_call_reinvite(call_id, unhold, &msg_data);
4778 pj_pool_release(pool);
4779 } else {
4780 status = pjsua_call_reinvite(call_id, unhold, NULL);
4781 }
4782 return Py_BuildValue("i",status);
4783}
4784
4785/*
4786 * py_pjsua_call_xfer
4787 */
4788static PyObject *py_pjsua_call_xfer
4789(PyObject *pSelf, PyObject *pArgs)
4790{
4791 int status;
4792 int call_id;
4793 pj_str_t dest;
4794 PyObject * sd;
4795 pjsua_msg_data msg_data;
4796 PyObject * omdObj;
4797 PyObj_pjsua_msg_data * omd;
4798 pj_pool_t * pool;
4799
4800 PJ_UNUSED_ARG(pSelf);
4801
4802 if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &sd, &omdObj))
4803 {
4804 return NULL;
4805 }
4806
4807 dest.ptr = PyString_AsString(sd);
4808 dest.slen = strlen(PyString_AsString(sd));
4809
4810 if (omdObj != Py_None)
4811 {
4812 omd = (PyObj_pjsua_msg_data *)omdObj;
4813 msg_data.content_type.ptr = PyString_AsString(omd->content_type);
4814 msg_data.content_type.slen = strlen
4815 (PyString_AsString(omd->content_type));
4816 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
4817 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
4818 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
4819 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
4820 status = pjsua_call_xfer(call_id, &dest, &msg_data);
4821 pj_pool_release(pool);
4822 } else {
4823 status = pjsua_call_xfer(call_id, &dest, NULL);
4824 }
4825 return Py_BuildValue("i",status);
4826}
4827
4828/*
4829 * py_pjsua_call_xfer_replaces
4830 */
4831static PyObject *py_pjsua_call_xfer_replaces
4832(PyObject *pSelf, PyObject *pArgs)
4833{
4834 int status;
4835 int call_id;
4836 int dest_call_id;
4837 unsigned options;
4838 pjsua_msg_data msg_data;
4839 PyObject * omdObj;
4840 PyObj_pjsua_msg_data * omd;
4841 pj_pool_t * pool;
4842
4843 PJ_UNUSED_ARG(pSelf);
4844
4845 if (!PyArg_ParseTuple
4846 (pArgs, "iiIO", &call_id, &dest_call_id, &options, &omdObj))
4847 {
4848 return NULL;
4849 }
4850
4851 if (omdObj != Py_None)
4852 {
4853 omd = (PyObj_pjsua_msg_data *)omdObj;
4854 msg_data.content_type.ptr = PyString_AsString(omd->content_type);
4855 msg_data.content_type.slen = strlen
4856 (PyString_AsString(omd->content_type));
4857 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
4858 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
4859 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
4860 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
4861 status = pjsua_call_xfer_replaces
4862 (call_id, dest_call_id, options, &msg_data);
4863 pj_pool_release(pool);
4864 } else {
4865 status = pjsua_call_xfer_replaces(call_id, dest_call_id,options, NULL);
4866 }
4867 return Py_BuildValue("i",status);
4868}
4869
4870/*
4871 * py_pjsua_call_dial_dtmf
4872 */
4873static PyObject *py_pjsua_call_dial_dtmf
4874(PyObject *pSelf, PyObject *pArgs)
4875{
4876 int call_id;
4877 PyObject * sd;
4878 pj_str_t digits;
4879 int status;
4880
4881 PJ_UNUSED_ARG(pSelf);
4882
4883 if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &sd))
4884 {
4885 return NULL;
4886 }
4887 digits.ptr = PyString_AsString(sd);
4888 digits.slen = strlen(PyString_AsString(sd));
4889 status = pjsua_call_dial_dtmf(call_id, &digits);
4890
4891 return Py_BuildValue("i", status);
4892}
4893
4894/*
4895 * py_pjsua_call_send_im
4896 */
4897static PyObject *py_pjsua_call_send_im
4898(PyObject *pSelf, PyObject *pArgs)
4899{
4900 int status;
4901 int call_id;
4902 pj_str_t content;
4903 pj_str_t * mime_type, tmp_mime_type;
4904 PyObject * sm;
4905 PyObject * sc;
4906 pjsua_msg_data msg_data;
4907 PyObject * omdObj;
4908 PyObj_pjsua_msg_data * omd;
4909 int user_data;
4910 pj_pool_t * pool;
4911
4912 PJ_UNUSED_ARG(pSelf);
4913
4914 if (!PyArg_ParseTuple
4915 (pArgs, "iOOOi", &call_id, &sm, &sc, &omdObj, &user_data))
4916 {
4917 return NULL;
4918 }
4919 if (sm == Py_None)
4920 {
4921 mime_type = NULL;
4922 } else {
4923 mime_type = &tmp_mime_type;
4924 tmp_mime_type.ptr = PyString_AsString(sm);
4925 tmp_mime_type.slen = strlen(PyString_AsString(sm));
4926 }
4927 content.ptr = PyString_AsString(sc);
4928 content.slen = strlen(PyString_AsString(sc));
4929
4930 if (omdObj != Py_None)
4931 {
4932 omd = (PyObj_pjsua_msg_data *)omdObj;
4933 msg_data.content_type.ptr = PyString_AsString(omd->content_type);
4934 msg_data.content_type.slen = strlen
4935 (PyString_AsString(omd->content_type));
4936 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
4937 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
4938 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
4939 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
4940 status = pjsua_call_send_im
4941 (call_id, mime_type, &content, &msg_data, (void *)user_data);
4942 pj_pool_release(pool);
4943 } else {
4944 status = pjsua_call_send_im
4945 (call_id, mime_type, &content, NULL, (void *)user_data);
4946 }
4947
4948 return Py_BuildValue("i",status);
4949}
4950
4951/*
4952 * py_pjsua_call_send_typing_ind
4953 */
4954static PyObject *py_pjsua_call_send_typing_ind
4955(PyObject *pSelf, PyObject *pArgs)
4956{
4957 int status;
4958 int call_id;
4959 int is_typing;
4960 pjsua_msg_data msg_data;
4961 PyObject * omdObj;
4962 PyObj_pjsua_msg_data * omd;
4963 pj_pool_t * pool;
4964
4965 PJ_UNUSED_ARG(pSelf);
4966
4967 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omdObj))
4968 {
4969 return NULL;
4970 }
4971
4972 if (omdObj != Py_None)
4973 {
4974 omd = (PyObj_pjsua_msg_data *)omdObj;
4975 msg_data.content_type.ptr = PyString_AsString(omd->content_type);
4976 msg_data.content_type.slen = strlen
4977 (PyString_AsString(omd->content_type));
4978 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body);
4979 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body));
4980 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE);
4981 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list);
4982 status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data);
4983 pj_pool_release(pool);
4984 } else {
4985 status = pjsua_call_send_typing_ind(call_id, is_typing, NULL);
4986 }
4987 return Py_BuildValue("i",status);
4988}
4989
4990/*
4991 * py_pjsua_call_hangup_all
4992 */
4993static PyObject *py_pjsua_call_hangup_all
4994(PyObject *pSelf, PyObject *pArgs)
4995{
4996
4997 PJ_UNUSED_ARG(pSelf);
4998
4999 if (!PyArg_ParseTuple(pArgs, ""))
5000 {
5001 return NULL;
5002 }
5003
5004 pjsua_call_hangup_all();
5005
5006 Py_INCREF(Py_None);
5007 return Py_None;
5008}
5009
5010/*
5011 * py_pjsua_call_dump
5012 */
5013static PyObject *py_pjsua_call_dump
5014(PyObject *pSelf, PyObject *pArgs)
5015{
5016 int call_id;
5017 int with_media;
5018 PyObject * sb;
5019 PyObject * si;
5020 char * buffer;
5021 char * indent;
5022 unsigned maxlen;
5023 int status;
5024
5025 PJ_UNUSED_ARG(pSelf);
5026
5027 if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media, &maxlen, &si))
5028 {
5029 return NULL;
5030 }
5031 buffer = (char *) malloc (maxlen * sizeof(char));
5032 indent = PyString_AsString(si);
5033
5034 status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent);
5035 sb = PyString_FromStringAndSize(buffer, maxlen);
5036 free(buffer);
5037 return Py_BuildValue("O", sb);
5038}
5039
5040
5041/*
5042 * py_pjsua_dump
5043 * Dump application states.
5044 */
5045static PyObject *py_pjsua_dump(PyObject *pSelf, PyObject *pArgs)
5046{
5047 unsigned old_decor;
5048 char buf[1024];
5049 int detail;
5050
5051 PJ_UNUSED_ARG(pSelf);
5052
5053 if (!PyArg_ParseTuple(pArgs, "i", &detail))
5054 {
5055 return NULL;
5056 }
5057
5058 PJ_LOG(3,(THIS_FILE, "Start dumping application states:"));
5059
5060 old_decor = pj_log_get_decor();
5061 pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR));
5062
5063 if (detail)
5064 pj_dump_config();
5065
5066 pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail);
5067 pjmedia_endpt_dump(pjsua_get_pjmedia_endpt());
5068 pjsip_tsx_layer_dump(detail);
5069 pjsip_ua_dump(detail);
5070
5071
5072 /* Dump all invite sessions: */
5073 PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:"));
5074
5075 if (pjsua_call_get_count() == 0) {
5076
5077 PJ_LOG(3,(THIS_FILE, " - no sessions -"));
5078
5079 } else {
5080 unsigned i, max;
5081
5082 max = pjsua_call_get_max_count();
5083 for (i=0; i<max; ++i) {
5084 if (pjsua_call_is_active(i)) {
5085 pjsua_call_dump(i, detail, buf, sizeof(buf), " ");
5086 PJ_LOG(3,(THIS_FILE, "%s", buf));
5087 }
5088 }
5089 }
5090
5091 /* Dump presence status */
5092 pjsua_pres_dump(detail);
5093
5094 pj_log_set_decor(old_decor);
5095 PJ_LOG(3,(THIS_FILE, "Dump complete"));
5096
5097 Py_INCREF(Py_None);
5098 return Py_None;
5099}
5100
5101
5102static char pjsua_call_get_max_count_doc[] =
5103 "int py_pjsua.call_get_max_count () "
5104 "Get maximum number of calls configured in pjsua.";
5105static char pjsua_call_get_count_doc[] =
5106 "int py_pjsua.call_get_count () "
5107 "Get number of currently active calls.";
5108static char pjsua_enum_calls_doc[] =
5109 "int[] py_pjsua.enum_calls () "
5110 "Get maximum number of calls configured in pjsua.";
5111static char pjsua_call_make_call_doc[] =
5112 "int,int py_pjsua.call_make_call (int acc_id, string dst_uri, int options,"
5113 "int user_data, py_pjsua.Msg_Data msg_data) "
5114 "Make outgoing call to the specified URI using the specified account.";
5115static char pjsua_call_is_active_doc[] =
5116 "int py_pjsua.call_is_active (int call_id) "
5117 "Check if the specified call has active INVITE session and the INVITE "
5118 "session has not been disconnected.";
5119static char pjsua_call_has_media_doc[] =
5120 "int py_pjsua.call_has_media (int call_id) "
5121 "Check if call has an active media session.";
5122static char pjsua_call_get_conf_port_doc[] =
5123 "int py_pjsua.call_get_conf_port (int call_id) "
5124 "Get the conference port identification associated with the call.";
5125static char pjsua_call_get_info_doc[] =
5126 "py_pjsua.Call_Info py_pjsua.call_get_info (int call_id) "
5127 "Obtain detail information about the specified call.";
5128static char pjsua_call_set_user_data_doc[] =
5129 "int py_pjsua.call_set_user_data (int call_id, int user_data) "
5130 "Attach application specific data to the call.";
5131static char pjsua_call_get_user_data_doc[] =
5132 "int py_pjsua.call_get_user_data (int call_id) "
5133 "Get user data attached to the call.";
5134static char pjsua_call_answer_doc[] =
5135 "int py_pjsua.call_answer (int call_id, int code, string reason, "
5136 "py_pjsua.Msg_Data msg_data) "
5137 "Send response to incoming INVITE request.";
5138static char pjsua_call_hangup_doc[] =
5139 "int py_pjsua.call_hangup (int call_id, int code, string reason, "
5140 "py_pjsua.Msg_Data msg_data) "
5141 "Hangup call by using method that is appropriate according "
5142 "to the call state.";
5143static char pjsua_call_set_hold_doc[] =
5144 "int py_pjsua.call_set_hold (int call_id, py_pjsua.Msg_Data msg_data) "
5145 "Put the specified call on hold.";
5146static char pjsua_call_reinvite_doc[] =
5147 "int py_pjsua.call_reinvite (int call_id, int unhold, "
5148 "py_pjsua.Msg_Data msg_data) "
5149 "Send re-INVITE (to release hold).";
5150static char pjsua_call_xfer_doc[] =
5151 "int py_pjsua.call_xfer (int call_id, string dest, "
5152 "py_pjsua.Msg_Data msg_data) "
5153 "Initiate call transfer to the specified address. "
5154 "This function will send REFER request to instruct remote call party "
5155 "to initiate a new INVITE session to the specified destination/target.";
5156static char pjsua_call_xfer_replaces_doc[] =
5157 "int py_pjsua.call_xfer_replaces (int call_id, int dest_call_id, "
5158 "int options, py_pjsua.Msg_Data msg_data) "
5159 "Initiate attended call transfer. This function will send REFER request "
5160 "to instruct remote call party to initiate new INVITE session to the URL "
5161 "of dest_call_id. The party at dest_call_id then should 'replace' the call"
5162 "with us with the new call from the REFER recipient.";
5163static char pjsua_call_dial_dtmf_doc[] =
5164 "int py_pjsua.call_dial_dtmf (int call_id, string digits) "
5165 "Send DTMF digits to remote using RFC 2833 payload formats.";
5166static char pjsua_call_send_im_doc[] =
5167 "int py_pjsua.call_send_im (int call_id, string mime_type, string content,"
5168 "py_pjsua.Msg_Data msg_data, int user_data) "
5169 "Send instant messaging inside INVITE session.";
5170static char pjsua_call_send_typing_ind_doc[] =
5171 "int py_pjsua.call_send_typing_ind (int call_id, int is_typing, "
5172 "py_pjsua.Msg_Data msg_data) "
5173 "Send IM typing indication inside INVITE session.";
5174static char pjsua_call_hangup_all_doc[] =
5175 "void py_pjsua.call_hangup_all () "
5176 "Terminate all calls.";
5177static char pjsua_call_dump_doc[] =
5178 "int py_pjsua.call_dump (int call_id, int with_media, int maxlen, "
5179 "string indent) "
5180 "Dump call and media statistics to string.";
5181
5182/* END OF LIB CALL */
5183
5184/*
5185 * Map of function names to functions
5186 */
5187static PyMethodDef py_pjsua_methods[] =
5188{
5189 {
5190 "thread_register", py_pjsua_thread_register, METH_VARARGS,
5191 pjsua_thread_register_doc
5192 },
5193 {
5194 "perror", py_pjsua_perror, METH_VARARGS, pjsua_perror_doc
5195 },
5196 {
5197 "create", py_pjsua_create, METH_VARARGS, pjsua_create_doc
5198 },
5199 {
5200 "init", py_pjsua_init, METH_VARARGS, pjsua_init_doc
5201 },
5202 {
5203 "start", py_pjsua_start, METH_VARARGS, pjsua_start_doc
5204 },
5205 {
5206 "destroy", py_pjsua_destroy, METH_VARARGS, pjsua_destroy_doc
5207 },
5208 {
5209 "handle_events", py_pjsua_handle_events, METH_VARARGS,
5210 pjsua_handle_events_doc
5211 },
5212 {
5213 "verify_sip_url", py_pjsua_verify_sip_url, METH_VARARGS,
5214 pjsua_verify_sip_url_doc
5215 },
5216 {
5217 "pool_create", py_pjsua_pool_create, METH_VARARGS,
5218 pjsua_pool_create_doc
5219 },
5220 {
5221 "get_pjsip_endpt", py_pjsua_get_pjsip_endpt, METH_VARARGS,
5222 pjsua_get_pjsip_endpt_doc
5223 },
5224 {
5225 "get_pjmedia_endpt", py_pjsua_get_pjmedia_endpt, METH_VARARGS,
5226 pjsua_get_pjmedia_endpt_doc
5227 },
5228 {
5229 "get_pool_factory", py_pjsua_get_pool_factory, METH_VARARGS,
5230 pjsua_get_pool_factory_doc
5231 },
5232 {
5233 "reconfigure_logging", py_pjsua_reconfigure_logging, METH_VARARGS,
5234 pjsua_reconfigure_logging_doc
5235 },
5236 {
5237 "logging_config_default", py_pjsua_logging_config_default,
5238 METH_VARARGS, pjsua_logging_config_default_doc
5239 },
5240 {
5241 "config_default", py_pjsua_config_default, METH_VARARGS,
5242 pjsua_config_default_doc
5243 },
5244 {
5245 "media_config_default", py_pjsua_media_config_default, METH_VARARGS,
5246 pjsua_media_config_default_doc
5247 },
5248
5249
5250 {
5251 "msg_data_init", py_pjsua_msg_data_init, METH_VARARGS,
5252 pjsua_msg_data_init_doc
5253 },
5254 {
5255 "transport_config_default", py_pjsua_transport_config_default,
5256 METH_VARARGS,pjsua_transport_config_default_doc
5257 },
5258 {
5259 "transport_create", py_pjsua_transport_create, METH_VARARGS,
5260 pjsua_transport_create_doc
5261 },
5262 {
5263 "transport_enum_transports", py_pjsua_enum_transports, METH_VARARGS,
5264 pjsua_enum_transports_doc
5265 },
5266 {
5267 "transport_get_info", py_pjsua_transport_get_info, METH_VARARGS,
5268 pjsua_transport_get_info_doc
5269 },
5270 {
5271 "transport_set_enable", py_pjsua_transport_set_enable, METH_VARARGS,
5272 pjsua_transport_set_enable_doc
5273 },
5274 {
5275 "transport_close", py_pjsua_transport_close, METH_VARARGS,
5276 pjsua_transport_close_doc
5277 },
5278 {
5279 "acc_config_default", py_pjsua_acc_config_default, METH_VARARGS,
5280 pjsua_acc_config_default_doc
5281 },
5282 {
5283 "acc_get_count", py_pjsua_acc_get_count, METH_VARARGS,
5284 pjsua_acc_get_count_doc
5285 },
5286 {
5287 "acc_is_valid", py_pjsua_acc_is_valid, METH_VARARGS,
5288 pjsua_acc_is_valid_doc
5289 },
5290 {
5291 "acc_set_default", py_pjsua_acc_set_default, METH_VARARGS,
5292 pjsua_acc_set_default_doc
5293 },
5294 {
5295 "acc_get_default", py_pjsua_acc_get_default, METH_VARARGS,
5296 pjsua_acc_get_default_doc
5297 },
5298 {
5299 "acc_add", py_pjsua_acc_add, METH_VARARGS,
5300 pjsua_acc_add_doc
5301 },
5302 {
5303 "acc_add_local", py_pjsua_acc_add_local, METH_VARARGS,
5304 pjsua_acc_add_local_doc
5305 },
5306 {
5307 "acc_del", py_pjsua_acc_del, METH_VARARGS,
5308 pjsua_acc_del_doc
5309 },
5310 {
5311 "acc_modify", py_pjsua_acc_modify, METH_VARARGS,
5312 pjsua_acc_modify_doc
5313 },
5314 {
5315 "acc_set_online_status", py_pjsua_acc_set_online_status, METH_VARARGS,
5316 pjsua_acc_set_online_status_doc
5317 },
5318 {
5319 "acc_set_online_status2", py_pjsua_acc_set_online_status2, METH_VARARGS,
5320 pjsua_acc_set_online_status2_doc
5321 },
5322 {
5323 "acc_set_registration", py_pjsua_acc_set_registration, METH_VARARGS,
5324 pjsua_acc_set_registration_doc
5325 },
5326 {
5327 "acc_get_info", py_pjsua_acc_get_info, METH_VARARGS,
5328 pjsua_acc_get_info_doc
5329 },
5330 {
5331 "enum_accs", py_pjsua_enum_accs, METH_VARARGS,
5332 pjsua_enum_accs_doc
5333 },
5334 {
5335 "acc_enum_info", py_pjsua_acc_enum_info, METH_VARARGS,
5336 pjsua_acc_enum_info_doc
5337 },
5338 {
5339 "acc_find_for_outgoing", py_pjsua_acc_find_for_outgoing, METH_VARARGS,
5340 pjsua_acc_find_for_outgoing_doc
5341 },
5342 {
5343 "acc_find_for_incoming", py_pjsua_acc_find_for_incoming, METH_VARARGS,
5344 pjsua_acc_find_for_incoming_doc
5345 },
5346 {
5347 "acc_create_uac_contact", py_pjsua_acc_create_uac_contact, METH_VARARGS,
5348 pjsua_acc_create_uac_contact_doc
5349 },
5350 {
5351 "acc_create_uas_contact", py_pjsua_acc_create_uas_contact, METH_VARARGS,
5352 pjsua_acc_create_uas_contact_doc
5353 },
5354 {
5355 "buddy_config_default", py_pjsua_buddy_config_default, METH_VARARGS,
5356 pjsua_buddy_config_default_doc
5357 },
5358 {
5359 "get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS,
5360 pjsua_get_buddy_count_doc
5361 },
5362 {
5363 "buddy_is_valid", py_pjsua_buddy_is_valid, METH_VARARGS,
5364 pjsua_buddy_is_valid_doc
5365 },
5366 {
5367 "enum_buddies", py_pjsua_enum_buddies, METH_VARARGS,
5368 pjsua_enum_buddies_doc
5369 },
5370 {
5371 "buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS,
5372 pjsua_buddy_get_info_doc
5373 },
5374 {
5375 "buddy_add", py_pjsua_buddy_add, METH_VARARGS,
5376 pjsua_buddy_add_doc
5377 },
5378 {
5379 "buddy_del", py_pjsua_buddy_del, METH_VARARGS,
5380 pjsua_buddy_del_doc
5381 },
5382 {
5383 "buddy_subscribe_pres", py_pjsua_buddy_subscribe_pres, METH_VARARGS,
5384 pjsua_buddy_subscribe_pres_doc
5385 },
5386 {
5387 "pres_dump", py_pjsua_pres_dump, METH_VARARGS,
5388 pjsua_pres_dump_doc
5389 },
5390 {
5391 "im_send", py_pjsua_im_send, METH_VARARGS,
5392 pjsua_im_send_doc
5393 },
5394 {
5395 "im_typing", py_pjsua_im_typing, METH_VARARGS,
5396 pjsua_im_typing_doc
5397 },
5398 {
5399 "conf_get_max_ports", py_pjsua_conf_get_max_ports, METH_VARARGS,
5400 pjsua_conf_get_max_ports_doc
5401 },
5402 {
5403 "conf_get_active_ports", py_pjsua_conf_get_active_ports, METH_VARARGS,
5404 pjsua_conf_get_active_ports_doc
5405 },
5406 {
5407 "enum_conf_ports", py_pjsua_enum_conf_ports, METH_VARARGS,
5408 pjsua_enum_conf_ports_doc
5409 },
5410 {
5411 "conf_get_port_info", py_pjsua_conf_get_port_info, METH_VARARGS,
5412 pjsua_conf_get_port_info_doc
5413 },
5414 {
5415 "conf_add_port", py_pjsua_conf_add_port, METH_VARARGS,
5416 pjsua_conf_add_port_doc
5417 },
5418 {
5419 "conf_remove_port", py_pjsua_conf_remove_port, METH_VARARGS,
5420 pjsua_conf_remove_port_doc
5421 },
5422 {
5423 "conf_connect", py_pjsua_conf_connect, METH_VARARGS,
5424 pjsua_conf_connect_doc
5425 },
5426 {
5427 "conf_disconnect", py_pjsua_conf_disconnect, METH_VARARGS,
5428 pjsua_conf_disconnect_doc
5429 },
5430 {
5431 "player_create", py_pjsua_player_create, METH_VARARGS,
5432 pjsua_player_create_doc
5433 },
5434 {
5435 "player_get_conf_port", py_pjsua_player_get_conf_port, METH_VARARGS,
5436 pjsua_player_get_conf_port_doc
5437 },
5438 {
5439 "player_set_pos", py_pjsua_player_set_pos, METH_VARARGS,
5440 pjsua_player_set_pos_doc
5441 },
5442 {
5443 "player_destroy", py_pjsua_player_destroy, METH_VARARGS,
5444 pjsua_player_destroy_doc
5445 },
5446 {
5447 "recorder_create", py_pjsua_recorder_create, METH_VARARGS,
5448 pjsua_recorder_create_doc
5449 },
5450 {
5451 "recorder_get_conf_port", py_pjsua_recorder_get_conf_port, METH_VARARGS,
5452 pjsua_recorder_get_conf_port_doc
5453 },
5454 {
5455 "recorder_destroy", py_pjsua_recorder_destroy, METH_VARARGS,
5456 pjsua_recorder_destroy_doc
5457 },
5458 {
5459 "enum_snd_devs", py_pjsua_enum_snd_devs, METH_VARARGS,
5460 pjsua_enum_snd_devs_doc
5461 },
5462 {
5463 "get_snd_dev", py_pjsua_get_snd_dev, METH_VARARGS,
5464 pjsua_get_snd_dev_doc
5465 },
5466 {
5467 "set_snd_dev", py_pjsua_set_snd_dev, METH_VARARGS,
5468 pjsua_set_snd_dev_doc
5469 },
5470 {
5471 "set_null_snd_dev", py_pjsua_set_null_snd_dev, METH_VARARGS,
5472 pjsua_set_null_snd_dev_doc
5473 },
5474 {
5475 "set_no_snd_dev", py_pjsua_set_no_snd_dev, METH_VARARGS,
5476 pjsua_set_no_snd_dev_doc
5477 },
5478 {
5479 "set_ec", py_pjsua_set_ec, METH_VARARGS,
5480 pjsua_set_ec_doc
5481 },
5482 {
5483 "get_ec_tail", py_pjsua_get_ec_tail, METH_VARARGS,
5484 pjsua_get_ec_tail_doc
5485 },
5486 {
5487 "enum_codecs", py_pjsua_enum_codecs, METH_VARARGS,
5488 pjsua_enum_codecs_doc
5489 },
5490 {
5491 "codec_set_priority", py_pjsua_codec_set_priority, METH_VARARGS,
5492 pjsua_codec_set_priority_doc
5493 },
5494 {
5495 "codec_get_param", py_pjsua_codec_get_param, METH_VARARGS,
5496 pjsua_codec_get_param_doc
5497 },
5498 {
5499 "codec_set_param", py_pjsua_codec_set_param, METH_VARARGS,
5500 pjsua_codec_set_param_doc
5501 },
5502 {
5503 "call_get_max_count", py_pjsua_call_get_max_count, METH_VARARGS,
5504 pjsua_call_get_max_count_doc
5505 },
5506 {
5507 "call_get_count", py_pjsua_call_get_count, METH_VARARGS,
5508 pjsua_call_get_count_doc
5509 },
5510 {
5511 "enum_calls", py_pjsua_enum_calls, METH_VARARGS,
5512 pjsua_enum_calls_doc
5513 },
5514 {
5515 "call_make_call", py_pjsua_call_make_call, METH_VARARGS,
5516 pjsua_call_make_call_doc
5517 },
5518 {
5519 "call_is_active", py_pjsua_call_is_active, METH_VARARGS,
5520 pjsua_call_is_active_doc
5521 },
5522 {
5523 "call_has_media", py_pjsua_call_has_media, METH_VARARGS,
5524 pjsua_call_has_media_doc
5525 },
5526 {
5527 "call_get_conf_port", py_pjsua_call_get_conf_port, METH_VARARGS,
5528 pjsua_call_get_conf_port_doc
5529 },
5530 {
5531 "call_get_info", py_pjsua_call_get_info, METH_VARARGS,
5532 pjsua_call_get_info_doc
5533 },
5534 {
5535 "call_set_user_data", py_pjsua_call_set_user_data, METH_VARARGS,
5536 pjsua_call_set_user_data_doc
5537 },
5538 {
5539 "call_get_user_data", py_pjsua_call_get_user_data, METH_VARARGS,
5540 pjsua_call_get_user_data_doc
5541 },
5542 {
5543 "call_answer", py_pjsua_call_answer, METH_VARARGS,
5544 pjsua_call_answer_doc
5545 },
5546 {
5547 "call_hangup", py_pjsua_call_hangup, METH_VARARGS,
5548 pjsua_call_hangup_doc
5549 },
5550 {
5551 "call_set_hold", py_pjsua_call_set_hold, METH_VARARGS,
5552 pjsua_call_set_hold_doc
5553 },
5554 {
5555 "call_reinvite", py_pjsua_call_reinvite, METH_VARARGS,
5556 pjsua_call_reinvite_doc
5557 },
5558 {
5559 "call_xfer", py_pjsua_call_xfer, METH_VARARGS,
5560 pjsua_call_xfer_doc
5561 },
5562 {
5563 "call_xfer_replaces", py_pjsua_call_xfer_replaces, METH_VARARGS,
5564 pjsua_call_xfer_replaces_doc
5565 },
5566 {
5567 "call_dial_dtmf", py_pjsua_call_dial_dtmf, METH_VARARGS,
5568 pjsua_call_dial_dtmf_doc
5569 },
5570 {
5571 "call_send_im", py_pjsua_call_send_im, METH_VARARGS,
5572 pjsua_call_send_im_doc
5573 },
5574 {
5575 "call_send_typing_ind", py_pjsua_call_send_typing_ind, METH_VARARGS,
5576 pjsua_call_send_typing_ind_doc
5577 },
5578 {
5579 "call_hangup_all", py_pjsua_call_hangup_all, METH_VARARGS,
5580 pjsua_call_hangup_all_doc
5581 },
5582 {
5583 "call_dump", py_pjsua_call_dump, METH_VARARGS,
5584 pjsua_call_dump_doc
5585 },
5586 {
5587 "dump", py_pjsua_dump, METH_VARARGS, "Dump application state"
5588 },
5589
5590
5591 {NULL, NULL} /* end of function list */
5592};
5593
5594
5595
5596/*
5597 * Mapping C structs from and to Python objects & initializing object
5598 */
5599DL_EXPORT(void)
5600initpy_pjsua(void)
5601{
5602 PyObject* m = NULL;
5603#define ADD_CONSTANT(mod,name) PyModule_AddIntConstant(mod,#name,name)
5604
5605
5606 PyEval_InitThreads();
5607
5608 if (PyType_Ready(&PyTyp_pjsua_callback) < 0)
5609 return;
5610 if (PyType_Ready(&PyTyp_pjsua_config) < 0)
5611 return;
5612 if (PyType_Ready(&PyTyp_pjsua_logging_config) < 0)
5613 return;
5614 if (PyType_Ready(&PyTyp_pjsua_msg_data) < 0)
5615 return;
5616 PyTyp_pjsua_media_config.tp_new = PyType_GenericNew;
5617 if (PyType_Ready(&PyTyp_pjsua_media_config) < 0)
5618 return;
5619 PyTyp_pjsip_event.tp_new = PyType_GenericNew;
5620 if (PyType_Ready(&PyTyp_pjsip_event) < 0)
5621 return;
5622 PyTyp_pjsip_rx_data.tp_new = PyType_GenericNew;
5623 if (PyType_Ready(&PyTyp_pjsip_rx_data) < 0)
5624 return;
5625 PyTyp_pj_pool_t.tp_new = PyType_GenericNew;
5626 if (PyType_Ready(&PyTyp_pj_pool_t) < 0)
5627 return;
5628 PyTyp_pjsip_endpoint.tp_new = PyType_GenericNew;
5629 if (PyType_Ready(&PyTyp_pjsip_endpoint) < 0)
5630 return;
5631 PyTyp_pjmedia_endpt.tp_new = PyType_GenericNew;
5632 if (PyType_Ready(&PyTyp_pjmedia_endpt) < 0)
5633 return;
5634 PyTyp_pj_pool_factory.tp_new = PyType_GenericNew;
5635 if (PyType_Ready(&PyTyp_pj_pool_factory) < 0)
5636 return;
5637 PyTyp_pjsip_cred_info.tp_new = PyType_GenericNew;
5638 if (PyType_Ready(&PyTyp_pjsip_cred_info) < 0)
5639 return;
5640
5641 /* LIB TRANSPORT */
5642
5643 if (PyType_Ready(&PyTyp_pjsua_transport_config) < 0)
5644 return;
5645
5646 if (PyType_Ready(&PyTyp_pjsua_transport_info) < 0)
5647 return;
5648
5649 /* END OF LIB TRANSPORT */
5650
5651 /* LIB ACCOUNT */
5652
5653
5654 if (PyType_Ready(&PyTyp_pjsua_acc_config) < 0)
5655 return;
5656 if (PyType_Ready(&PyTyp_pjsua_acc_info) < 0)
5657 return;
5658
5659 /* END OF LIB ACCOUNT */
5660
5661 /* LIB BUDDY */
5662
5663 if (PyType_Ready(&PyTyp_pjsua_buddy_config) < 0)
5664 return;
5665 if (PyType_Ready(&PyTyp_pjsua_buddy_info) < 0)
5666 return;
5667
5668 /* END OF LIB BUDDY */
5669
5670 /* LIB MEDIA */
5671
5672 if (PyType_Ready(&PyTyp_pjsua_codec_info) < 0)
5673 return;
5674
5675 if (PyType_Ready(&PyTyp_pjsua_conf_port_info) < 0)
5676 return;
5677
5678 PyTyp_pjmedia_port.tp_new = PyType_GenericNew;
5679 if (PyType_Ready(&PyTyp_pjmedia_port) < 0)
5680 return;
5681
5682 if (PyType_Ready(&PyTyp_pjmedia_snd_dev_info) < 0)
5683 return;
5684
5685 PyTyp_pjmedia_codec_param_info.tp_new = PyType_GenericNew;
5686 if (PyType_Ready(&PyTyp_pjmedia_codec_param_info) < 0)
5687 return;
5688 PyTyp_pjmedia_codec_param_setting.tp_new = PyType_GenericNew;
5689 if (PyType_Ready(&PyTyp_pjmedia_codec_param_setting) < 0)
5690 return;
5691
5692 if (PyType_Ready(&PyTyp_pjmedia_codec_param) < 0)
5693 return;
5694
5695 /* END OF LIB MEDIA */
5696
5697 /* LIB CALL */
5698
5699 PyTyp_pj_time_val.tp_new = PyType_GenericNew;
5700 if (PyType_Ready(&PyTyp_pj_time_val) < 0)
5701 return;
5702
5703 if (PyType_Ready(&PyTyp_pjsua_call_info) < 0)
5704 return;
5705
5706 /* END OF LIB CALL */
5707
5708 m = Py_InitModule3(
5709 "py_pjsua", py_pjsua_methods,"PJSUA-lib module for python"
5710 );
5711
5712 Py_INCREF(&PyTyp_pjsua_callback);
5713 PyModule_AddObject(m, "Callback", (PyObject *)&PyTyp_pjsua_callback);
5714
5715 Py_INCREF(&PyTyp_pjsua_config);
5716 PyModule_AddObject(m, "Config", (PyObject *)&PyTyp_pjsua_config);
5717
5718 Py_INCREF(&PyTyp_pjsua_media_config);
5719 PyModule_AddObject(m, "Media_Config", (PyObject *)&PyTyp_pjsua_media_config);
5720
5721 Py_INCREF(&PyTyp_pjsua_logging_config);
5722 PyModule_AddObject(m, "Logging_Config", (PyObject *)&PyTyp_pjsua_logging_config);
5723
5724 Py_INCREF(&PyTyp_pjsua_msg_data);
5725 PyModule_AddObject(m, "Msg_Data", (PyObject *)&PyTyp_pjsua_msg_data);
5726
5727 Py_INCREF(&PyTyp_pjsip_event);
5728 PyModule_AddObject(m, "Pjsip_Event", (PyObject *)&PyTyp_pjsip_event);
5729
5730 Py_INCREF(&PyTyp_pjsip_rx_data);
5731 PyModule_AddObject(m, "Pjsip_Rx_Data", (PyObject *)&PyTyp_pjsip_rx_data);
5732
5733 Py_INCREF(&PyTyp_pj_pool_t);
5734 PyModule_AddObject(m, "Pj_Pool", (PyObject *)&PyTyp_pj_pool_t);
5735
5736 Py_INCREF(&PyTyp_pjsip_endpoint);
5737 PyModule_AddObject(m, "Pjsip_Endpoint", (PyObject *)&PyTyp_pjsip_endpoint);
5738
5739 Py_INCREF(&PyTyp_pjmedia_endpt);
5740 PyModule_AddObject(m, "Pjmedia_Endpt", (PyObject *)&PyTyp_pjmedia_endpt);
5741
5742 Py_INCREF(&PyTyp_pj_pool_factory);
5743 PyModule_AddObject(
5744 m, "Pj_Pool_Factory", (PyObject *)&PyTyp_pj_pool_factory
5745 );
5746
5747 Py_INCREF(&PyTyp_pjsip_cred_info);
5748 PyModule_AddObject(m, "Pjsip_Cred_Info",
5749 (PyObject *)&PyTyp_pjsip_cred_info
5750 );
5751
5752 /* LIB TRANSPORT */
5753
5754 Py_INCREF(&PyTyp_pjsua_transport_config);
5755 PyModule_AddObject
5756 (m, "Transport_Config", (PyObject *)&PyTyp_pjsua_transport_config);
5757
5758 Py_INCREF(&PyTyp_pjsua_transport_info);
5759 PyModule_AddObject(m, "Transport_Info", (PyObject *)&PyTyp_pjsua_transport_info);
5760
5761
5762 /* END OF LIB TRANSPORT */
5763
5764 /* LIB ACCOUNT */
5765
5766
5767 Py_INCREF(&PyTyp_pjsua_acc_config);
5768 PyModule_AddObject(m, "Acc_Config", (PyObject *)&PyTyp_pjsua_acc_config);
5769 Py_INCREF(&PyTyp_pjsua_acc_info);
5770 PyModule_AddObject(m, "Acc_Info", (PyObject *)&PyTyp_pjsua_acc_info);
5771
5772 /* END OF LIB ACCOUNT */
5773
5774 /* LIB BUDDY */
5775
5776 Py_INCREF(&PyTyp_pjsua_buddy_config);
5777 PyModule_AddObject(m, "Buddy_Config", (PyObject *)&PyTyp_pjsua_buddy_config);
5778 Py_INCREF(&PyTyp_pjsua_buddy_info);
5779 PyModule_AddObject(m, "Buddy_Info", (PyObject *)&PyTyp_pjsua_buddy_info);
5780
5781 /* END OF LIB BUDDY */
5782
5783 /* LIB MEDIA */
5784
5785 Py_INCREF(&PyTyp_pjsua_codec_info);
5786 PyModule_AddObject(m, "Codec_Info", (PyObject *)&PyTyp_pjsua_codec_info);
5787 Py_INCREF(&PyTyp_pjsua_conf_port_info);
5788 PyModule_AddObject(m, "Conf_Port_Info", (PyObject *)&PyTyp_pjsua_conf_port_info);
5789 Py_INCREF(&PyTyp_pjmedia_port);
5790 PyModule_AddObject(m, "PJMedia_Port", (PyObject *)&PyTyp_pjmedia_port);
5791 Py_INCREF(&PyTyp_pjmedia_snd_dev_info);
5792 PyModule_AddObject(m, "PJMedia_Snd_Dev_Info",
5793 (PyObject *)&PyTyp_pjmedia_snd_dev_info);
5794 Py_INCREF(&PyTyp_pjmedia_codec_param_info);
5795 PyModule_AddObject(m, "PJMedia_Codec_Param_Info",
5796 (PyObject *)&PyTyp_pjmedia_codec_param_info);
5797 Py_INCREF(&PyTyp_pjmedia_codec_param_setting);
5798 PyModule_AddObject(m, "PJMedia_Codec_Param_Setting",
5799 (PyObject *)&PyTyp_pjmedia_codec_param_setting);
5800 Py_INCREF(&PyTyp_pjmedia_codec_param);
5801 PyModule_AddObject(m, "PJMedia_Codec_Param",
5802 (PyObject *)&PyTyp_pjmedia_codec_param);
5803
5804 /* END OF LIB MEDIA */
5805
5806 /* LIB CALL */
5807
5808 Py_INCREF(&PyTyp_pj_time_val);
5809 PyModule_AddObject(m, "PJ_Time_Val", (PyObject *)&PyTyp_pj_time_val);
5810
5811 Py_INCREF(&PyTyp_pjsua_call_info);
5812 PyModule_AddObject(m, "Call_Info", (PyObject *)&PyTyp_pjsua_call_info);
5813
5814 /* END OF LIB CALL */
5815
5816
5817 /*
5818 * Add various constants.
5819 */
5820
5821 /* Call states */
5822 ADD_CONSTANT(m, PJSIP_INV_STATE_NULL);
5823 ADD_CONSTANT(m, PJSIP_INV_STATE_CALLING);
5824 ADD_CONSTANT(m, PJSIP_INV_STATE_INCOMING);
5825 ADD_CONSTANT(m, PJSIP_INV_STATE_EARLY);
5826 ADD_CONSTANT(m, PJSIP_INV_STATE_CONNECTING);
5827 ADD_CONSTANT(m, PJSIP_INV_STATE_CONFIRMED);
5828 ADD_CONSTANT(m, PJSIP_INV_STATE_DISCONNECTED);
5829
5830 /* Call media status (enum pjsua_call_media_status) */
5831 ADD_CONSTANT(m, PJSUA_CALL_MEDIA_NONE);
5832 ADD_CONSTANT(m, PJSUA_CALL_MEDIA_ACTIVE);
5833 ADD_CONSTANT(m, PJSUA_CALL_MEDIA_LOCAL_HOLD);
5834 ADD_CONSTANT(m, PJSUA_CALL_MEDIA_REMOTE_HOLD);
5835
5836 /* Buddy status */
5837 ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_UNKNOWN);
5838 ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_ONLINE);
5839 ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_OFFLINE);
5840
5841 /* PJSIP transport types (enum pjsip_transport_type_e) */
5842 ADD_CONSTANT(m, PJSIP_TRANSPORT_UNSPECIFIED);
5843 ADD_CONSTANT(m, PJSIP_TRANSPORT_UDP);
5844 ADD_CONSTANT(m, PJSIP_TRANSPORT_TCP);
5845 ADD_CONSTANT(m, PJSIP_TRANSPORT_TLS);
5846 ADD_CONSTANT(m, PJSIP_TRANSPORT_SCTP);
5847 ADD_CONSTANT(m, PJSIP_TRANSPORT_LOOP);
5848 ADD_CONSTANT(m, PJSIP_TRANSPORT_LOOP_DGRAM);
5849
5850
5851 /* Invalid IDs */
5852 ADD_CONSTANT(m, PJSUA_INVALID_ID);
5853
5854
5855 /* Various compile time constants */
5856 ADD_CONSTANT(m, PJSUA_ACC_MAX_PROXIES);
5857 ADD_CONSTANT(m, PJSUA_MAX_ACC);
5858 ADD_CONSTANT(m, PJSUA_REG_INTERVAL);
5859 ADD_CONSTANT(m, PJSUA_PUBLISH_EXPIRATION);
5860 ADD_CONSTANT(m, PJSUA_DEFAULT_ACC_PRIORITY);
5861 ADD_CONSTANT(m, PJSUA_MAX_BUDDIES);
5862 ADD_CONSTANT(m, PJSUA_MAX_CONF_PORTS);
5863 ADD_CONSTANT(m, PJSUA_DEFAULT_CLOCK_RATE);
5864 ADD_CONSTANT(m, PJSUA_DEFAULT_CODEC_QUALITY);
5865 ADD_CONSTANT(m, PJSUA_DEFAULT_ILBC_MODE);
5866 ADD_CONSTANT(m, PJSUA_DEFAULT_EC_TAIL_LEN);
5867 ADD_CONSTANT(m, PJSUA_MAX_CALLS);
5868 ADD_CONSTANT(m, PJSUA_XFER_NO_REQUIRE_REPLACES);
5869
5870
5871#undef ADD_CONSTANT
5872}