1
/* $Id: py_pjsua.c 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
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.
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.
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
22
#define THIS_FILE "main.c"
23
#define POOL_SIZE 4000
24
#define SND_DEV_NUM 64
25
#define SND_NAME_LEN 64
29
static PyObject* obj_log_cb;
30
static long thread_id;
32
#define ENTER_PYTHON() PyGILState_STATE state = PyGILState_Ensure()
33
#define LEAVE_PYTHON() PyGILState_Release(state)
37
* declares method for reconfiguring logging process for callback struct
39
static void cb_log_cb(int level, const char *data, int len)
42
/* Ignore if this callback is called from alien thread context,
43
* or otherwise it will crash Python.
45
if (pj_thread_local_get(thread_id) == 0)
48
if (PyCallable_Check(obj_log_cb))
52
PyObject_CallFunctionObjArgs(
53
obj_log_cb, Py_BuildValue("i",level),
54
PyString_FromString(data), Py_BuildValue("i",len), NULL
64
* The global callback object.
66
static PyObj_pjsua_callback * g_obj_callback;
71
* declares method on_call_state for callback struct
73
static void cb_on_call_state(pjsua_call_id call_id, pjsip_event *e)
75
if (PyCallable_Check(g_obj_callback->on_call_state))
77
PyObj_pjsip_event * obj;
81
obj = (PyObj_pjsip_event *)PyType_GenericNew(&PyTyp_pjsip_event,
86
PyObject_CallFunctionObjArgs(
87
g_obj_callback->on_call_state,
88
Py_BuildValue("i",call_id),
100
* declares method on_incoming_call for callback struct
102
static void cb_on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
103
pjsip_rx_data *rdata)
105
if (PyCallable_Check(g_obj_callback->on_incoming_call))
107
PyObj_pjsip_rx_data * obj;
111
obj = (PyObj_pjsip_rx_data *)PyType_GenericNew(&PyTyp_pjsip_rx_data,
115
PyObject_CallFunctionObjArgs(
116
g_obj_callback->on_incoming_call,
117
Py_BuildValue("i",acc_id),
118
Py_BuildValue("i",call_id),
129
* cb_on_call_media_state
130
* declares method on_call_media_state for callback struct
132
static void cb_on_call_media_state(pjsua_call_id call_id)
134
if (PyCallable_Check(g_obj_callback->on_call_media_state))
138
PyObject_CallFunction(
139
g_obj_callback->on_call_media_state,
152
* Callback from PJSUA-LIB on receiving DTMF digit
154
static void cb_on_dtmf_digit(pjsua_call_id call_id, int digit)
156
if (PyCallable_Check(g_obj_callback->on_dtmf_digit))
162
pj_ansi_snprintf(digit_str, sizeof(digit_str), "%c", digit);
164
PyObject_CallFunctionObjArgs(
165
g_obj_callback->on_dtmf_digit,
166
Py_BuildValue("i",call_id),
167
PyString_FromString(digit_str),
177
* Notify application on call being transfered.
180
static void cb_on_call_transfer_request(pjsua_call_id call_id,
182
pjsip_status_code *code)
184
if (PyCallable_Check(g_obj_callback->on_call_transfer_request))
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),
199
if (ret != Py_None) {
200
if (PyArg_Parse(ret,"i",&cd)) {
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.
218
static void cb_on_call_transfer_status( pjsua_call_id call_id,
220
const pj_str_t *status_text,
224
if (PyCallable_Check(g_obj_callback->on_call_transfer_status))
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),
241
if (ret != Py_None) {
242
if (PyArg_Parse(ret,"i",&cnt)) {
254
* Notify application about incoming INVITE with Replaces header.
255
* Application may reject the request by setting non-2xx code.
258
static void cb_on_call_replace_request( pjsua_call_id call_id,
259
pjsip_rx_data *rdata,
263
if (PyCallable_Check(g_obj_callback->on_call_replace_request))
268
PyObj_pjsip_rx_data * obj;
272
obj = (PyObj_pjsip_rx_data *)PyType_GenericNew(&PyTyp_pjsip_rx_data,
276
ret = PyObject_CallFunctionObjArgs(
277
g_obj_callback->on_call_replace_request,
278
Py_BuildValue("i",call_id),
280
Py_BuildValue("i",*st_code),
281
PyString_FromStringAndSize(st_text->ptr, st_text->slen),
285
if (ret != Py_None) {
286
if (PyArg_ParseTuple(ret,"iO",&cd, &txt)) {
288
st_text->ptr = PyString_AsString(txt);
289
st_text->slen = strlen(PyString_AsString(txt));
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.
304
static void cb_on_call_replaced(pjsua_call_id old_call_id,
305
pjsua_call_id new_call_id)
307
if (PyCallable_Check(g_obj_callback->on_call_replaced))
311
PyObject_CallFunctionObjArgs(
312
g_obj_callback->on_call_replaced,
313
Py_BuildValue("i",old_call_id),
314
Py_BuildValue("i",new_call_id),
325
* declares method on_reg_state for callback struct
327
static void cb_on_reg_state(pjsua_acc_id acc_id)
329
if (PyCallable_Check(g_obj_callback->on_reg_state))
333
PyObject_CallFunction(
334
g_obj_callback->on_reg_state,
347
* declares method on_buddy state for callback struct
349
static void cb_on_buddy_state(pjsua_buddy_id buddy_id)
351
if (PyCallable_Check(g_obj_callback->on_buddy_state))
355
PyObject_CallFunction(
356
g_obj_callback->on_buddy_state,
368
* declares method on_pager for callback struct
370
static 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)
374
if (PyCallable_Check(g_obj_callback->on_pager))
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),
395
* declares method on_pager_status for callback struct
397
static 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)
402
if (PyCallable_Check(g_obj_callback->on_pager))
404
PyObject * obj_user_data;
408
obj_user_data = Py_BuildValue("i", user_data);
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),
416
Py_BuildValue("i",status),
417
PyString_FromStringAndSize(reason->ptr,reason->slen),
428
* declares method on_typing for callback struct
430
static 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,
434
if (PyCallable_Check(g_obj_callback->on_typing))
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),
456
* translate from hdr_list to pjsip_generic_string_hdr
458
void translate_hdr(pj_pool_t *pool, pjsip_hdr *hdr, PyObject *py_hdr_list)
462
if (PyList_Check(py_hdr_list)) {
465
for (i = 0; i < PyList_Size(py_hdr_list); i++)
467
pj_str_t hname, hvalue;
468
pjsip_generic_string_hdr * new_hdr;
469
PyObject * tuple = PyList_GetItem(py_hdr_list, i);
471
if (PyTuple_Check(tuple))
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)));
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);
494
* translate from pjsip_generic_string_hdr to hdr_list
497
void translate_hdr_rev(pjsip_generic_string_hdr *hdr, PyObject *py_hdr_list)
501
pjsip_generic_string_hdr * p_hdr;
503
len = pj_list_size(hdr);
508
Py_XDECREF(py_hdr_list);
509
py_hdr_list = PyList_New(len);
511
for (i = 0; i < len && p_hdr != NULL; i++)
516
tuple = PyTuple_New(2);
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);
532
* py_pjsua_thread_register
535
static PyObject *py_pjsua_thread_register(PyObject *pSelf, PyObject *pArgs)
549
PJ_UNUSED_ARG(pSelf);
551
if (!PyArg_ParseTuple(pArgs, "sO", &name, &py_desc))
556
size = PyList_Size(py_desc);
557
td = (int *)malloc(size * sizeof(int));
558
for (i = 0; i < size; i++)
560
if (!PyArg_Parse(PyList_GetItem(py_desc,i),"i", td[i]))
567
thread_desc = malloc(sizeof(pj_thread_desc));
569
status = pj_thread_register(name, thread_desc, &thread);
571
if (status == PJ_SUCCESS)
572
status = pj_thread_local_set(thread_id, (void*)1);
573
return Py_BuildValue("i",status);
577
* py_pjsua_logging_config_default
580
static PyObject *py_pjsua_logging_config_default(PyObject *pSelf,
583
PyObj_pjsua_logging_config *obj;
584
pjsua_logging_config cfg;
586
PJ_UNUSED_ARG(pSelf);
588
if (!PyArg_ParseTuple(pArgs, ""))
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);
598
return (PyObject *)obj;
603
* py_pjsua_config_default
606
static PyObject *py_pjsua_config_default(PyObject *pSelf, PyObject *pArgs)
608
PyObj_pjsua_config *obj;
611
PJ_UNUSED_ARG(pSelf);
613
if (!PyArg_ParseTuple(pArgs, ""))
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);
621
return (PyObject *)obj;
626
* py_pjsua_media_config_default
629
static PyObject * py_pjsua_media_config_default(PyObject *pSelf,
632
PyObj_pjsua_media_config *obj;
633
pjsua_media_config cfg;
635
PJ_UNUSED_ARG(pSelf);
637
if (!PyArg_ParseTuple(pArgs, ""))
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;
650
* py_pjsua_msg_data_init
653
static PyObject *py_pjsua_msg_data_init(PyObject *pSelf, PyObject *pArgs)
655
PyObj_pjsua_msg_data *obj;
658
PJ_UNUSED_ARG(pSelf);
660
if (!PyArg_ParseTuple(pArgs, ""))
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
670
Py_XDECREF(obj->msg_body);
671
obj->msg_body = PyString_FromStringAndSize(
672
msg.msg_body.ptr, msg.msg_body.slen
675
translate_hdr_rev((pjsip_generic_string_hdr *)&msg.hdr_list,obj->hdr_list);
677
return (PyObject *)obj;
682
* py_pjsua_reconfigure_logging
684
static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, PyObject *pArgs)
687
PyObj_pjsua_logging_config *log;
688
pjsua_logging_config cfg;
691
PJ_UNUSED_ARG(pSelf);
693
if (!PyArg_ParseTuple(pArgs, "O", &logObj))
697
if (logObj != Py_None)
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);
710
status = pjsua_reconfigure_logging(&cfg);
712
status = pjsua_reconfigure_logging(NULL);
714
return Py_BuildValue("i",status);
719
* py_pjsua_pool_create
721
static PyObject *py_pjsua_pool_create(PyObject *pSelf, PyObject *pArgs)
729
PJ_UNUSED_ARG(pSelf);
731
if (!PyArg_ParseTuple(pArgs, "sII", &name, &init_size, &increment))
736
p = pjsua_pool_create(name, init_size, increment);
737
pool = (PyObj_pj_pool *)PyType_GenericNew(&PyTyp_pj_pool_t, NULL, NULL);
739
return (PyObject *)pool;
745
* py_pjsua_get_pjsip_endpt
747
static PyObject *py_pjsua_get_pjsip_endpt(PyObject *pSelf, PyObject *pArgs)
749
PyObj_pjsip_endpoint *endpt;
752
PJ_UNUSED_ARG(pSelf);
754
if (!PyArg_ParseTuple(pArgs, ""))
758
e = pjsua_get_pjsip_endpt();
759
endpt = (PyObj_pjsip_endpoint *)PyType_GenericNew(
760
&PyTyp_pjsip_endpoint, NULL, NULL
763
return (PyObject *)endpt;
768
* py_pjsua_get_pjmedia_endpt
770
static PyObject *py_pjsua_get_pjmedia_endpt(PyObject *pSelf, PyObject *pArgs)
772
PyObj_pjmedia_endpt *endpt;
775
PJ_UNUSED_ARG(pSelf);
777
if (!PyArg_ParseTuple(pArgs, ""))
781
e = pjsua_get_pjmedia_endpt();
782
endpt = (PyObj_pjmedia_endpt *)PyType_GenericNew(
783
&PyTyp_pjmedia_endpt, NULL, NULL
786
return (PyObject *)endpt;
791
* py_pjsua_get_pool_factory
793
static PyObject *py_pjsua_get_pool_factory(PyObject *pSelf, PyObject *pArgs)
795
PyObj_pj_pool_factory *pool;
798
PJ_UNUSED_ARG(pSelf);
800
if (!PyArg_ParseTuple(pArgs, ""))
804
p = pjsua_get_pool_factory();
805
pool = (PyObj_pj_pool_factory *)PyType_GenericNew(
806
&PyTyp_pj_pool_factory, NULL, NULL
809
return (PyObject *)pool;
816
static PyObject *py_pjsua_perror(PyObject *pSelf, PyObject *pArgs)
822
PJ_UNUSED_ARG(pSelf);
824
if (!PyArg_ParseTuple(pArgs, "ssi", &sender, &title, &status))
829
pjsua_perror(sender, title, status);
838
static PyObject *py_pjsua_create(PyObject *pSelf, PyObject *pArgs)
842
PJ_UNUSED_ARG(pSelf);
844
if (!PyArg_ParseTuple(pArgs, ""))
848
status = pjsua_create();
850
if (status == PJ_SUCCESS)
852
status = pj_thread_local_alloc(&thread_id);
853
if (status == PJ_SUCCESS)
854
status = pj_thread_local_set(thread_id, (void*)1);
857
return Py_BuildValue("i",status);
864
static PyObject *py_pjsua_init(PyObject *pSelf, PyObject *pArgs)
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;
872
PJ_UNUSED_ARG(pSelf);
874
if (!PyArg_ParseTuple(pArgs, "OOO", &o_ua_cfg, &o_log_cfg, &o_media_cfg))
879
pjsua_config_default(&cfg_ua);
880
pjsua_logging_config_default(&cfg_log);
881
pjsua_media_config_default(&cfg_media);
883
if (o_ua_cfg != Py_None)
885
PyObj_pjsua_config *obj_ua_cfg = (PyObj_pjsua_config*)o_ua_cfg;
887
PyObj_pjsua_config_export(&cfg_ua, obj_ua_cfg);
889
g_obj_callback = obj_ua_cfg->cb;
890
Py_INCREF(g_obj_callback);
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;
912
if (o_log_cfg != Py_None)
914
PyObj_pjsua_logging_config * obj_log;
916
obj_log = (PyObj_pjsua_logging_config *)o_log_cfg;
918
PyObj_pjsua_logging_config_export(&cfg_log, obj_log);
920
Py_XDECREF(obj_log_cb);
921
obj_log_cb = obj_log->cb;
922
Py_INCREF(obj_log_cb);
924
cfg_log.cb = &cb_log_cb;
925
p_cfg_log = &cfg_log;
931
if (o_media_cfg != Py_None)
933
PyObj_pjsua_media_config_export(&cfg_media,
934
(PyObj_pjsua_media_config*)o_media_cfg);
935
p_cfg_media = &cfg_media;
941
status = pjsua_init(p_cfg_ua, p_cfg_log, p_cfg_media);
942
return Py_BuildValue("i",status);
949
static PyObject *py_pjsua_start(PyObject *pSelf, PyObject *pArgs)
953
PJ_UNUSED_ARG(pSelf);
955
if (!PyArg_ParseTuple(pArgs, ""))
959
status = pjsua_start();
961
return Py_BuildValue("i",status);
968
static PyObject *py_pjsua_destroy(PyObject *pSelf, PyObject *pArgs)
972
PJ_UNUSED_ARG(pSelf);
974
if (!PyArg_ParseTuple(pArgs, ""))
978
status = pjsua_destroy();
980
return Py_BuildValue("i",status);
985
* py_pjsua_handle_events
987
static PyObject *py_pjsua_handle_events(PyObject *pSelf, PyObject *pArgs)
992
PJ_UNUSED_ARG(pSelf);
994
if (!PyArg_ParseTuple(pArgs, "i", &msec))
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.
1004
Py_BEGIN_ALLOW_THREADS
1005
ret = pjsua_handle_events(msec);
1006
Py_END_ALLOW_THREADS
1008
return Py_BuildValue("i",ret);
1013
* py_pjsua_verify_sip_url
1015
static PyObject *py_pjsua_verify_sip_url(PyObject *pSelf, PyObject *pArgs)
1020
PJ_UNUSED_ARG(pSelf);
1022
if (!PyArg_ParseTuple(pArgs, "s", &url))
1026
status = pjsua_verify_sip_url(url);
1028
return Py_BuildValue("i",status);
1036
static char pjsua_thread_register_doc[] =
1037
"int py_pjsua.thread_register(string name, int[] desc)";
1038
static 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.";
1045
static 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() "
1053
static 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.";
1063
static 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";
1069
static 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.";
1075
static 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).";
1084
static 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.";
1089
static char pjsua_pool_create_doc[] =
1090
"py_pjsua.Pj_Pool py_pjsua.pool_create (string name, int init_size, "
1092
"Create memory pool Parameters: "
1093
"name: Optional pool name; "
1094
"init_size: Initial size of the pool; "
1095
"increment: Increment size.";
1097
static 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.";
1103
static 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.";
1108
static 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.";
1113
static 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.";
1119
static char pjsua_logging_config_default_doc[] =
1120
"py_pjsua.Logging_Config py_pjsua.logging_config_default () "
1121
"Use this function to initialize logging config.";
1123
static char pjsua_config_default_doc[] =
1124
"py_pjsua.Config py_pjsua.config_default (). Use this function to "
1125
"initialize pjsua config. ";
1127
static char pjsua_media_config_default_doc[] =
1128
"py_pjsua.Media_Config py_pjsua.media_config_default (). "
1129
"Use this function to initialize media config.";
1131
static char pjsua_msg_data_init_doc[] =
1132
"py_pjsua.Msg_Data void py_pjsua.msg_data_init () "
1133
"Initialize message data ";
1136
/* END OF LIB BASE */
1141
* py_pjsua_transport_config_default
1142
* !modified @ 051206
1144
static PyObject *py_pjsua_transport_config_default(PyObject *pSelf,
1147
PyObj_pjsua_transport_config *obj;
1148
pjsua_transport_config cfg;
1150
PJ_UNUSED_ARG(pSelf);
1152
if (!PyArg_ParseTuple(pArgs, "")) {
1156
pjsua_transport_config_default(&cfg);
1157
obj = (PyObj_pjsua_transport_config*)
1158
PyObj_pjsua_transport_config_new(&PyTyp_pjsua_transport_config,
1160
PyObj_pjsua_transport_config_import(obj, &cfg);
1162
return (PyObject *)obj;
1166
* py_pjsua_transport_create
1167
* !modified @ 051206
1169
static PyObject *py_pjsua_transport_create(PyObject *pSelf, PyObject *pArgs)
1174
pjsua_transport_config cfg;
1175
pjsua_transport_id id;
1177
PJ_UNUSED_ARG(pSelf);
1179
if (!PyArg_ParseTuple(pArgs, "iO", &type, &tmpObj)) {
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);
1189
status = pjsua_transport_create(type, NULL, &id);
1193
return Py_BuildValue("ii", status, id);
1197
* py_pjsua_enum_transports
1198
* !modified @ 261206
1200
static PyObject *py_pjsua_enum_transports(PyObject *pSelf, PyObject *pArgs)
1205
pjsua_transport_id id[PJSIP_MAX_TRANSPORTS];
1208
PJ_UNUSED_ARG(pSelf);
1210
if (!PyArg_ParseTuple(pArgs, ""))
1215
c = PJ_ARRAY_SIZE(id);
1216
status = pjsua_enum_transports(id, &c);
1218
list = PyList_New(c);
1219
for (i = 0; i < c; i++)
1221
int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
1228
return Py_BuildValue("O",list);
1232
* py_pjsua_transport_get_info
1233
* !modified @ 051206
1235
static PyObject *py_pjsua_transport_get_info(PyObject *pSelf, PyObject *pArgs)
1239
pjsua_transport_info info;
1241
PJ_UNUSED_ARG(pSelf);
1243
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
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,
1253
PyObj_pjsua_transport_info_import(obj, &info);
1254
return Py_BuildValue("O", obj);
1262
* py_pjsua_transport_set_enable
1264
static PyObject *py_pjsua_transport_set_enable
1265
(PyObject *pSelf, PyObject *pArgs)
1271
PJ_UNUSED_ARG(pSelf);
1273
if (!PyArg_ParseTuple(pArgs, "ii", &id, &enabled))
1277
status = pjsua_transport_set_enable(id, enabled);
1279
return Py_BuildValue("i",status);
1283
* py_pjsua_transport_close
1285
static PyObject *py_pjsua_transport_close(PyObject *pSelf, PyObject *pArgs)
1291
PJ_UNUSED_ARG(pSelf);
1293
if (!PyArg_ParseTuple(pArgs, "ii", &id, &force))
1297
status = pjsua_transport_close(id, force);
1299
return Py_BuildValue("i",status);
1302
static 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.";
1305
static char pjsua_transport_create_doc[] =
1306
"int, int py_pjsua.transport_create (int type, "
1307
"py_pjsua.Transport_Config cfg) "
1308
"Create SIP transport.";
1309
static char pjsua_enum_transports_doc[] =
1310
"int[] py_pjsua.enum_transports () "
1311
"Enumerate all transports currently created in the system.";
1312
static 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.";
1316
static 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.";
1324
static 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.";
1333
/* END OF LIB TRANSPORT */
1339
* py_pjsua_acc_config_default
1340
* !modified @ 051206
1342
static PyObject *py_pjsua_acc_config_default(PyObject *pSelf, PyObject *pArgs)
1344
PyObj_pjsua_acc_config *obj;
1345
pjsua_acc_config cfg;
1347
PJ_UNUSED_ARG(pSelf);
1349
if (!PyArg_ParseTuple(pArgs, "")) {
1353
pjsua_acc_config_default(&cfg);
1354
obj = (PyObj_pjsua_acc_config *)
1355
PyObj_pjsua_acc_config_new(&PyTyp_pjsua_acc_config,
1357
PyObj_pjsua_acc_config_import(obj, &cfg);
1358
return (PyObject *)obj;
1362
* py_pjsua_acc_get_count
1364
static PyObject *py_pjsua_acc_get_count(PyObject *pSelf, PyObject *pArgs)
1368
PJ_UNUSED_ARG(pSelf);
1370
if (!PyArg_ParseTuple(pArgs, "")) {
1374
count = pjsua_acc_get_count();
1375
return Py_BuildValue("i",count);
1379
* py_pjsua_acc_is_valid
1381
static PyObject *py_pjsua_acc_is_valid(PyObject *pSelf, PyObject *pArgs)
1386
PJ_UNUSED_ARG(pSelf);
1388
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
1392
is_valid = pjsua_acc_is_valid(id);
1393
return Py_BuildValue("i", is_valid);
1397
* py_pjsua_acc_set_default
1399
static PyObject *py_pjsua_acc_set_default(PyObject *pSelf, PyObject *pArgs)
1404
PJ_UNUSED_ARG(pSelf);
1406
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
1409
status = pjsua_acc_set_default(id);
1411
return Py_BuildValue("i", status);
1415
* py_pjsua_acc_get_default
1417
static PyObject *py_pjsua_acc_get_default(PyObject *pSelf, PyObject *pArgs)
1421
PJ_UNUSED_ARG(pSelf);
1423
if (!PyArg_ParseTuple(pArgs, "")) {
1427
id = pjsua_acc_get_default();
1429
return Py_BuildValue("i", id);
1434
* !modified @ 051206
1436
static PyObject *py_pjsua_acc_add(PyObject *pSelf, PyObject *pArgs)
1440
PyObj_pjsua_acc_config * ac;
1444
PJ_UNUSED_ARG(pSelf);
1446
if (!PyArg_ParseTuple(pArgs, "Oi", &acObj, &is_default)) {
1450
if (acObj != Py_None) {
1451
pjsua_acc_config cfg;
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);
1459
acc_id = PJSUA_INVALID_ID;
1462
return Py_BuildValue("ii", status, acc_id);
1466
* py_pjsua_acc_add_local
1467
* !modified @ 051206
1469
static PyObject *py_pjsua_acc_add_local(PyObject *pSelf, PyObject *pArgs)
1476
PJ_UNUSED_ARG(pSelf);
1478
if (!PyArg_ParseTuple(pArgs, "ii", &tid, &is_default)) {
1483
status = pjsua_acc_add_local(tid, is_default, &p_acc_id);
1485
return Py_BuildValue("ii", status, p_acc_id);
1491
static PyObject *py_pjsua_acc_del(PyObject *pSelf, PyObject *pArgs)
1496
PJ_UNUSED_ARG(pSelf);
1498
if (!PyArg_ParseTuple(pArgs, "i", &acc_id))
1504
status = pjsua_acc_del(acc_id);
1505
return Py_BuildValue("i", status);
1509
* py_pjsua_acc_modify
1511
static PyObject *py_pjsua_acc_modify(PyObject *pSelf, PyObject *pArgs)
1514
PyObj_pjsua_acc_config * ac;
1518
PJ_UNUSED_ARG(pSelf);
1520
if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &acObj)) {
1524
if (acObj != Py_None) {
1525
pjsua_acc_config cfg;
1527
pjsua_acc_config_default(&cfg);
1528
ac = (PyObj_pjsua_acc_config *)acObj;
1529
PyObj_pjsua_acc_config_export(&cfg, ac);
1531
status = pjsua_acc_modify(acc_id, &cfg);
1535
return Py_BuildValue("i", status);
1539
* py_pjsua_acc_set_online_status
1541
static PyObject *py_pjsua_acc_set_online_status(PyObject *pSelf,
1548
PJ_UNUSED_ARG(pSelf);
1550
if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &is_online)) {
1554
status = pjsua_acc_set_online_status(acc_id, is_online);
1556
return Py_BuildValue("i", status);
1560
* py_pjsua_acc_set_online_status2
1562
static PyObject *py_pjsua_acc_set_online_status2(PyObject *pSelf,
1568
const char *activity_text;
1569
pjrpid_element rpid;
1572
PJ_UNUSED_ARG(pSelf);
1574
if (!PyArg_ParseTuple(pArgs, "iiis", &acc_id, &is_online,
1575
&activity_id, &activity_text)) {
1579
pj_bzero(&rpid, sizeof(rpid));
1580
rpid.activity = activity_id;
1581
rpid.note = pj_str((char*)activity_text);
1583
status = pjsua_acc_set_online_status2(acc_id, is_online, &rpid);
1585
return Py_BuildValue("i", status);
1589
* py_pjsua_acc_set_registration
1591
static PyObject *py_pjsua_acc_set_registration(PyObject *pSelf,
1598
PJ_UNUSED_ARG(pSelf);
1600
if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &renew)) {
1604
status = pjsua_acc_set_registration(acc_id, renew);
1606
return Py_BuildValue("i", status);
1610
* py_pjsua_acc_get_info
1611
* !modified @ 051206
1613
static PyObject *py_pjsua_acc_get_info(PyObject *pSelf, PyObject *pArgs)
1616
PyObj_pjsua_acc_info * obj;
1617
pjsua_acc_info info;
1620
PJ_UNUSED_ARG(pSelf);
1622
if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) {
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);
1639
* py_pjsua_enum_accs
1640
* !modified @ 241206
1642
static PyObject *py_pjsua_enum_accs(PyObject *pSelf, PyObject *pArgs)
1647
pjsua_acc_id id[PJSUA_MAX_ACC];
1650
PJ_UNUSED_ARG(pSelf);
1652
if (!PyArg_ParseTuple(pArgs, ""))
1656
c = PJ_ARRAY_SIZE(id);
1658
status = pjsua_enum_accs(id, &c);
1660
list = PyList_New(c);
1661
for (i = 0; i < c; i++)
1663
int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
1670
return Py_BuildValue("O",list);
1674
* py_pjsua_acc_enum_info
1675
* !modified @ 241206
1677
static PyObject *py_pjsua_acc_enum_info(PyObject *pSelf, PyObject *pArgs)
1681
pjsua_acc_info info[PJSUA_MAX_ACC];
1684
PJ_UNUSED_ARG(pSelf);
1686
if (!PyArg_ParseTuple(pArgs, "")) {
1690
c = PJ_ARRAY_SIZE(info);
1691
status = pjsua_acc_enum_info(info, &c);
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);
1699
PyObj_pjsua_acc_info_import(obj, &info[i]);
1701
PyList_SetItem(list, i, (PyObject *)obj);
1704
return Py_BuildValue("O",list);
1708
* py_pjsua_acc_find_for_outgoing
1710
static PyObject *py_pjsua_acc_find_for_outgoing(PyObject *pSelf,
1717
PJ_UNUSED_ARG(pSelf);
1719
if (!PyArg_ParseTuple(pArgs, "O", &url))
1723
str.ptr = PyString_AsString(url);
1724
str.slen = strlen(PyString_AsString(url));
1726
acc_id = pjsua_acc_find_for_outgoing(&str);
1728
return Py_BuildValue("i", acc_id);
1732
* py_pjsua_acc_find_for_incoming
1734
static PyObject *py_pjsua_acc_find_for_incoming(PyObject *pSelf,
1739
PyObj_pjsip_rx_data * obj;
1740
pjsip_rx_data * rdata;
1742
PJ_UNUSED_ARG(pSelf);
1744
if (!PyArg_ParseTuple(pArgs, "O", &tmpObj))
1748
if (tmpObj != Py_None)
1750
obj = (PyObj_pjsip_rx_data *)tmpObj;
1752
acc_id = pjsua_acc_find_for_incoming(rdata);
1754
acc_id = pjsua_acc_find_for_incoming(NULL);
1756
return Py_BuildValue("i", acc_id);
1760
* py_pjsua_acc_create_uac_contact
1761
* !modified @ 061206
1763
static PyObject *py_pjsua_acc_create_uac_contact(PyObject *pSelf,
1776
PJ_UNUSED_ARG(pSelf);
1778
if (!PyArg_ParseTuple(pArgs, "OiO", &pObj, &acc_id, &stru))
1782
if (pObj != Py_None)
1784
p = (PyObj_pj_pool *)pObj;
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);
1790
status = pjsua_acc_create_uac_contact(NULL, &contact, acc_id, &uri);
1792
strc = PyString_FromStringAndSize(contact.ptr, contact.slen);
1794
return Py_BuildValue("O", strc);
1798
* py_pjsua_acc_create_uas_contact
1799
* !modified @ 061206
1801
static PyObject *py_pjsua_acc_create_uas_contact(PyObject *pSelf,
1812
PyObj_pjsip_rx_data * objr;
1813
pjsip_rx_data * rdata;
1815
PJ_UNUSED_ARG(pSelf);
1817
if (!PyArg_ParseTuple(pArgs, "OiO", &pObj, &acc_id, &rObj))
1821
if (pObj != Py_None)
1823
p = (PyObj_pj_pool *)pObj;
1828
if (rObj != Py_None)
1830
objr = (PyObj_pjsip_rx_data *)rObj;
1831
rdata = objr->rdata;
1835
status = pjsua_acc_create_uas_contact(pool, &contact, acc_id, rdata);
1836
strc = PyString_FromStringAndSize(contact.ptr, contact.slen);
1838
return Py_BuildValue("O", strc);
1841
static 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.";
1844
static char pjsua_acc_get_count_doc[] =
1845
"int py_pjsua.acc_get_count () "
1846
"Get number of current accounts.";
1847
static 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.";
1850
static 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.";
1854
static char pjsua_acc_get_default_doc[] =
1855
"int py_pjsua.acc_get_default () "
1856
"Get default account.";
1857
static char pjsua_acc_add_doc[] =
1858
"int, int py_pjsua.acc_add (py_pjsua.Acc_Config cfg, "
1860
"Add a new account to pjsua. PJSUA must have been initialized "
1861
"(with pjsua_init()) before calling this function.";
1862
static char pjsua_acc_add_local_doc[] =
1863
"int,int py_pjsua.acc_add_local (int tid, "
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.";
1868
static char pjsua_acc_del_doc[] =
1869
"int py_pjsua.acc_del (int acc_id) "
1871
static char pjsua_acc_modify_doc[] =
1872
"int py_pjsua.acc_modify (int acc_id, py_pjsua.Acc_Config cfg) "
1873
"Modify account information.";
1874
static 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.";
1878
static 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.";
1883
static char pjsua_acc_set_registration_doc[] =
1884
"int py_pjsua.acc_set_registration (int acc_id, int renew) "
1885
"Update registration or perform unregistration.";
1886
static char pjsua_acc_get_info_doc[] =
1887
"py_pjsua.Acc_Info py_pjsua.acc_get_info (int acc_id) "
1888
"Get account information.";
1889
static char pjsua_enum_accs_doc[] =
1890
"int[] py_pjsua.enum_accs () "
1891
"Enum accounts all account ids.";
1892
static char pjsua_acc_enum_info_doc[] =
1893
"py_pjsua.Acc_Info[] py_pjsua.acc_enum_info () "
1894
"Enum accounts info.";
1895
static 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.";
1899
static 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.";
1903
static 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.";
1908
static 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.";
1914
/* END OF LIB ACCOUNT */
1921
* py_pjsua_buddy_config_default
1923
static PyObject *py_pjsua_buddy_config_default(PyObject *pSelf,
1926
PyObj_pjsua_buddy_config *obj;
1927
pjsua_buddy_config cfg;
1929
PJ_UNUSED_ARG(pSelf);
1931
if (!PyArg_ParseTuple(pArgs, "")) {
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);
1940
return (PyObject *)obj;
1944
* py_pjsua_get_buddy_count
1946
static PyObject *py_pjsua_get_buddy_count(PyObject *pSelf, PyObject *pArgs)
1950
PJ_UNUSED_ARG(pSelf);
1952
if (!PyArg_ParseTuple(pArgs, "")) {
1955
ret = pjsua_get_buddy_count();
1957
return Py_BuildValue("i", ret);
1961
* py_pjsua_buddy_is_valid
1963
static PyObject *py_pjsua_buddy_is_valid(PyObject *pSelf, PyObject *pArgs)
1968
PJ_UNUSED_ARG(pSelf);
1970
if (!PyArg_ParseTuple(pArgs, "i", &id)) {
1973
is_valid = pjsua_buddy_is_valid(id);
1975
return Py_BuildValue("i", is_valid);
1979
* py_pjsua_enum_buddies
1980
* !modified @ 241206
1982
static PyObject *py_pjsua_enum_buddies(PyObject *pSelf, PyObject *pArgs)
1987
pjsua_buddy_id id[PJSUA_MAX_BUDDIES];
1990
PJ_UNUSED_ARG(pSelf);
1992
if (!PyArg_ParseTuple(pArgs, "")) {
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]));
2002
return Py_BuildValue("O",list);
2006
* py_pjsua_buddy_get_info
2007
* !modified @ 071206
2009
static PyObject *py_pjsua_buddy_get_info(PyObject *pSelf, PyObject *pArgs)
2012
PyObj_pjsua_buddy_info * obj;
2013
pjsua_buddy_info info;
2016
PJ_UNUSED_ARG(pSelf);
2018
if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) {
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);
2035
* py_pjsua_buddy_add
2036
* !modified @ 061206
2038
static PyObject *py_pjsua_buddy_add(PyObject *pSelf, PyObject *pArgs)
2044
PJ_UNUSED_ARG(pSelf);
2046
if (!PyArg_ParseTuple(pArgs, "O", &bcObj)) {
2050
if (bcObj != Py_None) {
2051
pjsua_buddy_config cfg;
2052
PyObj_pjsua_buddy_config * bc;
2054
bc = (PyObj_pjsua_buddy_config *)bcObj;
2056
pjsua_buddy_config_default(&cfg);
2057
PyObj_pjsua_buddy_config_export(&cfg, bc);
2059
status = pjsua_buddy_add(&cfg, &buddy_id);
2062
buddy_id = PJSUA_INVALID_ID;
2064
return Py_BuildValue("ii", status, buddy_id);
2068
* py_pjsua_buddy_del
2070
static PyObject *py_pjsua_buddy_del(PyObject *pSelf, PyObject *pArgs)
2075
PJ_UNUSED_ARG(pSelf);
2077
if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) {
2082
status = pjsua_buddy_del(buddy_id);
2083
return Py_BuildValue("i", status);
2087
* py_pjsua_buddy_subscribe_pres
2089
static PyObject *py_pjsua_buddy_subscribe_pres(PyObject *pSelf, PyObject *pArgs)
2095
PJ_UNUSED_ARG(pSelf);
2097
if (!PyArg_ParseTuple(pArgs, "ii", &buddy_id, &subscribe)) {
2102
status = pjsua_buddy_subscribe_pres(buddy_id, subscribe);
2103
return Py_BuildValue("i", status);
2107
* py_pjsua_pres_dump
2109
static PyObject *py_pjsua_pres_dump(PyObject *pSelf, PyObject *pArgs)
2113
PJ_UNUSED_ARG(pSelf);
2115
if (!PyArg_ParseTuple(pArgs, "i", &verbose)) {
2120
pjsua_pres_dump(verbose);
2127
* !modified @ 071206
2129
static PyObject *py_pjsua_im_send(PyObject *pSelf, PyObject *pArgs)
2133
pj_str_t * mime_type, tmp_mime_type;
2134
pj_str_t to, content;
2138
pjsua_msg_data msg_data;
2140
PyObj_pjsua_msg_data * omd;
2145
PJ_UNUSED_ARG(pSelf);
2147
if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id,
2148
&st, &smt, &sc, &omdObj, &user_data))
2152
if (smt != Py_None) {
2153
mime_type = &tmp_mime_type;
2154
tmp_mime_type = PyString_to_pj_str(smt);
2158
to = PyString_to_pj_str(st);
2159
content = PyString_to_pj_str(sc);
2161
if (omdObj != Py_None) {
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);
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);
2174
status = pjsua_im_send(acc_id, &to, mime_type,
2175
&content, NULL, NULL);
2178
return Py_BuildValue("i",status);
2182
* py_pjsua_im_typing
2184
static PyObject *py_pjsua_im_typing(PyObject *pSelf, PyObject *pArgs)
2191
pjsua_msg_data msg_data;
2193
PyObj_pjsua_msg_data * omd;
2196
PJ_UNUSED_ARG(pSelf);
2198
if (!PyArg_ParseTuple(pArgs, "iOiO", &acc_id, &st, &is_typing, &omdObj)) {
2202
to = PyString_to_pj_str(st);
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);
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);
2214
status = pjsua_im_typing(acc_id, &to, is_typing, NULL);
2216
return Py_BuildValue("i",status);
2219
static char pjsua_buddy_config_default_doc[] =
2220
"py_pjsua.Buddy_Config py_pjsua.buddy_config_default () "
2221
"Set default values to the buddy config.";
2222
static char pjsua_get_buddy_count_doc[] =
2223
"int py_pjsua.get_buddy_count () "
2224
"Get total number of buddies.";
2225
static char pjsua_buddy_is_valid_doc[] =
2226
"int py_pjsua.buddy_is_valid (int buddy_id) "
2227
"Check if buddy ID is valid.";
2228
static char pjsua_enum_buddies_doc[] =
2229
"int[] py_pjsua.enum_buddies () "
2231
static char pjsua_buddy_get_info_doc[] =
2232
"py_pjsua.Buddy_Info py_pjsua.buddy_get_info (int buddy_id) "
2233
"Get detailed buddy info.";
2234
static char pjsua_buddy_add_doc[] =
2235
"int,int py_pjsua.buddy_add (py_pjsua.Buddy_Config cfg) "
2237
static char pjsua_buddy_del_doc[] =
2238
"int py_pjsua.buddy_del (int buddy_id) "
2240
static 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.";
2243
static char pjsua_pres_dump_doc[] =
2244
"void py_pjsua.pres_dump (int verbose) "
2245
"Dump presence subscriptions to log file.";
2246
static 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.";
2251
static 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.";
2256
/* END OF LIB BUDDY */
2263
* PyObj_pjsua_codec_info
2265
* !modified @ 071206
2270
/* Type-specific fields go here. */
2272
PyObject * codec_id;
2273
pj_uint8_t priority;
2275
} PyObj_pjsua_codec_info;
2279
* codec_info_dealloc
2280
* deletes a codec_info from memory
2281
* !modified @ 071206
2283
static void codec_info_dealloc(PyObj_pjsua_codec_info* self)
2285
Py_XDECREF(self->codec_id);
2287
self->ob_type->tp_free((PyObject*)self);
2293
* constructor for codec_info object
2294
* !modified @ 071206
2296
static PyObject * codec_info_new(PyTypeObject *type, PyObject *args,
2299
PyObj_pjsua_codec_info *self;
2301
PJ_UNUSED_ARG(args);
2302
PJ_UNUSED_ARG(kwds);
2304
self = (PyObj_pjsua_codec_info *)type->tp_alloc(type, 0);
2307
self->codec_id = PyString_FromString("");
2308
if (self->codec_id == NULL)
2316
return (PyObject *)self;
2320
* codec_info_members
2321
* !modified @ 071206
2323
static PyMemberDef codec_info_members[] =
2326
"codec_id", T_OBJECT_EX,
2327
offsetof(PyObj_pjsua_codec_info, codec_id), 0,
2328
"Codec unique identification."
2333
offsetof(PyObj_pjsua_codec_info, priority), 0,
2334
"Codec priority (integer 0-255)."
2339
{NULL} /* Sentinel */
2346
* PyTyp_pjsua_codec_info
2348
static PyTypeObject PyTyp_pjsua_codec_info =
2350
PyObject_HEAD_INIT(NULL)
2352
"py_pjsua.Codec_Info", /*tp_name*/
2353
sizeof(PyObj_pjsua_codec_info), /*tp_basicsize*/
2355
(destructor)codec_info_dealloc,/*tp_dealloc*/
2362
0, /*tp_as_sequence*/
2363
0, /*tp_as_mapping*/
2370
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2371
"Codec Info objects", /* tp_doc */
2372
0, /* tp_traverse */
2374
0, /* tp_richcompare */
2375
0, /* tp_weaklistoffset */
2377
0, /* tp_iternext */
2379
codec_info_members, /* tp_members */
2383
0, /* tp_descr_get */
2384
0, /* tp_descr_set */
2385
0, /* tp_dictoffset */
2388
codec_info_new, /* tp_new */
2393
* PyObj_pjsua_conf_port_info
2399
/* Type-specific fields go here. */
2403
unsigned clock_rate;
2404
unsigned channel_count;
2405
unsigned samples_per_frame;
2406
unsigned bits_per_sample;
2407
PyListObject * listeners;
2409
} PyObj_pjsua_conf_port_info;
2413
* conf_port_info_dealloc
2414
* deletes a conf_port_info from memory
2416
static void conf_port_info_dealloc(PyObj_pjsua_conf_port_info* self)
2418
Py_XDECREF(self->name);
2419
Py_XDECREF(self->listeners);
2420
self->ob_type->tp_free((PyObject*)self);
2425
* conf_port_info_new
2426
* constructor for conf_port_info object
2428
static PyObject * conf_port_info_new(PyTypeObject *type, PyObject *args,
2431
PyObj_pjsua_conf_port_info *self;
2433
PJ_UNUSED_ARG(args);
2434
PJ_UNUSED_ARG(kwds);
2436
self = (PyObj_pjsua_conf_port_info *)type->tp_alloc(type, 0);
2439
self->name = PyString_FromString("");
2440
if (self->name == NULL)
2446
self->listeners = (PyListObject *)PyList_New(0);
2447
if (self->listeners == NULL)
2453
return (PyObject *)self;
2457
* conf_port_info_members
2459
static PyMemberDef conf_port_info_members[] =
2463
offsetof(PyObj_pjsua_conf_port_info, slot_id), 0,
2464
"Conference port number."
2467
"name", T_OBJECT_EX,
2468
offsetof(PyObj_pjsua_conf_port_info, name), 0,
2472
"clock_rate", T_INT,
2473
offsetof(PyObj_pjsua_conf_port_info, clock_rate), 0,
2477
"channel_count", T_INT,
2478
offsetof(PyObj_pjsua_conf_port_info, channel_count), 0,
2479
"Number of channels."
2482
"samples_per_frame", T_INT,
2483
offsetof(PyObj_pjsua_conf_port_info, samples_per_frame), 0,
2484
"Samples per frame "
2487
"bits_per_sample", T_INT,
2488
offsetof(PyObj_pjsua_conf_port_info, bits_per_sample), 0,
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"
2498
{NULL} /* Sentinel */
2505
* PyTyp_pjsua_conf_port_info
2507
static PyTypeObject PyTyp_pjsua_conf_port_info =
2509
PyObject_HEAD_INIT(NULL)
2511
"py_pjsua.Conf_Port_Info", /*tp_name*/
2512
sizeof(PyObj_pjsua_conf_port_info), /*tp_basicsize*/
2514
(destructor)conf_port_info_dealloc,/*tp_dealloc*/
2521
0, /*tp_as_sequence*/
2522
0, /*tp_as_mapping*/
2529
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2530
"Conf Port Info objects", /* tp_doc */
2531
0, /* tp_traverse */
2533
0, /* tp_richcompare */
2534
0, /* tp_weaklistoffset */
2536
0, /* tp_iternext */
2538
conf_port_info_members, /* tp_members */
2542
0, /* tp_descr_get */
2543
0, /* tp_descr_set */
2544
0, /* tp_dictoffset */
2547
conf_port_info_new, /* tp_new */
2552
* PyObj_pjmedia_port
2557
/* Type-specific fields go here. */
2558
pjmedia_port * port;
2559
} PyObj_pjmedia_port;
2563
* PyTyp_pjmedia_port
2565
static PyTypeObject PyTyp_pjmedia_port =
2567
PyObject_HEAD_INIT(NULL)
2569
"py_pjsua.PJMedia_Port", /*tp_name*/
2570
sizeof(PyObj_pjmedia_port), /*tp_basicsize*/
2579
0, /*tp_as_sequence*/
2580
0, /*tp_as_mapping*/
2587
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2588
"pjmedia_port objects", /* tp_doc */
2593
* PyObj_pjmedia_snd_dev_info
2594
* PJMedia Snd Dev Info
2599
/* Type-specific fields go here. */
2602
unsigned input_count;
2603
unsigned output_count;
2604
unsigned default_samples_per_sec;
2607
} PyObj_pjmedia_snd_dev_info;
2611
* pjmedia_snd_dev_info_dealloc
2612
* deletes a pjmedia_snd_dev_info from memory
2614
static void pjmedia_snd_dev_info_dealloc(PyObj_pjmedia_snd_dev_info* self)
2616
Py_XDECREF(self->name);
2617
self->ob_type->tp_free((PyObject*)self);
2622
* pjmedia_snd_dev_info_new
2623
* constructor for pjmedia_snd_dev_info object
2625
static PyObject * pjmedia_snd_dev_info_new(PyTypeObject *type, PyObject *args,
2628
PyObj_pjmedia_snd_dev_info *self;
2630
PJ_UNUSED_ARG(args);
2631
PJ_UNUSED_ARG(kwds);
2633
self = (PyObj_pjmedia_snd_dev_info *)type->tp_alloc(type, 0);
2636
self->name = PyString_FromString("");
2637
if (self->name == NULL)
2644
return (PyObject *)self;
2648
* pjmedia_snd_dev_info_members
2650
static PyMemberDef pjmedia_snd_dev_info_members[] =
2654
"name", T_OBJECT_EX,
2655
offsetof(PyObj_pjmedia_snd_dev_info, name), 0,
2659
"input_count", T_INT,
2660
offsetof(PyObj_pjmedia_snd_dev_info, input_count), 0,
2661
"Max number of input channels"
2664
"output_count", T_INT,
2665
offsetof(PyObj_pjmedia_snd_dev_info, output_count), 0,
2666
"Max number of output channels"
2669
"default_samples_per_sec", T_INT,
2670
offsetof(PyObj_pjmedia_snd_dev_info, default_samples_per_sec), 0,
2671
"Default sampling rate."
2675
{NULL} /* Sentinel */
2682
* PyTyp_pjmedia_snd_dev_info
2684
static PyTypeObject PyTyp_pjmedia_snd_dev_info =
2686
PyObject_HEAD_INIT(NULL)
2688
"py_pjsua.PJMedia_Snd_Dev_Info", /*tp_name*/
2689
sizeof(PyObj_pjmedia_snd_dev_info), /*tp_basicsize*/
2691
(destructor)pjmedia_snd_dev_info_dealloc,/*tp_dealloc*/
2698
0, /*tp_as_sequence*/
2699
0, /*tp_as_mapping*/
2706
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2707
"PJMedia Snd Dev Info objects", /* tp_doc */
2708
0, /* tp_traverse */
2710
0, /* tp_richcompare */
2711
0, /* tp_weaklistoffset */
2713
0, /* tp_iternext */
2715
pjmedia_snd_dev_info_members, /* tp_members */
2719
0, /* tp_descr_get */
2720
0, /* tp_descr_set */
2721
0, /* tp_dictoffset */
2724
pjmedia_snd_dev_info_new, /* tp_new */
2729
* PyObj_pjmedia_codec_param_info
2730
* PJMedia Codec Param Info
2735
/* Type-specific fields go here. */
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;
2744
} PyObj_pjmedia_codec_param_info;
2749
* pjmedia_codec_param_info_members
2751
static PyMemberDef pjmedia_codec_param_info_members[] =
2755
"clock_rate", T_INT,
2756
offsetof(PyObj_pjmedia_codec_param_info, clock_rate), 0,
2757
"Sampling rate in Hz"
2760
"channel_cnt", T_INT,
2761
offsetof(PyObj_pjmedia_codec_param_info, channel_cnt), 0,
2766
offsetof(PyObj_pjmedia_codec_param_info, avg_bps), 0,
2767
"Average bandwidth in bits/sec"
2771
offsetof(PyObj_pjmedia_codec_param_info, frm_ptime), 0,
2772
"Base frame ptime in msec."
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"
2781
offsetof(PyObj_pjmedia_codec_param_info, pt), 0,
2785
{NULL} /* Sentinel */
2792
* PyTyp_pjmedia_codec_param_info
2794
static PyTypeObject PyTyp_pjmedia_codec_param_info =
2796
PyObject_HEAD_INIT(NULL)
2798
"py_pjsua.PJMedia_Codec_Param_Info", /*tp_name*/
2799
sizeof(PyObj_pjmedia_codec_param_info), /*tp_basicsize*/
2808
0, /*tp_as_sequence*/
2809
0, /*tp_as_mapping*/
2816
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2817
"PJMedia Codec Param Info objects", /* tp_doc */
2818
0, /* tp_traverse */
2820
0, /* tp_richcompare */
2821
0, /* tp_weaklistoffset */
2823
0, /* tp_iternext */
2825
pjmedia_codec_param_info_members, /* tp_members */
2831
* PyObj_pjmedia_codec_param_setting
2832
* PJMedia Codec Param Setting
2837
/* Type-specific fields go here. */
2838
pj_uint8_t frm_per_pkt;
2844
pj_uint8_t enc_fmtp_mode;
2845
pj_uint8_t dec_fmtp_mode;
2847
} PyObj_pjmedia_codec_param_setting;
2852
* pjmedia_codec_param_setting_members
2854
static PyMemberDef pjmedia_codec_param_setting_members[] =
2858
"frm_per_pkt", T_INT,
2859
offsetof(PyObj_pjmedia_codec_param_setting, frm_per_pkt), 0,
2860
"Number of frames per packet"
2864
offsetof(PyObj_pjmedia_codec_param_setting, vad), 0,
2865
"Voice Activity Detector"
2869
offsetof(PyObj_pjmedia_codec_param_setting, penh), 0,
2870
"Perceptual Enhancement"
2874
offsetof(PyObj_pjmedia_codec_param_setting, plc), 0,
2875
"Packet loss concealment"
2879
offsetof(PyObj_pjmedia_codec_param_setting, reserved), 0,
2880
"Reserved, must be zero"
2884
offsetof(PyObj_pjmedia_codec_param_setting, cng), 0,
2885
"Comfort Noise Generator"
2888
"enc_fmtp_mode", T_INT,
2889
offsetof(PyObj_pjmedia_codec_param_setting, enc_fmtp_mode), 0,
2890
"Mode param in fmtp (def:0)"
2893
"dec_fmtp_mode", T_INT,
2894
offsetof(PyObj_pjmedia_codec_param_setting, dec_fmtp_mode), 0,
2895
"Mode param in fmtp (def:0)"
2898
{NULL} /* Sentinel */
2905
* PyTyp_pjmedia_codec_param_setting
2907
static PyTypeObject PyTyp_pjmedia_codec_param_setting =
2909
PyObject_HEAD_INIT(NULL)
2911
"py_pjsua.PJMedia_Codec_Param_Setting", /*tp_name*/
2912
sizeof(PyObj_pjmedia_codec_param_setting), /*tp_basicsize*/
2921
0, /*tp_as_sequence*/
2922
0, /*tp_as_mapping*/
2929
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2930
"PJMedia Codec Param Setting objects", /* tp_doc */
2931
0, /* tp_traverse */
2933
0, /* tp_richcompare */
2934
0, /* tp_weaklistoffset */
2936
0, /* tp_iternext */
2938
pjmedia_codec_param_setting_members, /* tp_members */
2944
* PyObj_pjmedia_codec_param
2945
* PJMedia Codec Param
2950
/* Type-specific fields go here. */
2952
PyObj_pjmedia_codec_param_info * info;
2953
PyObj_pjmedia_codec_param_setting * setting;
2955
} PyObj_pjmedia_codec_param;
2959
* pjmedia_codec_param_dealloc
2960
* deletes a pjmedia_codec_param from memory
2962
static void pjmedia_codec_param_dealloc(PyObj_pjmedia_codec_param* self)
2964
Py_XDECREF(self->info);
2965
Py_XDECREF(self->setting);
2966
self->ob_type->tp_free((PyObject*)self);
2971
* pjmedia_codec_param_new
2972
* constructor for pjmedia_codec_param object
2974
static PyObject * pjmedia_codec_param_new(PyTypeObject *type, PyObject *args,
2977
PyObj_pjmedia_codec_param *self;
2979
PJ_UNUSED_ARG(args);
2980
PJ_UNUSED_ARG(kwds);
2982
self = (PyObj_pjmedia_codec_param *)type->tp_alloc(type, 0);
2985
self->info = (PyObj_pjmedia_codec_param_info *)
2986
PyType_GenericNew(&PyTyp_pjmedia_codec_param_info, NULL, NULL);
2987
if (self->info == NULL)
2992
self->setting = (PyObj_pjmedia_codec_param_setting *)
2993
PyType_GenericNew(&PyTyp_pjmedia_codec_param_setting, NULL, NULL);
2994
if (self->setting == NULL)
3000
return (PyObject *)self;
3004
* pjmedia_codec_param_members
3006
static PyMemberDef pjmedia_codec_param_members[] =
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."
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 "
3028
{NULL} /* Sentinel */
3035
* PyTyp_pjmedia_codec_param
3037
static PyTypeObject PyTyp_pjmedia_codec_param =
3039
PyObject_HEAD_INIT(NULL)
3041
"py_pjsua.PJMedia_Codec_Param", /*tp_name*/
3042
sizeof(PyObj_pjmedia_codec_param), /*tp_basicsize*/
3044
(destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/
3051
0, /*tp_as_sequence*/
3052
0, /*tp_as_mapping*/
3059
Py_TPFLAGS_DEFAULT, /*tp_flags*/
3060
"PJMedia Codec Param objects", /* tp_doc */
3061
0, /* tp_traverse */
3063
0, /* tp_richcompare */
3064
0, /* tp_weaklistoffset */
3066
0, /* tp_iternext */
3068
pjmedia_codec_param_members, /* tp_members */
3072
0, /* tp_descr_get */
3073
0, /* tp_descr_set */
3074
0, /* tp_dictoffset */
3077
pjmedia_codec_param_new, /* tp_new */
3082
* py_pjsua_conf_get_max_ports
3084
static PyObject *py_pjsua_conf_get_max_ports
3085
(PyObject *pSelf, PyObject *pArgs)
3089
PJ_UNUSED_ARG(pSelf);
3091
if (!PyArg_ParseTuple(pArgs, ""))
3095
ret = pjsua_conf_get_max_ports();
3097
return Py_BuildValue("i", ret);
3101
* py_pjsua_conf_get_active_ports
3103
static PyObject *py_pjsua_conf_get_active_ports
3104
(PyObject *pSelf, PyObject *pArgs)
3108
PJ_UNUSED_ARG(pSelf);
3110
if (!PyArg_ParseTuple(pArgs, ""))
3114
ret = pjsua_conf_get_active_ports();
3116
return Py_BuildValue("i", ret);
3120
* py_pjsua_enum_conf_ports
3121
* !modified @ 241206
3123
static PyObject *py_pjsua_enum_conf_ports(PyObject *pSelf, PyObject *pArgs)
3128
pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS];
3131
PJ_UNUSED_ARG(pSelf);
3133
if (!PyArg_ParseTuple(pArgs, ""))
3138
c = PJ_ARRAY_SIZE(id);
3139
status = pjsua_enum_conf_ports(id, &c);
3141
list = PyList_New(c);
3142
for (i = 0; i < c; i++)
3144
int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
3151
return Py_BuildValue("O",list);
3155
* py_pjsua_conf_get_port_info
3157
static PyObject *py_pjsua_conf_get_port_info
3158
(PyObject *pSelf, PyObject *pArgs)
3161
PyObj_pjsua_conf_port_info * obj;
3162
pjsua_conf_port_info info;
3166
PJ_UNUSED_ARG(pSelf);
3168
if (!PyArg_ParseTuple(pArgs, "i", &id))
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;
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);
3189
return Py_BuildValue("O", obj);
3193
* py_pjsua_conf_add_port
3195
static PyObject *py_pjsua_conf_add_port
3196
(PyObject *pSelf, PyObject *pArgs)
3199
PyObject * oportObj;
3200
PyObj_pjmedia_port * oport;
3201
pjmedia_port * port;
3202
PyObject * opoolObj;
3203
PyObj_pj_pool * opool;
3208
PJ_UNUSED_ARG(pSelf);
3210
if (!PyArg_ParseTuple(pArgs, "OO", &opoolObj, &oportObj))
3214
if (opoolObj != Py_None)
3216
opool = (PyObj_pj_pool *)opoolObj;
3222
if (oportObj != Py_None)
3224
oport = (PyObj_pjmedia_port *)oportObj;
3231
status = pjsua_conf_add_port(pool, port, &p_id);
3234
return Py_BuildValue("ii", status, p_id);
3238
* py_pjsua_conf_remove_port
3240
static PyObject *py_pjsua_conf_remove_port
3241
(PyObject *pSelf, PyObject *pArgs)
3246
PJ_UNUSED_ARG(pSelf);
3248
if (!PyArg_ParseTuple(pArgs, "i", &id))
3253
status = pjsua_conf_remove_port(id);
3256
return Py_BuildValue("i", status);
3260
* py_pjsua_conf_connect
3262
static PyObject *py_pjsua_conf_connect
3263
(PyObject *pSelf, PyObject *pArgs)
3268
PJ_UNUSED_ARG(pSelf);
3270
if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink))
3275
status = pjsua_conf_connect(source, sink);
3278
return Py_BuildValue("i", status);
3282
* py_pjsua_conf_disconnect
3284
static PyObject *py_pjsua_conf_disconnect
3285
(PyObject *pSelf, PyObject *pArgs)
3290
PJ_UNUSED_ARG(pSelf);
3292
if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink))
3297
status = pjsua_conf_disconnect(source, sink);
3300
return Py_BuildValue("i", status);
3304
* py_pjsua_player_create
3306
static PyObject *py_pjsua_player_create
3307
(PyObject *pSelf, PyObject *pArgs)
3311
PyObject * filename;
3315
PJ_UNUSED_ARG(pSelf);
3317
if (!PyArg_ParseTuple(pArgs, "Oi", &filename, &options))
3321
str.ptr = PyString_AsString(filename);
3322
str.slen = strlen(PyString_AsString(filename));
3323
status = pjsua_player_create(&str, options, &id);
3325
return Py_BuildValue("ii", status, id);
3329
* py_pjsua_player_get_conf_port
3331
static PyObject *py_pjsua_player_get_conf_port
3332
(PyObject *pSelf, PyObject *pArgs)
3337
PJ_UNUSED_ARG(pSelf);
3339
if (!PyArg_ParseTuple(pArgs, "i", &id))
3344
port_id = pjsua_player_get_conf_port(id);
3347
return Py_BuildValue("i", port_id);
3351
* py_pjsua_player_set_pos
3353
static PyObject *py_pjsua_player_set_pos
3354
(PyObject *pSelf, PyObject *pArgs)
3357
pj_uint32_t samples;
3360
PJ_UNUSED_ARG(pSelf);
3362
if (!PyArg_ParseTuple(pArgs, "iI", &id, &samples))
3367
status = pjsua_player_set_pos(id, samples);
3370
return Py_BuildValue("i", status);
3374
* py_pjsua_player_destroy
3376
static PyObject *py_pjsua_player_destroy
3377
(PyObject *pSelf, PyObject *pArgs)
3382
PJ_UNUSED_ARG(pSelf);
3384
if (!PyArg_ParseTuple(pArgs, "i", &id))
3389
status = pjsua_player_destroy(id);
3392
return Py_BuildValue("i", status);
3396
* py_pjsua_recorder_create
3397
* !modified @ 261206
3399
static PyObject *py_pjsua_recorder_create
3400
(PyObject *pSelf, PyObject *pArgs)
3405
PyObject * filename;
3407
PyObject * enc_param;
3413
PJ_UNUSED_ARG(pSelf);
3415
if (!PyArg_ParseTuple(pArgs, "OiOii", &filename,
3416
&enc_type, &enc_param, &max_size, &options))
3420
str.ptr = PyString_AsString(filename);
3421
str.slen = strlen(PyString_AsString(filename));
3422
if (enc_param != Py_None)
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);
3429
status = pjsua_recorder_create
3430
(&str, enc_type, NULL, max_size, options, &p_id);
3432
return Py_BuildValue("ii", status, p_id);
3436
* py_pjsua_recorder_get_conf_port
3438
static PyObject *py_pjsua_recorder_get_conf_port
3439
(PyObject *pSelf, PyObject *pArgs)
3444
PJ_UNUSED_ARG(pSelf);
3446
if (!PyArg_ParseTuple(pArgs, "i", &id))
3451
port_id = pjsua_recorder_get_conf_port(id);
3454
return Py_BuildValue("i", port_id);
3458
* py_pjsua_recorder_destroy
3460
static PyObject *py_pjsua_recorder_destroy
3461
(PyObject *pSelf, PyObject *pArgs)
3466
PJ_UNUSED_ARG(pSelf);
3468
if (!PyArg_ParseTuple(pArgs, "i", &id))
3473
status = pjsua_recorder_destroy(id);
3476
return Py_BuildValue("i", status);
3480
* py_pjsua_enum_snd_devs
3482
static PyObject *py_pjsua_enum_snd_devs(PyObject *pSelf, PyObject *pArgs)
3487
pjmedia_snd_dev_info info[SND_DEV_NUM];
3490
PJ_UNUSED_ARG(pSelf);
3492
if (!PyArg_ParseTuple(pArgs, ""))
3497
c = PJ_ARRAY_SIZE(info);
3498
status = pjsua_enum_snd_devs(info, &c);
3500
list = PyList_New(c);
3501
for (i = 0; i < c; i++)
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++)
3517
str[j] = info[i].name[j];
3519
obj->name = PyString_FromStringAndSize(str, SND_NAME_LEN);
3521
ret = PyList_SetItem(list, i, (PyObject *)obj);
3528
return Py_BuildValue("O",list);
3532
* py_pjsua_get_snd_dev
3534
static PyObject *py_pjsua_get_snd_dev
3535
(PyObject *pSelf, PyObject *pArgs)
3537
int capture_dev, playback_dev;
3540
PJ_UNUSED_ARG(pSelf);
3542
if (!PyArg_ParseTuple(pArgs, ""))
3547
status = pjsua_get_snd_dev(&capture_dev, &playback_dev);
3550
return Py_BuildValue("ii", capture_dev, playback_dev);
3554
* py_pjsua_set_snd_dev
3556
static PyObject *py_pjsua_set_snd_dev
3557
(PyObject *pSelf, PyObject *pArgs)
3559
int capture_dev, playback_dev;
3562
PJ_UNUSED_ARG(pSelf);
3564
if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev))
3569
status = pjsua_set_snd_dev(capture_dev, playback_dev);
3572
return Py_BuildValue("i", status);
3576
* py_pjsua_set_null_snd_dev
3578
static PyObject *py_pjsua_set_null_snd_dev
3579
(PyObject *pSelf, PyObject *pArgs)
3584
PJ_UNUSED_ARG(pSelf);
3586
if (!PyArg_ParseTuple(pArgs, ""))
3591
status = pjsua_set_null_snd_dev();
3594
return Py_BuildValue("i", status);
3598
* py_pjsua_set_no_snd_dev
3600
static PyObject *py_pjsua_set_no_snd_dev
3601
(PyObject *pSelf, PyObject *pArgs)
3604
PyObj_pjmedia_port * obj;
3606
PJ_UNUSED_ARG(pSelf);
3608
if (!PyArg_ParseTuple(pArgs, ""))
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);
3622
static PyObject *py_pjsua_set_ec
3623
(PyObject *pSelf, PyObject *pArgs)
3629
PJ_UNUSED_ARG(pSelf);
3631
if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options))
3636
status = pjsua_set_ec(tail_ms, options);
3639
return Py_BuildValue("i", status);
3643
* py_pjsua_get_ec_tail
3645
static PyObject *py_pjsua_get_ec_tail
3646
(PyObject *pSelf, PyObject *pArgs)
3652
PJ_UNUSED_ARG(pSelf);
3654
if (!PyArg_ParseTuple(pArgs, ""))
3659
status = pjsua_get_ec_tail(&p_tail_ms);
3662
return Py_BuildValue("i", p_tail_ms);
3666
* py_pjsua_enum_codecs
3667
* !modified @ 261206
3669
static PyObject *py_pjsua_enum_codecs(PyObject *pSelf, PyObject *pArgs)
3674
pjsua_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS];
3677
PJ_UNUSED_ARG(pSelf);
3679
if (!PyArg_ParseTuple(pArgs, ""))
3684
c = PJ_ARRAY_SIZE(info);
3685
status = pjsua_enum_codecs(info, &c);
3687
list = PyList_New(c);
3688
for (i = 0; i < c; i++)
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++)
3700
obj->buf_[j] = info[i].buf_[j];
3702
ret = PyList_SetItem(list, i, (PyObject *)obj);
3709
return Py_BuildValue("O",list);
3713
* py_pjsua_codec_set_priority
3715
static PyObject *py_pjsua_codec_set_priority
3716
(PyObject *pSelf, PyObject *pArgs)
3722
pj_uint8_t priority;
3724
PJ_UNUSED_ARG(pSelf);
3726
if (!PyArg_ParseTuple(pArgs, "OB", &id, &priority))
3730
str.ptr = PyString_AsString(id);
3731
str.slen = strlen(PyString_AsString(id));
3732
status = pjsua_codec_set_priority(&str, priority);
3735
return Py_BuildValue("i", status);
3739
* py_pjsua_codec_get_param
3741
static PyObject *py_pjsua_codec_get_param
3742
(PyObject *pSelf, PyObject *pArgs)
3748
pjmedia_codec_param param;
3749
PyObj_pjmedia_codec_param *obj;
3751
PJ_UNUSED_ARG(pSelf);
3753
if (!PyArg_ParseTuple(pArgs, "O", &id))
3757
str.ptr = PyString_AsString(id);
3758
str.slen = strlen(PyString_AsString(id));
3759
status = pjsua_codec_get_param(&str, ¶m);
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;
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;
3778
return Py_BuildValue("O", obj);
3781
* py_pjsua_codec_set_param
3783
static PyObject *py_pjsua_codec_set_param
3784
(PyObject *pSelf, PyObject *pArgs)
3790
pjmedia_codec_param param;
3792
PyObj_pjmedia_codec_param *obj;
3794
PJ_UNUSED_ARG(pSelf);
3796
if (!PyArg_ParseTuple(pArgs, "OO", &id, &tmpObj))
3801
str.ptr = PyString_AsString(id);
3802
str.slen = strlen(PyString_AsString(id));
3803
if (tmpObj != Py_None)
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;
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, ¶m);
3823
status = pjsua_codec_set_param(&str, NULL);
3825
return Py_BuildValue("i", status);
3828
static char pjsua_conf_get_max_ports_doc[] =
3829
"int py_pjsua.conf_get_max_ports () "
3830
"Get maxinum number of conference ports.";
3831
static 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.";
3834
static char pjsua_enum_conf_ports_doc[] =
3835
"int[] py_pjsua.enum_conf_ports () "
3836
"Enumerate all conference ports.";
3837
static 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";
3840
static 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.";
3848
static 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.";
3853
static 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.";
3863
static 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.";
3866
static 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.";
3870
static char pjsua_player_get_conf_port_doc[] =
3871
"int py_pjsua.player_get_conf_port (int) "
3872
"Get conference port ID associated with player.";
3873
static char pjsua_player_set_pos_doc[] =
3874
"int py_pjsua.player_set_pos (int id, int samples) "
3875
"Set playback position.";
3876
static 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.";
3880
static 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').";
3887
static char pjsua_recorder_get_conf_port_doc[] =
3888
"int py_pjsua.recorder_get_conf_port (int id) "
3889
"Get conference port associated with recorder.";
3890
static char pjsua_recorder_destroy_doc[] =
3891
"int py_pjsua.recorder_destroy (int id) "
3892
"Destroy recorder (this will complete recording).";
3893
static char pjsua_enum_snd_devs_doc[] =
3894
"py_pjsua.PJMedia_Snd_Dev_Info[] py_pjsua.enum_snd_devs (int count) "
3895
"Enum sound devices.";
3896
static 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.";
3903
static 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.";
3907
static 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.";
3912
static 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.";
3917
static 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.";
3920
static char pjsua_get_ec_tail_doc[] =
3921
"int py_pjsua.get_ec_tail () "
3922
"Get current echo canceller tail length.";
3923
static char pjsua_enum_codecs_doc[] =
3924
"py_pjsua.Codec_Info[] py_pjsua.enum_codecs () "
3925
"Enum all supported codecs in the system.";
3926
static char pjsua_codec_set_priority_doc[] =
3927
"int py_pjsua.codec_set_priority (string id, int priority) "
3928
"Change codec priority.";
3929
static char pjsua_codec_get_param_doc[] =
3930
"py_pjsua.PJMedia_Codec_Param py_pjsua.codec_get_param (string id) "
3931
"Get codec parameters";
3932
static 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.";
3937
/* END OF LIB MEDIA */
3948
/* Type-specific fields go here. */
3952
} PyObj_pj_time_val;
3957
* pj_time_val_members
3959
static PyMemberDef pj_time_val_members[] =
3964
offsetof(PyObj_pj_time_val, sec), 0,
3965
"The seconds part of the time"
3969
offsetof(PyObj_pj_time_val, sec), 0,
3970
"The milliseconds fraction of the time"
3974
{NULL} /* Sentinel */
3983
static PyTypeObject PyTyp_pj_time_val =
3985
PyObject_HEAD_INIT(NULL)
3987
"py_pjsua.PJ_Time_Val", /*tp_name*/
3988
sizeof(PyObj_pj_time_val), /*tp_basicsize*/
3997
0, /*tp_as_sequence*/
3998
0, /*tp_as_mapping*/
4005
Py_TPFLAGS_DEFAULT, /*tp_flags*/
4006
"PJ Time Val objects", /* tp_doc */
4007
0, /* tp_traverse */
4009
0, /* tp_richcompare */
4010
0, /* tp_weaklistoffset */
4012
0, /* tp_iternext */
4014
pj_time_val_members, /* tp_members */
4020
* PyObj_pjsua_call_info
4026
/* Type-specific fields go here. */
4031
PyObject * local_info;
4032
PyObject * local_contact;
4033
PyObject * remote_info;
4034
PyObject * remote_contact;
4037
PyObject * state_text;
4039
PyObject * last_status_text;
4043
PyObj_pj_time_val * connect_duration;
4044
PyObj_pj_time_val * total_duration;
4046
char local_info[128];
4047
char local_contact[128];
4048
char remote_info[128];
4049
char remote_contact[128];
4051
char last_status_text[128];
4054
} PyObj_pjsua_call_info;
4059
* deletes a call_info from memory
4061
static void call_info_dealloc(PyObj_pjsua_call_info* self)
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);
4078
* constructor for call_info object
4080
static PyObject * call_info_new(PyTypeObject *type, PyObject *args,
4083
PyObj_pjsua_call_info *self;
4085
PJ_UNUSED_ARG(args);
4086
PJ_UNUSED_ARG(kwds);
4088
self = (PyObj_pjsua_call_info *)type->tp_alloc(type, 0);
4091
self->local_info = PyString_FromString("");
4092
if (self->local_info == NULL)
4097
self->local_contact = PyString_FromString("");
4098
if (self->local_contact == NULL)
4103
self->remote_info = PyString_FromString("");
4104
if (self->remote_info == NULL)
4109
self->remote_contact = PyString_FromString("");
4110
if (self->remote_contact == NULL)
4115
self->call_id = PyString_FromString("");
4116
if (self->call_id == NULL)
4121
self->state_text = PyString_FromString("");
4122
if (self->state_text == NULL)
4127
self->last_status_text = PyString_FromString("");
4128
if (self->last_status_text == NULL)
4133
self->connect_duration = (PyObj_pj_time_val *)PyType_GenericNew
4134
(&PyTyp_pj_time_val,NULL,NULL);
4135
if (self->connect_duration == NULL)
4140
self->total_duration = (PyObj_pj_time_val *)PyType_GenericNew
4141
(&PyTyp_pj_time_val,NULL,NULL);
4142
if (self->total_duration == NULL)
4148
return (PyObject *)self;
4154
static PyMemberDef call_info_members[] =
4158
offsetof(PyObj_pjsua_call_info, id), 0,
4159
"Call identification"
4163
offsetof(PyObj_pjsua_call_info, role), 0,
4164
"Initial call role (UAC == caller)"
4168
offsetof(PyObj_pjsua_call_info, acc_id), 0,
4169
"The account ID where this call belongs."
4172
"local_info", T_OBJECT_EX,
4173
offsetof(PyObj_pjsua_call_info, local_info), 0,
4177
"local_contact", T_OBJECT_EX,
4178
offsetof(PyObj_pjsua_call_info, local_contact), 0,
4182
"remote_info", T_OBJECT_EX,
4183
offsetof(PyObj_pjsua_call_info, remote_info), 0,
4187
"remote_contact", T_OBJECT_EX,
4188
offsetof(PyObj_pjsua_call_info, remote_contact), 0,
4192
"call_id", T_OBJECT_EX,
4193
offsetof(PyObj_pjsua_call_info, call_id), 0,
4194
"Dialog Call-ID string"
4198
offsetof(PyObj_pjsua_call_info, state), 0,
4202
"state_text", T_OBJECT_EX,
4203
offsetof(PyObj_pjsua_call_info, state_text), 0,
4204
"Text describing the state "
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"
4212
"last_status_text", T_OBJECT_EX,
4213
offsetof(PyObj_pjsua_call_info, last_status_text), 0,
4214
"The reason phrase describing the status."
4217
"media_status", T_INT,
4218
offsetof(PyObj_pjsua_call_info, media_status), 0,
4219
"Call media status."
4223
offsetof(PyObj_pjsua_call_info, media_dir), 0,
4228
offsetof(PyObj_pjsua_call_info, conf_slot), 0,
4229
"The conference port number for the call"
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)"
4237
"total_duration", T_OBJECT_EX,
4238
offsetof(PyObj_pjsua_call_info, total_duration), 0,
4239
"Total call duration, including set-up time"
4242
{NULL} /* Sentinel */
4249
* PyTyp_pjsua_call_info
4251
static PyTypeObject PyTyp_pjsua_call_info =
4253
PyObject_HEAD_INIT(NULL)
4255
"py_pjsua.Call_Info", /*tp_name*/
4256
sizeof(PyObj_pjsua_call_info), /*tp_basicsize*/
4258
(destructor)call_info_dealloc,/*tp_dealloc*/
4265
0, /*tp_as_sequence*/
4266
0, /*tp_as_mapping*/
4273
Py_TPFLAGS_DEFAULT, /*tp_flags*/
4274
"Call Info objects", /* tp_doc */
4275
0, /* tp_traverse */
4277
0, /* tp_richcompare */
4278
0, /* tp_weaklistoffset */
4280
0, /* tp_iternext */
4282
call_info_members, /* tp_members */
4286
0, /* tp_descr_get */
4287
0, /* tp_descr_set */
4288
0, /* tp_dictoffset */
4291
call_info_new, /* tp_new */
4296
* py_pjsua_call_get_max_count
4298
static PyObject *py_pjsua_call_get_max_count
4299
(PyObject *pSelf, PyObject *pArgs)
4303
PJ_UNUSED_ARG(pSelf);
4305
if (!PyArg_ParseTuple(pArgs, ""))
4310
count = pjsua_call_get_max_count();
4313
return Py_BuildValue("i", count);
4317
* py_pjsua_call_get_count
4319
static PyObject *py_pjsua_call_get_count
4320
(PyObject *pSelf, PyObject *pArgs)
4325
PJ_UNUSED_ARG(pSelf);
4327
if (!PyArg_ParseTuple(pArgs, ""))
4332
count = pjsua_call_get_count();
4335
return Py_BuildValue("i", count);
4339
* py_pjsua_enum_calls
4341
static PyObject *py_pjsua_enum_calls(PyObject *pSelf, PyObject *pArgs)
4346
pjsua_transport_id id[PJSUA_MAX_CALLS];
4349
PJ_UNUSED_ARG(pSelf);
4351
if (!PyArg_ParseTuple(pArgs, ""))
4356
c = PJ_ARRAY_SIZE(id);
4357
status = pjsua_enum_calls(id, &c);
4359
list = PyList_New(c);
4360
for (i = 0; i < c; i++)
4362
int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i]));
4369
return Py_BuildValue("O",list);
4373
* py_pjsua_call_make_call
4375
static PyObject *py_pjsua_call_make_call
4376
(PyObject *pSelf, PyObject *pArgs)
4383
pjsua_msg_data msg_data;
4385
PyObj_pjsua_msg_data * omd;
4390
PJ_UNUSED_ARG(pSelf);
4392
if (!PyArg_ParseTuple
4393
(pArgs, "iOIiO", &acc_id, &sd, &options, &user_data, &omdObj))
4398
dst_uri.ptr = PyString_AsString(sd);
4399
dst_uri.slen = strlen(PyString_AsString(sd));
4400
if (omdObj != Py_None)
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);
4415
status = pjsua_call_make_call(acc_id, &dst_uri,
4416
options, (void*)user_data, NULL, &call_id);
4419
return Py_BuildValue("ii",status, call_id);
4424
* py_pjsua_call_is_active
4426
static PyObject *py_pjsua_call_is_active
4427
(PyObject *pSelf, PyObject *pArgs)
4432
PJ_UNUSED_ARG(pSelf);
4434
if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4439
isActive = pjsua_call_is_active(call_id);
4442
return Py_BuildValue("i", isActive);
4446
* py_pjsua_call_has_media
4448
static PyObject *py_pjsua_call_has_media
4449
(PyObject *pSelf, PyObject *pArgs)
4454
PJ_UNUSED_ARG(pSelf);
4456
if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4461
hasMedia = pjsua_call_has_media(call_id);
4464
return Py_BuildValue("i", hasMedia);
4468
* py_pjsua_call_get_conf_port
4470
static PyObject *py_pjsua_call_get_conf_port
4471
(PyObject *pSelf, PyObject *pArgs)
4476
PJ_UNUSED_ARG(pSelf);
4478
if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4483
port_id = pjsua_call_get_conf_port(call_id);
4486
return Py_BuildValue("i", port_id);
4490
* py_pjsua_call_get_info
4492
static PyObject *py_pjsua_call_get_info
4493
(PyObject *pSelf, PyObject *pArgs)
4497
PyObj_pjsua_call_info * oi;
4498
pjsua_call_info info;
4500
PJ_UNUSED_ARG(pSelf);
4502
if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4508
status = pjsua_call_get_info(call_id, &info);
4509
if (status == PJ_SUCCESS)
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);
4528
oi->call_id = PyString_FromStringAndSize(info.call_id.ptr,
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;
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);
4554
return Py_BuildValue("O", oi);
4562
* py_pjsua_call_set_user_data
4564
static PyObject *py_pjsua_call_set_user_data
4565
(PyObject *pSelf, PyObject *pArgs)
4571
PJ_UNUSED_ARG(pSelf);
4573
if (!PyArg_ParseTuple(pArgs, "ii", &call_id, &user_data))
4578
status = pjsua_call_set_user_data(call_id, (void*)user_data);
4581
return Py_BuildValue("i", status);
4585
* py_pjsua_call_get_user_data
4587
static PyObject *py_pjsua_call_get_user_data
4588
(PyObject *pSelf, PyObject *pArgs)
4593
PJ_UNUSED_ARG(pSelf);
4595
if (!PyArg_ParseTuple(pArgs, "i", &call_id))
4600
user_data = pjsua_call_get_user_data(call_id);
4603
return Py_BuildValue("i", (int)user_data);
4607
* py_pjsua_call_answer
4609
static PyObject *py_pjsua_call_answer
4610
(PyObject *pSelf, PyObject *pArgs)
4614
pj_str_t * reason, tmp_reason;
4617
pjsua_msg_data msg_data;
4619
PyObj_pjsua_msg_data * omd;
4622
PJ_UNUSED_ARG(pSelf);
4624
if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omdObj))
4632
reason = &tmp_reason;
4633
tmp_reason.ptr = PyString_AsString(sr);
4634
tmp_reason.slen = strlen(PyString_AsString(sr));
4636
if (omdObj != Py_None)
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);
4647
status = pjsua_call_answer(call_id, code, reason, &msg_data);
4649
pj_pool_release(pool);
4652
status = pjsua_call_answer(call_id, code, reason, NULL);
4656
return Py_BuildValue("i",status);
4660
* py_pjsua_call_hangup
4662
static PyObject *py_pjsua_call_hangup
4663
(PyObject *pSelf, PyObject *pArgs)
4667
pj_str_t * reason, tmp_reason;
4670
pjsua_msg_data msg_data;
4672
PyObj_pjsua_msg_data * omd;
4673
pj_pool_t * pool = NULL;
4675
PJ_UNUSED_ARG(pSelf);
4677
if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omdObj))
4685
reason = &tmp_reason;
4686
tmp_reason.ptr = PyString_AsString(sr);
4687
tmp_reason.slen = strlen(PyString_AsString(sr));
4689
if (omdObj != Py_None)
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);
4702
status = pjsua_call_hangup(call_id, code, reason, NULL);
4705
return Py_BuildValue("i",status);
4709
* py_pjsua_call_set_hold
4711
static PyObject *py_pjsua_call_set_hold
4712
(PyObject *pSelf, PyObject *pArgs)
4716
pjsua_msg_data msg_data;
4718
PyObj_pjsua_msg_data * omd;
4721
PJ_UNUSED_ARG(pSelf);
4723
if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omdObj))
4728
if (omdObj != Py_None)
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);
4741
status = pjsua_call_set_hold(call_id, NULL);
4743
return Py_BuildValue("i",status);
4747
* py_pjsua_call_reinvite
4749
static PyObject *py_pjsua_call_reinvite
4750
(PyObject *pSelf, PyObject *pArgs)
4755
pjsua_msg_data msg_data;
4757
PyObj_pjsua_msg_data * omd;
4760
PJ_UNUSED_ARG(pSelf);
4762
if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omdObj))
4767
if (omdObj != Py_None)
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);
4780
status = pjsua_call_reinvite(call_id, unhold, NULL);
4782
return Py_BuildValue("i",status);
4786
* py_pjsua_call_xfer
4788
static PyObject *py_pjsua_call_xfer
4789
(PyObject *pSelf, PyObject *pArgs)
4795
pjsua_msg_data msg_data;
4797
PyObj_pjsua_msg_data * omd;
4800
PJ_UNUSED_ARG(pSelf);
4802
if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &sd, &omdObj))
4807
dest.ptr = PyString_AsString(sd);
4808
dest.slen = strlen(PyString_AsString(sd));
4810
if (omdObj != Py_None)
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);
4823
status = pjsua_call_xfer(call_id, &dest, NULL);
4825
return Py_BuildValue("i",status);
4829
* py_pjsua_call_xfer_replaces
4831
static PyObject *py_pjsua_call_xfer_replaces
4832
(PyObject *pSelf, PyObject *pArgs)
4838
pjsua_msg_data msg_data;
4840
PyObj_pjsua_msg_data * omd;
4843
PJ_UNUSED_ARG(pSelf);
4845
if (!PyArg_ParseTuple
4846
(pArgs, "iiIO", &call_id, &dest_call_id, &options, &omdObj))
4851
if (omdObj != Py_None)
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);
4865
status = pjsua_call_xfer_replaces(call_id, dest_call_id,options, NULL);
4867
return Py_BuildValue("i",status);
4871
* py_pjsua_call_dial_dtmf
4873
static PyObject *py_pjsua_call_dial_dtmf
4874
(PyObject *pSelf, PyObject *pArgs)
4881
PJ_UNUSED_ARG(pSelf);
4883
if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &sd))
4887
digits.ptr = PyString_AsString(sd);
4888
digits.slen = strlen(PyString_AsString(sd));
4889
status = pjsua_call_dial_dtmf(call_id, &digits);
4891
return Py_BuildValue("i", status);
4895
* py_pjsua_call_send_im
4897
static PyObject *py_pjsua_call_send_im
4898
(PyObject *pSelf, PyObject *pArgs)
4903
pj_str_t * mime_type, tmp_mime_type;
4906
pjsua_msg_data msg_data;
4908
PyObj_pjsua_msg_data * omd;
4912
PJ_UNUSED_ARG(pSelf);
4914
if (!PyArg_ParseTuple
4915
(pArgs, "iOOOi", &call_id, &sm, &sc, &omdObj, &user_data))
4923
mime_type = &tmp_mime_type;
4924
tmp_mime_type.ptr = PyString_AsString(sm);
4925
tmp_mime_type.slen = strlen(PyString_AsString(sm));
4927
content.ptr = PyString_AsString(sc);
4928
content.slen = strlen(PyString_AsString(sc));
4930
if (omdObj != Py_None)
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);
4944
status = pjsua_call_send_im
4945
(call_id, mime_type, &content, NULL, (void *)user_data);
4948
return Py_BuildValue("i",status);
4952
* py_pjsua_call_send_typing_ind
4954
static PyObject *py_pjsua_call_send_typing_ind
4955
(PyObject *pSelf, PyObject *pArgs)
4960
pjsua_msg_data msg_data;
4962
PyObj_pjsua_msg_data * omd;
4965
PJ_UNUSED_ARG(pSelf);
4967
if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omdObj))
4972
if (omdObj != Py_None)
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);
4985
status = pjsua_call_send_typing_ind(call_id, is_typing, NULL);
4987
return Py_BuildValue("i",status);
4991
* py_pjsua_call_hangup_all
4993
static PyObject *py_pjsua_call_hangup_all
4994
(PyObject *pSelf, PyObject *pArgs)
4997
PJ_UNUSED_ARG(pSelf);
4999
if (!PyArg_ParseTuple(pArgs, ""))
5004
pjsua_call_hangup_all();
5011
* py_pjsua_call_dump
5013
static PyObject *py_pjsua_call_dump
5014
(PyObject *pSelf, PyObject *pArgs)
5025
PJ_UNUSED_ARG(pSelf);
5027
if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media, &maxlen, &si))
5031
buffer = (char *) malloc (maxlen * sizeof(char));
5032
indent = PyString_AsString(si);
5034
status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent);
5035
sb = PyString_FromStringAndSize(buffer, maxlen);
5037
return Py_BuildValue("O", sb);
5043
* Dump application states.
5045
static PyObject *py_pjsua_dump(PyObject *pSelf, PyObject *pArgs)
5051
PJ_UNUSED_ARG(pSelf);
5053
if (!PyArg_ParseTuple(pArgs, "i", &detail))
5058
PJ_LOG(3,(THIS_FILE, "Start dumping application states:"));
5060
old_decor = pj_log_get_decor();
5061
pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR));
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);
5072
/* Dump all invite sessions: */
5073
PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:"));
5075
if (pjsua_call_get_count() == 0) {
5077
PJ_LOG(3,(THIS_FILE, " - no sessions -"));
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));
5091
/* Dump presence status */
5092
pjsua_pres_dump(detail);
5094
pj_log_set_decor(old_decor);
5095
PJ_LOG(3,(THIS_FILE, "Dump complete"));
5102
static char pjsua_call_get_max_count_doc[] =
5103
"int py_pjsua.call_get_max_count () "
5104
"Get maximum number of calls configured in pjsua.";
5105
static char pjsua_call_get_count_doc[] =
5106
"int py_pjsua.call_get_count () "
5107
"Get number of currently active calls.";
5108
static char pjsua_enum_calls_doc[] =
5109
"int[] py_pjsua.enum_calls () "
5110
"Get maximum number of calls configured in pjsua.";
5111
static 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.";
5115
static 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.";
5119
static 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.";
5122
static 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.";
5125
static 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.";
5128
static 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.";
5131
static 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.";
5134
static 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.";
5138
static 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.";
5143
static 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.";
5146
static 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).";
5150
static 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.";
5156
static 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.";
5163
static 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.";
5166
static 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.";
5170
static 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.";
5174
static char pjsua_call_hangup_all_doc[] =
5175
"void py_pjsua.call_hangup_all () "
5176
"Terminate all calls.";
5177
static char pjsua_call_dump_doc[] =
5178
"int py_pjsua.call_dump (int call_id, int with_media, int maxlen, "
5180
"Dump call and media statistics to string.";
5182
/* END OF LIB CALL */
5185
* Map of function names to functions
5187
static PyMethodDef py_pjsua_methods[] =
5190
"thread_register", py_pjsua_thread_register, METH_VARARGS,
5191
pjsua_thread_register_doc
5194
"perror", py_pjsua_perror, METH_VARARGS, pjsua_perror_doc
5197
"create", py_pjsua_create, METH_VARARGS, pjsua_create_doc
5200
"init", py_pjsua_init, METH_VARARGS, pjsua_init_doc
5203
"start", py_pjsua_start, METH_VARARGS, pjsua_start_doc
5206
"destroy", py_pjsua_destroy, METH_VARARGS, pjsua_destroy_doc
5209
"handle_events", py_pjsua_handle_events, METH_VARARGS,
5210
pjsua_handle_events_doc
5213
"verify_sip_url", py_pjsua_verify_sip_url, METH_VARARGS,
5214
pjsua_verify_sip_url_doc
5217
"pool_create", py_pjsua_pool_create, METH_VARARGS,
5218
pjsua_pool_create_doc
5221
"get_pjsip_endpt", py_pjsua_get_pjsip_endpt, METH_VARARGS,
5222
pjsua_get_pjsip_endpt_doc
5225
"get_pjmedia_endpt", py_pjsua_get_pjmedia_endpt, METH_VARARGS,
5226
pjsua_get_pjmedia_endpt_doc
5229
"get_pool_factory", py_pjsua_get_pool_factory, METH_VARARGS,
5230
pjsua_get_pool_factory_doc
5233
"reconfigure_logging", py_pjsua_reconfigure_logging, METH_VARARGS,
5234
pjsua_reconfigure_logging_doc
5237
"logging_config_default", py_pjsua_logging_config_default,
5238
METH_VARARGS, pjsua_logging_config_default_doc
5241
"config_default", py_pjsua_config_default, METH_VARARGS,
5242
pjsua_config_default_doc
5245
"media_config_default", py_pjsua_media_config_default, METH_VARARGS,
5246
pjsua_media_config_default_doc
5251
"msg_data_init", py_pjsua_msg_data_init, METH_VARARGS,
5252
pjsua_msg_data_init_doc
5255
"transport_config_default", py_pjsua_transport_config_default,
5256
METH_VARARGS,pjsua_transport_config_default_doc
5259
"transport_create", py_pjsua_transport_create, METH_VARARGS,
5260
pjsua_transport_create_doc
5263
"transport_enum_transports", py_pjsua_enum_transports, METH_VARARGS,
5264
pjsua_enum_transports_doc
5267
"transport_get_info", py_pjsua_transport_get_info, METH_VARARGS,
5268
pjsua_transport_get_info_doc
5271
"transport_set_enable", py_pjsua_transport_set_enable, METH_VARARGS,
5272
pjsua_transport_set_enable_doc
5275
"transport_close", py_pjsua_transport_close, METH_VARARGS,
5276
pjsua_transport_close_doc
5279
"acc_config_default", py_pjsua_acc_config_default, METH_VARARGS,
5280
pjsua_acc_config_default_doc
5283
"acc_get_count", py_pjsua_acc_get_count, METH_VARARGS,
5284
pjsua_acc_get_count_doc
5287
"acc_is_valid", py_pjsua_acc_is_valid, METH_VARARGS,
5288
pjsua_acc_is_valid_doc
5291
"acc_set_default", py_pjsua_acc_set_default, METH_VARARGS,
5292
pjsua_acc_set_default_doc
5295
"acc_get_default", py_pjsua_acc_get_default, METH_VARARGS,
5296
pjsua_acc_get_default_doc
5299
"acc_add", py_pjsua_acc_add, METH_VARARGS,
5303
"acc_add_local", py_pjsua_acc_add_local, METH_VARARGS,
5304
pjsua_acc_add_local_doc
5307
"acc_del", py_pjsua_acc_del, METH_VARARGS,
5311
"acc_modify", py_pjsua_acc_modify, METH_VARARGS,
5312
pjsua_acc_modify_doc
5315
"acc_set_online_status", py_pjsua_acc_set_online_status, METH_VARARGS,
5316
pjsua_acc_set_online_status_doc
5319
"acc_set_online_status2", py_pjsua_acc_set_online_status2, METH_VARARGS,
5320
pjsua_acc_set_online_status2_doc
5323
"acc_set_registration", py_pjsua_acc_set_registration, METH_VARARGS,
5324
pjsua_acc_set_registration_doc
5327
"acc_get_info", py_pjsua_acc_get_info, METH_VARARGS,
5328
pjsua_acc_get_info_doc
5331
"enum_accs", py_pjsua_enum_accs, METH_VARARGS,
5335
"acc_enum_info", py_pjsua_acc_enum_info, METH_VARARGS,
5336
pjsua_acc_enum_info_doc
5339
"acc_find_for_outgoing", py_pjsua_acc_find_for_outgoing, METH_VARARGS,
5340
pjsua_acc_find_for_outgoing_doc
5343
"acc_find_for_incoming", py_pjsua_acc_find_for_incoming, METH_VARARGS,
5344
pjsua_acc_find_for_incoming_doc
5347
"acc_create_uac_contact", py_pjsua_acc_create_uac_contact, METH_VARARGS,
5348
pjsua_acc_create_uac_contact_doc
5351
"acc_create_uas_contact", py_pjsua_acc_create_uas_contact, METH_VARARGS,
5352
pjsua_acc_create_uas_contact_doc
5355
"buddy_config_default", py_pjsua_buddy_config_default, METH_VARARGS,
5356
pjsua_buddy_config_default_doc
5359
"get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS,
5360
pjsua_get_buddy_count_doc
5363
"buddy_is_valid", py_pjsua_buddy_is_valid, METH_VARARGS,
5364
pjsua_buddy_is_valid_doc
5367
"enum_buddies", py_pjsua_enum_buddies, METH_VARARGS,
5368
pjsua_enum_buddies_doc
5371
"buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS,
5372
pjsua_buddy_get_info_doc
5375
"buddy_add", py_pjsua_buddy_add, METH_VARARGS,
5379
"buddy_del", py_pjsua_buddy_del, METH_VARARGS,
5383
"buddy_subscribe_pres", py_pjsua_buddy_subscribe_pres, METH_VARARGS,
5384
pjsua_buddy_subscribe_pres_doc
5387
"pres_dump", py_pjsua_pres_dump, METH_VARARGS,
5391
"im_send", py_pjsua_im_send, METH_VARARGS,
5395
"im_typing", py_pjsua_im_typing, METH_VARARGS,
5399
"conf_get_max_ports", py_pjsua_conf_get_max_ports, METH_VARARGS,
5400
pjsua_conf_get_max_ports_doc
5403
"conf_get_active_ports", py_pjsua_conf_get_active_ports, METH_VARARGS,
5404
pjsua_conf_get_active_ports_doc
5407
"enum_conf_ports", py_pjsua_enum_conf_ports, METH_VARARGS,
5408
pjsua_enum_conf_ports_doc
5411
"conf_get_port_info", py_pjsua_conf_get_port_info, METH_VARARGS,
5412
pjsua_conf_get_port_info_doc
5415
"conf_add_port", py_pjsua_conf_add_port, METH_VARARGS,
5416
pjsua_conf_add_port_doc
5419
"conf_remove_port", py_pjsua_conf_remove_port, METH_VARARGS,
5420
pjsua_conf_remove_port_doc
5423
"conf_connect", py_pjsua_conf_connect, METH_VARARGS,
5424
pjsua_conf_connect_doc
5427
"conf_disconnect", py_pjsua_conf_disconnect, METH_VARARGS,
5428
pjsua_conf_disconnect_doc
5431
"player_create", py_pjsua_player_create, METH_VARARGS,
5432
pjsua_player_create_doc
5435
"player_get_conf_port", py_pjsua_player_get_conf_port, METH_VARARGS,
5436
pjsua_player_get_conf_port_doc
5439
"player_set_pos", py_pjsua_player_set_pos, METH_VARARGS,
5440
pjsua_player_set_pos_doc
5443
"player_destroy", py_pjsua_player_destroy, METH_VARARGS,
5444
pjsua_player_destroy_doc
5447
"recorder_create", py_pjsua_recorder_create, METH_VARARGS,
5448
pjsua_recorder_create_doc
5451
"recorder_get_conf_port", py_pjsua_recorder_get_conf_port, METH_VARARGS,
5452
pjsua_recorder_get_conf_port_doc
5455
"recorder_destroy", py_pjsua_recorder_destroy, METH_VARARGS,
5456
pjsua_recorder_destroy_doc
5459
"enum_snd_devs", py_pjsua_enum_snd_devs, METH_VARARGS,
5460
pjsua_enum_snd_devs_doc
5463
"get_snd_dev", py_pjsua_get_snd_dev, METH_VARARGS,
5464
pjsua_get_snd_dev_doc
5467
"set_snd_dev", py_pjsua_set_snd_dev, METH_VARARGS,
5468
pjsua_set_snd_dev_doc
5471
"set_null_snd_dev", py_pjsua_set_null_snd_dev, METH_VARARGS,
5472
pjsua_set_null_snd_dev_doc
5475
"set_no_snd_dev", py_pjsua_set_no_snd_dev, METH_VARARGS,
5476
pjsua_set_no_snd_dev_doc
5479
"set_ec", py_pjsua_set_ec, METH_VARARGS,
5483
"get_ec_tail", py_pjsua_get_ec_tail, METH_VARARGS,
5484
pjsua_get_ec_tail_doc
5487
"enum_codecs", py_pjsua_enum_codecs, METH_VARARGS,
5488
pjsua_enum_codecs_doc
5491
"codec_set_priority", py_pjsua_codec_set_priority, METH_VARARGS,
5492
pjsua_codec_set_priority_doc
5495
"codec_get_param", py_pjsua_codec_get_param, METH_VARARGS,
5496
pjsua_codec_get_param_doc
5499
"codec_set_param", py_pjsua_codec_set_param, METH_VARARGS,
5500
pjsua_codec_set_param_doc
5503
"call_get_max_count", py_pjsua_call_get_max_count, METH_VARARGS,
5504
pjsua_call_get_max_count_doc
5507
"call_get_count", py_pjsua_call_get_count, METH_VARARGS,
5508
pjsua_call_get_count_doc
5511
"enum_calls", py_pjsua_enum_calls, METH_VARARGS,
5512
pjsua_enum_calls_doc
5515
"call_make_call", py_pjsua_call_make_call, METH_VARARGS,
5516
pjsua_call_make_call_doc
5519
"call_is_active", py_pjsua_call_is_active, METH_VARARGS,
5520
pjsua_call_is_active_doc
5523
"call_has_media", py_pjsua_call_has_media, METH_VARARGS,
5524
pjsua_call_has_media_doc
5527
"call_get_conf_port", py_pjsua_call_get_conf_port, METH_VARARGS,
5528
pjsua_call_get_conf_port_doc
5531
"call_get_info", py_pjsua_call_get_info, METH_VARARGS,
5532
pjsua_call_get_info_doc
5535
"call_set_user_data", py_pjsua_call_set_user_data, METH_VARARGS,
5536
pjsua_call_set_user_data_doc
5539
"call_get_user_data", py_pjsua_call_get_user_data, METH_VARARGS,
5540
pjsua_call_get_user_data_doc
5543
"call_answer", py_pjsua_call_answer, METH_VARARGS,
5544
pjsua_call_answer_doc
5547
"call_hangup", py_pjsua_call_hangup, METH_VARARGS,
5548
pjsua_call_hangup_doc
5551
"call_set_hold", py_pjsua_call_set_hold, METH_VARARGS,
5552
pjsua_call_set_hold_doc
5555
"call_reinvite", py_pjsua_call_reinvite, METH_VARARGS,
5556
pjsua_call_reinvite_doc
5559
"call_xfer", py_pjsua_call_xfer, METH_VARARGS,
5563
"call_xfer_replaces", py_pjsua_call_xfer_replaces, METH_VARARGS,
5564
pjsua_call_xfer_replaces_doc
5567
"call_dial_dtmf", py_pjsua_call_dial_dtmf, METH_VARARGS,
5568
pjsua_call_dial_dtmf_doc
5571
"call_send_im", py_pjsua_call_send_im, METH_VARARGS,
5572
pjsua_call_send_im_doc
5575
"call_send_typing_ind", py_pjsua_call_send_typing_ind, METH_VARARGS,
5576
pjsua_call_send_typing_ind_doc
5579
"call_hangup_all", py_pjsua_call_hangup_all, METH_VARARGS,
5580
pjsua_call_hangup_all_doc
5583
"call_dump", py_pjsua_call_dump, METH_VARARGS,
5587
"dump", py_pjsua_dump, METH_VARARGS, "Dump application state"
5591
{NULL, NULL} /* end of function list */
5597
* Mapping C structs from and to Python objects & initializing object
5603
#define ADD_CONSTANT(mod,name) PyModule_AddIntConstant(mod,#name,name)
5606
PyEval_InitThreads();
5608
if (PyType_Ready(&PyTyp_pjsua_callback) < 0)
5610
if (PyType_Ready(&PyTyp_pjsua_config) < 0)
5612
if (PyType_Ready(&PyTyp_pjsua_logging_config) < 0)
5614
if (PyType_Ready(&PyTyp_pjsua_msg_data) < 0)
5616
PyTyp_pjsua_media_config.tp_new = PyType_GenericNew;
5617
if (PyType_Ready(&PyTyp_pjsua_media_config) < 0)
5619
PyTyp_pjsip_event.tp_new = PyType_GenericNew;
5620
if (PyType_Ready(&PyTyp_pjsip_event) < 0)
5622
PyTyp_pjsip_rx_data.tp_new = PyType_GenericNew;
5623
if (PyType_Ready(&PyTyp_pjsip_rx_data) < 0)
5625
PyTyp_pj_pool_t.tp_new = PyType_GenericNew;
5626
if (PyType_Ready(&PyTyp_pj_pool_t) < 0)
5628
PyTyp_pjsip_endpoint.tp_new = PyType_GenericNew;
5629
if (PyType_Ready(&PyTyp_pjsip_endpoint) < 0)
5631
PyTyp_pjmedia_endpt.tp_new = PyType_GenericNew;
5632
if (PyType_Ready(&PyTyp_pjmedia_endpt) < 0)
5634
PyTyp_pj_pool_factory.tp_new = PyType_GenericNew;
5635
if (PyType_Ready(&PyTyp_pj_pool_factory) < 0)
5637
PyTyp_pjsip_cred_info.tp_new = PyType_GenericNew;
5638
if (PyType_Ready(&PyTyp_pjsip_cred_info) < 0)
5643
if (PyType_Ready(&PyTyp_pjsua_transport_config) < 0)
5646
if (PyType_Ready(&PyTyp_pjsua_transport_info) < 0)
5649
/* END OF LIB TRANSPORT */
5654
if (PyType_Ready(&PyTyp_pjsua_acc_config) < 0)
5656
if (PyType_Ready(&PyTyp_pjsua_acc_info) < 0)
5659
/* END OF LIB ACCOUNT */
5663
if (PyType_Ready(&PyTyp_pjsua_buddy_config) < 0)
5665
if (PyType_Ready(&PyTyp_pjsua_buddy_info) < 0)
5668
/* END OF LIB BUDDY */
5672
if (PyType_Ready(&PyTyp_pjsua_codec_info) < 0)
5675
if (PyType_Ready(&PyTyp_pjsua_conf_port_info) < 0)
5678
PyTyp_pjmedia_port.tp_new = PyType_GenericNew;
5679
if (PyType_Ready(&PyTyp_pjmedia_port) < 0)
5682
if (PyType_Ready(&PyTyp_pjmedia_snd_dev_info) < 0)
5685
PyTyp_pjmedia_codec_param_info.tp_new = PyType_GenericNew;
5686
if (PyType_Ready(&PyTyp_pjmedia_codec_param_info) < 0)
5688
PyTyp_pjmedia_codec_param_setting.tp_new = PyType_GenericNew;
5689
if (PyType_Ready(&PyTyp_pjmedia_codec_param_setting) < 0)
5692
if (PyType_Ready(&PyTyp_pjmedia_codec_param) < 0)
5695
/* END OF LIB MEDIA */
5699
PyTyp_pj_time_val.tp_new = PyType_GenericNew;
5700
if (PyType_Ready(&PyTyp_pj_time_val) < 0)
5703
if (PyType_Ready(&PyTyp_pjsua_call_info) < 0)
5706
/* END OF LIB CALL */
5709
"py_pjsua", py_pjsua_methods,"PJSUA-lib module for python"
5712
Py_INCREF(&PyTyp_pjsua_callback);
5713
PyModule_AddObject(m, "Callback", (PyObject *)&PyTyp_pjsua_callback);
5715
Py_INCREF(&PyTyp_pjsua_config);
5716
PyModule_AddObject(m, "Config", (PyObject *)&PyTyp_pjsua_config);
5718
Py_INCREF(&PyTyp_pjsua_media_config);
5719
PyModule_AddObject(m, "Media_Config", (PyObject *)&PyTyp_pjsua_media_config);
5721
Py_INCREF(&PyTyp_pjsua_logging_config);
5722
PyModule_AddObject(m, "Logging_Config", (PyObject *)&PyTyp_pjsua_logging_config);
5724
Py_INCREF(&PyTyp_pjsua_msg_data);
5725
PyModule_AddObject(m, "Msg_Data", (PyObject *)&PyTyp_pjsua_msg_data);
5727
Py_INCREF(&PyTyp_pjsip_event);
5728
PyModule_AddObject(m, "Pjsip_Event", (PyObject *)&PyTyp_pjsip_event);
5730
Py_INCREF(&PyTyp_pjsip_rx_data);
5731
PyModule_AddObject(m, "Pjsip_Rx_Data", (PyObject *)&PyTyp_pjsip_rx_data);
5733
Py_INCREF(&PyTyp_pj_pool_t);
5734
PyModule_AddObject(m, "Pj_Pool", (PyObject *)&PyTyp_pj_pool_t);
5736
Py_INCREF(&PyTyp_pjsip_endpoint);
5737
PyModule_AddObject(m, "Pjsip_Endpoint", (PyObject *)&PyTyp_pjsip_endpoint);
5739
Py_INCREF(&PyTyp_pjmedia_endpt);
5740
PyModule_AddObject(m, "Pjmedia_Endpt", (PyObject *)&PyTyp_pjmedia_endpt);
5742
Py_INCREF(&PyTyp_pj_pool_factory);
5744
m, "Pj_Pool_Factory", (PyObject *)&PyTyp_pj_pool_factory
5747
Py_INCREF(&PyTyp_pjsip_cred_info);
5748
PyModule_AddObject(m, "Pjsip_Cred_Info",
5749
(PyObject *)&PyTyp_pjsip_cred_info
5754
Py_INCREF(&PyTyp_pjsua_transport_config);
5756
(m, "Transport_Config", (PyObject *)&PyTyp_pjsua_transport_config);
5758
Py_INCREF(&PyTyp_pjsua_transport_info);
5759
PyModule_AddObject(m, "Transport_Info", (PyObject *)&PyTyp_pjsua_transport_info);
5762
/* END OF LIB TRANSPORT */
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);
5772
/* END OF LIB ACCOUNT */
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);
5781
/* END OF LIB BUDDY */
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);
5804
/* END OF LIB MEDIA */
5808
Py_INCREF(&PyTyp_pj_time_val);
5809
PyModule_AddObject(m, "PJ_Time_Val", (PyObject *)&PyTyp_pj_time_val);
5811
Py_INCREF(&PyTyp_pjsua_call_info);
5812
PyModule_AddObject(m, "Call_Info", (PyObject *)&PyTyp_pjsua_call_info);
5814
/* END OF LIB CALL */
5818
* Add various constants.
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);
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);
5837
ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_UNKNOWN);
5838
ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_ONLINE);
5839
ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_OFFLINE);
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);
5852
ADD_CONSTANT(m, PJSUA_INVALID_ID);
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);