| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef __PY_PJSUA_H__ |
| 20 |
#define __PY_PJSUA_H__ |
| 21 |
|
| 22 |
#define _CRT_SECURE_NO_DEPRECATE |
| 23 |
|
| 24 |
#include <Python.h> |
| 25 |
#include <structmember.h> |
| 26 |
#include <pjsua-lib/pjsua.h> |
| 27 |
|
| 28 |
|
| 29 |
PJ_INLINE(pj_str_t) PyString_to_pj_str(const PyObject *obj) |
| 30 |
{ |
| 31 |
pj_str_t str; |
| 32 |
|
| 33 |
if (obj) { |
| 34 |
str.ptr = PyString_AS_STRING(obj); |
| 35 |
str.slen = PyString_GET_SIZE(obj); |
| 36 |
} else { |
| 37 |
str.ptr = NULL; |
| 38 |
str.slen = 0; |
| 39 |
} |
| 40 |
|
| 41 |
return str; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
typedef struct |
| 50 |
{ |
| 51 |
PyObject_HEAD |
| 52 |
|
| 53 |
pj_pool_t * pool; |
| 54 |
} PyObj_pj_pool; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
static PyTypeObject PyTyp_pj_pool_t = |
| 61 |
{ |
| 62 |
PyObject_HEAD_INIT(NULL) |
| 63 |
0, |
| 64 |
"py_pjsua.Pj_Pool", |
| 65 |
sizeof(PyObj_pj_pool), |
| 66 |
0, |
| 67 |
0, |
| 68 |
0, |
| 69 |
0, |
| 70 |
0, |
| 71 |
0, |
| 72 |
0, |
| 73 |
0, |
| 74 |
0, |
| 75 |
0, |
| 76 |
0, |
| 77 |
0, |
| 78 |
0, |
| 79 |
0, |
| 80 |
0, |
| 81 |
0, |
| 82 |
Py_TPFLAGS_DEFAULT, |
| 83 |
"pj_pool_t objects", |
| 84 |
|
| 85 |
}; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
typedef struct |
| 93 |
{ |
| 94 |
PyObject_HEAD |
| 95 |
|
| 96 |
pjsip_endpoint * endpt; |
| 97 |
} PyObj_pjsip_endpoint; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
static PyTypeObject PyTyp_pjsip_endpoint = |
| 104 |
{ |
| 105 |
PyObject_HEAD_INIT(NULL) |
| 106 |
0, |
| 107 |
"py_pjsua.Pjsip_Endpoint", |
| 108 |
sizeof(PyObj_pjsip_endpoint), |
| 109 |
0, |
| 110 |
0, |
| 111 |
0, |
| 112 |
0, |
| 113 |
0, |
| 114 |
0, |
| 115 |
0, |
| 116 |
0, |
| 117 |
0, |
| 118 |
0, |
| 119 |
0, |
| 120 |
0, |
| 121 |
0, |
| 122 |
0, |
| 123 |
0, |
| 124 |
0, |
| 125 |
Py_TPFLAGS_DEFAULT, |
| 126 |
"pjsip_endpoint objects", |
| 127 |
}; |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
typedef struct |
| 134 |
{ |
| 135 |
PyObject_HEAD |
| 136 |
|
| 137 |
pjmedia_endpt * endpt; |
| 138 |
} PyObj_pjmedia_endpt; |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
static PyTypeObject PyTyp_pjmedia_endpt = |
| 146 |
{ |
| 147 |
PyObject_HEAD_INIT(NULL) |
| 148 |
0, |
| 149 |
"py_pjsua.Pjmedia_Endpt", |
| 150 |
sizeof(PyObj_pjmedia_endpt), |
| 151 |
0, |
| 152 |
0, |
| 153 |
0, |
| 154 |
0, |
| 155 |
0, |
| 156 |
0, |
| 157 |
0, |
| 158 |
0, |
| 159 |
0, |
| 160 |
0, |
| 161 |
0, |
| 162 |
0, |
| 163 |
0, |
| 164 |
0, |
| 165 |
0, |
| 166 |
0, |
| 167 |
Py_TPFLAGS_DEFAULT, |
| 168 |
"pjmedia_endpt objects", |
| 169 |
|
| 170 |
}; |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
typedef struct |
| 178 |
{ |
| 179 |
PyObject_HEAD |
| 180 |
|
| 181 |
pj_pool_factory * pool_fact; |
| 182 |
} PyObj_pj_pool_factory; |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
static PyTypeObject PyTyp_pj_pool_factory = |
| 190 |
{ |
| 191 |
PyObject_HEAD_INIT(NULL) |
| 192 |
0, |
| 193 |
"py_pjsua.Pj_Pool_Factory", |
| 194 |
sizeof(PyObj_pj_pool_factory), |
| 195 |
0, |
| 196 |
0, |
| 197 |
0, |
| 198 |
0, |
| 199 |
0, |
| 200 |
0, |
| 201 |
0, |
| 202 |
0, |
| 203 |
0, |
| 204 |
0, |
| 205 |
0, |
| 206 |
0, |
| 207 |
0, |
| 208 |
0, |
| 209 |
0, |
| 210 |
0, |
| 211 |
Py_TPFLAGS_DEFAULT, |
| 212 |
"pj_pool_factory objects", |
| 213 |
|
| 214 |
}; |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
typedef struct |
| 222 |
{ |
| 223 |
PyObject_HEAD |
| 224 |
|
| 225 |
|
| 226 |
PyObject *realm; |
| 227 |
PyObject *scheme; |
| 228 |
PyObject *username; |
| 229 |
int data_type; |
| 230 |
PyObject *data; |
| 231 |
|
| 232 |
} PyObj_pjsip_cred_info; |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
static void PyObj_pjsip_cred_info_delete(PyObj_pjsip_cred_info* self) |
| 239 |
{ |
| 240 |
Py_XDECREF(self->realm); |
| 241 |
Py_XDECREF(self->scheme); |
| 242 |
Py_XDECREF(self->username); |
| 243 |
Py_XDECREF(self->data); |
| 244 |
self->ob_type->tp_free((PyObject*)self); |
| 245 |
} |
| 246 |
|
| 247 |
|
| 248 |
static void PyObj_pjsip_cred_info_import(PyObj_pjsip_cred_info *obj, |
| 249 |
const pjsip_cred_info *cfg) |
| 250 |
{ |
| 251 |
Py_XDECREF(obj->realm); |
| 252 |
obj->realm = PyString_FromStringAndSize(cfg->realm.ptr, cfg->realm.slen); |
| 253 |
Py_XDECREF(obj->scheme); |
| 254 |
obj->scheme = PyString_FromStringAndSize(cfg->scheme.ptr, cfg->scheme.slen); |
| 255 |
Py_XDECREF(obj->username); |
| 256 |
obj->username = PyString_FromStringAndSize(cfg->username.ptr, cfg->username.slen); |
| 257 |
obj->data_type = cfg->data_type; |
| 258 |
Py_XDECREF(obj->data); |
| 259 |
obj->data = PyString_FromStringAndSize(cfg->data.ptr, cfg->data.slen); |
| 260 |
} |
| 261 |
|
| 262 |
static void PyObj_pjsip_cred_info_export(pjsip_cred_info *cfg, |
| 263 |
PyObj_pjsip_cred_info *obj) |
| 264 |
{ |
| 265 |
cfg->realm = PyString_to_pj_str(obj->realm); |
| 266 |
cfg->scheme = PyString_to_pj_str(obj->scheme); |
| 267 |
cfg->username = PyString_to_pj_str(obj->username); |
| 268 |
cfg->data_type = obj->data_type; |
| 269 |
cfg->data = PyString_to_pj_str(obj->data); |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
static PyObject * PyObj_pjsip_cred_info_new(PyTypeObject *type, |
| 278 |
PyObject *args, |
| 279 |
PyObject *kwds) |
| 280 |
{ |
| 281 |
PyObj_pjsip_cred_info *self; |
| 282 |
|
| 283 |
PJ_UNUSED_ARG(args); |
| 284 |
PJ_UNUSED_ARG(kwds); |
| 285 |
|
| 286 |
self = (PyObj_pjsip_cred_info *)type->tp_alloc(type, 0); |
| 287 |
if (self != NULL) |
| 288 |
{ |
| 289 |
self->realm = PyString_FromString(""); |
| 290 |
if (self->realm == NULL) |
| 291 |
{ |
| 292 |
Py_DECREF(self); |
| 293 |
return NULL; |
| 294 |
} |
| 295 |
self->scheme = PyString_FromString(""); |
| 296 |
if (self->scheme == NULL) |
| 297 |
{ |
| 298 |
Py_DECREF(self); |
| 299 |
return NULL; |
| 300 |
} |
| 301 |
self->username = PyString_FromString(""); |
| 302 |
if (self->username == NULL) |
| 303 |
{ |
| 304 |
Py_DECREF(self); |
| 305 |
return NULL; |
| 306 |
} |
| 307 |
self->data_type = PJSIP_CRED_DATA_PLAIN_PASSWD; |
| 308 |
self->data = PyString_FromString(""); |
| 309 |
if (self->data == NULL) |
| 310 |
{ |
| 311 |
Py_DECREF(self); |
| 312 |
return NULL; |
| 313 |
} |
| 314 |
} |
| 315 |
|
| 316 |
return (PyObject *)self; |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
static PyMemberDef PyObj_pjsip_cred_info_members[] = |
| 324 |
{ |
| 325 |
{ |
| 326 |
"realm", T_OBJECT_EX, |
| 327 |
offsetof(PyObj_pjsip_cred_info, realm), 0, |
| 328 |
"Realm" |
| 329 |
}, |
| 330 |
{ |
| 331 |
"scheme", T_OBJECT_EX, |
| 332 |
offsetof(PyObj_pjsip_cred_info, scheme), 0, |
| 333 |
"Scheme" |
| 334 |
}, |
| 335 |
{ |
| 336 |
"username", T_OBJECT_EX, |
| 337 |
offsetof(PyObj_pjsip_cred_info, username), 0, |
| 338 |
"User name" |
| 339 |
}, |
| 340 |
{ |
| 341 |
"data", T_OBJECT_EX, |
| 342 |
offsetof(PyObj_pjsip_cred_info, data), 0, |
| 343 |
"The data, which can be a plaintext password or a hashed digest, " |
| 344 |
"depending on the value of data_type" |
| 345 |
}, |
| 346 |
{ |
| 347 |
"data_type", T_INT, |
| 348 |
offsetof(PyObj_pjsip_cred_info, data_type), 0, |
| 349 |
"Type of data" |
| 350 |
}, |
| 351 |
|
| 352 |
{NULL} |
| 353 |
}; |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
static PyTypeObject PyTyp_pjsip_cred_info = |
| 359 |
{ |
| 360 |
PyObject_HEAD_INIT(NULL) |
| 361 |
0, |
| 362 |
"py_pjsua.Pjsip_Cred_Info", |
| 363 |
sizeof(PyObj_pjsip_cred_info), |
| 364 |
0, |
| 365 |
(destructor)PyObj_pjsip_cred_info_delete, |
| 366 |
0, |
| 367 |
0, |
| 368 |
0, |
| 369 |
0, |
| 370 |
0, |
| 371 |
0, |
| 372 |
0, |
| 373 |
0, |
| 374 |
0, |
| 375 |
0, |
| 376 |
0, |
| 377 |
0, |
| 378 |
0, |
| 379 |
0, |
| 380 |
Py_TPFLAGS_DEFAULT, |
| 381 |
"PJSIP credential information", |
| 382 |
0, |
| 383 |
0, |
| 384 |
0, |
| 385 |
0, |
| 386 |
0, |
| 387 |
0, |
| 388 |
0, |
| 389 |
PyObj_pjsip_cred_info_members, |
| 390 |
0, |
| 391 |
0, |
| 392 |
0, |
| 393 |
0, |
| 394 |
0, |
| 395 |
0, |
| 396 |
0, |
| 397 |
0, |
| 398 |
PyObj_pjsip_cred_info_new, |
| 399 |
|
| 400 |
}; |
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
typedef struct |
| 409 |
{ |
| 410 |
PyObject_HEAD |
| 411 |
|
| 412 |
pjsip_event * event; |
| 413 |
} PyObj_pjsip_event; |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
static PyTypeObject PyTyp_pjsip_event = |
| 422 |
{ |
| 423 |
PyObject_HEAD_INIT(NULL) |
| 424 |
0, |
| 425 |
"py_pjsua.Pjsip_Event", |
| 426 |
sizeof(PyObj_pjsip_event), |
| 427 |
0, |
| 428 |
0, |
| 429 |
0, |
| 430 |
0, |
| 431 |
0, |
| 432 |
0, |
| 433 |
0, |
| 434 |
0, |
| 435 |
0, |
| 436 |
0, |
| 437 |
0, |
| 438 |
0, |
| 439 |
0, |
| 440 |
0, |
| 441 |
0, |
| 442 |
0, |
| 443 |
Py_TPFLAGS_DEFAULT, |
| 444 |
"pjsip_event object", |
| 445 |
}; |
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
typedef struct |
| 454 |
{ |
| 455 |
PyObject_HEAD |
| 456 |
|
| 457 |
pjsip_rx_data * rdata; |
| 458 |
} PyObj_pjsip_rx_data; |
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
static PyTypeObject PyTyp_pjsip_rx_data = |
| 465 |
{ |
| 466 |
PyObject_HEAD_INIT(NULL) |
| 467 |
0, |
| 468 |
"py_pjsua.Pjsip_Rx_Data", |
| 469 |
sizeof(PyObj_pjsip_rx_data), |
| 470 |
0, |
| 471 |
0, |
| 472 |
0, |
| 473 |
0, |
| 474 |
0, |
| 475 |
0, |
| 476 |
0, |
| 477 |
0, |
| 478 |
0, |
| 479 |
0, |
| 480 |
0, |
| 481 |
0, |
| 482 |
0, |
| 483 |
0, |
| 484 |
0, |
| 485 |
0, |
| 486 |
Py_TPFLAGS_DEFAULT, |
| 487 |
"pjsip_rx_data object", |
| 488 |
}; |
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
typedef struct PyObj_pjsua_callback |
| 498 |
{ |
| 499 |
PyObject_HEAD |
| 500 |
|
| 501 |
PyObject * on_call_state; |
| 502 |
PyObject * on_incoming_call; |
| 503 |
PyObject * on_call_media_state; |
| 504 |
PyObject * on_dtmf_digit; |
| 505 |
PyObject * on_call_transfer_request; |
| 506 |
PyObject * on_call_transfer_status; |
| 507 |
PyObject * on_call_replace_request; |
| 508 |
PyObject * on_call_replaced; |
| 509 |
PyObject * on_reg_state; |
| 510 |
PyObject * on_buddy_state; |
| 511 |
PyObject * on_pager; |
| 512 |
PyObject * on_pager_status; |
| 513 |
PyObject * on_typing; |
| 514 |
} PyObj_pjsua_callback; |
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
static void PyObj_pjsua_callback_delete(PyObj_pjsua_callback* self) |
| 522 |
{ |
| 523 |
Py_XDECREF(self->on_call_state); |
| 524 |
Py_XDECREF(self->on_incoming_call); |
| 525 |
Py_XDECREF(self->on_call_media_state); |
| 526 |
Py_XDECREF(self->on_dtmf_digit); |
| 527 |
Py_XDECREF(self->on_call_transfer_request); |
| 528 |
Py_XDECREF(self->on_call_transfer_status); |
| 529 |
Py_XDECREF(self->on_call_replace_request); |
| 530 |
Py_XDECREF(self->on_call_replaced); |
| 531 |
Py_XDECREF(self->on_reg_state); |
| 532 |
Py_XDECREF(self->on_buddy_state); |
| 533 |
Py_XDECREF(self->on_pager); |
| 534 |
Py_XDECREF(self->on_pager_status); |
| 535 |
Py_XDECREF(self->on_typing); |
| 536 |
self->ob_type->tp_free((PyObject*)self); |
| 537 |
} |
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
static PyObject * PyObj_pjsua_callback_new(PyTypeObject *type, |
| 545 |
PyObject *args, |
| 546 |
PyObject *kwds) |
| 547 |
{ |
| 548 |
PyObj_pjsua_callback *self; |
| 549 |
|
| 550 |
PJ_UNUSED_ARG(args); |
| 551 |
PJ_UNUSED_ARG(kwds); |
| 552 |
|
| 553 |
self = (PyObj_pjsua_callback *)type->tp_alloc(type, 0); |
| 554 |
if (self != NULL) |
| 555 |
{ |
| 556 |
Py_INCREF(Py_None); |
| 557 |
self->on_call_state = Py_None; |
| 558 |
if (self->on_call_state == NULL) |
| 559 |
{ |
| 560 |
Py_DECREF(Py_None); |
| 561 |
return NULL; |
| 562 |
} |
| 563 |
Py_INCREF(Py_None); |
| 564 |
self->on_incoming_call = Py_None; |
| 565 |
if (self->on_incoming_call == NULL) |
| 566 |
{ |
| 567 |
Py_DECREF(Py_None); |
| 568 |
return NULL; |
| 569 |
} |
| 570 |
Py_INCREF(Py_None); |
| 571 |
self->on_call_media_state = Py_None; |
| 572 |
if (self->on_call_media_state == NULL) |
| 573 |
{ |
| 574 |
Py_DECREF(Py_None); |
| 575 |
return NULL; |
| 576 |
} |
| 577 |
Py_INCREF(Py_None); |
| 578 |
self->on_dtmf_digit = Py_None; |
| 579 |
if (self->on_dtmf_digit == NULL) |
| 580 |
{ |
| 581 |
Py_DECREF(Py_None); |
| 582 |
return NULL; |
| 583 |
} |
| 584 |
Py_INCREF(Py_None); |
| 585 |
self->on_call_transfer_request = Py_None; |
| 586 |
if (self->on_call_transfer_request == NULL) |
| 587 |
{ |
| 588 |
Py_DECREF(Py_None); |
| 589 |
return NULL; |
| 590 |
} |
| 591 |
Py_INCREF(Py_None); |
| 592 |
self->on_call_transfer_status = Py_None; |
| 593 |
if (self->on_call_transfer_status == NULL) |
| 594 |
{ |
| 595 |
Py_DECREF(Py_None); |
| 596 |
return NULL; |
| 597 |
} |
| 598 |
Py_INCREF(Py_None); |
| 599 |
self->on_call_replace_request = Py_None; |
| 600 |
if (self->on_call_replace_request == NULL) |
| 601 |
{ |
| 602 |
Py_DECREF(Py_None); |
| 603 |
return NULL; |
| 604 |
} |
| 605 |
Py_INCREF(Py_None); |
| 606 |
self->on_call_replaced = Py_None; |
| 607 |
if (self->on_call_replaced == NULL) |
| 608 |
{ |
| 609 |
Py_DECREF(Py_None); |
| 610 |
return NULL; |
| 611 |
} |
| 612 |
Py_INCREF(Py_None); |
| 613 |
self->on_reg_state = Py_None; |
| 614 |
if (self->on_reg_state == NULL) |
| 615 |
{ |
| 616 |
Py_DECREF(Py_None); |
| 617 |
return NULL; |
| 618 |
} |
| 619 |
Py_INCREF(Py_None); |
| 620 |
self->on_buddy_state = Py_None; |
| 621 |
if (self->on_buddy_state == NULL) |
| 622 |
{ |
| 623 |
Py_DECREF(Py_None); |
| 624 |
return NULL; |
| 625 |
} |
| 626 |
Py_INCREF(Py_None); |
| 627 |
self->on_pager = Py_None; |
| 628 |
if (self->on_pager == NULL) |
| 629 |
{ |
| 630 |
Py_DECREF(Py_None); |
| 631 |
return NULL; |
| 632 |
} |
| 633 |
Py_INCREF(Py_None); |
| 634 |
self->on_pager_status = Py_None; |
| 635 |
if (self->on_pager_status == NULL) |
| 636 |
{ |
| 637 |
Py_DECREF(Py_None); |
| 638 |
return NULL; |
| 639 |
} |
| 640 |
Py_INCREF(Py_None); |
| 641 |
self->on_typing = Py_None; |
| 642 |
if (self->on_typing == NULL) |
| 643 |
{ |
| 644 |
Py_DECREF(Py_None); |
| 645 |
return NULL; |
| 646 |
} |
| 647 |
} |
| 648 |
|
| 649 |
return (PyObject *)self; |
| 650 |
} |
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
static PyMemberDef PyObj_pjsua_callback_members[] = |
| 658 |
{ |
| 659 |
{ |
| 660 |
"on_call_state", T_OBJECT_EX, |
| 661 |
offsetof(PyObj_pjsua_callback, on_call_state), 0, |
| 662 |
"Notify application when invite state has changed. Application may " |
| 663 |
"then query the call info to get the detail call states." |
| 664 |
}, |
| 665 |
{ |
| 666 |
"on_incoming_call", T_OBJECT_EX, |
| 667 |
offsetof(PyObj_pjsua_callback, on_incoming_call), 0, |
| 668 |
"Notify application on incoming call." |
| 669 |
}, |
| 670 |
{ |
| 671 |
"on_call_media_state", T_OBJECT_EX, |
| 672 |
offsetof(PyObj_pjsua_callback, on_call_media_state), 0, |
| 673 |
"Notify application when media state in the call has changed. Normal " |
| 674 |
"application would need to implement this callback, e.g. to connect " |
| 675 |
"the call's media to sound device." |
| 676 |
}, |
| 677 |
{ |
| 678 |
"on_dtmf_digit", T_OBJECT_EX, |
| 679 |
offsetof(PyObj_pjsua_callback, on_dtmf_digit), 0, |
| 680 |
"Notify application upon receiving incoming DTMF digit." |
| 681 |
}, |
| 682 |
{ |
| 683 |
"on_call_transfer_request", T_OBJECT_EX, |
| 684 |
offsetof(PyObj_pjsua_callback, on_call_transfer_request), 0, |
| 685 |
"Notify application on call being transfered. " |
| 686 |
"Application can decide to accept/reject transfer request " |
| 687 |
"by setting the code (default is 200). When this callback " |
| 688 |
"is not defined, the default behavior is to accept the " |
| 689 |
"transfer." |
| 690 |
}, |
| 691 |
{ |
| 692 |
"on_call_transfer_status", T_OBJECT_EX, |
| 693 |
offsetof(PyObj_pjsua_callback, on_call_transfer_status), 0, |
| 694 |
"Notify application of the status of previously sent call " |
| 695 |
"transfer request. Application can monitor the status of the " |
| 696 |
"call transfer request, for example to decide whether to " |
| 697 |
"terminate existing call." |
| 698 |
}, |
| 699 |
{ |
| 700 |
"on_call_replace_request", T_OBJECT_EX, |
| 701 |
offsetof(PyObj_pjsua_callback, on_call_replace_request), 0, |
| 702 |
"Notify application about incoming INVITE with Replaces header. " |
| 703 |
"Application may reject the request by setting non-2xx code." |
| 704 |
}, |
| 705 |
{ |
| 706 |
"on_call_replaced", T_OBJECT_EX, |
| 707 |
offsetof(PyObj_pjsua_callback, on_call_replaced), 0, |
| 708 |
"Notify application that an existing call has been replaced with " |
| 709 |
"a new call. This happens when PJSUA-API receives incoming INVITE " |
| 710 |
"request with Replaces header." |
| 711 |
" " |
| 712 |
"After this callback is called, normally PJSUA-API will disconnect " |
| 713 |
"old_call_id and establish new_call_id." |
| 714 |
}, |
| 715 |
{ |
| 716 |
"on_reg_state", T_OBJECT_EX, |
| 717 |
offsetof(PyObj_pjsua_callback, on_reg_state), 0, |
| 718 |
"Notify application when registration status has changed. Application " |
| 719 |
"may then query the account info to get the registration details." |
| 720 |
}, |
| 721 |
{ |
| 722 |
"on_buddy_state", T_OBJECT_EX, |
| 723 |
offsetof(PyObj_pjsua_callback, on_buddy_state), 0, |
| 724 |
"Notify application when the buddy state has changed. Application may " |
| 725 |
"then query the buddy into to get the details." |
| 726 |
}, |
| 727 |
{ |
| 728 |
"on_pager", T_OBJECT_EX, |
| 729 |
offsetof(PyObj_pjsua_callback, on_pager), 0, |
| 730 |
"Notify application on incoming pager (i.e. MESSAGE request). " |
| 731 |
"Argument call_id will be -1 if MESSAGE request is not related to an " |
| 732 |
"existing call." |
| 733 |
}, |
| 734 |
{ |
| 735 |
"on_pager_status", T_OBJECT_EX, |
| 736 |
offsetof(PyObj_pjsua_callback, on_pager_status), 0, |
| 737 |
"Notify application about the delivery status of outgoing pager " |
| 738 |
"request." |
| 739 |
}, |
| 740 |
{ |
| 741 |
"on_typing", T_OBJECT_EX, |
| 742 |
offsetof(PyObj_pjsua_callback, on_typing), 0, |
| 743 |
"Notify application about typing indication." |
| 744 |
}, |
| 745 |
{NULL} |
| 746 |
}; |
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
static PyTypeObject PyTyp_pjsua_callback = |
| 754 |
{ |
| 755 |
PyObject_HEAD_INIT(NULL) |
| 756 |
0, |
| 757 |
"py_pjsua.Callback", |
| 758 |
sizeof(PyObj_pjsua_callback), |
| 759 |
0, |
| 760 |
(destructor)PyObj_pjsua_callback_delete, |
| 761 |
0, |
| 762 |
0, |
| 763 |
0, |
| 764 |
0, |
| 765 |
0, |
| 766 |
0, |
| 767 |
0, |
| 768 |
0, |
| 769 |
0, |
| 770 |
0, |
| 771 |
0, |
| 772 |
0, |
| 773 |
0, |
| 774 |
0, |
| 775 |
Py_TPFLAGS_DEFAULT, |
| 776 |
"This structure describes application callback " |
| 777 |
"to receive various event notifications from " |
| 778 |
"PJSUA-API", |
| 779 |
0, |
| 780 |
0, |
| 781 |
0, |
| 782 |
0, |
| 783 |
0, |
| 784 |
0, |
| 785 |
0, |
| 786 |
PyObj_pjsua_callback_members, |
| 787 |
0, |
| 788 |
0, |
| 789 |
0, |
| 790 |
0, |
| 791 |
0, |
| 792 |
0, |
| 793 |
0, |
| 794 |
0, |
| 795 |
PyObj_pjsua_callback_new, |
| 796 |
|
| 797 |
}; |
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
typedef struct |
| 806 |
{ |
| 807 |
PyObject_HEAD |
| 808 |
|
| 809 |
unsigned clock_rate; |
| 810 |
unsigned max_media_ports; |
| 811 |
int has_ioqueue; |
| 812 |
unsigned thread_cnt; |
| 813 |
unsigned quality; |
| 814 |
unsigned ptime; |
| 815 |
int no_vad; |
| 816 |
unsigned ilbc_mode; |
| 817 |
unsigned tx_drop_pct; |
| 818 |
unsigned rx_drop_pct; |
| 819 |
unsigned ec_options; |
| 820 |
unsigned ec_tail_len; |
| 821 |
} PyObj_pjsua_media_config; |
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
static PyMemberDef PyObj_pjsua_media_config_members[] = |
| 829 |
{ |
| 830 |
{ |
| 831 |
"clock_rate", T_INT, |
| 832 |
offsetof(PyObj_pjsua_media_config, clock_rate), 0, |
| 833 |
"Clock rate to be applied to the conference bridge. If value is zero, " |
| 834 |
"default clock rate will be used (16KHz)." |
| 835 |
}, |
| 836 |
{ |
| 837 |
"max_media_ports", T_INT, |
| 838 |
offsetof(PyObj_pjsua_media_config, max_media_ports), 0, |
| 839 |
"Specify maximum number of media ports to be created in the " |
| 840 |
"conference bridge. Since all media terminate in the bridge (calls, " |
| 841 |
"file player, file recorder, etc), the value must be large enough to " |
| 842 |
"support all of them. However, the larger the value, the more " |
| 843 |
"computations are performed." |
| 844 |
}, |
| 845 |
{ |
| 846 |
"has_ioqueue", T_INT, |
| 847 |
offsetof(PyObj_pjsua_media_config, has_ioqueue), 0, |
| 848 |
"Specify whether the media manager should manage its own ioqueue for " |
| 849 |
"the RTP/RTCP sockets. If yes, ioqueue will be created and at least " |
| 850 |
"one worker thread will be created too. If no, the RTP/RTCP sockets " |
| 851 |
"will share the same ioqueue as SIP sockets, and no worker thread is " |
| 852 |
"needed." |
| 853 |
}, |
| 854 |
{ |
| 855 |
"thread_cnt", T_INT, |
| 856 |
offsetof(PyObj_pjsua_media_config, thread_cnt), 0, |
| 857 |
"Specify the number of worker threads to handle incoming RTP packets. " |
| 858 |
"A value of one is recommended for most applications." |
| 859 |
}, |
| 860 |
{ |
| 861 |
"quality", T_INT, |
| 862 |
offsetof(PyObj_pjsua_media_config, quality), 0, |
| 863 |
"The media quality also sets speex codec quality/complexity to the " |
| 864 |
"number." |
| 865 |
}, |
| 866 |
{ |
| 867 |
"ptime", T_INT, |
| 868 |
offsetof(PyObj_pjsua_media_config, ptime), 0, |
| 869 |
"Specify default ptime." |
| 870 |
}, |
| 871 |
{ |
| 872 |
"no_vad", T_INT, |
| 873 |
offsetof(PyObj_pjsua_media_config, no_vad), 0, |
| 874 |
"Disable VAD?" |
| 875 |
}, |
| 876 |
{ |
| 877 |
"ilbc_mode", T_INT, |
| 878 |
offsetof(PyObj_pjsua_media_config, ilbc_mode), 0, |
| 879 |
"iLBC mode (20 or 30)." |
| 880 |
}, |
| 881 |
{ |
| 882 |
"tx_drop_pct", T_INT, |
| 883 |
offsetof(PyObj_pjsua_media_config, tx_drop_pct), 0, |
| 884 |
"Percentage of RTP packet to drop in TX direction (to simulate packet " |
| 885 |
"lost)." |
| 886 |
}, |
| 887 |
{ |
| 888 |
"rx_drop_pct", T_INT, |
| 889 |
offsetof(PyObj_pjsua_media_config, rx_drop_pct), 0, |
| 890 |
"Percentage of RTP packet to drop in RX direction (to simulate packet " |
| 891 |
"lost)."}, |
| 892 |
{ |
| 893 |
"ec_options", T_INT, |
| 894 |
offsetof(PyObj_pjsua_media_config, ec_options), 0, |
| 895 |
"Echo canceller options (see pjmedia_echo_create())" |
| 896 |
}, |
| 897 |
{ |
| 898 |
"ec_tail_len", T_INT, |
| 899 |
offsetof(PyObj_pjsua_media_config, ec_tail_len), 0, |
| 900 |
"Echo canceller tail length, in miliseconds." |
| 901 |
}, |
| 902 |
{NULL} |
| 903 |
}; |
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
static PyTypeObject PyTyp_pjsua_media_config = |
| 910 |
{ |
| 911 |
PyObject_HEAD_INIT(NULL) |
| 912 |
0, |
| 913 |
"py_pjsua.Media_Config", |
| 914 |
sizeof(PyObj_pjsua_media_config), |
| 915 |
0, |
| 916 |
0, |
| 917 |
0, |
| 918 |
0, |
| 919 |
0, |
| 920 |
0, |
| 921 |
0, |
| 922 |
0, |
| 923 |
0, |
| 924 |
0, |
| 925 |
0, |
| 926 |
0, |
| 927 |
0, |
| 928 |
0, |
| 929 |
0, |
| 930 |
0, |
| 931 |
Py_TPFLAGS_DEFAULT, |
| 932 |
"Media Config objects", |
| 933 |
0, |
| 934 |
0, |
| 935 |
0, |
| 936 |
0, |
| 937 |
0, |
| 938 |
0, |
| 939 |
0, |
| 940 |
PyObj_pjsua_media_config_members, |
| 941 |
|
| 942 |
}; |
| 943 |
|
| 944 |
|
| 945 |
static void PyObj_pjsua_media_config_import(PyObj_pjsua_media_config *obj, |
| 946 |
const pjsua_media_config *cfg) |
| 947 |
{ |
| 948 |
obj->clock_rate = cfg->clock_rate; |
| 949 |
obj->max_media_ports = cfg->max_media_ports; |
| 950 |
obj->has_ioqueue = cfg->has_ioqueue; |
| 951 |
obj->thread_cnt = cfg->thread_cnt; |
| 952 |
obj->quality = cfg->quality; |
| 953 |
obj->ptime = cfg->ptime; |
| 954 |
obj->no_vad = cfg->no_vad; |
| 955 |
obj->ilbc_mode = cfg->ilbc_mode; |
| 956 |
obj->tx_drop_pct = cfg->tx_drop_pct; |
| 957 |
obj->rx_drop_pct = cfg->rx_drop_pct; |
| 958 |
obj->ec_options = cfg->ec_options; |
| 959 |
obj->ec_tail_len = cfg->ec_tail_len; |
| 960 |
} |
| 961 |
|
| 962 |
static void PyObj_pjsua_media_config_export(pjsua_media_config *cfg, |
| 963 |
const PyObj_pjsua_media_config *obj) |
| 964 |
{ |
| 965 |
cfg->clock_rate = obj->clock_rate; |
| 966 |
cfg->max_media_ports = obj->max_media_ports; |
| 967 |
cfg->has_ioqueue = obj->has_ioqueue; |
| 968 |
cfg->thread_cnt = obj->thread_cnt; |
| 969 |
cfg->quality = obj->quality; |
| 970 |
cfg->ptime = obj->ptime; |
| 971 |
cfg->no_vad = obj->no_vad; |
| 972 |
cfg->ilbc_mode = obj->ilbc_mode; |
| 973 |
cfg->tx_drop_pct = obj->tx_drop_pct; |
| 974 |
cfg->rx_drop_pct = obj->rx_drop_pct; |
| 975 |
cfg->ec_options = obj->ec_options; |
| 976 |
cfg->ec_tail_len = obj->ec_tail_len; |
| 977 |
} |
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
typedef struct |
| 985 |
{ |
| 986 |
PyObject_HEAD |
| 987 |
|
| 988 |
unsigned max_calls; |
| 989 |
unsigned thread_cnt; |
| 990 |
PyObject *outbound_proxy; |
| 991 |
PyObject *stun_domain; |
| 992 |
PyObject *stun_host; |
| 993 |
PyObject *stun_relay_host; |
| 994 |
PyObj_pjsua_callback *cb; |
| 995 |
PyObject *user_agent; |
| 996 |
} PyObj_pjsua_config; |
| 997 |
|
| 998 |
|
| 999 |
static void PyObj_pjsua_config_delete(PyObj_pjsua_config* self) |
| 1000 |
{ |
| 1001 |
Py_XDECREF(self->outbound_proxy); |
| 1002 |
Py_XDECREF(self->stun_domain); |
| 1003 |
Py_XDECREF(self->stun_host); |
| 1004 |
Py_XDECREF(self->stun_relay_host); |
| 1005 |
Py_XDECREF(self->cb); |
| 1006 |
Py_XDECREF(self->user_agent); |
| 1007 |
self->ob_type->tp_free((PyObject*)self); |
| 1008 |
} |
| 1009 |
|
| 1010 |
|
| 1011 |
static void PyObj_pjsua_config_import(PyObj_pjsua_config *obj, |
| 1012 |
const pjsua_config *cfg) |
| 1013 |
{ |
| 1014 |
obj->max_calls = cfg->max_calls; |
| 1015 |
obj->thread_cnt = cfg->thread_cnt; |
| 1016 |
Py_XDECREF(obj->outbound_proxy); |
| 1017 |
obj->outbound_proxy = PyString_FromStringAndSize(cfg->outbound_proxy[0].ptr, |
| 1018 |
cfg->outbound_proxy[0].slen); |
| 1019 |
Py_XDECREF(obj->stun_domain); |
| 1020 |
obj->stun_domain = PyString_FromStringAndSize(cfg->stun_domain.ptr, |
| 1021 |
cfg->stun_domain.slen); |
| 1022 |
Py_XDECREF(obj->stun_host); |
| 1023 |
obj->stun_host = PyString_FromStringAndSize(cfg->stun_host.ptr, |
| 1024 |
cfg->stun_host.slen); |
| 1025 |
Py_XDECREF(obj->stun_relay_host); |
| 1026 |
obj->stun_relay_host= PyString_FromStringAndSize(cfg->stun_host.ptr, |
| 1027 |
cfg->stun_host.slen); |
| 1028 |
Py_XDECREF(obj->user_agent); |
| 1029 |
obj->user_agent = PyString_FromStringAndSize(cfg->user_agent.ptr, |
| 1030 |
cfg->user_agent.slen); |
| 1031 |
} |
| 1032 |
|
| 1033 |
|
| 1034 |
static void PyObj_pjsua_config_export(pjsua_config *cfg, |
| 1035 |
PyObj_pjsua_config *obj) |
| 1036 |
{ |
| 1037 |
cfg->max_calls = obj->max_calls; |
| 1038 |
cfg->thread_cnt = obj->thread_cnt; |
| 1039 |
if (PyString_Size(obj->outbound_proxy) > 0) { |
| 1040 |
cfg->outbound_proxy_cnt = 1; |
| 1041 |
cfg->outbound_proxy[0] = PyString_to_pj_str(obj->outbound_proxy); |
| 1042 |
} else { |
| 1043 |
cfg->outbound_proxy_cnt = 0; |
| 1044 |
} |
| 1045 |
cfg->stun_domain = PyString_to_pj_str(obj->stun_domain); |
| 1046 |
cfg->stun_host = PyString_to_pj_str(obj->stun_host); |
| 1047 |
|
| 1048 |
cfg->user_agent = PyString_to_pj_str(obj->user_agent); |
| 1049 |
|
| 1050 |
} |
| 1051 |
|
| 1052 |
|
| 1053 |
static PyObject *PyObj_pjsua_config_new(PyTypeObject *type, |
| 1054 |
PyObject *args, |
| 1055 |
PyObject *kwds) |
| 1056 |
{ |
| 1057 |
PyObj_pjsua_config *self; |
| 1058 |
|
| 1059 |
PJ_UNUSED_ARG(args); |
| 1060 |
PJ_UNUSED_ARG(kwds); |
| 1061 |
|
| 1062 |
self = (PyObj_pjsua_config *)type->tp_alloc(type, 0); |
| 1063 |
if (self != NULL) |
| 1064 |
{ |
| 1065 |
self->user_agent = PyString_FromString(""); |
| 1066 |
if (self->user_agent == NULL) |
| 1067 |
{ |
| 1068 |
Py_DECREF(self); |
| 1069 |
return NULL; |
| 1070 |
} |
| 1071 |
self->outbound_proxy = PyString_FromString(""); |
| 1072 |
if (self->outbound_proxy == NULL) |
| 1073 |
{ |
| 1074 |
Py_DECREF(self); |
| 1075 |
return NULL; |
| 1076 |
} |
| 1077 |
self->cb = (PyObj_pjsua_callback *) |
| 1078 |
PyType_GenericNew(&PyTyp_pjsua_callback, NULL, NULL); |
| 1079 |
if (self->cb == NULL) |
| 1080 |
{ |
| 1081 |
Py_DECREF(Py_None); |
| 1082 |
return NULL; |
| 1083 |
} |
| 1084 |
} |
| 1085 |
return (PyObject *)self; |
| 1086 |
} |
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
static PyMemberDef PyObj_pjsua_config_members[] = |
| 1094 |
{ |
| 1095 |
{ |
| 1096 |
"max_calls", T_INT, |
| 1097 |
offsetof(PyObj_pjsua_config, max_calls), 0, |
| 1098 |
"Maximum calls to support (default: 4) " |
| 1099 |
}, |
| 1100 |
{ |
| 1101 |
"thread_cnt", T_INT, |
| 1102 |
offsetof(PyObj_pjsua_config, thread_cnt), 0, |
| 1103 |
"Number of worker threads. Normally application will want to have at " |
| 1104 |
"least one worker thread, unless when it wants to poll the library " |
| 1105 |
"periodically, which in this case the worker thread can be set to " |
| 1106 |
"zero." |
| 1107 |
}, |
| 1108 |
{ |
| 1109 |
"outbound_proxy", T_OBJECT_EX, |
| 1110 |
offsetof(PyObj_pjsua_config, outbound_proxy), 0, |
| 1111 |
"SIP URL of the outbound proxy (optional)" |
| 1112 |
}, |
| 1113 |
{ |
| 1114 |
"stun_domain", T_OBJECT_EX, |
| 1115 |
offsetof(PyObj_pjsua_config, stun_domain), 0, |
| 1116 |
"Domain of the STUN server (optional). STUN server will be resolved " |
| 1117 |
"using DNS SRV resolution only when nameserver is configured. " |
| 1118 |
"Alternatively, if DNS SRV resolution for STUN is not desired, " |
| 1119 |
"application can specify the STUN server hostname or IP address " |
| 1120 |
"in stun_host attribute." |
| 1121 |
}, |
| 1122 |
{ |
| 1123 |
"stun_host", T_OBJECT_EX, |
| 1124 |
offsetof(PyObj_pjsua_config, stun_host), 0, |
| 1125 |
"Hostname or IP address of the STUN server (optional)." |
| 1126 |
}, |
| 1127 |
{ |
| 1128 |
"stun_relay_host", T_OBJECT_EX, |
| 1129 |
offsetof(PyObj_pjsua_config, stun_relay_host), 0, |
| 1130 |
"Hostname or IP address of the TURN server (optional)." |
| 1131 |
}, |
| 1132 |
{ |
| 1133 |
"cb", T_OBJECT_EX, offsetof(PyObj_pjsua_config, cb), 0, |
| 1134 |
"Application callback." |
| 1135 |
}, |
| 1136 |
{ |
| 1137 |
"user_agent", T_OBJECT_EX, offsetof(PyObj_pjsua_config, user_agent), 0, |
| 1138 |
"User agent string (default empty)" |
| 1139 |
}, |
| 1140 |
{NULL} |
| 1141 |
}; |
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
static PyTypeObject PyTyp_pjsua_config = |
| 1149 |
{ |
| 1150 |
PyObject_HEAD_INIT(NULL) |
| 1151 |
0, |
| 1152 |
"py_pjsua.Config", |
| 1153 |
sizeof(PyObj_pjsua_config), |
| 1154 |
0, |
| 1155 |
(destructor)PyObj_pjsua_config_delete, |
| 1156 |
0, |
| 1157 |
0, |
| 1158 |
0, |
| 1159 |
0, |
| 1160 |
0, |
| 1161 |
0, |
| 1162 |
0, |
| 1163 |
0, |
| 1164 |
0, |
| 1165 |
0, |
| 1166 |
0, |
| 1167 |
0, |
| 1168 |
0, |
| 1169 |
0, |
| 1170 |
Py_TPFLAGS_DEFAULT, |
| 1171 |
"Config object", |
| 1172 |
0, |
| 1173 |
0, |
| 1174 |
0, |
| 1175 |
0, |
| 1176 |
0, |
| 1177 |
0, |
| 1178 |
0, |
| 1179 |
PyObj_pjsua_config_members, |
| 1180 |
0, |
| 1181 |
0, |
| 1182 |
0, |
| 1183 |
0, |
| 1184 |
0, |
| 1185 |
0, |
| 1186 |
0, |
| 1187 |
0, |
| 1188 |
PyObj_pjsua_config_new, |
| 1189 |
|
| 1190 |
}; |
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
typedef struct |
| 1198 |
{ |
| 1199 |
PyObject_HEAD |
| 1200 |
|
| 1201 |
int msg_logging; |
| 1202 |
unsigned level; |
| 1203 |
unsigned console_level; |
| 1204 |
unsigned decor; |
| 1205 |
PyObject *log_filename; |
| 1206 |
PyObject *cb; |
| 1207 |
} PyObj_pjsua_logging_config; |
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
static void PyObj_pjsua_logging_config_delete(PyObj_pjsua_logging_config* self) |
| 1215 |
{ |
| 1216 |
Py_XDECREF(self->log_filename); |
| 1217 |
Py_XDECREF(self->cb); |
| 1218 |
self->ob_type->tp_free((PyObject*)self); |
| 1219 |
} |
| 1220 |
|
| 1221 |
|
| 1222 |
static void PyObj_pjsua_logging_config_import(PyObj_pjsua_logging_config *obj, |
| 1223 |
const pjsua_logging_config *cfg) |
| 1224 |
{ |
| 1225 |
obj->msg_logging = cfg->msg_logging; |
| 1226 |
obj->level = cfg->level; |
| 1227 |
obj->console_level = cfg->console_level; |
| 1228 |
obj->decor = cfg->decor; |
| 1229 |
} |
| 1230 |
|
| 1231 |
static void PyObj_pjsua_logging_config_export(pjsua_logging_config *cfg, |
| 1232 |
PyObj_pjsua_logging_config *obj) |
| 1233 |
{ |
| 1234 |
cfg->msg_logging = obj->msg_logging; |
| 1235 |
cfg->level = obj->level; |
| 1236 |
cfg->console_level = obj->console_level; |
| 1237 |
cfg->decor = obj->decor; |
| 1238 |
cfg->log_filename = PyString_to_pj_str(obj->log_filename); |
| 1239 |
} |
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
static PyObject * PyObj_pjsua_logging_config_new(PyTypeObject *type, |
| 1247 |
PyObject *args, |
| 1248 |
PyObject *kwds) |
| 1249 |
{ |
| 1250 |
PyObj_pjsua_logging_config *self; |
| 1251 |
|
| 1252 |
PJ_UNUSED_ARG(args); |
| 1253 |
PJ_UNUSED_ARG(kwds); |
| 1254 |
|
| 1255 |
self = (PyObj_pjsua_logging_config *)type->tp_alloc(type, 0); |
| 1256 |
if (self != NULL) |
| 1257 |
{ |
| 1258 |
self->log_filename = PyString_FromString(""); |
| 1259 |
if (self->log_filename == NULL) |
| 1260 |
{ |
| 1261 |
Py_DECREF(self); |
| 1262 |
return NULL; |
| 1263 |
} |
| 1264 |
Py_INCREF(Py_None); |
| 1265 |
self->cb = Py_None; |
| 1266 |
if (self->cb == NULL) |
| 1267 |
{ |
| 1268 |
Py_DECREF(Py_None); |
| 1269 |
return NULL; |
| 1270 |
} |
| 1271 |
} |
| 1272 |
|
| 1273 |
return (PyObject *)self; |
| 1274 |
} |
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
static PyMemberDef PyObj_pjsua_logging_config_members[] = |
| 1281 |
{ |
| 1282 |
{ |
| 1283 |
"msg_logging", T_INT, |
| 1284 |
offsetof(PyObj_pjsua_logging_config, msg_logging), 0, |
| 1285 |
"Log incoming and outgoing SIP message? Yes!" |
| 1286 |
}, |
| 1287 |
{ |
| 1288 |
"level", T_INT, |
| 1289 |
offsetof(PyObj_pjsua_logging_config, level), 0, |
| 1290 |
"Input verbosity level. Value 5 is reasonable." |
| 1291 |
}, |
| 1292 |
{ |
| 1293 |
"console_level", T_INT, |
| 1294 |
offsetof(PyObj_pjsua_logging_config, console_level), |
| 1295 |
0, "Verbosity level for console. Value 4 is reasonable." |
| 1296 |
}, |
| 1297 |
{ |
| 1298 |
"decor", T_INT, |
| 1299 |
offsetof(PyObj_pjsua_logging_config, decor), 0, |
| 1300 |
"Log decoration" |
| 1301 |
}, |
| 1302 |
{ |
| 1303 |
"log_filename", T_OBJECT_EX, |
| 1304 |
offsetof(PyObj_pjsua_logging_config, log_filename), 0, |
| 1305 |
"Optional log filename" |
| 1306 |
}, |
| 1307 |
{ |
| 1308 |
"cb", T_OBJECT_EX, |
| 1309 |
offsetof(PyObj_pjsua_logging_config, cb), 0, |
| 1310 |
"Optional callback function to be called to write log to application " |
| 1311 |
"specific device. This function will be called forlog messages on " |
| 1312 |
"input verbosity level." |
| 1313 |
}, |
| 1314 |
{NULL} |
| 1315 |
}; |
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
static PyTypeObject PyTyp_pjsua_logging_config = |
| 1324 |
{ |
| 1325 |
PyObject_HEAD_INIT(NULL) |
| 1326 |
0, |
| 1327 |
"py_pjsua.Logging_Config", |
| 1328 |
sizeof(PyObj_pjsua_logging_config), |
| 1329 |
0, |
| 1330 |
(destructor)PyObj_pjsua_logging_config_delete, |
| 1331 |
0, |
| 1332 |
0, |
| 1333 |
0, |
| 1334 |
0, |
| 1335 |
0, |
| 1336 |
0, |
| 1337 |
0, |
| 1338 |
0, |
| 1339 |
0, |
| 1340 |
0, |
| 1341 |
0, |
| 1342 |
0, |
| 1343 |
0, |
| 1344 |
0, |
| 1345 |
Py_TPFLAGS_DEFAULT, |
| 1346 |
"Logging Config objects", |
| 1347 |
0, |
| 1348 |
0, |
| 1349 |
0, |
| 1350 |
0, |
| 1351 |
0, |
| 1352 |
0, |
| 1353 |
0, |
| 1354 |
PyObj_pjsua_logging_config_members, |
| 1355 |
0, |
| 1356 |
0, |
| 1357 |
0, |
| 1358 |
0, |
| 1359 |
0, |
| 1360 |
0, |
| 1361 |
0, |
| 1362 |
0, |
| 1363 |
PyObj_pjsua_logging_config_new, |
| 1364 |
|
| 1365 |
}; |
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
typedef struct |
| 1375 |
{ |
| 1376 |
PyObject_HEAD |
| 1377 |
|
| 1378 |
PyObject * hdr_list; |
| 1379 |
PyObject * content_type; |
| 1380 |
PyObject * msg_body; |
| 1381 |
} PyObj_pjsua_msg_data; |
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
static void PyObj_pjsua_msg_data_delete(PyObj_pjsua_msg_data* self) |
| 1390 |
{ |
| 1391 |
Py_XDECREF(self->hdr_list); |
| 1392 |
Py_XDECREF(self->content_type); |
| 1393 |
Py_XDECREF(self->msg_body); |
| 1394 |
self->ob_type->tp_free((PyObject*)self); |
| 1395 |
} |
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
static PyObject * PyObj_pjsua_msg_data_new(PyTypeObject *type, |
| 1404 |
PyObject *args, |
| 1405 |
PyObject *kwds) |
| 1406 |
{ |
| 1407 |
PyObj_pjsua_msg_data *self; |
| 1408 |
|
| 1409 |
PJ_UNUSED_ARG(args); |
| 1410 |
PJ_UNUSED_ARG(kwds); |
| 1411 |
|
| 1412 |
self = (PyObj_pjsua_msg_data *)type->tp_alloc(type, 0); |
| 1413 |
if (self != NULL) |
| 1414 |
{ |
| 1415 |
Py_INCREF(Py_None); |
| 1416 |
self->hdr_list = Py_None; |
| 1417 |
if (self->hdr_list == NULL) { |
| 1418 |
Py_DECREF(self); |
| 1419 |
return NULL; |
| 1420 |
} |
| 1421 |
self->content_type = PyString_FromString(""); |
| 1422 |
if (self->content_type == NULL) { |
| 1423 |
Py_DECREF(self); |
| 1424 |
return NULL; |
| 1425 |
} |
| 1426 |
self->msg_body = PyString_FromString(""); |
| 1427 |
if (self->msg_body == NULL) { |
| 1428 |
Py_DECREF(self); |
| 1429 |
return NULL; |
| 1430 |
} |
| 1431 |
} |
| 1432 |
|
| 1433 |
return (PyObject *)self; |
| 1434 |
} |
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
static PyMemberDef PyObj_pjsua_msg_data_members[] = |
| 1442 |
{ |
| 1443 |
{ |
| 1444 |
"hdr_list", T_OBJECT_EX, |
| 1445 |
offsetof(PyObj_pjsua_msg_data, hdr_list), 0, |
| 1446 |
"Additional message headers as linked list of strings." |
| 1447 |
}, |
| 1448 |
{ |
| 1449 |
"content_type", T_OBJECT_EX, |
| 1450 |
offsetof(PyObj_pjsua_msg_data, content_type), 0, |
| 1451 |
"MIME type of optional message body." |
| 1452 |
}, |
| 1453 |
{ |
| 1454 |
"msg_body", T_OBJECT_EX, |
| 1455 |
offsetof(PyObj_pjsua_msg_data, msg_body), 0, |
| 1456 |
"Optional message body." |
| 1457 |
}, |
| 1458 |
{NULL} |
| 1459 |
}; |
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
static PyTypeObject PyTyp_pjsua_msg_data = |
| 1466 |
{ |
| 1467 |
PyObject_HEAD_INIT(NULL) |
| 1468 |
0, |
| 1469 |
"py_pjsua.Msg_Data", |
| 1470 |
sizeof(PyObj_pjsua_msg_data), |
| 1471 |
0, |
| 1472 |
(destructor)PyObj_pjsua_msg_data_delete, |
| 1473 |
0, |
| 1474 |
0, |
| 1475 |
0, |
| 1476 |
0, |
| 1477 |
0, |
| 1478 |
0, |
| 1479 |
0, |
| 1480 |
0, |
| 1481 |
0, |
| 1482 |
0, |
| 1483 |
0, |
| 1484 |
0, |
| 1485 |
0, |
| 1486 |
0, |
| 1487 |
Py_TPFLAGS_DEFAULT, |
| 1488 |
"msg_data objects", |
| 1489 |
0, |
| 1490 |
0, |
| 1491 |
0, |
| 1492 |
0, |
| 1493 |
0, |
| 1494 |
0, |
| 1495 |
0, |
| 1496 |
PyObj_pjsua_msg_data_members, |
| 1497 |
0, |
| 1498 |
0, |
| 1499 |
0, |
| 1500 |
0, |
| 1501 |
0, |
| 1502 |
0, |
| 1503 |
0, |
| 1504 |
0, |
| 1505 |
PyObj_pjsua_msg_data_new, |
| 1506 |
|
| 1507 |
}; |
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
|
| 1515 |
|
| 1516 |
typedef struct |
| 1517 |
{ |
| 1518 |
PyObject_HEAD |
| 1519 |
|
| 1520 |
unsigned port; |
| 1521 |
PyObject *public_addr; |
| 1522 |
PyObject *bound_addr; |
| 1523 |
} PyObj_pjsua_transport_config; |
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
static void PyObj_pjsua_transport_config_delete(PyObj_pjsua_transport_config* self) |
| 1531 |
{ |
| 1532 |
Py_XDECREF(self->public_addr); |
| 1533 |
Py_XDECREF(self->bound_addr); |
| 1534 |
self->ob_type->tp_free((PyObject*)self); |
| 1535 |
} |
| 1536 |
|
| 1537 |
|
| 1538 |
static void PyObj_pjsua_transport_config_export(pjsua_transport_config *cfg, |
| 1539 |
PyObj_pjsua_transport_config *obj) |
| 1540 |
{ |
| 1541 |
cfg->public_addr = PyString_to_pj_str(obj->public_addr); |
| 1542 |
cfg->bound_addr = PyString_to_pj_str(obj->bound_addr); |
| 1543 |
cfg->port = obj->port; |
| 1544 |
|
| 1545 |
} |
| 1546 |
|
| 1547 |
static void PyObj_pjsua_transport_config_import(PyObj_pjsua_transport_config *obj, |
| 1548 |
const pjsua_transport_config *cfg) |
| 1549 |
{ |
| 1550 |
Py_XDECREF(obj->public_addr); |
| 1551 |
obj->public_addr = PyString_FromStringAndSize(cfg->public_addr.ptr, |
| 1552 |
cfg->public_addr.slen); |
| 1553 |
|
| 1554 |
Py_XDECREF(obj->bound_addr); |
| 1555 |
obj->bound_addr = PyString_FromStringAndSize(cfg->bound_addr.ptr, |
| 1556 |
cfg->bound_addr.slen); |
| 1557 |
|
| 1558 |
obj->port = cfg->port; |
| 1559 |
} |
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
|
| 1564 |
|
| 1565 |
|
| 1566 |
static PyObject * PyObj_pjsua_transport_config_new(PyTypeObject *type, |
| 1567 |
PyObject *args, |
| 1568 |
PyObject *kwds) |
| 1569 |
{ |
| 1570 |
PyObj_pjsua_transport_config *self; |
| 1571 |
|
| 1572 |
PJ_UNUSED_ARG(args); |
| 1573 |
PJ_UNUSED_ARG(kwds); |
| 1574 |
|
| 1575 |
self = (PyObj_pjsua_transport_config *)type->tp_alloc(type, 0); |
| 1576 |
if (self != NULL) { |
| 1577 |
self->public_addr = PyString_FromString(""); |
| 1578 |
if (self->public_addr == NULL) { |
| 1579 |
Py_DECREF(self); |
| 1580 |
return NULL; |
| 1581 |
} |
| 1582 |
self->bound_addr = PyString_FromString(""); |
| 1583 |
if (self->bound_addr == NULL) { |
| 1584 |
Py_DECREF(self); |
| 1585 |
return NULL; |
| 1586 |
} |
| 1587 |
} |
| 1588 |
|
| 1589 |
return (PyObject *)self; |
| 1590 |
} |
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
|
| 1596 |
static PyMemberDef PyObj_pjsua_transport_config_members[] = |
| 1597 |
{ |
| 1598 |
{ |
| 1599 |
"port", T_INT, |
| 1600 |
offsetof(PyObj_pjsua_transport_config, port), 0, |
| 1601 |
"UDP port number to bind locally. This setting MUST be specified " |
| 1602 |
"even when default port is desired. If the value is zero, the " |
| 1603 |
"transport will be bound to any available port, and application " |
| 1604 |
"can query the port by querying the transport info." |
| 1605 |
}, |
| 1606 |
{ |
| 1607 |
"public_addr", T_OBJECT_EX, |
| 1608 |
offsetof(PyObj_pjsua_transport_config, public_addr), 0, |
| 1609 |
"Optional address to advertise as the address of this transport. " |
| 1610 |
"Application can specify any address or hostname for this field, " |
| 1611 |
"for example it can point to one of the interface address in the " |
| 1612 |
"system, or it can point to the public address of a NAT router " |
| 1613 |
"where port mappings have been configured for the application." |
| 1614 |
}, |
| 1615 |
{ |
| 1616 |
"bound_addr", T_OBJECT_EX, |
| 1617 |
offsetof(PyObj_pjsua_transport_config, bound_addr), 0, |
| 1618 |
"Optional address where the socket should be bound to. This option " |
| 1619 |
"SHOULD only be used to selectively bind the socket to particular " |
| 1620 |
"interface (instead of 0.0.0.0), and SHOULD NOT be used to set the " |
| 1621 |
"published address of a transport (the public_addr field should be " |
| 1622 |
"used for that purpose)." |
| 1623 |
}, |
| 1624 |
{NULL} |
| 1625 |
}; |
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
static PyTypeObject PyTyp_pjsua_transport_config = |
| 1634 |
{ |
| 1635 |
PyObject_HEAD_INIT(NULL) |
| 1636 |
0, |
| 1637 |
"py_pjsua.Transport_Config", |
| 1638 |
sizeof(PyObj_pjsua_transport_config), |
| 1639 |
0, |
| 1640 |
(destructor)PyObj_pjsua_transport_config_delete, |
| 1641 |
0, |
| 1642 |
0, |
| 1643 |
0, |
| 1644 |
0, |
| 1645 |
0, |
| 1646 |
0, |
| 1647 |
0, |
| 1648 |
0, |
| 1649 |
0, |
| 1650 |
0, |
| 1651 |
0, |
| 1652 |
0, |
| 1653 |
0, |
| 1654 |
0, |
| 1655 |
Py_TPFLAGS_DEFAULT, |
| 1656 |
"Transport setting", |
| 1657 |
0, |
| 1658 |
0, |
| 1659 |
0, |
| 1660 |
0, |
| 1661 |
0, |
| 1662 |
0, |
| 1663 |
0, |
| 1664 |
PyObj_pjsua_transport_config_members, |
| 1665 |
0, |
| 1666 |
0, |
| 1667 |
0, |
| 1668 |
0, |
| 1669 |
0, |
| 1670 |
0, |
| 1671 |
0, |
| 1672 |
0, |
| 1673 |
PyObj_pjsua_transport_config_new, |
| 1674 |
}; |
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
typedef struct |
| 1683 |
{ |
| 1684 |
PyObject_HEAD |
| 1685 |
|
| 1686 |
int id; |
| 1687 |
int type; |
| 1688 |
PyObject *type_name; |
| 1689 |
PyObject *info; |
| 1690 |
unsigned flag; |
| 1691 |
PyObject *addr; |
| 1692 |
unsigned port; |
| 1693 |
unsigned usage_count; |
| 1694 |
} PyObj_pjsua_transport_info; |
| 1695 |
|
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
static void PyObj_pjsua_transport_info_delete(PyObj_pjsua_transport_info* self) |
| 1702 |
{ |
| 1703 |
Py_XDECREF(self->type_name); |
| 1704 |
Py_XDECREF(self->info); |
| 1705 |
Py_XDECREF(self->addr); |
| 1706 |
self->ob_type->tp_free((PyObject*)self); |
| 1707 |
} |
| 1708 |
|
| 1709 |
|
| 1710 |
static void PyObj_pjsua_transport_info_import(PyObj_pjsua_transport_info *obj, |
| 1711 |
const pjsua_transport_info *info) |
| 1712 |
{ |
| 1713 |
obj->id = info->id; |
| 1714 |
obj->type = info->type; |
| 1715 |
obj->type_name = PyString_FromStringAndSize(info->type_name.ptr, |
| 1716 |
info->type_name.slen); |
| 1717 |
obj->info = PyString_FromStringAndSize(info->info.ptr, |
| 1718 |
info->info.slen); |
| 1719 |
obj->flag = info->flag; |
| 1720 |
obj->addr = PyString_FromStringAndSize(info->local_name.host.ptr, |
| 1721 |
info->local_name.host.slen); |
| 1722 |
obj->port = info->local_name.port; |
| 1723 |
obj->usage_count= info->usage_count; |
| 1724 |
} |
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
static PyObject * PyObj_pjsua_transport_info_new(PyTypeObject *type, |
| 1731 |
PyObject *args, |
| 1732 |
PyObject *kwds) |
| 1733 |
{ |
| 1734 |
PyObj_pjsua_transport_info *self; |
| 1735 |
|
| 1736 |
PJ_UNUSED_ARG(args); |
| 1737 |
PJ_UNUSED_ARG(kwds); |
| 1738 |
|
| 1739 |
self = (PyObj_pjsua_transport_info *)type->tp_alloc(type, 0); |
| 1740 |
if (self != NULL) |
| 1741 |
{ |
| 1742 |
self->type_name = PyString_FromString(""); |
| 1743 |
if (self->type_name == NULL) { |
| 1744 |
Py_DECREF(self); |
| 1745 |
return NULL; |
| 1746 |
} |
| 1747 |
self->info = PyString_FromString(""); |
| 1748 |
if (self->info == NULL) { |
| 1749 |
Py_DECREF(self); |
| 1750 |
return NULL; |
| 1751 |
} |
| 1752 |
self->addr = PyString_FromString(""); |
| 1753 |
if (self->addr == NULL) { |
| 1754 |
Py_DECREF(self); |
| 1755 |
return NULL; |
| 1756 |
} |
| 1757 |
} |
| 1758 |
|
| 1759 |
return (PyObject *)self; |
| 1760 |
} |
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
static PyMemberDef PyObj_pjsua_transport_info_members[] = |
| 1767 |
{ |
| 1768 |
{ |
| 1769 |
"id", T_INT, |
| 1770 |
offsetof(PyObj_pjsua_transport_info, id), 0, |
| 1771 |
"PJSUA transport identification." |
| 1772 |
}, |
| 1773 |
{ |
| 1774 |
"type", T_INT, |
| 1775 |
offsetof(PyObj_pjsua_transport_info, id), 0, |
| 1776 |
"Transport type." |
| 1777 |
}, |
| 1778 |
{ |
| 1779 |
"type_name", T_OBJECT_EX, |
| 1780 |
offsetof(PyObj_pjsua_transport_info, type_name), 0, |
| 1781 |
"Transport type name." |
| 1782 |
}, |
| 1783 |
{ |
| 1784 |
"info", T_OBJECT_EX, |
| 1785 |
offsetof(PyObj_pjsua_transport_info, info), 0, |
| 1786 |
"Transport string info/description." |
| 1787 |
}, |
| 1788 |
{ |
| 1789 |
"flag", T_INT, |
| 1790 |
offsetof(PyObj_pjsua_transport_info, flag), 0, |
| 1791 |
"Transport flag (see ##pjsip_transport_flags_e)." |
| 1792 |
}, |
| 1793 |
{ |
| 1794 |
"addr", T_OBJECT_EX, |
| 1795 |
offsetof(PyObj_pjsua_transport_info, addr), 0, |
| 1796 |
"Published address (or transport address name)." |
| 1797 |
}, |
| 1798 |
{ |
| 1799 |
"port", T_INT, |
| 1800 |
offsetof(PyObj_pjsua_transport_info, port), 0, |
| 1801 |
"Published port number." |
| 1802 |
}, |
| 1803 |
{ |
| 1804 |
"usage_count", T_INT, |
| 1805 |
offsetof(PyObj_pjsua_transport_info, usage_count), 0, |
| 1806 |
"Current number of objects currently referencing this transport." |
| 1807 |
}, |
| 1808 |
{NULL} |
| 1809 |
}; |
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
static PyTypeObject PyTyp_pjsua_transport_info = |
| 1816 |
{ |
| 1817 |
PyObject_HEAD_INIT(NULL) |
| 1818 |
0, |
| 1819 |
"py_pjsua.Transport_Info", |
| 1820 |
sizeof(PyObj_pjsua_transport_info), |
| 1821 |
0, |
| 1822 |
(destructor)PyObj_pjsua_transport_info_delete, |
| 1823 |
0, |
| 1824 |
0, |
| 1825 |
0, |
| 1826 |
0, |
| 1827 |
0, |
| 1828 |
0, |
| 1829 |
0, |
| 1830 |
0, |
| 1831 |
0, |
| 1832 |
0, |
| 1833 |
0, |
| 1834 |
0, |
| 1835 |
0, |
| 1836 |
0, |
| 1837 |
Py_TPFLAGS_DEFAULT, |
| 1838 |
"Transport Info objects", |
| 1839 |
0, |
| 1840 |
0, |
| 1841 |
0, |
| 1842 |
0, |
| 1843 |
0, |
| 1844 |
0, |
| 1845 |
0, |
| 1846 |
PyObj_pjsua_transport_info_members, |
| 1847 |
0, |
| 1848 |
0, |
| 1849 |
0, |
| 1850 |
0, |
| 1851 |
0, |
| 1852 |
0, |
| 1853 |
0, |
| 1854 |
0, |
| 1855 |
PyObj_pjsua_transport_info_new, |
| 1856 |
|
| 1857 |
}; |
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
typedef struct |
| 1867 |
{ |
| 1868 |
PyObject_HEAD |
| 1869 |
|
| 1870 |
int priority; |
| 1871 |
PyObject *id; |
| 1872 |
PyObject *reg_uri; |
| 1873 |
int publish_enabled; |
| 1874 |
PyObject *force_contact; |
| 1875 |
|
| 1876 |
PyListObject *proxy; |
| 1877 |
unsigned reg_timeout; |
| 1878 |
|
| 1879 |
PyListObject *cred_info; |
| 1880 |
int transport_id; |
| 1881 |
} PyObj_pjsua_acc_config; |
| 1882 |
|
| 1883 |
|
| 1884 |
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
static void PyObj_pjsua_acc_config_delete(PyObj_pjsua_acc_config* self) |
| 1889 |
{ |
| 1890 |
Py_XDECREF(self->id); |
| 1891 |
Py_XDECREF(self->reg_uri); |
| 1892 |
Py_XDECREF(self->force_contact); |
| 1893 |
Py_XDECREF(self->proxy); |
| 1894 |
Py_XDECREF(self->cred_info); |
| 1895 |
self->ob_type->tp_free((PyObject*)self); |
| 1896 |
} |
| 1897 |
|
| 1898 |
|
| 1899 |
static void PyObj_pjsua_acc_config_import(PyObj_pjsua_acc_config *obj, |
| 1900 |
const pjsua_acc_config *cfg) |
| 1901 |
{ |
| 1902 |
unsigned i; |
| 1903 |
|
| 1904 |
obj->priority = cfg->priority; |
| 1905 |
Py_XDECREF(obj->id); |
| 1906 |
obj->id = PyString_FromStringAndSize(cfg->id.ptr, cfg->id.slen); |
| 1907 |
Py_XDECREF(obj->reg_uri); |
| 1908 |
obj->reg_uri = PyString_FromStringAndSize(cfg->reg_uri.ptr, |
| 1909 |
cfg->reg_uri.slen); |
| 1910 |
obj->publish_enabled = cfg->publish_enabled; |
| 1911 |
Py_XDECREF(obj->force_contact); |
| 1912 |
obj->force_contact = PyString_FromStringAndSize(cfg->force_contact.ptr, |
| 1913 |
cfg->force_contact.slen); |
| 1914 |
Py_XDECREF(obj->proxy); |
| 1915 |
obj->proxy = (PyListObject *)PyList_New(0); |
| 1916 |
for (i=0; i<cfg->proxy_cnt; ++i) { |
| 1917 |
PyObject * str; |
| 1918 |
str = PyString_FromStringAndSize(cfg->proxy[i].ptr, |
| 1919 |
cfg->proxy[i].slen); |
| 1920 |
PyList_Append((PyObject *)obj->proxy, str); |
| 1921 |
} |
| 1922 |
|
| 1923 |
obj->reg_timeout = cfg->reg_timeout; |
| 1924 |
|
| 1925 |
Py_XDECREF(obj->cred_info); |
| 1926 |
obj->cred_info = (PyListObject *)PyList_New(0); |
| 1927 |
for (i=0; i<cfg->cred_count; ++i) { |
| 1928 |
PyObj_pjsip_cred_info * ci; |
| 1929 |
|
| 1930 |
ci = (PyObj_pjsip_cred_info *) |
| 1931 |
PyObj_pjsip_cred_info_new(&PyTyp_pjsip_cred_info,NULL,NULL); |
| 1932 |
PyObj_pjsip_cred_info_import(ci, &cfg->cred_info[i]); |
| 1933 |
PyList_Append((PyObject *)obj->cred_info, (PyObject *)ci); |
| 1934 |
} |
| 1935 |
|
| 1936 |
obj->transport_id = cfg->transport_id; |
| 1937 |
} |
| 1938 |
|
| 1939 |
static void PyObj_pjsua_acc_config_export(pjsua_acc_config *cfg, |
| 1940 |
PyObj_pjsua_acc_config *obj) |
| 1941 |
{ |
| 1942 |
unsigned i; |
| 1943 |
|
| 1944 |
cfg->priority = obj->priority; |
| 1945 |
cfg->id = PyString_to_pj_str(obj->id); |
| 1946 |
cfg->reg_uri = PyString_to_pj_str(obj->reg_uri); |
| 1947 |
cfg->publish_enabled = obj->publish_enabled; |
| 1948 |
cfg->force_contact = PyString_to_pj_str(obj->force_contact); |
| 1949 |
|
| 1950 |
cfg->proxy_cnt = PyList_Size((PyObject*)obj->proxy); |
| 1951 |
for (i = 0; i < cfg->proxy_cnt; i++) { |
| 1952 |
|
| 1953 |
cfg->proxy[i] = PyString_to_pj_str(PyList_GetItem((PyObject *)obj->proxy,i)); |
| 1954 |
} |
| 1955 |
|
| 1956 |
cfg->reg_timeout = obj->reg_timeout; |
| 1957 |
|
| 1958 |
cfg->cred_count = PyList_Size((PyObject*)obj->cred_info); |
| 1959 |
for (i = 0; i < cfg->cred_count; i++) { |
| 1960 |
|
| 1961 |
PyObj_pjsip_cred_info *ci; |
| 1962 |
ci = (PyObj_pjsip_cred_info*) |
| 1963 |
PyList_GetItem((PyObject *)obj->cred_info,i); |
| 1964 |
PyObj_pjsip_cred_info_export(&cfg->cred_info[i], ci); |
| 1965 |
} |
| 1966 |
|
| 1967 |
cfg->transport_id = obj->transport_id; |
| 1968 |
} |
| 1969 |
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
static PyObject * PyObj_pjsua_acc_config_new(PyTypeObject *type, |
| 1976 |
PyObject *args, |
| 1977 |
PyObject *kwds) |
| 1978 |
{ |
| 1979 |
PyObj_pjsua_acc_config *self; |
| 1980 |
|
| 1981 |
PJ_UNUSED_ARG(args); |
| 1982 |
PJ_UNUSED_ARG(kwds); |
| 1983 |
|
| 1984 |
self = (PyObj_pjsua_acc_config *)type->tp_alloc(type, 0); |
| 1985 |
if (self != NULL) { |
| 1986 |
self->id = PyString_FromString(""); |
| 1987 |
if (self->id == NULL) { |
| 1988 |
Py_DECREF(self); |
| 1989 |
return NULL; |
| 1990 |
} |
| 1991 |
self->reg_uri = PyString_FromString(""); |
| 1992 |
if (self->reg_uri == NULL) { |
| 1993 |
Py_DECREF(self); |
| 1994 |
return NULL; |
| 1995 |
} |
| 1996 |
self->force_contact = PyString_FromString(""); |
| 1997 |
if (self->force_contact == NULL) { |
| 1998 |
Py_DECREF(self); |
| 1999 |
return NULL; |
| 2000 |
} |
| 2001 |
self->proxy = (PyListObject *)PyList_New(0); |
| 2002 |
if (self->proxy == NULL) { |
| 2003 |
Py_DECREF(self); |
| 2004 |
return NULL; |
| 2005 |
} |
| 2006 |
self->cred_info = (PyListObject *)PyList_New(0); |
| 2007 |
if (self->cred_info == NULL) { |
| 2008 |
Py_DECREF(self); |
| 2009 |
return NULL; |
| 2010 |
} |
| 2011 |
} |
| 2012 |
|
| 2013 |
return (PyObject *)self; |
| 2014 |
} |
| 2015 |
|
| 2016 |
|
| 2017 |
|
| 2018 |
|
| 2019 |
|
| 2020 |
|
| 2021 |
static PyMemberDef PyObj_pjsua_acc_config_members[] = |
| 2022 |
{ |
| 2023 |
{ |
| 2024 |
"priority", T_INT, offsetof(PyObj_pjsua_acc_config, priority), 0, |
| 2025 |
"Account priority, which is used to control the order of matching " |
| 2026 |
"incoming/outgoing requests. The higher the number means the higher " |
| 2027 |
"the priority is, and the account will be matched first. " |
| 2028 |
}, |
| 2029 |
{ |
| 2030 |
"id", T_OBJECT_EX, |
| 2031 |
offsetof(PyObj_pjsua_acc_config, id), 0, |
| 2032 |
"The full SIP URL for the account. " |
| 2033 |
"The value can take name address or URL format, " |
| 2034 |
"and will look something like 'sip:account@serviceprovider'. " |
| 2035 |
"This field is mandatory." |
| 2036 |
}, |
| 2037 |
{ |
| 2038 |
"reg_uri", T_OBJECT_EX, |
| 2039 |
offsetof(PyObj_pjsua_acc_config, reg_uri), 0, |
| 2040 |
"This is the URL to be put in the request URI for the registration, " |
| 2041 |
"and will look something like 'sip:serviceprovider'. " |
| 2042 |
"This field should be specified if registration is desired. " |
| 2043 |
"If the value is empty, no account registration will be performed. " |
| 2044 |
}, |
| 2045 |
{ |
| 2046 |
"publish_enabled", T_INT, |
| 2047 |
offsetof(PyObj_pjsua_acc_config, publish_enabled), 0, |
| 2048 |
"Publish presence? " |
| 2049 |
}, |
| 2050 |
{ |
| 2051 |
"force_contact", T_OBJECT_EX, |
| 2052 |
offsetof(PyObj_pjsua_acc_config, force_contact), 0, |
| 2053 |
"Optional URI to be put as Contact for this account. " |
| 2054 |
"It is recommended that this field is left empty, " |
| 2055 |
"so that the value will be calculated automatically " |
| 2056 |
"based on the transport address. " |
| 2057 |
}, |
| 2058 |
{ |
| 2059 |
"proxy", T_OBJECT_EX, |
| 2060 |
offsetof(PyObj_pjsua_acc_config, proxy), 0, |
| 2061 |
"Optional URI of the proxies to be visited for all outgoing requests " |
| 2062 |
"that are using this account (REGISTER, INVITE, etc). Application need " |
| 2063 |
"to specify these proxies if the service provider requires " |
| 2064 |
"that requests destined towards its network should go through certain " |
| 2065 |
"proxies first (for example, border controllers)." |
| 2066 |
}, |
| 2067 |
{ |
| 2068 |
"reg_timeout", T_INT, offsetof(PyObj_pjsua_acc_config, reg_timeout), 0, |
| 2069 |
"Optional interval for registration, in seconds. " |
| 2070 |
"If the value is zero, default interval will be used " |
| 2071 |
"(PJSUA_REG_INTERVAL, 55 seconds). " |
| 2072 |
}, |
| 2073 |
{ |
| 2074 |
"cred_info", T_OBJECT_EX, |
| 2075 |
offsetof(PyObj_pjsua_acc_config, cred_info), 0, |
| 2076 |
"Array of credentials. If registration is desired, normally there " |
| 2077 |
"should be at least one credential specified, to successfully " |
| 2078 |
"authenticate against the service provider. More credentials can " |
| 2079 |
"be specified, for example when the requests are expected to be " |
| 2080 |
"challenged by the proxies in the route set." |
| 2081 |
}, |
| 2082 |
{ |
| 2083 |
"transport_id", T_INT, |
| 2084 |
offsetof(PyObj_pjsua_acc_config, transport_id), 0, |
| 2085 |
"Optionally bind this account to specific transport. This normally is" |
| 2086 |
" not a good idea, as account should be able to send requests using" |
| 2087 |
" any available transports according to the destination. But some" |
| 2088 |
" application may want to have explicit control over the transport to" |
| 2089 |
" use, so in that case it can set this field." |
| 2090 |
}, |
| 2091 |
{NULL} |
| 2092 |
}; |
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
|
| 2097 |
|
| 2098 |
|
| 2099 |
|
| 2100 |
static PyTypeObject PyTyp_pjsua_acc_config = |
| 2101 |
{ |
| 2102 |
PyObject_HEAD_INIT(NULL) |
| 2103 |
0, |
| 2104 |
"py_pjsua.Acc_Config", |
| 2105 |
sizeof(PyObj_pjsua_acc_config), |
| 2106 |
0, |
| 2107 |
(destructor)PyObj_pjsua_acc_config_delete, |
| 2108 |
0, |
| 2109 |
0, |
| 2110 |
0, |
| 2111 |
0, |
| 2112 |
0, |
| 2113 |
0, |
| 2114 |
0, |
| 2115 |
0, |
| 2116 |
0, |
| 2117 |
0, |
| 2118 |
0, |
| 2119 |
0, |
| 2120 |
0, |
| 2121 |
0, |
| 2122 |
Py_TPFLAGS_DEFAULT, |
| 2123 |
"Acc Config objects", |
| 2124 |
0, |
| 2125 |
0, |
| 2126 |
0, |
| 2127 |
0, |
| 2128 |
0, |
| 2129 |
0, |
| 2130 |
0, |
| 2131 |
PyObj_pjsua_acc_config_members, |
| 2132 |
0, |
| 2133 |
0, |
| 2134 |
0, |
| 2135 |
0, |
| 2136 |
0, |
| 2137 |
0, |
| 2138 |
0, |
| 2139 |
0, |
| 2140 |
PyObj_pjsua_acc_config_new, |
| 2141 |
|
| 2142 |
}; |
| 2143 |
|
| 2144 |
|
| 2145 |
|
| 2146 |
|
| 2147 |
|
| 2148 |
|
| 2149 |
|
| 2150 |
typedef struct |
| 2151 |
{ |
| 2152 |
PyObject_HEAD |
| 2153 |
|
| 2154 |
int id; |
| 2155 |
int is_default; |
| 2156 |
PyObject *acc_uri; |
| 2157 |
int has_registration; |
| 2158 |
int expires; |
| 2159 |
int status; |
| 2160 |
PyObject *status_text; |
| 2161 |
int online_status; |
| 2162 |
PyObject *online_status_text; |
| 2163 |
} PyObj_pjsua_acc_info; |
| 2164 |
|
| 2165 |
|
| 2166 |
|
| 2167 |
|
| 2168 |
|
| 2169 |
|
| 2170 |
static void PyObj_pjsua_acc_info_delete(PyObj_pjsua_acc_info* self) |
| 2171 |
{ |
| 2172 |
Py_XDECREF(self->acc_uri); |
| 2173 |
Py_XDECREF(self->status_text); |
| 2174 |
Py_XDECREF(self->online_status_text); |
| 2175 |
self->ob_type->tp_free((PyObject*)self); |
| 2176 |
} |
| 2177 |
|
| 2178 |
|
| 2179 |
static void PyObj_pjsua_acc_info_import(PyObj_pjsua_acc_info *obj, |
| 2180 |
const pjsua_acc_info *info) |
| 2181 |
{ |
| 2182 |
obj->id = info->id; |
| 2183 |
obj->is_default = info->is_default; |
| 2184 |
obj->acc_uri = PyString_FromStringAndSize(info->acc_uri.ptr, |
| 2185 |
info->acc_uri.slen); |
| 2186 |
obj->has_registration = info->has_registration; |
| 2187 |
obj->expires = info->expires; |
| 2188 |
obj->status = info->status; |
| 2189 |
obj->status_text= PyString_FromStringAndSize(info->status_text.ptr, |
| 2190 |
info->status_text.slen); |
| 2191 |
obj->online_status = info->online_status; |
| 2192 |
obj->online_status_text = PyString_FromStringAndSize(info->online_status_text.ptr, |
| 2193 |
info->online_status_text.slen); |
| 2194 |
} |
| 2195 |
|
| 2196 |
|
| 2197 |
|
| 2198 |
|
| 2199 |
|
| 2200 |
|
| 2201 |
static PyObject * PyObj_pjsua_acc_info_new(PyTypeObject *type, |
| 2202 |
PyObject *args, |
| 2203 |
PyObject *kwds) |
| 2204 |
{ |
| 2205 |
PyObj_pjsua_acc_info *self; |
| 2206 |
|
| 2207 |
PJ_UNUSED_ARG(args); |
| 2208 |
PJ_UNUSED_ARG(kwds); |
| 2209 |
|
| 2210 |
self = (PyObj_pjsua_acc_info *)type->tp_alloc(type, 0); |
| 2211 |
if (self != NULL) { |
| 2212 |
self->acc_uri = PyString_FromString(""); |
| 2213 |
if (self->acc_uri == NULL) { |
| 2214 |
Py_DECREF(self); |
| 2215 |
return NULL; |
| 2216 |
} |
| 2217 |
self->status_text = PyString_FromString(""); |
| 2218 |
if (self->status_text == NULL) { |
| 2219 |
Py_DECREF(self); |
| 2220 |
return NULL; |
| 2221 |
} |
| 2222 |
self->online_status_text = PyString_FromString(""); |
| 2223 |
if (self->online_status_text == NULL) { |
| 2224 |
Py_DECREF(self); |
| 2225 |
return NULL; |
| 2226 |
} |
| 2227 |
} |
| 2228 |
|
| 2229 |
return (PyObject *)self; |
| 2230 |
} |
| 2231 |
|
| 2232 |
|
| 2233 |
|
| 2234 |
|
| 2235 |
static PyMemberDef acc_info_members[] = |
| 2236 |
{ |
| 2237 |
{ |
| 2238 |
"id", T_INT, |
| 2239 |
offsetof(PyObj_pjsua_acc_info, id), 0, |
| 2240 |
"The account ID." |
| 2241 |
}, |
| 2242 |
{ |
| 2243 |
"is_default", T_INT, |
| 2244 |
offsetof(PyObj_pjsua_acc_info, is_default), 0, |
| 2245 |
"Flag to indicate whether this is the default account. " |
| 2246 |
}, |
| 2247 |
{ |
| 2248 |
"acc_uri", T_OBJECT_EX, |
| 2249 |
offsetof(PyObj_pjsua_acc_info, acc_uri), 0, |
| 2250 |
"Account URI" |
| 2251 |
}, |
| 2252 |
{ |
| 2253 |
"has_registration", T_INT, |
| 2254 |
offsetof(PyObj_pjsua_acc_info, has_registration), 0, |
| 2255 |
"Flag to tell whether this account has registration setting " |
| 2256 |
"(reg_uri is not empty)." |
| 2257 |
}, |
| 2258 |
{ |
| 2259 |
"expires", T_INT, |
| 2260 |
offsetof(PyObj_pjsua_acc_info, expires), 0, |
| 2261 |
"An up to date expiration interval for account registration session." |
| 2262 |
}, |
| 2263 |
{ |
| 2264 |
"status", T_INT, |
| 2265 |
offsetof(PyObj_pjsua_acc_info, status), 0, |
| 2266 |
"Last registration status code. If status code is zero, " |
| 2267 |
"the account is currently not registered. Any other value indicates " |
| 2268 |
"the SIP status code of the registration. " |
| 2269 |
}, |
| 2270 |
{ |
| 2271 |
"status_text", T_OBJECT_EX, |
| 2272 |
offsetof(PyObj_pjsua_acc_info, status_text), 0, |
| 2273 |
"String describing the registration status." |
| 2274 |
}, |
| 2275 |
{ |
| 2276 |
"online_status", T_INT, |
| 2277 |
offsetof(PyObj_pjsua_acc_info, online_status), 0, |
| 2278 |
"Presence online status for this account. " |
| 2279 |
}, |
| 2280 |
{ |
| 2281 |
"online_status_text", T_OBJECT_EX, |
| 2282 |
offsetof(PyObj_pjsua_acc_info, online_status_text), 0, |
| 2283 |
"Presence online status text." |
| 2284 |
}, |
| 2285 |
{NULL} |
| 2286 |
}; |
| 2287 |
|
| 2288 |
|
| 2289 |
|
| 2290 |
|
| 2291 |
|
| 2292 |
|
| 2293 |
|
| 2294 |
static PyTypeObject PyTyp_pjsua_acc_info = |
| 2295 |
{ |
| 2296 |
PyObject_HEAD_INIT(NULL) |
| 2297 |
0, |
| 2298 |
"py_pjsua.Acc_Info", |
| 2299 |
sizeof(PyObj_pjsua_acc_info), |
| 2300 |
0, |
| 2301 |
(destructor)PyObj_pjsua_acc_info_delete, |
| 2302 |
0, |
| 2303 |
0, |
| 2304 |
0, |
| 2305 |
0, |
| 2306 |
0, |
| 2307 |
0, |
| 2308 |
0, |
| 2309 |
0, |
| 2310 |
0, |
| 2311 |
0, |
| 2312 |
0, |
| 2313 |
0, |
| 2314 |
0, |
| 2315 |
0, |
| 2316 |
Py_TPFLAGS_DEFAULT, |
| 2317 |
"Acc Info objects", |
| 2318 |
0, |
| 2319 |
0, |
| 2320 |
0, |
| 2321 |
0, |
| 2322 |
0, |
| 2323 |
0, |
| 2324 |
NULL, |
| 2325 |
acc_info_members, |
| 2326 |
0, |
| 2327 |
0, |
| 2328 |
0, |
| 2329 |
0, |
| 2330 |
0, |
| 2331 |
0, |
| 2332 |
0, |
| 2333 |
0, |
| 2334 |
PyObj_pjsua_acc_info_new, |
| 2335 |
|
| 2336 |
}; |
| 2337 |
|
| 2338 |
|
| 2339 |
|
| 2340 |
|
| 2341 |
|
| 2342 |
|
| 2343 |
|
| 2344 |
|
| 2345 |
typedef struct |
| 2346 |
{ |
| 2347 |
PyObject_HEAD |
| 2348 |
|
| 2349 |
PyObject *uri; |
| 2350 |
int subscribe; |
| 2351 |
} PyObj_pjsua_buddy_config; |
| 2352 |
|
| 2353 |
|
| 2354 |
|
| 2355 |
|
| 2356 |
|
| 2357 |
|
| 2358 |
static void PyObj_pjsua_buddy_config_delete(PyObj_pjsua_buddy_config* self) |
| 2359 |
{ |
| 2360 |
Py_XDECREF(self->uri); |
| 2361 |
self->ob_type->tp_free((PyObject*)self); |
| 2362 |
} |
| 2363 |
|
| 2364 |
|
| 2365 |
static void PyObj_pjsua_buddy_config_import(PyObj_pjsua_buddy_config *obj, |
| 2366 |
const pjsua_buddy_config *cfg) |
| 2367 |
{ |
| 2368 |
Py_XDECREF(obj->uri); |
| 2369 |
obj->uri = PyString_FromStringAndSize(cfg->uri.ptr, cfg->uri.slen); |
| 2370 |
obj->subscribe = cfg->subscribe; |
| 2371 |
} |
| 2372 |
|
| 2373 |
|
| 2374 |
static void PyObj_pjsua_buddy_config_export(pjsua_buddy_config *cfg, |
| 2375 |
PyObj_pjsua_buddy_config *obj) |
| 2376 |
{ |
| 2377 |
cfg->uri = PyString_to_pj_str(obj->uri); |
| 2378 |
cfg->subscribe = obj->subscribe; |
| 2379 |
} |
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
|
| 2384 |
|
| 2385 |
|
| 2386 |
|
| 2387 |
static PyObject *PyObj_pjsua_buddy_config_new(PyTypeObject *type, |
| 2388 |
PyObject *args, |
| 2389 |
PyObject *kwds) |
| 2390 |
{ |
| 2391 |
PyObj_pjsua_buddy_config *self; |
| 2392 |
|
| 2393 |
PJ_UNUSED_ARG(args); |
| 2394 |
PJ_UNUSED_ARG(kwds); |
| 2395 |
|
| 2396 |
self = (PyObj_pjsua_buddy_config *)type->tp_alloc(type, 0); |
| 2397 |
if (self != NULL) { |
| 2398 |
self->uri = PyString_FromString(""); |
| 2399 |
if (self->uri == NULL) { |
| 2400 |
Py_DECREF(self); |
| 2401 |
return NULL; |
| 2402 |
} |
| 2403 |
} |
| 2404 |
return (PyObject *)self; |
| 2405 |
} |
| 2406 |
|
| 2407 |
|
| 2408 |
|
| 2409 |
|
| 2410 |
static PyMemberDef PyObj_pjsua_buddy_config_members[] = |
| 2411 |
{ |
| 2412 |
|
| 2413 |
{ |
| 2414 |
"uri", T_OBJECT_EX, |
| 2415 |
offsetof(PyObj_pjsua_buddy_config, uri), 0, |
| 2416 |
"TBuddy URL or name address." |
| 2417 |
}, |
| 2418 |
|
| 2419 |
{ |
| 2420 |
"subscribe", T_INT, |
| 2421 |
offsetof(PyObj_pjsua_buddy_config, subscribe), 0, |
| 2422 |
"Specify whether presence subscription should start immediately. " |
| 2423 |
}, |
| 2424 |
|
| 2425 |
{NULL} |
| 2426 |
}; |
| 2427 |
|
| 2428 |
|
| 2429 |
|
| 2430 |
|
| 2431 |
|
| 2432 |
|
| 2433 |
|
| 2434 |
static PyTypeObject PyTyp_pjsua_buddy_config = |
| 2435 |
{ |
| 2436 |
PyObject_HEAD_INIT(NULL) |
| 2437 |
0, |
| 2438 |
"py_pjsua.Buddy_Config", |
| 2439 |
sizeof(PyObj_pjsua_buddy_config), |
| 2440 |
0, |
| 2441 |
(destructor)PyObj_pjsua_buddy_config_delete, |
| 2442 |
0, |
| 2443 |
0, |
| 2444 |
0, |
| 2445 |
0, |
| 2446 |
0, |
| 2447 |
0, |
| 2448 |
0, |
| 2449 |
0, |
| 2450 |
0, |
| 2451 |
0, |
| 2452 |
0, |
| 2453 |
0, |
| 2454 |
0, |
| 2455 |
0, |
| 2456 |
Py_TPFLAGS_DEFAULT, |
| 2457 |
"Buddy Config objects", |
| 2458 |
0, |
| 2459 |
0, |
| 2460 |
0, |
| 2461 |
0, |
| 2462 |
0, |
| 2463 |
0, |
| 2464 |
0, |
| 2465 |
PyObj_pjsua_buddy_config_members, |
| 2466 |
0, |
| 2467 |
0, |
| 2468 |
0, |
| 2469 |
0, |
| 2470 |
0, |
| 2471 |
0, |
| 2472 |
0, |
| 2473 |
0, |
| 2474 |
PyObj_pjsua_buddy_config_new, |
| 2475 |
|
| 2476 |
}; |
| 2477 |
|
| 2478 |
|
| 2479 |
|
| 2480 |
|
| 2481 |
|
| 2482 |
|
| 2483 |
typedef struct |
| 2484 |
{ |
| 2485 |
PyObject_HEAD |
| 2486 |
|
| 2487 |
int id; |
| 2488 |
PyObject *uri; |
| 2489 |
PyObject *contact; |
| 2490 |
int status; |
| 2491 |
PyObject *status_text; |
| 2492 |
int monitor_pres; |
| 2493 |
} PyObj_pjsua_buddy_info; |
| 2494 |
|
| 2495 |
|
| 2496 |
|
| 2497 |
|
| 2498 |
|
| 2499 |
|
| 2500 |
|
| 2501 |
static void PyObj_pjsua_buddy_info_delete(PyObj_pjsua_buddy_info* self) |
| 2502 |
{ |
| 2503 |
Py_XDECREF(self->uri); |
| 2504 |
Py_XDECREF(self->contact); |
| 2505 |
Py_XDECREF(self->status_text); |
| 2506 |
|
| 2507 |
self->ob_type->tp_free((PyObject*)self); |
| 2508 |
} |
| 2509 |
|
| 2510 |
|
| 2511 |
static void PyObj_pjsua_buddy_info_import(PyObj_pjsua_buddy_info *obj, |
| 2512 |
const pjsua_buddy_info *info) |
| 2513 |
{ |
| 2514 |
obj->id = info->id; |
| 2515 |
Py_XDECREF(obj->uri); |
| 2516 |
obj->uri = PyString_FromStringAndSize(info->uri.ptr, info->uri.slen); |
| 2517 |
Py_XDECREF(obj->contact); |
| 2518 |
obj->contact = PyString_FromStringAndSize(info->contact.ptr, info->contact.slen); |
| 2519 |
obj->status = info->status; |
| 2520 |
Py_XDECREF(obj->status_text); |
| 2521 |
obj->status_text = PyString_FromStringAndSize(info->status_text.ptr, |
| 2522 |
info->status_text.slen); |
| 2523 |
obj->monitor_pres = info->monitor_pres; |
| 2524 |
} |
| 2525 |
|
| 2526 |
|
| 2527 |
|
| 2528 |
|
| 2529 |
|
| 2530 |
|
| 2531 |
|
| 2532 |
static PyObject * PyObj_pjsua_buddy_info_new(PyTypeObject *type, |
| 2533 |
PyObject *args, |
| 2534 |
PyObject *kwds) |
| 2535 |
{ |
| 2536 |
PyObj_pjsua_buddy_info *self; |
| 2537 |
|
| 2538 |
PJ_UNUSED_ARG(args); |
| 2539 |
PJ_UNUSED_ARG(kwds); |
| 2540 |
|
| 2541 |
self = (PyObj_pjsua_buddy_info *)type->tp_alloc(type, 0); |
| 2542 |
if (self != NULL) { |
| 2543 |
self->uri = PyString_FromString(""); |
| 2544 |
if (self->uri == NULL) { |
| 2545 |
Py_DECREF(self); |
| 2546 |
return NULL; |
| 2547 |
} |
| 2548 |
self->contact = PyString_FromString(""); |
| 2549 |
if (self->contact == NULL) { |
| 2550 |
Py_DECREF(self); |
| 2551 |
return NULL; |
| 2552 |
} |
| 2553 |
self->status_text = PyString_FromString(""); |
| 2554 |
if (self->status_text == NULL) { |
| 2555 |
Py_DECREF(self); |
| 2556 |
return NULL; |
| 2557 |
} |
| 2558 |
|
| 2559 |
} |
| 2560 |
return (PyObject *)self; |
| 2561 |
} |
| 2562 |
|
| 2563 |
|
| 2564 |
|
| 2565 |
|
| 2566 |
|
| 2567 |
static PyMemberDef PyObj_pjsua_buddy_info_members[] = |
| 2568 |
{ |
| 2569 |
{ |
| 2570 |
"id", T_INT, |
| 2571 |
offsetof(PyObj_pjsua_buddy_info, id), 0, |
| 2572 |
"The buddy ID." |
| 2573 |
}, |
| 2574 |
{ |
| 2575 |
"uri", T_OBJECT_EX, |
| 2576 |
offsetof(PyObj_pjsua_buddy_info, uri), 0, |
| 2577 |
"The full URI of the buddy, as specified in the configuration. " |
| 2578 |
}, |
| 2579 |
{ |
| 2580 |
"contact", T_OBJECT_EX, |
| 2581 |
offsetof(PyObj_pjsua_buddy_info, contact), 0, |
| 2582 |
"Buddy's Contact, only available when presence subscription " |
| 2583 |
"has been established to the buddy." |
| 2584 |
}, |
| 2585 |
{ |
| 2586 |
"status", T_INT, |
| 2587 |
offsetof(PyObj_pjsua_buddy_info, status), 0, |
| 2588 |
"Buddy's online status. " |
| 2589 |
}, |
| 2590 |
{ |
| 2591 |
"status_text", T_OBJECT_EX, |
| 2592 |
offsetof(PyObj_pjsua_buddy_info, status_text), 0, |
| 2593 |
"Text to describe buddy's online status." |
| 2594 |
}, |
| 2595 |
{ |
| 2596 |
"monitor_pres", T_INT, |
| 2597 |
offsetof(PyObj_pjsua_buddy_info, monitor_pres), 0, |
| 2598 |
"Flag to indicate that we should monitor the presence information " |
| 2599 |
"for this buddy (normally yes, unless explicitly disabled). " |
| 2600 |
}, |
| 2601 |
|
| 2602 |
|
| 2603 |
{NULL} |
| 2604 |
}; |
| 2605 |
|
| 2606 |
|
| 2607 |
|
| 2608 |
|
| 2609 |
|
| 2610 |
|
| 2611 |
|
| 2612 |
static PyTypeObject PyTyp_pjsua_buddy_info = |
| 2613 |
{ |
| 2614 |
PyObject_HEAD_INIT(NULL) |
| 2615 |
0, |
| 2616 |
"py_pjsua.Buddy_Info", |
| 2617 |
sizeof(PyObj_pjsua_buddy_info), |
| 2618 |
0, |
| 2619 |
(destructor)PyObj_pjsua_buddy_info_delete, |
| 2620 |
0, |
| 2621 |
0, |
| 2622 |
0, |
| 2623 |
0, |
| 2624 |
0, |
| 2625 |
0, |
| 2626 |
0, |
| 2627 |
0, |
| 2628 |
0, |
| 2629 |
0, |
| 2630 |
0, |
| 2631 |
0, |
| 2632 |
0, |
| 2633 |
0, |
| 2634 |
Py_TPFLAGS_DEFAULT, |
| 2635 |
"Buddy Info objects", |
| 2636 |
0, |
| 2637 |
0, |
| 2638 |
0, |
| 2639 |
0, |
| 2640 |
0, |
| 2641 |
0, |
| 2642 |
0, |
| 2643 |
PyObj_pjsua_buddy_info_members, |
| 2644 |
0, |
| 2645 |
0, |
| 2646 |
0, |
| 2647 |
0, |
| 2648 |
0, |
| 2649 |
0, |
| 2650 |
0, |
| 2651 |
0, |
| 2652 |
PyObj_pjsua_buddy_info_new, |
| 2653 |
|
| 2654 |
}; |
| 2655 |
|
| 2656 |
|
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
#endif |
| 2661 |
|