Changeset 2163 for pjproject/trunk/pjsip-apps/src/python/_pjsua.c
- Timestamp:
- Jul 21, 2008 6:20:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/python/_pjsua.c
r2158 r2163 20 20 21 21 #define THIS_FILE "main.c" 22 #define POOL_SIZE 400022 #define POOL_SIZE 512 23 23 #define SND_DEV_NUM 64 24 24 #define SND_NAME_LEN 64 … … 26 26 /* LIB BASE */ 27 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) 28 static PyObject* g_obj_log_cb; 29 static long g_thread_id; 30 static struct py_thread_desc 31 { 32 struct py_thread_desc *next; 33 pj_thread_desc desc; 34 } *py_thread_desc; 35 36 /* 37 * The global callback object. 38 */ 39 static PyObj_pjsua_callback * g_obj_callback; 40 41 /* Set this to 1 if all threads are created by Python */ 42 #define NO_PJSIP_THREAD 1 43 44 #if NO_PJSIP_THREAD 45 # define ENTER_PYTHON() 46 # define LEAVE_PYTHON() 47 #else 48 # define ENTER_PYTHON() PyGILState_STATE state = PyGILState_Ensure() 49 # define LEAVE_PYTHON() PyGILState_Release(state) 50 #endif 51 52 53 static void clear_py_thread_desc(void) 54 { 55 while (py_thread_desc) { 56 struct py_thread_desc *next = py_thread_desc->next; 57 free(py_thread_desc); 58 py_thread_desc = next; 59 } 60 } 61 33 62 34 63 /* … … 42 71 * or otherwise it will crash Python. 43 72 */ 44 if (pj_thread_local_get( thread_id) == 0)73 if (pj_thread_local_get(g_thread_id) == 0) 45 74 return; 46 75 47 if (PyCallable_Check(obj_log_cb)) 48 { 76 if (PyCallable_Check(g_obj_log_cb)) { 77 PyObject *param_data; 78 49 79 ENTER_PYTHON(); 50 80 51 PyObject_CallFunctionObjArgs( 52 obj_log_cb, Py_BuildValue("i",level), 53 PyString_FromString(data), Py_BuildValue("i",len), NULL 81 param_data = PyString_FromStringAndSize(data, len); 82 83 PyObject_CallFunction( 84 g_obj_log_cb, 85 "iOi", 86 level, 87 param_data, 88 len, 89 NULL 54 90 ); 55 91 92 Py_DECREF(param_data); 93 56 94 LEAVE_PYTHON(); 57 95 } 58 96 } 59 60 61 62 /*63 * The global callback object.64 */65 static PyObj_pjsua_callback * g_obj_callback;66 67 97 68 98 /* … … 72 102 static void cb_on_call_state(pjsua_call_id call_id, pjsip_event *e) 73 103 { 74 if (PyCallable_Check(g_obj_callback->on_call_state)) 75 { 76 PyObj_pjsip_event * obj; 104 PJ_UNUSED_ARG(e); 105 106 if (PyCallable_Check(g_obj_callback->on_call_state)) { 107 PyObject * obj; 77 108 78 109 ENTER_PYTHON(); 79 110 80 obj = (PyObj_pjsip_event *)PyType_GenericNew(&PyTyp_pjsip_event, 81 NULL, NULL); 111 obj = Py_BuildValue(""); 82 112 83 obj->event = e; 84 85 PyObject_CallFunctionObjArgs( 113 PyObject_CallFunction( 86 114 g_obj_callback->on_call_state, 87 Py_BuildValue("i",call_id), 115 "iO", 116 call_id, 88 117 obj, 89 118 NULL 90 119 ); 91 120 121 Py_DECREF(obj); 122 92 123 LEAVE_PYTHON(); 93 124 } … … 102 133 pjsip_rx_data *rdata) 103 134 { 104 if (PyCallable_Check(g_obj_callback->on_incoming_call)) 105 { 106 PyObj_pjsip_rx_data * obj; 135 PJ_UNUSED_ARG(rdata); 136 137 if (PyCallable_Check(g_obj_callback->on_incoming_call)) { 138 PyObject *obj; 107 139 108 140 ENTER_PYTHON(); 109 141 110 obj = (PyObj_pjsip_rx_data *)PyType_GenericNew(&PyTyp_pjsip_rx_data, 111 NULL, NULL); 112 obj->rdata = rdata; 113 114 PyObject_CallFunctionObjArgs( 142 obj = Py_BuildValue(""); 143 144 PyObject_CallFunction( 115 145 g_obj_callback->on_incoming_call, 116 Py_BuildValue("i",acc_id), 117 Py_BuildValue("i",call_id), 146 "iiO", 147 acc_id, 148 call_id, 118 149 obj, 119 150 NULL 120 151 ); 121 152 153 Py_DECREF(obj); 154 122 155 LEAVE_PYTHON(); 123 156 } … … 131 164 static void cb_on_call_media_state(pjsua_call_id call_id) 132 165 { 133 if (PyCallable_Check(g_obj_callback->on_call_media_state)) 134 { 166 if (PyCallable_Check(g_obj_callback->on_call_media_state)) { 167 135 168 ENTER_PYTHON(); 136 169 … … 153 186 static void cb_on_dtmf_digit(pjsua_call_id call_id, int digit) 154 187 { 155 if (PyCallable_Check(g_obj_callback->on_dtmf_digit)) 156 { 188 if (PyCallable_Check(g_obj_callback->on_dtmf_digit)) { 157 189 char digit_str[10]; 158 190 … … 161 193 pj_ansi_snprintf(digit_str, sizeof(digit_str), "%c", digit); 162 194 163 PyObject_CallFunction ObjArgs(195 PyObject_CallFunction( 164 196 g_obj_callback->on_dtmf_digit, 165 Py_BuildValue("i",call_id), 166 PyString_FromString(digit_str), 197 "is", 198 call_id, 199 digit_str, 167 200 NULL 168 201 ); … … 181 214 pjsip_status_code *code) 182 215 { 183 if (PyCallable_Check(g_obj_callback->on_call_transfer_request)) 184 { 185 PyObject * ret; 216 if (PyCallable_Check(g_obj_callback->on_call_transfer_request)) { 217 PyObject *ret, *param_dst; 186 218 int cd; 187 219 188 220 ENTER_PYTHON(); 189 221 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 ); 222 param_dst = PyString_FromPJ(dst); 223 224 ret = PyObject_CallFunction( 225 g_obj_callback->on_call_transfer_request, 226 "iOi", 227 call_id, 228 param_dst, 229 *code, 230 NULL 231 ); 232 233 Py_DECREF(param_dst); 234 197 235 if (ret != NULL) { 198 236 if (ret != Py_None) { … … 201 239 } 202 240 } 241 Py_DECREF(ret); 203 242 } 204 243 … … 221 260 pj_bool_t *p_cont) 222 261 { 223 if (PyCallable_Check(g_obj_callback->on_call_transfer_status)) 224 { 225 PyObject * ret; 226 int cnt; 262 if (PyCallable_Check(g_obj_callback->on_call_transfer_status)) { 263 PyObject *ret, *param_reason; 227 264 228 265 ENTER_PYTHON(); 229 266 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 ); 267 param_reason = PyString_FromPJ(status_text); 268 269 ret = PyObject_CallFunction( 270 g_obj_callback->on_call_transfer_status, 271 "iiOii", 272 call_id, 273 status_code, 274 param_reason, 275 final, 276 *p_cont, 277 NULL 278 ); 279 280 Py_DECREF(param_reason); 281 239 282 if (ret != NULL) { 240 283 if (ret != Py_None) { 284 int cnt; 241 285 if (PyArg_Parse(ret,"i",&cnt)) { 242 286 *p_cont = cnt; 243 287 } 244 288 } 289 Py_DECREF(ret); 245 290 } 246 291 … … 260 305 pj_str_t *st_text) 261 306 { 262 if (PyCallable_Check(g_obj_callback->on_call_replace_request))263 { 264 PyObject * ret; 265 PyObject * txt;307 PJ_UNUSED_ARG(rdata); 308 309 if (PyCallable_Check(g_obj_callback->on_call_replace_request)) { 310 PyObject *ret, *param_reason, *param_rdata; 266 311 int cd; 267 PyObj_pjsip_rx_data * obj;268 312 269 313 ENTER_PYTHON(); 270 314 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 ); 315 param_reason = PyString_FromPJ(st_text); 316 param_rdata = Py_BuildValue(""); 317 318 ret = PyObject_CallFunction( 319 g_obj_callback->on_call_replace_request, 320 "iOiO", 321 call_id, 322 param_rdata, 323 *st_code, 324 param_reason, 325 NULL 326 ); 327 328 Py_DECREF(param_rdata); 329 Py_DECREF(param_reason); 330 283 331 if (ret != NULL) { 284 332 if (ret != Py_None) { 333 PyObject * txt; 285 334 if (PyArg_ParseTuple(ret,"iO",&cd, &txt)) { 286 335 *st_code = cd; 287 st_text->ptr = PyString_AsString(txt); 288 st_text->slen = strlen(PyString_AsString(txt)); 336 *st_text = PyString_ToPJ(txt); 289 337 } 290 338 } 339 Py_DECREF(ret); 291 340 } 292 341 … … 304 353 pjsua_call_id new_call_id) 305 354 { 306 if (PyCallable_Check(g_obj_callback->on_call_replaced)) 307 { 355 if (PyCallable_Check(g_obj_callback->on_call_replaced)) { 308 356 ENTER_PYTHON(); 309 357 310 PyObject_CallFunction ObjArgs(358 PyObject_CallFunction( 311 359 g_obj_callback->on_call_replaced, 312 Py_BuildValue("i",old_call_id), 313 Py_BuildValue("i",new_call_id), 360 "ii", 361 old_call_id, 362 new_call_id, 314 363 NULL 315 364 ); … … 326 375 static void cb_on_reg_state(pjsua_acc_id acc_id) 327 376 { 328 if (PyCallable_Check(g_obj_callback->on_reg_state)) 329 { 377 if (PyCallable_Check(g_obj_callback->on_reg_state)) { 330 378 ENTER_PYTHON(); 331 379 … … 358 406 PJ_UNUSED_ARG(msg_data); 359 407 360 if (PyCallable_Check(g_obj_callback->on_incoming_subscribe)) 361 { 362 PyObject *ret; 408 if (PyCallable_Check(g_obj_callback->on_incoming_subscribe)) { 409 PyObject *ret, *param_from, *param_contact, *param_srv_pres; 410 pjsip_contact_hdr *contact_hdr; 411 pj_pool_t *pool = NULL; 363 412 364 413 ENTER_PYTHON(); 365 414 366 ret = PyObject_CallFunctionObjArgs( 367 g_obj_callback->on_incoming_subscribe, 368 Py_BuildValue("i", acc_id), 369 Py_BuildValue("i", buddy_id), 370 PyString_FromStringAndSize(from->ptr, from->slen), 371 PyLong_FromLong((long)srv_pres), 372 NULL 373 ); 415 param_from = PyString_FromPJ(from); 416 param_srv_pres = PyLong_FromLong((long)srv_pres); 417 418 contact_hdr = (pjsip_contact_hdr*) 419 pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 420 NULL); 421 if (contact_hdr) { 422 char *contact; 423 int len; 424 425 pool = pjsua_pool_create("pytmp", 512, 512); 426 contact = (char*) pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE+1); 427 len = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, contact_hdr->uri, 428 contact, PJSIP_MAX_URL_SIZE); 429 if (len < 1) 430 len = 0; 431 contact[len] = '\0'; 432 433 param_contact = PyString_FromStringAndSize(contact, len); 434 } else { 435 param_contact = Py_BuildValue(""); 436 } 437 438 ret = PyObject_CallFunction( 439 g_obj_callback->on_incoming_subscribe, 440 "iiOOO", 441 acc_id, 442 buddy_id, 443 param_from, 444 param_contact, 445 param_srv_pres, 446 NULL 447 ); 448 449 if (pool) 450 pj_pool_release(pool); 451 452 Py_DECREF(param_from); 453 Py_DECREF(param_contact); 454 Py_DECREF(param_srv_pres); 374 455 375 456 if (ret && PyTuple_Check(ret)) { … … 379 460 if (PyTuple_GetItem(ret, 1) != Py_None) { 380 461 pj_str_t tmp; 381 tmp = PyString_ to_pj_str(PyTuple_GetItem(ret, 1));462 tmp = PyString_ToPJ(PyTuple_GetItem(ret, 1)); 382 463 reason->ptr = reason_buf; 383 464 pj_strncpy(reason, &tmp, sizeof(reason_buf)); 384 465 } else { 466 reason->slen = 0; 385 467 } 386 468 } 387 469 Py_XDECREF(ret); 388 470 } else if (ret) { 389 471 Py_XDECREF(ret); … … 400 482 static void cb_on_buddy_state(pjsua_buddy_id buddy_id) 401 483 { 402 if (PyCallable_Check(g_obj_callback->on_buddy_state)) 403 { 484 if (PyCallable_Check(g_obj_callback->on_buddy_state)) { 404 485 ENTER_PYTHON(); 405 486 … … 426 507 PJ_UNUSED_ARG(rdata); 427 508 428 if (PyCallable_Check(g_obj_callback->on_pager)) 429 { 509 if (PyCallable_Check(g_obj_callback->on_pager)) { 510 PyObject *param_from, *param_to, *param_contact, *param_mime_type, 511 *param_body; 512 430 513 ENTER_PYTHON(); 431 514 432 PyObject_CallFunctionObjArgs( 433 g_obj_callback->on_pager, 434 Py_BuildValue("i",call_id), 435 PyString_FromStringAndSize(from->ptr, from->slen), 436 PyString_FromStringAndSize(to->ptr, to->slen), 437 PyString_FromStringAndSize(contact->ptr, contact->slen), 438 PyString_FromStringAndSize(mime_type->ptr, mime_type->slen), 439 PyString_FromStringAndSize(body->ptr, body->slen), 440 Py_BuildValue("i",acc_id), 441 NULL 442 ); 515 param_from = PyString_FromPJ(from); 516 param_to = PyString_FromPJ(to); 517 param_contact = PyString_FromPJ(contact); 518 param_mime_type = PyString_FromPJ(mime_type); 519 param_body = PyString_FromPJ(body); 520 521 PyObject_CallFunction( 522 g_obj_callback->on_pager, 523 "iOOOOOi", 524 call_id, 525 param_from, 526 param_to, 527 param_contact, 528 param_mime_type, 529 param_body, 530 acc_id, 531 NULL 532 ); 533 534 Py_DECREF(param_body); 535 Py_DECREF(param_mime_type); 536 Py_DECREF(param_contact); 537 Py_DECREF(param_to); 538 Py_DECREF(param_from); 443 539 444 540 LEAVE_PYTHON(); … … 459 555 pjsua_acc_id acc_id) 460 556 { 461 if (PyCallable_Check(g_obj_callback->on_pager)) 462 { 463 PyObject * obj_user_data; 557 if (PyCallable_Check(g_obj_callback->on_pager)) { 558 PyObject *param_call_id, *param_to, *param_body, 559 *param_user_data, *param_status, *param_reason, 560 *param_acc_id; 464 561 465 562 ENTER_PYTHON(); … … 468 565 PJ_UNUSED_ARG(rdata); 469 566 470 obj_user_data = Py_BuildValue("i", user_data);471 472 567 PyObject_CallFunctionObjArgs( 473 g_obj_callback->on_pager_status, 474 Py_BuildValue("i",call_id), 475 PyString_FromStringAndSize(to->ptr, to->slen), 476 PyString_FromStringAndSize(body->ptr, body->slen), 477 obj_user_data, 478 Py_BuildValue("i",status), 479 PyString_FromStringAndSize(reason->ptr,reason->slen), 480 Py_BuildValue("i",acc_id), 481 NULL 482 ); 568 g_obj_callback->on_pager_status, 569 param_call_id = Py_BuildValue("i",call_id), 570 param_to = PyString_FromPJ(to), 571 param_body = PyString_FromPJ(body), 572 param_user_data = Py_BuildValue("i", user_data), 573 param_status = Py_BuildValue("i",status), 574 param_reason = PyString_FromPJ(reason), 575 param_acc_id = Py_BuildValue("i",acc_id), 576 NULL 577 ); 578 579 Py_DECREF(param_call_id); 580 Py_DECREF(param_to); 581 Py_DECREF(param_body); 582 Py_DECREF(param_user_data); 583 Py_DECREF(param_status); 584 Py_DECREF(param_reason); 585 Py_DECREF(param_acc_id); 483 586 484 587 LEAVE_PYTHON(); … … 496 599 pjsua_acc_id acc_id) 497 600 { 498 if (PyCallable_Check(g_obj_callback->on_typing)) 499 { 601 if (PyCallable_Check(g_obj_callback->on_typing)) { 602 PyObject *param_call_id, *param_from, *param_to, *param_contact, 603 *param_is_typing, *param_acc_id; 604 500 605 ENTER_PYTHON(); 501 606 … … 503 608 504 609 PyObject_CallFunctionObjArgs( 505 g_obj_callback->on_typing,Py_BuildValue("i",call_id), 506 PyString_FromStringAndSize(from->ptr, from->slen), 507 PyString_FromStringAndSize(to->ptr, to->slen), 508 PyString_FromStringAndSize(contact->ptr, contact->slen), 509 Py_BuildValue("i",is_typing), 510 Py_BuildValue("i",acc_id), 511 NULL 512 ); 610 g_obj_callback->on_typing, 611 param_call_id = Py_BuildValue("i",call_id), 612 param_from = PyString_FromPJ(from), 613 param_to = PyString_FromPJ(to), 614 param_contact = PyString_FromPJ(contact), 615 param_is_typing = Py_BuildValue("i",is_typing), 616 param_acc_id = Py_BuildValue("i",acc_id), 617 NULL 618 ); 619 620 Py_DECREF(param_call_id); 621 Py_DECREF(param_from); 622 Py_DECREF(param_to); 623 Py_DECREF(param_contact); 624 Py_DECREF(param_is_typing); 625 Py_DECREF(param_acc_id); 513 626 514 627 LEAVE_PYTHON(); … … 530 643 int i; 531 644 532 for (i = 0; i < PyList_Size(py_hdr_list); i++) 533 { 645 for (i=0; i<PyList_Size(py_hdr_list); ++i) { 534 646 pj_str_t hname, hvalue; 535 647 pjsip_generic_string_hdr * new_hdr; 536 648 PyObject * tuple = PyList_GetItem(py_hdr_list, i); 537 649 538 if (PyTuple_Check(tuple)) 539 { 540 hname.ptr = PyString_AsString(PyTuple_GetItem(tuple,0)); 541 hname.slen = strlen(PyString_AsString 542 (PyTuple_GetItem(tuple,0))); 543 hvalue.ptr = PyString_AsString(PyTuple_GetItem(tuple,1)); 544 hvalue.slen = strlen(PyString_AsString 545 (PyTuple_GetItem(tuple,1))); 650 if (PyTuple_Check(tuple)) { 651 if (PyTuple_Size(tuple) >= 1) 652 hname = PyString_ToPJ(PyTuple_GetItem(tuple,0)); 653 else 654 hname.slen = 0; 655 if (PyTuple_Size(tuple) >= 2) 656 hvalue = PyString_ToPJ(PyTuple_GetItem(tuple,1)); 657 else 658 hvalue.slen = 0; 546 659 } else { 547 660 hname.ptr = ""; … … 556 669 } 557 670 558 /*559 * translate_hdr_rev560 * internal function561 * translate from pjsip_generic_string_hdr to hdr_list562 */563 564 void translate_hdr_rev(pjsip_generic_string_hdr *hdr, PyObject *py_hdr_list)565 {566 int i;567 int len;568 pjsip_generic_string_hdr * p_hdr;569 570 len = pj_list_size(hdr);571 572 if (len > 0)573 {574 p_hdr = hdr;575 Py_XDECREF(py_hdr_list);576 py_hdr_list = PyList_New(len);577 578 for (i = 0; i < len && p_hdr != NULL; i++)579 {580 PyObject * tuple;581 PyObject * str;582 583 tuple = PyTuple_New(2);584 585 str = PyString_FromStringAndSize(p_hdr->name.ptr, p_hdr->name.slen);586 PyTuple_SetItem(tuple, 0, str);587 str = PyString_FromStringAndSize588 (hdr->hvalue.ptr, p_hdr->hvalue.slen);589 PyTuple_SetItem(tuple, 1, str);590 PyList_SetItem(py_hdr_list, i, tuple);591 p_hdr = p_hdr->next;592 }593 }594 595 596 }597 598 671 /* 599 672 * py_pjsua_thread_register 600 * !added @ 061206601 673 */ 602 674 static PyObject *py_pjsua_thread_register(PyObject *pSelf, PyObject *pArgs) 603 675 { 604 605 676 pj_status_t status; 606 677 const char *name; 607 678 PyObject *py_desc; 608 679 pj_thread_t *thread; 609 void *thread_desc; 610 #if 0 611 int size; 612 int i; 613 int *td; 614 #endif 615 616 PJ_UNUSED_ARG(pSelf); 617 618 if (!PyArg_ParseTuple(pArgs, "sO", &name, &py_desc)) 619 { 680 struct py_thread_desc *thread_desc; 681 682 PJ_UNUSED_ARG(pSelf); 683 684 if (!PyArg_ParseTuple(pArgs, "sO", &name, &py_desc)) { 620 685 return NULL; 621 686 } 622 #if 0 623 size = PyList_Size(py_desc); 624 td = (int *)malloc(size * sizeof(int)); 625 for (i = 0; i < size; i++) 626 { 627 if (!PyArg_Parse(PyList_GetItem(py_desc,i),"i", td[i])) 628 { 629 return NULL; 630 } 631 } 632 thread_desc = td; 633 #else 634 thread_desc = malloc(sizeof(pj_thread_desc)); 635 #endif 636 status = pj_thread_register(name, thread_desc, &thread); 687 thread_desc = (struct py_thread_desc*) 688 malloc(sizeof(struct py_thread_desc)); 689 thread_desc->next = py_thread_desc; 690 py_thread_desc = thread_desc; 691 692 status = pj_thread_register(name, thread_desc->desc, &thread); 637 693 638 694 if (status == PJ_SUCCESS) 639 status = pj_thread_local_set(thread_id, (void*)1); 695 status = pj_thread_local_set(g_thread_id, (void*)1); 696 640 697 return Py_BuildValue("i",status); 641 698 } … … 643 700 /* 644 701 * py_pjsua_logging_config_default 645 * !modified @ 051206646 702 */ 647 703 static PyObject *py_pjsua_logging_config_default(PyObject *pSelf, 648 704 PyObject *pArgs) 649 705 { 650 706 PyObj_pjsua_logging_config *obj; … … 652 708 653 709 PJ_UNUSED_ARG(pSelf); 654 655 if (!PyArg_ParseTuple(pArgs, "")) 656 { 657 return NULL; 658 } 659 710 PJ_UNUSED_ARG(pArgs); 711 660 712 pjsua_logging_config_default(&cfg); 661 obj = (PyObj_pjsua_logging_config *) PyObj_pjsua_logging_config_new 662 (&PyTyp_pjsua_logging_config,NULL,NULL); 713 obj = (PyObj_pjsua_logging_config*) 714 PyObj_pjsua_logging_config_new(&PyTyp_pjsua_logging_config, 715 NULL, NULL); 663 716 PyObj_pjsua_logging_config_import(obj, &cfg); 664 717 665 return (PyObject 718 return (PyObject*)obj; 666 719 } 667 720 … … 669 722 /* 670 723 * py_pjsua_config_default 671 * !modified @ 051206672 724 */ 673 725 static PyObject *py_pjsua_config_default(PyObject *pSelf, PyObject *pArgs) … … 677 729 678 730 PJ_UNUSED_ARG(pSelf); 679 680 if (!PyArg_ParseTuple(pArgs, "")) 681 { 682 return NULL; 683 } 731 PJ_UNUSED_ARG(pArgs); 732 684 733 pjsua_config_default(&cfg); 685 obj = (PyObj_pjsua_config *) PyObj_pjsua_config_new(&PyTyp_pjsua_config, NULL, NULL); 734 obj = (PyObj_pjsua_config *) PyObj_pjsua_config_new(&PyTyp_pjsua_config, 735 NULL, NULL); 686 736 PyObj_pjsua_config_import(obj, &cfg); 687 737 688 return (PyObject 738 return (PyObject*)obj; 689 739 } 690 740 … … 692 742 /* 693 743 * py_pjsua_media_config_default 694 * !modified @ 051206695 744 */ 696 745 static PyObject * py_pjsua_media_config_default(PyObject *pSelf, … … 701 750 702 751 PJ_UNUSED_ARG(pSelf); 703 704 if (!PyArg_ParseTuple(pArgs, "")) 705 { 706 return NULL; 707 } 752 PJ_UNUSED_ARG(pArgs); 753 708 754 pjsua_media_config_default(&cfg); 709 755 obj = (PyObj_pjsua_media_config *) 710 756 PyType_GenericNew(&PyTyp_pjsua_media_config, NULL, NULL); 711 757 PyObj_pjsua_media_config_import(obj, &cfg); 758 712 759 return (PyObject *)obj; 713 760 } … … 716 763 /* 717 764 * py_pjsua_msg_data_init 718 * !modified @ 051206719 765 */ 720 766 static PyObject *py_pjsua_msg_data_init(PyObject *pSelf, PyObject *pArgs) 721 767 { 722 PyObj_pjsua_msg_data *obj; 723 pjsua_msg_data msg; 724 725 PJ_UNUSED_ARG(pSelf); 726 727 if (!PyArg_ParseTuple(pArgs, "")) 728 { 729 return NULL; 730 } 731 pjsua_msg_data_init(&msg); 732 obj = (PyObj_pjsua_msg_data *)PyObj_pjsua_msg_data_new(&PyTyp_pjsua_msg_data, NULL, NULL); 733 Py_XDECREF(obj->content_type); 734 obj->content_type = PyString_FromStringAndSize( 735 msg.content_type.ptr, msg.content_type.slen 736 ); 737 Py_XDECREF(obj->msg_body); 738 obj->msg_body = PyString_FromStringAndSize( 739 msg.msg_body.ptr, msg.msg_body.slen 740 ); 741 742 translate_hdr_rev((pjsip_generic_string_hdr *)&msg.hdr_list,obj->hdr_list); 743 744 return (PyObject *)obj; 768 PJ_UNUSED_ARG(pSelf); 769 PJ_UNUSED_ARG(pArgs); 770 771 return (PyObject *)PyObj_pjsua_msg_data_new(&PyTyp_pjsua_msg_data, 772 NULL, NULL); 745 773 } 746 774 … … 749 777 * py_pjsua_reconfigure_logging 750 778 */ 751 static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, PyObject *pArgs) 752 { 753 PyObject * logObj; 754 PyObj_pjsua_logging_config *log; 755 pjsua_logging_config cfg; 779 static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, 780 PyObject *pArgs) 781 { 782 PyObject *logObj; 756 783 pj_status_t status; 757 784 758 785 PJ_UNUSED_ARG(pSelf); 759 786 760 if (!PyArg_ParseTuple(pArgs, "O", &logObj)) 761 { 762 return NULL; 763 } 764 if (logObj != Py_None) 765 { 766 log = (PyObj_pjsua_logging_config *)logObj; 787 if (!PyArg_ParseTuple(pArgs, "O", &logObj)) { 788 return NULL; 789 } 790 791 if (logObj != Py_None) { 792 PyObj_pjsua_logging_config *log; 793 pjsua_logging_config cfg; 794 795 log = (PyObj_pjsua_logging_config*)logObj; 767 796 cfg.msg_logging = log->msg_logging; 768 797 cfg.level = log->level; 769 798 cfg.console_level = log->console_level; 770 799 cfg.decor = log->decor; 771 cfg.log_filename.ptr = PyString_AsString(log->log_filename); 772 cfg.log_filename.slen = strlen(cfg.log_filename.ptr); 773 Py_XDECREF(obj_log_cb); 774 obj_log_cb = log->cb; 775 Py_INCREF(obj_log_cb); 800 cfg.log_filename = PyString_ToPJ(log->log_filename); 801 Py_XDECREF(g_obj_log_cb); 802 g_obj_log_cb = log->cb; 803 Py_INCREF(g_obj_log_cb); 776 804 cfg.cb = &cb_log_cb; 777 805 status = pjsua_reconfigure_logging(&cfg); … … 779 807 status = pjsua_reconfigure_logging(NULL); 780 808 } 809 781 810 return Py_BuildValue("i",status); 782 }783 784 785 /*786 * py_pjsua_pool_create787 */788 static PyObject *py_pjsua_pool_create(PyObject *pSelf, PyObject *pArgs)789 {790 pj_size_t init_size;791 pj_size_t increment;792 const char * name;793 pj_pool_t *p;794 PyObj_pj_pool *pool;795 796 PJ_UNUSED_ARG(pSelf);797 798 if (!PyArg_ParseTuple(pArgs, "sII", &name, &init_size, &increment))799 {800 return NULL;801 }802 803 p = pjsua_pool_create(name, init_size, increment);804 pool = (PyObj_pj_pool *)PyType_GenericNew(&PyTyp_pj_pool_t, NULL, NULL);805 pool->pool = p;806 return (PyObject *)pool;807 808 }809 810 811 /*812 * py_pjsua_get_pjsip_endpt813 */814 static PyObject *py_pjsua_get_pjsip_endpt(PyObject *pSelf, PyObject *pArgs)815 {816 PyObj_pjsip_endpoint *endpt;817 pjsip_endpoint *e;818 819 PJ_UNUSED_ARG(pSelf);820 821 if (!PyArg_ParseTuple(pArgs, ""))822 {823 return NULL;824 }825 e = pjsua_get_pjsip_endpt();826 endpt = (PyObj_pjsip_endpoint *)PyType_GenericNew(827 &PyTyp_pjsip_endpoint, NULL, NULL828 );829 endpt->endpt = e;830 return (PyObject *)endpt;831 }832 833 834 /*835 * py_pjsua_get_pjmedia_endpt836 */837 static PyObject *py_pjsua_get_pjmedia_endpt(PyObject *pSelf, PyObject *pArgs)838 {839 PyObj_pjmedia_endpt *endpt;840 pjmedia_endpt *e;841 842 PJ_UNUSED_ARG(pSelf);843 844 if (!PyArg_ParseTuple(pArgs, ""))845 {846 return NULL;847 }848 e = pjsua_get_pjmedia_endpt();849 endpt = (PyObj_pjmedia_endpt *)PyType_GenericNew(850 &PyTyp_pjmedia_endpt, NULL, NULL851 );852 endpt->endpt = e;853 return (PyObject *)endpt;854 }855 856 857 /*858 * py_pjsua_get_pool_factory859 */860 static PyObject *py_pjsua_get_pool_factory(PyObject *pSelf, PyObject *pArgs)861 {862 PyObj_pj_pool_factory *pool;863 pj_pool_factory *p;864 865 PJ_UNUSED_ARG(pSelf);866 867 if (!PyArg_ParseTuple(pArgs, ""))868 {869 return NULL;870 }871 p = pjsua_get_pool_factory();872 pool = (PyObj_pj_pool_factory *)PyType_GenericNew(873 &PyTyp_pj_pool_factory, NULL, NULL874 );875 pool->pool_fact = p;876 return (PyObject *)pool;877 811 } 878 812 … … 889 823 PJ_UNUSED_ARG(pSelf); 890 824 891 if (!PyArg_ParseTuple(pArgs, "ssi", &sender, &title, &status)) 892 { 825 if (!PyArg_ParseTuple(pArgs, "ssi", &sender, &title, &status)) { 893 826 return NULL; 894 827 } 895 828 896 829 pjsua_perror(sender, title, status); 897 Py_INCREF(Py_None); 898 return Py_ None;830 831 return Py_BuildValue(""); 899 832 } 900 833 … … 908 841 909 842 PJ_UNUSED_ARG(pSelf); 910 911 if (!PyArg_ParseTuple(pArgs, "")) 912 { 913 return NULL; 914 } 843 PJ_UNUSED_ARG(pArgs); 844 915 845 status = pjsua_create(); 916 846 917 if (status == PJ_SUCCESS) 918 { 919 status = pj_thread_local_alloc(&thread_id); 847 if (status == PJ_SUCCESS) { 848 status = pj_thread_local_alloc(&g_thread_id); 920 849 if (status == PJ_SUCCESS) 921 status = pj_thread_local_set(thread_id, (void*)1); 850 status = pj_thread_local_set(g_thread_id, (void*)1); 851 852 pj_atexit(&clear_py_thread_desc); 922 853 } 923 854 … … 939 870 PJ_UNUSED_ARG(pSelf); 940 871 941 if (!PyArg_ParseTuple(pArgs, "OOO", &o_ua_cfg, &o_log_cfg, &o_media_cfg)) 942 { 872 if (!PyArg_ParseTuple(pArgs, "OOO", &o_ua_cfg, &o_log_cfg, &o_media_cfg)) { 943 873 return NULL; 944 874 } … … 948 878 pjsua_media_config_default(&cfg_media); 949 879 950 if (o_ua_cfg != Py_None) 951 { 880 if (o_ua_cfg != Py_None) { 952 881 PyObj_pjsua_config *obj_ua_cfg = (PyObj_pjsua_config*)o_ua_cfg; 953 882 954 883 PyObj_pjsua_config_export(&cfg_ua, obj_ua_cfg); 955 884 885 Py_XDECREF(g_obj_callback); 956 886 g_obj_callback = obj_ua_cfg->cb; 957 887 Py_INCREF(g_obj_callback); … … 978 908 } 979 909 980 if (o_log_cfg != Py_None) 981 { 910 if (o_log_cfg != Py_None) { 982 911 PyObj_pjsua_logging_config * obj_log; 983 912 … … 986 915 PyObj_pjsua_logging_config_export(&cfg_log, obj_log); 987 916 988 Py_XDECREF( obj_log_cb);989 obj_log_cb = obj_log->cb;990 Py_INCREF( obj_log_cb);917 Py_XDECREF(g_obj_log_cb); 918 g_obj_log_cb = obj_log->cb; 919 Py_INCREF(g_obj_log_cb); 991 920 992 921 cfg_log.cb = &cb_log_cb; … … 997 926 } 998 927 999 if (o_media_cfg != Py_None) 1000 { 928 if (o_media_cfg != Py_None) { 1001 929 PyObj_pjsua_media_config_export(&cfg_media, 1002 930 (PyObj_pjsua_media_config*)o_media_cfg); … … 1008 936 1009 937 status = pjsua_init(p_cfg_ua, p_cfg_log, p_cfg_media); 1010 return Py_BuildValue("i",status); 938 939 return Py_BuildValue("i", status); 1011 940 } 1012 941 … … 1020 949 1021 950 PJ_UNUSED_ARG(pSelf); 1022 1023 if (!PyArg_ParseTuple(pArgs, "")) 1024 { 1025 return NULL; 1026 } 951 PJ_UNUSED_ARG(pArgs); 952 1027 953 status = pjsua_start(); 1028 954 1029 return Py_BuildValue("i", status);955 return Py_BuildValue("i", status); 1030 956 } 1031 957 … … 1039 965 1040 966 PJ_UNUSED_ARG(pSelf); 1041 1042 if (!PyArg_ParseTuple(pArgs, "")) 1043 { 1044 return NULL; 1045 } 967 PJ_UNUSED_ARG(pArgs); 968 1046 969 status = pjsua_destroy(); 1047 970 1048 return Py_BuildValue("i", status);971 return Py_BuildValue("i", status); 1049 972 } 1050 973 … … 1056 979 { 1057 980 int ret; 1058 unsigned msec; 1059 1060 PJ_UNUSED_ARG(pSelf); 1061 1062 if (!PyArg_ParseTuple(pArgs, "i", &msec)) 1063 { 1064 return NULL; 1065 } 1066 981 int msec; 982 983 PJ_UNUSED_ARG(pSelf); 984 985 if (!PyArg_ParseTuple(pArgs, "i", &msec)) { 986 return NULL; 987 } 988 989 if (msec < 0) 990 msec = 0; 991 992 #if !NO_PJSIP_THREAD 1067 993 /* Since handle_events() will block, we must wrap it with ALLOW_THREADS 1068 994 * construct, or otherwise many Python blocking functions (such as … … 1071 997 */ 1072 998 Py_BEGIN_ALLOW_THREADS 999 #endif 1000 1073 1001 ret = pjsua_handle_events(msec); 1002 1003 #if !NO_PJSIP_THREAD 1074 1004 Py_END_ALLOW_THREADS 1075 1076 return Py_BuildValue("i",ret); 1005 #endif 1006 1007 return Py_BuildValue("i", ret); 1077 1008 } 1078 1009 … … 1088 1019 PJ_UNUSED_ARG(pSelf); 1089 1020 1090 if (!PyArg_ParseTuple(pArgs, "s", &url)) 1091 {1092 return NULL;1093 } 1021 if (!PyArg_ParseTuple(pArgs, "s", &url)) { 1022 return NULL; 1023 } 1024 1094 1025 status = pjsua_verify_sip_url(url); 1095 1026 1096 return Py_BuildValue("i", status);1027 return Py_BuildValue("i", status); 1097 1028 } 1098 1029 … … 1155 1086 "c_url: The URL, as NULL terminated string."; 1156 1087 1157 static char pjsua_pool_create_doc[] =1158 "_pjsua.Pj_Pool _pjsua.pool_create (string name, int init_size, "1159 "int increment) "1160 "Create memory pool Parameters: "1161 "name: Optional pool name; "1162 "init_size: Initial size of the pool; "1163 "increment: Increment size.";1164 1165 static char pjsua_get_pjsip_endpt_doc[] =1166 "_pjsua.Pjsip_Endpoint _pjsua.get_pjsip_endpt (void) "1167 "Internal function to get SIP endpoint instance of pjsua, which is needed "1168 "for example to register module, create transports, etc. Probably is only "1169 "valid after pjsua_init() is called.";1170 1171 static char pjsua_get_pjmedia_endpt_doc[] =1172 "_pjsua.Pjmedia_Endpt _pjsua.get_pjmedia_endpt (void) "1173 "Internal function to get media endpoint instance. Only valid after "1174 "pjsua_init() is called.";1175 1176 static char pjsua_get_pool_factory_doc[] =1177 "_pjsua.Pj_Pool_Factory _pjsua.get_pool_factory (void) "1178 "Internal function to get PJSUA pool factory. Only valid after "1179 "pjsua_init() is called.";1180 1181 1088 static char pjsua_reconfigure_logging_doc[] = 1182 1089 "int _pjsua.reconfigure_logging (_pjsua.Logging_Config c) " … … 1208 1115 /* 1209 1116 * py_pjsua_transport_config_default 1210 * !modified @ 0512061211 1117 */ 1212 1118 static PyObject *py_pjsua_transport_config_default(PyObject *pSelf, … … 1217 1123 1218 1124 PJ_UNUSED_ARG(pSelf); 1219 1220 if (!PyArg_ParseTuple(pArgs, "")) { 1221 return NULL; 1222 } 1125 PJ_UNUSED_ARG(pArgs); 1223 1126 1224 1127 pjsua_transport_config_default(&cfg); … … 1233 1136 /* 1234 1137 * py_pjsua_transport_create 1235 * !modified @ 0512061236 1138 */ 1237 1139 static PyObject *py_pjsua_transport_create(PyObject *pSelf, PyObject *pArgs) … … 1239 1141 pj_status_t status; 1240 1142 int type; 1241 PyObject * tmpObj;1143 PyObject *pCfg; 1242 1144 pjsua_transport_config cfg; 1243 1145 pjsua_transport_id id; … … 1245 1147 PJ_UNUSED_ARG(pSelf); 1246 1148 1247 if (!PyArg_ParseTuple(pArgs, "iO", &type, & tmpObj)) {1248 return NULL; 1249 } 1250 1251 if ( tmpObj!= Py_None) {1149 if (!PyArg_ParseTuple(pArgs, "iO", &type, &pCfg)) { 1150 return NULL; 1151 } 1152 1153 if (pCfg != Py_None) { 1252 1154 PyObj_pjsua_transport_config *obj; 1253 obj = (PyObj_pjsua_transport_config*)tmpObj; 1155 1156 obj = (PyObj_pjsua_transport_config*)pCfg; 1254 1157 PyObj_pjsua_transport_config_export(&cfg, obj); 1255 1158 status = pjsua_transport_create(type, &cfg, &id); … … 1264 1167 /* 1265 1168 * py_pjsua_enum_transports 1266 * !modified @ 2612061267 1169 */ 1268 1170 static PyObject *py_pjsua_enum_transports(PyObject *pSelf, PyObject *pArgs) … … 1270 1172 pj_status_t status; 1271 1173 PyObject *list; 1272 1273 1174 pjsua_transport_id id[PJSIP_MAX_TRANSPORTS]; 1274 1175 unsigned c, i; 1275 1176 1276 1177 PJ_UNUSED_ARG(pSelf); 1277 1278 if (!PyArg_ParseTuple(pArgs, "")) 1279 { 1280 return NULL; 1281 } 1282 1178 PJ_UNUSED_ARG(pArgs); 1179 1283 1180 c = PJ_ARRAY_SIZE(id); 1284 1181 status = pjsua_enum_transports(id, &c); 1285 1182 1286 1183 list = PyList_New(c); 1287 for (i = 0; i < c; i++) 1288 { 1289 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 1290 if (ret == -1) 1291 { 1292 return NULL; 1293 } 1294 } 1295 1296 return Py_BuildValue("O",list); 1184 for (i = 0; i < c; i++) { 1185 PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 1186 } 1187 1188 return (PyObject*)list; 1297 1189 } 1298 1190 … … 1320 1212 NULL, NULL); 1321 1213 PyObj_pjsua_transport_info_import(obj, &info); 1322 return Py_BuildValue("O", obj);1214 return (PyObject*)obj; 1323 1215 } else { 1324 Py_INCREF(Py_None); 1325 return Py_None; 1216 return Py_BuildValue(""); 1326 1217 } 1327 1218 } … … 1330 1221 * py_pjsua_transport_set_enable 1331 1222 */ 1332 static PyObject *py_pjsua_transport_set_enable 1333 (PyObject *pSelf,PyObject *pArgs)1223 static PyObject *py_pjsua_transport_set_enable(PyObject *pSelf, 1224 PyObject *pArgs) 1334 1225 { 1335 1226 pj_status_t status; … … 1339 1230 PJ_UNUSED_ARG(pSelf); 1340 1231 1341 if (!PyArg_ParseTuple(pArgs, "ii", &id, &enabled)) 1342 { 1343 return NULL; 1344 } 1345 status = pjsua_transport_set_enable(id, enabled); 1346 1347 return Py_BuildValue("i",status); 1232 if (!PyArg_ParseTuple(pArgs, "ii", &id, &enabled)) { 1233 return NULL; 1234 } 1235 status = pjsua_transport_set_enable(id, enabled); 1236 1237 return Py_BuildValue("i", status); 1348 1238 } 1349 1239 … … 1359 1249 PJ_UNUSED_ARG(pSelf); 1360 1250 1361 if (!PyArg_ParseTuple(pArgs, "ii", &id, &force)) 1362 { 1251 if (!PyArg_ParseTuple(pArgs, "ii", &id, &force)) { 1363 1252 return NULL; 1364 1253 } 1365 1254 status = pjsua_transport_close(id, force); 1366 1255 1367 return Py_BuildValue("i", status);1256 return Py_BuildValue("i", status); 1368 1257 } 1369 1258 … … 1406 1295 /* 1407 1296 * py_pjsua_acc_config_default 1408 * !modified @ 0512061409 1297 */ 1410 1298 static PyObject *py_pjsua_acc_config_default(PyObject *pSelf, PyObject *pArgs) … … 1414 1302 1415 1303 PJ_UNUSED_ARG(pSelf); 1304 PJ_UNUSED_ARG(pArgs); 1416 1305 1417 1306 if (!PyArg_ParseTuple(pArgs, "")) { … … 1435 1324 1436 1325 PJ_UNUSED_ARG(pSelf); 1437 1438 if (!PyArg_ParseTuple(pArgs, "")) { 1439 return NULL; 1440 } 1326 PJ_UNUSED_ARG(pArgs); 1441 1327 1442 1328 count = pjsua_acc_get_count(); 1443 return Py_BuildValue("i", count);1329 return Py_BuildValue("i", count); 1444 1330 } 1445 1331 … … 1488 1374 1489 1375 PJ_UNUSED_ARG(pSelf); 1490 1491 if (!PyArg_ParseTuple(pArgs, "")) { 1492 return NULL; 1493 } 1376 PJ_UNUSED_ARG(pArgs); 1494 1377 1495 1378 id = pjsua_acc_get_default(); … … 1500 1383 /* 1501 1384 * py_pjsua_acc_add 1502 * !modified @ 0512061503 1385 */ 1504 1386 static PyObject *py_pjsua_acc_add(PyObject *pSelf, PyObject *pArgs) 1505 1387 { 1506 1388 int is_default; 1507 PyObject * acObj; 1508 PyObj_pjsua_acc_config * ac; 1389 PyObject *pCfg; 1509 1390 int acc_id; 1510 1391 int status; … … 1512 1393 PJ_UNUSED_ARG(pSelf); 1513 1394 1514 if (!PyArg_ParseTuple(pArgs, "Oi", & acObj, &is_default)) {1515 return NULL; 1516 } 1517 1518 if ( acObj!= Py_None) {1395 if (!PyArg_ParseTuple(pArgs, "Oi", &pCfg, &is_default)) { 1396 return NULL; 1397 } 1398 1399 if (pCfg != Py_None) { 1519 1400 pjsua_acc_config cfg; 1401 PyObj_pjsua_acc_config *ac; 1520 1402 1521 1403 pjsua_acc_config_default(&cfg); 1522 ac = (PyObj_pjsua_acc_config *) acObj;1404 ac = (PyObj_pjsua_acc_config *)pCfg; 1523 1405 PyObj_pjsua_acc_config_export(&cfg, ac); 1524 1406 status = pjsua_acc_add(&cfg, is_default, &acc_id); … … 1533 1415 /* 1534 1416 * py_pjsua_acc_add_local 1535 * !modified @ 0512061536 1417 */ 1537 1418 static PyObject *py_pjsua_acc_add_local(PyObject *pSelf, PyObject *pArgs) … … 1539 1420 int is_default; 1540 1421 int tid; 1541 int p_acc_id;1422 int acc_id; 1542 1423 int status; 1543 1424 … … 1548 1429 } 1549 1430 1550 1551 status = pjsua_acc_add_local(tid, is_default, &p_acc_id); 1552 1553 return Py_BuildValue("ii", status, p_acc_id); 1431 status = pjsua_acc_add_local(tid, is_default, &acc_id); 1432 1433 return Py_BuildValue("ii", status, acc_id); 1434 } 1435 1436 /* 1437 * py_pjsua_acc_set_user_data 1438 */ 1439 static PyObject *py_pjsua_acc_set_user_data(PyObject *pSelf, PyObject *pArgs) 1440 { 1441 int acc_id; 1442 PyObject *pUserData, *old_user_data; 1443 int status; 1444 1445 PJ_UNUSED_ARG(pSelf); 1446 1447 if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &pUserData)) { 1448 return NULL; 1449 } 1450 1451 old_user_data = (PyObject*) pjsua_acc_get_user_data(acc_id); 1452 1453 status = pjsua_acc_set_user_data(acc_id, (void*)pUserData); 1454 1455 if (status == PJ_SUCCESS) { 1456 Py_XINCREF(pUserData); 1457 Py_XDECREF(old_user_data); 1458 } 1459 1460 return Py_BuildValue("i", status); 1461 } 1462 1463 /* 1464 * py_pjsua_acc_get_user_data 1465 */ 1466 static PyObject *py_pjsua_acc_get_user_data(PyObject *pSelf, PyObject *pArgs) 1467 { 1468 int acc_id; 1469 PyObject *user_data; 1470 1471 PJ_UNUSED_ARG(pSelf); 1472 1473 if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) { 1474 return NULL; 1475 } 1476 1477 user_data = (PyObject*) pjsua_acc_get_user_data(acc_id); 1478 1479 return user_data ? Py_BuildValue("O", user_data) : Py_BuildValue(""); 1554 1480 } 1555 1481 … … 1560 1486 { 1561 1487 int acc_id; 1488 PyObject *user_data; 1562 1489 int status; 1563 1490 1564 1491 PJ_UNUSED_ARG(pSelf); 1565 1492 1566 if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) 1567 { 1568 return NULL; 1569 } 1570 1571 1572 status = pjsua_acc_del(acc_id); 1493 if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) { 1494 return NULL; 1495 } 1496 1497 user_data = (PyObject*) pjsua_acc_get_user_data(acc_id); 1498 Py_XDECREF(user_data); 1499 1500 status = pjsua_acc_del(acc_id); 1501 1573 1502 return Py_BuildValue("i", status); 1574 1503 } … … 1579 1508 static PyObject *py_pjsua_acc_modify(PyObject *pSelf, PyObject *pArgs) 1580 1509 { 1581 PyObject * acObj;1510 PyObject *pCfg; 1582 1511 PyObj_pjsua_acc_config * ac; 1583 1512 int acc_id; … … 1586 1515 PJ_UNUSED_ARG(pSelf); 1587 1516 1588 if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, & acObj)) {1589 return NULL; 1590 } 1591 1592 if ( acObj!= Py_None) {1517 if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &pCfg)) { 1518 return NULL; 1519 } 1520 1521 if (pCfg != Py_None) { 1593 1522 pjsua_acc_config cfg; 1594 1523 1595 1524 pjsua_acc_config_default(&cfg); 1596 ac = (PyObj_pjsua_acc_config *)acObj;1525 ac = (PyObj_pjsua_acc_config*)pCfg; 1597 1526 PyObj_pjsua_acc_config_export(&cfg, ac); 1598 1527 … … 1634 1563 int acc_id; 1635 1564 int activity_id; 1636 const char *activity_text ;1637 const char *rpid_id ;1565 const char *activity_text = NULL; 1566 const char *rpid_id = NULL; 1638 1567 pjrpid_element rpid; 1639 1568 pj_status_t status; … … 1642 1571 1643 1572 if (!PyArg_ParseTuple(pArgs, "iiiss", &acc_id, &is_online, 1644 &activity_id, &activity_text, &rpid_id)) { 1573 &activity_id, &activity_text, &rpid_id)) 1574 { 1645 1575 return NULL; 1646 1576 } … … 1649 1579 rpid.type = PJRPID_ELEMENT_TYPE_PERSON; 1650 1580 rpid.activity = activity_id; 1651 rpid.note = pj_str((char*)activity_text); 1581 if (activity_text) 1582 rpid.note = pj_str((char*)activity_text); 1652 1583 1653 1584 if (rpid_id) … … 1682 1613 /* 1683 1614 * py_pjsua_acc_get_info 1684 * !modified @ 0512061685 1615 */ 1686 1616 static PyObject *py_pjsua_acc_get_info(PyObject *pSelf, PyObject *pArgs) … … 1699 1629 status = pjsua_acc_get_info(acc_id, &info); 1700 1630 if (status == PJ_SUCCESS) { 1701 obj = (PyObj_pjsua_acc_info 1702 PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info,NULL, NULL);1631 obj = (PyObj_pjsua_acc_info*) 1632 PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info, NULL, NULL); 1703 1633 PyObj_pjsua_acc_info_import(obj, &info); 1704 return Py_BuildValue("O", obj);1634 return (PyObject*)obj; 1705 1635 } else { 1706 Py_INCREF(Py_None); 1707 return Py_None; 1636 return Py_BuildValue(""); 1708 1637 } 1709 1638 } … … 1711 1640 /* 1712 1641 * py_pjsua_enum_accs 1713 * !modified @ 2412061714 1642 */ 1715 1643 static PyObject *py_pjsua_enum_accs(PyObject *pSelf, PyObject *pArgs) … … 1717 1645 pj_status_t status; 1718 1646 PyObject *list; 1719 1720 1647 pjsua_acc_id id[PJSUA_MAX_ACC]; 1721 1648 unsigned c, i; 1722 1649 1723 1650 PJ_UNUSED_ARG(pSelf); 1724 1725 if (!PyArg_ParseTuple(pArgs, "")) 1726 { 1727 return NULL; 1728 } 1651 PJ_UNUSED_ARG(pArgs); 1652 1729 1653 c = PJ_ARRAY_SIZE(id); 1730 1731 1654 status = pjsua_enum_accs(id, &c); 1655 if (status != PJ_SUCCESS) 1656 c = 0; 1732 1657 1733 1658 list = PyList_New(c); 1734 for (i = 0; i < c; i++) 1735 { 1736 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 1737 if (ret == -1) 1738 { 1739 return NULL; 1740 } 1741 } 1742 1743 return Py_BuildValue("O",list); 1659 for (i = 0; i < c; i++) { 1660 PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 1661 } 1662 1663 return (PyObject*)list; 1744 1664 } 1745 1665 1746 1666 /* 1747 1667 * py_pjsua_acc_enum_info 1748 * !modified @ 2412061749 1668 */ 1750 1669 static PyObject *py_pjsua_acc_enum_info(PyObject *pSelf, PyObject *pArgs) … … 1756 1675 1757 1676 PJ_UNUSED_ARG(pSelf); 1677 PJ_UNUSED_ARG(pArgs); 1758 1678 1759 1679 if (!PyArg_ParseTuple(pArgs, "")) { … … 1763 1683 c = PJ_ARRAY_SIZE(info); 1764 1684 status = pjsua_acc_enum_info(info, &c); 1765 1685 if (status != PJ_SUCCESS) 1686 c = 0; 1687 1766 1688 list = PyList_New(c); 1767 1689 for (i = 0; i < c; i++) { … … 1772 1694 PyObj_pjsua_acc_info_import(obj, &info[i]); 1773 1695 1774 PyList_SetItem(list, i, (PyObject *)obj); 1775 } 1776 1777 return Py_BuildValue("O",list); 1778 } 1779 1780 /* 1781 * py_pjsua_acc_find_for_outgoing 1782 */ 1783 static PyObject *py_pjsua_acc_find_for_outgoing(PyObject *pSelf, 1784 PyObject *pArgs) 1785 { 1786 int acc_id; 1787 PyObject * url; 1788 pj_str_t str; 1789 1790 PJ_UNUSED_ARG(pSelf); 1791 1792 if (!PyArg_ParseTuple(pArgs, "O", &url)) 1793 { 1794 return NULL; 1795 } 1796 str.ptr = PyString_AsString(url); 1797 str.slen = strlen(PyString_AsString(url)); 1798 1799 acc_id = pjsua_acc_find_for_outgoing(&str); 1800 1801 return Py_BuildValue("i", acc_id); 1802 } 1803 1804 /* 1805 * py_pjsua_acc_find_for_incoming 1806 */ 1807 static PyObject *py_pjsua_acc_find_for_incoming(PyObject *pSelf, 1808 PyObject *pArgs) 1809 { 1810 int acc_id; 1811 PyObject * tmpObj; 1812 PyObj_pjsip_rx_data * obj; 1813 pjsip_rx_data * rdata; 1814 1815 PJ_UNUSED_ARG(pSelf); 1816 1817 if (!PyArg_ParseTuple(pArgs, "O", &tmpObj)) 1818 { 1819 return NULL; 1820 } 1821 if (tmpObj != Py_None) 1822 { 1823 obj = (PyObj_pjsip_rx_data *)tmpObj; 1824 rdata = obj->rdata; 1825 acc_id = pjsua_acc_find_for_incoming(rdata); 1826 } else { 1827 acc_id = pjsua_acc_find_for_incoming(NULL); 1828 } 1829 return Py_BuildValue("i", acc_id); 1830 } 1831 1832 /* 1833 * py_pjsua_acc_create_uac_contact 1834 * !modified @ 061206 1835 */ 1836 static PyObject *py_pjsua_acc_create_uac_contact(PyObject *pSelf, 1837 PyObject *pArgs) 1838 { 1839 int status; 1840 int acc_id; 1841 PyObject * pObj; 1842 PyObj_pj_pool * p; 1843 pj_pool_t * pool; 1844 PyObject * strc; 1845 pj_str_t contact; 1846 PyObject * stru; 1847 pj_str_t uri; 1848 1849 PJ_UNUSED_ARG(pSelf); 1850 1851 if (!PyArg_ParseTuple(pArgs, "OiO", &pObj, &acc_id, &stru)) 1852 { 1853 return NULL; 1854 } 1855 if (pObj != Py_None) 1856 { 1857 p = (PyObj_pj_pool *)pObj; 1858 pool = p->pool; 1859 uri.ptr = PyString_AsString(stru); 1860 uri.slen = strlen(PyString_AsString(stru)); 1861 status = pjsua_acc_create_uac_contact(pool, &contact, acc_id, &uri); 1862 } else { 1863 status = pjsua_acc_create_uac_contact(NULL, &contact, acc_id, &uri); 1864 } 1865 strc = PyString_FromStringAndSize(contact.ptr, contact.slen); 1866 1867 return Py_BuildValue("O", strc); 1868 } 1869 1870 /* 1871 * py_pjsua_acc_create_uas_contact 1872 * !modified @ 061206 1873 */ 1874 static PyObject *py_pjsua_acc_create_uas_contact(PyObject *pSelf, 1875 PyObject *pArgs) 1876 { 1877 int status; 1878 int acc_id; 1879 PyObject * pObj; 1880 PyObj_pj_pool * p; 1881 pj_pool_t * pool; 1882 PyObject * strc; 1883 pj_str_t contact; 1884 PyObject * rObj; 1885 PyObj_pjsip_rx_data * objr; 1886 pjsip_rx_data * rdata; 1887 1888 PJ_UNUSED_ARG(pSelf); 1889 1890 if (!PyArg_ParseTuple(pArgs, "OiO", &pObj, &acc_id, &rObj)) 1891 { 1892 return NULL; 1893 } 1894 if (pObj != Py_None) 1895 { 1896 p = (PyObj_pj_pool *)pObj; 1897 pool = p->pool; 1898 } else { 1899 pool = NULL; 1900 } 1901 if (rObj != Py_None) 1902 { 1903 objr = (PyObj_pjsip_rx_data *)rObj; 1904 rdata = objr->rdata; 1905 } else { 1906 rdata = NULL; 1907 } 1908 status = pjsua_acc_create_uas_contact(pool, &contact, acc_id, rdata); 1909 strc = PyString_FromStringAndSize(contact.ptr, contact.slen); 1910 1911 return Py_BuildValue("O", strc); 1696 PyList_SetItem(list, i, (PyObject*)obj); 1697 } 1698 1699 return (PyObject*)list; 1912 1700 } 1913 1701 … … 1915 1703 * py_pjsua_acc_set_transport 1916 1704 */ 1917 static PyObject *py_pjsua_acc_set_transport 1918 (PyObject *pSelf, PyObject *pArgs) 1705 static PyObject *py_pjsua_acc_set_transport(PyObject *pSelf, PyObject *pArgs) 1919 1706 { 1920 1707 int acc_id, transport_id; … … 1923 1710 PJ_UNUSED_ARG(pSelf); 1924 1711 1925 if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &transport_id)) 1926 { 1712 if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &transport_id)) { 1927 1713 return NULL; 1928 1714 } … … 1938 1724 * py_pjsua_acc_pres_notify 1939 1725 */ 1940 static PyObject *py_pjsua_acc_pres_notify 1941 (PyObject *pSelf, PyObject *pArgs) 1942 { 1943 static char reason_buf[64]; 1726 static PyObject *py_pjsua_acc_pres_notify(PyObject *pSelf, 1727 PyObject *pArgs) 1728 { 1944 1729 int acc_id, state; 1945 PyObject *arg_pres, *arg_msg_data ;1730 PyObject *arg_pres, *arg_msg_data, *arg_reason; 1946 1731 void *srv_pres; 1947 1732 pjsua_msg_data msg_data; 1948 const char *arg_reason;1949 1733 pj_str_t reason; 1950 1734 pj_bool_t with_body; … … 1954 1738 PJ_UNUSED_ARG(pSelf); 1955 1739 1956 if (!PyArg_ParseTuple(pArgs, "iOi sO", &acc_id, &arg_pres,1740 if (!PyArg_ParseTuple(pArgs, "iOiOO", &acc_id, &arg_pres, 1957 1741 &state, &arg_reason, &arg_msg_data)) 1958 1742 { … … 1961 1745 1962 1746 srv_pres = (void*) PyLong_AsLong(arg_pres); 1963 pjsua_msg_data_init(&msg_data);1964 1747 with_body = (state != PJSIP_EVSUB_STATE_TERMINATED); 1965 1748 1966 if (arg_reason) { 1967 strncpy(reason_buf, arg_reason, sizeof(reason_buf)); 1968 reason.ptr = reason_buf; 1969 reason.slen = strlen(arg_reason); 1749 if (arg_reason && PyString_Check(arg_reason)) { 1750 reason = PyString_ToPJ(arg_reason); 1970 1751 } else { 1971 1752 reason = pj_str(""); 1972 1753 } 1973 1754 1755 pjsua_msg_data_init(&msg_data); 1974 1756 if (arg_msg_data && arg_msg_data != Py_None) { 1975 1757 PyObj_pjsua_msg_data *omd = (PyObj_pjsua_msg_data *)arg_msg_data; 1976 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 1977 msg_data.content_type.slen = PyString_Size(omd->content_type); 1978 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 1979 msg_data.msg_body.slen = PyString_Size(omd->msg_body); 1758 msg_data.content_type = PyString_ToPJ(omd->content_type); 1759 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 1980 1760 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 1981 1761 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 1982 } else if (arg_msg_data) {1983 Py_XDECREF(arg_msg_data);1984 1762 } 1985 1763 … … 2049 1827 "_pjsua.Acc_Info[] _pjsua.acc_enum_info () " 2050 1828 "Enum accounts info."; 2051 static char pjsua_acc_find_for_outgoing_doc[] =2052 "int _pjsua.acc_find_for_outgoing (string url) "2053 "This is an internal function to find the most appropriate account "2054 "to used to reach to the specified URL.";2055 static char pjsua_acc_find_for_incoming_doc[] =2056 "int _pjsua.acc_find_for_incoming (PyObj_pjsip_rx_data rdata) "2057 "This is an internal function to find the most appropriate account "2058 "to be used to handle incoming calls.";2059 static char pjsua_acc_create_uac_contact_doc[] =2060 "string _pjsua.acc_create_uac_contact (PyObj_pj_pool pool, "2061 "int acc_id, string uri) "2062 "Create a suitable URI to be put as Contact based on the specified "2063 "target URI for the specified account.";2064 static char pjsua_acc_create_uas_contact_doc[] =2065 "string _pjsua.acc_create_uas_contact (PyObj_pj_pool pool, "2066 "int acc_id, PyObj_pjsip_rx_data rdata) "2067 "Create a suitable URI to be put as Contact based on the information "2068 "in the incoming request.";2069 1829 2070 1830 /* END OF LIB ACCOUNT */ … … 2084 1844 2085 1845 PJ_UNUSED_ARG(pSelf); 2086 2087 if (!PyArg_ParseTuple(pArgs, "")) { 2088 return NULL; 2089 } 2090 1846 PJ_UNUSED_ARG(pArgs); 1847 2091 1848 pjsua_buddy_config_default(&cfg); 2092 1849 obj = (PyObj_pjsua_buddy_config *) … … 2102 1859 static PyObject *py_pjsua_get_buddy_count(PyObject *pSelf, PyObject *pArgs) 2103 1860 { 2104 int ret; 2105 2106 PJ_UNUSED_ARG(pSelf); 2107 2108 if (!PyArg_ParseTuple(pArgs, "")) { 2109 return NULL; 2110 } 2111 ret = pjsua_get_buddy_count(); 2112 2113 return Py_BuildValue("i", ret); 1861 PJ_UNUSED_ARG(pSelf); 1862 PJ_UNUSED_ARG(pArgs); 1863 1864 return Py_BuildValue("i", pjsua_get_buddy_count()); 2114 1865 } 2115 1866 … … 2134 1885 /* 2135 1886 * py_pjsua_enum_buddies 2136 * !modified @ 2412062137 1887 */ 2138 1888 static PyObject *py_pjsua_enum_buddies(PyObject *pSelf, PyObject *pArgs) … … 2140 1890 pj_status_t status; 2141 1891 PyObject *list; 2142 2143 1892 pjsua_buddy_id id[PJSUA_MAX_BUDDIES]; 2144 1893 unsigned c, i; 2145 1894 2146 1895 PJ_UNUSED_ARG(pSelf); 2147 2148 if (!PyArg_ParseTuple(pArgs, "")) { 2149 return NULL; 2150 } 1896 PJ_UNUSED_ARG(pArgs); 1897 2151 1898 c = PJ_ARRAY_SIZE(id); 2152 1899 status = pjsua_enum_buddies(id, &c); 1900 if (status != PJ_SUCCESS) 1901 c = 0; 1902 2153 1903 list = PyList_New(c); 2154 1904 for (i = 0; i < c; i++) { … … 2156 1906 } 2157 1907 2158 return Py_BuildValue("O",list); 1908 return (PyObject*)list; 1909 } 1910 1911 /* 1912 * py_pjsua_buddy_find 1913 */ 1914 static PyObject *py_pjsua_buddy_find(PyObject *pSelf, PyObject *pArgs) 1915 { 1916 PyObject *pURI; 1917 pj_str_t uri; 1918 pjsua_buddy_id buddy_id; 1919 1920 PJ_UNUSED_ARG(pSelf); 1921 1922 if (!PyArg_ParseTuple(pArgs, "O", &pURI)) { 1923 return NULL; 1924 } 1925 1926 if (!PyString_Check(pURI)) 1927 return Py_BuildValue("i", PJSUA_INVALID_ID); 1928 1929 uri = PyString_ToPJ(pURI); 1930 buddy_id = pjsua_buddy_find(&uri); 1931 1932 return Py_BuildValue("i", buddy_id); 2159 1933 } 2160 1934 2161 1935 /* 2162 1936 * py_pjsua_buddy_get_info 2163 * !modified @ 0712062164 1937 */ 2165 1938 static PyObject *py_pjsua_buddy_get_info(PyObject *pSelf, PyObject *pArgs) 2166 1939 { 2167 1940 int buddy_id; 2168 PyObj_pjsua_buddy_info * obj;2169 1941 pjsua_buddy_info info; 2170 1942 int status; … … 2178 1950 status = pjsua_buddy_get_info(buddy_id, &info); 2179 1951 if (status == PJ_SUCCESS) { 1952 PyObj_pjsua_buddy_info *obj; 1953 2180 1954 obj = (PyObj_pjsua_buddy_info *) 2181 PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_info,NULL,NULL); 1955 PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_info, 1956 NULL, NULL); 2182 1957 PyObj_pjsua_buddy_info_import(obj, &info); 2183 return Py_BuildValue("O", obj);1958 return (PyObject*)obj; 2184 1959 } else { 2185 Py_INCREF(Py_None); 2186 return Py_None; 1960 return Py_BuildValue(""); 2187 1961 } 2188 1962 } … … 2190 1964 /* 2191 1965 * py_pjsua_buddy_add 2192 * !modified @ 0612062193 1966 */ 2194 1967 static PyObject *py_pjsua_buddy_add(PyObject *pSelf, PyObject *pArgs) 2195 1968 { 2196 PyObject * bcObj;1969 PyObject *pCfg; 2197 1970 int buddy_id; 2198 1971 int status; … … 2200 1973 PJ_UNUSED_ARG(pSelf); 2201 1974 2202 if (!PyArg_ParseTuple(pArgs, "O", & bcObj)) {2203 return NULL; 2204 } 2205 2206 if ( bcObj!= Py_None) {1975 if (!PyArg_ParseTuple(pArgs, "O", &pCfg)) { 1976 return NULL; 1977 } 1978 1979 if (pCfg != Py_None) { 2207 1980 pjsua_buddy_config cfg; 2208 PyObj_pjsua_buddy_config * 2209 2210 bc = (PyObj_pjsua_buddy_config *) bcObj;1981 PyObj_pjsua_buddy_config *bc; 1982 1983 bc = (PyObj_pjsua_buddy_config *)pCfg; 2211 1984 2212 1985 pjsua_buddy_config_default(&cfg); … … 2214 1987 2215 1988 status = pjsua_buddy_add(&cfg, &buddy_id); 1989 2216 1990 } else { 2217 1991 status = PJ_EINVAL; … … 2228 2002 int buddy_id; 2229 2003 int status; 2004 PyObject *user_data; 2230 2005 2231 2006 PJ_UNUSED_ARG(pSelf); … … 2234 2009 return NULL; 2235 2010 } 2236 2237 2238 status = pjsua_buddy_del(buddy_id); 2011 2012 user_data = (PyObject*) pjsua_buddy_get_user_data(buddy_id); 2013 Py_XDECREF(user_data); 2014 2015 status = pjsua_buddy_del(buddy_id); 2016 2239 2017 return Py_BuildValue("i", status); 2240 2018 } 2241 2019 2242 2020 /* 2243 * py_pjsua_buddy_s ubscribe_pres2244 */ 2245 static PyObject *py_pjsua_buddy_s ubscribe_pres(PyObject *pSelf, PyObject *pArgs)2021 * py_pjsua_buddy_set_user_data 2022 */ 2023 static PyObject *py_pjsua_buddy_set_user_data(PyObject *pSelf, PyObject *pArgs) 2246 2024 { 2247 2025 int buddy_id; 2248 2026 int status; 2027 PyObject *user_data, *old_user_data; 2028 2029 PJ_UNUSED_ARG(pSelf); 2030 2031 if (!PyArg_ParseTuple(pArgs, "iO", &buddy_id, &user_data)) { 2032 return NULL; 2033 } 2034 2035 old_user_data = (PyObject*) pjsua_buddy_get_user_data(buddy_id); 2036 2037 status = pjsua_buddy_set_user_data(buddy_id, (void*)user_data); 2038 2039 if (status == PJ_SUCCESS) { 2040 Py_XINCREF(user_data); 2041 Py_XDECREF(old_user_data); 2042 } 2043 2044 return Py_BuildValue("i", status); 2045 } 2046 2047 /* 2048 * py_pjsua_buddy_get_user_data 2049 */ 2050 static PyObject *py_pjsua_buddy_get_user_data(PyObject *pSelf, PyObject *pArgs) 2051 { 2052 int buddy_id; 2053 PyObject *user_data; 2054 2055 PJ_UNUSED_ARG(pSelf); 2056 2057 if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) { 2058 return NULL; 2059 } 2060 2061 user_data = (PyObject*) pjsua_buddy_get_user_data(buddy_id); 2062 2063 return user_data? Py_BuildValue("O", user_data) : Py_BuildValue(""); 2064 } 2065 2066 /* 2067 * py_pjsua_buddy_subscribe_pres 2068 */ 2069 static PyObject *py_pjsua_buddy_subscribe_pres(PyObject *pSelf, 2070 PyObject *pArgs) 2071 { 2072 int buddy_id; 2073 int status; 2249 2074 int subscribe; 2250 2075 … … 2254 2079 return NULL; 2255 2080 } 2256 2257 2258 status = pjsua_buddy_subscribe_pres(buddy_id, subscribe); 2081 2082 status = pjsua_buddy_subscribe_pres(buddy_id, subscribe); 2083 2259 2084 return Py_BuildValue("i", status); 2260 2085 } … … 2272 2097 return NULL; 2273 2098 } 2274 2275 2099 2276 2100 pjsua_pres_dump(verbose); 2277 Py_INCREF(Py_None); 2278 return Py_ None;2101 2102 return Py_BuildValue(""); 2279 2103 } 2280 2104 2281 2105 /* 2282 2106 * py_pjsua_im_send 2283 * !modified @ 0712062284 2107 */ 2285 2108 static PyObject *py_pjsua_im_send(PyObject *pSelf, PyObject *pArgs) … … 2287 2110 int status; 2288 2111 int acc_id; 2289 pj_str_t * 2112 pj_str_t *mime_type, tmp_mime_type; 2290 2113 pj_str_t to, content; 2291 PyObject * st;2292 PyObject * smt;2293 PyObject * sc;2114 PyObject *pTo; 2115 PyObject *pMimeType; 2116 PyObject *pContent; 2294 2117 pjsua_msg_data msg_data; 2295 PyObject * omdObj; 2296 PyObj_pjsua_msg_data * omd; 2297 2118 PyObject *pMsgData; 2298 2119 int user_data; 2299 pj_pool_t *pool ;2120 pj_pool_t *pool = NULL; 2300 2121 2301 2122 PJ_UNUSED_ARG(pSelf); 2302 2123 2303 2124 if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id, 2304 &st, &smt, &sc, &omdObj, &user_data)) 2305 { 2306 return NULL; 2307 } 2308 if (smt != Py_None) { 2125 &pTo, &pMimeType, &pContent, &pMsgData, &user_data)) 2126 { 2127 return NULL; 2128 } 2129 2130 if (pMimeType != Py_None) { 2309 2131 mime_type = &tmp_mime_type; 2310 tmp_mime_type = PyString_ to_pj_str(smt);2132 tmp_mime_type = PyString_ToPJ(pMimeType); 2311 2133 } else { 2312 2134 mime_type = NULL; 2313 2135 } 2314 to = PyString_to_pj_str(st); 2315 content = PyString_to_pj_str(sc); 2316 2317 if (omdObj != Py_None) { 2318 2319 omd = (PyObj_pjsua_msg_data *)omdObj; 2320 msg_data.content_type = PyString_to_pj_str(omd->content_type); 2321 msg_data.msg_body = PyString_to_pj_str(omd->msg_body); 2322 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 2323 2136 2137 to = PyString_ToPJ(pTo); 2138 content = PyString_ToPJ(pContent); 2139 2140 if (pMsgData != Py_None) { 2141 PyObj_pjsua_msg_data *omd; 2142 2143 omd = (PyObj_pjsua_msg_data *)pMsgData; 2144 msg_data.content_type = PyString_ToPJ(omd->content_type); 2145 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 2146 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 2324 2147 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 2325 status = pjsua_im_send(acc_id, &to, mime_type, 2326 &content, &msg_data, (void *)user_data); 2327 pj_pool_release(pool); 2328 } else { 2329 2330 status = pjsua_im_send(acc_id, &to, mime_type, 2331 &content, NULL, NULL); 2332 } 2148 } 2149 2150 status = pjsua_im_send(acc_id, &to, mime_type, &content, 2151 &msg_data, (void *)user_data); 2152 if (pool) 2153 pj_pool_release(pool); 2333 2154 2334 2155 return Py_BuildValue("i",status); … … 2343 2164 int acc_id; 2344 2165 pj_str_t to; 2345 PyObject * st;2166 PyObject *pTo; 2346 2167 int is_typing; 2347 2168 pjsua_msg_data msg_data; 2348 PyObject * omdObj; 2349 PyObj_pjsua_msg_data * omd; 2350 pj_pool_t * pool; 2351 2352 PJ_UNUSED_ARG(pSelf); 2353 2354 if (!PyArg_ParseTuple(pArgs, "iOiO", &acc_id, &st, &is_typing, &omdObj)) { 2169 PyObject *pMsgData; 2170 pj_pool_t *pool = NULL; 2171 2172 PJ_UNUSED_ARG(pSelf); 2173 2174 if (!PyArg_ParseTuple(pArgs, "iOiO", &acc_id, &pTo, &is_typing, 2175 &pMsgData)) 2176 { 2355 2177 return NULL; 2356 2178 } 2357 2179 2358 to = PyString_to_pj_str(st); 2359 2360 if (omdObj != Py_None) { 2361 omd = (PyObj_pjsua_msg_data *)omdObj; 2362 msg_data.content_type = PyString_to_pj_str(omd->content_type); 2363 msg_data.msg_body = PyString_to_pj_str(omd->msg_body); 2364 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 2180 to = PyString_ToPJ(pTo); 2181 2182 if (pMsgData != Py_None) { 2183 PyObj_pjsua_msg_data *omd; 2184 2185 omd = (PyObj_pjsua_msg_data *)pMsgData; 2186 msg_data.content_type = PyString_ToPJ(omd->content_type); 2187 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 2188 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 2365 2189 2366 2190 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 2367 status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data); 2368 pj_pool_release(pool); 2369 } else { 2370 status = pjsua_im_typing(acc_id, &to, is_typing, NULL); 2371 } 2372 return Py_BuildValue("i",status); 2191 } 2192 2193 status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data); 2194 2195 if (pool) 2196 pj_pool_release(pool); 2197 2198 return Py_BuildValue("i", status); 2373 2199 } 2374 2200 … … 2415 2241 2416 2242 2417 2418 /* 2419 * PyObj_pjsua_codec_info 2420 * Codec Info 2421 * !modified @ 071206 2422 */ 2423 typedef struct 2424 { 2425 PyObject_HEAD 2426 /* Type-specific fields go here. */ 2427 2428 PyObject * codec_id; 2429 pj_uint8_t priority; 2430 char buf_[32]; 2431 } PyObj_pjsua_codec_info; 2432 2433 2434 /* 2435 * codec_info_dealloc 2436 * deletes a codec_info from memory 2437 * !modified @ 071206 2438 */ 2439 static void codec_info_dealloc(PyObj_pjsua_codec_info* self) 2440 { 2441 Py_XDECREF(self->codec_id); 2442 2443 self->ob_type->tp_free((PyObject*)self); 2444 } 2445 2446 2447 /* 2448 * codec_info_new 2449 * constructor for codec_info object 2450 * !modified @ 071206 2451 */ 2452 static PyObject * codec_info_new(PyTypeObject *type, PyObject *args, 2453 PyObject *kwds) 2454 { 2455 PyObj_pjsua_codec_info *self; 2456 2457 PJ_UNUSED_ARG(args); 2458 PJ_UNUSED_ARG(kwds); 2459 2460 self = (PyObj_pjsua_codec_info *)type->tp_alloc(type, 0); 2461 if (self != NULL) 2462 { 2463 self->codec_id = PyString_FromString(""); 2464 if (self->codec_id == NULL) 2465 { 2466 Py_DECREF(self); 2467 return NULL; 2468 } 2469 2470 2471 } 2472 return (PyObject *)self; 2473 } 2474 2475 /* 2476 * codec_info_members 2477 * !modified @ 071206 2478 */ 2479 static PyMemberDef codec_info_members[] = 2243 /* 2244 * py_pjsua_conf_get_max_ports 2245 */ 2246 static PyObject *py_pjsua_conf_get_max_ports(PyObject *pSelf, PyObject *pArgs) 2480 2247 { 2481 { 2482 "codec_id", T_OBJECT_EX, 2483 offsetof(PyObj_pjsua_codec_info, codec_id), 0, 2484 "Codec unique identification." 2485 }, 2486 2487 { 2488 "priority", T_INT, 2489 offsetof(PyObj_pjsua_codec_info, priority), 0, 2490 "Codec priority (integer 0-255)." 2491 }, 2492 2493 2494 2495 {NULL} /* Sentinel */ 2496 }; 2497 2498 2499 2500 2501 /* 2502 * PyTyp_pjsua_codec_info 2503 */ 2504 static PyTypeObject PyTyp_pjsua_codec_info = 2505 { 2506 PyObject_HEAD_INIT(NULL) 2507 0, /*ob_size*/ 2508 "_pjsua.Codec_Info", /*tp_name*/ 2509 sizeof(PyObj_pjsua_codec_info), /*tp_basicsize*/ 2510 0, /*tp_itemsize*/ 2511 (destructor)codec_info_dealloc,/*tp_dealloc*/ 2512 0, /*tp_print*/ 2513 0, /*tp_getattr*/ 2514 0, /*tp_setattr*/ 2515 0, /*tp_compare*/ 2516 0, /*tp_repr*/ 2517 0, /*tp_as_number*/ 2518 0, /*tp_as_sequence*/ 2519 0, /*tp_as_mapping*/ 2520 0, /*tp_hash */ 2521 0, /*tp_call*/ 2522 0, /*tp_str*/ 2523 0, /*tp_getattro*/ 2524 0, /*tp_setattro*/ 2525 0, /*tp_as_buffer*/ 2526 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 2527 "Codec Info objects", /* tp_doc */ 2528 0, /* tp_traverse */ 2529 0, /* tp_clear */ 2530 0, /* tp_richcompare */ 2531 0, /* tp_weaklistoffset */ 2532 0, /* tp_iter */ 2533 0, /* tp_iternext */ 2534 0, /* tp_methods */ 2535 codec_info_members, /* tp_members */ 2536 0, /* tp_getset */ 2537 0, /* tp_base */ 2538 0, /* tp_dict */ 2539 0, /* tp_descr_get */ 2540 0, /* tp_descr_set */ 2541 0, /* tp_dictoffset */ 2542 0, /* tp_init */ 2543 0, /* tp_alloc */ 2544 codec_info_new, /* tp_new */ 2545 2546 }; 2547 2548 /* 2549 * PyObj_pjsua_conf_port_info 2550 * Conf Port Info 2551 */ 2552 typedef struct 2553 { 2554 PyObject_HEAD 2555 /* Type-specific fields go here. */ 2556 2557 int slot_id; 2558 PyObject * name; 2559 unsigned clock_rate; 2560 unsigned channel_count; 2561 unsigned samples_per_frame; 2562 unsigned bits_per_sample; 2563 PyListObject * listeners; 2564 2565 } PyObj_pjsua_conf_port_info; 2566 2567 2568 /* 2569 * conf_port_info_dealloc 2570 * deletes a conf_port_info from memory 2571 */ 2572 static void conf_port_info_dealloc(PyObj_pjsua_conf_port_info* self) 2573 { 2574 Py_XDECREF(self->name); 2575 Py_XDECREF(self->listeners); 2576 self->ob_type->tp_free((PyObject*)self); 2577 } 2578 2579 2580 /* 2581 * conf_port_info_new 2582 * constructor for conf_port_info object 2583 */ 2584 static PyObject * conf_port_info_new(PyTypeObject *type, PyObject *args, 2585 PyObject *kwds) 2586 { 2587 PyObj_pjsua_conf_port_info *self; 2588 2589 PJ_UNUSED_ARG(args); 2590 PJ_UNUSED_ARG(kwds); 2591 2592 self = (PyObj_pjsua_conf_port_info *)type->tp_alloc(type, 0); 2593 if (self != NULL) 2594 { 2595 self->name = PyString_FromString(""); 2596 if (self->name == NULL) 2597 { 2598 Py_DECREF(self); 2599 return NULL; 2600 } 2601 2602 self->listeners = (PyListObject *)PyList_New(0); 2603 if (self->listeners == NULL) 2604 { 2605 Py_DECREF(self); 2606 return NULL; 2607 } 2608 } 2609 return (PyObject *)self; 2610 } 2611 2612 /* 2613 * conf_port_info_members 2614 */ 2615 static PyMemberDef conf_port_info_members[] = 2616 { 2617 { 2618 "slot_id", T_INT, 2619 offsetof(PyObj_pjsua_conf_port_info, slot_id), 0, 2620 "Conference port number." 2621 }, 2622 { 2623 "name", T_OBJECT_EX, 2624 offsetof(PyObj_pjsua_conf_port_info, name), 0, 2625 "Port name" 2626 }, 2627 { 2628 "clock_rate", T_INT, 2629 offsetof(PyObj_pjsua_conf_port_info, clock_rate), 0, 2630 "Clock rate" 2631 }, 2632 { 2633 "channel_count", T_INT, 2634 offsetof(PyObj_pjsua_conf_port_info, channel_count), 0, 2635 "Number of channels." 2636 }, 2637 { 2638 "samples_per_frame", T_INT, 2639 offsetof(PyObj_pjsua_conf_port_info, samples_per_frame), 0, 2640 "Samples per frame " 2641 }, 2642 { 2643 "bits_per_sample", T_INT, 2644 offsetof(PyObj_pjsua_conf_port_info, bits_per_sample), 0, 2645 "Bits per sample" 2646 }, 2647 { 2648 "listeners", T_OBJECT_EX, 2649 offsetof(PyObj_pjsua_conf_port_info, listeners), 0, 2650 "Array of listeners (in other words, ports where this port " 2651 "is transmitting to" 2652 }, 2653 2654 {NULL} /* Sentinel */ 2655 }; 2656 2657 2658 2659 2660 /* 2661 * PyTyp_pjsua_conf_port_info 2662 */ 2663 static PyTypeObject PyTyp_pjsua_conf_port_info = 2664 { 2665 PyObject_HEAD_INIT(NULL) 2666 0, /*ob_size*/ 2667 "_pjsua.Conf_Port_Info", /*tp_name*/ 2668 sizeof(PyObj_pjsua_conf_port_info), /*tp_basicsize*/ 2669 0, /*tp_itemsize*/ 2670 (destructor)conf_port_info_dealloc,/*tp_dealloc*/ 2671 0, /*tp_print*/ 2672 0, /*tp_getattr*/ 2673 0, /*tp_setattr*/ 2674 0, /*tp_compare*/ 2675 0, /*tp_repr*/ 2676 0, /*tp_as_number*/ 2677 0, /*tp_as_sequence*/ 2678 0, /*tp_as_mapping*/ 2679 0, /*tp_hash */ 2680 0, /*tp_call*/ 2681 0, /*tp_str*/ 2682 0, /*tp_getattro*/ 2683 0, /*tp_setattro*/ 2684 0, /*tp_as_buffer*/ 2685 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 2686 "Conf Port Info objects", /* tp_doc */ 2687 0, /* tp_traverse */ 2688 0, /* tp_clear */ 2689 0, /* tp_richcompare */ 2690 0, /* tp_weaklistoffset */ 2691 0, /* tp_iter */ 2692 0, /* tp_iternext */ 2693 0, /* tp_methods */ 2694 conf_port_info_members, /* tp_members */ 2695 0, /* tp_getset */ 2696 0, /* tp_base */ 2697 0, /* tp_dict */ 2698 0, /* tp_descr_get */ 2699 0, /* tp_descr_set */ 2700 0, /* tp_dictoffset */ 2701 0, /* tp_init */ 2702 0, /* tp_alloc */ 2703 conf_port_info_new, /* tp_new */ 2704 2705 }; 2706 2707 /* 2708 * PyObj_pjmedia_port 2709 */ 2710 typedef struct 2711 { 2712 PyObject_HEAD 2713 /* Type-specific fields go here. */ 2714 pjmedia_port * port; 2715 } PyObj_pjmedia_port; 2716 2717 2718 /* 2719 * PyTyp_pjmedia_port 2720 */ 2721 static PyTypeObject PyTyp_pjmedia_port = 2722 { 2723 PyObject_HEAD_INIT(NULL) 2724 0, /*ob_size*/ 2725 "_pjsua.PJMedia_Port", /*tp_name*/ 2726 sizeof(PyObj_pjmedia_port), /*tp_basicsize*/ 2727 0, /*tp_itemsize*/ 2728 0, /*tp_dealloc*/ 2729 0, /*tp_print*/ 2730 0, /*tp_getattr*/ 2731 0, /*tp_setattr*/ 2732 0, /*tp_compare*/ 2733 0, /*tp_repr*/ 2734 0, /*tp_as_number*/ 2735 0, /*tp_as_sequence*/ 2736 0, /*tp_as_mapping*/ 2737 0, /*tp_hash */ 2738 0, /*tp_call*/ 2739 0, /*tp_str*/ 2740 0, /*tp_getattro*/ 2741 0, /*tp_setattro*/ 2742 0, /*tp_as_buffer*/ 2743 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 2744 "pjmedia_port objects", /* tp_doc */ 2745 2746 }; 2747 2748 /* 2749 * PyObj_pjmedia_snd_dev_info 2750 * PJMedia Snd Dev Info 2751 */ 2752 typedef struct 2753 { 2754 PyObject_HEAD 2755 /* Type-specific fields go here. */ 2756 2757 2758 unsigned input_count; 2759 unsigned output_count; 2760 unsigned default_samples_per_sec; 2761 PyObject * name; 2762 2763 } PyObj_pjmedia_snd_dev_info; 2764 2765 2766 /* 2767 * pjmedia_snd_dev_info_dealloc 2768 * deletes a pjmedia_snd_dev_info from memory 2769 */ 2770 static void pjmedia_snd_dev_info_dealloc(PyObj_pjmedia_snd_dev_info* self) 2771 { 2772 Py_XDECREF(self->name); 2773 self->ob_type->tp_free((PyObject*)self); 2774 } 2775 2776 2777 /* 2778 * pjmedia_snd_dev_info_new 2779 * constructor for pjmedia_snd_dev_info object 2780 */ 2781 static PyObject * pjmedia_snd_dev_info_new(PyTypeObject *type, PyObject *args, 2782 PyObject *kwds) 2783 { 2784 PyObj_pjmedia_snd_dev_info *self; 2785 2786 PJ_UNUSED_ARG(args); 2787 PJ_UNUSED_ARG(kwds); 2788 2789 self = (PyObj_pjmedia_snd_dev_info *)type->tp_alloc(type, 0); 2790 if (self != NULL) 2791 { 2792 self->name = PyString_FromString(""); 2793 if (self->name == NULL) 2794 { 2795 Py_DECREF(self); 2796 return NULL; 2797 } 2798 2799 } 2800 return (PyObject *)self; 2801 } 2802 2803 /* 2804 * pjmedia_snd_dev_info_members 2805 */ 2806 static PyMemberDef pjmedia_snd_dev_info_members[] = 2807 { 2808 2809 { 2810 "name", T_OBJECT_EX, 2811 offsetof(PyObj_pjmedia_snd_dev_info, name), 0, 2812 "Device name" 2813 }, 2814 { 2815 "input_count", T_INT, 2816 offsetof(PyObj_pjmedia_snd_dev_info, input_count), 0, 2817 "Max number of input channels" 2818 }, 2819 { 2820 "output_count", T_INT, 2821 offsetof(PyObj_pjmedia_snd_dev_info, output_count), 0, 2822 "Max number of output channels" 2823 }, 2824 { 2825 "default_samples_per_sec", T_INT, 2826 offsetof(PyObj_pjmedia_snd_dev_info, default_samples_per_sec), 0, 2827 "Default sampling rate." 2828 }, 2829 2830 2831 {NULL} /* Sentinel */ 2832 }; 2833 2834 2835 2836 2837 /* 2838 * PyTyp_pjmedia_snd_dev_info 2839 */ 2840 static PyTypeObject PyTyp_pjmedia_snd_dev_info = 2841 { 2842 PyObject_HEAD_INIT(NULL) 2843 0, /*ob_size*/ 2844 "_pjsua.PJMedia_Snd_Dev_Info", /*tp_name*/ 2845 sizeof(PyObj_pjmedia_snd_dev_info), /*tp_basicsize*/ 2846 0, /*tp_itemsize*/ 2847 (destructor)pjmedia_snd_dev_info_dealloc,/*tp_dealloc*/ 2848 0, /*tp_print*/ 2849 0, /*tp_getattr*/ 2850 0, /*tp_setattr*/ 2851 0, /*tp_compare*/ 2852 0, /*tp_repr*/ 2853 0, /*tp_as_number*/ 2854 0, /*tp_as_sequence*/ 2855 0, /*tp_as_mapping*/ 2856 0, /*tp_hash */ 2857 0, /*tp_call*/ 2858 0, /*tp_str*/ 2859 0, /*tp_getattro*/ 2860 0, /*tp_setattro*/ 2861 0, /*tp_as_buffer*/ 2862 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 2863 "PJMedia Snd Dev Info objects", /* tp_doc */ 2864 0, /* tp_traverse */ 2865 0, /* tp_clear */ 2866 0, /* tp_richcompare */ 2867 0, /* tp_weaklistoffset */ 2868 0, /* tp_iter */ 2869 0, /* tp_iternext */ 2870 0, /* tp_methods */ 2871 pjmedia_snd_dev_info_members, /* tp_members */ 2872 0, /* tp_getset */ 2873 0, /* tp_base */ 2874 0, /* tp_dict */ 2875 0, /* tp_descr_get */ 2876 0, /* tp_descr_set */ 2877 0, /* tp_dictoffset */ 2878 0, /* tp_init */ 2879 0, /* tp_alloc */ 2880 pjmedia_snd_dev_info_new, /* tp_new */ 2881 2882 }; 2883 2884 /* 2885 * PyObj_pjmedia_codec_param_info 2886 * PJMedia Codec Param Info 2887 */ 2888 typedef struct 2889 { 2890 PyObject_HEAD 2891 /* Type-specific fields go here. */ 2892 2893 unsigned clock_rate; 2894 unsigned channel_cnt; 2895 pj_uint32_t avg_bps; 2896 pj_uint16_t frm_ptime; 2897 pj_uint8_t pcm_bits_per_sample; 2898 pj_uint8_t pt; 2899 2900 } PyObj_pjmedia_codec_param_info; 2901 2902 2903 2904 /* 2905 * pjmedia_codec_param_info_members 2906 */ 2907 static PyMemberDef pjmedia_codec_param_info_members[] = 2908 { 2909 2910 { 2911 "clock_rate", T_INT, 2912 offsetof(PyObj_pjmedia_codec_param_info, clock_rate), 0, 2913 "Sampling rate in Hz" 2914 }, 2915 { 2916 "channel_cnt", T_INT, 2917 offsetof(PyObj_pjmedia_codec_param_info, channel_cnt), 0, 2918 "Channel count" 2919 }, 2920 { 2921 "avg_bps", T_INT, 2922 offsetof(PyObj_pjmedia_codec_param_info, avg_bps), 0, 2923 "Average bandwidth in bits/sec" 2924 }, 2925 { 2926 "frm_ptime", T_INT, 2927 offsetof(PyObj_pjmedia_codec_param_info, frm_ptime), 0, 2928 "Base frame ptime in msec." 2929 }, 2930 { 2931 "pcm_bits_per_sample", T_INT, 2932 offsetof(PyObj_pjmedia_codec_param_info, pcm_bits_per_sample), 0, 2933 "Bits/sample in the PCM side" 2934 }, 2935 { 2936 "pt", T_INT, 2937 offsetof(PyObj_pjmedia_codec_param_info, pt), 0, 2938 "Payload type" 2939 }, 2940 2941 {NULL} /* Sentinel */ 2942 }; 2943 2944 2945 2946 2947 /* 2948 * PyTyp_pjmedia_codec_param_info 2949 */ 2950 static PyTypeObject PyTyp_pjmedia_codec_param_info = 2951 { 2952 PyObject_HEAD_INIT(NULL) 2953 0, /*ob_size*/ 2954 "_pjsua.PJMedia_Codec_Param_Info", /*tp_name*/ 2955 sizeof(PyObj_pjmedia_codec_param_info), /*tp_basicsize*/ 2956 0, /*tp_itemsize*/ 2957 0,/*tp_dealloc*/ 2958 0, /*tp_print*/ 2959 0, /*tp_getattr*/ 2960 0, /*tp_setattr*/ 2961 0, /*tp_compare*/ 2962 0, /*tp_repr*/ 2963 0, /*tp_as_number*/ 2964 0, /*tp_as_sequence*/ 2965 0, /*tp_as_mapping*/ 2966 0, /*tp_hash */ 2967 0, /*tp_call*/ 2968 0, /*tp_str*/ 2969 0, /*tp_getattro*/ 2970 0, /*tp_setattro*/ 2971 0, /*tp_as_buffer*/ 2972 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 2973 "PJMedia Codec Param Info objects", /* tp_doc */ 2974 0, /* tp_traverse */ 2975 0, /* tp_clear */ 2976 0, /* tp_richcompare */ 2977 0, /* tp_weaklistoffset */ 2978 0, /* tp_iter */ 2979 0, /* tp_iternext */ 2980 0, /* tp_methods */ 2981 pjmedia_codec_param_info_members, /* tp_members */ 2982 2983 2984 }; 2985 2986 /* 2987 * PyObj_pjmedia_codec_param_setting 2988 * PJMedia Codec Param Setting 2989 */ 2990 typedef struct 2991 { 2992 PyObject_HEAD 2993 /* Type-specific fields go here. */ 2994 pj_uint8_t frm_per_pkt; 2995 unsigned vad; 2996 unsigned cng; 2997 unsigned penh; 2998 unsigned plc; 2999 unsigned reserved; 3000 pj_uint8_t enc_fmtp_mode; 3001 pj_uint8_t dec_fmtp_mode; 3002 3003 } PyObj_pjmedia_codec_param_setting; 3004 3005 3006 3007 /* 3008 * pjmedia_codec_param_setting_members 3009 */ 3010 static PyMemberDef pjmedia_codec_param_setting_members[] = 3011 { 3012 3013 { 3014 "frm_per_pkt", T_INT, 3015 offsetof(PyObj_pjmedia_codec_param_setting, frm_per_pkt), 0, 3016 "Number of frames per packet" 3017 }, 3018 { 3019 "vad", T_INT, 3020 offsetof(PyObj_pjmedia_codec_param_setting, vad), 0, 3021 "Voice Activity Detector" 3022 }, 3023 { 3024 "penh", T_INT, 3025 offsetof(PyObj_pjmedia_codec_param_setting, penh), 0, 3026 "Perceptual Enhancement" 3027 }, 3028 { 3029 "plc", T_INT, 3030 offsetof(PyObj_pjmedia_codec_param_setting, plc), 0, 3031 "Packet loss concealment" 3032 }, 3033 { 3034 "reserved", T_INT, 3035 offsetof(PyObj_pjmedia_codec_param_setting, reserved), 0, 3036 "Reserved, must be zero" 3037 }, 3038 { 3039 "cng", T_INT, 3040 offsetof(PyObj_pjmedia_codec_param_setting, cng), 0, 3041 "Comfort Noise Generator" 3042 }, 3043 { 3044 "enc_fmtp_mode", T_INT, 3045 offsetof(PyObj_pjmedia_codec_param_setting, enc_fmtp_mode), 0, 3046 "Mode param in fmtp (def:0)" 3047 }, 3048 { 3049 "dec_fmtp_mode", T_INT, 3050 offsetof(PyObj_pjmedia_codec_param_setting, dec_fmtp_mode), 0, 3051 "Mode param in fmtp (def:0)" 3052 }, 3053 3054 {NULL} /* Sentinel */ 3055 }; 3056 3057 3058 3059 3060 /* 3061 * PyTyp_pjmedia_codec_param_setting 3062 */ 3063 static PyTypeObject PyTyp_pjmedia_codec_param_setting = 3064 { 3065 PyObject_HEAD_INIT(NULL) 3066 0, /*ob_size*/ 3067 "_pjsua.PJMedia_Codec_Param_Setting", /*tp_name*/ 3068 sizeof(PyObj_pjmedia_codec_param_setting), /*tp_basicsize*/ 3069 0, /*tp_itemsize*/ 3070 0,/*tp_dealloc*/ 3071 0, /*tp_print*/ 3072 0, /*tp_getattr*/ 3073 0, /*tp_setattr*/ 3074 0, /*tp_compare*/ 3075 0, /*tp_repr*/ 3076 0, /*tp_as_number*/ 3077 0, /*tp_as_sequence*/ 3078 0, /*tp_as_mapping*/ 3079 0, /*tp_hash */ 3080 0, /*tp_call*/ 3081 0, /*tp_str*/ 3082 0, /*tp_getattro*/ 3083 0, /*tp_setattro*/ 3084 0, /*tp_as_buffer*/ 3085 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 3086 "PJMedia Codec Param Setting objects", /* tp_doc */ 3087 0, /* tp_traverse */ 3088 0, /* tp_clear */ 3089 0, /* tp_richcompare */ 3090 0, /* tp_weaklistoffset */ 3091 0, /* tp_iter */ 3092 0, /* tp_iternext */ 3093 0, /* tp_methods */ 3094 pjmedia_codec_param_setting_members, /* tp_members */ 3095 3096 3097 }; 3098 3099 /* 3100 * PyObj_pjmedia_codec_param 3101 * PJMedia Codec Param 3102 */ 3103 typedef struct 3104 { 3105 PyObject_HEAD 3106 /* Type-specific fields go here. */ 3107 3108 PyObj_pjmedia_codec_param_info * info; 3109 PyObj_pjmedia_codec_param_setting * setting; 3110 3111 } PyObj_pjmedia_codec_param; 3112 3113 3114 /* 3115 * pjmedia_codec_param_dealloc 3116 * deletes a pjmedia_codec_param from memory 3117 */ 3118 static void pjmedia_codec_param_dealloc(PyObj_pjmedia_codec_param* self) 3119 { 3120 Py_XDECREF(self->info); 3121 Py_XDECREF(self->setting); 3122 self->ob_type->tp_free((PyObject*)self); 3123 } 3124 3125 3126 /* 3127 * pjmedia_codec_param_new 3128 * constructor for pjmedia_codec_param object 3129 */ 3130 static PyObject * pjmedia_codec_param_new(PyTypeObject *type, PyObject *args, 3131 PyObject *kwds) 3132 { 3133 PyObj_pjmedia_codec_param *self; 3134 3135 PJ_UNUSED_ARG(args); 3136 PJ_UNUSED_ARG(kwds); 3137 3138 self = (PyObj_pjmedia_codec_param *)type->tp_alloc(type, 0); 3139 if (self != NULL) 3140 { 3141 self->info = (PyObj_pjmedia_codec_param_info *) 3142 PyType_GenericNew(&PyTyp_pjmedia_codec_param_info, NULL, NULL); 3143 if (self->info == NULL) 3144 { 3145 Py_DECREF(self); 3146 return NULL; 3147 } 3148 self->setting = (PyObj_pjmedia_codec_param_setting *) 3149 PyType_GenericNew(&PyTyp_pjmedia_codec_param_setting, NULL, NULL); 3150 if (self->setting == NULL) 3151 { 3152 Py_DECREF(self); 3153 return NULL; 3154 } 3155 } 3156 return (PyObject *)self; 3157 } 3158 3159 /* 3160 * pjmedia_codec_param_members 3161 */ 3162 static PyMemberDef pjmedia_codec_param_members[] = 3163 { 3164 3165 { 3166 "info", T_OBJECT_EX, 3167 offsetof(PyObj_pjmedia_codec_param, info), 0, 3168 "The 'info' part of codec param describes the capability of the codec," 3169 " and the value should NOT be changed by application." 3170 }, 3171 { 3172 "setting", T_OBJECT_EX, 3173 offsetof(PyObj_pjmedia_codec_param, setting), 0, 3174 "The 'setting' part of codec param describes various settings to be " 3175 "applied to the codec. When the codec param is retrieved from the " 3176 "codec or codec factory, the values of these will be filled by " 3177 "the capability of the codec. Any features that are supported by " 3178 "the codec (e.g. vad or plc) will be turned on, so that application " 3179 "can query which capabilities are supported by the codec. " 3180 "Application may change the settings here before instantiating " 3181 "the codec/stream." 3182 }, 3183 3184 {NULL} /* Sentinel */ 3185 }; 3186 3187 3188 3189 3190 /* 3191 * PyTyp_pjmedia_codec_param 3192 */ 3193 static PyTypeObject PyTyp_pjmedia_codec_param = 3194 { 3195 PyObject_HEAD_INIT(NULL) 3196 0, /*ob_size*/ 3197 "_pjsua.PJMedia_Codec_Param", /*tp_name*/ 3198 sizeof(PyObj_pjmedia_codec_param), /*tp_basicsize*/ 3199 0, /*tp_itemsize*/ 3200 (destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/ 3201 0, /*tp_print*/ 3202 0, /*tp_getattr*/ 3203 0, /*tp_setattr*/ 3204 0, /*tp_compare*/ 3205 0, /*tp_repr*/ 3206 0, /*tp_as_number*/ 3207 0, /*tp_as_sequence*/ 3208 0, /*tp_as_mapping*/ 3209 0, /*tp_hash */ 3210 0, /*tp_call*/ 3211 0, /*tp_str*/ 3212 0, /*tp_getattro*/ 3213 0, /*tp_setattro*/ 3214 0, /*tp_as_buffer*/ 3215 Py_TPFLAGS_DEFAULT, /*tp_flags*/ 3216 "PJMedia Codec Param objects", /* tp_doc */ 3217 0, /* tp_traverse */ 3218 0, /* tp_clear */ 3219 0, /* tp_richcompare */ 3220 0, /* tp_weaklistoffset */ 3221 0, /* tp_iter */ 3222 0, /* tp_iternext */ 3223 0, /* tp_methods */ 3224 pjmedia_codec_param_members, /* tp_members */ 3225 0, /* tp_getset */ 3226 0, /* tp_base */ 3227 0, /* tp_dict */ 3228 0, /* tp_descr_get */ 3229 0, /* tp_descr_set */ 3230 0, /* tp_dictoffset */ 3231 0, /* tp_init */ 3232 0, /* tp_alloc */ 3233 pjmedia_codec_param_new, /* tp_new */ 3234 3235 }; 3236 3237 /* 3238 * py_pjsua_conf_get_max_ports 3239 */ 3240 static PyObject *py_pjsua_conf_get_max_ports 3241 (PyObject *pSelf, PyObject *pArgs) 2248 PJ_UNUSED_ARG(pSelf); 2249 PJ_UNUSED_ARG(pArgs); 2250 2251 return Py_BuildValue("i", pjsua_conf_get_max_ports()); 2252 } 2253 2254 /* 2255 * py_pjsua_conf_get_active_ports 2256 */ 2257 static PyObject *py_pjsua_conf_get_active_ports(PyObject *pSelf, 2258 PyObject *pArgs) 3242 2259 { 3243 int ret; 3244 3245 PJ_UNUSED_ARG(pSelf); 3246 3247 if (!PyArg_ParseTuple(pArgs, "")) 3248 { 3249 return NULL; 3250 } 3251 ret = pjsua_conf_get_max_ports(); 3252 3253 return Py_BuildValue("i", ret); 3254 } 3255 3256 /* 3257 * py_pjsua_conf_get_active_ports 3258 */ 3259 static PyObject *py_pjsua_conf_get_active_ports 3260 (PyObject *pSelf, PyObject *pArgs) 3261 { 3262 int ret; 3263 3264 PJ_UNUSED_ARG(pSelf); 3265 3266 if (!PyArg_ParseTuple(pArgs, "")) 3267 { 3268 return NULL; 3269 } 3270 ret = pjsua_conf_get_active_ports(); 3271 3272 return Py_BuildValue("i", ret); 2260 PJ_UNUSED_ARG(pSelf); 2261 PJ_UNUSED_ARG(pArgs); 2262 2263 return Py_BuildValue("i", pjsua_conf_get_active_ports()); 3273 2264 } 3274 2265 3275 2266 /* 3276 2267 * py_pjsua_enum_conf_ports 3277 * !modified @ 2412063278 2268 */ 3279 2269 static PyObject *py_pjsua_enum_conf_ports(PyObject *pSelf, PyObject *pArgs) … … 3281 2271 pj_status_t status; 3282 2272 PyObject *list; 3283 3284 2273 pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS]; 3285 2274 unsigned c, i; 3286 2275 3287 2276 PJ_UNUSED_ARG(pSelf); 3288 3289 if (!PyArg_ParseTuple(pArgs, "")) 3290 { 3291 return NULL; 3292 } 3293 2277 PJ_UNUSED_ARG(pArgs); 2278 3294 2279 c = PJ_ARRAY_SIZE(id); 3295 2280 status = pjsua_enum_conf_ports(id, &c); 2281 if (status != PJ_SUCCESS) 2282 c = 0; 3296 2283 3297 2284 list = PyList_New(c); 3298 for (i = 0; i < c; i++) 3299 { 3300 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 3301 if (ret == -1) 3302 { 3303 return NULL; 3304 } 3305 } 3306 3307 return Py_BuildValue("O",list); 2285 for (i = 0; i < c; i++) { 2286 PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 2287 } 2288 2289 return (PyObject*)list; 3308 2290 } 3309 2291 … … 3311 2293 * py_pjsua_conf_get_port_info 3312 2294 */ 3313 static PyObject *py_pjsua_conf_get_port_info 3314 (PyObject *pSelf, PyObject *pArgs) 2295 static PyObject *py_pjsua_conf_get_port_info(PyObject *pSelf, PyObject *pArgs) 3315 2296 { 3316 2297 int id; 3317 PyObj_pjsua_conf_port_info * obj;2298 PyObj_pjsua_conf_port_info *ret; 3318 2299 pjsua_conf_port_info info; 3319 2300 int status; … … 3322 2303 PJ_UNUSED_ARG(pSelf); 3323 2304 3324 if (!PyArg_ParseTuple(pArgs, "i", &id)) 3325 { 3326 return NULL; 3327 } 3328 2305 if (!PyArg_ParseTuple(pArgs, "i", &id)) { 2306 return NULL; 2307 } 3329 2308 3330 2309 status = pjsua_conf_get_port_info(id, &info); 3331 obj = (PyObj_pjsua_conf_port_info *)conf_port_info_new3332 (&PyTyp_pjsua_conf_port_info,NULL,NULL);3333 obj->bits_per_sample = info.bits_per_sample;3334 obj->channel_count = info.bits_per_sample;3335 obj->clock_rate = info.clock_rate;3336 obj->name = PyString_FromStringAndSize(info.name.ptr, info.name.slen);3337 obj->samples_per_frame = info.samples_per_frame;3338 obj->slot_id = info.slot_id;3339 3340 obj->listeners = (PyListObject *)PyList_New(info.listener_cnt);2310 ret = (PyObj_pjsua_conf_port_info *) 2311 conf_port_info_new(&PyTyp_pjsua_conf_port_info, NULL, NULL); 2312 ret->bits_per_sample = info.bits_per_sample; 2313 ret->channel_count = info.bits_per_sample; 2314 ret->clock_rate = info.clock_rate; 2315 ret->name = PyString_FromPJ(&info.name); 2316 ret->samples_per_frame = info.samples_per_frame; 2317 ret->slot_id = info.slot_id; 2318 Py_XDECREF(ret->listeners); 2319 ret->listeners = PyList_New(info.listener_cnt); 3341 2320 for (i = 0; i < info.listener_cnt; i++) { 3342 PyObject * item = Py_BuildValue("i",info.listeners[i]); 3343 PyList_SetItem((PyObject *)obj->listeners, i, item); 3344 } 3345 return Py_BuildValue("O", obj); 3346 } 3347 3348 /* 3349 * py_pjsua_conf_add_port 3350 */ 3351 static PyObject *py_pjsua_conf_add_port 3352 (PyObject *pSelf, PyObject *pArgs) 3353 { 3354 int p_id; 3355 PyObject * oportObj; 3356 PyObj_pjmedia_port * oport; 3357 pjmedia_port * port; 3358 PyObject * opoolObj; 3359 PyObj_pj_pool * opool; 3360 pj_pool_t * pool; 3361 3362 int status; 3363 3364 PJ_UNUSED_ARG(pSelf); 3365 3366 if (!PyArg_ParseTuple(pArgs, "OO", &opoolObj, &oportObj)) 3367 { 3368 return NULL; 3369 } 3370 if (opoolObj != Py_None) 3371 { 3372 opool = (PyObj_pj_pool *)opoolObj; 3373 pool = opool->pool; 3374 } else { 3375 opool = NULL; 3376 pool = NULL; 3377 } 3378 if (oportObj != Py_None) 3379 { 3380 oport = (PyObj_pjmedia_port *)oportObj; 3381 port = oport->port; 3382 } else { 3383 oport = NULL; 3384 port = NULL; 3385 } 3386 3387 status = pjsua_conf_add_port(pool, port, &p_id); 3388 3389 3390 return Py_BuildValue("ii", status, p_id); 2321 PyObject *item = Py_BuildValue("i",info.listeners[i]); 2322 PyList_SetItem(ret->listeners, i, item); 2323 } 2324 return (PyObject*)ret; 3391 2325 } 3392 2326 … … 3394 2328 * py_pjsua_conf_remove_port 3395 2329 */ 3396 static PyObject *py_pjsua_conf_remove_port 3397 (PyObject *pSelf, PyObject *pArgs) 2330 static PyObject *py_pjsua_conf_remove_port(PyObject *pSelf, PyObject *pArgs) 3398 2331 { 3399 2332 int id; … … 3402 2335 PJ_UNUSED_ARG(pSelf); 3403 2336 3404 if (!PyArg_ParseTuple(pArgs, "i", &id)) 3405 { 2337 if (!PyArg_ParseTuple(pArgs, "i", &id)) { 3406 2338 return NULL; 3407 2339 } … … 3409 2341 status = pjsua_conf_remove_port(id); 3410 2342 3411 3412 2343 return Py_BuildValue("i", status); 3413 2344 } … … 3416 2347 * py_pjsua_conf_connect 3417 2348 */ 3418 static PyObject *py_pjsua_conf_connect 3419 (PyObject *pSelf, PyObject *pArgs) 2349 static PyObject *py_pjsua_conf_connect(PyObject *pSelf, PyObject *pArgs) 3420 2350 { 3421 2351 int source, sink; … … 3424 2354 PJ_UNUSED_ARG(pSelf); 3425 2355 3426 if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) 3427 { 2356 if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) { 3428 2357 return NULL; 3429 2358 } … … 3431 2360 status = pjsua_conf_connect(source, sink); 3432 2361 3433 3434 2362 return Py_BuildValue("i", status); 3435 2363 } … … 3438 2366 * py_pjsua_conf_disconnect 3439 2367 */ 3440 static PyObject *py_pjsua_conf_disconnect 3441 (PyObject *pSelf, PyObject *pArgs) 2368 static PyObject *py_pjsua_conf_disconnect(PyObject *pSelf, PyObject *pArgs) 3442 2369 { 3443 2370 int source, sink; … … 3446 2373 PJ_UNUSED_ARG(pSelf); 3447 2374 3448 if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) 3449 { 2375 if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) { 3450 2376 return NULL; 3451 2377 } … … 3453 2379 status = pjsua_conf_disconnect(source, sink); 3454 2380 3455 3456 2381 return Py_BuildValue("i", status); 3457 2382 } … … 3460 2385 * py_pjsua_conf_set_tx_level 3461 2386 */ 3462 static PyObject *py_pjsua_conf_set_tx_level 3463 (PyObject *pSelf, PyObject *pArgs) 2387 static PyObject *py_pjsua_conf_set_tx_level(PyObject *pSelf, PyObject *pArgs) 3464 2388 { 3465 2389 int slot; … … 3469 2393 PJ_UNUSED_ARG(pSelf); 3470 2394 3471 if (!PyArg_ParseTuple(pArgs, "if", &slot, &level)) 3472 { 2395 if (!PyArg_ParseTuple(pArgs, "if", &slot, &level)) { 3473 2396 return NULL; 3474 2397 } … … 3476 2399 status = pjsua_conf_adjust_tx_level(slot, level); 3477 2400 3478 3479 2401 return Py_BuildValue("i", status); 3480 2402 } … … 3483 2405 * py_pjsua_conf_set_rx_level 3484 2406 */ 3485 static PyObject *py_pjsua_conf_set_rx_level 3486 (PyObject *pSelf, PyObject *pArgs) 2407 static PyObject *py_pjsua_conf_set_rx_level(PyObject *pSelf, PyObject *pArgs) 3487 2408 { 3488 2409 int slot; … … 3492 2413 PJ_UNUSED_ARG(pSelf); 3493 2414 3494 if (!PyArg_ParseTuple(pArgs, "if", &slot, &level)) 3495 { 2415 if (!PyArg_ParseTuple(pArgs, "if", &slot, &level)) { 3496 2416 return NULL; 3497 2417 } … … 3499 2419 status = pjsua_conf_adjust_rx_level(slot, level); 3500 2420 3501 3502 2421 return Py_BuildValue("i", status); 3503 2422 } … … 3506 2425 * py_pjsua_conf_get_signal_level 3507 2426 */ 3508 static PyObject *py_pjsua_conf_get_signal_level 3509 (PyObject *pSelf,PyObject *pArgs)2427 static PyObject *py_pjsua_conf_get_signal_level(PyObject *pSelf, 2428 PyObject *pArgs) 3510 2429 { 3511 2430 int slot; … … 3515 2434 PJ_UNUSED_ARG(pSelf); 3516 2435 3517 if (!PyArg_ParseTuple(pArgs, "i", &slot)) 3518 { 2436 if (!PyArg_ParseTuple(pArgs, "i", &slot)) { 3519 2437 return NULL; 3520 2438 } … … 3522 2440 status = pjsua_conf_get_signal_level(slot, &tx_level, &rx_level); 3523 2441 3524 3525 2442 return Py_BuildValue("iff", status, (float)(tx_level/255.0), 3526 2443 (float)(rx_level/255.0)); 3527 2444 } 3528 2445 … … 3530 2447 * py_pjsua_player_create 3531 2448 */ 3532 static PyObject *py_pjsua_player_create 3533 (PyObject *pSelf, PyObject *pArgs) 2449 static PyObject *py_pjsua_player_create(PyObject *pSelf, PyObject *pArgs) 3534 2450 { 3535 2451 int id; 3536 2452 int options; 3537 PyObject * filename;3538 pj_str_t str;2453 PyObject *pFilename; 2454 pj_str_t filename; 3539 2455 int status; 3540 2456 3541 2457 PJ_UNUSED_ARG(pSelf); 3542 2458 3543 if (!PyArg_ParseTuple(pArgs, "Oi", &filename, &options)) 3544 { 3545 return NULL; 3546 } 3547 str.ptr = PyString_AsString(filename); 3548 str.slen = strlen(PyString_AsString(filename)); 3549 status = pjsua_player_create(&str, options, &id); 2459 if (!PyArg_ParseTuple(pArgs, "Oi", &pFilename, &options)) { 2460 return NULL; 2461 } 2462 2463 filename = PyString_ToPJ(pFilename); 2464 status = pjsua_player_create(&filename, options, &id); 3550 2465 3551 2466 return Py_BuildValue("ii", status, id); … … 3555 2470 * py_pjsua_playlist_create 3556 2471 */ 3557 static PyObject *py_pjsua_playlist_create 3558 (PyObject *pSelf, PyObject *pArgs) 2472 static PyObject *py_pjsua_playlist_create(PyObject *pSelf, PyObject *pArgs) 3559 2473 { 3560 2474 int id; 3561 2475 int options; 3562 PyObject * arg_label, *arg_filelist;2476 PyObject *pLabel, *pFileList; 3563 2477 pj_str_t label; 3564 2478 int count; … … 3568 2482 PJ_UNUSED_ARG(pSelf); 3569 2483 3570 if (!PyArg_ParseTuple(pArgs, "OOi", &arg_label, &arg_filelist, &options)) 3571 { 2484 if (!PyArg_ParseTuple(pArgs, "OOi", &pLabel, &pFileList, &options)) { 2485 return NULL; 2486 } 2487 2488 label = PyString_ToPJ(pLabel); 2489 if (!PyList_Check(pFileList)) 2490 return Py_BuildValue("ii", PJ_EINVAL, PJSUA_INVALID_ID); 2491 2492 count = 0; 2493 for (count=0; count<PyList_Size(pFileList) && 2494 count<PJ_ARRAY_SIZE(files); ++count) 2495 { 2496 files[count] = PyString_ToPJ(PyList_GetItem(pFileList, count)); 2497 } 2498 2499 status = pjsua_playlist_create(files, count, &label, options, &id); 2500 2501 return Py_BuildValue("ii", status, id); 2502 } 2503 2504 /* 2505 * py_pjsua_player_get_conf_port 2506 */ 2507 static PyObject *py_pjsua_player_get_conf_port(PyObject *pSelf, 2508 PyObject *pArgs) 2509 { 2510 2511 int id, port_id; 2512 2513 PJ_UNUSED_ARG(pSelf); 2514 2515 if (!PyArg_ParseTuple(pArgs, "i", &id)) { 3572 2516 return NULL; 3573 2517 } 3574 label.ptr = PyString_AsString(arg_label);3575 label.slen = PyString_Size(arg_label);3576 3577 if (!PyList_Check(arg_filelist))3578 return NULL;3579 3580 count = 0;3581 for (count=0; count<PyList_Size(arg_filelist) &&3582 count<PJ_ARRAY_SIZE(files); ++count)3583 {3584 files[count].ptr = PyString_AsString(PyList_GetItem(arg_filelist, count));3585 files[count].slen = PyString_Size(PyList_GetItem(arg_filelist, count));3586 }3587 3588 status = pjsua_playlist_create(files, count, &label, options, &id);3589 3590 return Py_BuildValue("ii", status, id);3591 }3592 3593 /*3594 * py_pjsua_player_get_conf_port3595 */3596 static PyObject *py_pjsua_player_get_conf_port3597 (PyObject *pSelf, PyObject *pArgs)3598 {3599 3600 int id, port_id;3601 3602 PJ_UNUSED_ARG(pSelf);3603 3604 if (!PyArg_ParseTuple(pArgs, "i", &id))3605 {3606 return NULL;3607 }3608 2518 3609 2519 port_id = pjsua_player_get_conf_port(id); 3610 2520 3611 3612 2521 return Py_BuildValue("i", port_id); 3613 2522 } … … 3616 2525 * py_pjsua_player_set_pos 3617 2526 */ 3618 static PyObject *py_pjsua_player_set_pos 3619 (PyObject *pSelf, PyObject *pArgs) 2527 static PyObject *py_pjsua_player_set_pos(PyObject *pSelf, PyObject *pArgs) 3620 2528 { 3621 2529 int id; 3622 pj_uint32_t samples;2530 int samples; 3623 2531 int status; 3624 2532 3625 2533 PJ_UNUSED_ARG(pSelf); 3626 2534 3627 if (!PyArg_ParseTuple(pArgs, "iI", &id, &samples)) 3628 { 2535 if (!PyArg_ParseTuple(pArgs, "ii", &id, &samples)) { 3629 2536 return NULL; 3630 2537 } 3631 2538 2539 if (samples < 0) 2540 samples = 0; 2541 3632 2542 status = pjsua_player_set_pos(id, samples); 3633 2543 3634 3635 2544 return Py_BuildValue("i", status); 3636 2545 } … … 3639 2548 * py_pjsua_player_destroy 3640 2549 */ 3641 static PyObject *py_pjsua_player_destroy 3642 (PyObject *pSelf, PyObject *pArgs) 2550 static PyObject *py_pjsua_player_destroy(PyObject *pSelf, PyObject *pArgs) 3643 2551 { 3644 2552 int id; … … 3647 2555 PJ_UNUSED_ARG(pSelf); 3648 2556 3649 if (!PyArg_ParseTuple(pArgs, "i", &id)) 3650 { 2557 if (!PyArg_ParseTuple(pArgs, "i", &id)) { 3651 2558 return NULL; 3652 2559 } … … 3654 2561 status = pjsua_player_destroy(id); 3655 2562 3656 3657 2563 return Py_BuildValue("i", status); 3658 2564 } … … 3660 2566 /* 3661 2567 * py_pjsua_recorder_create 3662 * !modified @ 261206 3663 */ 3664 static PyObject *py_pjsua_recorder_create 3665 (PyObject *pSelf, PyObject *pArgs) 2568 */ 2569 static PyObject *py_pjsua_recorder_create(PyObject *pSelf, PyObject *pArgs) 3666 2570 { 3667 int p_id; 3668 int options; 2571 int id, options; 3669 2572 int max_size; 3670 PyObject * filename; 3671 pj_str_t str; 3672 PyObject * enc_param; 3673 pj_str_t strparam; 2573 PyObject *pFilename, *pEncParam; 2574 pj_str_t filename; 3674 2575 int enc_type; 3675 2576 … … 3678 2579 PJ_UNUSED_ARG(pSelf); 3679 2580 3680 if (!PyArg_ParseTuple(pArgs, "OiOii", &filename, 3681 &enc_type, &enc_param, &max_size, &options)) 3682 { 2581 if (!PyArg_ParseTuple(pArgs, "OiOii", &pFilename, &enc_type, &pEncParam, 2582 &max_size, &options)) 2583 { 2584 return NULL; 2585 } 2586 2587 filename = PyString_ToPJ(pFilename); 2588 2589 status = pjsua_recorder_create(&filename, enc_type, NULL, max_size, 2590 options, &id); 2591 2592 return Py_BuildValue("ii", status, id); 2593 } 2594 2595 /* 2596 * py_pjsua_recorder_get_conf_port 2597 */ 2598 static PyObject *py_pjsua_recorder_get_conf_port(PyObject *pSelf, 2599 PyObject *pArgs) 2600 { 2601 2602 int id, port_id; 2603 2604 PJ_UNUSED_ARG(pSelf); 2605 2606 if (!PyArg_ParseTuple(pArgs, "i", &id)) { 3683 2607 return NULL; 3684 2608 } 3685 str.ptr = PyString_AsString(filename);3686 str.slen = strlen(PyString_AsString(filename));3687 if (enc_param != Py_None)3688 {3689 strparam.ptr = PyString_AsString(enc_param);3690 strparam.slen = strlen(PyString_AsString(enc_param));3691 status = pjsua_recorder_create3692 (&str, enc_type, NULL, max_size, options, &p_id);3693 } else {3694 status = pjsua_recorder_create3695 (&str, enc_type, NULL, max_size, options, &p_id);3696 }3697 return Py_BuildValue("ii", status, p_id);3698 }3699 3700 /*3701 * py_pjsua_recorder_get_conf_port3702 */3703 static PyObject *py_pjsua_recorder_get_conf_port3704 (PyObject *pSelf, PyObject *pArgs)3705 {3706 3707 int id, port_id;3708 3709 PJ_UNUSED_ARG(pSelf);3710 3711 if (!PyArg_ParseTuple(pArgs, "i", &id))3712 {3713 return NULL;3714 }3715 2609 3716 2610 port_id = pjsua_recorder_get_conf_port(id); 3717 2611 3718 3719 2612 return Py_BuildValue("i", port_id); 3720 2613 } … … 3723 2616 * py_pjsua_recorder_destroy 3724 2617 */ 3725 static PyObject *py_pjsua_recorder_destroy 3726 (PyObject *pSelf, PyObject *pArgs) 2618 static PyObject *py_pjsua_recorder_destroy(PyObject *pSelf, PyObject *pArgs) 3727 2619 { 3728 2620 int id; … … 3731 2623 PJ_UNUSED_ARG(pSelf); 3732 2624 3733 if (!PyArg_ParseTuple(pArgs, "i", &id)) 3734 { 2625 if (!PyArg_ParseTuple(pArgs, "i", &id)) { 3735 2626 return NULL; 3736 2627 } … … 3738 2629 status = pjsua_recorder_destroy(id); 3739 2630 3740 3741 2631 return Py_BuildValue("i", status); 3742 2632 } … … 3748 2638 { 3749 2639 pj_status_t status; 3750 PyObject *list; 3751 2640 PyObject *ret; 3752 2641 pjmedia_snd_dev_info info[SND_DEV_NUM]; 3753 2642 unsigned c, i; 3754 2643 3755 2644 PJ_UNUSED_ARG(pSelf); 3756 3757 if (!PyArg_ParseTuple(pArgs, "")) 3758 { 3759 return NULL; 3760 } 3761 2645 PJ_UNUSED_ARG(pArgs); 2646 3762 2647 c = PJ_ARRAY_SIZE(info); 3763 2648 status = pjsua_enum_snd_devs(info, &c); 3764 3765 list = PyList_New(c); 3766 for (i = 0; i < c; i++) 3767 { 3768 int ret; 3769 int j; 3770 char * str; 3771 2649 if (status != PJ_SUCCESS) 2650 c = 0; 2651 2652 ret = PyList_New(c); 2653 for (i = 0; i < c; i++) { 3772 2654 PyObj_pjmedia_snd_dev_info * obj; 3773 obj = (PyObj_pjmedia_snd_dev_info *)pjmedia_snd_dev_info_new 3774 (&PyTyp_pjmedia_snd_dev_info, NULL, NULL); 2655 2656 obj = (PyObj_pjmedia_snd_dev_info *) 2657 pjmedia_snd_dev_info_new(&PyTyp_pjmedia_snd_dev_info, 2658 NULL, NULL); 3775 2659 obj->default_samples_per_sec = info[i].default_samples_per_sec; 3776 2660 obj->input_count = info[i].input_count; 3777 2661 obj->output_count = info[i].output_count; 3778 str = (char *)malloc(SND_NAME_LEN * sizeof(char)); 3779 memset(str, 0, SND_NAME_LEN); 3780 for (j = 0; j < SND_NAME_LEN; j++) 3781 { 3782 str[j] = info[i].name[j]; 3783 } 3784 obj->name = PyString_FromStringAndSize(str, SND_NAME_LEN); 3785 free(str); 3786 ret = PyList_SetItem(list, i, (PyObject *)obj); 3787 if (ret == -1) 3788 { 3789 return NULL; 3790 } 3791 } 3792 3793 return Py_BuildValue("O",list); 2662 obj->name = PyString_FromString(info[i].name); 2663 2664 PyList_SetItem(ret, i, (PyObject *)obj); 2665 } 2666 2667 return (PyObject*)ret; 3794 2668 } 3795 2669 … … 3797 2671 * py_pjsua_get_snd_dev 3798 2672 */ 3799 static PyObject *py_pjsua_get_snd_dev 3800 (PyObject *pSelf, PyObject *pArgs) 2673 static PyObject *py_pjsua_get_snd_dev(PyObject *pSelf, PyObject *pArgs) 3801 2674 { 3802 2675 int capture_dev, playback_dev; … … 3804 2677 3805 2678 PJ_UNUSED_ARG(pSelf); 3806 3807 if (!PyArg_ParseTuple(pArgs, "")) 3808 { 3809 return NULL; 3810 } 3811 2679 PJ_UNUSED_ARG(pArgs); 2680 3812 2681 status = pjsua_get_snd_dev(&capture_dev, &playback_dev); 3813 2682 3814 3815 2683 return Py_BuildValue("ii", capture_dev, playback_dev); 3816 2684 } … … 3819 2687 * py_pjsua_set_snd_dev 3820 2688 */ 3821 static PyObject *py_pjsua_set_snd_dev 3822 (PyObject *pSelf, PyObject *pArgs) 2689 static PyObject *py_pjsua_set_snd_dev(PyObject *pSelf, PyObject *pArgs) 3823 2690 { 3824 2691 int capture_dev, playback_dev; … … 3827 2694 PJ_UNUSED_ARG(pSelf); 3828 2695 3829 if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev)) 3830 { 2696 if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev)) { 3831 2697 return NULL; 3832 2698 } … … 3834 2700 status = pjsua_set_snd_dev(capture_dev, playback_dev); 3835 2701 3836 3837 2702 return Py_BuildValue("i", status); 3838 2703 } … … 3841 2706 * py_pjsua_set_null_snd_dev 3842 2707 */ 3843 static PyObject *py_pjsua_set_null_snd_dev 3844 (PyObject *pSelf, PyObject *pArgs) 2708 static PyObject *py_pjsua_set_null_snd_dev(PyObject *pSelf, PyObject *pArgs) 3845 2709 { 3846 3847 2710 int status; 3848 3849 PJ_UNUSED_ARG(pSelf); 3850 3851 if (!PyArg_ParseTuple(pArgs, "")) 3852 { 3853 return NULL; 3854 } 3855 2711 2712 PJ_UNUSED_ARG(pSelf); 2713 PJ_UNUSED_ARG(pArgs); 2714 3856 2715 status = pjsua_set_null_snd_dev(); 3857 3858 2716 3859 2717 return Py_BuildValue("i", status); 3860 2718 } 3861 2719 3862 2720 /* 3863 * py_pjsua_set_no_snd_dev3864 */3865 static PyObject *py_pjsua_set_no_snd_dev3866 (PyObject *pSelf, PyObject *pArgs)3867 {3868 3869 PyObj_pjmedia_port * obj;3870 3871 PJ_UNUSED_ARG(pSelf);3872 3873 if (!PyArg_ParseTuple(pArgs, ""))3874 {3875 return NULL;3876 }3877 3878 obj = (PyObj_pjmedia_port *)PyType_GenericNew3879 (&PyTyp_pjmedia_port, NULL, NULL);3880 obj->port = pjsua_set_no_snd_dev();3881 return Py_BuildValue("O", obj);3882 }3883 3884 /*3885 2721 * py_pjsua_set_ec 3886 2722 */ 3887 static PyObject *py_pjsua_set_ec 3888 (PyObject *pSelf, PyObject *pArgs) 2723 static PyObject *py_pjsua_set_ec(PyObject *pSelf, PyObject *pArgs) 3889 2724 { 3890 2725 int options; … … 3894 2729 PJ_UNUSED_ARG(pSelf); 3895 2730 3896 if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options)) 3897 { 2731 if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options)) { 3898 2732 return NULL; 3899 2733 } 3900 2734 3901 2735 status = pjsua_set_ec(tail_ms, options); 3902 2736 3903 3904 2737 return Py_BuildValue("i", status); 3905 2738 } … … 3908 2741 * py_pjsua_get_ec_tail 3909 2742 */ 3910 static PyObject *py_pjsua_get_ec_tail 3911 (PyObject *pSelf, PyObject *pArgs) 2743 static PyObject *py_pjsua_get_ec_tail(PyObject *pSelf, PyObject *pArgs) 3912 2744 { 3913 3914 2745 int status; 3915 unsigned p_tail_ms; 3916 3917 PJ_UNUSED_ARG(pSelf); 3918 3919 if (!PyArg_ParseTuple(pArgs, "")) 3920 { 3921 return NULL; 3922 } 3923 3924 status = pjsua_get_ec_tail(&p_tail_ms); 3925 3926 3927 return Py_BuildValue("i", p_tail_ms); 2746 unsigned tail_ms; 2747 2748 PJ_UNUSED_ARG(pSelf); 2749 PJ_UNUSED_ARG(pArgs); 2750 2751 status = pjsua_get_ec_tail(&tail_ms); 2752 if (status != PJ_SUCCESS) 2753 tail_ms = 0; 2754 2755 return Py_BuildValue("i", tail_ms); 3928 2756 } 3929 2757 3930 2758 /* 3931 2759 * py_pjsua_enum_codecs 3932 * !modified @ 2612063933 2760 */ 3934 2761 static PyObject *py_pjsua_enum_codecs(PyObject *pSelf, PyObject *pArgs) 3935 2762 { 3936 2763 pj_status_t status; 3937 PyObject *list; 3938 2764 PyObject *ret; 3939 2765 pjsua_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS]; 3940 2766 unsigned c, i; 3941 2767 3942 2768 PJ_UNUSED_ARG(pSelf); 3943 3944 if (!PyArg_ParseTuple(pArgs, "")) 3945 { 3946 return NULL; 3947 } 3948 2769 PJ_UNUSED_ARG(pArgs); 2770 3949 2771 c = PJ_ARRAY_SIZE(info); 3950 2772 status = pjsua_enum_codecs(info, &c); 3951 3952 list = PyList_New(c); 3953 for (i = 0; i < c; i++) 3954 { 3955 int ret; 3956 int j; 2773 if (status != PJ_SUCCESS) 2774 c = 0; 2775 2776 ret = PyList_New(c); 2777 for (i = 0; i < c; i++) { 3957 2778 PyObj_pjsua_codec_info * obj; 3958 obj = (PyObj_pjsua_codec_info *)codec_info_new 3959 (&PyTyp_pjsua_codec_info, NULL, NULL); 3960 obj->codec_id = PyString_FromStringAndSize 3961 (info[i].codec_id.ptr, info[i].codec_id.slen); 2779 obj = (PyObj_pjsua_codec_info *) 2780 codec_info_new(&PyTyp_pjsua_codec_info, NULL, NULL); 2781 obj->codec_id = PyString_FromPJ(&info[i].codec_id); 3962 2782 obj->priority = info[i].priority; 3963 for (j = 0; j < 32; j++) 3964 { 3965 obj->buf_[j] = info[i].buf_[j]; 3966 } 3967 ret = PyList_SetItem(list, i, (PyObject *)obj); 3968 if (ret == -1) { 3969 return NULL; 3970 } 3971 } 3972 3973 3974 return Py_BuildValue("O",list); 2783 2784 PyList_SetItem(ret, i, (PyObject *)obj); 2785 } 2786 2787 return (PyObject*)ret; 3975 2788 } 3976 2789 … … 3978 2791 * py_pjsua_codec_set_priority 3979 2792 */ 3980 static PyObject *py_pjsua_codec_set_priority 3981 (PyObject *pSelf, PyObject *pArgs) 2793 static PyObject *py_pjsua_codec_set_priority(PyObject *pSelf, PyObject *pArgs) 3982 2794 { 3983 3984 2795 int status; 3985 PyObject * id; 3986 pj_str_t str; 3987 pj_uint8_t priority; 3988 3989 PJ_UNUSED_ARG(pSelf); 3990 3991 if (!PyArg_ParseTuple(pArgs, "OB", &id, &priority)) 3992 { 2796 PyObject *pCodecId; 2797 pj_str_t codec_id; 2798 int priority; 2799 2800 PJ_UNUSED_ARG(pSelf); 2801 2802 if (!PyArg_ParseTuple(pArgs, "Oi", &pCodecId, &priority)) { 2803 return NULL; 2804 } 2805 2806 codec_id = PyString_ToPJ(pCodecId); 2807 if (priority < 0) 2808 priority = 0; 2809 if (priority > 255) 2810 priority = 255; 2811 2812 status = pjsua_codec_set_priority(&codec_id, (pj_uint8_t)priority); 2813 2814 return Py_BuildValue("i", status); 2815 } 2816 2817 /* 2818 * py_pjsua_codec_get_param 2819 */ 2820 static PyObject *py_pjsua_codec_get_param(PyObject *pSelf, PyObject *pArgs) 2821 { 2822 int status; 2823 PyObject *pCodecId; 2824 pj_str_t codec_id; 2825 pjmedia_codec_param param; 2826 PyObj_pjmedia_codec_param *ret; 2827 2828 PJ_UNUSED_ARG(pSelf); 2829 2830 if (!PyArg_ParseTuple(pArgs, "O", &pCodecId)) { 3993 2831 return NULL; 3994 2832 } 3995 str.ptr = PyString_AsString(id); 3996 str.slen = strlen(PyString_AsString(id)); 3997 status = pjsua_codec_set_priority(&str, priority); 3998 3999 4000 return Py_BuildValue("i", status); 4001 } 4002 4003 /* 4004 * py_pjsua_codec_get_param 4005 */ 4006 static PyObject *py_pjsua_codec_get_param 4007 (PyObject *pSelf, PyObject *pArgs) 2833 2834 codec_id = PyString_ToPJ(pCodecId); 2835 2836 status = pjsua_codec_get_param(&codec_id, ¶m); 2837 if (status != PJ_SUCCESS) 2838 return Py_BuildValue(""); 2839 2840 ret = (PyObj_pjmedia_codec_param *) 2841 pjmedia_codec_param_new(&PyTyp_pjmedia_codec_param, NULL, NULL); 2842 2843 ret->info->avg_bps = param.info.avg_bps; 2844 ret->info->channel_cnt = param.info.channel_cnt; 2845 ret->info->clock_rate = param.info.clock_rate; 2846 ret->info->frm_ptime = param.info.frm_ptime; 2847 ret->info->pcm_bits_per_sample = param.info.pcm_bits_per_sample; 2848 ret->info->pt = param.info.pt; 2849 ret->setting->cng = param.setting.cng; 2850 ret->setting->dec_fmtp_mode = param.setting.dec_fmtp_mode; 2851 ret->setting->enc_fmtp_mode = param.setting.enc_fmtp_mode; 2852 ret->setting->frm_per_pkt = param.setting.frm_per_pkt; 2853 ret->setting->penh = param.setting.penh; 2854 ret->setting->plc = param.setting.plc; 2855 ret->setting->vad = param.setting.vad; 2856 2857 return (PyObject*)ret; 2858 } 2859 2860 2861 /* 2862 * py_pjsua_codec_set_param 2863 */ 2864 static PyObject *py_pjsua_codec_set_param(PyObject *pSelf, PyObject *pArgs) 4008 2865 { 4009 4010 2866 int status; 4011 PyObject * id;4012 pj_str_t str;2867 PyObject *pCodecId, *pCodecParam; 2868 pj_str_t codec_id; 4013 2869 pjmedia_codec_param param; 4014 PyObj_pjmedia_codec_param *obj; 4015 4016 PJ_UNUSED_ARG(pSelf); 4017 4018 if (!PyArg_ParseTuple(pArgs, "O", &id)) 4019 { 2870 2871 PJ_UNUSED_ARG(pSelf); 2872 2873 if (!PyArg_ParseTuple(pArgs, "OO", &pCodecId, &pCodecParam)) { 4020 2874 return NULL; 4021 2875 } 4022 str.ptr = PyString_AsString(id); 4023 str.slen = strlen(PyString_AsString(id)); 4024 status = pjsua_codec_get_param(&str, ¶m); 4025 obj = (PyObj_pjmedia_codec_param *)pjmedia_codec_param_new 4026 (&PyTyp_pjmedia_codec_param, NULL, NULL); 4027 obj->info->avg_bps = param.info.avg_bps; 4028 obj->info->channel_cnt = param.info.channel_cnt; 4029 obj->info->clock_rate = param.info.clock_rate; 4030 obj->info->frm_ptime = param.info.frm_ptime; 4031 obj->info->pcm_bits_per_sample = param.info.pcm_bits_per_sample; 4032 obj->info->pt = param.info.pt; 4033 obj->setting->cng = param.setting.cng; 4034 obj->setting->dec_fmtp_mode = param.setting.dec_fmtp_mode; 4035 obj->setting->enc_fmtp_mode = param.setting.enc_fmtp_mode; 4036 obj->setting->frm_per_pkt = param.setting.frm_per_pkt; 4037 obj->setting->penh = param.setting.penh; 4038 obj->setting->plc = param.setting.plc; 4039 obj->setting->reserved = param.setting.reserved; 4040 obj->setting->vad = param.setting.vad; 4041 4042 return Py_BuildValue("O", obj); 4043 } 4044 /* 4045 * py_pjsua_codec_set_param 4046 */ 4047 static PyObject *py_pjsua_codec_set_param 4048 (PyObject *pSelf, PyObject *pArgs) 4049 { 4050 4051 int status; 4052 PyObject * id; 4053 pj_str_t str; 4054 pjmedia_codec_param param; 4055 PyObject * tmpObj; 4056 PyObj_pjmedia_codec_param *obj; 4057 4058 PJ_UNUSED_ARG(pSelf); 4059 4060 if (!PyArg_ParseTuple(pArgs, "OO", &id, &tmpObj)) 4061 { 4062 return NULL; 4063 } 4064 4065 str.ptr = PyString_AsString(id); 4066 str.slen = strlen(PyString_AsString(id)); 4067 if (tmpObj != Py_None) 4068 { 4069 obj = (PyObj_pjmedia_codec_param *)tmpObj; 2876 2877 codec_id = PyString_ToPJ(pCodecId); 2878 2879 if (pCodecParam != Py_None) { 2880 PyObj_pjmedia_codec_param *obj; 2881 2882 obj = (PyObj_pjmedia_codec_param *)pCodecParam; 2883 4070 2884 param.info.avg_bps = obj->info->avg_bps; 4071 2885 param.info.channel_cnt = obj->info->channel_cnt; … … 4080 2894 param.setting.penh = obj->setting->penh; 4081 2895 param.setting.plc = obj->setting->plc; 4082 param.setting.reserved = obj->setting->reserved;4083 2896 param.setting.vad = obj->setting->vad; 4084 status = pjsua_codec_set_param(&str, ¶m); 2897 status = pjsua_codec_set_param(&codec_id, ¶m); 2898 4085 2899 } else { 4086 status = pjsua_codec_set_param(&str, NULL); 4087 } 2900 status = pjsua_codec_set_param(&codec_id, NULL); 2901 } 2902 4088 2903 return Py_BuildValue("i", status); 4089 2904 } … … 4101 2916 "_pjsua.Conf_Port_Info _pjsua.conf_get_port_info (int id) " 4102 2917 "Get information about the specified conference port"; 4103 static char pjsua_conf_add_port_doc[] =4104 "int, int _pjsua.conf_add_port "4105 "(_pjsua.Pj_Pool pool, _pjsua.PJMedia_Port port) "4106 "Add arbitrary media port to PJSUA's conference bridge. "4107 "Application can use this function to add the media port "4108 "that it creates. For media ports that are created by PJSUA-LIB "4109 "(such as calls, file player, or file recorder), PJSUA-LIB will "4110 "automatically add the port to the bridge.";4111 2918 static char pjsua_conf_remove_port_doc[] = 4112 2919 "int _pjsua.conf_remove_port (int id) " … … 4173 2980 "provides the timing needed by the conference bridge, and will not " 4174 2981 "interract with any hardware."; 4175 static char pjsua_set_no_snd_dev_doc[] =4176 "_pjsua.PJMedia_Port _pjsua.set_no_snd_dev () "4177 "Disconnect the main conference bridge from any sound devices, "4178 "and let application connect the bridge to it's "4179 "own sound device/master port.";4180 2982 static char pjsua_set_ec_doc[] = 4181 2983 "int _pjsua.set_ec (int tail_ms, int options) " … … 4203 3005 4204 3006 /* 4205 * PyObj_pj_time_val4206 * PJ Time Val4207 */4208 typedef struct4209 {4210 PyObject_HEAD4211 /* Type-specific fields go here. */4212 long sec;4213 long msec;4214 4215 } PyObj_pj_time_val;4216 4217 4218 4219 /*4220 * pj_time_val_members4221 */4222 static PyMemberDef pj_time_val_members[] =4223 {4224 4225 {4226 "sec", T_INT,4227 offsetof(PyObj_pj_time_val, sec), 0,4228 "The seconds part of the time"4229 },4230 {4231 "msec", T_INT,4232 offsetof(PyObj_pj_time_val, sec), 0,4233 "The milliseconds fraction of the time"4234 },4235 4236 4237 {NULL} /* Sentinel */4238 };4239 4240 4241 4242 4243 /*4244 * PyTyp_pj_time_val4245 */4246 static PyTypeObject PyTyp_pj_time_val =4247 {4248 PyObject_HEAD_INIT(NULL)4249 0, /*ob_size*/4250 "_pjsua.PJ_Time_Val", /*tp_name*/4251 sizeof(PyObj_pj_time_val), /*tp_basicsize*/4252 0, /*tp_itemsize*/4253 0,/*tp_dealloc*/4254 0, /*tp_print*/4255 0, /*tp_getattr*/4256 0, /*tp_setattr*/4257 0, /*tp_compare*/4258 0, /*tp_repr*/4259 0, /*tp_as_number*/4260 0, /*tp_as_sequence*/4261 0, /*tp_as_mapping*/4262 0, /*tp_hash */4263 0, /*tp_call*/4264 0, /*tp_str*/4265 0, /*tp_getattro*/4266 0, /*tp_setattro*/4267 0, /*tp_as_buffer*/4268 Py_TPFLAGS_DEFAULT, /*tp_flags*/4269 "PJ Time Val objects", /* tp_doc */4270 0, /* tp_traverse */4271 0, /* tp_clear */4272 0, /* tp_richcompare */4273 0, /* tp_weaklistoffset */4274 0, /* tp_iter */4275 0, /* tp_iternext */4276 0, /* tp_methods */4277 pj_time_val_members, /* tp_members */4278 4279 4280 };4281 4282 /*4283 * PyObj_pjsua_call_info4284 * Call Info4285 */4286 typedef struct4287 {4288 PyObject_HEAD4289 /* Type-specific fields go here. */4290 4291 int id;4292 int role;4293 int acc_id;4294 PyObject * local_info;4295 PyObject * local_contact;4296 PyObject * remote_info;4297 PyObject * remote_contact;4298 PyObject * call_id;4299 int state;4300 PyObject * state_text;4301 int last_status;4302 PyObject * last_status_text;4303 int media_status;4304 int media_dir;4305 int conf_slot;4306 PyObj_pj_time_val * connect_duration;4307 PyObj_pj_time_val * total_duration;4308 struct {4309 char local_info[128];4310 char local_contact[128];4311 char remote_info[128];4312 char remote_contact[128];4313 char call_id[128];4314 char last_status_text[128];4315 } buf_;4316 4317 } PyObj_pjsua_call_info;4318 4319 4320 /*4321 * call_info_dealloc4322 * deletes a call_info from memory4323 */4324 static void call_info_dealloc(PyObj_pjsua_call_info* self)4325 {4326 Py_XDECREF(self->local_info);4327 Py_XDECREF(self->local_contact);4328 Py_XDECREF(self->remote_info);4329 Py_XDECREF(self->remote_contact);4330 Py_XDECREF(self->call_id);4331 Py_XDECREF(self->state_text);4332 Py_XDECREF(self->last_status_text);4333 Py_XDECREF(self->connect_duration);4334 Py_XDECREF(self->total_duration);4335 self->ob_type->tp_free((PyObject*)self);4336 }4337 4338 4339 /*4340 * call_info_new4341 * constructor for call_info object4342 */4343 static PyObject * call_info_new(PyTypeObject *type, PyObject *args,4344 PyObject *kwds)4345 {4346 PyObj_pjsua_call_info *self;4347 4348 PJ_UNUSED_ARG(args);4349 PJ_UNUSED_ARG(kwds);4350 4351 self = (PyObj_pjsua_call_info *)type->tp_alloc(type, 0);4352 if (self != NULL)4353 {4354 self->local_info = PyString_FromString("");4355 if (self->local_info == NULL)4356 {4357 Py_DECREF(self);4358 return NULL;4359 }4360 self->local_contact = PyString_FromString("");4361 if (self->local_contact == NULL)4362 {4363 Py_DECREF(self);4364 return NULL;4365 }4366 self->remote_info = PyString_FromString("");4367 if (self->remote_info == NULL)4368 {4369 Py_DECREF(self);4370 return NULL;4371 }4372 self->remote_contact = PyString_FromString("");4373 if (self->remote_contact == NULL)4374 {4375 Py_DECREF(self);4376 return NULL;4377 }4378 self->call_id = PyString_FromString("");4379 if (self->call_id == NULL)4380 {4381 Py_DECREF(self);4382 return NULL;4383 }4384 self->state_text = PyString_FromString("");4385 if (self->state_text == NULL)4386 {4387 Py_DECREF(self);4388 return NULL;4389 }4390 self->last_status_text = PyString_FromString("");4391 if (self->last_status_text == NULL)4392 {4393 Py_DECREF(self);4394 return NULL;4395 }4396 self->connect_duration = (PyObj_pj_time_val *)PyType_GenericNew4397 (&PyTyp_pj_time_val,NULL,NULL);4398 if (self->connect_duration == NULL)4399 {4400 Py_DECREF(self);4401 return NULL;4402 }4403 self->total_duration = (PyObj_pj_time_val *)PyType_GenericNew4404 (&PyTyp_pj_time_val,NULL,NULL);4405 if (self->total_duration == NULL)4406 {4407 Py_DECREF(self);4408 return NULL;4409 }4410 }4411 return (PyObject *)self;4412 }4413 4414 /*4415 * call_info_members4416 */4417 static PyMemberDef call_info_members[] =4418 {4419 {4420 "id", T_INT,4421 offsetof(PyObj_pjsua_call_info, id), 0,4422 "Call identification"4423 },4424 {4425 "role", T_INT,4426 offsetof(PyObj_pjsua_call_info, role), 0,4427 "Initial call role (UAC == caller)"4428 },4429 {4430 "acc_id", T_INT,4431 offsetof(PyObj_pjsua_call_info, acc_id), 0,4432 "The account ID where this call belongs."4433 },4434 {4435 "local_info", T_OBJECT_EX,4436 offsetof(PyObj_pjsua_call_info, local_info), 0,4437 "Local URI"4438 },4439 {4440 "local_contact", T_OBJECT_EX,4441 offsetof(PyObj_pjsua_call_info, local_contact), 0,4442 "Local Contact"4443 },4444 {4445 "remote_info", T_OBJECT_EX,4446 offsetof(PyObj_pjsua_call_info, remote_info), 0,4447 "Remote URI"4448 },4449 {4450 "remote_contact", T_OBJECT_EX,4451 offsetof(PyObj_pjsua_call_info, remote_contact), 0,4452 "Remote Contact"4453 },4454 {4455 "call_id", T_OBJECT_EX,4456 offsetof(PyObj_pjsua_call_info, call_id), 0,4457 "Dialog Call-ID string"4458 },4459 {4460 "state", T_INT,4461 offsetof(PyObj_pjsua_call_info, state), 0,4462 "Call state"4463 },4464 {4465 "state_text", T_OBJECT_EX,4466 offsetof(PyObj_pjsua_call_info, state_text), 0,4467 "Text describing the state "4468 },4469 {4470 "last_status", T_INT,4471 offsetof(PyObj_pjsua_call_info, last_status), 0,4472 "Last status code heard, which can be used as cause code"4473 },4474 {4475 "last_status_text", T_OBJECT_EX,4476 offsetof(PyObj_pjsua_call_info, last_status_text), 0,4477 "The reason phrase describing the status."4478 },4479 {4480 "media_status", T_INT,4481 offsetof(PyObj_pjsua_call_info, media_status), 0,4482 "Call media status."4483 },4484 {4485 "media_dir", T_INT,4486 offsetof(PyObj_pjsua_call_info, media_dir), 0,4487 "Media direction"4488 },4489 {4490 "conf_slot", T_INT,4491 offsetof(PyObj_pjsua_call_info, conf_slot), 0,4492 "The conference port number for the call"4493 },4494 {4495 "connect_duration", T_OBJECT_EX,4496 offsetof(PyObj_pjsua_call_info, connect_duration), 0,4497 "Up-to-date call connected duration(zero when call is not established)"4498 },4499 {4500 "total_duration", T_OBJECT_EX,4501 offsetof(PyObj_pjsua_call_info, total_duration), 0,4502 "Total call duration, including set-up time"4503 },4504 4505 {NULL} /* Sentinel */4506 };4507 4508 4509 4510 4511 /*4512 * PyTyp_pjsua_call_info4513 */4514 static PyTypeObject PyTyp_pjsua_call_info =4515 {4516 PyObject_HEAD_INIT(NULL)4517 0, /*ob_size*/4518 "_pjsua.Call_Info", /*tp_name*/4519 sizeof(PyObj_pjsua_call_info), /*tp_basicsize*/4520 0, /*tp_itemsize*/4521 (destructor)call_info_dealloc,/*tp_dealloc*/4522 0, /*tp_print*/4523 0, /*tp_getattr*/4524 0, /*tp_setattr*/4525 0, /*tp_compare*/4526 0, /*tp_repr*/4527 0, /*tp_as_number*/4528 0, /*tp_as_sequence*/4529 0, /*tp_as_mapping*/4530 0, /*tp_hash */4531 0, /*tp_call*/4532 0, /*tp_str*/4533 0, /*tp_getattro*/4534 0, /*tp_setattro*/4535 0, /*tp_as_buffer*/4536 Py_TPFLAGS_DEFAULT, /*tp_flags*/4537 "Call Info objects", /* tp_doc */4538 0, /* tp_traverse */4539 0, /* tp_clear */4540 0, /* tp_richcompare */4541 0, /* tp_weaklistoffset */4542 0, /* tp_iter */4543 0, /* tp_iternext */4544 0, /* tp_methods */4545 call_info_members, /* tp_members */4546 0, /* tp_getset */4547 0, /* tp_base */4548 0, /* tp_dict */4549 0, /* tp_descr_get */4550 0, /* tp_descr_set */4551 0, /* tp_dictoffset */4552 0, /* tp_init */4553 0, /* tp_alloc */4554 call_info_new, /* tp_new */4555 4556 };4557 4558 /*4559 3007 * py_pjsua_call_get_max_count 4560 3008 */ 4561 static PyObject *py_pjsua_call_get_max_count 4562 (PyObject *pSelf, PyObject *pArgs) 3009 static PyObject *py_pjsua_call_get_max_count(PyObject *pSelf, PyObject *pArgs) 4563 3010 { 4564 3011 int count; 4565 3012 4566 3013 PJ_UNUSED_ARG(pSelf); 4567 4568 if (!PyArg_ParseTuple(pArgs, "")) 4569 { 4570 return NULL; 4571 } 4572 3014 PJ_UNUSED_ARG(pArgs); 3015 4573 3016 count = pjsua_call_get_max_count(); 4574 3017 4575 4576 3018 return Py_BuildValue("i", count); 4577 3019 } … … 4580 3022 * py_pjsua_call_get_count 4581 3023 */ 4582 static PyObject *py_pjsua_call_get_count 4583 (PyObject *pSelf, PyObject *pArgs) 3024 static PyObject *py_pjsua_call_get_count(PyObject *pSelf, PyObject *pArgs) 4584 3025 { 4585 4586 3026 int count; 4587 3027 4588 3028 PJ_UNUSED_ARG(pSelf); 4589 4590 if (!PyArg_ParseTuple(pArgs, "")) 4591 { 4592 return NULL; 4593 } 4594 3029 PJ_UNUSED_ARG(pArgs); 3030 4595 3031 count = pjsua_call_get_count(); 4596 3032 4597 4598 3033 return Py_BuildValue("i", count); 4599 3034 } … … 4605 3040 { 4606 3041 pj_status_t status; 4607 PyObject *list; 4608 3042 PyObject *ret; 4609 3043 pjsua_transport_id id[PJSUA_MAX_CALLS]; 4610 3044 unsigned c, i; 4611 3045 4612 3046 PJ_UNUSED_ARG(pSelf); 4613 4614 if (!PyArg_ParseTuple(pArgs, "")) 4615 { 4616 return NULL; 4617 } 4618 3047 PJ_UNUSED_ARG(pArgs); 3048 4619 3049 c = PJ_ARRAY_SIZE(id); 4620 3050 status = pjsua_enum_calls(id, &c); 4621 4622 list = PyList_New(c); 4623 for (i = 0; i < c; i++) 4624 { 4625 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 4626 if (ret == -1) 4627 { 4628 return NULL; 4629 } 4630 } 4631 4632 return Py_BuildValue("O",list); 3051 if (status != PJ_SUCCESS) 3052 c = 0; 3053 3054 ret = PyList_New(c); 3055 for (i = 0; i < c; i++) { 3056 PyList_SetItem(ret, i, Py_BuildValue("i", id[i])); 3057 } 3058 3059 return (PyObject*)ret; 4633 3060 } 4634 3061 … … 4636 3063 * py_pjsua_call_make_call 4637 3064 */ 4638 static PyObject *py_pjsua_call_make_call 4639 (PyObject *pSelf, PyObject *pArgs) 3065 static PyObject *py_pjsua_call_make_call(PyObject *pSelf, PyObject *pArgs) 4640 3066 { 4641 3067 int status; 4642 3068 int acc_id; 4643 3069 pj_str_t dst_uri; 4644 PyObject * sd;3070 PyObject *pDstUri, *pMsgData, *pUserData; 4645 3071 unsigned options; 4646 3072 pjsua_msg_data msg_data; 4647 PyObject * omdObj;4648 PyObj_pjsua_msg_data * omd;4649 int user_data;4650 3073 int call_id; 4651 pj_pool_t * pool;4652 4653 PJ_UNUSED_ARG(pSelf); 4654 4655 if (!PyArg_ParseTuple 4656 (pArgs, "iOIiO", &acc_id, &sd, &options, &user_data, &omdObj))3074 pj_pool_t *pool = NULL; 3075 3076 PJ_UNUSED_ARG(pSelf); 3077 3078 if (!PyArg_ParseTuple(pArgs, "iOIOO", &acc_id, &pDstUri, &options, 3079 &pUserData, &pMsgData)) 4657 3080 { 4658 3081 return NULL; 4659 3082 } 4660 3083 4661 dst_uri .ptr = PyString_AsString(sd);4662 dst_uri.slen = strlen(PyString_AsString(sd));4663 if (omdObj != Py_None) 4664 {4665 omd = (PyObj_pjsua_msg_data *)omdObj;4666 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 4667 msg_data.content_type.slen = strlen4668 (PyString_AsString(omd->content_type)); 4669 msg_data. msg_body.ptr = PyString_AsString(omd->msg_body);4670 msg_data.msg_body .slen = strlen(PyString_AsString(omd->msg_body));4671 pool = pjsua_pool_create("p jsua", POOL_SIZE, POOL_SIZE);3084 dst_uri = PyString_ToPJ(pDstUri); 3085 pjsua_msg_data_init(&msg_data); 3086 3087 if (pMsgData != Py_None) { 3088 PyObj_pjsua_msg_data * omd; 3089 3090 omd = (PyObj_pjsua_msg_data *)pMsgData; 3091 3092 msg_data.content_type = PyString_ToPJ(omd->content_type); 3093 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3094 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 4672 3095 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 4673 status = pjsua_call_make_call(acc_id, &dst_uri, 4674 options, (void*)user_data, &msg_data, &call_id); 4675 pj_pool_release(pool); 4676 } else { 4677 4678 status = pjsua_call_make_call(acc_id, &dst_uri, 4679 options, (void*)user_data, NULL, &call_id); 4680 } 4681 4682 return Py_BuildValue("ii",status, call_id); 4683 3096 } 3097 3098 Py_XINCREF(pUserData); 3099 3100 status = pjsua_call_make_call(acc_id, &dst_uri, 3101 options, (void*)pUserData, 3102 &msg_data, &call_id); 3103 if (pool != NULL) 3104 pj_pool_release(pool); 3105 3106 if (status != PJ_SUCCESS) 3107 Py_XDECREF(pUserData); 3108 3109 return Py_BuildValue("ii", status, call_id); 4684 3110 } 4685 3111 … … 4687 3113 * py_pjsua_call_is_active 4688 3114 */ 4689 static PyObject *py_pjsua_call_is_active 4690 (PyObject *pSelf, PyObject *pArgs) 3115 static PyObject *py_pjsua_call_is_active(PyObject *pSelf, PyObject *pArgs) 4691 3116 { 4692 3117 int call_id; 4693 int isActive; 4694 4695 PJ_UNUSED_ARG(pSelf); 4696 4697 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 4698 { 3118 int is_active; 3119 3120 PJ_UNUSED_ARG(pSelf); 3121 3122 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { 4699 3123 return NULL; 4700 3124 } 4701 3125 4702 isActive = pjsua_call_is_active(call_id); 4703 4704 4705 return Py_BuildValue("i", isActive); 3126 is_active = pjsua_call_is_active(call_id); 3127 3128 return Py_BuildValue("i", is_active); 4706 3129 } 4707 3130 … … 4709 3132 * py_pjsua_call_has_media 4710 3133 */ 4711 static PyObject *py_pjsua_call_has_media 4712 (PyObject *pSelf, PyObject *pArgs) 3134 static PyObject *py_pjsua_call_has_media(PyObject *pSelf, PyObject *pArgs) 4713 3135 { 4714 3136 int call_id; 4715 int hasMedia; 4716 4717 PJ_UNUSED_ARG(pSelf); 4718 4719 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 4720 { 3137 int has_media; 3138 3139 PJ_UNUSED_ARG(pSelf); 3140 3141 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { 4721 3142 return NULL; 4722 3143 } 4723 3144 4724 hasMedia = pjsua_call_has_media(call_id); 4725 4726 4727 return Py_BuildValue("i", hasMedia); 3145 has_media = pjsua_call_has_media(call_id); 3146 3147 return Py_BuildValue("i", has_media); 4728 3148 } 4729 3149 … … 4731 3151 * py_pjsua_call_get_conf_port 4732 3152 */ 4733 static PyObject *py_pjsua_call_get_conf_port 4734 (PyObject *pSelf, PyObject *pArgs) 3153 static PyObject* py_pjsua_call_get_conf_port(PyObject *pSelf, PyObject *pArgs) 4735 3154 { 4736 3155 int call_id; 4737 int port_id; 4738 4739 PJ_UNUSED_ARG(pSelf); 4740 4741 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 4742 { 4743 return NULL; 4744 } 4745 3156 int port_id; 3157 3158 PJ_UNUSED_ARG(pSelf); 3159 3160 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { 3161 return NULL; 3162 } 3163 4746 3164 port_id = pjsua_call_get_conf_port(call_id); 4747 4748 3165 4749 3166 return Py_BuildValue("i", port_id); 4750 3167 } … … 4753 3170 * py_pjsua_call_get_info 4754 3171 */ 4755 static PyObject *py_pjsua_call_get_info 4756 (PyObject *pSelf, PyObject *pArgs) 3172 static PyObject* py_pjsua_call_get_info(PyObject *pSelf, PyObject *pArgs) 4757 3173 { 4758 3174 int call_id; 4759 3175 int status; 4760 PyObj_pjsua_call_info * oi;3176 PyObj_pjsua_call_info *ret; 4761 3177 pjsua_call_info info; 4762 3178 4763 3179 PJ_UNUSED_ARG(pSelf); 4764 3180 4765 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 4766 { 3181 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { 4767 3182 return NULL; 4768 3183 } 4769 3184 4770 4771 3185 status = pjsua_call_get_info(call_id, &info); 4772 if (status == PJ_SUCCESS) 4773 { 4774 oi = (PyObj_pjsua_call_info *)call_info_new(&PyTyp_pjsua_call_info, NULL, NULL); 4775 oi->acc_id = info.acc_id; 4776 pj_ansi_snprintf(oi->buf_.call_id, sizeof(oi->buf_.call_id), 4777 "%.*s", (int)info.call_id.slen, info.call_id.ptr); 4778 pj_ansi_snprintf(oi->buf_.last_status_text, 4779 sizeof(oi->buf_.last_status_text), 4780 "%.*s", (int)info.last_status_text.slen, info.last_status_text.ptr); 4781 pj_ansi_snprintf(oi->buf_.local_contact, sizeof(oi->buf_.local_contact), 4782 "%.*s", (int)info.local_contact.slen, info.local_contact.ptr); 4783 pj_ansi_snprintf(oi->buf_.local_info, sizeof(oi->buf_.local_info), 4784 "%.*s", (int)info.local_info.slen, info.local_info.ptr); 4785 pj_ansi_snprintf(oi->buf_.remote_contact, 4786 sizeof(oi->buf_.remote_contact), 4787 "%.*s", (int)info.remote_contact.slen, info.remote_contact.ptr); 4788 pj_ansi_snprintf(oi->buf_.remote_info, sizeof(oi->buf_.remote_info), 4789 "%.*s", (int)info.remote_info.slen, info.remote_info.ptr); 4790 4791 oi->call_id = PyString_FromStringAndSize(info.call_id.ptr, 4792 info.call_id.slen); 4793 oi->conf_slot = info.conf_slot; 4794 oi->connect_duration->sec = info.connect_duration.sec; 4795 oi->connect_duration->msec = info.connect_duration.msec; 4796 oi->total_duration->sec = info.total_duration.sec; 4797 oi->total_duration->msec = info.total_duration.msec; 4798 oi->id = info.id; 4799 oi->last_status = info.last_status; 4800 oi->last_status_text = PyString_FromStringAndSize( 4801 info.last_status_text.ptr, info.last_status_text.slen); 4802 oi->local_contact = PyString_FromStringAndSize( 4803 info.local_contact.ptr, info.local_contact.slen); 4804 oi->local_info = PyString_FromStringAndSize( 4805 info.local_info.ptr, info.local_info.slen); 4806 oi->remote_contact = PyString_FromStringAndSize( 4807 info.remote_contact.ptr, info.remote_contact.slen); 4808 oi->remote_info = PyString_FromStringAndSize( 4809 info.remote_info.ptr, info.remote_info.slen); 4810 oi->media_dir = info.media_dir; 4811 oi->media_status = info.media_status; 4812 oi->role = info.role; 4813 oi->state = info.state; 4814 oi->state_text = PyString_FromStringAndSize( 4815 info.state_text.ptr, info.state_text.slen); 4816 4817 return Py_BuildValue("O", oi); 4818 } else { 4819 Py_INCREF(Py_None); 4820 return Py_None; 4821 } 3186 if (status != PJ_SUCCESS) 3187 return Py_BuildValue(""); 3188 3189 ret = (PyObj_pjsua_call_info *)call_info_new(&PyTyp_pjsua_call_info, 3190 NULL, NULL); 3191 ret->acc_id = info.acc_id; 3192 Py_XDECREF(ret->call_id); 3193 ret->call_id = PyString_FromPJ(&info.call_id); 3194 ret->conf_slot = info.conf_slot; 3195 ret->connect_duration = info.connect_duration.sec * 1000 + 3196 info.connect_duration.msec; 3197 ret->total_duration = info.total_duration.sec * 1000 + 3198 info.total_duration.msec; 3199 ret->id = info.id; 3200 ret->last_status = info.last_status; 3201 Py_XDECREF(ret->last_status_text); 3202 ret->last_status_text = PyString_FromPJ(&info.last_status_text); 3203 Py_XDECREF(ret->local_contact); 3204 ret->local_contact = PyString_FromPJ(&info.local_contact); 3205 Py_XDECREF(ret->local_info); 3206 ret->local_info = PyString_FromPJ(&info.local_info); 3207 Py_XDECREF(ret->remote_contact); 3208 ret->remote_contact = PyString_FromPJ(&info.remote_contact); 3209 Py_XDECREF(ret->remote_info); 3210 ret->remote_info = PyString_FromPJ(&info.remote_info); 3211 ret->media_dir = info.media_dir; 3212 ret->media_status = info.media_status; 3213 ret->role = info.role; 3214 ret->state = info.state; 3215 Py_XDECREF(ret->state_text); 3216 ret->state_text = PyString_FromPJ(&info.state_text); 3217 3218 return (PyObject*)ret; 4822 3219 } 4823 3220 … … 4825 3222 * py_pjsua_call_set_user_data 4826 3223 */ 4827 static PyObject *py_pjsua_call_set_user_data 4828 (PyObject *pSelf, PyObject *pArgs) 3224 static PyObject *py_pjsua_call_set_user_data(PyObject *pSelf, PyObject *pArgs) 4829 3225 { 4830 3226 int call_id; 4831 int user_data;3227 PyObject *pUserData, *old_user_data; 4832 3228 int status; 4833 3229 4834 3230 PJ_UNUSED_ARG(pSelf); 4835 3231 4836 if (!PyArg_ParseTuple(pArgs, "ii", &call_id, &user_data)) 4837 { 4838 return NULL; 4839 } 4840 4841 status = pjsua_call_set_user_data(call_id, (void*)user_data); 4842 4843 3232 if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &pUserData)) { 3233 return NULL; 3234 } 3235 3236 old_user_data = (PyObject*) pjsua_call_get_user_data(call_id); 3237 3238 if (old_user_data == pUserData) { 3239 return Py_BuildValue("i", PJ_SUCCESS); 3240 } 3241 3242 Py_XINCREF(pUserData); 3243 Py_XDECREF(old_user_data); 3244 3245 status = pjsua_call_set_user_data(call_id, (void*)pUserData); 3246 3247 if (status != PJ_SUCCESS) 3248 Py_XDECREF(pUserData); 3249 4844 3250 return Py_BuildValue("i", status); 4845 3251 } … … 4848 3254 * py_pjsua_call_get_user_data 4849 3255 */ 4850 static PyObject *py_pjsua_call_get_user_data 4851 (PyObject *pSelf, PyObject *pArgs) 3256 static PyObject *py_pjsua_call_get_user_data(PyObject *pSelf, PyObject *pArgs) 4852 3257 { 4853 3258 int call_id; 4854 void * user_data; 4855 4856 PJ_UNUSED_ARG(pSelf); 4857 4858 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) 4859 { 3259 PyObject *user_data; 3260 3261 PJ_UNUSED_ARG(pSelf); 3262 3263 if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { 4860 3264 return NULL; 4861 3265 } 4862 3266 4863 user_data = pjsua_call_get_user_data(call_id); 4864 4865 4866 return Py_BuildValue("i", (int)user_data); 3267 user_data = (PyObject*)pjsua_call_get_user_data(call_id); 3268 return user_data ? Py_BuildValue("O", user_data) : Py_BuildValue(""); 4867 3269 } 4868 3270 … … 4870 3272 * py_pjsua_call_answer 4871 3273 */ 4872 static PyObject *py_pjsua_call_answer 4873 (PyObject *pSelf, PyObject *pArgs) 3274 static PyObject *py_pjsua_call_answer(PyObject *pSelf, PyObject *pArgs) 4874 3275 { 4875 3276 int status; 4876 3277 int call_id; 4877 3278 pj_str_t * reason, tmp_reason; 4878 PyObject * sr;3279 PyObject *pReason; 4879 3280 unsigned code; 4880 3281 pjsua_msg_data msg_data; 4881 3282 PyObject * omdObj; 4882 PyObj_pjsua_msg_data * omd; 4883 pj_pool_t * pool; 4884 4885 PJ_UNUSED_ARG(pSelf); 4886 4887 if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omdObj)) 4888 { 4889 return NULL; 4890 } 4891 if (sr == Py_None) 4892 { 3283 pj_pool_t * pool = NULL; 3284 3285 PJ_UNUSED_ARG(pSelf); 3286 3287 if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &pReason, &omdObj)) { 3288 return NULL; 3289 } 3290 3291 if (pReason == Py_None) { 4893 3292 reason = NULL; 4894 3293 } else { 4895 3294 reason = &tmp_reason; 4896 tmp_reason.ptr = PyString_AsString(sr); 4897 tmp_reason.slen = strlen(PyString_AsString(sr)); 4898 } 4899 if (omdObj != Py_None) 4900 { 3295 tmp_reason = PyString_ToPJ(pReason); 3296 } 3297 3298 pjsua_msg_data_init(&msg_data); 3299 if (omdObj != Py_None) { 3300 PyObj_pjsua_msg_data *omd; 3301 4901 3302 omd = (PyObj_pjsua_msg_data *)omdObj; 4902 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 4903 msg_data.content_type.slen = strlen 4904 (PyString_AsString(omd->content_type)); 4905 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 4906 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 4907 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3303 msg_data.content_type = PyString_ToPJ(omd->content_type); 3304 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3305 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 4908 3306 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 4909 4910 status = pjsua_call_answer(call_id, code, reason, &msg_data); 4911 4912 pj_pool_release(pool); 4913 } else { 4914 4915 status = pjsua_call_answer(call_id, code, reason, NULL); 4916 4917 } 4918 4919 return Py_BuildValue("i",status); 3307 } 3308 3309 status = pjsua_call_answer(call_id, code, reason, &msg_data); 3310 3311 if (pool) 3312 pj_pool_release(pool); 3313 3314 return Py_BuildValue("i", status); 4920 3315 } 4921 3316 … … 4923 3318 * py_pjsua_call_hangup 4924 3319 */ 4925 static PyObject *py_pjsua_call_hangup 4926 (PyObject *pSelf, PyObject *pArgs) 3320 static PyObject *py_pjsua_call_hangup(PyObject *pSelf, PyObject *pArgs) 4927 3321 { 4928 3322 int status; 4929 3323 int call_id; 4930 pj_str_t * 4931 PyObject * sr;3324 pj_str_t *reason, tmp_reason; 3325 PyObject *pReason; 4932 3326 unsigned code; 4933 3327 pjsua_msg_data msg_data; 4934 PyObject * 4935 PyObj_pjsua_msg_data * omd;4936 pj_pool_t * pool = NULL; 4937 4938 PJ_UNUSED_ARG(pSelf); 4939 4940 if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr,&omdObj))4941 { 4942 return NULL; 4943 } 4944 if (sr == Py_None) 4945 {3328 PyObject *omdObj; 3329 pj_pool_t *pool = NULL; 3330 3331 PJ_UNUSED_ARG(pSelf); 3332 3333 if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &pReason, 3334 &omdObj)) 3335 { 3336 return NULL; 3337 } 3338 3339 if (pReason == Py_None) { 4946 3340 reason = NULL; 4947 3341 } else { 4948 3342 reason = &tmp_reason; 4949 tmp_reason.ptr = PyString_AsString(sr); 4950 tmp_reason.slen = strlen(PyString_AsString(sr)); 4951 } 4952 if (omdObj != Py_None) 4953 { 3343 tmp_reason = PyString_ToPJ(pReason); 3344 } 3345 3346 pjsua_msg_data_init(&msg_data); 3347 if (omdObj != Py_None) { 3348 PyObj_pjsua_msg_data *omd; 3349 4954 3350 omd = (PyObj_pjsua_msg_data *)omdObj; 4955 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 4956 msg_data.content_type.slen = strlen 4957 (PyString_AsString(omd->content_type)); 4958 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 4959 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 4960 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3351 msg_data.content_type = PyString_ToPJ(omd->content_type); 3352 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3353 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 4961 3354 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 4962 status = pjsua_call_hangup(call_id, code, reason, &msg_data);4963 pj_pool_release(pool);4964 } else {4965 status = pjsua_call_hangup(call_id, code, reason, NULL);4966 } 4967 4968 return Py_BuildValue("i", status);3355 } 3356 3357 status = pjsua_call_hangup(call_id, code, reason, &msg_data); 3358 if (pool) 3359 pj_pool_release(pool); 3360 3361 return Py_BuildValue("i", status); 4969 3362 } 4970 3363 … … 4972 3365 * py_pjsua_call_set_hold 4973 3366 */ 4974 static PyObject *py_pjsua_call_set_hold 4975 (PyObject *pSelf, PyObject *pArgs) 3367 static PyObject *py_pjsua_call_set_hold(PyObject *pSelf, PyObject *pArgs) 4976 3368 { 4977 3369 int status; 4978 3370 int call_id; 4979 3371 pjsua_msg_data msg_data; 4980 PyObject * 4981 PyObj_pjsua_msg_data * omd;4982 pj_pool_t * pool; 4983 4984 PJ_UNUSED_ARG(pSelf); 4985 4986 if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omdObj))4987 {4988 return NULL; 4989 }4990 4991 if (omdObj != Py_None)4992 { 3372 PyObject *omdObj; 3373 pj_pool_t *pool = NULL; 3374 3375 PJ_UNUSED_ARG(pSelf); 3376 3377 if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omdObj)) { 3378 return NULL; 3379 } 3380 3381 pjsua_msg_data_init(&msg_data); 3382 if (omdObj != Py_None) { 3383 PyObj_pjsua_msg_data *omd; 3384 4993 3385 omd = (PyObj_pjsua_msg_data *)omdObj; 4994 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 4995 msg_data.content_type.slen = strlen 4996 (PyString_AsString(omd->content_type)); 4997 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 4998 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 4999 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3386 msg_data.content_type = PyString_ToPJ(omd->content_type); 3387 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3388 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 5000 3389 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 5001 status = pjsua_call_set_hold(call_id, &msg_data); 3390 } 3391 3392 status = pjsua_call_set_hold(call_id, &msg_data); 3393 3394 if (pool) 5002 3395 pj_pool_release(pool); 5003 } else { 5004 status = pjsua_call_set_hold(call_id, NULL); 5005 } 3396 5006 3397 return Py_BuildValue("i",status); 5007 3398 } … … 5010 3401 * py_pjsua_call_reinvite 5011 3402 */ 5012 static PyObject *py_pjsua_call_reinvite 5013 (PyObject *pSelf, PyObject *pArgs) 3403 static PyObject *py_pjsua_call_reinvite(PyObject *pSelf, PyObject *pArgs) 5014 3404 { 5015 3405 int status; 5016 int call_id; 3406 int call_id; 5017 3407 int unhold; 5018 3408 pjsua_msg_data msg_data; 5019 PyObject * 5020 PyObj_pjsua_msg_data * omd;5021 pj_pool_t * pool; 5022 5023 PJ_UNUSED_ARG(pSelf); 5024 5025 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omdObj))5026 {5027 return NULL; 5028 }5029 5030 if (omdObj != Py_None) 5031 { 3409 PyObject *omdObj; 3410 pj_pool_t *pool = NULL; 3411 3412 PJ_UNUSED_ARG(pSelf); 3413 3414 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omdObj)) { 3415 return NULL; 3416 } 3417 3418 pjsua_msg_data_init(&msg_data); 3419 if (omdObj != Py_None) { 3420 PyObj_pjsua_msg_data *omd; 3421 5032 3422 omd = (PyObj_pjsua_msg_data *)omdObj; 5033 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 5034 msg_data.content_type.slen = strlen 5035 (PyString_AsString(omd->content_type)); 5036 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 5037 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 5038 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3423 msg_data.content_type = PyString_ToPJ(omd->content_type); 3424 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3425 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 5039 3426 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 5040 status = pjsua_call_reinvite(call_id, unhold, &msg_data); 3427 } 3428 3429 status = pjsua_call_reinvite(call_id, unhold, &msg_data); 3430 3431 if (pool) 5041 3432 pj_pool_release(pool); 5042 } else { 5043 status = pjsua_call_reinvite(call_id, unhold, NULL); 5044 } 5045 return Py_BuildValue("i",status); 3433 3434 return Py_BuildValue("i", status); 5046 3435 } 5047 3436 … … 5049 3438 * py_pjsua_call_update 5050 3439 */ 5051 static PyObject *py_pjsua_call_update 5052 (PyObject *pSelf, PyObject *pArgs) 3440 static PyObject *py_pjsua_call_update(PyObject *pSelf, PyObject *pArgs) 5053 3441 { 5054 3442 int status; … … 5056 3444 int option; 5057 3445 pjsua_msg_data msg_data; 5058 PyObject * 5059 PyObj_pjsua_msg_data * omd;5060 pj_pool_t * pool; 5061 5062 PJ_UNUSED_ARG(pSelf); 5063 5064 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &option, &omdObj))5065 {5066 return NULL; 5067 }5068 5069 if (omdObj != Py_None) 5070 { 3446 PyObject *omdObj; 3447 pj_pool_t *pool = NULL; 3448 3449 PJ_UNUSED_ARG(pSelf); 3450 3451 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &option, &omdObj)) { 3452 return NULL; 3453 } 3454 3455 pjsua_msg_data_init(&msg_data); 3456 if (omdObj != Py_None) { 3457 PyObj_pjsua_msg_data *omd; 3458 5071 3459 omd = (PyObj_pjsua_msg_data *)omdObj; 5072 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 5073 msg_data.content_type.slen = strlen 5074 (PyString_AsString(omd->content_type)); 5075 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 5076 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 5077 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3460 msg_data.content_type = PyString_ToPJ(omd->content_type); 3461 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3462 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 5078 3463 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 5079 status = pjsua_call_update(call_id, option, &msg_data); 3464 } 3465 3466 status = pjsua_call_update(call_id, option, &msg_data); 3467 3468 if (pool) 5080 3469 pj_pool_release(pool); 5081 } else { 5082 status = pjsua_call_update(call_id, option, NULL); 5083 } 5084 return Py_BuildValue("i",status); 3470 3471 return Py_BuildValue("i", status); 5085 3472 } 5086 3473 … … 5088 3475 * py_pjsua_call_send_request 5089 3476 */ 5090 static PyObject *py_pjsua_call_send_request 5091 (PyObject *pSelf, PyObject *pArgs) 3477 static PyObject *py_pjsua_call_send_request(PyObject *pSelf, PyObject *pArgs) 5092 3478 { 5093 3479 int status; 5094 3480 int call_id; 5095 PyObject * method_obj;3481 PyObject *pMethod; 5096 3482 pj_str_t method; 5097 3483 pjsua_msg_data msg_data; 5098 PyObject * omdObj; 5099 PyObj_pjsua_msg_data * omd; 5100 pj_pool_t * pool; 5101 5102 PJ_UNUSED_ARG(pSelf); 5103 5104 if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &method_obj, &omdObj)) 5105 { 5106 return NULL; 5107 } 5108 5109 if (!PyString_Check(method_obj)) { 3484 PyObject *omdObj; 3485 pj_pool_t *pool = NULL; 3486 3487 PJ_UNUSED_ARG(pSelf); 3488 3489 if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &pMethod, &omdObj)) { 3490 return NULL; 3491 } 3492 3493 if (!PyString_Check(pMethod)) { 5110 3494 return NULL; 5111 3495 } 5112 3496 5113 method.ptr = PyString_AsString(method_obj); 5114 method.slen = PyString_Size(method_obj); 5115 5116 if (omdObj != Py_None) 5117 { 3497 method = PyString_ToPJ(pMethod); 3498 pjsua_msg_data_init(&msg_data); 3499 3500 if (omdObj != Py_None) { 3501 PyObj_pjsua_msg_data *omd; 3502 5118 3503 omd = (PyObj_pjsua_msg_data *)omdObj; 5119 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 5120 msg_data.content_type.slen = strlen 5121 (PyString_AsString(omd->content_type)); 5122 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 5123 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 5124 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3504 msg_data.content_type = PyString_ToPJ(omd->content_type); 3505 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3506 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 5125 3507 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 5126 status = pjsua_call_send_request(call_id, &method, &msg_data); 3508 } 3509 3510 status = pjsua_call_send_request(call_id, &method, &msg_data); 3511 3512 if (pool) 5127 3513 pj_pool_release(pool); 5128 } else { 5129 status = pjsua_call_send_request(call_id, &method, NULL); 5130 } 5131 return Py_BuildValue("i",status); 3514 3515 return Py_BuildValue("i", status); 5132 3516 } 5133 3517 … … 5135 3519 * py_pjsua_call_xfer 5136 3520 */ 5137 static PyObject *py_pjsua_call_xfer 5138 (PyObject *pSelf, PyObject *pArgs) 3521 static PyObject *py_pjsua_call_xfer(PyObject *pSelf, PyObject *pArgs) 5139 3522 { 5140 3523 int status; 5141 3524 int call_id; 5142 3525 pj_str_t dest; 5143 PyObject * sd;3526 PyObject *pDstUri; 5144 3527 pjsua_msg_data msg_data; 5145 PyObject * omdObj; 5146 PyObj_pjsua_msg_data * omd; 5147 pj_pool_t * pool; 5148 5149 PJ_UNUSED_ARG(pSelf); 5150 5151 if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &sd, &omdObj)) 5152 { 5153 return NULL; 5154 } 5155 5156 dest.ptr = PyString_AsString(sd); 5157 dest.slen = strlen(PyString_AsString(sd)); 5158 5159 if (omdObj != Py_None) 5160 { 3528 PyObject *omdObj; 3529 pj_pool_t *pool = NULL; 3530 3531 PJ_UNUSED_ARG(pSelf); 3532 3533 if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &pDstUri, &omdObj)) { 3534 return NULL; 3535 } 3536 3537 if (!PyString_Check(pDstUri)) 3538 return NULL; 3539 3540 dest = PyString_ToPJ(pDstUri); 3541 pjsua_msg_data_init(&msg_data); 3542 3543 if (omdObj != Py_None) { 3544 PyObj_pjsua_msg_data *omd; 3545 5161 3546 omd = (PyObj_pjsua_msg_data *)omdObj; 5162 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 5163 msg_data.content_type.slen = strlen 5164 (PyString_AsString(omd->content_type)); 5165 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 5166 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 5167 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3547 msg_data.content_type = PyString_ToPJ(omd->content_type); 3548 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3549 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 5168 3550 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 5169 status = pjsua_call_xfer(call_id, &dest, &msg_data); 3551 } 3552 3553 status = pjsua_call_xfer(call_id, &dest, &msg_data); 3554 3555 if (pool) 5170 3556 pj_pool_release(pool); 5171 } else { 5172 status = pjsua_call_xfer(call_id, &dest, NULL); 5173 } 5174 return Py_BuildValue("i",status); 3557 3558 return Py_BuildValue("i", status); 5175 3559 } 5176 3560 … … 5178 3562 * py_pjsua_call_xfer_replaces 5179 3563 */ 5180 static PyObject *py_pjsua_call_xfer_replaces 5181 (PyObject *pSelf, PyObject *pArgs) 3564 static PyObject *py_pjsua_call_xfer_replaces(PyObject *pSelf, PyObject *pArgs) 5182 3565 { 5183 3566 int status; … … 5186 3569 unsigned options; 5187 3570 pjsua_msg_data msg_data; 5188 PyObject * omdObj; 5189 PyObj_pjsua_msg_data * omd; 5190 pj_pool_t * pool; 5191 5192 PJ_UNUSED_ARG(pSelf); 5193 5194 if (!PyArg_ParseTuple 5195 (pArgs, "iiIO", &call_id, &dest_call_id, &options, &omdObj)) 5196 { 5197 return NULL; 5198 } 5199 5200 if (omdObj != Py_None) 5201 { 5202 omd = (PyObj_pjsua_msg_data *)omdObj; 5203 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 5204 msg_data.content_type.slen = strlen 5205 (PyString_AsString(omd->content_type)); 5206 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 5207 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 5208 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3571 PyObject *omdObj; 3572 pj_pool_t *pool = NULL; 3573 3574 PJ_UNUSED_ARG(pSelf); 3575 3576 if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &dest_call_id, 3577 &options, &omdObj)) 3578 { 3579 return NULL; 3580 } 3581 3582 pjsua_msg_data_init(&msg_data); 3583 3584 if (omdObj != Py_None) { 3585 PyObj_pjsua_msg_data *omd; 3586 3587 omd = (PyObj_pjsua_msg_data *)omdObj; 3588 msg_data.content_type = PyString_ToPJ(omd->content_type); 3589 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3590 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 5209 3591 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 5210 status = pjsua_call_xfer_replaces 5211 (call_id, dest_call_id, options, &msg_data); 5212 pj_pool_release(pool); 5213 } else { 5214 status = pjsua_call_xfer_replaces(call_id, dest_call_id,options, NULL); 5215 } 5216 return Py_BuildValue("i",status); 3592 } 3593 3594 status = pjsua_call_xfer_replaces(call_id, dest_call_id, options, 3595 &msg_data); 3596 3597 if (pool) 3598 pj_pool_release(pool); 3599 3600 return Py_BuildValue("i", status); 5217 3601 } 5218 3602 … … 5220 3604 * py_pjsua_call_dial_dtmf 5221 3605 */ 5222 static PyObject *py_pjsua_call_dial_dtmf 5223 (PyObject *pSelf, PyObject *pArgs) 3606 static PyObject *py_pjsua_call_dial_dtmf(PyObject *pSelf, PyObject *pArgs) 5224 3607 { 5225 3608 int call_id; 5226 PyObject * sd;3609 PyObject *pDigits; 5227 3610 pj_str_t digits; 5228 3611 int status; … … 5230 3613 PJ_UNUSED_ARG(pSelf); 5231 3614 5232 if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &sd)) 5233 { 5234 return NULL; 5235 } 5236 digits.ptr = PyString_AsString(sd); 5237 digits.slen = strlen(PyString_AsString(sd)); 3615 if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &pDigits)) { 3616 return NULL; 3617 } 3618 3619 if (!PyString_Check(pDigits)) 3620 return Py_BuildValue("i", PJ_EINVAL); 3621 3622 digits = PyString_ToPJ(pDigits); 5238 3623 status = pjsua_call_dial_dtmf(call_id, &digits); 5239 3624 … … 5244 3629 * py_pjsua_call_send_im 5245 3630 */ 5246 static PyObject *py_pjsua_call_send_im 5247 (PyObject *pSelf, PyObject *pArgs) 3631 static PyObject *py_pjsua_call_send_im(PyObject *pSelf, PyObject *pArgs) 5248 3632 { 5249 3633 int status; … … 5251 3635 pj_str_t content; 5252 3636 pj_str_t * mime_type, tmp_mime_type; 5253 PyObject * sm; 5254 PyObject * sc; 3637 PyObject *pMimeType, *pContent, *omdObj; 5255 3638 pjsua_msg_data msg_data; 5256 PyObject * omdObj;5257 PyObj_pjsua_msg_data * omd;5258 3639 int user_data; 5259 pj_pool_t * pool; 5260 5261 PJ_UNUSED_ARG(pSelf); 5262 5263 if (!PyArg_ParseTuple 5264 (pArgs, "iOOOi", &call_id, &sm, &sc, &omdObj, &user_data)) 5265 { 5266 return NULL; 5267 } 5268 if (sm == Py_None) 5269 { 5270 mime_type = NULL; 3640 pj_pool_t *pool = NULL; 3641 3642 PJ_UNUSED_ARG(pSelf); 3643 3644 if (!PyArg_ParseTuple(pArgs, "iOOOi", &call_id, &pMimeType, &pContent, 3645 &omdObj, &user_data)) 3646 { 3647 return NULL; 3648 } 3649 3650 if (!PyString_Check(pContent)) 3651 return Py_BuildValue("i", PJ_EINVAL); 3652 3653 content = PyString_ToPJ(pContent); 3654 3655 if (PyString_Check(pMimeType)) { 3656 mime_type = &tmp_mime_type; 3657 tmp_mime_type = PyString_ToPJ(pMimeType); 5271 3658 } else { 5272 mime_type = &tmp_mime_type; 5273 tmp_mime_type.ptr = PyString_AsString(sm); 5274 tmp_mime_type.slen = strlen(PyString_AsString(sm)); 5275 } 5276 content.ptr = PyString_AsString(sc); 5277 content.slen = strlen(PyString_AsString(sc)); 5278 5279 if (omdObj != Py_None) 5280 { 3659 mime_type = NULL; 3660 } 3661 3662 pjsua_msg_data_init(&msg_data); 3663 if (omdObj != Py_None) { 3664 PyObj_pjsua_msg_data * omd; 3665 5281 3666 omd = (PyObj_pjsua_msg_data *)omdObj; 5282 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 5283 msg_data.content_type.slen = strlen 5284 (PyString_AsString(omd->content_type)); 5285 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 5286 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 5287 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3667 msg_data.content_type = PyString_ToPJ(omd->content_type); 3668 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3669 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 5288 3670 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 5289 status = pjsua_call_send_im 5290 (call_id, mime_type, &content, &msg_data, (void *)user_data); 3671 } 3672 3673 status = pjsua_call_send_im(call_id, mime_type, &content, 3674 &msg_data, (void *)user_data); 3675 3676 if (pool) 5291 3677 pj_pool_release(pool); 5292 } else { 5293 status = pjsua_call_send_im 5294 (call_id, mime_type, &content, NULL, (void *)user_data); 5295 } 5296 5297 return Py_BuildValue("i",status); 3678 3679 return Py_BuildValue("i", status); 5298 3680 } 5299 3681 … … 5301 3683 * py_pjsua_call_send_typing_ind 5302 3684 */ 5303 static PyObject *py_pjsua_call_send_typing_ind 5304 (PyObject *pSelf,PyObject *pArgs)3685 static PyObject *py_pjsua_call_send_typing_ind(PyObject *pSelf, 3686 PyObject *pArgs) 5305 3687 { 5306 3688 int status; … … 5308 3690 int is_typing; 5309 3691 pjsua_msg_data msg_data; 5310 PyObject * omdObj; 5311 PyObj_pjsua_msg_data * omd; 5312 pj_pool_t * pool; 5313 5314 PJ_UNUSED_ARG(pSelf); 5315 5316 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omdObj)) 5317 { 3692 PyObject *omdObj; 3693 pj_pool_t *pool = NULL; 3694 3695 PJ_UNUSED_ARG(pSelf); 3696 3697 if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omdObj)) { 5318 3698 return NULL; 5319 3699 } 5320 3700 5321 if (omdObj != Py_None) 5322 { 3701 pjsua_msg_data_init(&msg_data); 3702 if (omdObj != Py_None) { 3703 PyObj_pjsua_msg_data *omd; 3704 5323 3705 omd = (PyObj_pjsua_msg_data *)omdObj; 5324 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 5325 msg_data.content_type.slen = strlen 5326 (PyString_AsString(omd->content_type)); 5327 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 5328 msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 5329 pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 3706 msg_data.content_type = PyString_ToPJ(omd->content_type); 3707 msg_data.msg_body = PyString_ToPJ(omd->msg_body); 3708 pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); 5330 3709 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 5331 status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data); 3710 } 3711 3712 status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data); 3713 3714 if (pool) 5332 3715 pj_pool_release(pool); 5333 } else { 5334 status = pjsua_call_send_typing_ind(call_id, is_typing, NULL); 5335 } 5336 return Py_BuildValue("i",status); 3716 3717 return Py_BuildValue("i", status); 5337 3718 } 5338 3719 … … 5340 3721 * py_pjsua_call_hangup_all 5341 3722 */ 5342 static PyObject *py_pjsua_call_hangup_all 5343 (PyObject *pSelf, PyObject *pArgs) 3723 static PyObject *py_pjsua_call_hangup_all(PyObject *pSelf, PyObject *pArgs) 5344 3724 { 5345 5346 PJ_UNUSED_ARG(pSelf); 5347 5348 if (!PyArg_ParseTuple(pArgs, "")) 5349 { 5350 return NULL; 5351 } 5352 3725 PJ_UNUSED_ARG(pSelf); 3726 PJ_UNUSED_ARG(pArgs); 3727 5353 3728 pjsua_call_hangup_all(); 5354 3729 5355 Py_INCREF(Py_None); 5356 return Py_None; 3730 return Py_BuildValue(""); 5357 3731 } 5358 3732 … … 5360 3734 * py_pjsua_call_dump 5361 3735 */ 5362 static PyObject *py_pjsua_call_dump 5363 (PyObject *pSelf, PyObject *pArgs) 3736 static PyObject *py_pjsua_call_dump(PyObject *pSelf, PyObject *pArgs) 5364 3737 { 5365 3738 int call_id; 5366 3739 int with_media; 5367 PyObject * sb;5368 PyObject * si;5369 char * 5370 char * 3740 PyObject *ret; 3741 PyObject *pIndent; 3742 char *buffer; 3743 char *indent; 5371 3744 unsigned maxlen; 5372 3745 int status; … … 5374 3747 PJ_UNUSED_ARG(pSelf); 5375 3748 5376 if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media, &maxlen, &si)) 3749 if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media, 3750 &maxlen, &pIndent)) 5377 3751 { 5378 3752 return NULL; 5379 3753 } 5380 buffer = (char *) malloc (maxlen * sizeof(char)); 5381 indent = PyString_AsString(si); 3754 3755 buffer = (char*) malloc(maxlen * sizeof(char)); 3756 indent = PyString_AsString(pIndent); 5382 3757 5383 3758 status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent); 5384 sb = PyString_FromStringAndSize(buffer, maxlen); 3759 if (status != PJ_SUCCESS) { 3760 free(buffer); 3761 return PyString_FromString(""); 3762 } 3763 3764 ret = PyString_FromString(buffer); 5385 3765 free(buffer); 5386 return Py_BuildValue("O", sb);3766 return (PyObject*)ret; 5387 3767 } 5388 3768 … … 5394 3774 static PyObject *py_pjsua_dump(PyObject *pSelf, PyObject *pArgs) 5395 3775 { 5396 unsigned old_decor;5397 char buf[1024];5398 3776 int detail; 5399 3777 5400 3778 PJ_UNUSED_ARG(pSelf); 5401 3779 5402 if (!PyArg_ParseTuple(pArgs, "i", &detail)) 5403 { 3780 if (!PyArg_ParseTuple(pArgs, "i", &detail)) { 5404 3781 return NULL; 5405 3782 } 5406 3783 5407 PJ_LOG(3,(THIS_FILE, "Start dumping application states:")); 5408 5409 old_decor = pj_log_get_decor(); 5410 pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR)); 5411 5412 if (detail) 5413 pj_dump_config(); 5414 5415 pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail); 5416 pjmedia_endpt_dump(pjsua_get_pjmedia_endpt()); 5417 pjsip_tsx_layer_dump(detail); 5418 pjsip_ua_dump(detail); 5419 5420 5421 /* Dump all invite sessions: */ 5422 PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:")); 5423 5424 if (pjsua_call_get_count() == 0) { 5425 5426 PJ_LOG(3,(THIS_FILE, " - no sessions -")); 5427 5428 } else { 5429 unsigned i, max; 5430 5431 max = pjsua_call_get_max_count(); 5432 for (i=0; i<max; ++i) { 5433 if (pjsua_call_is_active(i)) { 5434 pjsua_call_dump(i, detail, buf, sizeof(buf), " "); 5435 PJ_LOG(3,(THIS_FILE, "%s", buf)); 5436 } 5437 } 5438 } 5439 5440 /* Dump presence status */ 5441 pjsua_pres_dump(detail); 5442 5443 pj_log_set_decor(old_decor); 5444 PJ_LOG(3,(THIS_FILE, "Dump complete")); 5445 5446 Py_INCREF(Py_None); 5447 return Py_None; 3784 pjsua_dump(detail); 3785 3786 return Py_BuildValue(""); 5448 3787 } 5449 3788 … … 5456 3795 int err; 5457 3796 char err_msg[PJ_ERR_MSG_SIZE]; 5458 5459 PJ_UNUSED_ARG(pSelf); 5460 5461 if (!PyArg_ParseTuple(pArgs, "i", &err)) 5462 {5463 return NULL; 5464 } 5465 5466 pj_strerror(err, err_msg, sizeof(err_msg));5467 5468 return PyString_FromString (err_msg);3797 pj_str_t ret; 3798 3799 PJ_UNUSED_ARG(pSelf); 3800 3801 if (!PyArg_ParseTuple(pArgs, "i", &err)) { 3802 return NULL; 3803 } 3804 3805 ret = pj_strerror(err, err_msg, sizeof(err_msg)); 3806 3807 return PyString_FromStringAndSize(err_msg, ret.slen); 5469 3808 } 5470 3809 … … 5475 3814 static PyObject *py_pj_parse_simple_sip(PyObject *pSelf, PyObject *pArgs) 5476 3815 { 5477 const char * uri_param;3816 const char *arg_uri; 5478 3817 pj_pool_t *pool; 5479 3818 char tmp[PJSIP_MAX_URL_SIZE]; … … 5484 3823 PJ_UNUSED_ARG(pSelf); 5485 3824 5486 if (!PyArg_ParseTuple(pArgs, "s", &uri_param)) 5487 { 5488 return NULL; 5489 } 5490 5491 strncpy(tmp, uri_param, sizeof(tmp)); 3825 if (!PyArg_ParseTuple(pArgs, "s", &arg_uri)) { 3826 return NULL; 3827 } 3828 3829 strncpy(tmp, arg_uri, sizeof(tmp)); 5492 3830 tmp[sizeof(tmp)-1] = '\0'; 5493 3831 … … 5498 3836 !PJSIP_URI_SCHEME_IS_SIPS(uri))) { 5499 3837 pj_pool_release(pool); 5500 Py_INCREF(Py_None); 5501 return Py_None; 3838 return Py_BuildValue(""); 5502 3839 } 5503 3840 … … 5506 3843 5507 3844 /* Scheme */ 5508 item = PyString_FromStringAndSize(pjsip_uri_get_scheme(uri)->ptr, 5509 pjsip_uri_get_scheme(uri)->slen); 3845 item = PyString_FromPJ(pjsip_uri_get_scheme(uri)); 5510 3846 PyTuple_SetItem(ret, 0, item); 5511 3847 5512 3848 /* Username */ 5513 item = PyString_From StringAndSize(sip_uri->user.ptr, sip_uri->user.slen);3849 item = PyString_FromPJ(&sip_uri->user); 5514 3850 PyTuple_SetItem(ret, 1, item); 5515 3851 5516 3852 /* Host */ 5517 item = PyString_From StringAndSize(sip_uri->host.ptr, sip_uri->host.slen);3853 item = PyString_FromPJ(&sip_uri->host); 5518 3854 PyTuple_SetItem(ret, 2, item); 5519 3855 … … 5530 3866 sip_uri->transport_param.slen = 0; 5531 3867 } 5532 item = PyString_FromStringAndSize(sip_uri->transport_param.ptr, 5533 sip_uri->transport_param.slen); 3868 item = PyString_FromPJ(&sip_uri->transport_param); 5534 3869 PyTuple_SetItem(ret, 4, item); 5535 3870 … … 5653 3988 }, 5654 3989 { 5655 "pool_create", py_pjsua_pool_create, METH_VARARGS,5656 pjsua_pool_create_doc5657 },5658 {5659 "get_pjsip_endpt", py_pjsua_get_pjsip_endpt, METH_VARARGS,5660 pjsua_get_pjsip_endpt_doc5661 },5662 {5663 "get_pjmedia_endpt", py_pjsua_get_pjmedia_endpt, METH_VARARGS,5664 pjsua_get_pjmedia_endpt_doc5665 },5666 {5667 "get_pool_factory", py_pjsua_get_pool_factory, METH_VARARGS,5668 pjsua_get_pool_factory_doc5669 },5670 {5671 3990 "reconfigure_logging", py_pjsua_reconfigure_logging, METH_VARARGS, 5672 3991 pjsua_reconfigure_logging_doc … … 5747 4066 }, 5748 4067 { 4068 "acc_set_user_data", py_pjsua_acc_set_user_data, METH_VARARGS, 4069 "Accociate user data with the account" 4070 }, 4071 { 4072 "acc_get_user_data", py_pjsua_acc_get_user_data, METH_VARARGS, 4073 "Get account's user data" 4074 }, 4075 { 5749 4076 "acc_modify", py_pjsua_acc_modify, METH_VARARGS, 5750 4077 pjsua_acc_modify_doc … … 5777 4104 "acc_enum_info", py_pjsua_acc_enum_info, METH_VARARGS, 5778 4105 pjsua_acc_enum_info_doc 5779 },5780 {5781 "acc_find_for_outgoing", py_pjsua_acc_find_for_outgoing, METH_VARARGS,5782 pjsua_acc_find_for_outgoing_doc5783 },5784 {5785 "acc_find_for_incoming", py_pjsua_acc_find_for_incoming, METH_VARARGS,5786 pjsua_acc_find_for_incoming_doc5787 },5788 {5789 "acc_create_uac_contact", py_pjsua_acc_create_uac_contact, METH_VARARGS,5790 pjsua_acc_create_uac_contact_doc5791 },5792 {5793 "acc_create_uas_contact", py_pjsua_acc_create_uas_contact, METH_VARARGS,5794 pjsua_acc_create_uas_contact_doc5795 4106 }, 5796 4107 { … … 5815 4126 }, 5816 4127 { 4128 "buddy_find", py_pjsua_buddy_find, METH_VARARGS, 4129 "Find buddy with the specified URI" 4130 }, 4131 { 5817 4132 "buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS, 5818 4133 pjsua_buddy_get_info_doc … … 5825 4140 "buddy_del", py_pjsua_buddy_del, METH_VARARGS, 5826 4141 pjsua_buddy_del_doc 4142 }, 4143 { 4144 "buddy_set_user_data", py_pjsua_buddy_set_user_data, METH_VARARGS, 4145 "Associate user data to the buddy object" 4146 }, 4147 { 4148 "buddy_get_user_data", py_pjsua_buddy_get_user_data, METH_VARARGS, 4149 "Get buddy user data" 5827 4150 }, 5828 4151 { … … 5859 4182 }, 5860 4183 { 5861 "conf_add_port", py_pjsua_conf_add_port, METH_VARARGS,5862 pjsua_conf_add_port_doc5863 },5864 {5865 4184 "conf_remove_port", py_pjsua_conf_remove_port, METH_VARARGS, 5866 4185 pjsua_conf_remove_port_doc … … 5935 4254 "set_null_snd_dev", py_pjsua_set_null_snd_dev, METH_VARARGS, 5936 4255 pjsua_set_null_snd_dev_doc 5937 },5938 {5939 "set_no_snd_dev", py_pjsua_set_no_snd_dev, METH_VARARGS,5940 pjsua_set_no_snd_dev_doc5941 4256 }, 5942 4257 { … … 6095 4410 if (PyType_Ready(&PyTyp_pjsua_media_config) < 0) 6096 4411 return; 6097 PyTyp_pjsip_event.tp_new = PyType_GenericNew;6098 if (PyType_Ready(&PyTyp_pjsip_event) < 0)6099 return;6100 PyTyp_pjsip_rx_data.tp_new = PyType_GenericNew;6101 if (PyType_Ready(&PyTyp_pjsip_rx_data) < 0)6102 return;6103 PyTyp_pj_pool_t.tp_new = PyType_GenericNew;6104 if (PyType_Ready(&PyTyp_pj_pool_t) < 0)6105 return;6106 PyTyp_pjsip_endpoint.tp_new = PyType_GenericNew;6107 if (PyType_Ready(&PyTyp_pjsip_endpoint) < 0)6108 return;6109 PyTyp_pjmedia_endpt.tp_new = PyType_GenericNew;6110 if (PyType_Ready(&PyTyp_pjmedia_endpt) < 0)6111 return;6112 PyTyp_pj_pool_factory.tp_new = PyType_GenericNew;6113 if (PyType_Ready(&PyTyp_pj_pool_factory) < 0)6114 return;6115 4412 PyTyp_pjsip_cred_info.tp_new = PyType_GenericNew; 6116 4413 if (PyType_Ready(&PyTyp_pjsip_cred_info) < 0) … … 6152 4449 6153 4450 if (PyType_Ready(&PyTyp_pjsua_conf_port_info) < 0) 6154 return;6155 6156 PyTyp_pjmedia_port.tp_new = PyType_GenericNew;6157 if (PyType_Ready(&PyTyp_pjmedia_port) < 0)6158 4451 return; 6159 4452 … … 6175 4468 /* LIB CALL */ 6176 4469 6177 PyTyp_pj_time_val.tp_new = PyType_GenericNew;6178 if (PyType_Ready(&PyTyp_pj_time_val) < 0)6179 return;6180 6181 4470 if (PyType_Ready(&PyTyp_pjsua_call_info) < 0) 6182 4471 return; … … 6185 4474 6186 4475 m = Py_InitModule3( 6187 "_pjsua", py_pjsua_methods, "PJSUA-lib module for python"4476 "_pjsua", py_pjsua_methods, "PJSUA-lib module for python" 6188 4477 ); 6189 4478 … … 6202 4491 Py_INCREF(&PyTyp_pjsua_msg_data); 6203 4492 PyModule_AddObject(m, "Msg_Data", (PyObject *)&PyTyp_pjsua_msg_data); 6204 6205 Py_INCREF(&PyTyp_pjsip_event);6206 PyModule_AddObject(m, "Pjsip_Event", (PyObject *)&PyTyp_pjsip_event);6207 6208 Py_INCREF(&PyTyp_pjsip_rx_data);6209 PyModule_AddObject(m, "Pjsip_Rx_Data", (PyObject *)&PyTyp_pjsip_rx_data);6210 6211 Py_INCREF(&PyTyp_pj_pool_t);6212 PyModule_AddObject(m, "Pj_Pool", (PyObject *)&PyTyp_pj_pool_t);6213 6214 Py_INCREF(&PyTyp_pjsip_endpoint);6215 PyModule_AddObject(m, "Pjsip_Endpoint", (PyObject *)&PyTyp_pjsip_endpoint);6216 6217 Py_INCREF(&PyTyp_pjmedia_endpt);6218 PyModule_AddObject(m, "Pjmedia_Endpt", (PyObject *)&PyTyp_pjmedia_endpt);6219 6220 Py_INCREF(&PyTyp_pj_pool_factory);6221 PyModule_AddObject(6222 m, "Pj_Pool_Factory", (PyObject *)&PyTyp_pj_pool_factory6223 );6224 4493 6225 4494 Py_INCREF(&PyTyp_pjsip_cred_info); … … 6265 4534 Py_INCREF(&PyTyp_pjsua_conf_port_info); 6266 4535 PyModule_AddObject(m, "Conf_Port_Info", (PyObject *)&PyTyp_pjsua_conf_port_info); 6267 Py_INCREF(&PyTyp_pjmedia_port);6268 PyModule_AddObject(m, "PJMedia_Port", (PyObject *)&PyTyp_pjmedia_port);6269 4536 Py_INCREF(&PyTyp_pjmedia_snd_dev_info); 6270 4537 PyModule_AddObject(m, "PJMedia_Snd_Dev_Info", … … 6284 4551 /* LIB CALL */ 6285 4552 6286 Py_INCREF(&PyTyp_pj_time_val);6287 PyModule_AddObject(m, "PJ_Time_Val", (PyObject *)&PyTyp_pj_time_val);6288 6289 4553 Py_INCREF(&PyTyp_pjsua_call_info); 6290 4554 PyModule_AddObject(m, "Call_Info", (PyObject *)&PyTyp_pjsua_call_info); … … 6296 4560 * Add various constants. 6297 4561 */ 6298 6299 /* Call states */ 6300 ADD_CONSTANT(m, PJSIP_INV_STATE_NULL); 6301 ADD_CONSTANT(m, PJSIP_INV_STATE_CALLING); 6302 ADD_CONSTANT(m, PJSIP_INV_STATE_INCOMING); 6303 ADD_CONSTANT(m, PJSIP_INV_STATE_EARLY); 6304 ADD_CONSTANT(m, PJSIP_INV_STATE_CONNECTING); 6305 ADD_CONSTANT(m, PJSIP_INV_STATE_CONFIRMED); 6306 ADD_CONSTANT(m, PJSIP_INV_STATE_DISCONNECTED); 6307 6308 /* Call media status (enum pjsua_call_media_status) */ 6309 ADD_CONSTANT(m, PJSUA_CALL_MEDIA_NONE); 6310 ADD_CONSTANT(m, PJSUA_CALL_MEDIA_ACTIVE); 6311 ADD_CONSTANT(m, PJSUA_CALL_MEDIA_LOCAL_HOLD); 6312 ADD_CONSTANT(m, PJSUA_CALL_MEDIA_REMOTE_HOLD); 6313 6314 /* Buddy status */ 6315 ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_UNKNOWN); 6316 ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_ONLINE); 6317 ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_OFFLINE); 6318 6319 /* PJSIP transport types (enum pjsip_transport_type_e) */ 6320 ADD_CONSTANT(m, PJSIP_TRANSPORT_UNSPECIFIED); 6321 ADD_CONSTANT(m, PJSIP_TRANSPORT_UDP); 6322 ADD_CONSTANT(m, PJSIP_TRANSPORT_TCP); 6323 ADD_CONSTANT(m, PJSIP_TRANSPORT_TLS); 6324 ADD_CONSTANT(m, PJSIP_TRANSPORT_SCTP); 6325 ADD_CONSTANT(m, PJSIP_TRANSPORT_LOOP); 6326 ADD_CONSTANT(m, PJSIP_TRANSPORT_LOOP_DGRAM); 6327 6328 6329 /* Invalid IDs */ 6330 ADD_CONSTANT(m, PJSUA_INVALID_ID); 6331 6332 6333 /* Various compile time constants */ 6334 ADD_CONSTANT(m, PJSUA_ACC_MAX_PROXIES); 6335 ADD_CONSTANT(m, PJSUA_MAX_ACC); 6336 ADD_CONSTANT(m, PJSUA_REG_INTERVAL); 6337 ADD_CONSTANT(m, PJSUA_PUBLISH_EXPIRATION); 6338 ADD_CONSTANT(m, PJSUA_DEFAULT_ACC_PRIORITY); 6339 ADD_CONSTANT(m, PJSUA_MAX_BUDDIES); 6340 ADD_CONSTANT(m, PJSUA_MAX_CONF_PORTS); 6341 ADD_CONSTANT(m, PJSUA_DEFAULT_CLOCK_RATE); 6342 ADD_CONSTANT(m, PJSUA_DEFAULT_CODEC_QUALITY); 6343 ADD_CONSTANT(m, PJSUA_DEFAULT_ILBC_MODE); 6344 ADD_CONSTANT(m, PJSUA_DEFAULT_EC_TAIL_LEN); 6345 ADD_CONSTANT(m, PJSUA_MAX_CALLS); 6346 ADD_CONSTANT(m, PJSUA_XFER_NO_REQUIRE_REPLACES); 6347 4562 /* Skip it.. */ 6348 4563 6349 4564 #undef ADD_CONSTANT
Note: See TracChangeset
for help on using the changeset viewer.