| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "_pjsua.h" |
| 20 |
|
| 21 |
#define THIS_FILE "main.c" |
| 22 |
#define POOL_SIZE 512 |
| 23 |
#define SND_DEV_NUM 64 |
| 24 |
#define SND_NAME_LEN 64 |
| 25 |
|
| 26 |
|
| 27 |
|
| 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 |
|
| 38 |
|
| 39 |
static PyObj_pjsua_callback * g_obj_callback; |
| 40 |
|
| 41 |
|
| 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 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
static void cb_log_cb(int level, const char *data, int len) |
| 68 |
{ |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
if (pj_thread_local_get(g_thread_id) == 0) |
| 74 |
return; |
| 75 |
|
| 76 |
if (PyCallable_Check(g_obj_log_cb)) { |
| 77 |
PyObject *param_data; |
| 78 |
|
| 79 |
ENTER_PYTHON(); |
| 80 |
|
| 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 |
| 90 |
); |
| 91 |
|
| 92 |
Py_DECREF(param_data); |
| 93 |
|
| 94 |
LEAVE_PYTHON(); |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
static void cb_on_call_state(pjsua_call_id call_id, pjsip_event *e) |
| 103 |
{ |
| 104 |
PJ_UNUSED_ARG(e); |
| 105 |
|
| 106 |
if (PyCallable_Check(g_obj_callback->on_call_state)) { |
| 107 |
PyObject * obj; |
| 108 |
|
| 109 |
ENTER_PYTHON(); |
| 110 |
|
| 111 |
obj = Py_BuildValue(""); |
| 112 |
|
| 113 |
PyObject_CallFunction( |
| 114 |
g_obj_callback->on_call_state, |
| 115 |
"iO", |
| 116 |
call_id, |
| 117 |
obj, |
| 118 |
NULL |
| 119 |
); |
| 120 |
|
| 121 |
Py_DECREF(obj); |
| 122 |
|
| 123 |
LEAVE_PYTHON(); |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
static void cb_on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, |
| 133 |
pjsip_rx_data *rdata) |
| 134 |
{ |
| 135 |
if (PyCallable_Check(g_obj_callback->on_incoming_call)) { |
| 136 |
PyObj_pjsip_rx_data *obj; |
| 137 |
|
| 138 |
ENTER_PYTHON(); |
| 139 |
|
| 140 |
obj = (PyObj_pjsip_rx_data*) |
| 141 |
PyObj_pjsip_rx_data_new(&PyTyp_pjsip_rx_data, |
| 142 |
NULL, NULL); |
| 143 |
PyObj_pjsip_rx_data_import(obj, rdata); |
| 144 |
|
| 145 |
PyObject_CallFunction( |
| 146 |
g_obj_callback->on_incoming_call, |
| 147 |
"iiO", |
| 148 |
acc_id, |
| 149 |
call_id, |
| 150 |
obj, |
| 151 |
NULL |
| 152 |
); |
| 153 |
|
| 154 |
Py_DECREF(obj); |
| 155 |
|
| 156 |
LEAVE_PYTHON(); |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
static void cb_on_call_media_state(pjsua_call_id call_id) |
| 166 |
{ |
| 167 |
if (PyCallable_Check(g_obj_callback->on_call_media_state)) { |
| 168 |
|
| 169 |
ENTER_PYTHON(); |
| 170 |
|
| 171 |
PyObject_CallFunction( |
| 172 |
g_obj_callback->on_call_media_state, |
| 173 |
"i", |
| 174 |
call_id, |
| 175 |
NULL |
| 176 |
); |
| 177 |
|
| 178 |
LEAVE_PYTHON(); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
static void cb_on_dtmf_digit(pjsua_call_id call_id, int digit) |
| 188 |
{ |
| 189 |
if (PyCallable_Check(g_obj_callback->on_dtmf_digit)) { |
| 190 |
char digit_str[10]; |
| 191 |
|
| 192 |
PyGILState_STATE state = PyGILState_Ensure(); |
| 193 |
|
| 194 |
pj_ansi_snprintf(digit_str, sizeof(digit_str), "%c", digit); |
| 195 |
|
| 196 |
PyObject_CallFunction( |
| 197 |
g_obj_callback->on_dtmf_digit, |
| 198 |
"is", |
| 199 |
call_id, |
| 200 |
digit_str, |
| 201 |
NULL |
| 202 |
); |
| 203 |
|
| 204 |
PyGILState_Release(state); |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
static void cb_on_call_transfer_request(pjsua_call_id call_id, |
| 214 |
const pj_str_t *dst, |
| 215 |
pjsip_status_code *code) |
| 216 |
{ |
| 217 |
if (PyCallable_Check(g_obj_callback->on_call_transfer_request)) { |
| 218 |
PyObject *ret, *param_dst; |
| 219 |
int cd; |
| 220 |
|
| 221 |
ENTER_PYTHON(); |
| 222 |
|
| 223 |
param_dst = PyString_FromPJ(dst); |
| 224 |
|
| 225 |
ret = PyObject_CallFunction( |
| 226 |
g_obj_callback->on_call_transfer_request, |
| 227 |
"iOi", |
| 228 |
call_id, |
| 229 |
param_dst, |
| 230 |
*code, |
| 231 |
NULL |
| 232 |
); |
| 233 |
|
| 234 |
Py_DECREF(param_dst); |
| 235 |
|
| 236 |
if (ret != NULL) { |
| 237 |
if (ret != Py_None) { |
| 238 |
if (PyArg_Parse(ret,"i",&cd)) { |
| 239 |
*code = cd; |
| 240 |
} |
| 241 |
} |
| 242 |
Py_DECREF(ret); |
| 243 |
} |
| 244 |
|
| 245 |
LEAVE_PYTHON(); |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
static void cb_on_call_transfer_status( pjsua_call_id call_id, |
| 258 |
int status_code, |
| 259 |
const pj_str_t *status_text, |
| 260 |
pj_bool_t final, |
| 261 |
pj_bool_t *p_cont) |
| 262 |
{ |
| 263 |
if (PyCallable_Check(g_obj_callback->on_call_transfer_status)) { |
| 264 |
PyObject *ret, *param_reason; |
| 265 |
|
| 266 |
ENTER_PYTHON(); |
| 267 |
|
| 268 |
param_reason = PyString_FromPJ(status_text); |
| 269 |
|
| 270 |
ret = PyObject_CallFunction( |
| 271 |
g_obj_callback->on_call_transfer_status, |
| 272 |
"iiOii", |
| 273 |
call_id, |
| 274 |
status_code, |
| 275 |
param_reason, |
| 276 |
final, |
| 277 |
*p_cont, |
| 278 |
NULL |
| 279 |
); |
| 280 |
|
| 281 |
Py_DECREF(param_reason); |
| 282 |
|
| 283 |
if (ret != NULL) { |
| 284 |
if (ret != Py_None) { |
| 285 |
int cnt; |
| 286 |
if (PyArg_Parse(ret,"i",&cnt)) { |
| 287 |
*p_cont = cnt; |
| 288 |
} |
| 289 |
} |
| 290 |
Py_DECREF(ret); |
| 291 |
} |
| 292 |
|
| 293 |
LEAVE_PYTHON(); |
| 294 |
} |
| 295 |
} |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
static void cb_on_call_replace_request( pjsua_call_id call_id, |
| 304 |
pjsip_rx_data *rdata, |
| 305 |
int *st_code, |
| 306 |
pj_str_t *st_text) |
| 307 |
{ |
| 308 |
PJ_UNUSED_ARG(rdata); |
| 309 |
|
| 310 |
if (PyCallable_Check(g_obj_callback->on_call_replace_request)) { |
| 311 |
PyObject *ret, *param_reason, *param_rdata; |
| 312 |
int cd; |
| 313 |
|
| 314 |
ENTER_PYTHON(); |
| 315 |
|
| 316 |
param_reason = PyString_FromPJ(st_text); |
| 317 |
param_rdata = Py_BuildValue(""); |
| 318 |
|
| 319 |
ret = PyObject_CallFunction( |
| 320 |
g_obj_callback->on_call_replace_request, |
| 321 |
"iOiO", |
| 322 |
call_id, |
| 323 |
param_rdata, |
| 324 |
*st_code, |
| 325 |
param_reason, |
| 326 |
NULL |
| 327 |
); |
| 328 |
|
| 329 |
Py_DECREF(param_rdata); |
| 330 |
Py_DECREF(param_reason); |
| 331 |
|
| 332 |
if (ret != NULL) { |
| 333 |
if (ret != Py_None) { |
| 334 |
PyObject * txt; |
| 335 |
if (PyArg_ParseTuple(ret,"iO",&cd, &txt)) { |
| 336 |
*st_code = cd; |
| 337 |
*st_text = PyString_ToPJ(txt); |
| 338 |
} |
| 339 |
} |
| 340 |
Py_DECREF(ret); |
| 341 |
} |
| 342 |
|
| 343 |
LEAVE_PYTHON(); |
| 344 |
} |
| 345 |
} |
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
static void cb_on_call_replaced(pjsua_call_id old_call_id, |
| 354 |
pjsua_call_id new_call_id) |
| 355 |
{ |
| 356 |
if (PyCallable_Check(g_obj_callback->on_call_replaced)) { |
| 357 |
ENTER_PYTHON(); |
| 358 |
|
| 359 |
PyObject_CallFunction( |
| 360 |
g_obj_callback->on_call_replaced, |
| 361 |
"ii", |
| 362 |
old_call_id, |
| 363 |
new_call_id, |
| 364 |
NULL |
| 365 |
); |
| 366 |
|
| 367 |
LEAVE_PYTHON(); |
| 368 |
} |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
static void cb_on_reg_state(pjsua_acc_id acc_id) |
| 377 |
{ |
| 378 |
if (PyCallable_Check(g_obj_callback->on_reg_state)) { |
| 379 |
ENTER_PYTHON(); |
| 380 |
|
| 381 |
PyObject_CallFunction( |
| 382 |
g_obj_callback->on_reg_state, |
| 383 |
"i", |
| 384 |
acc_id, |
| 385 |
NULL |
| 386 |
); |
| 387 |
|
| 388 |
LEAVE_PYTHON(); |
| 389 |
} |
| 390 |
} |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
static void cb_on_incoming_subscribe( pjsua_acc_id acc_id, |
| 396 |
pjsua_srv_pres *srv_pres, |
| 397 |
pjsua_buddy_id buddy_id, |
| 398 |
const pj_str_t *from, |
| 399 |
pjsip_rx_data *rdata, |
| 400 |
pjsip_status_code *code, |
| 401 |
pj_str_t *reason, |
| 402 |
pjsua_msg_data *msg_data) |
| 403 |
{ |
| 404 |
static char reason_buf[64]; |
| 405 |
|
| 406 |
PJ_UNUSED_ARG(rdata); |
| 407 |
PJ_UNUSED_ARG(msg_data); |
| 408 |
|
| 409 |
if (PyCallable_Check(g_obj_callback->on_incoming_subscribe)) { |
| 410 |
PyObject *ret, *param_from, *param_contact, *param_srv_pres; |
| 411 |
pjsip_contact_hdr *contact_hdr; |
| 412 |
pj_pool_t *pool = NULL; |
| 413 |
|
| 414 |
ENTER_PYTHON(); |
| 415 |
|
| 416 |
param_from = PyString_FromPJ(from); |
| 417 |
param_srv_pres = PyLong_FromLong((long)srv_pres); |
| 418 |
|
| 419 |
contact_hdr = (pjsip_contact_hdr*) |
| 420 |
pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, |
| 421 |
NULL); |
| 422 |
if (contact_hdr) { |
| 423 |
char *contact; |
| 424 |
int len; |
| 425 |
|
| 426 |
pool = pjsua_pool_create("pytmp", 512, 512); |
| 427 |
contact = (char*) pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE+1); |
| 428 |
len = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, contact_hdr->uri, |
| 429 |
contact, PJSIP_MAX_URL_SIZE); |
| 430 |
if (len < 1) |
| 431 |
len = 0; |
| 432 |
contact[len] = '\0'; |
| 433 |
|
| 434 |
param_contact = PyString_FromStringAndSize(contact, len); |
| 435 |
} else { |
| 436 |
param_contact = Py_BuildValue(""); |
| 437 |
} |
| 438 |
|
| 439 |
ret = PyObject_CallFunction( |
| 440 |
g_obj_callback->on_incoming_subscribe, |
| 441 |
"iiOOO", |
| 442 |
acc_id, |
| 443 |
buddy_id, |
| 444 |
param_from, |
| 445 |
param_contact, |
| 446 |
param_srv_pres, |
| 447 |
NULL |
| 448 |
); |
| 449 |
|
| 450 |
if (pool) |
| 451 |
pj_pool_release(pool); |
| 452 |
|
| 453 |
Py_DECREF(param_from); |
| 454 |
Py_DECREF(param_contact); |
| 455 |
Py_DECREF(param_srv_pres); |
| 456 |
|
| 457 |
if (ret && PyTuple_Check(ret)) { |
| 458 |
if (PyTuple_Size(ret) >= 1) |
| 459 |
*code = (int)PyInt_AsLong(PyTuple_GetItem(ret, 0)); |
| 460 |
if (PyTuple_Size(ret) >= 2) { |
| 461 |
if (PyTuple_GetItem(ret, 1) != Py_None) { |
| 462 |
pj_str_t tmp; |
| 463 |
tmp = PyString_ToPJ(PyTuple_GetItem(ret, 1)); |
| 464 |
reason->ptr = reason_buf; |
| 465 |
pj_strncpy(reason, &tmp, sizeof(reason_buf)); |
| 466 |
} else { |
| 467 |
reason->slen = 0; |
| 468 |
} |
| 469 |
} |
| 470 |
Py_XDECREF(ret); |
| 471 |
} else if (ret) { |
| 472 |
Py_XDECREF(ret); |
| 473 |
} |
| 474 |
|
| 475 |
LEAVE_PYTHON(); |
| 476 |
} |
| 477 |
} |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
static void cb_on_buddy_state(pjsua_buddy_id buddy_id) |
| 484 |
{ |
| 485 |
if (PyCallable_Check(g_obj_callback->on_buddy_state)) { |
| 486 |
ENTER_PYTHON(); |
| 487 |
|
| 488 |
PyObject_CallFunction( |
| 489 |
g_obj_callback->on_buddy_state, |
| 490 |
"i", |
| 491 |
buddy_id, |
| 492 |
NULL |
| 493 |
); |
| 494 |
|
| 495 |
LEAVE_PYTHON(); |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
static void cb_on_pager(pjsua_call_id call_id, const pj_str_t *from, |
| 504 |
const pj_str_t *to, const pj_str_t *contact, |
| 505 |
const pj_str_t *mime_type, const pj_str_t *body, |
| 506 |
pjsip_rx_data *rdata, pjsua_acc_id acc_id) |
| 507 |
{ |
| 508 |
PJ_UNUSED_ARG(rdata); |
| 509 |
|
| 510 |
if (PyCallable_Check(g_obj_callback->on_pager)) { |
| 511 |
PyObject *param_from, *param_to, *param_contact, *param_mime_type, |
| 512 |
*param_body; |
| 513 |
|
| 514 |
ENTER_PYTHON(); |
| 515 |
|
| 516 |
param_from = PyString_FromPJ(from); |
| 517 |
param_to = PyString_FromPJ(to); |
| 518 |
param_contact = PyString_FromPJ(contact); |
| 519 |
param_mime_type = PyString_FromPJ(mime_type); |
| 520 |
param_body = PyString_FromPJ(body); |
| 521 |
|
| 522 |
PyObject_CallFunction( |
| 523 |
g_obj_callback->on_pager, |
| 524 |
"iOOOOOi", |
| 525 |
call_id, |
| 526 |
param_from, |
| 527 |
param_to, |
| 528 |
param_contact, |
| 529 |
param_mime_type, |
| 530 |
param_body, |
| 531 |
acc_id, |
| 532 |
NULL |
| 533 |
); |
| 534 |
|
| 535 |
Py_DECREF(param_body); |
| 536 |
Py_DECREF(param_mime_type); |
| 537 |
Py_DECREF(param_contact); |
| 538 |
Py_DECREF(param_to); |
| 539 |
Py_DECREF(param_from); |
| 540 |
|
| 541 |
LEAVE_PYTHON(); |
| 542 |
} |
| 543 |
} |
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
static void cb_on_pager_status(pjsua_call_id call_id, const pj_str_t *to, |
| 551 |
const pj_str_t *body, void *user_data, |
| 552 |
pjsip_status_code status, |
| 553 |
const pj_str_t *reason, |
| 554 |
pjsip_tx_data *tdata, |
| 555 |
pjsip_rx_data *rdata, |
| 556 |
pjsua_acc_id acc_id) |
| 557 |
{ |
| 558 |
if (PyCallable_Check(g_obj_callback->on_pager)) { |
| 559 |
PyObject *param_call_id, *param_to, *param_body, |
| 560 |
*param_user_data, *param_status, *param_reason, |
| 561 |
*param_acc_id; |
| 562 |
|
| 563 |
ENTER_PYTHON(); |
| 564 |
|
| 565 |
PJ_UNUSED_ARG(tdata); |
| 566 |
PJ_UNUSED_ARG(rdata); |
| 567 |
|
| 568 |
PyObject_CallFunctionObjArgs( |
| 569 |
g_obj_callback->on_pager_status, |
| 570 |
param_call_id = Py_BuildValue("i",call_id), |
| 571 |
param_to = PyString_FromPJ(to), |
| 572 |
param_body = PyString_FromPJ(body), |
| 573 |
param_user_data = Py_BuildValue("i", user_data), |
| 574 |
param_status = Py_BuildValue("i",status), |
| 575 |
param_reason = PyString_FromPJ(reason), |
| 576 |
param_acc_id = Py_BuildValue("i",acc_id), |
| 577 |
NULL |
| 578 |
); |
| 579 |
|
| 580 |
Py_DECREF(param_call_id); |
| 581 |
Py_DECREF(param_to); |
| 582 |
Py_DECREF(param_body); |
| 583 |
Py_DECREF(param_user_data); |
| 584 |
Py_DECREF(param_status); |
| 585 |
Py_DECREF(param_reason); |
| 586 |
Py_DECREF(param_acc_id); |
| 587 |
|
| 588 |
LEAVE_PYTHON(); |
| 589 |
} |
| 590 |
} |
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
static void cb_on_typing(pjsua_call_id call_id, const pj_str_t *from, |
| 598 |
const pj_str_t *to, const pj_str_t *contact, |
| 599 |
pj_bool_t is_typing, pjsip_rx_data *rdata, |
| 600 |
pjsua_acc_id acc_id) |
| 601 |
{ |
| 602 |
if (PyCallable_Check(g_obj_callback->on_typing)) { |
| 603 |
PyObject *param_call_id, *param_from, *param_to, *param_contact, |
| 604 |
*param_is_typing, *param_acc_id; |
| 605 |
|
| 606 |
ENTER_PYTHON(); |
| 607 |
|
| 608 |
PJ_UNUSED_ARG(rdata); |
| 609 |
|
| 610 |
PyObject_CallFunctionObjArgs( |
| 611 |
g_obj_callback->on_typing, |
| 612 |
param_call_id = Py_BuildValue("i",call_id), |
| 613 |
param_from = PyString_FromPJ(from), |
| 614 |
param_to = PyString_FromPJ(to), |
| 615 |
param_contact = PyString_FromPJ(contact), |
| 616 |
param_is_typing = Py_BuildValue("i",is_typing), |
| 617 |
param_acc_id = Py_BuildValue("i",acc_id), |
| 618 |
NULL |
| 619 |
); |
| 620 |
|
| 621 |
Py_DECREF(param_call_id); |
| 622 |
Py_DECREF(param_from); |
| 623 |
Py_DECREF(param_to); |
| 624 |
Py_DECREF(param_contact); |
| 625 |
Py_DECREF(param_is_typing); |
| 626 |
Py_DECREF(param_acc_id); |
| 627 |
|
| 628 |
LEAVE_PYTHON(); |
| 629 |
} |
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
static void cb_on_mwi_info(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info) |
| 637 |
{ |
| 638 |
if (PyCallable_Check(g_obj_callback->on_mwi_info)) { |
| 639 |
PyObject *param_acc_id, *param_body; |
| 640 |
pj_str_t body; |
| 641 |
|
| 642 |
ENTER_PYTHON(); |
| 643 |
|
| 644 |
body.ptr = mwi_info->rdata->msg_info.msg->body->data; |
| 645 |
body.slen = mwi_info->rdata->msg_info.msg->body->len; |
| 646 |
|
| 647 |
PyObject_CallFunctionObjArgs( |
| 648 |
g_obj_callback->on_mwi_info, |
| 649 |
param_acc_id = Py_BuildValue("i",acc_id), |
| 650 |
param_body = PyString_FromPJ(&body), |
| 651 |
NULL |
| 652 |
); |
| 653 |
|
| 654 |
Py_DECREF(param_acc_id); |
| 655 |
Py_DECREF(param_body); |
| 656 |
|
| 657 |
LEAVE_PYTHON(); |
| 658 |
} |
| 659 |
} |
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
void translate_hdr(pj_pool_t *pool, pjsip_hdr *hdr, PyObject *py_hdr_list) |
| 667 |
{ |
| 668 |
pj_list_init(hdr); |
| 669 |
|
| 670 |
if (PyList_Check(py_hdr_list)) { |
| 671 |
int i; |
| 672 |
|
| 673 |
for (i=0; i<PyList_Size(py_hdr_list); ++i) { |
| 674 |
pj_str_t hname, hvalue; |
| 675 |
pjsip_generic_string_hdr * new_hdr; |
| 676 |
PyObject * tuple = PyList_GetItem(py_hdr_list, i); |
| 677 |
|
| 678 |
if (PyTuple_Check(tuple)) { |
| 679 |
if (PyTuple_Size(tuple) >= 1) |
| 680 |
hname = PyString_ToPJ(PyTuple_GetItem(tuple,0)); |
| 681 |
else |
| 682 |
hname.slen = 0; |
| 683 |
if (PyTuple_Size(tuple) >= 2) |
| 684 |
hvalue = PyString_ToPJ(PyTuple_GetItem(tuple,1)); |
| 685 |
else |
| 686 |
hvalue.slen = 0; |
| 687 |
} else { |
| 688 |
hname.ptr = ""; |
| 689 |
hname.slen = 0; |
| 690 |
hvalue.ptr = ""; |
| 691 |
hvalue.slen = 0; |
| 692 |
} |
| 693 |
new_hdr = pjsip_generic_string_hdr_create(pool, &hname, &hvalue); |
| 694 |
pj_list_push_back((pj_list_type *)hdr, (pj_list_type *)new_hdr); |
| 695 |
} |
| 696 |
} |
| 697 |
} |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
static PyObject *py_pjsua_thread_register(PyObject *pSelf, PyObject *pArgs) |
| 703 |
{ |
| 704 |
pj_status_t status; |
| 705 |
const char *name; |
| 706 |
PyObject *py_desc; |
| 707 |
pj_thread_t *thread; |
| 708 |
struct py_thread_desc *thread_desc; |
| 709 |
|
| 710 |
PJ_UNUSED_ARG(pSelf); |
| 711 |
|
| 712 |
if (!PyArg_ParseTuple(pArgs, "sO", &name, &py_desc)) { |
| 713 |
return NULL; |
| 714 |
} |
| 715 |
thread_desc = (struct py_thread_desc*) |
| 716 |
malloc(sizeof(struct py_thread_desc)); |
| 717 |
thread_desc->next = py_thread_desc; |
| 718 |
py_thread_desc = thread_desc; |
| 719 |
|
| 720 |
status = pj_thread_register(name, thread_desc->desc, &thread); |
| 721 |
|
| 722 |
if (status == PJ_SUCCESS) |
| 723 |
status = pj_thread_local_set(g_thread_id, (void*)1); |
| 724 |
|
| 725 |
return Py_BuildValue("i",status); |
| 726 |
} |
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
static PyObject *py_pjsua_logging_config_default(PyObject *pSelf, |
| 732 |
PyObject *pArgs) |
| 733 |
{ |
| 734 |
PyObj_pjsua_logging_config *obj; |
| 735 |
pjsua_logging_config cfg; |
| 736 |
|
| 737 |
PJ_UNUSED_ARG(pSelf); |
| 738 |
PJ_UNUSED_ARG(pArgs); |
| 739 |
|
| 740 |
pjsua_logging_config_default(&cfg); |
| 741 |
obj = (PyObj_pjsua_logging_config*) |
| 742 |
PyObj_pjsua_logging_config_new(&PyTyp_pjsua_logging_config, |
| 743 |
NULL, NULL); |
| 744 |
PyObj_pjsua_logging_config_import(obj, &cfg); |
| 745 |
|
| 746 |
return (PyObject*)obj; |
| 747 |
} |
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
static PyObject *py_pjsua_config_default(PyObject *pSelf, PyObject *pArgs) |
| 754 |
{ |
| 755 |
PyObj_pjsua_config *obj; |
| 756 |
pjsua_config cfg; |
| 757 |
|
| 758 |
PJ_UNUSED_ARG(pSelf); |
| 759 |
PJ_UNUSED_ARG(pArgs); |
| 760 |
|
| 761 |
pjsua_config_default(&cfg); |
| 762 |
obj = (PyObj_pjsua_config *) PyObj_pjsua_config_new(&PyTyp_pjsua_config, |
| 763 |
NULL, NULL); |
| 764 |
PyObj_pjsua_config_import(obj, &cfg); |
| 765 |
|
| 766 |
return (PyObject*)obj; |
| 767 |
} |
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
static PyObject * py_pjsua_media_config_default(PyObject *pSelf, |
| 774 |
PyObject *pArgs) |
| 775 |
{ |
| 776 |
PyObj_pjsua_media_config *obj; |
| 777 |
pjsua_media_config cfg; |
| 778 |
|
| 779 |
PJ_UNUSED_ARG(pSelf); |
| 780 |
PJ_UNUSED_ARG(pArgs); |
| 781 |
|
| 782 |
pjsua_media_config_default(&cfg); |
| 783 |
obj = (PyObj_pjsua_media_config *) |
| 784 |
PyType_GenericNew(&PyTyp_pjsua_media_config, NULL, NULL); |
| 785 |
PyObj_pjsua_media_config_import(obj, &cfg); |
| 786 |
|
| 787 |
return (PyObject *)obj; |
| 788 |
} |
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
static PyObject *py_pjsua_msg_data_init(PyObject *pSelf, PyObject *pArgs) |
| 795 |
{ |
| 796 |
PJ_UNUSED_ARG(pSelf); |
| 797 |
PJ_UNUSED_ARG(pArgs); |
| 798 |
|
| 799 |
return (PyObject *)PyObj_pjsua_msg_data_new(&PyTyp_pjsua_msg_data, |
| 800 |
NULL, NULL); |
| 801 |
} |
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, |
| 808 |
PyObject *pArgs) |
| 809 |
{ |
| 810 |
PyObject *logObj; |
| 811 |
pj_status_t status; |
| 812 |
|
| 813 |
PJ_UNUSED_ARG(pSelf); |
| 814 |
|
| 815 |
if (!PyArg_ParseTuple(pArgs, "O", &logObj)) { |
| 816 |
return NULL; |
| 817 |
} |
| 818 |
|
| 819 |
if (logObj != Py_None) { |
| 820 |
PyObj_pjsua_logging_config *log; |
| 821 |
pjsua_logging_config cfg; |
| 822 |
|
| 823 |
log = (PyObj_pjsua_logging_config*)logObj; |
| 824 |
cfg.msg_logging = log->msg_logging; |
| 825 |
cfg.level = log->level; |
| 826 |
cfg.console_level = log->console_level; |
| 827 |
cfg.decor = log->decor; |
| 828 |
cfg.log_filename = PyString_ToPJ(log->log_filename); |
| 829 |
Py_XDECREF(g_obj_log_cb); |
| 830 |
g_obj_log_cb = log->cb; |
| 831 |
Py_INCREF(g_obj_log_cb); |
| 832 |
cfg.cb = &cb_log_cb; |
| 833 |
status = pjsua_reconfigure_logging(&cfg); |
| 834 |
} else { |
| 835 |
status = pjsua_reconfigure_logging(NULL); |
| 836 |
} |
| 837 |
|
| 838 |
return Py_BuildValue("i",status); |
| 839 |
} |
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
static PyObject *py_pjsua_perror(PyObject *pSelf, PyObject *pArgs) |
| 846 |
{ |
| 847 |
const char *sender; |
| 848 |
const char *title; |
| 849 |
pj_status_t status; |
| 850 |
|
| 851 |
PJ_UNUSED_ARG(pSelf); |
| 852 |
|
| 853 |
if (!PyArg_ParseTuple(pArgs, "ssi", &sender, &title, &status)) { |
| 854 |
return NULL; |
| 855 |
} |
| 856 |
|
| 857 |
pjsua_perror(sender, title, status); |
| 858 |
|
| 859 |
return Py_BuildValue(""); |
| 860 |
} |
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
static PyObject *py_pjsua_create(PyObject *pSelf, PyObject *pArgs) |
| 867 |
{ |
| 868 |
pj_status_t status; |
| 869 |
|
| 870 |
PJ_UNUSED_ARG(pSelf); |
| 871 |
PJ_UNUSED_ARG(pArgs); |
| 872 |
|
| 873 |
status = pjsua_create(); |
| 874 |
|
| 875 |
if (status == PJ_SUCCESS) { |
| 876 |
status = pj_thread_local_alloc(&g_thread_id); |
| 877 |
if (status == PJ_SUCCESS) |
| 878 |
status = pj_thread_local_set(g_thread_id, (void*)1); |
| 879 |
|
| 880 |
pj_atexit(&clear_py_thread_desc); |
| 881 |
} |
| 882 |
|
| 883 |
return Py_BuildValue("i",status); |
| 884 |
} |
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
static PyObject *py_pjsua_init(PyObject *pSelf, PyObject *pArgs) |
| 891 |
{ |
| 892 |
pj_status_t status; |
| 893 |
PyObject *o_ua_cfg, *o_log_cfg, *o_media_cfg; |
| 894 |
pjsua_config cfg_ua, *p_cfg_ua; |
| 895 |
pjsua_logging_config cfg_log, *p_cfg_log; |
| 896 |
pjsua_media_config cfg_media, *p_cfg_media; |
| 897 |
|
| 898 |
PJ_UNUSED_ARG(pSelf); |
| 899 |
|
| 900 |
if (!PyArg_ParseTuple(pArgs, "OOO", &o_ua_cfg, &o_log_cfg, &o_media_cfg)) { |
| 901 |
return NULL; |
| 902 |
} |
| 903 |
|
| 904 |
pjsua_config_default(&cfg_ua); |
| 905 |
pjsua_logging_config_default(&cfg_log); |
| 906 |
pjsua_media_config_default(&cfg_media); |
| 907 |
|
| 908 |
if (o_ua_cfg != Py_None) { |
| 909 |
PyObj_pjsua_config *obj_ua_cfg = (PyObj_pjsua_config*)o_ua_cfg; |
| 910 |
|
| 911 |
PyObj_pjsua_config_export(&cfg_ua, obj_ua_cfg); |
| 912 |
|
| 913 |
Py_XDECREF(g_obj_callback); |
| 914 |
g_obj_callback = obj_ua_cfg->cb; |
| 915 |
Py_INCREF(g_obj_callback); |
| 916 |
|
| 917 |
cfg_ua.cb.on_call_state = &cb_on_call_state; |
| 918 |
cfg_ua.cb.on_incoming_call = &cb_on_incoming_call; |
| 919 |
cfg_ua.cb.on_call_media_state = &cb_on_call_media_state; |
| 920 |
cfg_ua.cb.on_dtmf_digit = &cb_on_dtmf_digit; |
| 921 |
cfg_ua.cb.on_call_transfer_request = &cb_on_call_transfer_request; |
| 922 |
cfg_ua.cb.on_call_transfer_status = &cb_on_call_transfer_status; |
| 923 |
cfg_ua.cb.on_call_replace_request = &cb_on_call_replace_request; |
| 924 |
cfg_ua.cb.on_call_replaced = &cb_on_call_replaced; |
| 925 |
cfg_ua.cb.on_reg_state = &cb_on_reg_state; |
| 926 |
cfg_ua.cb.on_incoming_subscribe = &cb_on_incoming_subscribe; |
| 927 |
cfg_ua.cb.on_buddy_state = &cb_on_buddy_state; |
| 928 |
cfg_ua.cb.on_pager2 = &cb_on_pager; |
| 929 |
cfg_ua.cb.on_pager_status2 = &cb_on_pager_status; |
| 930 |
cfg_ua.cb.on_typing2 = &cb_on_typing; |
| 931 |
cfg_ua.cb.on_mwi_info = &cb_on_mwi_info; |
| 932 |
|
| 933 |
p_cfg_ua = &cfg_ua; |
| 934 |
|
| 935 |
} else { |
| 936 |
p_cfg_ua = NULL; |
| 937 |
} |
| 938 |
|
| 939 |
if (o_log_cfg != Py_None) { |
| 940 |
PyObj_pjsua_logging_config * obj_log; |
| 941 |
|
| 942 |
obj_log = (PyObj_pjsua_logging_config *)o_log_cfg; |
| 943 |
|
| 944 |
PyObj_pjsua_logging_config_export(&cfg_log, obj_log); |
| 945 |
|
| 946 |
Py_XDECREF(g_obj_log_cb); |
| 947 |
g_obj_log_cb = obj_log->cb; |
| 948 |
Py_INCREF(g_obj_log_cb); |
| 949 |
|
| 950 |
cfg_log.cb = &cb_log_cb; |
| 951 |
p_cfg_log = &cfg_log; |
| 952 |
|
| 953 |
} else { |
| 954 |
p_cfg_log = NULL; |
| 955 |
} |
| 956 |
|
| 957 |
if (o_media_cfg != Py_None) { |
| 958 |
PyObj_pjsua_media_config_export(&cfg_media, |
| 959 |
(PyObj_pjsua_media_config*)o_media_cfg); |
| 960 |
p_cfg_media = &cfg_media; |
| 961 |
|
| 962 |
} else { |
| 963 |
p_cfg_media = NULL; |
| 964 |
} |
| 965 |
|
| 966 |
status = pjsua_init(p_cfg_ua, p_cfg_log, p_cfg_media); |
| 967 |
|
| 968 |
return Py_BuildValue("i", status); |
| 969 |
} |
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
static PyObject *py_pjsua_start(PyObject *pSelf, PyObject *pArgs) |
| 976 |
{ |
| 977 |
pj_status_t status; |
| 978 |
|
| 979 |
PJ_UNUSED_ARG(pSelf); |
| 980 |
PJ_UNUSED_ARG(pArgs); |
| 981 |
|
| 982 |
status = pjsua_start(); |
| 983 |
|
| 984 |
return Py_BuildValue("i", status); |
| 985 |
} |
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
static PyObject *py_pjsua_destroy(PyObject *pSelf, PyObject *pArgs) |
| 992 |
{ |
| 993 |
pj_status_t status; |
| 994 |
|
| 995 |
PJ_UNUSED_ARG(pSelf); |
| 996 |
PJ_UNUSED_ARG(pArgs); |
| 997 |
|
| 998 |
status = pjsua_destroy(); |
| 999 |
|
| 1000 |
return Py_BuildValue("i", status); |
| 1001 |
} |
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
static PyObject *py_pjsua_handle_events(PyObject *pSelf, PyObject *pArgs) |
| 1008 |
{ |
| 1009 |
int ret; |
| 1010 |
int msec; |
| 1011 |
|
| 1012 |
PJ_UNUSED_ARG(pSelf); |
| 1013 |
|
| 1014 |
if (!PyArg_ParseTuple(pArgs, "i", &msec)) { |
| 1015 |
return NULL; |
| 1016 |
} |
| 1017 |
|
| 1018 |
if (msec < 0) |
| 1019 |
msec = 0; |
| 1020 |
|
| 1021 |
#if !NO_PJSIP_THREAD |
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
Py_BEGIN_ALLOW_THREADS |
| 1028 |
#endif |
| 1029 |
|
| 1030 |
ret = pjsua_handle_events(msec); |
| 1031 |
|
| 1032 |
#if !NO_PJSIP_THREAD |
| 1033 |
Py_END_ALLOW_THREADS |
| 1034 |
#endif |
| 1035 |
|
| 1036 |
return Py_BuildValue("i", ret); |
| 1037 |
} |
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
static PyObject *py_pjsua_verify_sip_url(PyObject *pSelf, PyObject *pArgs) |
| 1044 |
{ |
| 1045 |
pj_status_t status; |
| 1046 |
const char *url; |
| 1047 |
|
| 1048 |
PJ_UNUSED_ARG(pSelf); |
| 1049 |
|
| 1050 |
if (!PyArg_ParseTuple(pArgs, "s", &url)) { |
| 1051 |
return NULL; |
| 1052 |
} |
| 1053 |
|
| 1054 |
status = pjsua_verify_sip_url(url); |
| 1055 |
|
| 1056 |
return Py_BuildValue("i", status); |
| 1057 |
} |
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
static char pjsua_thread_register_doc[] = |
| 1065 |
"int _pjsua.thread_register(string name, int[] desc)"; |
| 1066 |
static char pjsua_perror_doc[] = |
| 1067 |
"void _pjsua.perror (string sender, string title, int status) " |
| 1068 |
"Display error message for the specified error code. Parameters: " |
| 1069 |
"sender: The log sender field; " |
| 1070 |
"title: Message title for the error; " |
| 1071 |
"status: Status code."; |
| 1072 |
|
| 1073 |
static char pjsua_create_doc[] = |
| 1074 |
"int _pjsua.create (void) " |
| 1075 |
"Instantiate pjsua application. Application " |
| 1076 |
"must call this function before calling any other functions, to make sure " |
| 1077 |
"that the underlying libraries are properly initialized. Once this " |
| 1078 |
"function has returned success, application must call pjsua_destroy() " |
| 1079 |
"before quitting."; |
| 1080 |
|
| 1081 |
static char pjsua_init_doc[] = |
| 1082 |
"int _pjsua.init (_pjsua.Config obj_ua_cfg, " |
| 1083 |
"_pjsua.Logging_Config log_cfg, _pjsua.Media_Config media_cfg) " |
| 1084 |
"Initialize pjsua with the specified settings. All the settings are " |
| 1085 |
"optional, and the default values will be used when the config is not " |
| 1086 |
"specified. Parameters: " |
| 1087 |
"obj_ua_cfg : User agent configuration; " |
| 1088 |
"log_cfg : Optional logging configuration; " |
| 1089 |
"media_cfg : Optional media configuration."; |
| 1090 |
|
| 1091 |
static char pjsua_start_doc[] = |
| 1092 |
"int _pjsua.start (void) " |
| 1093 |
"Application is recommended to call this function after all " |
| 1094 |
"initialization is done, so that the library can do additional checking " |
| 1095 |
"set up additional"; |
| 1096 |
|
| 1097 |
static char pjsua_destroy_doc[] = |
| 1098 |
"int _pjsua.destroy (void) " |
| 1099 |
"Destroy pjsua This function must be called once PJSUA is created. To " |
| 1100 |
"make it easier for application, application may call this function " |
| 1101 |
"several times with no danger."; |
| 1102 |
|
| 1103 |
static char pjsua_handle_events_doc[] = |
| 1104 |
"int _pjsua.handle_events (int msec_timeout) " |
| 1105 |
"Poll pjsua for events, and if necessary block the caller thread for the " |
| 1106 |
"specified maximum interval (in miliseconds) Parameters: " |
| 1107 |
"msec_timeout: Maximum time to wait, in miliseconds. " |
| 1108 |
"Returns: The number of events that have been handled during the poll. " |
| 1109 |
"Negative value indicates error, and application can retrieve the error " |
| 1110 |
"as (err = -return_value)."; |
| 1111 |
|
| 1112 |
static char pjsua_verify_sip_url_doc[] = |
| 1113 |
"int _pjsua.verify_sip_url (string c_url) " |
| 1114 |
"Verify that valid SIP url is given Parameters: " |
| 1115 |
"c_url: The URL, as NULL terminated string."; |
| 1116 |
|
| 1117 |
static char pjsua_reconfigure_logging_doc[] = |
| 1118 |
"int _pjsua.reconfigure_logging (_pjsua.Logging_Config c) " |
| 1119 |
"Application can call this function at any time (after pjsua_create(), of " |
| 1120 |
"course) to change logging settings. Parameters: " |
| 1121 |
"c: Logging configuration."; |
| 1122 |
|
| 1123 |
static char pjsua_logging_config_default_doc[] = |
| 1124 |
"_pjsua.Logging_Config _pjsua.logging_config_default () " |
| 1125 |
"Use this function to initialize logging config."; |
| 1126 |
|
| 1127 |
static char pjsua_config_default_doc[] = |
| 1128 |
"_pjsua.Config _pjsua.config_default (). Use this function to " |
| 1129 |
"initialize pjsua config. "; |
| 1130 |
|
| 1131 |
static char pjsua_media_config_default_doc[] = |
| 1132 |
"_pjsua.Media_Config _pjsua.media_config_default (). " |
| 1133 |
"Use this function to initialize media config."; |
| 1134 |
|
| 1135 |
static char pjsua_msg_data_init_doc[] = |
| 1136 |
"_pjsua.Msg_Data void _pjsua.msg_data_init () " |
| 1137 |
"Initialize message data "; |
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
static PyObject *py_pjsua_transport_config_default(PyObject *pSelf, |
| 1148 |
PyObject *pArgs) |
| 1149 |
{ |
| 1150 |
PyObj_pjsua_transport_config *obj; |
| 1151 |
pjsua_transport_config cfg; |
| 1152 |
|
| 1153 |
PJ_UNUSED_ARG(pSelf); |
| 1154 |
PJ_UNUSED_ARG(pArgs); |
| 1155 |
|
| 1156 |
pjsua_transport_config_default(&cfg); |
| 1157 |
obj = (PyObj_pjsua_transport_config*) |
| 1158 |
PyObj_pjsua_transport_config_new(&PyTyp_pjsua_transport_config, |
| 1159 |
NULL, NULL); |
| 1160 |
PyObj_pjsua_transport_config_import(obj, &cfg); |
| 1161 |
|
| 1162 |
return (PyObject *)obj; |
| 1163 |
} |
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
static PyObject *py_pjsua_transport_create(PyObject *pSelf, PyObject *pArgs) |
| 1169 |
{ |
| 1170 |
pj_status_t status; |
| 1171 |
int type; |
| 1172 |
PyObject *pCfg; |
| 1173 |
pjsua_transport_config cfg; |
| 1174 |
pjsua_transport_id id; |
| 1175 |
|
| 1176 |
PJ_UNUSED_ARG(pSelf); |
| 1177 |
|
| 1178 |
if (!PyArg_ParseTuple(pArgs, "iO", &type, &pCfg)) { |
| 1179 |
return NULL; |
| 1180 |
} |
| 1181 |
|
| 1182 |
if (pCfg != Py_None) { |
| 1183 |
PyObj_pjsua_transport_config *obj; |
| 1184 |
|
| 1185 |
obj = (PyObj_pjsua_transport_config*)pCfg; |
| 1186 |
PyObj_pjsua_transport_config_export(&cfg, obj); |
| 1187 |
status = pjsua_transport_create(type, &cfg, &id); |
| 1188 |
} else { |
| 1189 |
status = pjsua_transport_create(type, NULL, &id); |
| 1190 |
} |
| 1191 |
|
| 1192 |
|
| 1193 |
return Py_BuildValue("ii", status, id); |
| 1194 |
} |
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
static PyObject *py_pjsua_enum_transports(PyObject *pSelf, PyObject *pArgs) |
| 1200 |
{ |
| 1201 |
PyObject *list; |
| 1202 |
pjsua_transport_id id[PJSIP_MAX_TRANSPORTS]; |
| 1203 |
unsigned c, i; |
| 1204 |
|
| 1205 |
PJ_UNUSED_ARG(pSelf); |
| 1206 |
PJ_UNUSED_ARG(pArgs); |
| 1207 |
|
| 1208 |
c = PJ_ARRAY_SIZE(id); |
| 1209 |
pjsua_enum_transports(id, &c); |
| 1210 |
|
| 1211 |
list = PyList_New(c); |
| 1212 |
for (i = 0; i < c; i++) { |
| 1213 |
PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 1214 |
} |
| 1215 |
|
| 1216 |
return (PyObject*)list; |
| 1217 |
} |
| 1218 |
|
| 1219 |
|
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
static PyObject *py_pjsua_transport_get_info(PyObject *pSelf, PyObject *pArgs) |
| 1224 |
{ |
| 1225 |
pj_status_t status; |
| 1226 |
int id; |
| 1227 |
pjsua_transport_info info; |
| 1228 |
|
| 1229 |
PJ_UNUSED_ARG(pSelf); |
| 1230 |
|
| 1231 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 1232 |
return NULL; |
| 1233 |
} |
| 1234 |
|
| 1235 |
status = pjsua_transport_get_info(id, &info); |
| 1236 |
if (status == PJ_SUCCESS) { |
| 1237 |
PyObj_pjsua_transport_info *obj; |
| 1238 |
obj = (PyObj_pjsua_transport_info *) |
| 1239 |
PyObj_pjsua_transport_info_new(&PyTyp_pjsua_transport_info, |
| 1240 |
NULL, NULL); |
| 1241 |
PyObj_pjsua_transport_info_import(obj, &info); |
| 1242 |
return (PyObject*)obj; |
| 1243 |
} else { |
| 1244 |
return Py_BuildValue(""); |
| 1245 |
} |
| 1246 |
} |
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
static PyObject *py_pjsua_transport_close(PyObject *pSelf, PyObject *pArgs) |
| 1276 |
{ |
| 1277 |
pj_status_t status; |
| 1278 |
int id; |
| 1279 |
int force; |
| 1280 |
|
| 1281 |
PJ_UNUSED_ARG(pSelf); |
| 1282 |
|
| 1283 |
if (!PyArg_ParseTuple(pArgs, "ii", &id, &force)) { |
| 1284 |
return NULL; |
| 1285 |
} |
| 1286 |
status = pjsua_transport_close(id, force); |
| 1287 |
|
| 1288 |
return Py_BuildValue("i", status); |
| 1289 |
} |
| 1290 |
|
| 1291 |
static char pjsua_transport_config_default_doc[] = |
| 1292 |
"_pjsua.Transport_Config _pjsua.transport_config_default () " |
| 1293 |
"Call this function to initialize UDP config with default values."; |
| 1294 |
static char pjsua_transport_create_doc[] = |
| 1295 |
"int, int _pjsua.transport_create (int type, " |
| 1296 |
"_pjsua.Transport_Config cfg) " |
| 1297 |
"Create SIP transport."; |
| 1298 |
static char pjsua_enum_transports_doc[] = |
| 1299 |
"int[] _pjsua.enum_transports () " |
| 1300 |
"Enumerate all transports currently created in the system."; |
| 1301 |
static char pjsua_transport_get_info_doc[] = |
| 1302 |
"void _pjsua.transport_get_info " |
| 1303 |
"(_pjsua.Transport_ID id, _pjsua.Transport_Info info) " |
| 1304 |
"Get information about transports."; |
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
static char pjsua_transport_close_doc[] = |
| 1320 |
"void _pjsua.transport_close (_pjsua.Transport_ID id, int force) " |
| 1321 |
"Close the transport. If transport is forcefully closed, " |
| 1322 |
"it will be immediately closed, and any pending transactions " |
| 1323 |
"that are using the transport may not terminate properly. " |
| 1324 |
"Otherwise, the system will wait until all transactions are closed " |
| 1325 |
"while preventing new users from using the transport, and will close " |
| 1326 |
"the transport when it is safe to do so."; |
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
static PyObject *py_pjsua_acc_config_default(PyObject *pSelf, PyObject *pArgs) |
| 1337 |
{ |
| 1338 |
PyObj_pjsua_acc_config *obj; |
| 1339 |
pjsua_acc_config cfg; |
| 1340 |
|
| 1341 |
PJ_UNUSED_ARG(pSelf); |
| 1342 |
PJ_UNUSED_ARG(pArgs); |
| 1343 |
|
| 1344 |
if (!PyArg_ParseTuple(pArgs, "")) { |
| 1345 |
return NULL; |
| 1346 |
} |
| 1347 |
|
| 1348 |
pjsua_acc_config_default(&cfg); |
| 1349 |
obj = (PyObj_pjsua_acc_config *) |
| 1350 |
PyObj_pjsua_acc_config_new(&PyTyp_pjsua_acc_config, |
| 1351 |
NULL, NULL); |
| 1352 |
PyObj_pjsua_acc_config_import(obj, &cfg); |
| 1353 |
return (PyObject *)obj; |
| 1354 |
} |
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
static PyObject *py_pjsua_acc_get_count(PyObject *pSelf, PyObject *pArgs) |
| 1360 |
{ |
| 1361 |
int count; |
| 1362 |
|
| 1363 |
PJ_UNUSED_ARG(pSelf); |
| 1364 |
PJ_UNUSED_ARG(pArgs); |
| 1365 |
|
| 1366 |
count = pjsua_acc_get_count(); |
| 1367 |
return Py_BuildValue("i", count); |
| 1368 |
} |
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
static PyObject *py_pjsua_acc_is_valid(PyObject *pSelf, PyObject *pArgs) |
| 1374 |
{ |
| 1375 |
int id; |
| 1376 |
int is_valid; |
| 1377 |
|
| 1378 |
PJ_UNUSED_ARG(pSelf); |
| 1379 |
|
| 1380 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 1381 |
return NULL; |
| 1382 |
} |
| 1383 |
|
| 1384 |
is_valid = pjsua_acc_is_valid(id); |
| 1385 |
return Py_BuildValue("i", is_valid); |
| 1386 |
} |
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
|
| 1391 |
static PyObject *py_pjsua_acc_set_default(PyObject *pSelf, PyObject *pArgs) |
| 1392 |
{ |
| 1393 |
int id; |
| 1394 |
int status; |
| 1395 |
|
| 1396 |
PJ_UNUSED_ARG(pSelf); |
| 1397 |
|
| 1398 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 1399 |
return NULL; |
| 1400 |
} |
| 1401 |
status = pjsua_acc_set_default(id); |
| 1402 |
|
| 1403 |
return Py_BuildValue("i", status); |
| 1404 |
} |
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
static PyObject *py_pjsua_acc_get_default(PyObject *pSelf, PyObject *pArgs) |
| 1410 |
{ |
| 1411 |
int id; |
| 1412 |
|
| 1413 |
PJ_UNUSED_ARG(pSelf); |
| 1414 |
PJ_UNUSED_ARG(pArgs); |
| 1415 |
|
| 1416 |
id = pjsua_acc_get_default(); |
| 1417 |
|
| 1418 |
return Py_BuildValue("i", id); |
| 1419 |
} |
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
static PyObject *py_pjsua_acc_add(PyObject *pSelf, PyObject *pArgs) |
| 1425 |
{ |
| 1426 |
int is_default; |
| 1427 |
PyObject *pCfg; |
| 1428 |
int acc_id; |
| 1429 |
int status; |
| 1430 |
|
| 1431 |
PJ_UNUSED_ARG(pSelf); |
| 1432 |
|
| 1433 |
if (!PyArg_ParseTuple(pArgs, "Oi", &pCfg, &is_default)) { |
| 1434 |
return NULL; |
| 1435 |
} |
| 1436 |
|
| 1437 |
if (pCfg != Py_None) { |
| 1438 |
pjsua_acc_config cfg; |
| 1439 |
PyObj_pjsua_acc_config *ac; |
| 1440 |
|
| 1441 |
pjsua_acc_config_default(&cfg); |
| 1442 |
ac = (PyObj_pjsua_acc_config *)pCfg; |
| 1443 |
PyObj_pjsua_acc_config_export(&cfg, ac); |
| 1444 |
status = pjsua_acc_add(&cfg, is_default, &acc_id); |
| 1445 |
} else { |
| 1446 |
status = PJ_EINVAL; |
| 1447 |
acc_id = PJSUA_INVALID_ID; |
| 1448 |
} |
| 1449 |
|
| 1450 |
return Py_BuildValue("ii", status, acc_id); |
| 1451 |
} |
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
static PyObject *py_pjsua_acc_add_local(PyObject *pSelf, PyObject *pArgs) |
| 1457 |
{ |
| 1458 |
int is_default; |
| 1459 |
int tid; |
| 1460 |
int acc_id; |
| 1461 |
int status; |
| 1462 |
|
| 1463 |
PJ_UNUSED_ARG(pSelf); |
| 1464 |
|
| 1465 |
if (!PyArg_ParseTuple(pArgs, "ii", &tid, &is_default)) { |
| 1466 |
return NULL; |
| 1467 |
} |
| 1468 |
|
| 1469 |
status = pjsua_acc_add_local(tid, is_default, &acc_id); |
| 1470 |
|
| 1471 |
return Py_BuildValue("ii", status, acc_id); |
| 1472 |
} |
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
static PyObject *py_pjsua_acc_set_user_data(PyObject *pSelf, PyObject *pArgs) |
| 1478 |
{ |
| 1479 |
int acc_id; |
| 1480 |
PyObject *pUserData, *old_user_data; |
| 1481 |
int status; |
| 1482 |
|
| 1483 |
PJ_UNUSED_ARG(pSelf); |
| 1484 |
|
| 1485 |
if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &pUserData)) { |
| 1486 |
return NULL; |
| 1487 |
} |
| 1488 |
|
| 1489 |
old_user_data = (PyObject*) pjsua_acc_get_user_data(acc_id); |
| 1490 |
|
| 1491 |
status = pjsua_acc_set_user_data(acc_id, (void*)pUserData); |
| 1492 |
|
| 1493 |
if (status == PJ_SUCCESS) { |
| 1494 |
Py_XINCREF(pUserData); |
| 1495 |
Py_XDECREF(old_user_data); |
| 1496 |
} |
| 1497 |
|
| 1498 |
return Py_BuildValue("i", status); |
| 1499 |
} |
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
static PyObject *py_pjsua_acc_get_user_data(PyObject *pSelf, PyObject *pArgs) |
| 1505 |
{ |
| 1506 |
int acc_id; |
| 1507 |
PyObject *user_data; |
| 1508 |
|
| 1509 |
PJ_UNUSED_ARG(pSelf); |
| 1510 |
|
| 1511 |
if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) { |
| 1512 |
return NULL; |
| 1513 |
} |
| 1514 |
|
| 1515 |
user_data = (PyObject*) pjsua_acc_get_user_data(acc_id); |
| 1516 |
|
| 1517 |
return user_data ? Py_BuildValue("O", user_data) : Py_BuildValue(""); |
| 1518 |
} |
| 1519 |
|
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
static PyObject *py_pjsua_acc_del(PyObject *pSelf, PyObject *pArgs) |
| 1524 |
{ |
| 1525 |
int acc_id; |
| 1526 |
PyObject *user_data; |
| 1527 |
int status; |
| 1528 |
|
| 1529 |
PJ_UNUSED_ARG(pSelf); |
| 1530 |
|
| 1531 |
if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) { |
| 1532 |
return NULL; |
| 1533 |
} |
| 1534 |
|
| 1535 |
user_data = (PyObject*) pjsua_acc_get_user_data(acc_id); |
| 1536 |
Py_XDECREF(user_data); |
| 1537 |
|
| 1538 |
status = pjsua_acc_del(acc_id); |
| 1539 |
|
| 1540 |
return Py_BuildValue("i", status); |
| 1541 |
} |
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
static PyObject *py_pjsua_acc_modify(PyObject *pSelf, PyObject *pArgs) |
| 1547 |
{ |
| 1548 |
PyObject *pCfg; |
| 1549 |
PyObj_pjsua_acc_config * ac; |
| 1550 |
int acc_id; |
| 1551 |
int status; |
| 1552 |
|
| 1553 |
PJ_UNUSED_ARG(pSelf); |
| 1554 |
|
| 1555 |
if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &pCfg)) { |
| 1556 |
return NULL; |
| 1557 |
} |
| 1558 |
|
| 1559 |
if (pCfg != Py_None) { |
| 1560 |
pjsua_acc_config cfg; |
| 1561 |
|
| 1562 |
pjsua_acc_config_default(&cfg); |
| 1563 |
ac = (PyObj_pjsua_acc_config*)pCfg; |
| 1564 |
PyObj_pjsua_acc_config_export(&cfg, ac); |
| 1565 |
|
| 1566 |
status = pjsua_acc_modify(acc_id, &cfg); |
| 1567 |
} else { |
| 1568 |
status = PJ_EINVAL; |
| 1569 |
} |
| 1570 |
return Py_BuildValue("i", status); |
| 1571 |
} |
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
static PyObject *py_pjsua_acc_set_online_status(PyObject *pSelf, |
| 1577 |
PyObject *pArgs) |
| 1578 |
{ |
| 1579 |
int is_online; |
| 1580 |
int acc_id; |
| 1581 |
int status; |
| 1582 |
|
| 1583 |
PJ_UNUSED_ARG(pSelf); |
| 1584 |
|
| 1585 |
if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &is_online)) { |
| 1586 |
return NULL; |
| 1587 |
} |
| 1588 |
|
| 1589 |
status = pjsua_acc_set_online_status(acc_id, is_online); |
| 1590 |
|
| 1591 |
return Py_BuildValue("i", status); |
| 1592 |
} |
| 1593 |
|
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
static PyObject *py_pjsua_acc_set_online_status2(PyObject *pSelf, |
| 1598 |
PyObject *pArgs) |
| 1599 |
{ |
| 1600 |
int is_online; |
| 1601 |
int acc_id; |
| 1602 |
int activity_id; |
| 1603 |
const char *activity_text = NULL; |
| 1604 |
const char *rpid_id = NULL; |
| 1605 |
pjrpid_element rpid; |
| 1606 |
pj_status_t status; |
| 1607 |
|
| 1608 |
PJ_UNUSED_ARG(pSelf); |
| 1609 |
|
| 1610 |
if (!PyArg_ParseTuple(pArgs, "iiiss", &acc_id, &is_online, |
| 1611 |
&activity_id, &activity_text, &rpid_id)) |
| 1612 |
{ |
| 1613 |
return NULL; |
| 1614 |
} |
| 1615 |
|
| 1616 |
pj_bzero(&rpid, sizeof(rpid)); |
| 1617 |
rpid.type = PJRPID_ELEMENT_TYPE_PERSON; |
| 1618 |
rpid.activity = activity_id; |
| 1619 |
if (activity_text) |
| 1620 |
rpid.note = pj_str((char*)activity_text); |
| 1621 |
|
| 1622 |
if (rpid_id) |
| 1623 |
rpid.id = pj_str((char*)rpid_id); |
| 1624 |
|
| 1625 |
status = pjsua_acc_set_online_status2(acc_id, is_online, &rpid); |
| 1626 |
|
| 1627 |
return Py_BuildValue("i", status); |
| 1628 |
} |
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
static PyObject *py_pjsua_acc_set_registration(PyObject *pSelf, |
| 1634 |
PyObject *pArgs) |
| 1635 |
{ |
| 1636 |
int renew; |
| 1637 |
int acc_id; |
| 1638 |
int status; |
| 1639 |
|
| 1640 |
PJ_UNUSED_ARG(pSelf); |
| 1641 |
|
| 1642 |
if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &renew)) { |
| 1643 |
return NULL; |
| 1644 |
} |
| 1645 |
|
| 1646 |
status = pjsua_acc_set_registration(acc_id, renew); |
| 1647 |
|
| 1648 |
return Py_BuildValue("i", status); |
| 1649 |
} |
| 1650 |
|
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
static PyObject *py_pjsua_acc_get_info(PyObject *pSelf, PyObject *pArgs) |
| 1655 |
{ |
| 1656 |
int acc_id; |
| 1657 |
PyObj_pjsua_acc_info * obj; |
| 1658 |
pjsua_acc_info info; |
| 1659 |
int status; |
| 1660 |
|
| 1661 |
PJ_UNUSED_ARG(pSelf); |
| 1662 |
|
| 1663 |
if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) { |
| 1664 |
return NULL; |
| 1665 |
} |
| 1666 |
|
| 1667 |
status = pjsua_acc_get_info(acc_id, &info); |
| 1668 |
if (status == PJ_SUCCESS) { |
| 1669 |
obj = (PyObj_pjsua_acc_info*) |
| 1670 |
PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info, NULL, NULL); |
| 1671 |
PyObj_pjsua_acc_info_import(obj, &info); |
| 1672 |
return (PyObject*)obj; |
| 1673 |
} else { |
| 1674 |
return Py_BuildValue(""); |
| 1675 |
} |
| 1676 |
} |
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
static PyObject *py_pjsua_enum_accs(PyObject *pSelf, PyObject *pArgs) |
| 1682 |
{ |
| 1683 |
pj_status_t status; |
| 1684 |
PyObject *list; |
| 1685 |
pjsua_acc_id id[PJSUA_MAX_ACC]; |
| 1686 |
unsigned c, i; |
| 1687 |
|
| 1688 |
PJ_UNUSED_ARG(pSelf); |
| 1689 |
PJ_UNUSED_ARG(pArgs); |
| 1690 |
|
| 1691 |
c = PJ_ARRAY_SIZE(id); |
| 1692 |
status = pjsua_enum_accs(id, &c); |
| 1693 |
if (status != PJ_SUCCESS) |
| 1694 |
c = 0; |
| 1695 |
|
| 1696 |
list = PyList_New(c); |
| 1697 |
for (i = 0; i < c; i++) { |
| 1698 |
PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 1699 |
} |
| 1700 |
|
| 1701 |
return (PyObject*)list; |
| 1702 |
} |
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
static PyObject *py_pjsua_acc_enum_info(PyObject *pSelf, PyObject *pArgs) |
| 1708 |
{ |
| 1709 |
pj_status_t status; |
| 1710 |
PyObject *list; |
| 1711 |
pjsua_acc_info info[PJSUA_MAX_ACC]; |
| 1712 |
unsigned c, i; |
| 1713 |
|
| 1714 |
PJ_UNUSED_ARG(pSelf); |
| 1715 |
PJ_UNUSED_ARG(pArgs); |
| 1716 |
|
| 1717 |
if (!PyArg_ParseTuple(pArgs, "")) { |
| 1718 |
return NULL; |
| 1719 |
} |
| 1720 |
|
| 1721 |
c = PJ_ARRAY_SIZE(info); |
| 1722 |
status = pjsua_acc_enum_info(info, &c); |
| 1723 |
if (status != PJ_SUCCESS) |
| 1724 |
c = 0; |
| 1725 |
|
| 1726 |
list = PyList_New(c); |
| 1727 |
for (i = 0; i < c; i++) { |
| 1728 |
PyObj_pjsua_acc_info *obj; |
| 1729 |
obj = (PyObj_pjsua_acc_info *) |
| 1730 |
PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info, NULL, NULL); |
| 1731 |
|
| 1732 |
PyObj_pjsua_acc_info_import(obj, &info[i]); |
| 1733 |
|
| 1734 |
PyList_SetItem(list, i, (PyObject*)obj); |
| 1735 |
} |
| 1736 |
|
| 1737 |
return (PyObject*)list; |
| 1738 |
} |
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
static PyObject *py_pjsua_acc_set_transport(PyObject *pSelf, PyObject *pArgs) |
| 1744 |
{ |
| 1745 |
int acc_id, transport_id; |
| 1746 |
int status; |
| 1747 |
|
| 1748 |
PJ_UNUSED_ARG(pSelf); |
| 1749 |
|
| 1750 |
if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &transport_id)) { |
| 1751 |
return NULL; |
| 1752 |
} |
| 1753 |
|
| 1754 |
status = pjsua_acc_set_transport(acc_id, transport_id); |
| 1755 |
|
| 1756 |
|
| 1757 |
return Py_BuildValue("i", status); |
| 1758 |
} |
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
static PyObject *py_pjsua_acc_pres_notify(PyObject *pSelf, |
| 1765 |
PyObject *pArgs) |
| 1766 |
{ |
| 1767 |
int acc_id, state; |
| 1768 |
PyObject *arg_pres, *arg_msg_data, *arg_reason; |
| 1769 |
void *srv_pres; |
| 1770 |
pjsua_msg_data msg_data; |
| 1771 |
pj_str_t reason; |
| 1772 |
pj_bool_t with_body; |
| 1773 |
pj_pool_t *pool = NULL; |
| 1774 |
int status; |
| 1775 |
|
| 1776 |
PJ_UNUSED_ARG(pSelf); |
| 1777 |
|
| 1778 |
if (!PyArg_ParseTuple(pArgs, "iOiOO", &acc_id, &arg_pres, |
| 1779 |
&state, &arg_reason, &arg_msg_data)) |
| 1780 |
{ |
| 1781 |
return NULL; |
| 1782 |
} |
| 1783 |
|
| 1784 |
srv_pres = (void*) PyLong_AsLong(arg_pres); |
| 1785 |
with_body = (state != PJSIP_EVSUB_STATE_TERMINATED); |
| 1786 |
|
| 1787 |
if (arg_reason && PyString_Check(arg_reason)) { |
| 1788 |
reason = PyString_ToPJ(arg_reason); |
| 1789 |
} else { |
| 1790 |
reason = pj_str(""); |
| 1791 |
} |
| 1792 |
|
| 1793 |
pjsua_msg_data_init(&msg_data); |
| 1794 |
if (arg_msg_data && arg_msg_data != Py_None) { |
| 1795 |
PyObj_pjsua_msg_data *omd = (PyObj_pjsua_msg_data *)arg_msg_data; |
| 1796 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 1797 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 1798 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 1799 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 1800 |
} |
| 1801 |
|
| 1802 |
status = pjsua_pres_notify(acc_id, (pjsua_srv_pres*)srv_pres, |
| 1803 |
(pjsip_evsub_state)state, NULL, |
| 1804 |
&reason, with_body, &msg_data); |
| 1805 |
|
| 1806 |
if (pool) { |
| 1807 |
pj_pool_release(pool); |
| 1808 |
} |
| 1809 |
|
| 1810 |
return Py_BuildValue("i", status); |
| 1811 |
} |
| 1812 |
|
| 1813 |
static char pjsua_acc_config_default_doc[] = |
| 1814 |
"_pjsua.Acc_Config _pjsua.acc_config_default () " |
| 1815 |
"Call this function to initialize account config with default values."; |
| 1816 |
static char pjsua_acc_get_count_doc[] = |
| 1817 |
"int _pjsua.acc_get_count () " |
| 1818 |
"Get number of current accounts."; |
| 1819 |
static char pjsua_acc_is_valid_doc[] = |
| 1820 |
"int _pjsua.acc_is_valid (int acc_id) " |
| 1821 |
"Check if the specified account ID is valid."; |
| 1822 |
static char pjsua_acc_set_default_doc[] = |
| 1823 |
"int _pjsua.acc_set_default (int acc_id) " |
| 1824 |
"Set default account to be used when incoming " |
| 1825 |
"and outgoing requests doesn't match any accounts."; |
| 1826 |
static char pjsua_acc_get_default_doc[] = |
| 1827 |
"int _pjsua.acc_get_default () " |
| 1828 |
"Get default account."; |
| 1829 |
static char pjsua_acc_add_doc[] = |
| 1830 |
"int, int _pjsua.acc_add (_pjsua.Acc_Config cfg, " |
| 1831 |
"int is_default) " |
| 1832 |
"Add a new account to pjsua. PJSUA must have been initialized " |
| 1833 |
"(with pjsua_init()) before calling this function."; |
| 1834 |
static char pjsua_acc_add_local_doc[] = |
| 1835 |
"int,int _pjsua.acc_add_local (int tid, " |
| 1836 |
"int is_default) " |
| 1837 |
"Add a local account. A local account is used to identify " |
| 1838 |
"local endpoint instead of a specific user, and for this reason, " |
| 1839 |
"a transport ID is needed to obtain the local address information."; |
| 1840 |
static char pjsua_acc_del_doc[] = |
| 1841 |
"int _pjsua.acc_del (int acc_id) " |
| 1842 |
"Delete account."; |
| 1843 |
static char pjsua_acc_modify_doc[] = |
| 1844 |
"int _pjsua.acc_modify (int acc_id, _pjsua.Acc_Config cfg) " |
| 1845 |
"Modify account information."; |
| 1846 |
static char pjsua_acc_set_online_status_doc[] = |
| 1847 |
"int _pjsua.acc_set_online_status2(int acc_id, int is_online) " |
| 1848 |
"Modify account's presence status to be advertised " |
| 1849 |
"to remote/presence subscribers."; |
| 1850 |
static char pjsua_acc_set_online_status2_doc[] = |
| 1851 |
"int _pjsua.acc_set_online_status (int acc_id, int is_online, " |
| 1852 |
"int activity_id, string activity_text) " |
| 1853 |
"Modify account's presence status to be advertised " |
| 1854 |
"to remote/presence subscribers."; |
| 1855 |
static char pjsua_acc_set_registration_doc[] = |
| 1856 |
"int _pjsua.acc_set_registration (int acc_id, int renew) " |
| 1857 |
"Update registration or perform unregistration."; |
| 1858 |
static char pjsua_acc_get_info_doc[] = |
| 1859 |
"_pjsua.Acc_Info _pjsua.acc_get_info (int acc_id) " |
| 1860 |
"Get account information."; |
| 1861 |
static char pjsua_enum_accs_doc[] = |
| 1862 |
"int[] _pjsua.enum_accs () " |
| 1863 |
"Enum accounts all account ids."; |
| 1864 |
static char pjsua_acc_enum_info_doc[] = |
| 1865 |
"_pjsua.Acc_Info[] _pjsua.acc_enum_info () " |
| 1866 |
"Enum accounts info."; |
| 1867 |
|
| 1868 |
|
| 1869 |
|
| 1870 |
|
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
|
| 1877 |
static PyObject *py_pjsua_buddy_config_default(PyObject *pSelf, |
| 1878 |
PyObject *pArgs) |
| 1879 |
{ |
| 1880 |
PyObj_pjsua_buddy_config *obj; |
| 1881 |
pjsua_buddy_config cfg; |
| 1882 |
|
| 1883 |
PJ_UNUSED_ARG(pSelf); |
| 1884 |
PJ_UNUSED_ARG(pArgs); |
| 1885 |
|
| 1886 |
pjsua_buddy_config_default(&cfg); |
| 1887 |
obj = (PyObj_pjsua_buddy_config *) |
| 1888 |
PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_config, NULL, NULL); |
| 1889 |
PyObj_pjsua_buddy_config_import(obj, &cfg); |
| 1890 |
|
| 1891 |
return (PyObject *)obj; |
| 1892 |
} |
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
|
| 1897 |
static PyObject *py_pjsua_get_buddy_count(PyObject *pSelf, PyObject *pArgs) |
| 1898 |
{ |
| 1899 |
PJ_UNUSED_ARG(pSelf); |
| 1900 |
PJ_UNUSED_ARG(pArgs); |
| 1901 |
|
| 1902 |
return Py_BuildValue("i", pjsua_get_buddy_count()); |
| 1903 |
} |
| 1904 |
|
| 1905 |
|
| 1906 |
|
| 1907 |
|
| 1908 |
static PyObject *py_pjsua_buddy_is_valid(PyObject *pSelf, PyObject *pArgs) |
| 1909 |
{ |
| 1910 |
int id; |
| 1911 |
int is_valid; |
| 1912 |
|
| 1913 |
PJ_UNUSED_ARG(pSelf); |
| 1914 |
|
| 1915 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 1916 |
return NULL; |
| 1917 |
} |
| 1918 |
is_valid = pjsua_buddy_is_valid(id); |
| 1919 |
|
| 1920 |
return Py_BuildValue("i", is_valid); |
| 1921 |
} |
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
static PyObject *py_pjsua_enum_buddies(PyObject *pSelf, PyObject *pArgs) |
| 1927 |
{ |
| 1928 |
pj_status_t status; |
| 1929 |
PyObject *list; |
| 1930 |
pjsua_buddy_id id[PJSUA_MAX_BUDDIES]; |
| 1931 |
unsigned c, i; |
| 1932 |
|
| 1933 |
PJ_UNUSED_ARG(pSelf); |
| 1934 |
PJ_UNUSED_ARG(pArgs); |
| 1935 |
|
| 1936 |
c = PJ_ARRAY_SIZE(id); |
| 1937 |
status = pjsua_enum_buddies(id, &c); |
| 1938 |
if (status != PJ_SUCCESS) |
| 1939 |
c = 0; |
| 1940 |
|
| 1941 |
list = PyList_New(c); |
| 1942 |
for (i = 0; i < c; i++) { |
| 1943 |
PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 1944 |
} |
| 1945 |
|
| 1946 |
return (PyObject*)list; |
| 1947 |
} |
| 1948 |
|
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
static PyObject *py_pjsua_buddy_find(PyObject *pSelf, PyObject *pArgs) |
| 1953 |
{ |
| 1954 |
PyObject *pURI; |
| 1955 |
pj_str_t uri; |
| 1956 |
pjsua_buddy_id buddy_id; |
| 1957 |
|
| 1958 |
PJ_UNUSED_ARG(pSelf); |
| 1959 |
|
| 1960 |
if (!PyArg_ParseTuple(pArgs, "O", &pURI)) { |
| 1961 |
return NULL; |
| 1962 |
} |
| 1963 |
|
| 1964 |
if (!PyString_Check(pURI)) |
| 1965 |
return Py_BuildValue("i", PJSUA_INVALID_ID); |
| 1966 |
|
| 1967 |
uri = PyString_ToPJ(pURI); |
| 1968 |
buddy_id = pjsua_buddy_find(&uri); |
| 1969 |
|
| 1970 |
return Py_BuildValue("i", buddy_id); |
| 1971 |
} |
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
static PyObject *py_pjsua_buddy_get_info(PyObject *pSelf, PyObject *pArgs) |
| 1977 |
{ |
| 1978 |
int buddy_id; |
| 1979 |
pjsua_buddy_info info; |
| 1980 |
int status; |
| 1981 |
|
| 1982 |
PJ_UNUSED_ARG(pSelf); |
| 1983 |
|
| 1984 |
if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) { |
| 1985 |
return NULL; |
| 1986 |
} |
| 1987 |
|
| 1988 |
status = pjsua_buddy_get_info(buddy_id, &info); |
| 1989 |
if (status == PJ_SUCCESS) { |
| 1990 |
PyObj_pjsua_buddy_info *obj; |
| 1991 |
|
| 1992 |
obj = (PyObj_pjsua_buddy_info *) |
| 1993 |
PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_info, |
| 1994 |
NULL, NULL); |
| 1995 |
PyObj_pjsua_buddy_info_import(obj, &info); |
| 1996 |
return (PyObject*)obj; |
| 1997 |
} else { |
| 1998 |
return Py_BuildValue(""); |
| 1999 |
} |
| 2000 |
} |
| 2001 |
|
| 2002 |
|
| 2003 |
|
| 2004 |
|
| 2005 |
static PyObject *py_pjsua_buddy_add(PyObject *pSelf, PyObject *pArgs) |
| 2006 |
{ |
| 2007 |
PyObject *pCfg; |
| 2008 |
int buddy_id; |
| 2009 |
int status; |
| 2010 |
|
| 2011 |
PJ_UNUSED_ARG(pSelf); |
| 2012 |
|
| 2013 |
if (!PyArg_ParseTuple(pArgs, "O", &pCfg)) { |
| 2014 |
return NULL; |
| 2015 |
} |
| 2016 |
|
| 2017 |
if (pCfg != Py_None) { |
| 2018 |
pjsua_buddy_config cfg; |
| 2019 |
PyObj_pjsua_buddy_config *bc; |
| 2020 |
|
| 2021 |
bc = (PyObj_pjsua_buddy_config *)pCfg; |
| 2022 |
|
| 2023 |
pjsua_buddy_config_default(&cfg); |
| 2024 |
PyObj_pjsua_buddy_config_export(&cfg, bc); |
| 2025 |
|
| 2026 |
status = pjsua_buddy_add(&cfg, &buddy_id); |
| 2027 |
|
| 2028 |
} else { |
| 2029 |
status = PJ_EINVAL; |
| 2030 |
buddy_id = PJSUA_INVALID_ID; |
| 2031 |
} |
| 2032 |
return Py_BuildValue("ii", status, buddy_id); |
| 2033 |
} |
| 2034 |
|
| 2035 |
|
| 2036 |
|
| 2037 |
|
| 2038 |
static PyObject *py_pjsua_buddy_del(PyObject *pSelf, PyObject *pArgs) |
| 2039 |
{ |
| 2040 |
int buddy_id; |
| 2041 |
int status; |
| 2042 |
PyObject *user_data; |
| 2043 |
|
| 2044 |
PJ_UNUSED_ARG(pSelf); |
| 2045 |
|
| 2046 |
if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) { |
| 2047 |
return NULL; |
| 2048 |
} |
| 2049 |
|
| 2050 |
user_data = (PyObject*) pjsua_buddy_get_user_data(buddy_id); |
| 2051 |
Py_XDECREF(user_data); |
| 2052 |
|
| 2053 |
status = pjsua_buddy_del(buddy_id); |
| 2054 |
|
| 2055 |
return Py_BuildValue("i", status); |
| 2056 |
} |
| 2057 |
|
| 2058 |
|
| 2059 |
|
| 2060 |
|
| 2061 |
static PyObject *py_pjsua_buddy_set_user_data(PyObject *pSelf, PyObject *pArgs) |
| 2062 |
{ |
| 2063 |
int buddy_id; |
| 2064 |
int status; |
| 2065 |
PyObject *user_data, *old_user_data; |
| 2066 |
|
| 2067 |
PJ_UNUSED_ARG(pSelf); |
| 2068 |
|
| 2069 |
if (!PyArg_ParseTuple(pArgs, "iO", &buddy_id, &user_data)) { |
| 2070 |
return NULL; |
| 2071 |
} |
| 2072 |
|
| 2073 |
if (!pjsua_buddy_is_valid(buddy_id)) { |
| 2074 |
return Py_BuildValue("i", 0); |
| 2075 |
} |
| 2076 |
|
| 2077 |
old_user_data = (PyObject*) pjsua_buddy_get_user_data(buddy_id); |
| 2078 |
|
| 2079 |
status = pjsua_buddy_set_user_data(buddy_id, (void*)user_data); |
| 2080 |
|
| 2081 |
if (status == PJ_SUCCESS) { |
| 2082 |
Py_XINCREF(user_data); |
| 2083 |
Py_XDECREF(old_user_data); |
| 2084 |
} |
| 2085 |
|
| 2086 |
return Py_BuildValue("i", status); |
| 2087 |
} |
| 2088 |
|
| 2089 |
|
| 2090 |
|
| 2091 |
|
| 2092 |
static PyObject *py_pjsua_buddy_get_user_data(PyObject *pSelf, PyObject *pArgs) |
| 2093 |
{ |
| 2094 |
int buddy_id; |
| 2095 |
PyObject *user_data; |
| 2096 |
|
| 2097 |
PJ_UNUSED_ARG(pSelf); |
| 2098 |
|
| 2099 |
if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) { |
| 2100 |
return NULL; |
| 2101 |
} |
| 2102 |
|
| 2103 |
user_data = (PyObject*) pjsua_buddy_get_user_data(buddy_id); |
| 2104 |
|
| 2105 |
return user_data? Py_BuildValue("O", user_data) : Py_BuildValue(""); |
| 2106 |
} |
| 2107 |
|
| 2108 |
|
| 2109 |
|
| 2110 |
|
| 2111 |
static PyObject *py_pjsua_buddy_subscribe_pres(PyObject *pSelf, |
| 2112 |
PyObject *pArgs) |
| 2113 |
{ |
| 2114 |
int buddy_id; |
| 2115 |
int status; |
| 2116 |
int subscribe; |
| 2117 |
|
| 2118 |
PJ_UNUSED_ARG(pSelf); |
| 2119 |
|
| 2120 |
if (!PyArg_ParseTuple(pArgs, "ii", &buddy_id, &subscribe)) { |
| 2121 |
return NULL; |
| 2122 |
} |
| 2123 |
|
| 2124 |
status = pjsua_buddy_subscribe_pres(buddy_id, subscribe); |
| 2125 |
|
| 2126 |
return Py_BuildValue("i", status); |
| 2127 |
} |
| 2128 |
|
| 2129 |
|
| 2130 |
|
| 2131 |
|
| 2132 |
static PyObject *py_pjsua_pres_dump(PyObject *pSelf, PyObject *pArgs) |
| 2133 |
{ |
| 2134 |
int verbose; |
| 2135 |
|
| 2136 |
PJ_UNUSED_ARG(pSelf); |
| 2137 |
|
| 2138 |
if (!PyArg_ParseTuple(pArgs, "i", &verbose)) { |
| 2139 |
return NULL; |
| 2140 |
} |
| 2141 |
|
| 2142 |
pjsua_pres_dump(verbose); |
| 2143 |
|
| 2144 |
return Py_BuildValue(""); |
| 2145 |
} |
| 2146 |
|
| 2147 |
|
| 2148 |
|
| 2149 |
|
| 2150 |
static PyObject *py_pjsua_im_send(PyObject *pSelf, PyObject *pArgs) |
| 2151 |
{ |
| 2152 |
int status; |
| 2153 |
int acc_id; |
| 2154 |
pj_str_t *mime_type, tmp_mime_type; |
| 2155 |
pj_str_t to, content; |
| 2156 |
PyObject *pTo; |
| 2157 |
PyObject *pMimeType; |
| 2158 |
PyObject *pContent; |
| 2159 |
pjsua_msg_data msg_data; |
| 2160 |
PyObject *pMsgData; |
| 2161 |
int user_data; |
| 2162 |
pj_pool_t *pool = NULL; |
| 2163 |
|
| 2164 |
PJ_UNUSED_ARG(pSelf); |
| 2165 |
|
| 2166 |
if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id, |
| 2167 |
&pTo, &pMimeType, &pContent, &pMsgData, &user_data)) |
| 2168 |
{ |
| 2169 |
return NULL; |
| 2170 |
} |
| 2171 |
|
| 2172 |
if (pMimeType != Py_None) { |
| 2173 |
mime_type = &tmp_mime_type; |
| 2174 |
tmp_mime_type = PyString_ToPJ(pMimeType); |
| 2175 |
} else { |
| 2176 |
mime_type = NULL; |
| 2177 |
} |
| 2178 |
|
| 2179 |
to = PyString_ToPJ(pTo); |
| 2180 |
content = PyString_ToPJ(pContent); |
| 2181 |
|
| 2182 |
pjsua_msg_data_init(&msg_data); |
| 2183 |
|
| 2184 |
if (pMsgData != Py_None) { |
| 2185 |
PyObj_pjsua_msg_data *omd; |
| 2186 |
|
| 2187 |
omd = (PyObj_pjsua_msg_data *)pMsgData; |
| 2188 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 2189 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 2190 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 2191 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 2192 |
} |
| 2193 |
|
| 2194 |
status = pjsua_im_send(acc_id, &to, mime_type, &content, |
| 2195 |
&msg_data, (void*)(long)user_data); |
| 2196 |
if (pool) |
| 2197 |
pj_pool_release(pool); |
| 2198 |
|
| 2199 |
return Py_BuildValue("i",status); |
| 2200 |
} |
| 2201 |
|
| 2202 |
|
| 2203 |
|
| 2204 |
|
| 2205 |
static PyObject *py_pjsua_im_typing(PyObject *pSelf, PyObject *pArgs) |
| 2206 |
{ |
| 2207 |
int status; |
| 2208 |
int acc_id; |
| 2209 |
pj_str_t to; |
| 2210 |
PyObject *pTo; |
| 2211 |
int is_typing; |
| 2212 |
pjsua_msg_data msg_data; |
| 2213 |
PyObject *pMsgData; |
| 2214 |
pj_pool_t *pool = NULL; |
| 2215 |
|
| 2216 |
PJ_UNUSED_ARG(pSelf); |
| 2217 |
|
| 2218 |
if (!PyArg_ParseTuple(pArgs, "iOiO", &acc_id, &pTo, &is_typing, |
| 2219 |
&pMsgData)) |
| 2220 |
{ |
| 2221 |
return NULL; |
| 2222 |
} |
| 2223 |
|
| 2224 |
to = PyString_ToPJ(pTo); |
| 2225 |
|
| 2226 |
pjsua_msg_data_init(&msg_data); |
| 2227 |
|
| 2228 |
if (pMsgData != Py_None) { |
| 2229 |
PyObj_pjsua_msg_data *omd; |
| 2230 |
|
| 2231 |
omd = (PyObj_pjsua_msg_data *)pMsgData; |
| 2232 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 2233 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 2234 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 2235 |
|
| 2236 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 2237 |
} |
| 2238 |
|
| 2239 |
status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data); |
| 2240 |
|
| 2241 |
if (pool) |
| 2242 |
pj_pool_release(pool); |
| 2243 |
|
| 2244 |
return Py_BuildValue("i", status); |
| 2245 |
} |
| 2246 |
|
| 2247 |
static char pjsua_buddy_config_default_doc[] = |
| 2248 |
"_pjsua.Buddy_Config _pjsua.buddy_config_default () " |
| 2249 |
"Set default values to the buddy config."; |
| 2250 |
static char pjsua_get_buddy_count_doc[] = |
| 2251 |
"int _pjsua.get_buddy_count () " |
| 2252 |
"Get total number of buddies."; |
| 2253 |
static char pjsua_buddy_is_valid_doc[] = |
| 2254 |
"int _pjsua.buddy_is_valid (int buddy_id) " |
| 2255 |
"Check if buddy ID is valid."; |
| 2256 |
static char pjsua_enum_buddies_doc[] = |
| 2257 |
"int[] _pjsua.enum_buddies () " |
| 2258 |
"Enum buddy IDs."; |
| 2259 |
static char pjsua_buddy_get_info_doc[] = |
| 2260 |
"_pjsua.Buddy_Info _pjsua.buddy_get_info (int buddy_id) " |
| 2261 |
"Get detailed buddy info."; |
| 2262 |
static char pjsua_buddy_add_doc[] = |
| 2263 |
"int,int _pjsua.buddy_add (_pjsua.Buddy_Config cfg) " |
| 2264 |
"Add new buddy."; |
| 2265 |
static char pjsua_buddy_del_doc[] = |
| 2266 |
"int _pjsua.buddy_del (int buddy_id) " |
| 2267 |
"Delete buddy."; |
| 2268 |
static char pjsua_buddy_subscribe_pres_doc[] = |
| 2269 |
"int _pjsua.buddy_subscribe_pres (int buddy_id, int subscribe) " |
| 2270 |
"Enable/disable buddy's presence monitoring."; |
| 2271 |
static char pjsua_pres_dump_doc[] = |
| 2272 |
"void _pjsua.pres_dump (int verbose) " |
| 2273 |
"Dump presence subscriptions to log file."; |
| 2274 |
static char pjsua_im_send_doc[] = |
| 2275 |
"int _pjsua.im_send (int acc_id, string to, string mime_type, " |
| 2276 |
"string content, _pjsua.Msg_Data msg_data, int user_data) " |
| 2277 |
"Send instant messaging outside dialog, using the specified account " |
| 2278 |
"for route set and authentication."; |
| 2279 |
static char pjsua_im_typing_doc[] = |
| 2280 |
"int _pjsua.im_typing (int acc_id, string to, int is_typing, " |
| 2281 |
"_pjsua.Msg_Data msg_data) " |
| 2282 |
"Send typing indication outside dialog."; |
| 2283 |
|
| 2284 |
|
| 2285 |
|
| 2286 |
|
| 2287 |
|
| 2288 |
|
| 2289 |
|
| 2290 |
|
| 2291 |
|
| 2292 |
static PyObject *py_pjsua_conf_get_max_ports(PyObject *pSelf, PyObject *pArgs) |
| 2293 |
{ |
| 2294 |
PJ_UNUSED_ARG(pSelf); |
| 2295 |
PJ_UNUSED_ARG(pArgs); |
| 2296 |
|
| 2297 |
return Py_BuildValue("i", pjsua_conf_get_max_ports()); |
| 2298 |
} |
| 2299 |
|
| 2300 |
|
| 2301 |
|
| 2302 |
|
| 2303 |
static PyObject *py_pjsua_conf_get_active_ports(PyObject *pSelf, |
| 2304 |
PyObject *pArgs) |
| 2305 |
{ |
| 2306 |
PJ_UNUSED_ARG(pSelf); |
| 2307 |
PJ_UNUSED_ARG(pArgs); |
| 2308 |
|
| 2309 |
return Py_BuildValue("i", pjsua_conf_get_active_ports()); |
| 2310 |
} |
| 2311 |
|
| 2312 |
|
| 2313 |
|
| 2314 |
|
| 2315 |
static PyObject *py_pjsua_enum_conf_ports(PyObject *pSelf, PyObject *pArgs) |
| 2316 |
{ |
| 2317 |
pj_status_t status; |
| 2318 |
PyObject *list; |
| 2319 |
pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS]; |
| 2320 |
unsigned c, i; |
| 2321 |
|
| 2322 |
PJ_UNUSED_ARG(pSelf); |
| 2323 |
PJ_UNUSED_ARG(pArgs); |
| 2324 |
|
| 2325 |
c = PJ_ARRAY_SIZE(id); |
| 2326 |
status = pjsua_enum_conf_ports(id, &c); |
| 2327 |
if (status != PJ_SUCCESS) |
| 2328 |
c = 0; |
| 2329 |
|
| 2330 |
list = PyList_New(c); |
| 2331 |
for (i = 0; i < c; i++) { |
| 2332 |
PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 2333 |
} |
| 2334 |
|
| 2335 |
return (PyObject*)list; |
| 2336 |
} |
| 2337 |
|
| 2338 |
|
| 2339 |
|
| 2340 |
|
| 2341 |
static PyObject *py_pjsua_conf_get_port_info(PyObject *pSelf, PyObject *pArgs) |
| 2342 |
{ |
| 2343 |
int id; |
| 2344 |
PyObj_pjsua_conf_port_info *ret; |
| 2345 |
pjsua_conf_port_info info; |
| 2346 |
unsigned i; |
| 2347 |
|
| 2348 |
PJ_UNUSED_ARG(pSelf); |
| 2349 |
|
| 2350 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 2351 |
return NULL; |
| 2352 |
} |
| 2353 |
|
| 2354 |
pjsua_conf_get_port_info(id, &info); |
| 2355 |
ret = (PyObj_pjsua_conf_port_info *) |
| 2356 |
conf_port_info_new(&PyTyp_pjsua_conf_port_info, NULL, NULL); |
| 2357 |
ret->bits_per_sample = info.bits_per_sample; |
| 2358 |
ret->channel_count = info.channel_count; |
| 2359 |
ret->clock_rate = info.clock_rate; |
| 2360 |
ret->name = PyString_FromPJ(&info.name); |
| 2361 |
ret->samples_per_frame = info.samples_per_frame; |
| 2362 |
ret->slot_id = info.slot_id; |
| 2363 |
Py_XDECREF(ret->listeners); |
| 2364 |
ret->listeners = PyList_New(info.listener_cnt); |
| 2365 |
for (i = 0; i < info.listener_cnt; i++) { |
| 2366 |
PyObject *item = Py_BuildValue("i",info.listeners[i]); |
| 2367 |
PyList_SetItem(ret->listeners, i, item); |
| 2368 |
} |
| 2369 |
return (PyObject*)ret; |
| 2370 |
} |
| 2371 |
|
| 2372 |
|
| 2373 |
|
| 2374 |
|
| 2375 |
static PyObject *py_pjsua_conf_remove_port(PyObject *pSelf, PyObject *pArgs) |
| 2376 |
{ |
| 2377 |
int id; |
| 2378 |
int status; |
| 2379 |
|
| 2380 |
PJ_UNUSED_ARG(pSelf); |
| 2381 |
|
| 2382 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 2383 |
return NULL; |
| 2384 |
} |
| 2385 |
|
| 2386 |
status = pjsua_conf_remove_port(id); |
| 2387 |
|
| 2388 |
return Py_BuildValue("i", status); |
| 2389 |
} |
| 2390 |
|
| 2391 |
|
| 2392 |
|
| 2393 |
|
| 2394 |
static PyObject *py_pjsua_conf_connect(PyObject *pSelf, PyObject *pArgs) |
| 2395 |
{ |
| 2396 |
int source, sink; |
| 2397 |
int status; |
| 2398 |
|
| 2399 |
PJ_UNUSED_ARG(pSelf); |
| 2400 |
|
| 2401 |
if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) { |
| 2402 |
return NULL; |
| 2403 |
} |
| 2404 |
|
| 2405 |
status = pjsua_conf_connect(source, sink); |
| 2406 |
|
| 2407 |
return Py_BuildValue("i", status); |
| 2408 |
} |
| 2409 |
|
| 2410 |
|
| 2411 |
|
| 2412 |
|
| 2413 |
static PyObject *py_pjsua_conf_disconnect(PyObject *pSelf, PyObject *pArgs) |
| 2414 |
{ |
| 2415 |
int source, sink; |
| 2416 |
int status; |
| 2417 |
|
| 2418 |
PJ_UNUSED_ARG(pSelf); |
| 2419 |
|
| 2420 |
if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) { |
| 2421 |
return NULL; |
| 2422 |
} |
| 2423 |
|
| 2424 |
status = pjsua_conf_disconnect(source, sink); |
| 2425 |
|
| 2426 |
return Py_BuildValue("i", status); |
| 2427 |
} |
| 2428 |
|
| 2429 |
|
| 2430 |
|
| 2431 |
|
| 2432 |
static PyObject *py_pjsua_conf_set_tx_level(PyObject *pSelf, PyObject *pArgs) |
| 2433 |
{ |
| 2434 |
int slot; |
| 2435 |
float level; |
| 2436 |
int status; |
| 2437 |
|
| 2438 |
PJ_UNUSED_ARG(pSelf); |
| 2439 |
|
| 2440 |
if (!PyArg_ParseTuple(pArgs, "if", &slot, &level)) { |
| 2441 |
return NULL; |
| 2442 |
} |
| 2443 |
|
| 2444 |
status = pjsua_conf_adjust_tx_level(slot, level); |
| 2445 |
|
| 2446 |
return Py_BuildValue("i", status); |
| 2447 |
} |
| 2448 |
|
| 2449 |
|
| 2450 |
|
| 2451 |
|
| 2452 |
static PyObject *py_pjsua_conf_set_rx_level(PyObject *pSelf, PyObject *pArgs) |
| 2453 |
{ |
| 2454 |
int slot; |
| 2455 |
float level; |
| 2456 |
int status; |
| 2457 |
|
| 2458 |
PJ_UNUSED_ARG(pSelf); |
| 2459 |
|
| 2460 |
if (!PyArg_ParseTuple(pArgs, "if", &slot, &level)) { |
| 2461 |
return NULL; |
| 2462 |
} |
| 2463 |
|
| 2464 |
status = pjsua_conf_adjust_rx_level(slot, level); |
| 2465 |
|
| 2466 |
return Py_BuildValue("i", status); |
| 2467 |
} |
| 2468 |
|
| 2469 |
|
| 2470 |
|
| 2471 |
|
| 2472 |
static PyObject *py_pjsua_conf_get_signal_level(PyObject *pSelf, |
| 2473 |
PyObject *pArgs) |
| 2474 |
{ |
| 2475 |
int slot; |
| 2476 |
unsigned tx_level, rx_level; |
| 2477 |
int status; |
| 2478 |
|
| 2479 |
PJ_UNUSED_ARG(pSelf); |
| 2480 |
|
| 2481 |
if (!PyArg_ParseTuple(pArgs, "i", &slot)) { |
| 2482 |
return NULL; |
| 2483 |
} |
| 2484 |
|
| 2485 |
status = pjsua_conf_get_signal_level(slot, &tx_level, &rx_level); |
| 2486 |
|
| 2487 |
return Py_BuildValue("iff", status, (float)(tx_level/255.0), |
| 2488 |
(float)(rx_level/255.0)); |
| 2489 |
} |
| 2490 |
|
| 2491 |
|
| 2492 |
|
| 2493 |
|
| 2494 |
static PyObject *py_pjsua_player_create(PyObject *pSelf, PyObject *pArgs) |
| 2495 |
{ |
| 2496 |
int id; |
| 2497 |
int options; |
| 2498 |
PyObject *pFilename; |
| 2499 |
pj_str_t filename; |
| 2500 |
int status; |
| 2501 |
|
| 2502 |
PJ_UNUSED_ARG(pSelf); |
| 2503 |
|
| 2504 |
if (!PyArg_ParseTuple(pArgs, "Oi", &pFilename, &options)) { |
| 2505 |
return NULL; |
| 2506 |
} |
| 2507 |
|
| 2508 |
filename = PyString_ToPJ(pFilename); |
| 2509 |
status = pjsua_player_create(&filename, options, &id); |
| 2510 |
|
| 2511 |
return Py_BuildValue("ii", status, id); |
| 2512 |
} |
| 2513 |
|
| 2514 |
|
| 2515 |
|
| 2516 |
|
| 2517 |
static PyObject *py_pjsua_playlist_create(PyObject *pSelf, PyObject *pArgs) |
| 2518 |
{ |
| 2519 |
int id; |
| 2520 |
int options; |
| 2521 |
PyObject *pLabel, *pFileList; |
| 2522 |
pj_str_t label; |
| 2523 |
int count; |
| 2524 |
pj_str_t files[64]; |
| 2525 |
int status; |
| 2526 |
|
| 2527 |
PJ_UNUSED_ARG(pSelf); |
| 2528 |
|
| 2529 |
if (!PyArg_ParseTuple(pArgs, "OOi", &pLabel, &pFileList, &options)) { |
| 2530 |
return NULL; |
| 2531 |
} |
| 2532 |
|
| 2533 |
label = PyString_ToPJ(pLabel); |
| 2534 |
if (!PyList_Check(pFileList)) |
| 2535 |
return Py_BuildValue("ii", PJ_EINVAL, PJSUA_INVALID_ID); |
| 2536 |
|
| 2537 |
count = 0; |
| 2538 |
for (count=0; count<PyList_Size(pFileList) && |
| 2539 |
count<(int)PJ_ARRAY_SIZE(files); ++count) |
| 2540 |
{ |
| 2541 |
files[count] = PyString_ToPJ(PyList_GetItem(pFileList, count)); |
| 2542 |
} |
| 2543 |
|
| 2544 |
status = pjsua_playlist_create(files, count, &label, options, &id); |
| 2545 |
|
| 2546 |
return Py_BuildValue("ii", status, id); |
| 2547 |
} |
| 2548 |
|
| 2549 |
|
| 2550 |
|
| 2551 |
|
| 2552 |
static PyObject *py_pjsua_player_get_conf_port(PyObject *pSelf, |
| 2553 |
PyObject *pArgs) |
| 2554 |
{ |
| 2555 |
|
| 2556 |
int id, port_id; |
| 2557 |
|
| 2558 |
PJ_UNUSED_ARG(pSelf); |
| 2559 |
|
| 2560 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 2561 |
return NULL; |
| 2562 |
} |
| 2563 |
|
| 2564 |
port_id = pjsua_player_get_conf_port(id); |
| 2565 |
|
| 2566 |
return Py_BuildValue("i", port_id); |
| 2567 |
} |
| 2568 |
|
| 2569 |
|
| 2570 |
|
| 2571 |
|
| 2572 |
static PyObject *py_pjsua_player_set_pos(PyObject *pSelf, PyObject *pArgs) |
| 2573 |
{ |
| 2574 |
int id; |
| 2575 |
int samples; |
| 2576 |
int status; |
| 2577 |
|
| 2578 |
PJ_UNUSED_ARG(pSelf); |
| 2579 |
|
| 2580 |
if (!PyArg_ParseTuple(pArgs, "ii", &id, &samples)) { |
| 2581 |
return NULL; |
| 2582 |
} |
| 2583 |
|
| 2584 |
if (samples < 0) |
| 2585 |
samples = 0; |
| 2586 |
|
| 2587 |
status = pjsua_player_set_pos(id, samples); |
| 2588 |
|
| 2589 |
return Py_BuildValue("i", status); |
| 2590 |
} |
| 2591 |
|
| 2592 |
|
| 2593 |
|
| 2594 |
|
| 2595 |
static PyObject *py_pjsua_player_destroy(PyObject *pSelf, PyObject *pArgs) |
| 2596 |
{ |
| 2597 |
int id; |
| 2598 |
int status; |
| 2599 |
|
| 2600 |
PJ_UNUSED_ARG(pSelf); |
| 2601 |
|
| 2602 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 2603 |
return NULL; |
| 2604 |
} |
| 2605 |
|
| 2606 |
status = pjsua_player_destroy(id); |
| 2607 |
|
| 2608 |
return Py_BuildValue("i", status); |
| 2609 |
} |
| 2610 |
|
| 2611 |
|
| 2612 |
|
| 2613 |
|
| 2614 |
static PyObject *py_pjsua_recorder_create(PyObject *pSelf, PyObject *pArgs) |
| 2615 |
{ |
| 2616 |
int id, options; |
| 2617 |
int max_size; |
| 2618 |
PyObject *pFilename, *pEncParam; |
| 2619 |
pj_str_t filename; |
| 2620 |
int enc_type; |
| 2621 |
|
| 2622 |
int status; |
| 2623 |
|
| 2624 |
PJ_UNUSED_ARG(pSelf); |
| 2625 |
|
| 2626 |
if (!PyArg_ParseTuple(pArgs, "OiOii", &pFilename, &enc_type, &pEncParam, |
| 2627 |
&max_size, &options)) |
| 2628 |
{ |
| 2629 |
return NULL; |
| 2630 |
} |
| 2631 |
|
| 2632 |
filename = PyString_ToPJ(pFilename); |
| 2633 |
|
| 2634 |
status = pjsua_recorder_create(&filename, enc_type, NULL, max_size, |
| 2635 |
options, &id); |
| 2636 |
|
| 2637 |
return Py_BuildValue("ii", status, id); |
| 2638 |
} |
| 2639 |
|
| 2640 |
|
| 2641 |
|
| 2642 |
|
| 2643 |
static PyObject *py_pjsua_recorder_get_conf_port(PyObject *pSelf, |
| 2644 |
PyObject *pArgs) |
| 2645 |
{ |
| 2646 |
|
| 2647 |
int id, port_id; |
| 2648 |
|
| 2649 |
PJ_UNUSED_ARG(pSelf); |
| 2650 |
|
| 2651 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 2652 |
return NULL; |
| 2653 |
} |
| 2654 |
|
| 2655 |
port_id = pjsua_recorder_get_conf_port(id); |
| 2656 |
|
| 2657 |
return Py_BuildValue("i", port_id); |
| 2658 |
} |
| 2659 |
|
| 2660 |
|
| 2661 |
|
| 2662 |
|
| 2663 |
static PyObject *py_pjsua_recorder_destroy(PyObject *pSelf, PyObject *pArgs) |
| 2664 |
{ |
| 2665 |
int id; |
| 2666 |
int status; |
| 2667 |
|
| 2668 |
PJ_UNUSED_ARG(pSelf); |
| 2669 |
|
| 2670 |
if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
| 2671 |
return NULL; |
| 2672 |
} |
| 2673 |
|
| 2674 |
status = pjsua_recorder_destroy(id); |
| 2675 |
|
| 2676 |
return Py_BuildValue("i", status); |
| 2677 |
} |
| 2678 |
|
| 2679 |
|
| 2680 |
|
| 2681 |
|
| 2682 |
static PyObject *py_pjsua_enum_snd_devs(PyObject *pSelf, PyObject *pArgs) |
| 2683 |
{ |
| 2684 |
pj_status_t status; |
| 2685 |
PyObject *ret; |
| 2686 |
pjmedia_snd_dev_info info[SND_DEV_NUM]; |
| 2687 |
unsigned c, i; |
| 2688 |
|
| 2689 |
PJ_UNUSED_ARG(pSelf); |
| 2690 |
PJ_UNUSED_ARG(pArgs); |
| 2691 |
|
| 2692 |
c = PJ_ARRAY_SIZE(info); |
| 2693 |
status = pjsua_enum_snd_devs(info, &c); |
| 2694 |
if (status != PJ_SUCCESS) |
| 2695 |
c = 0; |
| 2696 |
|
| 2697 |
ret = PyList_New(c); |
| 2698 |
for (i = 0; i < c; i++) { |
| 2699 |
PyObj_pjmedia_snd_dev_info * obj; |
| 2700 |
|
| 2701 |
obj = (PyObj_pjmedia_snd_dev_info *) |
| 2702 |
pjmedia_snd_dev_info_new(&PyTyp_pjmedia_snd_dev_info, |
| 2703 |
NULL, NULL); |
| 2704 |
obj->default_samples_per_sec = info[i].default_samples_per_sec; |
| 2705 |
obj->input_count = info[i].input_count; |
| 2706 |
obj->output_count = info[i].output_count; |
| 2707 |
obj->name = PyString_FromString(info[i].name); |
| 2708 |
|
| 2709 |
PyList_SetItem(ret, i, (PyObject *)obj); |
| 2710 |
} |
| 2711 |
|
| 2712 |
return (PyObject*)ret; |
| 2713 |
} |
| 2714 |
|
| 2715 |
|
| 2716 |
|
| 2717 |
|
| 2718 |
static PyObject *py_pjsua_get_snd_dev(PyObject *pSelf, PyObject *pArgs) |
| 2719 |
{ |
| 2720 |
int capture_dev, playback_dev; |
| 2721 |
|
| 2722 |
PJ_UNUSED_ARG(pSelf); |
| 2723 |
PJ_UNUSED_ARG(pArgs); |
| 2724 |
|
| 2725 |
pjsua_get_snd_dev(&capture_dev, &playback_dev); |
| 2726 |
|
| 2727 |
return Py_BuildValue("ii", capture_dev, playback_dev); |
| 2728 |
} |
| 2729 |
|
| 2730 |
|
| 2731 |
|
| 2732 |
|
| 2733 |
static PyObject *py_pjsua_set_snd_dev(PyObject *pSelf, PyObject *pArgs) |
| 2734 |
{ |
| 2735 |
int capture_dev, playback_dev; |
| 2736 |
int status; |
| 2737 |
|
| 2738 |
PJ_UNUSED_ARG(pSelf); |
| 2739 |
|
| 2740 |
if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev)) { |
| 2741 |
return NULL; |
| 2742 |
} |
| 2743 |
|
| 2744 |
status = pjsua_set_snd_dev(capture_dev, playback_dev); |
| 2745 |
|
| 2746 |
return Py_BuildValue("i", status); |
| 2747 |
} |
| 2748 |
|
| 2749 |
|
| 2750 |
|
| 2751 |
|
| 2752 |
static PyObject *py_pjsua_set_null_snd_dev(PyObject *pSelf, PyObject *pArgs) |
| 2753 |
{ |
| 2754 |
int status; |
| 2755 |
|
| 2756 |
PJ_UNUSED_ARG(pSelf); |
| 2757 |
PJ_UNUSED_ARG(pArgs); |
| 2758 |
|
| 2759 |
status = pjsua_set_null_snd_dev(); |
| 2760 |
|
| 2761 |
return Py_BuildValue("i", status); |
| 2762 |
} |
| 2763 |
|
| 2764 |
|
| 2765 |
|
| 2766 |
|
| 2767 |
static PyObject *py_pjsua_set_ec(PyObject *pSelf, PyObject *pArgs) |
| 2768 |
{ |
| 2769 |
int options; |
| 2770 |
int tail_ms; |
| 2771 |
int status; |
| 2772 |
|
| 2773 |
PJ_UNUSED_ARG(pSelf); |
| 2774 |
|
| 2775 |
if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options)) { |
| 2776 |
return NULL; |
| 2777 |
} |
| 2778 |
|
| 2779 |
status = pjsua_set_ec(tail_ms, options); |
| 2780 |
|
| 2781 |
return Py_BuildValue("i", status); |
| 2782 |
} |
| 2783 |
|
| 2784 |
|
| 2785 |
|
| 2786 |
|
| 2787 |
static PyObject *py_pjsua_get_ec_tail(PyObject *pSelf, PyObject *pArgs) |
| 2788 |
{ |
| 2789 |
int status; |
| 2790 |
unsigned tail_ms; |
| 2791 |
|
| 2792 |
PJ_UNUSED_ARG(pSelf); |
| 2793 |
PJ_UNUSED_ARG(pArgs); |
| 2794 |
|
| 2795 |
status = pjsua_get_ec_tail(&tail_ms); |
| 2796 |
if (status != PJ_SUCCESS) |
| 2797 |
tail_ms = 0; |
| 2798 |
|
| 2799 |
return Py_BuildValue("i", tail_ms); |
| 2800 |
} |
| 2801 |
|
| 2802 |
|
| 2803 |
|
| 2804 |
|
| 2805 |
static PyObject *py_pjsua_enum_codecs(PyObject *pSelf, PyObject *pArgs) |
| 2806 |
{ |
| 2807 |
pj_status_t status; |
| 2808 |
PyObject *ret; |
| 2809 |
pjsua_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS]; |
| 2810 |
unsigned c, i; |
| 2811 |
|
| 2812 |
PJ_UNUSED_ARG(pSelf); |
| 2813 |
PJ_UNUSED_ARG(pArgs); |
| 2814 |
|
| 2815 |
c = PJ_ARRAY_SIZE(info); |
| 2816 |
status = pjsua_enum_codecs(info, &c); |
| 2817 |
if (status != PJ_SUCCESS) |
| 2818 |
c = 0; |
| 2819 |
|
| 2820 |
ret = PyList_New(c); |
| 2821 |
for (i = 0; i < c; i++) { |
| 2822 |
PyObj_pjsua_codec_info * obj; |
| 2823 |
obj = (PyObj_pjsua_codec_info *) |
| 2824 |
codec_info_new(&PyTyp_pjsua_codec_info, NULL, NULL); |
| 2825 |
obj->codec_id = PyString_FromPJ(&info[i].codec_id); |
| 2826 |
obj->priority = info[i].priority; |
| 2827 |
|
| 2828 |
PyList_SetItem(ret, i, (PyObject *)obj); |
| 2829 |
} |
| 2830 |
|
| 2831 |
return (PyObject*)ret; |
| 2832 |
} |
| 2833 |
|
| 2834 |
|
| 2835 |
|
| 2836 |
|
| 2837 |
static PyObject *py_pjsua_codec_set_priority(PyObject *pSelf, PyObject *pArgs) |
| 2838 |
{ |
| 2839 |
int status; |
| 2840 |
PyObject *pCodecId; |
| 2841 |
pj_str_t codec_id; |
| 2842 |
int priority; |
| 2843 |
|
| 2844 |
PJ_UNUSED_ARG(pSelf); |
| 2845 |
|
| 2846 |
if (!PyArg_ParseTuple(pArgs, "Oi", &pCodecId, &priority)) { |
| 2847 |
return NULL; |
| 2848 |
} |
| 2849 |
|
| 2850 |
codec_id = PyString_ToPJ(pCodecId); |
| 2851 |
if (priority < 0) |
| 2852 |
priority = 0; |
| 2853 |
if (priority > 255) |
| 2854 |
priority = 255; |
| 2855 |
|
| 2856 |
status = pjsua_codec_set_priority(&codec_id, (pj_uint8_t)priority); |
| 2857 |
|
| 2858 |
return Py_BuildValue("i", status); |
| 2859 |
} |
| 2860 |
|
| 2861 |
|
| 2862 |
|
| 2863 |
|
| 2864 |
static PyObject *py_pjsua_codec_get_param(PyObject *pSelf, PyObject *pArgs) |
| 2865 |
{ |
| 2866 |
int status; |
| 2867 |
PyObject *pCodecId; |
| 2868 |
pj_str_t codec_id; |
| 2869 |
pjmedia_codec_param param; |
| 2870 |
PyObj_pjmedia_codec_param *ret; |
| 2871 |
|
| 2872 |
PJ_UNUSED_ARG(pSelf); |
| 2873 |
|
| 2874 |
if (!PyArg_ParseTuple(pArgs, "O", &pCodecId)) { |
| 2875 |
return NULL; |
| 2876 |
} |
| 2877 |
|
| 2878 |
codec_id = PyString_ToPJ(pCodecId); |
| 2879 |
|
| 2880 |
status = pjsua_codec_get_param(&codec_id, ¶m); |
| 2881 |
if (status != PJ_SUCCESS) |
| 2882 |
return Py_BuildValue(""); |
| 2883 |
|
| 2884 |
ret = (PyObj_pjmedia_codec_param *) |
| 2885 |
pjmedia_codec_param_new(&PyTyp_pjmedia_codec_param, NULL, NULL); |
| 2886 |
|
| 2887 |
ret->info->avg_bps = param.info.avg_bps; |
| 2888 |
ret->info->channel_cnt = param.info.channel_cnt; |
| 2889 |
ret->info->clock_rate = param.info.clock_rate; |
| 2890 |
ret->info->frm_ptime = param.info.frm_ptime; |
| 2891 |
ret->info->pcm_bits_per_sample = param.info.pcm_bits_per_sample; |
| 2892 |
ret->info->pt = param.info.pt; |
| 2893 |
ret->setting->cng = param.setting.cng; |
| 2894 |
|
| 2895 |
|
| 2896 |
ret->setting->frm_per_pkt = param.setting.frm_per_pkt; |
| 2897 |
ret->setting->penh = param.setting.penh; |
| 2898 |
ret->setting->plc = param.setting.plc; |
| 2899 |
ret->setting->vad = param.setting.vad; |
| 2900 |
|
| 2901 |
return (PyObject*)ret; |
| 2902 |
} |
| 2903 |
|
| 2904 |
|
| 2905 |
|
| 2906 |
|
| 2907 |
|
| 2908 |
static PyObject *py_pjsua_codec_set_param(PyObject *pSelf, PyObject *pArgs) |
| 2909 |
{ |
| 2910 |
int status; |
| 2911 |
PyObject *pCodecId, *pCodecParam; |
| 2912 |
pj_str_t codec_id; |
| 2913 |
pjmedia_codec_param param; |
| 2914 |
|
| 2915 |
PJ_UNUSED_ARG(pSelf); |
| 2916 |
|
| 2917 |
if (!PyArg_ParseTuple(pArgs, "OO", &pCodecId, &pCodecParam)) { |
| 2918 |
return NULL; |
| 2919 |
} |
| 2920 |
|
| 2921 |
codec_id = PyString_ToPJ(pCodecId); |
| 2922 |
|
| 2923 |
if (pCodecParam != Py_None) { |
| 2924 |
PyObj_pjmedia_codec_param *obj; |
| 2925 |
|
| 2926 |
obj = (PyObj_pjmedia_codec_param *)pCodecParam; |
| 2927 |
|
| 2928 |
param.info.avg_bps = obj->info->avg_bps; |
| 2929 |
param.info.channel_cnt = obj->info->channel_cnt; |
| 2930 |
param.info.clock_rate = obj->info->clock_rate; |
| 2931 |
param.info.frm_ptime = obj->info->frm_ptime; |
| 2932 |
param.info.pcm_bits_per_sample = obj->info->pcm_bits_per_sample; |
| 2933 |
param.info.pt = obj->info->pt; |
| 2934 |
param.setting.cng = obj->setting->cng; |
| 2935 |
|
| 2936 |
|
| 2937 |
param.setting.frm_per_pkt = obj->setting->frm_per_pkt; |
| 2938 |
param.setting.penh = obj->setting->penh; |
| 2939 |
param.setting.plc = obj->setting->plc; |
| 2940 |
param.setting.vad = obj->setting->vad; |
| 2941 |
status = pjsua_codec_set_param(&codec_id, ¶m); |
| 2942 |
|
| 2943 |
} else { |
| 2944 |
status = pjsua_codec_set_param(&codec_id, NULL); |
| 2945 |
} |
| 2946 |
|
| 2947 |
return Py_BuildValue("i", status); |
| 2948 |
} |
| 2949 |
|
| 2950 |
static char pjsua_conf_get_max_ports_doc[] = |
| 2951 |
"int _pjsua.conf_get_max_ports () " |
| 2952 |
"Get maxinum number of conference ports."; |
| 2953 |
static char pjsua_conf_get_active_ports_doc[] = |
| 2954 |
"int _pjsua.conf_get_active_ports () " |
| 2955 |
"Get current number of active ports in the bridge."; |
| 2956 |
static char pjsua_enum_conf_ports_doc[] = |
| 2957 |
"int[] _pjsua.enum_conf_ports () " |
| 2958 |
"Enumerate all conference ports."; |
| 2959 |
static char pjsua_conf_get_port_info_doc[] = |
| 2960 |
"_pjsua.Conf_Port_Info _pjsua.conf_get_port_info (int id) " |
| 2961 |
"Get information about the specified conference port"; |
| 2962 |
static char pjsua_conf_remove_port_doc[] = |
| 2963 |
"int _pjsua.conf_remove_port (int id) " |
| 2964 |
"Remove arbitrary slot from the conference bridge. " |
| 2965 |
"Application should only call this function " |
| 2966 |
"if it registered the port manually."; |
| 2967 |
static char pjsua_conf_connect_doc[] = |
| 2968 |
"int _pjsua.conf_connect (int source, int sink) " |
| 2969 |
"Establish unidirectional media flow from souce to sink. " |
| 2970 |
"One source may transmit to multiple destinations/sink. " |
| 2971 |
"And if multiple sources are transmitting to the same sink, " |
| 2972 |
"the media will be mixed together. Source and sink may refer " |
| 2973 |
"to the same ID, effectively looping the media. " |
| 2974 |
"If bidirectional media flow is desired, application " |
| 2975 |
"needs to call this function twice, with the second " |
| 2976 |
"one having the arguments reversed."; |
| 2977 |
static char pjsua_conf_disconnect_doc[] = |
| 2978 |
"int _pjsua.conf_disconnect (int source, int sink) " |
| 2979 |
"Disconnect media flow from the source to destination port."; |
| 2980 |
static char pjsua_player_create_doc[] = |
| 2981 |
"int, int _pjsua.player_create (string filename, int options) " |
| 2982 |
"Create a file player, and automatically connect " |
| 2983 |
"this player to the conference bridge."; |
| 2984 |
static char pjsua_player_get_conf_port_doc[] = |
| 2985 |
"int _pjsua.player_get_conf_port (int) " |
| 2986 |
"Get conference port ID associated with player."; |
| 2987 |
static char pjsua_player_set_pos_doc[] = |
| 2988 |
"int _pjsua.player_set_pos (int id, int samples) " |
| 2989 |
"Set playback position."; |
| 2990 |
static char pjsua_player_destroy_doc[] = |
| 2991 |
"int _pjsua.player_destroy (int id) " |
| 2992 |
"Close the file, remove the player from the bridge, " |
| 2993 |
"and free resources associated with the file player."; |
| 2994 |
static char pjsua_recorder_create_doc[] = |
| 2995 |
"int, int _pjsua.recorder_create (string filename, " |
| 2996 |
"int enc_type, int enc_param, int max_size, int options) " |
| 2997 |
"Create a file recorder, and automatically connect this recorder " |
| 2998 |
"to the conference bridge. The recorder currently supports recording " |
| 2999 |
"WAV file, and on Windows, MP3 file. The type of the recorder to use " |
| 3000 |
"is determined by the extension of the file (e.g. '.wav' or '.mp3')."; |
| 3001 |
static char pjsua_recorder_get_conf_port_doc[] = |
| 3002 |
"int _pjsua.recorder_get_conf_port (int id) " |
| 3003 |
"Get conference port associated with recorder."; |
| 3004 |
static char pjsua_recorder_destroy_doc[] = |
| 3005 |
"int _pjsua.recorder_destroy (int id) " |
| 3006 |
"Destroy recorder (this will complete recording)."; |
| 3007 |
static char pjsua_enum_snd_devs_doc[] = |
| 3008 |
"_pjsua.PJMedia_Snd_Dev_Info[] _pjsua.enum_snd_devs (int count) " |
| 3009 |
"Enum sound devices."; |
| 3010 |
static char pjsua_get_snd_dev_doc[] = |
| 3011 |
"int, int _pjsua.get_snd_dev () " |
| 3012 |
"Get currently active sound devices. " |
| 3013 |
"If sound devices has not been created " |
| 3014 |
"(for example when pjsua_start() is not called), " |
| 3015 |
"it is possible that the function returns " |
| 3016 |
"PJ_SUCCESS with -1 as device IDs."; |
| 3017 |
static char pjsua_set_snd_dev_doc[] = |
| 3018 |
"int _pjsua.set_snd_dev (int capture_dev, int playback_dev) " |
| 3019 |
"Select or change sound device. Application may call this function " |
| 3020 |
"at any time to replace current sound device."; |
| 3021 |
static char pjsua_set_null_snd_dev_doc[] = |
| 3022 |
"int _pjsua.set_null_snd_dev () " |
| 3023 |
"Set pjsua to use null sound device. The null sound device only " |
| 3024 |
"provides the timing needed by the conference bridge, and will not " |
| 3025 |
"interract with any hardware."; |
| 3026 |
static char pjsua_set_ec_doc[] = |
| 3027 |
"int _pjsua.set_ec (int tail_ms, int options) " |
| 3028 |
"Configure the echo canceller tail length of the sound port."; |
| 3029 |
static char pjsua_get_ec_tail_doc[] = |
| 3030 |
"int _pjsua.get_ec_tail () " |
| 3031 |
"Get current echo canceller tail length."; |
| 3032 |
static char pjsua_enum_codecs_doc[] = |
| 3033 |
"_pjsua.Codec_Info[] _pjsua.enum_codecs () " |
| 3034 |
"Enum all supported codecs in the system."; |
| 3035 |
static char pjsua_codec_set_priority_doc[] = |
| 3036 |
"int _pjsua.codec_set_priority (string id, int priority) " |
| 3037 |
"Change codec priority."; |
| 3038 |
static char pjsua_codec_get_param_doc[] = |
| 3039 |
"_pjsua.PJMedia_Codec_Param _pjsua.codec_get_param (string id) " |
| 3040 |
"Get codec parameters"; |
| 3041 |
static char pjsua_codec_set_param_doc[] = |
| 3042 |
"int _pjsua.codec_set_param (string id, " |
| 3043 |
"_pjsua.PJMedia_Codec_Param param) " |
| 3044 |
"Set codec parameters."; |
| 3045 |
|
| 3046 |
|
| 3047 |
|
| 3048 |
|
| 3049 |
|
| 3050 |
|
| 3051 |
|
| 3052 |
|
| 3053 |
static PyObject *py_pjsua_call_get_max_count(PyObject *pSelf, PyObject *pArgs) |
| 3054 |
{ |
| 3055 |
int count; |
| 3056 |
|
| 3057 |
PJ_UNUSED_ARG(pSelf); |
| 3058 |
PJ_UNUSED_ARG(pArgs); |
| 3059 |
|
| 3060 |
count = pjsua_call_get_max_count(); |
| 3061 |
|
| 3062 |
return Py_BuildValue("i", count); |
| 3063 |
} |
| 3064 |
|
| 3065 |
|
| 3066 |
|
| 3067 |
|
| 3068 |
static PyObject *py_pjsua_call_get_count(PyObject *pSelf, PyObject *pArgs) |
| 3069 |
{ |
| 3070 |
int count; |
| 3071 |
|
| 3072 |
PJ_UNUSED_ARG(pSelf); |
| 3073 |
PJ_UNUSED_ARG(pArgs); |
| 3074 |
|
| 3075 |
count = pjsua_call_get_count(); |
| 3076 |
|
| 3077 |
return Py_BuildValue("i", count); |
| 3078 |
} |
| 3079 |
|
| 3080 |
|
| 3081 |
|
| 3082 |
|
| 3083 |
static PyObject *py_pjsua_enum_calls(PyObject *pSelf, PyObject *pArgs) |
| 3084 |
{ |
| 3085 |
pj_status_t status; |
| 3086 |
PyObject *ret; |
| 3087 |
pjsua_transport_id id[PJSUA_MAX_CALLS]; |
| 3088 |
unsigned c, i; |
| 3089 |
|
| 3090 |
PJ_UNUSED_ARG(pSelf); |
| 3091 |
PJ_UNUSED_ARG(pArgs); |
| 3092 |
|
| 3093 |
c = PJ_ARRAY_SIZE(id); |
| 3094 |
status = pjsua_enum_calls(id, &c); |
| 3095 |
if (status != PJ_SUCCESS) |
| 3096 |
c = 0; |
| 3097 |
|
| 3098 |
ret = PyList_New(c); |
| 3099 |
for (i = 0; i < c; i++) { |
| 3100 |
PyList_SetItem(ret, i, Py_BuildValue("i", id[i])); |
| 3101 |
} |
| 3102 |
|
| 3103 |
return (PyObject*)ret; |
| 3104 |
} |
| 3105 |
|
| 3106 |
|
| 3107 |
|
| 3108 |
|
| 3109 |
static PyObject *py_pjsua_call_make_call(PyObject *pSelf, PyObject *pArgs) |
| 3110 |
{ |
| 3111 |
int status; |
| 3112 |
int acc_id; |
| 3113 |
pj_str_t dst_uri; |
| 3114 |
PyObject *pDstUri, *pMsgData, *pUserData; |
| 3115 |
pjsua_call_setting option; |
| 3116 |
pjsua_msg_data msg_data; |
| 3117 |
int call_id; |
| 3118 |
pj_pool_t *pool = NULL; |
| 3119 |
|
| 3120 |
PJ_UNUSED_ARG(pSelf); |
| 3121 |
|
| 3122 |
pjsua_call_setting_default(&option); |
| 3123 |
if (!PyArg_ParseTuple(pArgs, "iOIOO", &acc_id, &pDstUri, &option.flag, |
| 3124 |
&pUserData, &pMsgData)) |
| 3125 |
{ |
| 3126 |
return NULL; |
| 3127 |
} |
| 3128 |
|
| 3129 |
dst_uri = PyString_ToPJ(pDstUri); |
| 3130 |
pjsua_msg_data_init(&msg_data); |
| 3131 |
|
| 3132 |
if (pMsgData != Py_None) { |
| 3133 |
PyObj_pjsua_msg_data * omd; |
| 3134 |
|
| 3135 |
omd = (PyObj_pjsua_msg_data *)pMsgData; |
| 3136 |
|
| 3137 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3138 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3139 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3140 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3141 |
} |
| 3142 |
|
| 3143 |
Py_XINCREF(pUserData); |
| 3144 |
|
| 3145 |
status = pjsua_call_make_call(acc_id, &dst_uri, |
| 3146 |
&option, (void*)pUserData, |
| 3147 |
&msg_data, &call_id); |
| 3148 |
if (pool != NULL) |
| 3149 |
pj_pool_release(pool); |
| 3150 |
|
| 3151 |
if (status != PJ_SUCCESS) { |
| 3152 |
Py_XDECREF(pUserData); |
| 3153 |
} |
| 3154 |
|
| 3155 |
return Py_BuildValue("ii", status, call_id); |
| 3156 |
} |
| 3157 |
|
| 3158 |
|
| 3159 |
|
| 3160 |
|
| 3161 |
static PyObject *py_pjsua_call_is_active(PyObject *pSelf, PyObject *pArgs) |
| 3162 |
{ |
| 3163 |
int call_id; |
| 3164 |
int is_active; |
| 3165 |
|
| 3166 |
PJ_UNUSED_ARG(pSelf); |
| 3167 |
|
| 3168 |
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { |
| 3169 |
return NULL; |
| 3170 |
} |
| 3171 |
|
| 3172 |
is_active = pjsua_call_is_active(call_id); |
| 3173 |
|
| 3174 |
return Py_BuildValue("i", is_active); |
| 3175 |
} |
| 3176 |
|
| 3177 |
|
| 3178 |
|
| 3179 |
|
| 3180 |
static PyObject *py_pjsua_call_has_media(PyObject *pSelf, PyObject *pArgs) |
| 3181 |
{ |
| 3182 |
int call_id; |
| 3183 |
int has_media; |
| 3184 |
|
| 3185 |
PJ_UNUSED_ARG(pSelf); |
| 3186 |
|
| 3187 |
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { |
| 3188 |
return NULL; |
| 3189 |
} |
| 3190 |
|
| 3191 |
has_media = pjsua_call_has_media(call_id); |
| 3192 |
|
| 3193 |
return Py_BuildValue("i", has_media); |
| 3194 |
} |
| 3195 |
|
| 3196 |
|
| 3197 |
|
| 3198 |
|
| 3199 |
static PyObject* py_pjsua_call_get_conf_port(PyObject *pSelf, PyObject *pArgs) |
| 3200 |
{ |
| 3201 |
int call_id; |
| 3202 |
int port_id; |
| 3203 |
|
| 3204 |
PJ_UNUSED_ARG(pSelf); |
| 3205 |
|
| 3206 |
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { |
| 3207 |
return NULL; |
| 3208 |
} |
| 3209 |
|
| 3210 |
port_id = pjsua_call_get_conf_port(call_id); |
| 3211 |
|
| 3212 |
return Py_BuildValue("i", port_id); |
| 3213 |
} |
| 3214 |
|
| 3215 |
|
| 3216 |
|
| 3217 |
|
| 3218 |
static PyObject* py_pjsua_call_get_info(PyObject *pSelf, PyObject *pArgs) |
| 3219 |
{ |
| 3220 |
int call_id; |
| 3221 |
int status; |
| 3222 |
PyObj_pjsua_call_info *ret; |
| 3223 |
pjsua_call_info info; |
| 3224 |
|
| 3225 |
PJ_UNUSED_ARG(pSelf); |
| 3226 |
|
| 3227 |
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { |
| 3228 |
return NULL; |
| 3229 |
} |
| 3230 |
|
| 3231 |
status = pjsua_call_get_info(call_id, &info); |
| 3232 |
if (status != PJ_SUCCESS) |
| 3233 |
return Py_BuildValue(""); |
| 3234 |
|
| 3235 |
ret = (PyObj_pjsua_call_info *)call_info_new(&PyTyp_pjsua_call_info, |
| 3236 |
NULL, NULL); |
| 3237 |
ret->acc_id = info.acc_id; |
| 3238 |
Py_XDECREF(ret->call_id); |
| 3239 |
ret->call_id = PyString_FromPJ(&info.call_id); |
| 3240 |
ret->conf_slot = info.conf_slot; |
| 3241 |
ret->connect_duration = info.connect_duration.sec * 1000 + |
| 3242 |
info.connect_duration.msec; |
| 3243 |
ret->total_duration = info.total_duration.sec * 1000 + |
| 3244 |
info.total_duration.msec; |
| 3245 |
ret->id = info.id; |
| 3246 |
ret->last_status = info.last_status; |
| 3247 |
Py_XDECREF(ret->last_status_text); |
| 3248 |
ret->last_status_text = PyString_FromPJ(&info.last_status_text); |
| 3249 |
Py_XDECREF(ret->local_contact); |
| 3250 |
ret->local_contact = PyString_FromPJ(&info.local_contact); |
| 3251 |
Py_XDECREF(ret->local_info); |
| 3252 |
ret->local_info = PyString_FromPJ(&info.local_info); |
| 3253 |
Py_XDECREF(ret->remote_contact); |
| 3254 |
ret->remote_contact = PyString_FromPJ(&info.remote_contact); |
| 3255 |
Py_XDECREF(ret->remote_info); |
| 3256 |
ret->remote_info = PyString_FromPJ(&info.remote_info); |
| 3257 |
ret->media_dir = info.media_dir; |
| 3258 |
ret->media_status = info.media_status; |
| 3259 |
ret->role = info.role; |
| 3260 |
ret->state = info.state; |
| 3261 |
Py_XDECREF(ret->state_text); |
| 3262 |
ret->state_text = PyString_FromPJ(&info.state_text); |
| 3263 |
|
| 3264 |
return (PyObject*)ret; |
| 3265 |
} |
| 3266 |
|
| 3267 |
|
| 3268 |
|
| 3269 |
|
| 3270 |
static PyObject *py_pjsua_call_set_user_data(PyObject *pSelf, PyObject *pArgs) |
| 3271 |
{ |
| 3272 |
int call_id; |
| 3273 |
PyObject *pUserData, *old_user_data; |
| 3274 |
int status; |
| 3275 |
|
| 3276 |
PJ_UNUSED_ARG(pSelf); |
| 3277 |
|
| 3278 |
if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &pUserData)) { |
| 3279 |
return NULL; |
| 3280 |
} |
| 3281 |
|
| 3282 |
old_user_data = (PyObject*) pjsua_call_get_user_data(call_id); |
| 3283 |
|
| 3284 |
if (old_user_data == pUserData) { |
| 3285 |
return Py_BuildValue("i", PJ_SUCCESS); |
| 3286 |
} |
| 3287 |
|
| 3288 |
Py_XINCREF(pUserData); |
| 3289 |
Py_XDECREF(old_user_data); |
| 3290 |
|
| 3291 |
status = pjsua_call_set_user_data(call_id, (void*)pUserData); |
| 3292 |
|
| 3293 |
if (status != PJ_SUCCESS) { |
| 3294 |
Py_XDECREF(pUserData); |
| 3295 |
} |
| 3296 |
|
| 3297 |
return Py_BuildValue("i", status); |
| 3298 |
} |
| 3299 |
|
| 3300 |
|
| 3301 |
|
| 3302 |
|
| 3303 |
static PyObject *py_pjsua_call_get_user_data(PyObject *pSelf, PyObject *pArgs) |
| 3304 |
{ |
| 3305 |
int call_id; |
| 3306 |
PyObject *user_data; |
| 3307 |
|
| 3308 |
PJ_UNUSED_ARG(pSelf); |
| 3309 |
|
| 3310 |
if (!PyArg_ParseTuple(pArgs, "i", &call_id)) { |
| 3311 |
return NULL; |
| 3312 |
} |
| 3313 |
|
| 3314 |
user_data = (PyObject*)pjsua_call_get_user_data(call_id); |
| 3315 |
return user_data ? Py_BuildValue("O", user_data) : Py_BuildValue(""); |
| 3316 |
} |
| 3317 |
|
| 3318 |
|
| 3319 |
|
| 3320 |
|
| 3321 |
static PyObject *py_pjsua_call_answer(PyObject *pSelf, PyObject *pArgs) |
| 3322 |
{ |
| 3323 |
int status; |
| 3324 |
int call_id; |
| 3325 |
pj_str_t * reason, tmp_reason; |
| 3326 |
PyObject *pReason; |
| 3327 |
unsigned code; |
| 3328 |
pjsua_msg_data msg_data; |
| 3329 |
PyObject * omdObj; |
| 3330 |
pj_pool_t * pool = NULL; |
| 3331 |
|
| 3332 |
PJ_UNUSED_ARG(pSelf); |
| 3333 |
|
| 3334 |
if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &pReason, &omdObj)) { |
| 3335 |
return NULL; |
| 3336 |
} |
| 3337 |
|
| 3338 |
if (pReason == Py_None) { |
| 3339 |
reason = NULL; |
| 3340 |
} else { |
| 3341 |
reason = &tmp_reason; |
| 3342 |
tmp_reason = PyString_ToPJ(pReason); |
| 3343 |
} |
| 3344 |
|
| 3345 |
pjsua_msg_data_init(&msg_data); |
| 3346 |
if (omdObj != Py_None) { |
| 3347 |
PyObj_pjsua_msg_data *omd; |
| 3348 |
|
| 3349 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3350 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3351 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3352 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3353 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3354 |
} |
| 3355 |
|
| 3356 |
status = pjsua_call_answer(call_id, code, reason, &msg_data); |
| 3357 |
|
| 3358 |
if (pool) |
| 3359 |
pj_pool_release(pool); |
| 3360 |
|
| 3361 |
return Py_BuildValue("i", status); |
| 3362 |
} |
| 3363 |
|
| 3364 |
|
| 3365 |
|
| 3366 |
|
| 3367 |
static PyObject *py_pjsua_call_hangup(PyObject *pSelf, PyObject *pArgs) |
| 3368 |
{ |
| 3369 |
int status; |
| 3370 |
int call_id; |
| 3371 |
pj_str_t *reason, tmp_reason; |
| 3372 |
PyObject *pReason; |
| 3373 |
unsigned code; |
| 3374 |
pjsua_msg_data msg_data; |
| 3375 |
PyObject *omdObj; |
| 3376 |
pj_pool_t *pool = NULL; |
| 3377 |
|
| 3378 |
PJ_UNUSED_ARG(pSelf); |
| 3379 |
|
| 3380 |
if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &pReason, |
| 3381 |
&omdObj)) |
| 3382 |
{ |
| 3383 |
return NULL; |
| 3384 |
} |
| 3385 |
|
| 3386 |
if (pReason == Py_None) { |
| 3387 |
reason = NULL; |
| 3388 |
} else { |
| 3389 |
reason = &tmp_reason; |
| 3390 |
tmp_reason = PyString_ToPJ(pReason); |
| 3391 |
} |
| 3392 |
|
| 3393 |
pjsua_msg_data_init(&msg_data); |
| 3394 |
if (omdObj != Py_None) { |
| 3395 |
PyObj_pjsua_msg_data *omd; |
| 3396 |
|
| 3397 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3398 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3399 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3400 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3401 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3402 |
} |
| 3403 |
|
| 3404 |
status = pjsua_call_hangup(call_id, code, reason, &msg_data); |
| 3405 |
if (pool) |
| 3406 |
pj_pool_release(pool); |
| 3407 |
|
| 3408 |
return Py_BuildValue("i", status); |
| 3409 |
} |
| 3410 |
|
| 3411 |
|
| 3412 |
|
| 3413 |
|
| 3414 |
static PyObject *py_pjsua_call_set_hold(PyObject *pSelf, PyObject *pArgs) |
| 3415 |
{ |
| 3416 |
int status; |
| 3417 |
int call_id; |
| 3418 |
pjsua_msg_data msg_data; |
| 3419 |
PyObject *omdObj; |
| 3420 |
pj_pool_t *pool = NULL; |
| 3421 |
|
| 3422 |
PJ_UNUSED_ARG(pSelf); |
| 3423 |
|
| 3424 |
if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omdObj)) { |
| 3425 |
return NULL; |
| 3426 |
} |
| 3427 |
|
| 3428 |
pjsua_msg_data_init(&msg_data); |
| 3429 |
if (omdObj != Py_None) { |
| 3430 |
PyObj_pjsua_msg_data *omd; |
| 3431 |
|
| 3432 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3433 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3434 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3435 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3436 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3437 |
} |
| 3438 |
|
| 3439 |
status = pjsua_call_set_hold(call_id, &msg_data); |
| 3440 |
|
| 3441 |
if (pool) |
| 3442 |
pj_pool_release(pool); |
| 3443 |
|
| 3444 |
return Py_BuildValue("i",status); |
| 3445 |
} |
| 3446 |
|
| 3447 |
|
| 3448 |
|
| 3449 |
|
| 3450 |
static PyObject *py_pjsua_call_reinvite(PyObject *pSelf, PyObject *pArgs) |
| 3451 |
{ |
| 3452 |
int status; |
| 3453 |
int call_id; |
| 3454 |
int unhold; |
| 3455 |
pjsua_msg_data msg_data; |
| 3456 |
PyObject *omdObj; |
| 3457 |
pj_pool_t *pool = NULL; |
| 3458 |
|
| 3459 |
PJ_UNUSED_ARG(pSelf); |
| 3460 |
|
| 3461 |
if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omdObj)) { |
| 3462 |
return NULL; |
| 3463 |
} |
| 3464 |
|
| 3465 |
pjsua_msg_data_init(&msg_data); |
| 3466 |
if (omdObj != Py_None) { |
| 3467 |
PyObj_pjsua_msg_data *omd; |
| 3468 |
|
| 3469 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3470 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3471 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3472 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3473 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3474 |
} |
| 3475 |
|
| 3476 |
status = pjsua_call_reinvite(call_id, unhold, &msg_data); |
| 3477 |
|
| 3478 |
if (pool) |
| 3479 |
pj_pool_release(pool); |
| 3480 |
|
| 3481 |
return Py_BuildValue("i", status); |
| 3482 |
} |
| 3483 |
|
| 3484 |
|
| 3485 |
|
| 3486 |
|
| 3487 |
static PyObject *py_pjsua_call_update(PyObject *pSelf, PyObject *pArgs) |
| 3488 |
{ |
| 3489 |
int status; |
| 3490 |
int call_id; |
| 3491 |
int option; |
| 3492 |
pjsua_msg_data msg_data; |
| 3493 |
PyObject *omdObj; |
| 3494 |
pj_pool_t *pool = NULL; |
| 3495 |
|
| 3496 |
PJ_UNUSED_ARG(pSelf); |
| 3497 |
|
| 3498 |
if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &option, &omdObj)) { |
| 3499 |
return NULL; |
| 3500 |
} |
| 3501 |
|
| 3502 |
pjsua_msg_data_init(&msg_data); |
| 3503 |
if (omdObj != Py_None) { |
| 3504 |
PyObj_pjsua_msg_data *omd; |
| 3505 |
|
| 3506 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3507 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3508 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3509 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3510 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3511 |
} |
| 3512 |
|
| 3513 |
status = pjsua_call_update(call_id, option, &msg_data); |
| 3514 |
|
| 3515 |
if (pool) |
| 3516 |
pj_pool_release(pool); |
| 3517 |
|
| 3518 |
return Py_BuildValue("i", status); |
| 3519 |
} |
| 3520 |
|
| 3521 |
|
| 3522 |
|
| 3523 |
|
| 3524 |
static PyObject *py_pjsua_call_send_request(PyObject *pSelf, PyObject *pArgs) |
| 3525 |
{ |
| 3526 |
int status; |
| 3527 |
int call_id; |
| 3528 |
PyObject *pMethod; |
| 3529 |
pj_str_t method; |
| 3530 |
pjsua_msg_data msg_data; |
| 3531 |
PyObject *omdObj; |
| 3532 |
pj_pool_t *pool = NULL; |
| 3533 |
|
| 3534 |
PJ_UNUSED_ARG(pSelf); |
| 3535 |
|
| 3536 |
if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &pMethod, &omdObj)) { |
| 3537 |
return NULL; |
| 3538 |
} |
| 3539 |
|
| 3540 |
if (!PyString_Check(pMethod)) { |
| 3541 |
return NULL; |
| 3542 |
} |
| 3543 |
|
| 3544 |
method = PyString_ToPJ(pMethod); |
| 3545 |
pjsua_msg_data_init(&msg_data); |
| 3546 |
|
| 3547 |
if (omdObj != Py_None) { |
| 3548 |
PyObj_pjsua_msg_data *omd; |
| 3549 |
|
| 3550 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3551 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3552 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3553 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3554 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3555 |
} |
| 3556 |
|
| 3557 |
status = pjsua_call_send_request(call_id, &method, &msg_data); |
| 3558 |
|
| 3559 |
if (pool) |
| 3560 |
pj_pool_release(pool); |
| 3561 |
|
| 3562 |
return Py_BuildValue("i", status); |
| 3563 |
} |
| 3564 |
|
| 3565 |
|
| 3566 |
|
| 3567 |
|
| 3568 |
static PyObject *py_pjsua_call_xfer(PyObject *pSelf, PyObject *pArgs) |
| 3569 |
{ |
| 3570 |
int status; |
| 3571 |
int call_id; |
| 3572 |
pj_str_t dest; |
| 3573 |
PyObject *pDstUri; |
| 3574 |
pjsua_msg_data msg_data; |
| 3575 |
PyObject *omdObj; |
| 3576 |
pj_pool_t *pool = NULL; |
| 3577 |
|
| 3578 |
PJ_UNUSED_ARG(pSelf); |
| 3579 |
|
| 3580 |
if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &pDstUri, &omdObj)) { |
| 3581 |
return NULL; |
| 3582 |
} |
| 3583 |
|
| 3584 |
if (!PyString_Check(pDstUri)) |
| 3585 |
return NULL; |
| 3586 |
|
| 3587 |
dest = PyString_ToPJ(pDstUri); |
| 3588 |
pjsua_msg_data_init(&msg_data); |
| 3589 |
|
| 3590 |
if (omdObj != Py_None) { |
| 3591 |
PyObj_pjsua_msg_data *omd; |
| 3592 |
|
| 3593 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3594 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3595 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3596 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3597 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3598 |
} |
| 3599 |
|
| 3600 |
status = pjsua_call_xfer(call_id, &dest, &msg_data); |
| 3601 |
|
| 3602 |
if (pool) |
| 3603 |
pj_pool_release(pool); |
| 3604 |
|
| 3605 |
return Py_BuildValue("i", status); |
| 3606 |
} |
| 3607 |
|
| 3608 |
|
| 3609 |
|
| 3610 |
|
| 3611 |
static PyObject *py_pjsua_call_xfer_replaces(PyObject *pSelf, PyObject *pArgs) |
| 3612 |
{ |
| 3613 |
int status; |
| 3614 |
int call_id; |
| 3615 |
int dest_call_id; |
| 3616 |
unsigned options; |
| 3617 |
pjsua_msg_data msg_data; |
| 3618 |
PyObject *omdObj; |
| 3619 |
pj_pool_t *pool = NULL; |
| 3620 |
|
| 3621 |
PJ_UNUSED_ARG(pSelf); |
| 3622 |
|
| 3623 |
if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &dest_call_id, |
| 3624 |
&options, &omdObj)) |
| 3625 |
{ |
| 3626 |
return NULL; |
| 3627 |
} |
| 3628 |
|
| 3629 |
pjsua_msg_data_init(&msg_data); |
| 3630 |
|
| 3631 |
if (omdObj != Py_None) { |
| 3632 |
PyObj_pjsua_msg_data *omd; |
| 3633 |
|
| 3634 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3635 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3636 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3637 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3638 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3639 |
} |
| 3640 |
|
| 3641 |
status = pjsua_call_xfer_replaces(call_id, dest_call_id, options, |
| 3642 |
&msg_data); |
| 3643 |
|
| 3644 |
if (pool) |
| 3645 |
pj_pool_release(pool); |
| 3646 |
|
| 3647 |
return Py_BuildValue("i", status); |
| 3648 |
} |
| 3649 |
|
| 3650 |
|
| 3651 |
|
| 3652 |
|
| 3653 |
static PyObject *py_pjsua_call_dial_dtmf(PyObject *pSelf, PyObject *pArgs) |
| 3654 |
{ |
| 3655 |
int call_id; |
| 3656 |
PyObject *pDigits; |
| 3657 |
pj_str_t digits; |
| 3658 |
int status; |
| 3659 |
|
| 3660 |
PJ_UNUSED_ARG(pSelf); |
| 3661 |
|
| 3662 |
if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &pDigits)) { |
| 3663 |
return NULL; |
| 3664 |
} |
| 3665 |
|
| 3666 |
if (!PyString_Check(pDigits)) |
| 3667 |
return Py_BuildValue("i", PJ_EINVAL); |
| 3668 |
|
| 3669 |
digits = PyString_ToPJ(pDigits); |
| 3670 |
status = pjsua_call_dial_dtmf(call_id, &digits); |
| 3671 |
|
| 3672 |
return Py_BuildValue("i", status); |
| 3673 |
} |
| 3674 |
|
| 3675 |
|
| 3676 |
|
| 3677 |
|
| 3678 |
static PyObject *py_pjsua_call_send_im(PyObject *pSelf, PyObject *pArgs) |
| 3679 |
{ |
| 3680 |
int status; |
| 3681 |
int call_id; |
| 3682 |
pj_str_t content; |
| 3683 |
pj_str_t * mime_type, tmp_mime_type; |
| 3684 |
PyObject *pMimeType, *pContent, *omdObj; |
| 3685 |
pjsua_msg_data msg_data; |
| 3686 |
int user_data; |
| 3687 |
pj_pool_t *pool = NULL; |
| 3688 |
|
| 3689 |
PJ_UNUSED_ARG(pSelf); |
| 3690 |
|
| 3691 |
if (!PyArg_ParseTuple(pArgs, "iOOOi", &call_id, &pMimeType, &pContent, |
| 3692 |
&omdObj, &user_data)) |
| 3693 |
{ |
| 3694 |
return NULL; |
| 3695 |
} |
| 3696 |
|
| 3697 |
if (!PyString_Check(pContent)) |
| 3698 |
return Py_BuildValue("i", PJ_EINVAL); |
| 3699 |
|
| 3700 |
content = PyString_ToPJ(pContent); |
| 3701 |
|
| 3702 |
if (PyString_Check(pMimeType)) { |
| 3703 |
mime_type = &tmp_mime_type; |
| 3704 |
tmp_mime_type = PyString_ToPJ(pMimeType); |
| 3705 |
} else { |
| 3706 |
mime_type = NULL; |
| 3707 |
} |
| 3708 |
|
| 3709 |
pjsua_msg_data_init(&msg_data); |
| 3710 |
if (omdObj != Py_None) { |
| 3711 |
PyObj_pjsua_msg_data * omd; |
| 3712 |
|
| 3713 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3714 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3715 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3716 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3717 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3718 |
} |
| 3719 |
|
| 3720 |
status = pjsua_call_send_im(call_id, mime_type, &content, |
| 3721 |
&msg_data, (void*)(long)user_data); |
| 3722 |
|
| 3723 |
if (pool) |
| 3724 |
pj_pool_release(pool); |
| 3725 |
|
| 3726 |
return Py_BuildValue("i", status); |
| 3727 |
} |
| 3728 |
|
| 3729 |
|
| 3730 |
|
| 3731 |
|
| 3732 |
static PyObject *py_pjsua_call_send_typing_ind(PyObject *pSelf, |
| 3733 |
PyObject *pArgs) |
| 3734 |
{ |
| 3735 |
int status; |
| 3736 |
int call_id; |
| 3737 |
int is_typing; |
| 3738 |
pjsua_msg_data msg_data; |
| 3739 |
PyObject *omdObj; |
| 3740 |
pj_pool_t *pool = NULL; |
| 3741 |
|
| 3742 |
PJ_UNUSED_ARG(pSelf); |
| 3743 |
|
| 3744 |
if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omdObj)) { |
| 3745 |
return NULL; |
| 3746 |
} |
| 3747 |
|
| 3748 |
pjsua_msg_data_init(&msg_data); |
| 3749 |
if (omdObj != Py_None) { |
| 3750 |
PyObj_pjsua_msg_data *omd; |
| 3751 |
|
| 3752 |
omd = (PyObj_pjsua_msg_data *)omdObj; |
| 3753 |
msg_data.content_type = PyString_ToPJ(omd->content_type); |
| 3754 |
msg_data.msg_body = PyString_ToPJ(omd->msg_body); |
| 3755 |
pool = pjsua_pool_create("pytmp", POOL_SIZE, POOL_SIZE); |
| 3756 |
translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 3757 |
} |
| 3758 |
|
| 3759 |
status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data); |
| 3760 |
|
| 3761 |
if (pool) |
| 3762 |
pj_pool_release(pool); |
| 3763 |
|
| 3764 |
return Py_BuildValue("i", status); |
| 3765 |
} |
| 3766 |
|
| 3767 |
|
| 3768 |
|
| 3769 |
|
| 3770 |
static PyObject *py_pjsua_call_hangup_all(PyObject *pSelf, PyObject *pArgs) |
| 3771 |
{ |
| 3772 |
PJ_UNUSED_ARG(pSelf); |
| 3773 |
PJ_UNUSED_ARG(pArgs); |
| 3774 |
|
| 3775 |
pjsua_call_hangup_all(); |
| 3776 |
|
| 3777 |
return Py_BuildValue(""); |
| 3778 |
} |
| 3779 |
|
| 3780 |
|
| 3781 |
|
| 3782 |
|
| 3783 |
static PyObject *py_pjsua_call_dump(PyObject *pSelf, PyObject *pArgs) |
| 3784 |
{ |
| 3785 |
int call_id; |
| 3786 |
int with_media; |
| 3787 |
PyObject *ret; |
| 3788 |
PyObject *pIndent; |
| 3789 |
char *buffer; |
| 3790 |
char *indent; |
| 3791 |
unsigned maxlen; |
| 3792 |
int status; |
| 3793 |
|
| 3794 |
PJ_UNUSED_ARG(pSelf); |
| 3795 |
|
| 3796 |
if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media, |
| 3797 |
&maxlen, &pIndent)) |
| 3798 |
{ |
| 3799 |
return NULL; |
| 3800 |
} |
| 3801 |
|
| 3802 |
buffer = (char*) malloc(maxlen * sizeof(char)); |
| 3803 |
indent = PyString_AsString(pIndent); |
| 3804 |
|
| 3805 |
status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent); |
| 3806 |
if (status != PJ_SUCCESS) { |
| 3807 |
free(buffer); |
| 3808 |
return PyString_FromString(""); |
| 3809 |
} |
| 3810 |
|
| 3811 |
ret = PyString_FromString(buffer); |
| 3812 |
free(buffer); |
| 3813 |
return (PyObject*)ret; |
| 3814 |
} |
| 3815 |
|
| 3816 |
|
| 3817 |
|
| 3818 |
|
| 3819 |
|
| 3820 |
|
| 3821 |
static PyObject *py_pjsua_dump(PyObject *pSelf, PyObject *pArgs) |
| 3822 |
{ |
| 3823 |
int detail; |
| 3824 |
|
| 3825 |
PJ_UNUSED_ARG(pSelf); |
| 3826 |
|
| 3827 |
if (!PyArg_ParseTuple(pArgs, "i", &detail)) { |
| 3828 |
return NULL; |
| 3829 |
} |
| 3830 |
|
| 3831 |
pjsua_dump(detail); |
| 3832 |
|
| 3833 |
return Py_BuildValue(""); |
| 3834 |
} |
| 3835 |
|
| 3836 |
|
| 3837 |
|
| 3838 |
|
| 3839 |
|
| 3840 |
static PyObject *py_pj_strerror(PyObject *pSelf, PyObject *pArgs) |
| 3841 |
{ |
| 3842 |
int err; |
| 3843 |
char err_msg[PJ_ERR_MSG_SIZE]; |
| 3844 |
pj_str_t ret; |
| 3845 |
|
| 3846 |
PJ_UNUSED_ARG(pSelf); |
| 3847 |
|
| 3848 |
if (!PyArg_ParseTuple(pArgs, "i", &err)) { |
| 3849 |
return NULL; |
| 3850 |
} |
| 3851 |
|
| 3852 |
ret = pj_strerror(err, err_msg, sizeof(err_msg)); |
| 3853 |
|
| 3854 |
return PyString_FromStringAndSize(err_msg, ret.slen); |
| 3855 |
} |
| 3856 |
|
| 3857 |
|
| 3858 |
|
| 3859 |
|
| 3860 |
|
| 3861 |
static PyObject *py_pj_parse_simple_sip(PyObject *pSelf, PyObject *pArgs) |
| 3862 |
{ |
| 3863 |
const char *arg_uri; |
| 3864 |
pj_pool_t *pool; |
| 3865 |
char tmp[PJSIP_MAX_URL_SIZE]; |
| 3866 |
pjsip_uri *uri; |
| 3867 |
pjsip_sip_uri *sip_uri; |
| 3868 |
PyObject *ret, *item; |
| 3869 |
|
| 3870 |
PJ_UNUSED_ARG(pSelf); |
| 3871 |
|
| 3872 |
if (!PyArg_ParseTuple(pArgs, "s", &arg_uri)) { |
| 3873 |
return NULL; |
| 3874 |
} |
| 3875 |
|
| 3876 |
pj_ansi_strxcpy(tmp, arg_uri, sizeof(tmp)); |
| 3877 |
|
| 3878 |
pool = pjsua_pool_create("py_pj_parse_simple_sip", 512, 512); |
| 3879 |
uri = pjsip_parse_uri(pool, tmp, strlen(tmp), 0); |
| 3880 |
|
| 3881 |
if (uri == NULL || (!PJSIP_URI_SCHEME_IS_SIP(uri) && |
| 3882 |
!PJSIP_URI_SCHEME_IS_SIPS(uri))) { |
| 3883 |
pj_pool_release(pool); |
| 3884 |
return Py_BuildValue(""); |
| 3885 |
} |
| 3886 |
|
| 3887 |
ret = PyTuple_New(5); |
| 3888 |
sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(uri); |
| 3889 |
|
| 3890 |
|
| 3891 |
item = PyString_FromPJ(pjsip_uri_get_scheme(uri)); |
| 3892 |
PyTuple_SetItem(ret, 0, item); |
| 3893 |
|
| 3894 |
|
| 3895 |
item = PyString_FromPJ(&sip_uri->user); |
| 3896 |
PyTuple_SetItem(ret, 1, item); |
| 3897 |
|
| 3898 |
|
| 3899 |
item = PyString_FromPJ(&sip_uri->host); |
| 3900 |
PyTuple_SetItem(ret, 2, item); |
| 3901 |
|
| 3902 |
|
| 3903 |
if (sip_uri->port == 5060) { |
| 3904 |
sip_uri->port = 0; |
| 3905 |
} |
| 3906 |
item = Py_BuildValue("i", sip_uri->port); |
| 3907 |
PyTuple_SetItem(ret, 3, item); |
| 3908 |
|
| 3909 |
|
| 3910 |
if (pj_stricmp2(&sip_uri->transport_param, "udp")) { |
| 3911 |
sip_uri->transport_param.ptr = ""; |
| 3912 |
sip_uri->transport_param.slen = 0; |
| 3913 |
} |
| 3914 |
item = PyString_FromPJ(&sip_uri->transport_param); |
| 3915 |
PyTuple_SetItem(ret, 4, item); |
| 3916 |
|
| 3917 |
pj_pool_release(pool); |
| 3918 |
return ret; |
| 3919 |
} |
| 3920 |
|
| 3921 |
|
| 3922 |
static char pjsua_call_get_max_count_doc[] = |
| 3923 |
"int _pjsua.call_get_max_count () " |
| 3924 |
"Get maximum number of calls configured in pjsua."; |
| 3925 |
static char pjsua_call_get_count_doc[] = |
| 3926 |
"int _pjsua.call_get_count () " |
| 3927 |
"Get number of currently active calls."; |
| 3928 |
static char pjsua_enum_calls_doc[] = |
| 3929 |
"int[] _pjsua.enum_calls () " |
| 3930 |
"Get maximum number of calls configured in pjsua."; |
| 3931 |
static char pjsua_call_make_call_doc[] = |
| 3932 |
"int,int _pjsua.call_make_call (int acc_id, string dst_uri, int options," |
| 3933 |
"int user_data, _pjsua.Msg_Data msg_data) " |
| 3934 |
"Make outgoing call to the specified URI using the specified account."; |
| 3935 |
static char pjsua_call_is_active_doc[] = |
| 3936 |
"int _pjsua.call_is_active (int call_id) " |
| 3937 |
"Check if the specified call has active INVITE session and the INVITE " |
| 3938 |
"session has not been disconnected."; |
| 3939 |
static char pjsua_call_has_media_doc[] = |
| 3940 |
"int _pjsua.call_has_media (int call_id) " |
| 3941 |
"Check if call has an active media session."; |
| 3942 |
static char pjsua_call_get_conf_port_doc[] = |
| 3943 |
"int _pjsua.call_get_conf_port (int call_id) " |
| 3944 |
"Get the conference port identification associated with the call."; |
| 3945 |
static char pjsua_call_get_info_doc[] = |
| 3946 |
"_pjsua.Call_Info _pjsua.call_get_info (int call_id) " |
| 3947 |
"Obtain detail information about the specified call."; |
| 3948 |
static char pjsua_call_set_user_data_doc[] = |
| 3949 |
"int _pjsua.call_set_user_data (int call_id, int user_data) " |
| 3950 |
"Attach application specific data to the call."; |
| 3951 |
static char pjsua_call_get_user_data_doc[] = |
| 3952 |
"int _pjsua.call_get_user_data (int call_id) " |
| 3953 |
"Get user data attached to the call."; |
| 3954 |
static char pjsua_call_answer_doc[] = |
| 3955 |
"int _pjsua.call_answer (int call_id, int code, string reason, " |
| 3956 |
"_pjsua.Msg_Data msg_data) " |
| 3957 |
"Send response to incoming INVITE request."; |
| 3958 |
static char pjsua_call_hangup_doc[] = |
| 3959 |
"int _pjsua.call_hangup (int call_id, int code, string reason, " |
| 3960 |
"_pjsua.Msg_Data msg_data) " |
| 3961 |
"Hangup call by using method that is appropriate according " |
| 3962 |
"to the call state."; |
| 3963 |
static char pjsua_call_set_hold_doc[] = |
| 3964 |
"int _pjsua.call_set_hold (int call_id, _pjsua.Msg_Data msg_data) " |
| 3965 |
"Put the specified call on hold."; |
| 3966 |
static char pjsua_call_reinvite_doc[] = |
| 3967 |
"int _pjsua.call_reinvite (int call_id, int unhold, " |
| 3968 |
"_pjsua.Msg_Data msg_data) " |
| 3969 |
"Send re-INVITE (to release hold)."; |
| 3970 |
static char pjsua_call_xfer_doc[] = |
| 3971 |
"int _pjsua.call_xfer (int call_id, string dest, " |
| 3972 |
"_pjsua.Msg_Data msg_data) " |
| 3973 |
"Initiate call transfer to the specified address. " |
| 3974 |
"This function will send REFER request to instruct remote call party " |
| 3975 |
"to initiate a new INVITE session to the specified destination/target."; |
| 3976 |
static char pjsua_call_xfer_replaces_doc[] = |
| 3977 |
"int _pjsua.call_xfer_replaces (int call_id, int dest_call_id, " |
| 3978 |
"int options, _pjsua.Msg_Data msg_data) " |
| 3979 |
"Initiate attended call transfer. This function will send REFER request " |
| 3980 |
"to instruct remote call party to initiate new INVITE session to the URL " |
| 3981 |
"of dest_call_id. The party at dest_call_id then should 'replace' the call" |
| 3982 |
"with us with the new call from the REFER recipient."; |
| 3983 |
static char pjsua_call_dial_dtmf_doc[] = |
| 3984 |
"int _pjsua.call_dial_dtmf (int call_id, string digits) " |
| 3985 |
"Send DTMF digits to remote using RFC 2833 payload formats."; |
| 3986 |
static char pjsua_call_send_im_doc[] = |
| 3987 |
"int _pjsua.call_send_im (int call_id, string mime_type, string content," |
| 3988 |
"_pjsua.Msg_Data msg_data, int user_data) " |
| 3989 |
"Send instant messaging inside INVITE session."; |
| 3990 |
static char pjsua_call_send_typing_ind_doc[] = |
| 3991 |
"int _pjsua.call_send_typing_ind (int call_id, int is_typing, " |
| 3992 |
"_pjsua.Msg_Data msg_data) " |
| 3993 |
"Send IM typing indication inside INVITE session."; |
| 3994 |
static char pjsua_call_hangup_all_doc[] = |
| 3995 |
"void _pjsua.call_hangup_all () " |
| 3996 |
"Terminate all calls."; |
| 3997 |
static char pjsua_call_dump_doc[] = |
| 3998 |
"int _pjsua.call_dump (int call_id, int with_media, int maxlen, " |
| 3999 |
"string indent) " |
| 4000 |
"Dump call and media statistics to string."; |
| 4001 |
|
| 4002 |
|
| 4003 |
|
| 4004 |
|
| 4005 |
|
| 4006 |
|
| 4007 |
static PyMethodDef py_pjsua_methods[] = |
| 4008 |
{ |
| 4009 |
{ |
| 4010 |
"thread_register", py_pjsua_thread_register, METH_VARARGS, |
| 4011 |
pjsua_thread_register_doc |
| 4012 |
}, |
| 4013 |
{ |
| 4014 |
"perror", py_pjsua_perror, METH_VARARGS, pjsua_perror_doc |
| 4015 |
}, |
| 4016 |
{ |
| 4017 |
"create", py_pjsua_create, METH_VARARGS, pjsua_create_doc |
| 4018 |
}, |
| 4019 |
{ |
| 4020 |
"init", py_pjsua_init, METH_VARARGS, pjsua_init_doc |
| 4021 |
}, |
| 4022 |
{ |
| 4023 |
"start", py_pjsua_start, METH_VARARGS, pjsua_start_doc |
| 4024 |
}, |
| 4025 |
{ |
| 4026 |
"destroy", py_pjsua_destroy, METH_VARARGS, pjsua_destroy_doc |
| 4027 |
}, |
| 4028 |
{ |
| 4029 |
"handle_events", py_pjsua_handle_events, METH_VARARGS, |
| 4030 |
pjsua_handle_events_doc |
| 4031 |
}, |
| 4032 |
{ |
| 4033 |
"verify_sip_url", py_pjsua_verify_sip_url, METH_VARARGS, |
| 4034 |
pjsua_verify_sip_url_doc |
| 4035 |
}, |
| 4036 |
{ |
| 4037 |
"reconfigure_logging", py_pjsua_reconfigure_logging, METH_VARARGS, |
| 4038 |
pjsua_reconfigure_logging_doc |
| 4039 |
}, |
| 4040 |
{ |
| 4041 |
"logging_config_default", py_pjsua_logging_config_default, |
| 4042 |
METH_VARARGS, pjsua_logging_config_default_doc |
| 4043 |
}, |
| 4044 |
{ |
| 4045 |
"config_default", py_pjsua_config_default, METH_VARARGS, |
| 4046 |
pjsua_config_default_doc |
| 4047 |
}, |
| 4048 |
{ |
| 4049 |
"media_config_default", py_pjsua_media_config_default, METH_VARARGS, |
| 4050 |
pjsua_media_config_default_doc |
| 4051 |
}, |
| 4052 |
|
| 4053 |
|
| 4054 |
{ |
| 4055 |
"msg_data_init", py_pjsua_msg_data_init, METH_VARARGS, |
| 4056 |
pjsua_msg_data_init_doc |
| 4057 |
}, |
| 4058 |
{ |
| 4059 |
"transport_config_default", py_pjsua_transport_config_default, |
| 4060 |
METH_VARARGS,pjsua_transport_config_default_doc |
| 4061 |
}, |
| 4062 |
{ |
| 4063 |
"transport_create", py_pjsua_transport_create, METH_VARARGS, |
| 4064 |
pjsua_transport_create_doc |
| 4065 |
}, |
| 4066 |
{ |
| 4067 |
"transport_enum_transports", py_pjsua_enum_transports, METH_VARARGS, |
| 4068 |
pjsua_enum_transports_doc |
| 4069 |
}, |
| 4070 |
{ |
| 4071 |
"transport_get_info", py_pjsua_transport_get_info, METH_VARARGS, |
| 4072 |
pjsua_transport_get_info_doc |
| 4073 |
}, |
| 4074 |
|
| 4075 |
|
| 4076 |
|
| 4077 |
|
| 4078 |
|
| 4079 |
|
| 4080 |
|
| 4081 |
|
| 4082 |
|
| 4083 |
|
| 4084 |
{ |
| 4085 |
"transport_close", py_pjsua_transport_close, METH_VARARGS, |
| 4086 |
pjsua_transport_close_doc |
| 4087 |
}, |
| 4088 |
{ |
| 4089 |
"acc_config_default", py_pjsua_acc_config_default, METH_VARARGS, |
| 4090 |
pjsua_acc_config_default_doc |
| 4091 |
}, |
| 4092 |
{ |
| 4093 |
"acc_get_count", py_pjsua_acc_get_count, METH_VARARGS, |
| 4094 |
pjsua_acc_get_count_doc |
| 4095 |
}, |
| 4096 |
{ |
| 4097 |
"acc_is_valid", py_pjsua_acc_is_valid, METH_VARARGS, |
| 4098 |
pjsua_acc_is_valid_doc |
| 4099 |
}, |
| 4100 |
{ |
| 4101 |
"acc_set_default", py_pjsua_acc_set_default, METH_VARARGS, |
| 4102 |
pjsua_acc_set_default_doc |
| 4103 |
}, |
| 4104 |
{ |
| 4105 |
"acc_get_default", py_pjsua_acc_get_default, METH_VARARGS, |
| 4106 |
pjsua_acc_get_default_doc |
| 4107 |
}, |
| 4108 |
{ |
| 4109 |
"acc_add", py_pjsua_acc_add, METH_VARARGS, |
| 4110 |
pjsua_acc_add_doc |
| 4111 |
}, |
| 4112 |
{ |
| 4113 |
"acc_add_local", py_pjsua_acc_add_local, METH_VARARGS, |
| 4114 |
pjsua_acc_add_local_doc |
| 4115 |
}, |
| 4116 |
{ |
| 4117 |
"acc_del", py_pjsua_acc_del, METH_VARARGS, |
| 4118 |
pjsua_acc_del_doc |
| 4119 |
}, |
| 4120 |
{ |
| 4121 |
"acc_set_user_data", py_pjsua_acc_set_user_data, METH_VARARGS, |
| 4122 |
"Accociate user data with the account" |
| 4123 |
}, |
| 4124 |
{ |
| 4125 |
"acc_get_user_data", py_pjsua_acc_get_user_data, METH_VARARGS, |
| 4126 |
"Get account's user data" |
| 4127 |
}, |
| 4128 |
{ |
| 4129 |
"acc_modify", py_pjsua_acc_modify, METH_VARARGS, |
| 4130 |
pjsua_acc_modify_doc |
| 4131 |
}, |
| 4132 |
{ |
| 4133 |
"acc_set_online_status", py_pjsua_acc_set_online_status, METH_VARARGS, |
| 4134 |
pjsua_acc_set_online_status_doc |
| 4135 |
}, |
| 4136 |
{ |
| 4137 |
"acc_set_online_status2", py_pjsua_acc_set_online_status2, METH_VARARGS, |
| 4138 |
pjsua_acc_set_online_status2_doc |
| 4139 |
}, |
| 4140 |
{ |
| 4141 |
"acc_set_registration", py_pjsua_acc_set_registration, METH_VARARGS, |
| 4142 |
pjsua_acc_set_registration_doc |
| 4143 |
}, |
| 4144 |
{ |
| 4145 |
"acc_get_info", py_pjsua_acc_get_info, METH_VARARGS, |
| 4146 |
pjsua_acc_get_info_doc |
| 4147 |
}, |
| 4148 |
{ |
| 4149 |
"acc_pres_notify", py_pjsua_acc_pres_notify, METH_VARARGS, |
| 4150 |
"Accept or reject subscription request" |
| 4151 |
}, |
| 4152 |
{ |
| 4153 |
"enum_accs", py_pjsua_enum_accs, METH_VARARGS, |
| 4154 |
pjsua_enum_accs_doc |
| 4155 |
}, |
| 4156 |
{ |
| 4157 |
"acc_enum_info", py_pjsua_acc_enum_info, METH_VARARGS, |
| 4158 |
pjsua_acc_enum_info_doc |
| 4159 |
}, |
| 4160 |
{ |
| 4161 |
"acc_set_transport", py_pjsua_acc_set_transport, METH_VARARGS, |
| 4162 |
"Lock transport to use the specified transport" |
| 4163 |
}, |
| 4164 |
{ |
| 4165 |
"buddy_config_default", py_pjsua_buddy_config_default, METH_VARARGS, |
| 4166 |
pjsua_buddy_config_default_doc |
| 4167 |
}, |
| 4168 |
{ |
| 4169 |
"get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS, |
| 4170 |
pjsua_get_buddy_count_doc |
| 4171 |
}, |
| 4172 |
{ |
| 4173 |
"buddy_is_valid", py_pjsua_buddy_is_valid, METH_VARARGS, |
| 4174 |
pjsua_buddy_is_valid_doc |
| 4175 |
}, |
| 4176 |
{ |
| 4177 |
"enum_buddies", py_pjsua_enum_buddies, METH_VARARGS, |
| 4178 |
pjsua_enum_buddies_doc |
| 4179 |
}, |
| 4180 |
{ |
| 4181 |
"buddy_find", py_pjsua_buddy_find, METH_VARARGS, |
| 4182 |
"Find buddy with the specified URI" |
| 4183 |
}, |
| 4184 |
{ |
| 4185 |
"buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS, |
| 4186 |
pjsua_buddy_get_info_doc |
| 4187 |
}, |
| 4188 |
{ |
| 4189 |
"buddy_add", py_pjsua_buddy_add, METH_VARARGS, |
| 4190 |
pjsua_buddy_add_doc |
| 4191 |
}, |
| 4192 |
{ |
| 4193 |
"buddy_del", py_pjsua_buddy_del, METH_VARARGS, |
| 4194 |
pjsua_buddy_del_doc |
| 4195 |
}, |
| 4196 |
{ |
| 4197 |
"buddy_set_user_data", py_pjsua_buddy_set_user_data, METH_VARARGS, |
| 4198 |
"Associate user data to the buddy object" |
| 4199 |
}, |
| 4200 |
{ |
| 4201 |
"buddy_get_user_data", py_pjsua_buddy_get_user_data, METH_VARARGS, |
| 4202 |
"Get buddy user data" |
| 4203 |
}, |
| 4204 |
{ |
| 4205 |
"buddy_subscribe_pres", py_pjsua_buddy_subscribe_pres, METH_VARARGS, |
| 4206 |
pjsua_buddy_subscribe_pres_doc |
| 4207 |
}, |
| 4208 |
{ |
| 4209 |
"pres_dump", py_pjsua_pres_dump, METH_VARARGS, |
| 4210 |
pjsua_pres_dump_doc |
| 4211 |
}, |
| 4212 |
{ |
| 4213 |
"im_send", py_pjsua_im_send, METH_VARARGS, |
| 4214 |
pjsua_im_send_doc |
| 4215 |
}, |
| 4216 |
{ |
| 4217 |
"im_typing", py_pjsua_im_typing, METH_VARARGS, |
| 4218 |
pjsua_im_typing_doc |
| 4219 |
}, |
| 4220 |
{ |
| 4221 |
"conf_get_max_ports", py_pjsua_conf_get_max_ports, METH_VARARGS, |
| 4222 |
pjsua_conf_get_max_ports_doc |
| 4223 |
}, |
| 4224 |
{ |
| 4225 |
"conf_get_active_ports", py_pjsua_conf_get_active_ports, METH_VARARGS, |
| 4226 |
pjsua_conf_get_active_ports_doc |
| 4227 |
}, |
| 4228 |
{ |
| 4229 |
"enum_conf_ports", py_pjsua_enum_conf_ports, METH_VARARGS, |
| 4230 |
pjsua_enum_conf_ports_doc |
| 4231 |
}, |
| 4232 |
{ |
| 4233 |
"conf_get_port_info", py_pjsua_conf_get_port_info, METH_VARARGS, |
| 4234 |
pjsua_conf_get_port_info_doc |
| 4235 |
}, |
| 4236 |
{ |
| 4237 |
"conf_remove_port", py_pjsua_conf_remove_port, METH_VARARGS, |
| 4238 |
pjsua_conf_remove_port_doc |
| 4239 |
}, |
| 4240 |
{ |
| 4241 |
"conf_connect", py_pjsua_conf_connect, METH_VARARGS, |
| 4242 |
pjsua_conf_connect_doc |
| 4243 |
}, |
| 4244 |
{ |
| 4245 |
"conf_disconnect", py_pjsua_conf_disconnect, METH_VARARGS, |
| 4246 |
pjsua_conf_disconnect_doc |
| 4247 |
}, |
| 4248 |
{ |
| 4249 |
"conf_set_tx_level", py_pjsua_conf_set_tx_level, METH_VARARGS, |
| 4250 |
"Adjust the signal level to be transmitted from the bridge to the" |
| 4251 |
" specified port by making it louder or quieter" |
| 4252 |
}, |
| 4253 |
{ |
| 4254 |
"conf_set_rx_level", py_pjsua_conf_set_rx_level, METH_VARARGS, |
| 4255 |
"Adjust the signal level to be received from the specified port (to" |
| 4256 |
" the bridge) by making it louder or quieter" |
| 4257 |
}, |
| 4258 |
{ |
| 4259 |
"conf_get_signal_level", py_pjsua_conf_get_signal_level, METH_VARARGS, |
| 4260 |
"Get last signal level transmitted to or received from the specified port" |
| 4261 |
}, |
| 4262 |
{ |
| 4263 |
"player_create", py_pjsua_player_create, METH_VARARGS, |
| 4264 |
pjsua_player_create_doc |
| 4265 |
}, |
| 4266 |
{ |
| 4267 |
"playlist_create", py_pjsua_playlist_create, METH_VARARGS, |
| 4268 |
"Create WAV playlist" |
| 4269 |
}, |
| 4270 |
{ |
| 4271 |
"player_get_conf_port", py_pjsua_player_get_conf_port, METH_VARARGS, |
| 4272 |
pjsua_player_get_conf_port_doc |
| 4273 |
}, |
| 4274 |
{ |
| 4275 |
"player_set_pos", py_pjsua_player_set_pos, METH_VARARGS, |
| 4276 |
pjsua_player_set_pos_doc |
| 4277 |
}, |
| 4278 |
{ |
| 4279 |
"player_destroy", py_pjsua_player_destroy, METH_VARARGS, |
| 4280 |
pjsua_player_destroy_doc |
| 4281 |
}, |
| 4282 |
{ |
| 4283 |
"recorder_create", py_pjsua_recorder_create, METH_VARARGS, |
| 4284 |
pjsua_recorder_create_doc |
| 4285 |
}, |
| 4286 |
{ |
| 4287 |
"recorder_get_conf_port", py_pjsua_recorder_get_conf_port, METH_VARARGS, |
| 4288 |
pjsua_recorder_get_conf_port_doc |
| 4289 |
}, |
| 4290 |
{ |
| 4291 |
"recorder_destroy", py_pjsua_recorder_destroy, METH_VARARGS, |
| 4292 |
pjsua_recorder_destroy_doc |
| 4293 |
}, |
| 4294 |
{ |
| 4295 |
"enum_snd_devs", py_pjsua_enum_snd_devs, METH_VARARGS, |
| 4296 |
pjsua_enum_snd_devs_doc |
| 4297 |
}, |
| 4298 |
{ |
| 4299 |
"get_snd_dev", py_pjsua_get_snd_dev, METH_VARARGS, |
| 4300 |
pjsua_get_snd_dev_doc |
| 4301 |
}, |
| 4302 |
{ |
| 4303 |
"set_snd_dev", py_pjsua_set_snd_dev, METH_VARARGS, |
| 4304 |
pjsua_set_snd_dev_doc |
| 4305 |
}, |
| 4306 |
{ |
| 4307 |
"set_null_snd_dev", py_pjsua_set_null_snd_dev, METH_VARARGS, |
| 4308 |
pjsua_set_null_snd_dev_doc |
| 4309 |
}, |
| 4310 |
{ |
| 4311 |
"set_ec", py_pjsua_set_ec, METH_VARARGS, |
| 4312 |
pjsua_set_ec_doc |
| 4313 |
}, |
| 4314 |
{ |
| 4315 |
"get_ec_tail", py_pjsua_get_ec_tail, METH_VARARGS, |
| 4316 |
pjsua_get_ec_tail_doc |
| 4317 |
}, |
| 4318 |
{ |
| 4319 |
"enum_codecs", py_pjsua_enum_codecs, METH_VARARGS, |
| 4320 |
pjsua_enum_codecs_doc |
| 4321 |
}, |
| 4322 |
{ |
| 4323 |
"codec_set_priority", py_pjsua_codec_set_priority, METH_VARARGS, |
| 4324 |
pjsua_codec_set_priority_doc |
| 4325 |
}, |
| 4326 |
{ |
| 4327 |
"codec_get_param", py_pjsua_codec_get_param, METH_VARARGS, |
| 4328 |
pjsua_codec_get_param_doc |
| 4329 |
}, |
| 4330 |
{ |
| 4331 |
"codec_set_param", py_pjsua_codec_set_param, METH_VARARGS, |
| 4332 |
pjsua_codec_set_param_doc |
| 4333 |
}, |
| 4334 |
{ |
| 4335 |
"call_get_max_count", py_pjsua_call_get_max_count, METH_VARARGS, |
| 4336 |
pjsua_call_get_max_count_doc |
| 4337 |
}, |
| 4338 |
{ |
| 4339 |
"call_get_count", py_pjsua_call_get_count, METH_VARARGS, |
| 4340 |
pjsua_call_get_count_doc |
| 4341 |
}, |
| 4342 |
{ |
| 4343 |
"enum_calls", py_pjsua_enum_calls, METH_VARARGS, |
| 4344 |
pjsua_enum_calls_doc |
| 4345 |
}, |
| 4346 |
{ |
| 4347 |
"call_make_call", py_pjsua_call_make_call, METH_VARARGS, |
| 4348 |
pjsua_call_make_call_doc |
| 4349 |
}, |
| 4350 |
{ |
| 4351 |
"call_is_active", py_pjsua_call_is_active, METH_VARARGS, |
| 4352 |
pjsua_call_is_active_doc |
| 4353 |
}, |
| 4354 |
{ |
| 4355 |
"call_has_media", py_pjsua_call_has_media, METH_VARARGS, |
| 4356 |
pjsua_call_has_media_doc |
| 4357 |
}, |
| 4358 |
{ |
| 4359 |
"call_get_conf_port", py_pjsua_call_get_conf_port, METH_VARARGS, |
| 4360 |
pjsua_call_get_conf_port_doc |
| 4361 |
}, |
| 4362 |
{ |
| 4363 |
"call_get_info", py_pjsua_call_get_info, METH_VARARGS, |
| 4364 |
pjsua_call_get_info_doc |
| 4365 |
}, |
| 4366 |
{ |
| 4367 |
"call_set_user_data", py_pjsua_call_set_user_data, METH_VARARGS, |
| 4368 |
pjsua_call_set_user_data_doc |
| 4369 |
}, |
| 4370 |
{ |
| 4371 |
"call_get_user_data", py_pjsua_call_get_user_data, METH_VARARGS, |
| 4372 |
pjsua_call_get_user_data_doc |
| 4373 |
}, |
| 4374 |
{ |
| 4375 |
"call_answer", py_pjsua_call_answer, METH_VARARGS, |
| 4376 |
pjsua_call_answer_doc |
| 4377 |
}, |
| 4378 |
{ |
| 4379 |
"call_hangup", py_pjsua_call_hangup, METH_VARARGS, |
| 4380 |
pjsua_call_hangup_doc |
| 4381 |
}, |
| 4382 |
{ |
| 4383 |
"call_set_hold", py_pjsua_call_set_hold, METH_VARARGS, |
| 4384 |
pjsua_call_set_hold_doc |
| 4385 |
}, |
| 4386 |
{ |
| 4387 |
"call_reinvite", py_pjsua_call_reinvite, METH_VARARGS, |
| 4388 |
pjsua_call_reinvite_doc |
| 4389 |
}, |
| 4390 |
{ |
| 4391 |
"call_update", py_pjsua_call_update, METH_VARARGS, |
| 4392 |
"Send UPDATE" |
| 4393 |
}, |
| 4394 |
{ |
| 4395 |
"call_xfer", py_pjsua_call_xfer, METH_VARARGS, |
| 4396 |
pjsua_call_xfer_doc |
| 4397 |
}, |
| 4398 |
{ |
| 4399 |
"call_xfer_replaces", py_pjsua_call_xfer_replaces, METH_VARARGS, |
| 4400 |
pjsua_call_xfer_replaces_doc |
| 4401 |
}, |
| 4402 |
{ |
| 4403 |
"call_dial_dtmf", py_pjsua_call_dial_dtmf, METH_VARARGS, |
| 4404 |
pjsua_call_dial_dtmf_doc |
| 4405 |
}, |
| 4406 |
{ |
| 4407 |
"call_send_im", py_pjsua_call_send_im, METH_VARARGS, |
| 4408 |
pjsua_call_send_im_doc |
| 4409 |
}, |
| 4410 |
{ |
| 4411 |
"call_send_typing_ind", py_pjsua_call_send_typing_ind, METH_VARARGS, |
| 4412 |
pjsua_call_send_typing_ind_doc |
| 4413 |
}, |
| 4414 |
{ |
| 4415 |
"call_hangup_all", py_pjsua_call_hangup_all, METH_VARARGS, |
| 4416 |
pjsua_call_hangup_all_doc |
| 4417 |
}, |
| 4418 |
{ |
| 4419 |
"call_dump", py_pjsua_call_dump, METH_VARARGS, |
| 4420 |
pjsua_call_dump_doc |
| 4421 |
}, |
| 4422 |
{ |
| 4423 |
"call_send_request", py_pjsua_call_send_request, METH_VARARGS, |
| 4424 |
"Send arbitrary request" |
| 4425 |
}, |
| 4426 |
{ |
| 4427 |
"dump", py_pjsua_dump, METH_VARARGS, "Dump application state" |
| 4428 |
}, |
| 4429 |
{ |
| 4430 |
"strerror", py_pj_strerror, METH_VARARGS, "Get error message" |
| 4431 |
}, |
| 4432 |
{ |
| 4433 |
"parse_simple_uri", py_pj_parse_simple_sip, METH_VARARGS, "Parse URI" |
| 4434 |
}, |
| 4435 |
|
| 4436 |
|
| 4437 |
{NULL, NULL} |
| 4438 |
}; |
| 4439 |
|
| 4440 |
|
| 4441 |
#if PY_MAJOR_VERSION > 2 |
| 4442 |
static struct PyModuleDef py_pjsua_module = |
| 4443 |
{ |
| 4444 |
PyModuleDef_HEAD_INIT, |
| 4445 |
"_pjsua", |
| 4446 |
"PJSUA-lib module for python\n", |
| 4447 |
-1, |
| 4448 |
py_pjsua_methods, |
| 4449 |
NULL, |
| 4450 |
NULL, |
| 4451 |
NULL, |
| 4452 |
NULL, |
| 4453 |
}; |
| 4454 |
#endif |
| 4455 |
|
| 4456 |
|
| 4457 |
|
| 4458 |
|
| 4459 |
|
| 4460 |
DL_EXPORT(void) |
| 4461 |
init_pjsua(void) |
| 4462 |
{ |
| 4463 |
PyObject* m = NULL; |
| 4464 |
#define ADD_CONSTANT(mod,name) PyModule_AddIntConstant(mod,#name,name) |
| 4465 |
|
| 4466 |
pj_log_set_level(1); |
| 4467 |
|
| 4468 |
PyEval_InitThreads(); |
| 4469 |
|
| 4470 |
if (PyType_Ready(&PyTyp_pjsua_callback) < 0) |
| 4471 |
return INIT_RETURN; |
| 4472 |
if (PyType_Ready(&PyTyp_pjsua_config) < 0) |
| 4473 |
return INIT_RETURN; |
| 4474 |
if (PyType_Ready(&PyTyp_pjsua_logging_config) < 0) |
| 4475 |
return INIT_RETURN; |
| 4476 |
if (PyType_Ready(&PyTyp_pjsua_msg_data) < 0) |
| 4477 |
return INIT_RETURN; |
| 4478 |
PyTyp_pjsua_media_config.tp_new = PyType_GenericNew; |
| 4479 |
if (PyType_Ready(&PyTyp_pjsua_media_config) < 0) |
| 4480 |
return INIT_RETURN; |
| 4481 |
PyTyp_pjsip_cred_info.tp_new = PyType_GenericNew; |
| 4482 |
if (PyType_Ready(&PyTyp_pjsip_cred_info) < 0) |
| 4483 |
return INIT_RETURN; |
| 4484 |
PyTyp_pjsip_rx_data.tp_new = PyType_GenericNew; |
| 4485 |
if (PyType_Ready(&PyTyp_pjsip_rx_data) < 0) |
| 4486 |
return INIT_RETURN; |
| 4487 |
|
| 4488 |
|
| 4489 |
|
| 4490 |
if (PyType_Ready(&PyTyp_pjsua_transport_config) < 0) |
| 4491 |
return INIT_RETURN; |
| 4492 |
|
| 4493 |
if (PyType_Ready(&PyTyp_pjsua_transport_info) < 0) |
| 4494 |
return INIT_RETURN; |
| 4495 |
|
| 4496 |
|
| 4497 |
|
| 4498 |
|
| 4499 |
|
| 4500 |
|
| 4501 |
if (PyType_Ready(&PyTyp_pjsua_acc_config) < 0) |
| 4502 |
return INIT_RETURN; |
| 4503 |
if (PyType_Ready(&PyTyp_pjsua_acc_info) < 0) |
| 4504 |
return INIT_RETURN; |
| 4505 |
|
| 4506 |
|
| 4507 |
|
| 4508 |
|
| 4509 |
|
| 4510 |
if (PyType_Ready(&PyTyp_pjsua_buddy_config) < 0) |
| 4511 |
return INIT_RETURN; |
| 4512 |
if (PyType_Ready(&PyTyp_pjsua_buddy_info) < 0) |
| 4513 |
return INIT_RETURN; |
| 4514 |
|
| 4515 |
|
| 4516 |
|
| 4517 |
|
| 4518 |
|
| 4519 |
if (PyType_Ready(&PyTyp_pjsua_codec_info) < 0) |
| 4520 |
return INIT_RETURN; |
| 4521 |
|
| 4522 |
if (PyType_Ready(&PyTyp_pjsua_conf_port_info) < 0) |
| 4523 |
return INIT_RETURN; |
| 4524 |
|
| 4525 |
if (PyType_Ready(&PyTyp_pjmedia_snd_dev_info) < 0) |
| 4526 |
return INIT_RETURN; |
| 4527 |
|
| 4528 |
PyTyp_pjmedia_codec_param_info.tp_new = PyType_GenericNew; |
| 4529 |
if (PyType_Ready(&PyTyp_pjmedia_codec_param_info) < 0) |
| 4530 |
return INIT_RETURN; |
| 4531 |
PyTyp_pjmedia_codec_param_setting.tp_new = PyType_GenericNew; |
| 4532 |
if (PyType_Ready(&PyTyp_pjmedia_codec_param_setting) < 0) |
| 4533 |
return INIT_RETURN; |
| 4534 |
|
| 4535 |
if (PyType_Ready(&PyTyp_pjmedia_codec_param) < 0) |
| 4536 |
return INIT_RETURN; |
| 4537 |
|
| 4538 |
|
| 4539 |
|
| 4540 |
|
| 4541 |
|
| 4542 |
if (PyType_Ready(&PyTyp_pjsua_call_info) < 0) |
| 4543 |
return INIT_RETURN; |
| 4544 |
|
| 4545 |
|
| 4546 |
|
| 4547 |
m = Py_InitModule3( |
| 4548 |
"_pjsua", py_pjsua_methods, "PJSUA-lib module for python" |
| 4549 |
); |
| 4550 |
|
| 4551 |
Py_INCREF(&PyTyp_pjsua_callback); |
| 4552 |
PyModule_AddObject(m, "Callback", (PyObject *)&PyTyp_pjsua_callback); |
| 4553 |
|
| 4554 |
Py_INCREF(&PyTyp_pjsua_config); |
| 4555 |
PyModule_AddObject(m, "Config", (PyObject *)&PyTyp_pjsua_config); |
| 4556 |
|
| 4557 |
Py_INCREF(&PyTyp_pjsua_media_config); |
| 4558 |
PyModule_AddObject(m, "Media_Config", (PyObject *)&PyTyp_pjsua_media_config); |
| 4559 |
|
| 4560 |
Py_INCREF(&PyTyp_pjsua_logging_config); |
| 4561 |
PyModule_AddObject(m, "Logging_Config", (PyObject *)&PyTyp_pjsua_logging_config); |
| 4562 |
|
| 4563 |
Py_INCREF(&PyTyp_pjsua_msg_data); |
| 4564 |
PyModule_AddObject(m, "Msg_Data", (PyObject *)&PyTyp_pjsua_msg_data); |
| 4565 |
|
| 4566 |
Py_INCREF(&PyTyp_pjsip_cred_info); |
| 4567 |
PyModule_AddObject(m, "Pjsip_Cred_Info", |
| 4568 |
(PyObject *)&PyTyp_pjsip_cred_info |
| 4569 |
); |
| 4570 |
|
| 4571 |
Py_INCREF(&PyTyp_pjsip_rx_data); |
| 4572 |
PyModule_AddObject(m, "Pjsip_Rx_Data", |
| 4573 |
(PyObject *)&PyTyp_pjsip_rx_data |
| 4574 |
); |
| 4575 |
|
| 4576 |
|
| 4577 |
|
| 4578 |
Py_INCREF(&PyTyp_pjsua_transport_config); |
| 4579 |
PyModule_AddObject |
| 4580 |
(m, "Transport_Config", (PyObject *)&PyTyp_pjsua_transport_config); |
| 4581 |
|
| 4582 |
Py_INCREF(&PyTyp_pjsua_transport_info); |
| 4583 |
PyModule_AddObject(m, "Transport_Info", (PyObject *)&PyTyp_pjsua_transport_info); |
| 4584 |
|
| 4585 |
|
| 4586 |
|
| 4587 |
|
| 4588 |
|
| 4589 |
|
| 4590 |
|
| 4591 |
Py_INCREF(&PyTyp_pjsua_acc_config); |
| 4592 |
PyModule_AddObject(m, "Acc_Config", (PyObject *)&PyTyp_pjsua_acc_config); |
| 4593 |
Py_INCREF(&PyTyp_pjsua_acc_info); |
| 4594 |
PyModule_AddObject(m, "Acc_Info", (PyObject *)&PyTyp_pjsua_acc_info); |
| 4595 |
|
| 4596 |
|
| 4597 |
|
| 4598 |
|
| 4599 |
|
| 4600 |
Py_INCREF(&PyTyp_pjsua_buddy_config); |
| 4601 |
PyModule_AddObject(m, "Buddy_Config", (PyObject *)&PyTyp_pjsua_buddy_config); |
| 4602 |
Py_INCREF(&PyTyp_pjsua_buddy_info); |
| 4603 |
PyModule_AddObject(m, "Buddy_Info", (PyObject *)&PyTyp_pjsua_buddy_info); |
| 4604 |
|
| 4605 |
|
| 4606 |
|
| 4607 |
|
| 4608 |
|
| 4609 |
Py_INCREF(&PyTyp_pjsua_codec_info); |
| 4610 |
PyModule_AddObject(m, "Codec_Info", (PyObject *)&PyTyp_pjsua_codec_info); |
| 4611 |
Py_INCREF(&PyTyp_pjsua_conf_port_info); |
| 4612 |
PyModule_AddObject(m, "Conf_Port_Info", (PyObject *)&PyTyp_pjsua_conf_port_info); |
| 4613 |
Py_INCREF(&PyTyp_pjmedia_snd_dev_info); |
| 4614 |
PyModule_AddObject(m, "PJMedia_Snd_Dev_Info", |
| 4615 |
(PyObject *)&PyTyp_pjmedia_snd_dev_info); |
| 4616 |
Py_INCREF(&PyTyp_pjmedia_codec_param_info); |
| 4617 |
PyModule_AddObject(m, "PJMedia_Codec_Param_Info", |
| 4618 |
(PyObject *)&PyTyp_pjmedia_codec_param_info); |
| 4619 |
Py_INCREF(&PyTyp_pjmedia_codec_param_setting); |
| 4620 |
PyModule_AddObject(m, "PJMedia_Codec_Param_Setting", |
| 4621 |
(PyObject *)&PyTyp_pjmedia_codec_param_setting); |
| 4622 |
Py_INCREF(&PyTyp_pjmedia_codec_param); |
| 4623 |
PyModule_AddObject(m, "PJMedia_Codec_Param", |
| 4624 |
(PyObject *)&PyTyp_pjmedia_codec_param); |
| 4625 |
|
| 4626 |
|
| 4627 |
|
| 4628 |
|
| 4629 |
|
| 4630 |
Py_INCREF(&PyTyp_pjsua_call_info); |
| 4631 |
PyModule_AddObject(m, "Call_Info", (PyObject *)&PyTyp_pjsua_call_info); |
| 4632 |
|
| 4633 |
|
| 4634 |
|
| 4635 |
|
| 4636 |
|
| 4637 |
|
| 4638 |
|
| 4639 |
|
| 4640 |
|
| 4641 |
#undef ADD_CONSTANT |
| 4642 |
|
| 4643 |
return INIT_RETURN; |
| 4644 |
} |