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