Alexandre Lision | 8af73cb | 2013-12-10 14:11:20 -0500 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) |
| 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #ifndef __PY_PJSUA_H__ |
| 21 | #define __PY_PJSUA_H__ |
| 22 | |
| 23 | #define _CRT_SECURE_NO_DEPRECATE |
| 24 | |
| 25 | #include <Python.h> |
| 26 | #include <structmember.h> |
| 27 | #include <pjsua-lib/pjsua.h> |
| 28 | |
| 29 | |
| 30 | PJ_INLINE(pj_str_t) PyString_ToPJ(const PyObject *obj) |
| 31 | { |
| 32 | pj_str_t str; |
| 33 | |
| 34 | if (obj && PyString_Check(obj)) { |
| 35 | str.ptr = PyString_AS_STRING(obj); |
| 36 | str.slen = PyString_GET_SIZE(obj); |
| 37 | } else { |
| 38 | str.ptr = NULL; |
| 39 | str.slen = 0; |
| 40 | } |
| 41 | |
| 42 | return str; |
| 43 | } |
| 44 | |
| 45 | PJ_INLINE(PyObject*) PyString_FromPJ(const pj_str_t *str) |
| 46 | { |
| 47 | return PyString_FromStringAndSize(str->ptr, str->slen); |
| 48 | } |
| 49 | |
| 50 | ////////////////////////////////////////////////////////////////////////////// |
| 51 | /* |
| 52 | * PyObj_pjsip_cred_info |
| 53 | */ |
| 54 | typedef struct |
| 55 | { |
| 56 | PyObject_HEAD |
| 57 | |
| 58 | /* Type-specific fields go here. */ |
| 59 | PyObject *realm; |
| 60 | PyObject *scheme; |
| 61 | PyObject *username; |
| 62 | int data_type; |
| 63 | PyObject *data; |
| 64 | |
| 65 | } PyObj_pjsip_cred_info; |
| 66 | |
| 67 | /* |
| 68 | * cred_info_dealloc |
| 69 | * deletes a cred info from memory |
| 70 | */ |
| 71 | static void PyObj_pjsip_cred_info_delete(PyObj_pjsip_cred_info* self) |
| 72 | { |
| 73 | Py_XDECREF(self->realm); |
| 74 | Py_XDECREF(self->scheme); |
| 75 | Py_XDECREF(self->username); |
| 76 | Py_XDECREF(self->data); |
| 77 | self->ob_type->tp_free((PyObject*)self); |
| 78 | } |
| 79 | |
| 80 | |
| 81 | static void PyObj_pjsip_cred_info_import(PyObj_pjsip_cred_info *obj, |
| 82 | const pjsip_cred_info *cfg) |
| 83 | { |
| 84 | Py_XDECREF(obj->realm); |
| 85 | obj->realm = PyString_FromPJ(&cfg->realm); |
| 86 | Py_XDECREF(obj->scheme); |
| 87 | obj->scheme = PyString_FromPJ(&cfg->scheme); |
| 88 | Py_XDECREF(obj->username); |
| 89 | obj->username = PyString_FromPJ(&cfg->username); |
| 90 | obj->data_type = cfg->data_type; |
| 91 | Py_XDECREF(obj->data); |
| 92 | obj->data = PyString_FromPJ(&cfg->data); |
| 93 | } |
| 94 | |
| 95 | static void PyObj_pjsip_cred_info_export(pjsip_cred_info *cfg, |
| 96 | PyObj_pjsip_cred_info *obj) |
| 97 | { |
| 98 | cfg->realm = PyString_ToPJ(obj->realm); |
| 99 | cfg->scheme = PyString_ToPJ(obj->scheme); |
| 100 | cfg->username = PyString_ToPJ(obj->username); |
| 101 | cfg->data_type = obj->data_type; |
| 102 | cfg->data = PyString_ToPJ(obj->data); |
| 103 | } |
| 104 | |
| 105 | |
| 106 | /* |
| 107 | * cred_info_new |
| 108 | * constructor for cred_info object |
| 109 | */ |
| 110 | static PyObject * PyObj_pjsip_cred_info_new(PyTypeObject *type, |
| 111 | PyObject *args, |
| 112 | PyObject *kwds) |
| 113 | { |
| 114 | PyObj_pjsip_cred_info *self; |
| 115 | |
| 116 | PJ_UNUSED_ARG(args); |
| 117 | PJ_UNUSED_ARG(kwds); |
| 118 | |
| 119 | self = (PyObj_pjsip_cred_info *)type->tp_alloc(type, 0); |
| 120 | if (self != NULL) { |
| 121 | self->realm = PyString_FromString(""); |
| 122 | self->scheme = PyString_FromString(""); |
| 123 | self->username = PyString_FromString(""); |
| 124 | self->data_type = PJSIP_CRED_DATA_PLAIN_PASSWD; |
| 125 | self->data = PyString_FromString(""); |
| 126 | } |
| 127 | |
| 128 | return (PyObject *)self; |
| 129 | } |
| 130 | |
| 131 | |
| 132 | /* |
| 133 | * PyObj_pjsip_cred_info_members |
| 134 | */ |
| 135 | static PyMemberDef PyObj_pjsip_cred_info_members[] = |
| 136 | { |
| 137 | { |
| 138 | "realm", T_OBJECT_EX, |
| 139 | offsetof(PyObj_pjsip_cred_info, realm), 0, |
| 140 | "Realm" |
| 141 | }, |
| 142 | { |
| 143 | "scheme", T_OBJECT_EX, |
| 144 | offsetof(PyObj_pjsip_cred_info, scheme), 0, |
| 145 | "Scheme" |
| 146 | }, |
| 147 | { |
| 148 | "username", T_OBJECT_EX, |
| 149 | offsetof(PyObj_pjsip_cred_info, username), 0, |
| 150 | "User name" |
| 151 | }, |
| 152 | { |
| 153 | "data", T_OBJECT_EX, |
| 154 | offsetof(PyObj_pjsip_cred_info, data), 0, |
| 155 | "The data, which can be a plaintext password or a hashed digest, " |
| 156 | "depending on the value of data_type" |
| 157 | }, |
| 158 | { |
| 159 | "data_type", T_INT, |
| 160 | offsetof(PyObj_pjsip_cred_info, data_type), 0, |
| 161 | "Type of data" |
| 162 | }, |
| 163 | |
| 164 | {NULL} /* Sentinel */ |
| 165 | }; |
| 166 | |
| 167 | /* |
| 168 | * PyTyp_pjsip_cred_info |
| 169 | */ |
| 170 | static PyTypeObject PyTyp_pjsip_cred_info = |
| 171 | { |
| 172 | PyObject_HEAD_INIT(NULL) |
| 173 | 0, /*ob_size*/ |
| 174 | "_pjsua.Pjsip_Cred_Info", /*tp_name*/ |
| 175 | sizeof(PyObj_pjsip_cred_info), /*tp_basicsize*/ |
| 176 | 0, /*tp_itemsize*/ |
| 177 | (destructor)PyObj_pjsip_cred_info_delete,/*tp_dealloc*/ |
| 178 | 0, /*tp_print*/ |
| 179 | 0, /*tp_getattr*/ |
| 180 | 0, /*tp_setattr*/ |
| 181 | 0, /*tp_compare*/ |
| 182 | 0, /*tp_repr*/ |
| 183 | 0, /*tp_as_number*/ |
| 184 | 0, /*tp_as_sequence*/ |
| 185 | 0, /*tp_as_mapping*/ |
| 186 | 0, /*tp_hash */ |
| 187 | 0, /*tp_call*/ |
| 188 | 0, /*tp_str*/ |
| 189 | 0, /*tp_getattro*/ |
| 190 | 0, /*tp_setattro*/ |
| 191 | 0, /*tp_as_buffer*/ |
| 192 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 193 | "PJSIP credential information", /* tp_doc */ |
| 194 | 0, /* tp_traverse */ |
| 195 | 0, /* tp_clear */ |
| 196 | 0, /* tp_richcompare */ |
| 197 | 0, /* tp_weaklistoffset */ |
| 198 | 0, /* tp_iter */ |
| 199 | 0, /* tp_iternext */ |
| 200 | 0, /* tp_methods */ |
| 201 | PyObj_pjsip_cred_info_members, /* tp_members */ |
| 202 | 0, /* tp_getset */ |
| 203 | 0, /* tp_base */ |
| 204 | 0, /* tp_dict */ |
| 205 | 0, /* tp_descr_get */ |
| 206 | 0, /* tp_descr_set */ |
| 207 | 0, /* tp_dictoffset */ |
| 208 | 0, /* tp_init */ |
| 209 | 0, /* tp_alloc */ |
| 210 | PyObj_pjsip_cred_info_new, /* tp_new */ |
| 211 | |
| 212 | }; |
| 213 | |
| 214 | |
| 215 | ////////////////////////////////////////////////////////////////////////////// |
| 216 | /* |
| 217 | * PyObj_pjsua_callback |
| 218 | * C/python typewrapper for callback struct |
| 219 | */ |
| 220 | typedef struct PyObj_pjsua_callback |
| 221 | { |
| 222 | PyObject_HEAD |
| 223 | /* Type-specific fields go here. */ |
| 224 | PyObject * on_call_state; |
| 225 | PyObject * on_incoming_call; |
| 226 | PyObject * on_call_media_state; |
| 227 | PyObject * on_dtmf_digit; |
| 228 | PyObject * on_call_transfer_request; |
| 229 | PyObject * on_call_transfer_status; |
| 230 | PyObject * on_call_replace_request; |
| 231 | PyObject * on_call_replaced; |
| 232 | PyObject * on_reg_state; |
| 233 | PyObject * on_incoming_subscribe; |
| 234 | PyObject * on_buddy_state; |
| 235 | PyObject * on_pager; |
| 236 | PyObject * on_pager_status; |
| 237 | PyObject * on_typing; |
| 238 | PyObject * on_mwi_info; |
| 239 | } PyObj_pjsua_callback; |
| 240 | |
| 241 | |
| 242 | /* |
| 243 | * PyObj_pjsua_callback_delete |
| 244 | * destructor function for callback struct |
| 245 | */ |
| 246 | static void PyObj_pjsua_callback_delete(PyObj_pjsua_callback* self) |
| 247 | { |
| 248 | Py_XDECREF(self->on_call_state); |
| 249 | Py_XDECREF(self->on_incoming_call); |
| 250 | Py_XDECREF(self->on_call_media_state); |
| 251 | Py_XDECREF(self->on_dtmf_digit); |
| 252 | Py_XDECREF(self->on_call_transfer_request); |
| 253 | Py_XDECREF(self->on_call_transfer_status); |
| 254 | Py_XDECREF(self->on_call_replace_request); |
| 255 | Py_XDECREF(self->on_call_replaced); |
| 256 | Py_XDECREF(self->on_reg_state); |
| 257 | Py_XDECREF(self->on_incoming_subscribe); |
| 258 | Py_XDECREF(self->on_buddy_state); |
| 259 | Py_XDECREF(self->on_pager); |
| 260 | Py_XDECREF(self->on_pager_status); |
| 261 | Py_XDECREF(self->on_typing); |
| 262 | Py_XDECREF(self->on_mwi_info); |
| 263 | self->ob_type->tp_free((PyObject*)self); |
| 264 | } |
| 265 | |
| 266 | |
| 267 | /* |
| 268 | * PyObj_pjsua_callback_new |
| 269 | * * declares constructor for callback struct |
| 270 | */ |
| 271 | static PyObject * PyObj_pjsua_callback_new(PyTypeObject *type, |
| 272 | PyObject *args, |
| 273 | PyObject *kwds) |
| 274 | { |
| 275 | PyObj_pjsua_callback *self; |
| 276 | |
| 277 | PJ_UNUSED_ARG(args); |
| 278 | PJ_UNUSED_ARG(kwds); |
| 279 | |
| 280 | self = (PyObj_pjsua_callback *)type->tp_alloc(type, 0); |
| 281 | if (self != NULL) { |
| 282 | self->on_call_state = Py_BuildValue(""); |
| 283 | self->on_incoming_call = Py_BuildValue(""); |
| 284 | self->on_call_media_state = Py_BuildValue(""); |
| 285 | self->on_dtmf_digit = Py_BuildValue(""); |
| 286 | self->on_call_transfer_request = Py_BuildValue(""); |
| 287 | self->on_call_transfer_status = Py_BuildValue(""); |
| 288 | self->on_call_replace_request = Py_BuildValue(""); |
| 289 | self->on_call_replaced = Py_BuildValue(""); |
| 290 | self->on_reg_state = Py_BuildValue(""); |
| 291 | self->on_incoming_subscribe = Py_BuildValue(""); |
| 292 | self->on_buddy_state = Py_BuildValue(""); |
| 293 | self->on_pager = Py_BuildValue(""); |
| 294 | self->on_pager_status = Py_BuildValue(""); |
| 295 | self->on_typing = Py_BuildValue(""); |
| 296 | self->on_mwi_info = Py_BuildValue(""); |
| 297 | } |
| 298 | |
| 299 | return (PyObject *)self; |
| 300 | } |
| 301 | |
| 302 | |
| 303 | /* |
| 304 | * PyObj_pjsua_callback_members |
| 305 | * declares available functions for callback object |
| 306 | */ |
| 307 | static PyMemberDef PyObj_pjsua_callback_members[] = |
| 308 | { |
| 309 | { |
| 310 | "on_call_state", T_OBJECT_EX, |
| 311 | offsetof(PyObj_pjsua_callback, on_call_state), 0, |
| 312 | "Notify application when invite state has changed. Application may " |
| 313 | "then query the call info to get the detail call states." |
| 314 | }, |
| 315 | { |
| 316 | "on_incoming_call", T_OBJECT_EX, |
| 317 | offsetof(PyObj_pjsua_callback, on_incoming_call), 0, |
| 318 | "Notify application on incoming call." |
| 319 | }, |
| 320 | { |
| 321 | "on_call_media_state", T_OBJECT_EX, |
| 322 | offsetof(PyObj_pjsua_callback, on_call_media_state), 0, |
| 323 | "Notify application when media state in the call has changed. Normal " |
| 324 | "application would need to implement this callback, e.g. to connect " |
| 325 | "the call's media to sound device." |
| 326 | }, |
| 327 | { |
| 328 | "on_dtmf_digit", T_OBJECT_EX, |
| 329 | offsetof(PyObj_pjsua_callback, on_dtmf_digit), 0, |
| 330 | "Notify application upon receiving incoming DTMF digit." |
| 331 | }, |
| 332 | { |
| 333 | "on_call_transfer_request", T_OBJECT_EX, |
| 334 | offsetof(PyObj_pjsua_callback, on_call_transfer_request), 0, |
| 335 | "Notify application on call being transfered. " |
| 336 | "Application can decide to accept/reject transfer request " |
| 337 | "by setting the code (default is 200). When this callback " |
| 338 | "is not defined, the default behavior is to accept the " |
| 339 | "transfer." |
| 340 | }, |
| 341 | { |
| 342 | "on_call_transfer_status", T_OBJECT_EX, |
| 343 | offsetof(PyObj_pjsua_callback, on_call_transfer_status), 0, |
| 344 | "Notify application of the status of previously sent call " |
| 345 | "transfer request. Application can monitor the status of the " |
| 346 | "call transfer request, for example to decide whether to " |
| 347 | "terminate existing call." |
| 348 | }, |
| 349 | { |
| 350 | "on_call_replace_request", T_OBJECT_EX, |
| 351 | offsetof(PyObj_pjsua_callback, on_call_replace_request), 0, |
| 352 | "Notify application about incoming INVITE with Replaces header. " |
| 353 | "Application may reject the request by setting non-2xx code." |
| 354 | }, |
| 355 | { |
| 356 | "on_call_replaced", T_OBJECT_EX, |
| 357 | offsetof(PyObj_pjsua_callback, on_call_replaced), 0, |
| 358 | "Notify application that an existing call has been replaced with " |
| 359 | "a new call. This happens when PJSUA-API receives incoming INVITE " |
| 360 | "request with Replaces header." |
| 361 | " " |
| 362 | "After this callback is called, normally PJSUA-API will disconnect " |
| 363 | "old_call_id and establish new_call_id." |
| 364 | }, |
| 365 | { |
| 366 | "on_reg_state", T_OBJECT_EX, |
| 367 | offsetof(PyObj_pjsua_callback, on_reg_state), 0, |
| 368 | "Notify application when registration status has changed. Application " |
| 369 | "may then query the account info to get the registration details." |
| 370 | }, |
| 371 | { |
| 372 | "on_incoming_subscribe", T_OBJECT_EX, |
| 373 | offsetof(PyObj_pjsua_callback, on_incoming_subscribe), 0, |
| 374 | "Notification when incoming SUBSCRIBE request is received." |
| 375 | }, |
| 376 | { |
| 377 | "on_buddy_state", T_OBJECT_EX, |
| 378 | offsetof(PyObj_pjsua_callback, on_buddy_state), 0, |
| 379 | "Notify application when the buddy state has changed. Application may " |
| 380 | "then query the buddy into to get the details." |
| 381 | }, |
| 382 | { |
| 383 | "on_pager", T_OBJECT_EX, |
| 384 | offsetof(PyObj_pjsua_callback, on_pager), 0, |
| 385 | "Notify application on incoming pager (i.e. MESSAGE request). " |
| 386 | "Argument call_id will be -1 if MESSAGE request is not related to an " |
| 387 | "existing call." |
| 388 | }, |
| 389 | { |
| 390 | "on_pager_status", T_OBJECT_EX, |
| 391 | offsetof(PyObj_pjsua_callback, on_pager_status), 0, |
| 392 | "Notify application about the delivery status of outgoing pager " |
| 393 | "request." |
| 394 | }, |
| 395 | { |
| 396 | "on_typing", T_OBJECT_EX, |
| 397 | offsetof(PyObj_pjsua_callback, on_typing), 0, |
| 398 | "Notify application about typing indication." |
| 399 | }, |
| 400 | { |
| 401 | "on_mwi_info", T_OBJECT_EX, |
| 402 | offsetof(PyObj_pjsua_callback, on_mwi_info), 0, |
| 403 | "Notify application about MWI indication." |
| 404 | }, |
| 405 | {NULL} /* Sentinel */ |
| 406 | }; |
| 407 | |
| 408 | |
| 409 | /* |
| 410 | * PyTyp_pjsua_callback |
| 411 | * callback class definition |
| 412 | */ |
| 413 | static PyTypeObject PyTyp_pjsua_callback = |
| 414 | { |
| 415 | PyObject_HEAD_INIT(NULL) |
| 416 | 0, /*ob_size*/ |
| 417 | "_pjsua.Callback", /*tp_name*/ |
| 418 | sizeof(PyObj_pjsua_callback), /*tp_basicsize*/ |
| 419 | 0, /*tp_itemsize*/ |
| 420 | (destructor)PyObj_pjsua_callback_delete, /*tp_dealloc*/ |
| 421 | 0, /*tp_print*/ |
| 422 | 0, /*tp_getattr*/ |
| 423 | 0, /*tp_setattr*/ |
| 424 | 0, /*tp_compare*/ |
| 425 | 0, /*tp_repr*/ |
| 426 | 0, /*tp_as_number*/ |
| 427 | 0, /*tp_as_sequence*/ |
| 428 | 0, /*tp_as_mapping*/ |
| 429 | 0, /*tp_hash */ |
| 430 | 0, /*tp_call*/ |
| 431 | 0, /*tp_str*/ |
| 432 | 0, /*tp_getattro*/ |
| 433 | 0, /*tp_setattro*/ |
| 434 | 0, /*tp_as_buffer*/ |
| 435 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 436 | "This structure describes application callback " |
| 437 | "to receive various event notifications from " |
| 438 | "PJSUA-API", /* tp_doc */ |
| 439 | 0, /* tp_traverse */ |
| 440 | 0, /* tp_clear */ |
| 441 | 0, /* tp_richcompare */ |
| 442 | 0, /* tp_weaklistoffset */ |
| 443 | 0, /* tp_iter */ |
| 444 | 0, /* tp_iternext */ |
| 445 | 0, /* tp_methods */ |
| 446 | PyObj_pjsua_callback_members, /* tp_members */ |
| 447 | 0, /* tp_getset */ |
| 448 | 0, /* tp_base */ |
| 449 | 0, /* tp_dict */ |
| 450 | 0, /* tp_descr_get */ |
| 451 | 0, /* tp_descr_set */ |
| 452 | 0, /* tp_dictoffset */ |
| 453 | 0, /* tp_init */ |
| 454 | 0, /* tp_alloc */ |
| 455 | PyObj_pjsua_callback_new, /* tp_new */ |
| 456 | |
| 457 | }; |
| 458 | |
| 459 | |
| 460 | ////////////////////////////////////////////////////////////////////////////// |
| 461 | /* |
| 462 | * PyObj_pjsua_media_config |
| 463 | * C/Python wrapper for pjsua_media_config object |
| 464 | */ |
| 465 | typedef struct |
| 466 | { |
| 467 | PyObject_HEAD |
| 468 | /* Type-specific fields go here. */ |
| 469 | unsigned clock_rate; |
| 470 | unsigned snd_clock_rate; |
| 471 | unsigned channel_count; |
| 472 | unsigned audio_frame_ptime; |
| 473 | int snd_auto_close_time; |
| 474 | unsigned max_media_ports; |
| 475 | int has_ioqueue; |
| 476 | unsigned thread_cnt; |
| 477 | unsigned quality; |
| 478 | unsigned ptime; |
| 479 | int no_vad; |
| 480 | unsigned ilbc_mode; |
| 481 | unsigned tx_drop_pct; |
| 482 | unsigned rx_drop_pct; |
| 483 | unsigned ec_options; |
| 484 | unsigned ec_tail_len; |
| 485 | int jb_min; |
| 486 | int jb_max; |
| 487 | int enable_ice; |
| 488 | int enable_turn; |
| 489 | PyObject *turn_server; |
| 490 | int turn_conn_type; |
| 491 | PyObject *turn_realm; |
| 492 | PyObject *turn_username; |
| 493 | int turn_passwd_type; |
| 494 | PyObject *turn_passwd; |
| 495 | } PyObj_pjsua_media_config; |
| 496 | |
| 497 | |
| 498 | /* |
| 499 | * PyObj_pjsua_media_config_members |
| 500 | * declares attributes accessible from both C and Python for media_config file |
| 501 | */ |
| 502 | static PyMemberDef PyObj_pjsua_media_config_members[] = |
| 503 | { |
| 504 | { |
| 505 | "clock_rate", T_INT, |
| 506 | offsetof(PyObj_pjsua_media_config, clock_rate), 0, |
| 507 | "Clock rate to be applied to the conference bridge. If value is zero, " |
| 508 | "default clock rate will be used (16KHz)." |
| 509 | }, |
| 510 | { |
| 511 | "snd_clock_rate", T_INT, |
| 512 | offsetof(PyObj_pjsua_media_config, snd_clock_rate), 0, |
| 513 | "Specify different clock rate of sound device, otherwise 0." |
| 514 | }, |
| 515 | { |
| 516 | "channel_count", T_INT, |
| 517 | offsetof(PyObj_pjsua_media_config, channel_count), 0, |
| 518 | "Specify channel count (default 1)." |
| 519 | }, |
| 520 | { |
| 521 | "audio_frame_ptime", T_INT, |
| 522 | offsetof(PyObj_pjsua_media_config, audio_frame_ptime), 0, |
| 523 | "Audio frame length in milliseconds." |
| 524 | }, |
| 525 | { |
| 526 | "snd_auto_close_time", T_INT, |
| 527 | offsetof(PyObj_pjsua_media_config, snd_auto_close_time), 0, |
| 528 | "Sound idle time before it's closed." |
| 529 | }, |
| 530 | { |
| 531 | "max_media_ports", T_INT, |
| 532 | offsetof(PyObj_pjsua_media_config, max_media_ports), 0, |
| 533 | "Specify maximum number of media ports to be created in the " |
| 534 | "conference bridge. Since all media terminate in the bridge (calls, " |
| 535 | "file player, file recorder, etc), the value must be large enough to " |
| 536 | "support all of them. However, the larger the value, the more " |
| 537 | "computations are performed." |
| 538 | }, |
| 539 | { |
| 540 | "has_ioqueue", T_INT, |
| 541 | offsetof(PyObj_pjsua_media_config, has_ioqueue), 0, |
| 542 | "Specify whether the media manager should manage its own ioqueue for " |
| 543 | "the RTP/RTCP sockets. If yes, ioqueue will be created and at least " |
| 544 | "one worker thread will be created too. If no, the RTP/RTCP sockets " |
| 545 | "will share the same ioqueue as SIP sockets, and no worker thread is " |
| 546 | "needed." |
| 547 | }, |
| 548 | { |
| 549 | "thread_cnt", T_INT, |
| 550 | offsetof(PyObj_pjsua_media_config, thread_cnt), 0, |
| 551 | "Specify the number of worker threads to handle incoming RTP packets. " |
| 552 | "A value of one is recommended for most applications." |
| 553 | }, |
| 554 | { |
| 555 | "quality", T_INT, |
| 556 | offsetof(PyObj_pjsua_media_config, quality), 0, |
| 557 | "The media quality also sets speex codec quality/complexity to the " |
| 558 | "number." |
| 559 | }, |
| 560 | { |
| 561 | "ptime", T_INT, |
| 562 | offsetof(PyObj_pjsua_media_config, ptime), 0, |
| 563 | "Specify default ptime." |
| 564 | }, |
| 565 | { |
| 566 | "no_vad", T_INT, |
| 567 | offsetof(PyObj_pjsua_media_config, no_vad), 0, |
| 568 | "Disable VAD?" |
| 569 | }, |
| 570 | { |
| 571 | "ilbc_mode", T_INT, |
| 572 | offsetof(PyObj_pjsua_media_config, ilbc_mode), 0, |
| 573 | "iLBC mode (20 or 30)." |
| 574 | }, |
| 575 | { |
| 576 | "tx_drop_pct", T_INT, |
| 577 | offsetof(PyObj_pjsua_media_config, tx_drop_pct), 0, |
| 578 | "Percentage of RTP packet to drop in TX direction (to simulate packet " |
| 579 | "lost)." |
| 580 | }, |
| 581 | { |
| 582 | "rx_drop_pct", T_INT, |
| 583 | offsetof(PyObj_pjsua_media_config, rx_drop_pct), 0, |
| 584 | "Percentage of RTP packet to drop in RX direction (to simulate packet " |
| 585 | "lost)."}, |
| 586 | { |
| 587 | "ec_options", T_INT, |
| 588 | offsetof(PyObj_pjsua_media_config, ec_options), 0, |
| 589 | "Echo canceller options (see pjmedia_echo_create())" |
| 590 | }, |
| 591 | { |
| 592 | "ec_tail_len", T_INT, |
| 593 | offsetof(PyObj_pjsua_media_config, ec_tail_len), 0, |
| 594 | "Echo canceller tail length, in miliseconds." |
| 595 | }, |
| 596 | { |
| 597 | "jb_min", T_INT, |
| 598 | offsetof(PyObj_pjsua_media_config, jb_min), 0, |
| 599 | "Jitter buffer minimum size in milliseconds." |
| 600 | }, |
| 601 | { |
| 602 | "jb_max", T_INT, |
| 603 | offsetof(PyObj_pjsua_media_config, jb_max), 0, |
| 604 | "Jitter buffer maximum size in milliseconds." |
| 605 | }, |
| 606 | { |
| 607 | "enable_ice", T_INT, |
| 608 | offsetof(PyObj_pjsua_media_config, enable_ice), 0, |
| 609 | "Enable ICE." |
| 610 | }, |
| 611 | { |
| 612 | "enable_turn", T_INT, |
| 613 | offsetof(PyObj_pjsua_media_config, enable_turn), 0, |
| 614 | "Enable TURN." |
| 615 | }, |
| 616 | { |
| 617 | "turn_server", T_OBJECT_EX, |
| 618 | offsetof(PyObj_pjsua_media_config, turn_server), 0, |
| 619 | "Specify the TURN server." |
| 620 | }, |
| 621 | { |
| 622 | "turn_conn_type", T_INT, |
| 623 | offsetof(PyObj_pjsua_media_config, turn_conn_type), 0, |
| 624 | "Specify TURN connection type." |
| 625 | }, |
| 626 | { |
| 627 | "turn_realm", T_OBJECT_EX, |
| 628 | offsetof(PyObj_pjsua_media_config, turn_realm), 0, |
| 629 | "Specify the TURN realm." |
| 630 | }, |
| 631 | { |
| 632 | "turn_username", T_OBJECT_EX, |
| 633 | offsetof(PyObj_pjsua_media_config, turn_username), 0, |
| 634 | "Specify the TURN username." |
| 635 | }, |
| 636 | { |
| 637 | "turn_passwd_type", T_INT, |
| 638 | offsetof(PyObj_pjsua_media_config, turn_passwd_type), 0, |
| 639 | "Specify TURN password type." |
| 640 | }, |
| 641 | { |
| 642 | "turn_passwd", T_OBJECT_EX, |
| 643 | offsetof(PyObj_pjsua_media_config, turn_passwd), 0, |
| 644 | "Specify the TURN password." |
| 645 | }, |
| 646 | |
| 647 | {NULL} /* Sentinel */ |
| 648 | }; |
| 649 | |
| 650 | |
| 651 | static PyObject *PyObj_pjsua_media_config_new(PyTypeObject *type, |
| 652 | PyObject *args, |
| 653 | PyObject *kwds) |
| 654 | { |
| 655 | PyObj_pjsua_media_config *self; |
| 656 | |
| 657 | PJ_UNUSED_ARG(args); |
| 658 | PJ_UNUSED_ARG(kwds); |
| 659 | |
| 660 | self = (PyObj_pjsua_media_config*)type->tp_alloc(type, 0); |
| 661 | if (self != NULL) { |
| 662 | self->turn_server = PyString_FromString(""); |
| 663 | self->turn_realm = PyString_FromString(""); |
| 664 | self->turn_username = PyString_FromString(""); |
| 665 | self->turn_passwd = PyString_FromString(""); |
| 666 | } |
| 667 | |
| 668 | return (PyObject *)self; |
| 669 | } |
| 670 | |
| 671 | static void PyObj_pjsua_media_config_delete(PyObj_pjsua_media_config * self) |
| 672 | { |
| 673 | Py_XDECREF(self->turn_server); |
| 674 | Py_XDECREF(self->turn_realm); |
| 675 | Py_XDECREF(self->turn_username); |
| 676 | Py_XDECREF(self->turn_passwd); |
| 677 | self->ob_type->tp_free((PyObject*)self); |
| 678 | } |
| 679 | |
| 680 | static void PyObj_pjsua_media_config_import(PyObj_pjsua_media_config *obj, |
| 681 | const pjsua_media_config *cfg) |
| 682 | { |
| 683 | obj->clock_rate = cfg->clock_rate; |
| 684 | obj->snd_clock_rate = cfg->snd_clock_rate; |
| 685 | obj->channel_count = cfg->channel_count; |
| 686 | obj->audio_frame_ptime = cfg->audio_frame_ptime; |
| 687 | obj->snd_auto_close_time= cfg->snd_auto_close_time; |
| 688 | obj->max_media_ports = cfg->max_media_ports; |
| 689 | obj->has_ioqueue = cfg->has_ioqueue; |
| 690 | obj->thread_cnt = cfg->thread_cnt; |
| 691 | obj->quality = cfg->quality; |
| 692 | obj->ptime = cfg->ptime; |
| 693 | obj->no_vad = cfg->no_vad; |
| 694 | obj->ilbc_mode = cfg->ilbc_mode; |
| 695 | obj->jb_min = cfg->jb_min_pre; |
| 696 | obj->jb_max = cfg->jb_max; |
| 697 | obj->tx_drop_pct = cfg->tx_drop_pct; |
| 698 | obj->rx_drop_pct = cfg->rx_drop_pct; |
| 699 | obj->ec_options = cfg->ec_options; |
| 700 | obj->ec_tail_len = cfg->ec_tail_len; |
| 701 | obj->enable_ice = cfg->enable_ice; |
| 702 | obj->enable_turn = cfg->enable_turn; |
| 703 | Py_XDECREF(obj->turn_server); |
| 704 | obj->turn_server = PyString_FromPJ(&cfg->turn_server); |
| 705 | obj->turn_conn_type = cfg->turn_conn_type; |
| 706 | if (cfg->turn_auth_cred.type == PJ_STUN_AUTH_CRED_STATIC) { |
| 707 | const pj_stun_auth_cred *cred = &cfg->turn_auth_cred; |
| 708 | |
| 709 | Py_XDECREF(obj->turn_realm); |
| 710 | obj->turn_realm = PyString_FromPJ(&cred->data.static_cred.realm); |
| 711 | Py_XDECREF(obj->turn_username); |
| 712 | obj->turn_username = PyString_FromPJ(&cred->data.static_cred.username); |
| 713 | obj->turn_passwd_type = cred->data.static_cred.data_type; |
| 714 | Py_XDECREF(obj->turn_passwd); |
| 715 | obj->turn_passwd = PyString_FromPJ(&cred->data.static_cred.data); |
| 716 | } else { |
| 717 | Py_XDECREF(obj->turn_realm); |
| 718 | obj->turn_realm = PyString_FromString(""); |
| 719 | Py_XDECREF(obj->turn_username); |
| 720 | obj->turn_username = PyString_FromString(""); |
| 721 | obj->turn_passwd_type = 0; |
| 722 | Py_XDECREF(obj->turn_passwd); |
| 723 | obj->turn_passwd = PyString_FromString(""); |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | static void PyObj_pjsua_media_config_export(pjsua_media_config *cfg, |
| 728 | const PyObj_pjsua_media_config *obj) |
| 729 | { |
| 730 | cfg->clock_rate = obj->clock_rate; |
| 731 | cfg->snd_clock_rate = obj->snd_clock_rate; |
| 732 | cfg->channel_count = obj->channel_count; |
| 733 | cfg->audio_frame_ptime = obj->audio_frame_ptime; |
| 734 | cfg->snd_auto_close_time=obj->snd_auto_close_time; |
| 735 | cfg->max_media_ports = obj->max_media_ports; |
| 736 | cfg->has_ioqueue = obj->has_ioqueue; |
| 737 | cfg->thread_cnt = obj->thread_cnt; |
| 738 | cfg->quality = obj->quality; |
| 739 | cfg->ptime = obj->ptime; |
| 740 | cfg->no_vad = obj->no_vad; |
| 741 | cfg->jb_min_pre = obj->jb_min; |
| 742 | cfg->jb_max = obj->jb_max; |
| 743 | cfg->ilbc_mode = obj->ilbc_mode; |
| 744 | cfg->tx_drop_pct = obj->tx_drop_pct; |
| 745 | cfg->rx_drop_pct = obj->rx_drop_pct; |
| 746 | cfg->ec_options = obj->ec_options; |
| 747 | cfg->ec_tail_len = obj->ec_tail_len; |
| 748 | cfg->enable_ice = obj->enable_ice; |
| 749 | cfg->enable_turn = obj->enable_turn; |
| 750 | |
| 751 | if (cfg->enable_turn) { |
| 752 | cfg->turn_server = PyString_ToPJ(obj->turn_server); |
| 753 | cfg->turn_conn_type = obj->turn_conn_type; |
| 754 | cfg->turn_auth_cred.type = PJ_STUN_AUTH_CRED_STATIC; |
| 755 | cfg->turn_auth_cred.data.static_cred.realm = PyString_ToPJ(obj->turn_realm); |
| 756 | cfg->turn_auth_cred.data.static_cred.username = PyString_ToPJ(obj->turn_username); |
| 757 | cfg->turn_auth_cred.data.static_cred.data_type= obj->turn_passwd_type; |
| 758 | cfg->turn_auth_cred.data.static_cred.data = PyString_ToPJ(obj->turn_passwd); |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | |
| 763 | /* |
| 764 | * PyTyp_pjsua_media_config |
| 765 | */ |
| 766 | static PyTypeObject PyTyp_pjsua_media_config = |
| 767 | { |
| 768 | PyObject_HEAD_INIT(NULL) |
| 769 | 0, /*ob_size*/ |
| 770 | "_pjsua.Media_Config", /*tp_name*/ |
| 771 | sizeof(PyObj_pjsua_media_config),/*tp_basicsize*/ |
| 772 | 0, /*tp_itemsize*/ |
| 773 | (destructor)PyObj_pjsua_media_config_delete,/*tp_dealloc*/ |
| 774 | 0, /*tp_print*/ |
| 775 | 0, /*tp_getattr*/ |
| 776 | 0, /*tp_setattr*/ |
| 777 | 0, /*tp_compare*/ |
| 778 | 0, /*tp_repr*/ |
| 779 | 0, /*tp_as_number*/ |
| 780 | 0, /*tp_as_sequence*/ |
| 781 | 0, /*tp_as_mapping*/ |
| 782 | 0, /*tp_hash */ |
| 783 | 0, /*tp_call*/ |
| 784 | 0, /*tp_str*/ |
| 785 | 0, /*tp_getattro*/ |
| 786 | 0, /*tp_setattro*/ |
| 787 | 0, /*tp_as_buffer*/ |
| 788 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 789 | "Media Config objects", /*tp_doc*/ |
| 790 | 0, /*tp_traverse*/ |
| 791 | 0, /*tp_clear*/ |
| 792 | 0, /*tp_richcompare*/ |
| 793 | 0, /* tp_weaklistoffset */ |
| 794 | 0, /* tp_iter */ |
| 795 | 0, /* tp_iternext */ |
| 796 | 0, /* tp_methods */ |
| 797 | PyObj_pjsua_media_config_members, /* tp_members */ |
| 798 | 0, /* tp_getset */ |
| 799 | 0, /* tp_base */ |
| 800 | 0, /* tp_dict */ |
| 801 | 0, /* tp_descr_get */ |
| 802 | 0, /* tp_descr_set */ |
| 803 | 0, /* tp_dictoffset */ |
| 804 | 0, /* tp_init */ |
| 805 | 0, /* tp_alloc */ |
| 806 | PyObj_pjsua_media_config_new, /* tp_new */ |
| 807 | }; |
| 808 | |
| 809 | |
| 810 | ////////////////////////////////////////////////////////////////////////////// |
| 811 | /* |
| 812 | * PyObj_pjsua_config |
| 813 | * attribute list for config object |
| 814 | */ |
| 815 | typedef struct |
| 816 | { |
| 817 | PyObject_HEAD |
| 818 | /* Type-specific fields go here. */ |
| 819 | unsigned max_calls; |
| 820 | unsigned thread_cnt; |
| 821 | PyObject *outbound_proxy; |
| 822 | PyObject *stun_domain; |
| 823 | PyObject *stun_host; |
| 824 | PyListObject *nameserver; |
| 825 | PyObj_pjsua_callback *cb; |
| 826 | PyObject *user_agent; |
| 827 | } PyObj_pjsua_config; |
| 828 | |
| 829 | |
| 830 | static void PyObj_pjsua_config_delete(PyObj_pjsua_config* self) |
| 831 | { |
| 832 | Py_XDECREF(self->outbound_proxy); |
| 833 | Py_XDECREF(self->stun_domain); |
| 834 | Py_XDECREF(self->stun_host); |
| 835 | Py_XDECREF(self->nameserver); |
| 836 | Py_XDECREF(self->cb); |
| 837 | Py_XDECREF(self->user_agent); |
| 838 | self->ob_type->tp_free((PyObject*)self); |
| 839 | } |
| 840 | |
| 841 | |
| 842 | static void PyObj_pjsua_config_import(PyObj_pjsua_config *obj, |
| 843 | const pjsua_config *cfg) |
| 844 | { |
| 845 | unsigned i; |
| 846 | |
| 847 | obj->max_calls = cfg->max_calls; |
| 848 | obj->thread_cnt = cfg->thread_cnt; |
| 849 | Py_XDECREF(obj->outbound_proxy); |
| 850 | if (cfg->outbound_proxy_cnt) |
| 851 | obj->outbound_proxy = PyString_FromPJ(&cfg->outbound_proxy[0]); |
| 852 | else |
| 853 | obj->outbound_proxy = PyString_FromString(""); |
| 854 | |
| 855 | Py_XDECREF(obj->stun_domain); |
| 856 | obj->stun_domain = PyString_FromPJ(&cfg->stun_domain); |
| 857 | Py_XDECREF(obj->stun_host); |
| 858 | obj->stun_host = PyString_FromPJ(&cfg->stun_host); |
| 859 | Py_XDECREF(obj->nameserver); |
| 860 | obj->nameserver = (PyListObject *)PyList_New(0); |
| 861 | for (i=0; i<cfg->nameserver_count; ++i) { |
| 862 | PyObject * str; |
| 863 | str = PyString_FromPJ(&cfg->nameserver[i]); |
| 864 | PyList_Append((PyObject *)obj->nameserver, str); |
| 865 | } |
| 866 | Py_XDECREF(obj->user_agent); |
| 867 | obj->user_agent = PyString_FromPJ(&cfg->user_agent); |
| 868 | } |
| 869 | |
| 870 | |
| 871 | static void PyObj_pjsua_config_export(pjsua_config *cfg, |
| 872 | PyObj_pjsua_config *obj) |
| 873 | { |
| 874 | unsigned i; |
| 875 | |
| 876 | cfg->max_calls = obj->max_calls; |
| 877 | cfg->thread_cnt = obj->thread_cnt; |
| 878 | if (PyString_Size(obj->outbound_proxy) > 0) { |
| 879 | cfg->outbound_proxy_cnt = 1; |
| 880 | cfg->outbound_proxy[0] = PyString_ToPJ(obj->outbound_proxy); |
| 881 | } else { |
| 882 | cfg->outbound_proxy_cnt = 0; |
| 883 | } |
| 884 | cfg->nameserver_count = PyList_Size((PyObject*)obj->nameserver); |
| 885 | if (cfg->nameserver_count > PJ_ARRAY_SIZE(cfg->nameserver)) |
| 886 | cfg->nameserver_count = PJ_ARRAY_SIZE(cfg->nameserver); |
| 887 | for (i = 0; i < cfg->nameserver_count; i++) { |
| 888 | PyObject *item = PyList_GetItem((PyObject *)obj->nameserver,i); |
| 889 | cfg->nameserver[i] = PyString_ToPJ(item); |
| 890 | } |
| 891 | cfg->stun_domain = PyString_ToPJ(obj->stun_domain); |
| 892 | cfg->stun_host = PyString_ToPJ(obj->stun_host); |
| 893 | cfg->user_agent = PyString_ToPJ(obj->user_agent); |
| 894 | |
| 895 | } |
| 896 | |
| 897 | |
| 898 | static PyObject *PyObj_pjsua_config_new(PyTypeObject *type, |
| 899 | PyObject *args, |
| 900 | PyObject *kwds) |
| 901 | { |
| 902 | PyObj_pjsua_config *self; |
| 903 | |
| 904 | PJ_UNUSED_ARG(args); |
| 905 | PJ_UNUSED_ARG(kwds); |
| 906 | |
| 907 | self = (PyObj_pjsua_config *)type->tp_alloc(type, 0); |
| 908 | if (self != NULL) { |
| 909 | self->user_agent = PyString_FromString(""); |
| 910 | self->outbound_proxy = PyString_FromString(""); |
| 911 | self->stun_domain = PyString_FromString(""); |
| 912 | self->stun_host = PyString_FromString(""); |
| 913 | self->cb = (PyObj_pjsua_callback *) |
| 914 | PyType_GenericNew(&PyTyp_pjsua_callback, NULL, NULL); |
| 915 | } |
| 916 | return (PyObject *)self; |
| 917 | } |
| 918 | |
| 919 | |
| 920 | /* |
| 921 | * PyObj_pjsua_config_members |
| 922 | * attribute list accessible from Python/C |
| 923 | */ |
| 924 | static PyMemberDef PyObj_pjsua_config_members[] = |
| 925 | { |
| 926 | { |
| 927 | "max_calls", T_INT, |
| 928 | offsetof(PyObj_pjsua_config, max_calls), 0, |
| 929 | "Maximum calls to support (default: 4) " |
| 930 | }, |
| 931 | { |
| 932 | "thread_cnt", T_INT, |
| 933 | offsetof(PyObj_pjsua_config, thread_cnt), 0, |
| 934 | "Number of worker threads. Normally application will want to have at " |
| 935 | "least one worker thread, unless when it wants to poll the library " |
| 936 | "periodically, which in this case the worker thread can be set to " |
| 937 | "zero." |
| 938 | }, |
| 939 | { |
| 940 | "outbound_proxy", T_OBJECT_EX, |
| 941 | offsetof(PyObj_pjsua_config, outbound_proxy), 0, |
| 942 | "SIP URL of the outbound proxy (optional)" |
| 943 | }, |
| 944 | { |
| 945 | "stun_domain", T_OBJECT_EX, |
| 946 | offsetof(PyObj_pjsua_config, stun_domain), 0, |
| 947 | "Domain of the STUN server (optional). STUN server will be resolved " |
| 948 | "using DNS SRV resolution only when nameserver is configured. " |
| 949 | "Alternatively, if DNS SRV resolution for STUN is not desired, " |
| 950 | "application can specify the STUN server hostname or IP address " |
| 951 | "in stun_host attribute." |
| 952 | }, |
| 953 | { |
| 954 | "stun_host", T_OBJECT_EX, |
| 955 | offsetof(PyObj_pjsua_config, stun_host), 0, |
| 956 | "Hostname or IP address of the STUN server (optional)." |
| 957 | }, |
| 958 | { |
| 959 | "nameserver", T_OBJECT_EX, |
| 960 | offsetof(PyObj_pjsua_config, nameserver), 0, |
| 961 | "IP address of the nameserver." |
| 962 | }, |
| 963 | { |
| 964 | "cb", T_OBJECT_EX, offsetof(PyObj_pjsua_config, cb), 0, |
| 965 | "Application callback." |
| 966 | }, |
| 967 | { |
| 968 | "user_agent", T_OBJECT_EX, offsetof(PyObj_pjsua_config, user_agent), 0, |
| 969 | "User agent string (default empty)" |
| 970 | }, |
| 971 | {NULL} /* Sentinel */ |
| 972 | }; |
| 973 | |
| 974 | |
| 975 | /* |
| 976 | * PyTyp_pjsua_config |
| 977 | * type wrapper for config class |
| 978 | */ |
| 979 | static PyTypeObject PyTyp_pjsua_config = |
| 980 | { |
| 981 | PyObject_HEAD_INIT(NULL) |
| 982 | 0, /*ob_size*/ |
| 983 | "_pjsua.Config", /*tp_name*/ |
| 984 | sizeof(PyObj_pjsua_config),/*tp_basicsize*/ |
| 985 | 0, /*tp_itemsize*/ |
| 986 | (destructor)PyObj_pjsua_config_delete,/*tp_dealloc*/ |
| 987 | 0, /*tp_print*/ |
| 988 | 0, /*tp_getattr*/ |
| 989 | 0, /*tp_setattr*/ |
| 990 | 0, /*tp_compare*/ |
| 991 | 0, /*tp_repr*/ |
| 992 | 0, /*tp_as_number*/ |
| 993 | 0, /*tp_as_sequence*/ |
| 994 | 0, /*tp_as_mapping*/ |
| 995 | 0, /*tp_hash */ |
| 996 | 0, /*tp_call*/ |
| 997 | 0, /*tp_str*/ |
| 998 | 0, /*tp_getattro*/ |
| 999 | 0, /*tp_setattro*/ |
| 1000 | 0, /*tp_as_buffer*/ |
| 1001 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1002 | "Config object", /* tp_doc */ |
| 1003 | 0, /* tp_traverse */ |
| 1004 | 0, /* tp_clear */ |
| 1005 | 0, /* tp_richcompare */ |
| 1006 | 0, /* tp_weaklistoffset */ |
| 1007 | 0, /* tp_iter */ |
| 1008 | 0, /* tp_iternext */ |
| 1009 | 0, /* tp_methods */ |
| 1010 | PyObj_pjsua_config_members,/* tp_members */ |
| 1011 | 0, /* tp_getset */ |
| 1012 | 0, /* tp_base */ |
| 1013 | 0, /* tp_dict */ |
| 1014 | 0, /* tp_descr_get */ |
| 1015 | 0, /* tp_descr_set */ |
| 1016 | 0, /* tp_dictoffset */ |
| 1017 | 0, /* tp_init */ |
| 1018 | 0, /* tp_alloc */ |
| 1019 | PyObj_pjsua_config_new, /* tp_new */ |
| 1020 | |
| 1021 | }; |
| 1022 | |
| 1023 | ////////////////////////////////////////////////////////////////////////////// |
| 1024 | /* |
| 1025 | * PyObj_pjsua_logging_config |
| 1026 | * configuration class for logging_config object |
| 1027 | */ |
| 1028 | typedef struct |
| 1029 | { |
| 1030 | PyObject_HEAD |
| 1031 | /* Type-specific fields go here. */ |
| 1032 | int msg_logging; |
| 1033 | unsigned level; |
| 1034 | unsigned console_level; |
| 1035 | unsigned decor; |
| 1036 | PyObject *log_filename; |
| 1037 | PyObject *cb; |
| 1038 | } PyObj_pjsua_logging_config; |
| 1039 | |
| 1040 | |
| 1041 | /* |
| 1042 | * PyObj_pjsua_logging_config_delete |
| 1043 | * deletes a logging config from memory |
| 1044 | */ |
| 1045 | static void PyObj_pjsua_logging_config_delete(PyObj_pjsua_logging_config* self) |
| 1046 | { |
| 1047 | Py_XDECREF(self->log_filename); |
| 1048 | Py_XDECREF(self->cb); |
| 1049 | self->ob_type->tp_free((PyObject*)self); |
| 1050 | } |
| 1051 | |
| 1052 | |
| 1053 | static void PyObj_pjsua_logging_config_import(PyObj_pjsua_logging_config *obj, |
| 1054 | const pjsua_logging_config *cfg) |
| 1055 | { |
| 1056 | obj->msg_logging = cfg->msg_logging; |
| 1057 | obj->level = cfg->level; |
| 1058 | obj->console_level = cfg->console_level; |
| 1059 | obj->decor = cfg->decor; |
| 1060 | Py_XDECREF(obj->log_filename); |
| 1061 | obj->log_filename = PyString_FromPJ(&cfg->log_filename); |
| 1062 | } |
| 1063 | |
| 1064 | static void PyObj_pjsua_logging_config_export(pjsua_logging_config *cfg, |
| 1065 | PyObj_pjsua_logging_config *obj) |
| 1066 | { |
| 1067 | cfg->msg_logging = obj->msg_logging; |
| 1068 | cfg->level = obj->level; |
| 1069 | cfg->console_level = obj->console_level; |
| 1070 | cfg->decor = obj->decor; |
| 1071 | cfg->log_filename = PyString_ToPJ(obj->log_filename); |
| 1072 | } |
| 1073 | |
| 1074 | |
| 1075 | /* |
| 1076 | * PyObj_pjsua_logging_config_new |
| 1077 | * constructor for logging_config object |
| 1078 | */ |
| 1079 | static PyObject * PyObj_pjsua_logging_config_new(PyTypeObject *type, |
| 1080 | PyObject *args, |
| 1081 | PyObject *kwds) |
| 1082 | { |
| 1083 | PyObj_pjsua_logging_config *self; |
| 1084 | |
| 1085 | PJ_UNUSED_ARG(args); |
| 1086 | PJ_UNUSED_ARG(kwds); |
| 1087 | |
| 1088 | self = (PyObj_pjsua_logging_config *)type->tp_alloc(type, 0); |
| 1089 | if (self != NULL) { |
| 1090 | self->log_filename = PyString_FromString(""); |
| 1091 | self->cb = Py_BuildValue(""); |
| 1092 | } |
| 1093 | |
| 1094 | return (PyObject *)self; |
| 1095 | } |
| 1096 | |
| 1097 | |
| 1098 | /* |
| 1099 | * PyObj_pjsua_logging_config_members |
| 1100 | */ |
| 1101 | static PyMemberDef PyObj_pjsua_logging_config_members[] = |
| 1102 | { |
| 1103 | { |
| 1104 | "msg_logging", T_INT, |
| 1105 | offsetof(PyObj_pjsua_logging_config, msg_logging), 0, |
| 1106 | "Log incoming and outgoing SIP message? Yes!" |
| 1107 | }, |
| 1108 | { |
| 1109 | "level", T_INT, |
| 1110 | offsetof(PyObj_pjsua_logging_config, level), 0, |
| 1111 | "Input verbosity level. Value 5 is reasonable." |
| 1112 | }, |
| 1113 | { |
| 1114 | "console_level", T_INT, |
| 1115 | offsetof(PyObj_pjsua_logging_config, console_level), |
| 1116 | 0, "Verbosity level for console. Value 4 is reasonable." |
| 1117 | }, |
| 1118 | { |
| 1119 | "decor", T_INT, |
| 1120 | offsetof(PyObj_pjsua_logging_config, decor), 0, |
| 1121 | "Log decoration" |
| 1122 | }, |
| 1123 | { |
| 1124 | "log_filename", T_OBJECT_EX, |
| 1125 | offsetof(PyObj_pjsua_logging_config, log_filename), 0, |
| 1126 | "Optional log filename" |
| 1127 | }, |
| 1128 | { |
| 1129 | "cb", T_OBJECT_EX, |
| 1130 | offsetof(PyObj_pjsua_logging_config, cb), 0, |
| 1131 | "Optional callback function to be called to write log to application " |
| 1132 | "specific device. This function will be called forlog messages on " |
| 1133 | "input verbosity level." |
| 1134 | }, |
| 1135 | {NULL} /* Sentinel */ |
| 1136 | }; |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | |
| 1141 | /* |
| 1142 | * PyTyp_pjsua_logging_config |
| 1143 | */ |
| 1144 | static PyTypeObject PyTyp_pjsua_logging_config = |
| 1145 | { |
| 1146 | PyObject_HEAD_INIT(NULL) |
| 1147 | 0, /*ob_size*/ |
| 1148 | "_pjsua.Logging_Config", /*tp_name*/ |
| 1149 | sizeof(PyObj_pjsua_logging_config), /*tp_basicsize*/ |
| 1150 | 0, /*tp_itemsize*/ |
| 1151 | (destructor)PyObj_pjsua_logging_config_delete,/*tp_dealloc*/ |
| 1152 | 0, /*tp_print*/ |
| 1153 | 0, /*tp_getattr*/ |
| 1154 | 0, /*tp_setattr*/ |
| 1155 | 0, /*tp_compare*/ |
| 1156 | 0, /*tp_repr*/ |
| 1157 | 0, /*tp_as_number*/ |
| 1158 | 0, /*tp_as_sequence*/ |
| 1159 | 0, /*tp_as_mapping*/ |
| 1160 | 0, /*tp_hash */ |
| 1161 | 0, /*tp_call*/ |
| 1162 | 0, /*tp_str*/ |
| 1163 | 0, /*tp_getattro*/ |
| 1164 | 0, /*tp_setattro*/ |
| 1165 | 0, /*tp_as_buffer*/ |
| 1166 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1167 | "Logging Config objects", /* tp_doc */ |
| 1168 | 0, /* tp_traverse */ |
| 1169 | 0, /* tp_clear */ |
| 1170 | 0, /* tp_richcompare */ |
| 1171 | 0, /* tp_weaklistoffset */ |
| 1172 | 0, /* tp_iter */ |
| 1173 | 0, /* tp_iternext */ |
| 1174 | 0, /* tp_methods */ |
| 1175 | PyObj_pjsua_logging_config_members,/* tp_members */ |
| 1176 | 0, /* tp_getset */ |
| 1177 | 0, /* tp_base */ |
| 1178 | 0, /* tp_dict */ |
| 1179 | 0, /* tp_descr_get */ |
| 1180 | 0, /* tp_descr_set */ |
| 1181 | 0, /* tp_dictoffset */ |
| 1182 | 0, /* tp_init */ |
| 1183 | 0, /* tp_alloc */ |
| 1184 | PyObj_pjsua_logging_config_new, /* tp_new */ |
| 1185 | |
| 1186 | }; |
| 1187 | |
| 1188 | |
| 1189 | ////////////////////////////////////////////////////////////////////////////// |
| 1190 | /* |
| 1191 | * PyObj_pjsua_msg_data |
| 1192 | * typewrapper for MessageData class |
| 1193 | * !modified @ 061206 |
| 1194 | */ |
| 1195 | typedef struct |
| 1196 | { |
| 1197 | PyObject_HEAD |
| 1198 | /* Type-specific fields go here. */ |
| 1199 | PyObject * hdr_list; |
| 1200 | PyObject * content_type; |
| 1201 | PyObject * msg_body; |
| 1202 | } PyObj_pjsua_msg_data; |
| 1203 | |
| 1204 | |
| 1205 | /* |
| 1206 | * PyObj_pjsua_msg_data_delete |
| 1207 | * deletes a msg_data |
| 1208 | * !modified @ 061206 |
| 1209 | */ |
| 1210 | static void PyObj_pjsua_msg_data_delete(PyObj_pjsua_msg_data* self) |
| 1211 | { |
| 1212 | Py_XDECREF(self->hdr_list); |
| 1213 | Py_XDECREF(self->content_type); |
| 1214 | Py_XDECREF(self->msg_body); |
| 1215 | self->ob_type->tp_free((PyObject*)self); |
| 1216 | } |
| 1217 | |
| 1218 | |
| 1219 | /* |
| 1220 | * PyObj_pjsua_msg_data_new |
| 1221 | * constructor for msg_data object |
| 1222 | * !modified @ 061206 |
| 1223 | */ |
| 1224 | static PyObject * PyObj_pjsua_msg_data_new(PyTypeObject *type, |
| 1225 | PyObject *args, |
| 1226 | PyObject *kwds) |
| 1227 | { |
| 1228 | PyObj_pjsua_msg_data *self; |
| 1229 | |
| 1230 | PJ_UNUSED_ARG(args); |
| 1231 | PJ_UNUSED_ARG(kwds); |
| 1232 | |
| 1233 | self = (PyObj_pjsua_msg_data *)type->tp_alloc(type, 0); |
| 1234 | if (self != NULL) { |
| 1235 | self->hdr_list = PyList_New(0); |
| 1236 | self->content_type = PyString_FromString(""); |
| 1237 | self->msg_body = PyString_FromString(""); |
| 1238 | } |
| 1239 | |
| 1240 | return (PyObject *)self; |
| 1241 | } |
| 1242 | |
| 1243 | |
| 1244 | /* |
| 1245 | * PyObj_pjsua_msg_data_members |
| 1246 | * !modified @ 061206 |
| 1247 | */ |
| 1248 | static PyMemberDef PyObj_pjsua_msg_data_members[] = |
| 1249 | { |
| 1250 | { |
| 1251 | "hdr_list", T_OBJECT_EX, |
| 1252 | offsetof(PyObj_pjsua_msg_data, hdr_list), 0, |
| 1253 | "Additional message headers as linked list of strings." |
| 1254 | }, |
| 1255 | { |
| 1256 | "content_type", T_OBJECT_EX, |
| 1257 | offsetof(PyObj_pjsua_msg_data, content_type), 0, |
| 1258 | "MIME type of optional message body." |
| 1259 | }, |
| 1260 | { |
| 1261 | "msg_body", T_OBJECT_EX, |
| 1262 | offsetof(PyObj_pjsua_msg_data, msg_body), 0, |
| 1263 | "Optional message body." |
| 1264 | }, |
| 1265 | {NULL} /* Sentinel */ |
| 1266 | }; |
| 1267 | |
| 1268 | |
| 1269 | /* |
| 1270 | * PyTyp_pjsua_msg_data |
| 1271 | */ |
| 1272 | static PyTypeObject PyTyp_pjsua_msg_data = |
| 1273 | { |
| 1274 | PyObject_HEAD_INIT(NULL) |
| 1275 | 0, /*ob_size*/ |
| 1276 | "_pjsua.Msg_Data", /*tp_name*/ |
| 1277 | sizeof(PyObj_pjsua_msg_data), /*tp_basicsize*/ |
| 1278 | 0, /*tp_itemsize*/ |
| 1279 | (destructor)PyObj_pjsua_msg_data_delete,/*tp_dealloc*/ |
| 1280 | 0, /*tp_print*/ |
| 1281 | 0, /*tp_getattr*/ |
| 1282 | 0, /*tp_setattr*/ |
| 1283 | 0, /*tp_compare*/ |
| 1284 | 0, /*tp_repr*/ |
| 1285 | 0, /*tp_as_number*/ |
| 1286 | 0, /*tp_as_sequence*/ |
| 1287 | 0, /*tp_as_mapping*/ |
| 1288 | 0, /*tp_hash */ |
| 1289 | 0, /*tp_call*/ |
| 1290 | 0, /*tp_str*/ |
| 1291 | 0, /*tp_getattro*/ |
| 1292 | 0, /*tp_setattro*/ |
| 1293 | 0, /*tp_as_buffer*/ |
| 1294 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1295 | "msg_data objects", /* tp_doc */ |
| 1296 | 0, /* tp_traverse */ |
| 1297 | 0, /* tp_clear */ |
| 1298 | 0, /* tp_richcompare */ |
| 1299 | 0, /* tp_weaklistoffset */ |
| 1300 | 0, /* tp_iter */ |
| 1301 | 0, /* tp_iternext */ |
| 1302 | 0, /* tp_methods */ |
| 1303 | PyObj_pjsua_msg_data_members, /* tp_members */ |
| 1304 | 0, /* tp_getset */ |
| 1305 | 0, /* tp_base */ |
| 1306 | 0, /* tp_dict */ |
| 1307 | 0, /* tp_descr_get */ |
| 1308 | 0, /* tp_descr_set */ |
| 1309 | 0, /* tp_dictoffset */ |
| 1310 | 0, /* tp_init */ |
| 1311 | 0, /* tp_alloc */ |
| 1312 | PyObj_pjsua_msg_data_new, /* tp_new */ |
| 1313 | |
| 1314 | }; |
| 1315 | |
| 1316 | |
| 1317 | ////////////////////////////////////////////////////////////////////////////// |
| 1318 | /* |
| 1319 | * PyObj_pjsua_transport_config |
| 1320 | * Transport configuration for creating UDP transports for both SIP |
| 1321 | * and media. |
| 1322 | */ |
| 1323 | typedef struct |
| 1324 | { |
| 1325 | PyObject_HEAD |
| 1326 | /* Type-specific fields go here. */ |
| 1327 | unsigned port; |
| 1328 | PyObject *public_addr; |
| 1329 | PyObject *bound_addr; |
| 1330 | pj_qos_type qos_type; |
| 1331 | pj_uint8_t qos_params_flags; |
| 1332 | pj_uint8_t qos_params_dscp_val; |
| 1333 | pj_uint8_t qos_params_so_prio; |
| 1334 | pj_qos_wmm_prio qos_params_wmm_prio; |
| 1335 | |
| 1336 | } PyObj_pjsua_transport_config; |
| 1337 | |
| 1338 | |
| 1339 | /* |
| 1340 | * PyObj_pjsua_transport_config_delete |
| 1341 | * deletes a transport config from memory |
| 1342 | */ |
| 1343 | static void PyObj_pjsua_transport_config_delete(PyObj_pjsua_transport_config* self) |
| 1344 | { |
| 1345 | Py_XDECREF(self->public_addr); |
| 1346 | Py_XDECREF(self->bound_addr); |
| 1347 | self->ob_type->tp_free((PyObject*)self); |
| 1348 | } |
| 1349 | |
| 1350 | |
| 1351 | static void PyObj_pjsua_transport_config_export(pjsua_transport_config *cfg, |
| 1352 | PyObj_pjsua_transport_config *obj) |
| 1353 | { |
| 1354 | pjsua_transport_config_default(cfg); |
| 1355 | cfg->public_addr = PyString_ToPJ(obj->public_addr); |
| 1356 | cfg->bound_addr = PyString_ToPJ(obj->bound_addr); |
| 1357 | cfg->port = obj->port; |
| 1358 | cfg->qos_type = obj->qos_type; |
| 1359 | cfg->qos_params.flags = obj->qos_params_flags; |
| 1360 | cfg->qos_params.dscp_val = obj->qos_params_dscp_val; |
| 1361 | cfg->qos_params.so_prio = obj->qos_params_so_prio; |
| 1362 | cfg->qos_params.wmm_prio = obj->qos_params_wmm_prio; |
| 1363 | } |
| 1364 | |
| 1365 | static void PyObj_pjsua_transport_config_import(PyObj_pjsua_transport_config *obj, |
| 1366 | const pjsua_transport_config *cfg) |
| 1367 | { |
| 1368 | Py_XDECREF(obj->public_addr); |
| 1369 | obj->public_addr = PyString_FromPJ(&cfg->public_addr); |
| 1370 | |
| 1371 | Py_XDECREF(obj->bound_addr); |
| 1372 | obj->bound_addr = PyString_FromPJ(&cfg->bound_addr); |
| 1373 | |
| 1374 | obj->port = cfg->port; |
| 1375 | obj->qos_type = cfg->qos_type; |
| 1376 | obj->qos_params_flags = cfg->qos_params.flags; |
| 1377 | obj->qos_params_dscp_val = cfg->qos_params.dscp_val; |
| 1378 | obj->qos_params_so_prio = cfg->qos_params.so_prio; |
| 1379 | obj->qos_params_wmm_prio = cfg->qos_params.wmm_prio; |
| 1380 | |
| 1381 | } |
| 1382 | |
| 1383 | |
| 1384 | /* |
| 1385 | * PyObj_pjsua_transport_config_new |
| 1386 | * constructor for transport_config object |
| 1387 | */ |
| 1388 | static PyObject * PyObj_pjsua_transport_config_new(PyTypeObject *type, |
| 1389 | PyObject *args, |
| 1390 | PyObject *kwds) |
| 1391 | { |
| 1392 | PyObj_pjsua_transport_config *self; |
| 1393 | |
| 1394 | PJ_UNUSED_ARG(args); |
| 1395 | PJ_UNUSED_ARG(kwds); |
| 1396 | |
| 1397 | self = (PyObj_pjsua_transport_config *)type->tp_alloc(type, 0); |
| 1398 | if (self != NULL) { |
| 1399 | self->public_addr = PyString_FromString(""); |
| 1400 | self->bound_addr = PyString_FromString(""); |
| 1401 | } |
| 1402 | |
| 1403 | return (PyObject *)self; |
| 1404 | } |
| 1405 | |
| 1406 | |
| 1407 | /* |
| 1408 | * PyObj_pjsua_transport_config_members |
| 1409 | */ |
| 1410 | static PyMemberDef PyObj_pjsua_transport_config_members[] = |
| 1411 | { |
| 1412 | { |
| 1413 | "port", T_INT, |
| 1414 | offsetof(PyObj_pjsua_transport_config, port), 0, |
| 1415 | "UDP port number to bind locally. This setting MUST be specified " |
| 1416 | "even when default port is desired. If the value is zero, the " |
| 1417 | "transport will be bound to any available port, and application " |
| 1418 | "can query the port by querying the transport info." |
| 1419 | }, |
| 1420 | { |
| 1421 | "public_addr", T_OBJECT_EX, |
| 1422 | offsetof(PyObj_pjsua_transport_config, public_addr), 0, |
| 1423 | "Optional address to advertise as the address of this transport. " |
| 1424 | "Application can specify any address or hostname for this field, " |
| 1425 | "for example it can point to one of the interface address in the " |
| 1426 | "system, or it can point to the public address of a NAT router " |
| 1427 | "where port mappings have been configured for the application." |
| 1428 | }, |
| 1429 | { |
| 1430 | "bound_addr", T_OBJECT_EX, |
| 1431 | offsetof(PyObj_pjsua_transport_config, bound_addr), 0, |
| 1432 | "Optional address where the socket should be bound to. This option " |
| 1433 | "SHOULD only be used to selectively bind the socket to particular " |
| 1434 | "interface (instead of 0.0.0.0), and SHOULD NOT be used to set the " |
| 1435 | "published address of a transport (the public_addr field should be " |
| 1436 | "used for that purpose)." |
| 1437 | }, |
| 1438 | { |
| 1439 | "qos_type", T_INT, |
| 1440 | offsetof(PyObj_pjsua_transport_config, qos_type), 0, |
| 1441 | "High level traffic classification." |
| 1442 | "Enumerator:" |
| 1443 | " 0: PJ_QOS_TYPE_BEST_EFFORT" |
| 1444 | " Best effort traffic (default value). Any QoS function calls with " |
| 1445 | " specifying this value are effectively no-op" |
| 1446 | " 1: PJ_QOS_TYPE_BACKGROUND" |
| 1447 | " Background traffic." |
| 1448 | " 2: PJ_QOS_TYPE_VIDEO" |
| 1449 | " Video traffic." |
| 1450 | " 3: PJ_QOS_TYPE_VOICE" |
| 1451 | " Voice traffic." |
| 1452 | " 4: PJ_QOS_TYPE_CONTROL" |
| 1453 | " Control traffic." |
| 1454 | }, |
| 1455 | { |
| 1456 | "qos_params_flags", T_INT, |
| 1457 | offsetof(PyObj_pjsua_transport_config, qos_params_flags), 0, |
| 1458 | "Determines which values to set, bitmask of pj_qos_flag." |
| 1459 | " PJ_QOS_PARAM_HAS_DSCP = 1" |
| 1460 | " PJ_QOS_PARAM_HAS_SO_PRIO = 2" |
| 1461 | " PJ_QOS_PARAM_HAS_WMM = 4" |
| 1462 | }, |
| 1463 | { |
| 1464 | "qos_params_dscp_val", T_INT, |
| 1465 | offsetof(PyObj_pjsua_transport_config, qos_params_dscp_val), 0, |
| 1466 | "The 6 bits DSCP value to set." |
| 1467 | "Example: 46=EF, 26=AF31, 24=CS3..." |
| 1468 | }, |
| 1469 | { |
| 1470 | "qos_params_so_prio", T_INT, |
| 1471 | offsetof(PyObj_pjsua_transport_config, qos_params_so_prio), 0, |
| 1472 | "Socket SO_PRIORITY value." |
| 1473 | }, |
| 1474 | { |
| 1475 | "qos_params_wmm_prio", T_INT, |
| 1476 | offsetof(PyObj_pjsua_transport_config, qos_params_wmm_prio), 0, |
| 1477 | "Standard WMM priorities." |
| 1478 | "Enumerator:" |
| 1479 | " 0: PJ_QOS_WMM_PRIO_BULK_EFFORT" |
| 1480 | " Bulk effort priority" |
| 1481 | " 1: PJ_QOS_WMM_PRIO_BULK" |
| 1482 | " Bulk priority." |
| 1483 | " 2: PJ_QOS_WMM_PRIO_VIDEO" |
| 1484 | " Video priority" |
| 1485 | " 3: PJ_QOS_WMM_PRIO_VOICE" |
| 1486 | " Voice priority." |
| 1487 | }, |
| 1488 | {NULL} /* Sentinel */ |
| 1489 | }; |
| 1490 | |
| 1491 | |
| 1492 | |
| 1493 | |
| 1494 | /* |
| 1495 | * PyTyp_pjsua_transport_config |
| 1496 | */ |
| 1497 | static PyTypeObject PyTyp_pjsua_transport_config = |
| 1498 | { |
| 1499 | PyObject_HEAD_INIT(NULL) |
| 1500 | 0, /*ob_size*/ |
| 1501 | "_pjsua.Transport_Config", /*tp_name*/ |
| 1502 | sizeof(PyObj_pjsua_transport_config), /*tp_basicsize*/ |
| 1503 | 0, /*tp_itemsize*/ |
| 1504 | (destructor)PyObj_pjsua_transport_config_delete,/*tp_dealloc*/ |
| 1505 | 0, /*tp_print*/ |
| 1506 | 0, /*tp_getattr*/ |
| 1507 | 0, /*tp_setattr*/ |
| 1508 | 0, /*tp_compare*/ |
| 1509 | 0, /*tp_repr*/ |
| 1510 | 0, /*tp_as_number*/ |
| 1511 | 0, /*tp_as_sequence*/ |
| 1512 | 0, /*tp_as_mapping*/ |
| 1513 | 0, /*tp_hash */ |
| 1514 | 0, /*tp_call*/ |
| 1515 | 0, /*tp_str*/ |
| 1516 | 0, /*tp_getattro*/ |
| 1517 | 0, /*tp_setattro*/ |
| 1518 | 0, /*tp_as_buffer*/ |
| 1519 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1520 | "Transport setting", /* tp_doc */ |
| 1521 | 0, /* tp_traverse */ |
| 1522 | 0, /* tp_clear */ |
| 1523 | 0, /* tp_richcompare */ |
| 1524 | 0, /* tp_weaklistoffset */ |
| 1525 | 0, /* tp_iter */ |
| 1526 | 0, /* tp_iternext */ |
| 1527 | 0, /* tp_methods */ |
| 1528 | PyObj_pjsua_transport_config_members,/* tp_members */ |
| 1529 | 0, /* tp_getset */ |
| 1530 | 0, /* tp_base */ |
| 1531 | 0, /* tp_dict */ |
| 1532 | 0, /* tp_descr_get */ |
| 1533 | 0, /* tp_descr_set */ |
| 1534 | 0, /* tp_dictoffset */ |
| 1535 | 0, /* tp_init */ |
| 1536 | 0, /* tp_alloc */ |
| 1537 | PyObj_pjsua_transport_config_new,/* tp_new */ |
| 1538 | }; |
| 1539 | |
| 1540 | |
| 1541 | ////////////////////////////////////////////////////////////////////////////// |
| 1542 | /* |
| 1543 | * PyObj_pjsua_transport_info |
| 1544 | * Transport info |
| 1545 | */ |
| 1546 | typedef struct |
| 1547 | { |
| 1548 | PyObject_HEAD |
| 1549 | /* Type-specific fields go here. */ |
| 1550 | int id; |
| 1551 | int type; |
| 1552 | PyObject *type_name; |
| 1553 | PyObject *info; |
| 1554 | unsigned flag; |
| 1555 | PyObject *addr; |
| 1556 | unsigned port; |
| 1557 | unsigned usage_count; |
| 1558 | } PyObj_pjsua_transport_info; |
| 1559 | |
| 1560 | |
| 1561 | /* |
| 1562 | * PyObj_pjsua_transport_info_delete |
| 1563 | * deletes a transport info from memory |
| 1564 | */ |
| 1565 | static void PyObj_pjsua_transport_info_delete(PyObj_pjsua_transport_info* self) |
| 1566 | { |
| 1567 | Py_XDECREF(self->type_name); |
| 1568 | Py_XDECREF(self->info); |
| 1569 | Py_XDECREF(self->addr); |
| 1570 | self->ob_type->tp_free((PyObject*)self); |
| 1571 | } |
| 1572 | |
| 1573 | |
| 1574 | static void PyObj_pjsua_transport_info_import(PyObj_pjsua_transport_info *obj, |
| 1575 | const pjsua_transport_info *info) |
| 1576 | { |
| 1577 | obj->id = info->id; |
| 1578 | obj->type = info->type; |
| 1579 | obj->type_name = PyString_FromPJ(&info->type_name); |
| 1580 | obj->info = PyString_FromPJ(&info->info); |
| 1581 | obj->flag = info->flag; |
| 1582 | obj->addr = PyString_FromPJ(&info->local_name.host); |
| 1583 | obj->port = info->local_name.port; |
| 1584 | obj->usage_count= info->usage_count; |
| 1585 | } |
| 1586 | |
| 1587 | /* |
| 1588 | * PyObj_pjsua_transport_info_new |
| 1589 | * constructor for transport_info object |
| 1590 | */ |
| 1591 | static PyObject * PyObj_pjsua_transport_info_new(PyTypeObject *type, |
| 1592 | PyObject *args, |
| 1593 | PyObject *kwds) |
| 1594 | { |
| 1595 | PyObj_pjsua_transport_info *self; |
| 1596 | |
| 1597 | PJ_UNUSED_ARG(args); |
| 1598 | PJ_UNUSED_ARG(kwds); |
| 1599 | |
| 1600 | self = (PyObj_pjsua_transport_info *)type->tp_alloc(type, 0); |
| 1601 | if (self != NULL) |
| 1602 | { |
| 1603 | self->type_name = PyString_FromString(""); |
| 1604 | self->info = PyString_FromString(""); |
| 1605 | self->addr = PyString_FromString(""); |
| 1606 | } |
| 1607 | |
| 1608 | return (PyObject *)self; |
| 1609 | } |
| 1610 | |
| 1611 | |
| 1612 | /* |
| 1613 | * PyObj_pjsua_transport_info_members |
| 1614 | */ |
| 1615 | static PyMemberDef PyObj_pjsua_transport_info_members[] = |
| 1616 | { |
| 1617 | { |
| 1618 | "id", T_INT, |
| 1619 | offsetof(PyObj_pjsua_transport_info, id), 0, |
| 1620 | "PJSUA transport identification." |
| 1621 | }, |
| 1622 | { |
| 1623 | "type", T_INT, |
| 1624 | offsetof(PyObj_pjsua_transport_info, type), 0, |
| 1625 | "Transport type." |
| 1626 | }, |
| 1627 | { |
| 1628 | "type_name", T_OBJECT_EX, |
| 1629 | offsetof(PyObj_pjsua_transport_info, type_name), 0, |
| 1630 | "Transport type name." |
| 1631 | }, |
| 1632 | { |
| 1633 | "info", T_OBJECT_EX, |
| 1634 | offsetof(PyObj_pjsua_transport_info, info), 0, |
| 1635 | "Transport string info/description." |
| 1636 | }, |
| 1637 | { |
| 1638 | "flag", T_INT, |
| 1639 | offsetof(PyObj_pjsua_transport_info, flag), 0, |
| 1640 | "Transport flag (see ##pjsip_transport_flags_e)." |
| 1641 | }, |
| 1642 | { |
| 1643 | "addr", T_OBJECT_EX, |
| 1644 | offsetof(PyObj_pjsua_transport_info, addr), 0, |
| 1645 | "Published address (or transport address name)." |
| 1646 | }, |
| 1647 | { |
| 1648 | "port", T_INT, |
| 1649 | offsetof(PyObj_pjsua_transport_info, port), 0, |
| 1650 | "Published port number." |
| 1651 | }, |
| 1652 | { |
| 1653 | "usage_count", T_INT, |
| 1654 | offsetof(PyObj_pjsua_transport_info, usage_count), 0, |
| 1655 | "Current number of objects currently referencing this transport." |
| 1656 | }, |
| 1657 | {NULL} /* Sentinel */ |
| 1658 | }; |
| 1659 | |
| 1660 | |
| 1661 | /* |
| 1662 | * PyTyp_pjsua_transport_info |
| 1663 | */ |
| 1664 | static PyTypeObject PyTyp_pjsua_transport_info = |
| 1665 | { |
| 1666 | PyObject_HEAD_INIT(NULL) |
| 1667 | 0, /*ob_size*/ |
| 1668 | "_pjsua.Transport_Info", /*tp_name*/ |
| 1669 | sizeof(PyObj_pjsua_transport_info), /*tp_basicsize*/ |
| 1670 | 0, /*tp_itemsize*/ |
| 1671 | (destructor)PyObj_pjsua_transport_info_delete,/*tp_dealloc*/ |
| 1672 | 0, /*tp_print*/ |
| 1673 | 0, /*tp_getattr*/ |
| 1674 | 0, /*tp_setattr*/ |
| 1675 | 0, /*tp_compare*/ |
| 1676 | 0, /*tp_repr*/ |
| 1677 | 0, /*tp_as_number*/ |
| 1678 | 0, /*tp_as_sequence*/ |
| 1679 | 0, /*tp_as_mapping*/ |
| 1680 | 0, /*tp_hash */ |
| 1681 | 0, /*tp_call*/ |
| 1682 | 0, /*tp_str*/ |
| 1683 | 0, /*tp_getattro*/ |
| 1684 | 0, /*tp_setattro*/ |
| 1685 | 0, /*tp_as_buffer*/ |
| 1686 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1687 | "Transport Info objects", /* tp_doc */ |
| 1688 | 0, /* tp_traverse */ |
| 1689 | 0, /* tp_clear */ |
| 1690 | 0, /* tp_richcompare */ |
| 1691 | 0, /* tp_weaklistoffset */ |
| 1692 | 0, /* tp_iter */ |
| 1693 | 0, /* tp_iternext */ |
| 1694 | 0, /* tp_methods */ |
| 1695 | PyObj_pjsua_transport_info_members, /* tp_members */ |
| 1696 | 0, /* tp_getset */ |
| 1697 | 0, /* tp_base */ |
| 1698 | 0, /* tp_dict */ |
| 1699 | 0, /* tp_descr_get */ |
| 1700 | 0, /* tp_descr_set */ |
| 1701 | 0, /* tp_dictoffset */ |
| 1702 | 0, /* tp_init */ |
| 1703 | 0, /* tp_alloc */ |
| 1704 | PyObj_pjsua_transport_info_new, /* tp_new */ |
| 1705 | |
| 1706 | }; |
| 1707 | |
| 1708 | |
| 1709 | ////////////////////////////////////////////////////////////////////////////// |
| 1710 | |
| 1711 | /* |
| 1712 | * PyObj_pjsua_acc_config |
| 1713 | * Acc Config |
| 1714 | */ |
| 1715 | typedef struct |
| 1716 | { |
| 1717 | PyObject_HEAD |
| 1718 | /* Type-specific fields go here. */ |
| 1719 | int priority; |
| 1720 | PyObject *id; |
| 1721 | PyObject *reg_uri; |
| 1722 | int publish_enabled; |
| 1723 | int mwi_enabled; |
| 1724 | PyObject *force_contact; |
| 1725 | PyListObject *proxy; |
| 1726 | unsigned reg_timeout; |
| 1727 | unsigned reg_delay_before_refresh; |
| 1728 | PyListObject *cred_info; |
| 1729 | int transport_id; |
| 1730 | int auth_initial_send; |
| 1731 | PyObject *auth_initial_algorithm; |
| 1732 | PyObject *pidf_tuple_id; |
| 1733 | PyObject *contact_params; |
| 1734 | PyObject *contact_uri_params; |
| 1735 | int require_100rel; |
| 1736 | int use_timer; |
| 1737 | unsigned timer_se; |
| 1738 | unsigned timer_min_se; |
| 1739 | int allow_contact_rewrite; |
| 1740 | int ka_interval; |
| 1741 | PyObject *ka_data; |
| 1742 | unsigned use_srtp; |
| 1743 | unsigned srtp_secure_signaling; |
| 1744 | PyObject *rtp_transport_cfg; |
| 1745 | } PyObj_pjsua_acc_config; |
| 1746 | |
| 1747 | |
| 1748 | /* |
| 1749 | * PyObj_pjsua_acc_config_delete |
| 1750 | * deletes a acc_config from memory |
| 1751 | */ |
| 1752 | static void PyObj_pjsua_acc_config_delete(PyObj_pjsua_acc_config* self) |
| 1753 | { |
| 1754 | Py_XDECREF(self->id); |
| 1755 | Py_XDECREF(self->reg_uri); |
| 1756 | Py_XDECREF(self->force_contact); |
| 1757 | Py_XDECREF(self->proxy); |
| 1758 | Py_XDECREF(self->cred_info); |
| 1759 | Py_XDECREF(self->auth_initial_algorithm); |
| 1760 | Py_XDECREF(self->pidf_tuple_id); |
| 1761 | Py_XDECREF(self->contact_params); |
| 1762 | Py_XDECREF(self->contact_uri_params); |
| 1763 | Py_XDECREF(self->ka_data); |
| 1764 | Py_XDECREF(self->rtp_transport_cfg); |
| 1765 | self->ob_type->tp_free((PyObject*)self); |
| 1766 | } |
| 1767 | |
| 1768 | |
| 1769 | static void PyObj_pjsua_acc_config_import(PyObj_pjsua_acc_config *obj, |
| 1770 | const pjsua_acc_config *cfg) |
| 1771 | { |
| 1772 | PyObj_pjsua_transport_config *tconf; |
| 1773 | unsigned i; |
| 1774 | |
| 1775 | obj->priority = cfg->priority; |
| 1776 | Py_XDECREF(obj->id); |
| 1777 | obj->id = PyString_FromPJ(&cfg->id); |
| 1778 | Py_XDECREF(obj->reg_uri); |
| 1779 | obj->reg_uri = PyString_FromPJ(&cfg->reg_uri); |
| 1780 | obj->publish_enabled = cfg->publish_enabled; |
| 1781 | obj->mwi_enabled = cfg->mwi_enabled; |
| 1782 | Py_XDECREF(obj->force_contact); |
| 1783 | obj->force_contact = PyString_FromPJ(&cfg->force_contact); |
| 1784 | Py_XDECREF(obj->proxy); |
| 1785 | obj->proxy = (PyListObject *)PyList_New(0); |
| 1786 | for (i=0; i<cfg->proxy_cnt; ++i) { |
| 1787 | PyObject * str; |
| 1788 | str = PyString_FromPJ(&cfg->proxy[i]); |
| 1789 | PyList_Append((PyObject *)obj->proxy, str); |
| 1790 | } |
| 1791 | |
| 1792 | obj->reg_timeout = cfg->reg_timeout; |
| 1793 | obj->reg_delay_before_refresh = cfg->reg_delay_before_refresh; |
| 1794 | |
| 1795 | Py_XDECREF(obj->cred_info); |
| 1796 | obj->cred_info = (PyListObject *)PyList_New(0); |
| 1797 | for (i=0; i<cfg->cred_count; ++i) { |
| 1798 | PyObj_pjsip_cred_info * ci; |
| 1799 | |
| 1800 | ci = (PyObj_pjsip_cred_info *) |
| 1801 | PyObj_pjsip_cred_info_new(&PyTyp_pjsip_cred_info,NULL,NULL); |
| 1802 | PyObj_pjsip_cred_info_import(ci, &cfg->cred_info[i]); |
| 1803 | PyList_Append((PyObject *)obj->cred_info, (PyObject *)ci); |
| 1804 | } |
| 1805 | |
| 1806 | obj->transport_id = cfg->transport_id; |
| 1807 | |
| 1808 | obj->auth_initial_send = cfg->auth_pref.initial_auth; |
| 1809 | Py_XDECREF(obj->auth_initial_algorithm); |
| 1810 | obj->auth_initial_algorithm = PyString_FromPJ(&cfg->auth_pref.algorithm); |
| 1811 | Py_XDECREF(obj->pidf_tuple_id); |
| 1812 | obj->pidf_tuple_id = PyString_FromPJ(&cfg->pidf_tuple_id); |
| 1813 | Py_XDECREF(obj->contact_params); |
| 1814 | obj->contact_params = PyString_FromPJ(&cfg->contact_params); |
| 1815 | Py_XDECREF(obj->contact_uri_params); |
| 1816 | obj->contact_uri_params = PyString_FromPJ(&cfg->contact_uri_params); |
| 1817 | obj->require_100rel = cfg->require_100rel; |
| 1818 | obj->use_timer = cfg->use_timer; |
| 1819 | obj->timer_se = cfg->timer_setting.sess_expires; |
| 1820 | obj->timer_min_se = cfg->timer_setting.min_se; |
| 1821 | obj->allow_contact_rewrite = cfg->allow_contact_rewrite; |
| 1822 | obj->ka_interval = cfg->ka_interval; |
| 1823 | Py_XDECREF(obj->ka_data); |
| 1824 | obj->ka_data = PyString_FromPJ(&cfg->ka_data); |
| 1825 | obj->use_srtp = cfg->use_srtp; |
| 1826 | obj->srtp_secure_signaling = cfg->srtp_secure_signaling; |
| 1827 | |
| 1828 | Py_XDECREF(obj->rtp_transport_cfg); |
| 1829 | tconf = (PyObj_pjsua_transport_config*) |
| 1830 | PyObj_pjsua_transport_config_new(&PyTyp_pjsua_transport_config, |
| 1831 | NULL, NULL); |
| 1832 | PyObj_pjsua_transport_config_import(tconf, &cfg->rtp_cfg); |
| 1833 | obj->rtp_transport_cfg = (PyObject *) tconf; |
| 1834 | } |
| 1835 | |
| 1836 | static void PyObj_pjsua_acc_config_export(pjsua_acc_config *cfg, |
| 1837 | PyObj_pjsua_acc_config *obj) |
| 1838 | { |
| 1839 | PyObj_pjsua_transport_config *tconf; |
| 1840 | unsigned i; |
| 1841 | |
| 1842 | cfg->priority = obj->priority; |
| 1843 | cfg->id = PyString_ToPJ(obj->id); |
| 1844 | cfg->reg_uri = PyString_ToPJ(obj->reg_uri); |
| 1845 | cfg->publish_enabled = obj->publish_enabled; |
| 1846 | cfg->mwi_enabled = obj->mwi_enabled; |
| 1847 | cfg->force_contact = PyString_ToPJ(obj->force_contact); |
| 1848 | |
| 1849 | cfg->proxy_cnt = PyList_Size((PyObject*)obj->proxy); |
| 1850 | if (cfg->proxy_cnt > PJ_ARRAY_SIZE(cfg->proxy)) |
| 1851 | cfg->proxy_cnt = PJ_ARRAY_SIZE(cfg->proxy); |
| 1852 | for (i = 0; i < cfg->proxy_cnt; i++) { |
| 1853 | PyObject *item = PyList_GetItem((PyObject *)obj->proxy, i); |
| 1854 | cfg->proxy[i] = PyString_ToPJ(item); |
| 1855 | } |
| 1856 | |
| 1857 | cfg->reg_timeout = obj->reg_timeout; |
| 1858 | cfg->reg_delay_before_refresh = obj->reg_delay_before_refresh; |
| 1859 | |
| 1860 | cfg->cred_count = PyList_Size((PyObject*)obj->cred_info); |
| 1861 | if (cfg->cred_count > PJ_ARRAY_SIZE(cfg->cred_info)) |
| 1862 | cfg->cred_count = PJ_ARRAY_SIZE(cfg->cred_info); |
| 1863 | for (i = 0; i < cfg->cred_count; i++) { |
| 1864 | PyObj_pjsip_cred_info *ci; |
| 1865 | ci = (PyObj_pjsip_cred_info*) |
| 1866 | PyList_GetItem((PyObject *)obj->cred_info, i); |
| 1867 | PyObj_pjsip_cred_info_export(&cfg->cred_info[i], ci); |
| 1868 | } |
| 1869 | |
| 1870 | cfg->transport_id = obj->transport_id; |
| 1871 | cfg->auth_pref.initial_auth = obj->auth_initial_send; |
| 1872 | cfg->auth_pref.algorithm = PyString_ToPJ(obj->auth_initial_algorithm); |
| 1873 | cfg->pidf_tuple_id = PyString_ToPJ(obj->pidf_tuple_id); |
| 1874 | cfg->contact_params = PyString_ToPJ(obj->contact_params); |
| 1875 | cfg->contact_uri_params = PyString_ToPJ(obj->contact_uri_params); |
| 1876 | cfg->require_100rel = obj->require_100rel; |
| 1877 | cfg->use_timer = obj->use_timer; |
| 1878 | cfg->timer_setting.sess_expires = obj->timer_se; |
| 1879 | cfg->timer_setting.min_se = obj->timer_min_se; |
| 1880 | cfg->allow_contact_rewrite = obj->allow_contact_rewrite; |
| 1881 | cfg->ka_interval = obj->ka_interval; |
| 1882 | cfg->ka_data = PyString_ToPJ(obj->ka_data); |
| 1883 | cfg->use_srtp = obj->use_srtp; |
| 1884 | cfg->srtp_secure_signaling = obj->srtp_secure_signaling; |
| 1885 | |
| 1886 | tconf = (PyObj_pjsua_transport_config*)obj->rtp_transport_cfg; |
| 1887 | PyObj_pjsua_transport_config_export(&cfg->rtp_cfg, tconf); |
| 1888 | } |
| 1889 | |
| 1890 | |
| 1891 | /* |
| 1892 | * PyObj_pjsua_acc_config_new |
| 1893 | * constructor for acc_config object |
| 1894 | */ |
| 1895 | static PyObject * PyObj_pjsua_acc_config_new(PyTypeObject *type, |
| 1896 | PyObject *args, |
| 1897 | PyObject *kwds) |
| 1898 | { |
| 1899 | PyObj_pjsua_acc_config *self; |
| 1900 | |
| 1901 | PJ_UNUSED_ARG(args); |
| 1902 | PJ_UNUSED_ARG(kwds); |
| 1903 | |
| 1904 | self = (PyObj_pjsua_acc_config *)type->tp_alloc(type, 0); |
| 1905 | if (self != NULL) { |
| 1906 | self->id = PyString_FromString(""); |
| 1907 | self->reg_uri = PyString_FromString(""); |
| 1908 | self->force_contact = PyString_FromString(""); |
| 1909 | self->proxy = (PyListObject *)PyList_New(0); |
| 1910 | self->cred_info = (PyListObject *)PyList_New(0); |
| 1911 | self->auth_initial_algorithm = PyString_FromString(""); |
| 1912 | self->pidf_tuple_id = PyString_FromString(""); |
| 1913 | self->contact_params = PyString_FromString(""); |
| 1914 | self->contact_uri_params = PyString_FromString(""); |
| 1915 | self->ka_data = PyString_FromString(""); |
| 1916 | } |
| 1917 | |
| 1918 | return (PyObject *)self; |
| 1919 | } |
| 1920 | |
| 1921 | |
| 1922 | |
| 1923 | /* |
| 1924 | * PyObj_pjsua_acc_config_members |
| 1925 | */ |
| 1926 | static PyMemberDef PyObj_pjsua_acc_config_members[] = |
| 1927 | { |
| 1928 | { |
| 1929 | "priority", T_INT, offsetof(PyObj_pjsua_acc_config, priority), 0, |
| 1930 | "Account priority, which is used to control the order of matching " |
| 1931 | "incoming/outgoing requests. The higher the number means the higher " |
| 1932 | "the priority is, and the account will be matched first. " |
| 1933 | }, |
| 1934 | { |
| 1935 | "id", T_OBJECT_EX, |
| 1936 | offsetof(PyObj_pjsua_acc_config, id), 0, |
| 1937 | "The full SIP URL for the account. " |
| 1938 | "The value can take name address or URL format, " |
| 1939 | "and will look something like 'sip:account@serviceprovider'. " |
| 1940 | "This field is mandatory." |
| 1941 | }, |
| 1942 | { |
| 1943 | "reg_uri", T_OBJECT_EX, |
| 1944 | offsetof(PyObj_pjsua_acc_config, reg_uri), 0, |
| 1945 | "This is the URL to be put in the request URI for the registration, " |
| 1946 | "and will look something like 'sip:serviceprovider'. " |
| 1947 | "This field should be specified if registration is desired. " |
| 1948 | "If the value is empty, no account registration will be performed. " |
| 1949 | }, |
| 1950 | { |
| 1951 | "publish_enabled", T_INT, |
| 1952 | offsetof(PyObj_pjsua_acc_config, publish_enabled), 0, |
| 1953 | "Publish presence? " |
| 1954 | }, |
| 1955 | { |
| 1956 | "mwi_enabled", T_INT, |
| 1957 | offsetof(PyObj_pjsua_acc_config, mwi_enabled), 0, |
| 1958 | "Enable MWI subscription " |
| 1959 | }, |
| 1960 | { |
| 1961 | "force_contact", T_OBJECT_EX, |
| 1962 | offsetof(PyObj_pjsua_acc_config, force_contact), 0, |
| 1963 | "Optional URI to be put as Contact for this account. " |
| 1964 | "It is recommended that this field is left empty, " |
| 1965 | "so that the value will be calculated automatically " |
| 1966 | "based on the transport address. " |
| 1967 | }, |
| 1968 | { |
| 1969 | "proxy", T_OBJECT_EX, |
| 1970 | offsetof(PyObj_pjsua_acc_config, proxy), 0, |
| 1971 | "Optional URI of the proxies to be visited for all outgoing requests " |
| 1972 | "that are using this account (REGISTER, INVITE, etc). Application need " |
| 1973 | "to specify these proxies if the service provider requires " |
| 1974 | "that requests destined towards its network should go through certain " |
| 1975 | "proxies first (for example, border controllers)." |
| 1976 | }, |
| 1977 | { |
| 1978 | "reg_timeout", T_INT, |
| 1979 | offsetof(PyObj_pjsua_acc_config, reg_timeout), 0, |
| 1980 | "Optional interval for registration, in seconds. " |
| 1981 | "If the value is zero, default interval will be used " |
| 1982 | "(PJSUA_REG_INTERVAL, 55 seconds). " |
| 1983 | }, |
| 1984 | { |
| 1985 | "reg_delay_before_refresh", T_INT, |
| 1986 | offsetof(PyObj_pjsua_acc_config, reg_delay_before_refresh), 0, |
| 1987 | "Specify the number of seconds to refresh the client registration" |
| 1988 | "before the registration expires." |
| 1989 | "(PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds). " |
| 1990 | }, |
| 1991 | { |
| 1992 | "cred_info", T_OBJECT_EX, |
| 1993 | offsetof(PyObj_pjsua_acc_config, cred_info), 0, |
| 1994 | "Array of credentials. If registration is desired, normally there " |
| 1995 | "should be at least one credential specified, to successfully " |
| 1996 | "authenticate against the service provider. More credentials can " |
| 1997 | "be specified, for example when the requests are expected to be " |
| 1998 | "challenged by the proxies in the route set." |
| 1999 | }, |
| 2000 | { |
| 2001 | "transport_id", T_INT, |
| 2002 | offsetof(PyObj_pjsua_acc_config, transport_id), 0, |
| 2003 | "Optionally bind this account to specific transport. This normally is" |
| 2004 | " not a good idea, as account should be able to send requests using" |
| 2005 | " any available transports according to the destination. But some" |
| 2006 | " application may want to have explicit control over the transport to" |
| 2007 | " use, so in that case it can set this field." |
| 2008 | }, |
| 2009 | { |
| 2010 | "auth_initial_send", T_INT, |
| 2011 | offsetof(PyObj_pjsua_acc_config, auth_initial_send), 0, |
| 2012 | "Send empty initial authorization header." |
| 2013 | }, |
| 2014 | { |
| 2015 | "auth_initial_algorithm", T_OBJECT_EX, |
| 2016 | offsetof(PyObj_pjsua_acc_config, auth_initial_algorithm), 0, |
| 2017 | "Specify algorithm in empty initial authorization header." |
| 2018 | }, |
| 2019 | { |
| 2020 | "pidf_tuple_id", T_OBJECT_EX, |
| 2021 | offsetof(PyObj_pjsua_acc_config, pidf_tuple_id), 0, |
| 2022 | "PIDF tuple id." |
| 2023 | }, |
| 2024 | { |
| 2025 | "contact_params", T_OBJECT_EX, |
| 2026 | offsetof(PyObj_pjsua_acc_config, contact_params), 0, |
| 2027 | "Additional parameters for Contact header." |
| 2028 | }, |
| 2029 | { |
| 2030 | "contact_uri_params", T_OBJECT_EX, |
| 2031 | offsetof(PyObj_pjsua_acc_config, contact_uri_params), 0, |
| 2032 | "Additional parameters for Contact URI." |
| 2033 | }, |
| 2034 | { |
| 2035 | "require_100rel", T_INT, |
| 2036 | offsetof(PyObj_pjsua_acc_config, require_100rel), 0, |
| 2037 | "Require reliable provisional response." |
| 2038 | }, |
| 2039 | { |
| 2040 | "use_timer", T_INT, |
| 2041 | offsetof(PyObj_pjsua_acc_config, use_timer), 0, |
| 2042 | "Use SIP session timers? (default=1)" |
| 2043 | "0:inactive, 1:optional, 2:mandatory, 3:always" |
| 2044 | }, |
| 2045 | { |
| 2046 | "timer_se", T_INT, |
| 2047 | offsetof(PyObj_pjsua_acc_config, timer_se), 0, |
| 2048 | "Session timer expiration period, in seconds." |
| 2049 | }, |
| 2050 | { |
| 2051 | "timer_min_se", T_INT, |
| 2052 | offsetof(PyObj_pjsua_acc_config, timer_min_se), 0, |
| 2053 | "Session timer minimum expiration period, in seconds." |
| 2054 | }, |
| 2055 | { |
| 2056 | "allow_contact_rewrite", T_INT, |
| 2057 | offsetof(PyObj_pjsua_acc_config, allow_contact_rewrite), 0, |
| 2058 | "Re-REGISTER if behind symmetric NAT." |
| 2059 | }, |
| 2060 | { |
| 2061 | "ka_interval", T_INT, |
| 2062 | offsetof(PyObj_pjsua_acc_config, ka_interval), 0, |
| 2063 | "Keep-alive interval." |
| 2064 | }, |
| 2065 | { |
| 2066 | "ka_data", T_OBJECT_EX, |
| 2067 | offsetof(PyObj_pjsua_acc_config, ka_data), 0, |
| 2068 | "Keep-alive data." |
| 2069 | }, |
| 2070 | { |
| 2071 | "use_srtp", T_INT, |
| 2072 | offsetof(PyObj_pjsua_acc_config, use_srtp), 0, |
| 2073 | "Specify SRTP usage." |
| 2074 | }, |
| 2075 | { |
| 2076 | "srtp_secure_signaling", T_INT, |
| 2077 | offsetof(PyObj_pjsua_acc_config, srtp_secure_signaling), 0, |
| 2078 | "Specify if SRTP requires secure signaling to be used." |
| 2079 | }, |
| 2080 | { |
| 2081 | "rtp_transport_cfg", T_OBJECT_EX, |
| 2082 | offsetof(PyObj_pjsua_acc_config, rtp_transport_cfg), 0, |
| 2083 | "Transport configuration for RTP." |
| 2084 | }, |
| 2085 | |
| 2086 | {NULL} /* Sentinel */ |
| 2087 | }; |
| 2088 | |
| 2089 | |
| 2090 | |
| 2091 | |
| 2092 | /* |
| 2093 | * PyTyp_pjsua_acc_config |
| 2094 | */ |
| 2095 | static PyTypeObject PyTyp_pjsua_acc_config = |
| 2096 | { |
| 2097 | PyObject_HEAD_INIT(NULL) |
| 2098 | 0, /*ob_size*/ |
| 2099 | "_pjsua.Acc_Config", /*tp_name*/ |
| 2100 | sizeof(PyObj_pjsua_acc_config), /*tp_basicsize*/ |
| 2101 | 0, /*tp_itemsize*/ |
| 2102 | (destructor)PyObj_pjsua_acc_config_delete,/*tp_dealloc*/ |
| 2103 | 0, /*tp_print*/ |
| 2104 | 0, /*tp_getattr*/ |
| 2105 | 0, /*tp_setattr*/ |
| 2106 | 0, /*tp_compare*/ |
| 2107 | 0, /*tp_repr*/ |
| 2108 | 0, /*tp_as_number*/ |
| 2109 | 0, /*tp_as_sequence*/ |
| 2110 | 0, /*tp_as_mapping*/ |
| 2111 | 0, /*tp_hash */ |
| 2112 | 0, /*tp_call*/ |
| 2113 | 0, /*tp_str*/ |
| 2114 | 0, /*tp_getattro*/ |
| 2115 | 0, /*tp_setattro*/ |
| 2116 | 0, /*tp_as_buffer*/ |
| 2117 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2118 | "Account settings", /* tp_doc */ |
| 2119 | 0, /* tp_traverse */ |
| 2120 | 0, /* tp_clear */ |
| 2121 | 0, /* tp_richcompare */ |
| 2122 | 0, /* tp_weaklistoffset */ |
| 2123 | 0, /* tp_iter */ |
| 2124 | 0, /* tp_iternext */ |
| 2125 | 0, /* tp_methods */ |
| 2126 | PyObj_pjsua_acc_config_members, /* tp_members */ |
| 2127 | 0, /* tp_getset */ |
| 2128 | 0, /* tp_base */ |
| 2129 | 0, /* tp_dict */ |
| 2130 | 0, /* tp_descr_get */ |
| 2131 | 0, /* tp_descr_set */ |
| 2132 | 0, /* tp_dictoffset */ |
| 2133 | 0, /* tp_init */ |
| 2134 | 0, /* tp_alloc */ |
| 2135 | PyObj_pjsua_acc_config_new, /* tp_new */ |
| 2136 | |
| 2137 | }; |
| 2138 | |
| 2139 | |
| 2140 | ////////////////////////////////////////////////////////////////////////////// |
| 2141 | /* |
| 2142 | * PyObj_pjsua_acc_info |
| 2143 | * Acc Info |
| 2144 | */ |
| 2145 | typedef struct |
| 2146 | { |
| 2147 | PyObject_HEAD |
| 2148 | /* Type-specific fields go here. */ |
| 2149 | int id; |
| 2150 | int is_default; |
| 2151 | PyObject *acc_uri; |
| 2152 | int has_registration; |
| 2153 | int expires; |
| 2154 | int status; |
| 2155 | PyObject *status_text; |
| 2156 | int online_status; |
| 2157 | PyObject *online_status_text; |
| 2158 | } PyObj_pjsua_acc_info; |
| 2159 | |
| 2160 | |
| 2161 | /* |
| 2162 | * PyObj_pjsua_acc_info_delete |
| 2163 | * deletes a acc_info from memory |
| 2164 | */ |
| 2165 | static void PyObj_pjsua_acc_info_delete(PyObj_pjsua_acc_info* self) |
| 2166 | { |
| 2167 | Py_XDECREF(self->acc_uri); |
| 2168 | Py_XDECREF(self->status_text); |
| 2169 | Py_XDECREF(self->online_status_text); |
| 2170 | self->ob_type->tp_free((PyObject*)self); |
| 2171 | } |
| 2172 | |
| 2173 | |
| 2174 | static void PyObj_pjsua_acc_info_import(PyObj_pjsua_acc_info *obj, |
| 2175 | const pjsua_acc_info *info) |
| 2176 | { |
| 2177 | obj->id = info->id; |
| 2178 | obj->is_default = info->is_default; |
| 2179 | Py_XDECREF(obj->acc_uri); |
| 2180 | obj->acc_uri = PyString_FromPJ(&info->acc_uri); |
| 2181 | obj->has_registration = info->has_registration; |
| 2182 | obj->expires = info->expires; |
| 2183 | obj->status = info->status; |
| 2184 | Py_XDECREF(obj->status_text); |
| 2185 | obj->status_text= PyString_FromPJ(&info->status_text); |
| 2186 | obj->online_status = info->online_status; |
| 2187 | Py_XDECREF(obj->online_status_text); |
| 2188 | obj->online_status_text = PyString_FromPJ(&info->online_status_text); |
| 2189 | } |
| 2190 | |
| 2191 | |
| 2192 | /* |
| 2193 | * PyObj_pjsua_acc_info_new |
| 2194 | * constructor for acc_info object |
| 2195 | */ |
| 2196 | static PyObject * PyObj_pjsua_acc_info_new(PyTypeObject *type, |
| 2197 | PyObject *args, |
| 2198 | PyObject *kwds) |
| 2199 | { |
| 2200 | PyObj_pjsua_acc_info *self; |
| 2201 | |
| 2202 | PJ_UNUSED_ARG(args); |
| 2203 | PJ_UNUSED_ARG(kwds); |
| 2204 | |
| 2205 | self = (PyObj_pjsua_acc_info *)type->tp_alloc(type, 0); |
| 2206 | if (self != NULL) { |
| 2207 | self->acc_uri = PyString_FromString(""); |
| 2208 | self->status_text = PyString_FromString(""); |
| 2209 | self->online_status_text = PyString_FromString(""); |
| 2210 | } |
| 2211 | |
| 2212 | return (PyObject *)self; |
| 2213 | } |
| 2214 | |
| 2215 | /* |
| 2216 | * acc_info_members |
| 2217 | */ |
| 2218 | static PyMemberDef acc_info_members[] = |
| 2219 | { |
| 2220 | { |
| 2221 | "id", T_INT, |
| 2222 | offsetof(PyObj_pjsua_acc_info, id), 0, |
| 2223 | "The account ID." |
| 2224 | }, |
| 2225 | { |
| 2226 | "is_default", T_INT, |
| 2227 | offsetof(PyObj_pjsua_acc_info, is_default), 0, |
| 2228 | "Flag to indicate whether this is the default account. " |
| 2229 | }, |
| 2230 | { |
| 2231 | "acc_uri", T_OBJECT_EX, |
| 2232 | offsetof(PyObj_pjsua_acc_info, acc_uri), 0, |
| 2233 | "Account URI" |
| 2234 | }, |
| 2235 | { |
| 2236 | "has_registration", T_INT, |
| 2237 | offsetof(PyObj_pjsua_acc_info, has_registration), 0, |
| 2238 | "Flag to tell whether this account has registration setting " |
| 2239 | "(reg_uri is not empty)." |
| 2240 | }, |
| 2241 | { |
| 2242 | "expires", T_INT, |
| 2243 | offsetof(PyObj_pjsua_acc_info, expires), 0, |
| 2244 | "An up to date expiration interval for account registration session." |
| 2245 | }, |
| 2246 | { |
| 2247 | "status", T_INT, |
| 2248 | offsetof(PyObj_pjsua_acc_info, status), 0, |
| 2249 | "Last registration status code. If status code is zero, " |
| 2250 | "the account is currently not registered. Any other value indicates " |
| 2251 | "the SIP status code of the registration. " |
| 2252 | }, |
| 2253 | { |
| 2254 | "status_text", T_OBJECT_EX, |
| 2255 | offsetof(PyObj_pjsua_acc_info, status_text), 0, |
| 2256 | "String describing the registration status." |
| 2257 | }, |
| 2258 | { |
| 2259 | "online_status", T_INT, |
| 2260 | offsetof(PyObj_pjsua_acc_info, online_status), 0, |
| 2261 | "Presence online status for this account. " |
| 2262 | }, |
| 2263 | { |
| 2264 | "online_status_text", T_OBJECT_EX, |
| 2265 | offsetof(PyObj_pjsua_acc_info, online_status_text), 0, |
| 2266 | "Presence online status text." |
| 2267 | }, |
| 2268 | {NULL} /* Sentinel */ |
| 2269 | }; |
| 2270 | |
| 2271 | |
| 2272 | |
| 2273 | |
| 2274 | /* |
| 2275 | * PyTyp_pjsua_acc_info |
| 2276 | */ |
| 2277 | static PyTypeObject PyTyp_pjsua_acc_info = |
| 2278 | { |
| 2279 | PyObject_HEAD_INIT(NULL) |
| 2280 | 0, /*ob_size*/ |
| 2281 | "_pjsua.Acc_Info", /*tp_name*/ |
| 2282 | sizeof(PyObj_pjsua_acc_info), /*tp_basicsize*/ |
| 2283 | 0, /*tp_itemsize*/ |
| 2284 | (destructor)PyObj_pjsua_acc_info_delete,/*tp_dealloc*/ |
| 2285 | 0, /*tp_print*/ |
| 2286 | 0, /*tp_getattr*/ |
| 2287 | 0, /*tp_setattr*/ |
| 2288 | 0, /*tp_compare*/ |
| 2289 | 0, /*tp_repr*/ |
| 2290 | 0, /*tp_as_number*/ |
| 2291 | 0, /*tp_as_sequence*/ |
| 2292 | 0, /*tp_as_mapping*/ |
| 2293 | 0, /*tp_hash */ |
| 2294 | 0, /*tp_call*/ |
| 2295 | 0, /*tp_str*/ |
| 2296 | 0, /*tp_getattro*/ |
| 2297 | 0, /*tp_setattro*/ |
| 2298 | 0, /*tp_as_buffer*/ |
| 2299 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2300 | "Account info", /* tp_doc */ |
| 2301 | 0, /* tp_traverse */ |
| 2302 | 0, /* tp_clear */ |
| 2303 | 0, /* tp_richcompare */ |
| 2304 | 0, /* tp_weaklistoffset */ |
| 2305 | 0, /* tp_iter */ |
| 2306 | 0, /* tp_iternext */ |
| 2307 | NULL, /* tp_methods */ |
| 2308 | acc_info_members, /* tp_members */ |
| 2309 | 0, /* tp_getset */ |
| 2310 | 0, /* tp_base */ |
| 2311 | 0, /* tp_dict */ |
| 2312 | 0, /* tp_descr_get */ |
| 2313 | 0, /* tp_descr_set */ |
| 2314 | 0, /* tp_dictoffset */ |
| 2315 | 0, /* tp_init */ |
| 2316 | 0, /* tp_alloc */ |
| 2317 | PyObj_pjsua_acc_info_new, /* tp_new */ |
| 2318 | |
| 2319 | }; |
| 2320 | |
| 2321 | |
| 2322 | ////////////////////////////////////////////////////////////////////////////// |
| 2323 | |
| 2324 | /* |
| 2325 | * PyObj_pjsua_buddy_config |
| 2326 | * Buddy Config |
| 2327 | */ |
| 2328 | typedef struct |
| 2329 | { |
| 2330 | PyObject_HEAD |
| 2331 | /* Type-specific fields go here. */ |
| 2332 | PyObject *uri; |
| 2333 | int subscribe; |
| 2334 | } PyObj_pjsua_buddy_config; |
| 2335 | |
| 2336 | |
| 2337 | /* |
| 2338 | * PyObj_pjsua_buddy_config_delete |
| 2339 | * deletes a buddy_config from memory |
| 2340 | */ |
| 2341 | static void PyObj_pjsua_buddy_config_delete(PyObj_pjsua_buddy_config* self) |
| 2342 | { |
| 2343 | Py_XDECREF(self->uri); |
| 2344 | self->ob_type->tp_free((PyObject*)self); |
| 2345 | } |
| 2346 | |
| 2347 | |
| 2348 | static void PyObj_pjsua_buddy_config_import(PyObj_pjsua_buddy_config *obj, |
| 2349 | const pjsua_buddy_config *cfg) |
| 2350 | { |
| 2351 | Py_XDECREF(obj->uri); |
| 2352 | obj->uri = PyString_FromPJ(&cfg->uri); |
| 2353 | obj->subscribe = cfg->subscribe; |
| 2354 | } |
| 2355 | |
| 2356 | |
| 2357 | static void PyObj_pjsua_buddy_config_export(pjsua_buddy_config *cfg, |
| 2358 | PyObj_pjsua_buddy_config *obj) |
| 2359 | { |
| 2360 | cfg->uri = PyString_ToPJ(obj->uri); |
| 2361 | cfg->subscribe = obj->subscribe; |
| 2362 | cfg->user_data = NULL; |
| 2363 | } |
| 2364 | |
| 2365 | |
| 2366 | /* |
| 2367 | * PyObj_pjsua_buddy_config_new |
| 2368 | * constructor for buddy_config object |
| 2369 | */ |
| 2370 | static PyObject *PyObj_pjsua_buddy_config_new(PyTypeObject *type, |
| 2371 | PyObject *args, |
| 2372 | PyObject *kwds) |
| 2373 | { |
| 2374 | PyObj_pjsua_buddy_config *self; |
| 2375 | |
| 2376 | PJ_UNUSED_ARG(args); |
| 2377 | PJ_UNUSED_ARG(kwds); |
| 2378 | |
| 2379 | self = (PyObj_pjsua_buddy_config *)type->tp_alloc(type, 0); |
| 2380 | if (self != NULL) { |
| 2381 | self->uri = PyString_FromString(""); |
| 2382 | } |
| 2383 | return (PyObject *)self; |
| 2384 | } |
| 2385 | |
| 2386 | /* |
| 2387 | * PyObj_pjsua_buddy_config_members |
| 2388 | */ |
| 2389 | static PyMemberDef PyObj_pjsua_buddy_config_members[] = |
| 2390 | { |
| 2391 | |
| 2392 | { |
| 2393 | "uri", T_OBJECT_EX, |
| 2394 | offsetof(PyObj_pjsua_buddy_config, uri), 0, |
| 2395 | "TBuddy URL or name address." |
| 2396 | }, |
| 2397 | |
| 2398 | { |
| 2399 | "subscribe", T_INT, |
| 2400 | offsetof(PyObj_pjsua_buddy_config, subscribe), 0, |
| 2401 | "Specify whether presence subscription should start immediately. " |
| 2402 | }, |
| 2403 | |
| 2404 | {NULL} /* Sentinel */ |
| 2405 | }; |
| 2406 | |
| 2407 | |
| 2408 | |
| 2409 | |
| 2410 | /* |
| 2411 | * PyTyp_pjsua_buddy_config |
| 2412 | */ |
| 2413 | static PyTypeObject PyTyp_pjsua_buddy_config = |
| 2414 | { |
| 2415 | PyObject_HEAD_INIT(NULL) |
| 2416 | 0, /*ob_size*/ |
| 2417 | "_pjsua.Buddy_Config", /*tp_name*/ |
| 2418 | sizeof(PyObj_pjsua_buddy_config),/*tp_basicsize*/ |
| 2419 | 0, /*tp_itemsize*/ |
| 2420 | (destructor)PyObj_pjsua_buddy_config_delete,/*tp_dealloc*/ |
| 2421 | 0, /*tp_print*/ |
| 2422 | 0, /*tp_getattr*/ |
| 2423 | 0, /*tp_setattr*/ |
| 2424 | 0, /*tp_compare*/ |
| 2425 | 0, /*tp_repr*/ |
| 2426 | 0, /*tp_as_number*/ |
| 2427 | 0, /*tp_as_sequence*/ |
| 2428 | 0, /*tp_as_mapping*/ |
| 2429 | 0, /*tp_hash */ |
| 2430 | 0, /*tp_call*/ |
| 2431 | 0, /*tp_str*/ |
| 2432 | 0, /*tp_getattro*/ |
| 2433 | 0, /*tp_setattro*/ |
| 2434 | 0, /*tp_as_buffer*/ |
| 2435 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2436 | "Buddy config", /* tp_doc */ |
| 2437 | 0, /* tp_traverse */ |
| 2438 | 0, /* tp_clear */ |
| 2439 | 0, /* tp_richcompare */ |
| 2440 | 0, /* tp_weaklistoffset */ |
| 2441 | 0, /* tp_iter */ |
| 2442 | 0, /* tp_iternext */ |
| 2443 | 0, /* tp_methods */ |
| 2444 | PyObj_pjsua_buddy_config_members,/* tp_members */ |
| 2445 | 0, /* tp_getset */ |
| 2446 | 0, /* tp_base */ |
| 2447 | 0, /* tp_dict */ |
| 2448 | 0, /* tp_descr_get */ |
| 2449 | 0, /* tp_descr_set */ |
| 2450 | 0, /* tp_dictoffset */ |
| 2451 | 0, /* tp_init */ |
| 2452 | 0, /* tp_alloc */ |
| 2453 | PyObj_pjsua_buddy_config_new, /* tp_new */ |
| 2454 | |
| 2455 | }; |
| 2456 | |
| 2457 | ////////////////////////////////////////////////////////////////////////////// |
| 2458 | /* |
| 2459 | * PyObj_pjsua_buddy_info |
| 2460 | * Buddy Info |
| 2461 | */ |
| 2462 | typedef struct |
| 2463 | { |
| 2464 | PyObject_HEAD |
| 2465 | /* Type-specific fields go here. */ |
| 2466 | int id; |
| 2467 | PyObject *uri; |
| 2468 | PyObject *contact; |
| 2469 | int status; |
| 2470 | PyObject *status_text; |
| 2471 | int monitor_pres; |
| 2472 | int activity; |
| 2473 | int sub_state; |
| 2474 | PyObject *sub_term_reason; |
| 2475 | } PyObj_pjsua_buddy_info; |
| 2476 | |
| 2477 | |
| 2478 | /* |
| 2479 | * PyObj_pjsua_buddy_info_delete |
| 2480 | * deletes a buddy_info from memory |
| 2481 | * !modified @ 071206 |
| 2482 | */ |
| 2483 | static void PyObj_pjsua_buddy_info_delete(PyObj_pjsua_buddy_info* self) |
| 2484 | { |
| 2485 | Py_XDECREF(self->uri); |
| 2486 | Py_XDECREF(self->contact); |
| 2487 | Py_XDECREF(self->status_text); |
| 2488 | Py_XDECREF(self->sub_term_reason); |
| 2489 | |
| 2490 | self->ob_type->tp_free((PyObject*)self); |
| 2491 | } |
| 2492 | |
| 2493 | |
| 2494 | static void PyObj_pjsua_buddy_info_import(PyObj_pjsua_buddy_info *obj, |
| 2495 | const pjsua_buddy_info *info) |
| 2496 | { |
| 2497 | obj->id = info->id; |
| 2498 | Py_XDECREF(obj->uri); |
| 2499 | obj->uri = PyString_FromPJ(&info->uri); |
| 2500 | Py_XDECREF(obj->contact); |
| 2501 | obj->contact = PyString_FromPJ(&info->contact); |
| 2502 | obj->status = info->status; |
| 2503 | Py_XDECREF(obj->status_text); |
| 2504 | obj->status_text = PyString_FromPJ(&info->status_text); |
| 2505 | obj->monitor_pres = info->monitor_pres; |
| 2506 | obj->activity = info->rpid.activity; |
| 2507 | obj->sub_state = info->sub_state; |
| 2508 | Py_XDECREF(obj->sub_term_reason); |
| 2509 | obj->sub_term_reason = PyString_FromPJ(&info->sub_term_reason); |
| 2510 | } |
| 2511 | |
| 2512 | |
| 2513 | /* |
| 2514 | * PyObj_pjsua_buddy_info_new |
| 2515 | * constructor for buddy_info object |
| 2516 | * !modified @ 071206 |
| 2517 | */ |
| 2518 | static PyObject * PyObj_pjsua_buddy_info_new(PyTypeObject *type, |
| 2519 | PyObject *args, |
| 2520 | PyObject *kwds) |
| 2521 | { |
| 2522 | PyObj_pjsua_buddy_info *self; |
| 2523 | |
| 2524 | PJ_UNUSED_ARG(args); |
| 2525 | PJ_UNUSED_ARG(kwds); |
| 2526 | |
| 2527 | self = (PyObj_pjsua_buddy_info *)type->tp_alloc(type, 0); |
| 2528 | if (self != NULL) { |
| 2529 | self->uri = PyString_FromString(""); |
| 2530 | self->contact = PyString_FromString(""); |
| 2531 | self->status_text = PyString_FromString(""); |
| 2532 | self->sub_term_reason = PyString_FromString(""); |
| 2533 | } |
| 2534 | return (PyObject *)self; |
| 2535 | } |
| 2536 | |
| 2537 | /* |
| 2538 | * PyObj_pjsua_buddy_info_members |
| 2539 | * !modified @ 071206 |
| 2540 | */ |
| 2541 | static PyMemberDef PyObj_pjsua_buddy_info_members[] = |
| 2542 | { |
| 2543 | { |
| 2544 | "id", T_INT, |
| 2545 | offsetof(PyObj_pjsua_buddy_info, id), 0, |
| 2546 | "The buddy ID." |
| 2547 | }, |
| 2548 | { |
| 2549 | "uri", T_OBJECT_EX, |
| 2550 | offsetof(PyObj_pjsua_buddy_info, uri), 0, |
| 2551 | "The full URI of the buddy, as specified in the configuration. " |
| 2552 | }, |
| 2553 | { |
| 2554 | "contact", T_OBJECT_EX, |
| 2555 | offsetof(PyObj_pjsua_buddy_info, contact), 0, |
| 2556 | "Buddy's Contact, only available when presence subscription " |
| 2557 | "has been established to the buddy." |
| 2558 | }, |
| 2559 | { |
| 2560 | "status", T_INT, |
| 2561 | offsetof(PyObj_pjsua_buddy_info, status), 0, |
| 2562 | "Buddy's online status. " |
| 2563 | }, |
| 2564 | { |
| 2565 | "status_text", T_OBJECT_EX, |
| 2566 | offsetof(PyObj_pjsua_buddy_info, status_text), 0, |
| 2567 | "Text to describe buddy's online status." |
| 2568 | }, |
| 2569 | { |
| 2570 | "monitor_pres", T_INT, |
| 2571 | offsetof(PyObj_pjsua_buddy_info, monitor_pres), 0, |
| 2572 | "Flag to indicate that we should monitor the presence information " |
| 2573 | "for this buddy (normally yes, unless explicitly disabled). " |
| 2574 | }, |
| 2575 | { |
| 2576 | "activity", T_INT, |
| 2577 | offsetof(PyObj_pjsua_buddy_info, activity), 0, |
| 2578 | "Activity type. " |
| 2579 | }, |
| 2580 | { |
| 2581 | "sub_state", T_INT, |
| 2582 | offsetof(PyObj_pjsua_buddy_info, sub_state), 0, |
| 2583 | "Subscription state." |
| 2584 | }, |
| 2585 | { |
| 2586 | "sub_term_reason", T_INT, |
| 2587 | offsetof(PyObj_pjsua_buddy_info, sub_term_reason), 0, |
| 2588 | "Subscription termination reason." |
| 2589 | }, |
| 2590 | |
| 2591 | |
| 2592 | {NULL} /* Sentinel */ |
| 2593 | }; |
| 2594 | |
| 2595 | |
| 2596 | |
| 2597 | |
| 2598 | /* |
| 2599 | * PyTyp_pjsua_buddy_info |
| 2600 | */ |
| 2601 | static PyTypeObject PyTyp_pjsua_buddy_info = |
| 2602 | { |
| 2603 | PyObject_HEAD_INIT(NULL) |
| 2604 | 0, /*ob_size*/ |
| 2605 | "_pjsua.Buddy_Info", /*tp_name*/ |
| 2606 | sizeof(PyObj_pjsua_buddy_info), /*tp_basicsize*/ |
| 2607 | 0, /*tp_itemsize*/ |
| 2608 | (destructor)PyObj_pjsua_buddy_info_delete,/*tp_dealloc*/ |
| 2609 | 0, /*tp_print*/ |
| 2610 | 0, /*tp_getattr*/ |
| 2611 | 0, /*tp_setattr*/ |
| 2612 | 0, /*tp_compare*/ |
| 2613 | 0, /*tp_repr*/ |
| 2614 | 0, /*tp_as_number*/ |
| 2615 | 0, /*tp_as_sequence*/ |
| 2616 | 0, /*tp_as_mapping*/ |
| 2617 | 0, /*tp_hash */ |
| 2618 | 0, /*tp_call*/ |
| 2619 | 0, /*tp_str*/ |
| 2620 | 0, /*tp_getattro*/ |
| 2621 | 0, /*tp_setattro*/ |
| 2622 | 0, /*tp_as_buffer*/ |
| 2623 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2624 | "Buddy Info object", /* tp_doc */ |
| 2625 | 0, /* tp_traverse */ |
| 2626 | 0, /* tp_clear */ |
| 2627 | 0, /* tp_richcompare */ |
| 2628 | 0, /* tp_weaklistoffset */ |
| 2629 | 0, /* tp_iter */ |
| 2630 | 0, /* tp_iternext */ |
| 2631 | 0, /* tp_methods */ |
| 2632 | PyObj_pjsua_buddy_info_members, /* tp_members */ |
| 2633 | 0, /* tp_getset */ |
| 2634 | 0, /* tp_base */ |
| 2635 | 0, /* tp_dict */ |
| 2636 | 0, /* tp_descr_get */ |
| 2637 | 0, /* tp_descr_set */ |
| 2638 | 0, /* tp_dictoffset */ |
| 2639 | 0, /* tp_init */ |
| 2640 | 0, /* tp_alloc */ |
| 2641 | PyObj_pjsua_buddy_info_new, /* tp_new */ |
| 2642 | |
| 2643 | }; |
| 2644 | |
| 2645 | |
| 2646 | ////////////////////////////////////////////////////////////////////////////// |
| 2647 | |
| 2648 | /* |
| 2649 | * PyObj_pjsua_codec_info |
| 2650 | * Codec Info |
| 2651 | */ |
| 2652 | typedef struct |
| 2653 | { |
| 2654 | PyObject_HEAD |
| 2655 | /* Type-specific fields go here. */ |
| 2656 | |
| 2657 | PyObject * codec_id; |
| 2658 | pj_uint8_t priority; |
| 2659 | } PyObj_pjsua_codec_info; |
| 2660 | |
| 2661 | |
| 2662 | /* |
| 2663 | * codec_info_dealloc |
| 2664 | * deletes a codec_info from memory |
| 2665 | */ |
| 2666 | static void codec_info_dealloc(PyObj_pjsua_codec_info* self) |
| 2667 | { |
| 2668 | Py_XDECREF(self->codec_id); |
| 2669 | self->ob_type->tp_free((PyObject*)self); |
| 2670 | } |
| 2671 | |
| 2672 | |
| 2673 | /* |
| 2674 | * codec_info_new |
| 2675 | * constructor for codec_info object |
| 2676 | */ |
| 2677 | static PyObject * codec_info_new(PyTypeObject *type, PyObject *args, |
| 2678 | PyObject *kwds) |
| 2679 | { |
| 2680 | PyObj_pjsua_codec_info *self; |
| 2681 | |
| 2682 | PJ_UNUSED_ARG(args); |
| 2683 | PJ_UNUSED_ARG(kwds); |
| 2684 | |
| 2685 | self = (PyObj_pjsua_codec_info *)type->tp_alloc(type, 0); |
| 2686 | if (self != NULL) { |
| 2687 | self->codec_id = PyString_FromString(""); |
| 2688 | } |
| 2689 | return (PyObject *)self; |
| 2690 | } |
| 2691 | |
| 2692 | /* |
| 2693 | * codec_info_members |
| 2694 | * !modified @ 071206 |
| 2695 | */ |
| 2696 | static PyMemberDef codec_info_members[] = |
| 2697 | { |
| 2698 | { |
| 2699 | "codec_id", T_OBJECT_EX, |
| 2700 | offsetof(PyObj_pjsua_codec_info, codec_id), 0, |
| 2701 | "Codec unique identification." |
| 2702 | }, |
| 2703 | { |
| 2704 | "priority", T_INT, |
| 2705 | offsetof(PyObj_pjsua_codec_info, priority), 0, |
| 2706 | "Codec priority (integer 0-255)." |
| 2707 | }, |
| 2708 | |
| 2709 | {NULL} /* Sentinel */ |
| 2710 | }; |
| 2711 | |
| 2712 | /* |
| 2713 | * PyTyp_pjsua_codec_info |
| 2714 | */ |
| 2715 | static PyTypeObject PyTyp_pjsua_codec_info = |
| 2716 | { |
| 2717 | PyObject_HEAD_INIT(NULL) |
| 2718 | 0, /*ob_size*/ |
| 2719 | "_pjsua.Codec_Info", /*tp_name*/ |
| 2720 | sizeof(PyObj_pjsua_codec_info), /*tp_basicsize*/ |
| 2721 | 0, /*tp_itemsize*/ |
| 2722 | (destructor)codec_info_dealloc, /*tp_dealloc*/ |
| 2723 | 0, /*tp_print*/ |
| 2724 | 0, /*tp_getattr*/ |
| 2725 | 0, /*tp_setattr*/ |
| 2726 | 0, /*tp_compare*/ |
| 2727 | 0, /*tp_repr*/ |
| 2728 | 0, /*tp_as_number*/ |
| 2729 | 0, /*tp_as_sequence*/ |
| 2730 | 0, /*tp_as_mapping*/ |
| 2731 | 0, /*tp_hash */ |
| 2732 | 0, /*tp_call*/ |
| 2733 | 0, /*tp_str*/ |
| 2734 | 0, /*tp_getattro*/ |
| 2735 | 0, /*tp_setattro*/ |
| 2736 | 0, /*tp_as_buffer*/ |
| 2737 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2738 | "Codec Info", /* tp_doc */ |
| 2739 | 0, /* tp_traverse */ |
| 2740 | 0, /* tp_clear */ |
| 2741 | 0, /* tp_richcompare */ |
| 2742 | 0, /* tp_weaklistoffset */ |
| 2743 | 0, /* tp_iter */ |
| 2744 | 0, /* tp_iternext */ |
| 2745 | 0, /* tp_methods */ |
| 2746 | codec_info_members, /* tp_members */ |
| 2747 | 0, /* tp_getset */ |
| 2748 | 0, /* tp_base */ |
| 2749 | 0, /* tp_dict */ |
| 2750 | 0, /* tp_descr_get */ |
| 2751 | 0, /* tp_descr_set */ |
| 2752 | 0, /* tp_dictoffset */ |
| 2753 | 0, /* tp_init */ |
| 2754 | 0, /* tp_alloc */ |
| 2755 | codec_info_new, /* tp_new */ |
| 2756 | |
| 2757 | }; |
| 2758 | |
| 2759 | |
| 2760 | ////////////////////////////////////////////////////////////////////////////// |
| 2761 | |
| 2762 | /* |
| 2763 | * PyObj_pjsua_conf_port_info |
| 2764 | * Conf Port Info |
| 2765 | */ |
| 2766 | typedef struct |
| 2767 | { |
| 2768 | PyObject_HEAD |
| 2769 | /* Type-specific fields go here. */ |
| 2770 | |
| 2771 | int slot_id; |
| 2772 | PyObject *name; |
| 2773 | unsigned clock_rate; |
| 2774 | unsigned channel_count; |
| 2775 | unsigned samples_per_frame; |
| 2776 | unsigned bits_per_sample; |
| 2777 | PyObject *listeners; |
| 2778 | |
| 2779 | } PyObj_pjsua_conf_port_info; |
| 2780 | |
| 2781 | |
| 2782 | /* |
| 2783 | * conf_port_info_dealloc |
| 2784 | * deletes a conf_port_info from memory |
| 2785 | */ |
| 2786 | static void conf_port_info_dealloc(PyObj_pjsua_conf_port_info* self) |
| 2787 | { |
| 2788 | Py_XDECREF(self->name); |
| 2789 | Py_XDECREF(self->listeners); |
| 2790 | self->ob_type->tp_free((PyObject*)self); |
| 2791 | } |
| 2792 | |
| 2793 | |
| 2794 | /* |
| 2795 | * conf_port_info_new |
| 2796 | * constructor for conf_port_info object |
| 2797 | */ |
| 2798 | static PyObject * conf_port_info_new(PyTypeObject *type, PyObject *args, |
| 2799 | PyObject *kwds) |
| 2800 | { |
| 2801 | PyObj_pjsua_conf_port_info *self; |
| 2802 | |
| 2803 | PJ_UNUSED_ARG(args); |
| 2804 | PJ_UNUSED_ARG(kwds); |
| 2805 | |
| 2806 | self = (PyObj_pjsua_conf_port_info *)type->tp_alloc(type, 0); |
| 2807 | if (self != NULL) { |
| 2808 | self->name = PyString_FromString(""); |
| 2809 | self->listeners = PyList_New(0); |
| 2810 | } |
| 2811 | return (PyObject *)self; |
| 2812 | } |
| 2813 | |
| 2814 | /* |
| 2815 | * conf_port_info_members |
| 2816 | */ |
| 2817 | static PyMemberDef conf_port_info_members[] = |
| 2818 | { |
| 2819 | { |
| 2820 | "slot_id", T_INT, |
| 2821 | offsetof(PyObj_pjsua_conf_port_info, slot_id), 0, |
| 2822 | "Conference port number." |
| 2823 | }, |
| 2824 | { |
| 2825 | "name", T_OBJECT_EX, |
| 2826 | offsetof(PyObj_pjsua_conf_port_info, name), 0, |
| 2827 | "Port name" |
| 2828 | }, |
| 2829 | { |
| 2830 | "clock_rate", T_INT, |
| 2831 | offsetof(PyObj_pjsua_conf_port_info, clock_rate), 0, |
| 2832 | "Clock rate" |
| 2833 | }, |
| 2834 | { |
| 2835 | "channel_count", T_INT, |
| 2836 | offsetof(PyObj_pjsua_conf_port_info, channel_count), 0, |
| 2837 | "Number of channels." |
| 2838 | }, |
| 2839 | { |
| 2840 | "samples_per_frame", T_INT, |
| 2841 | offsetof(PyObj_pjsua_conf_port_info, samples_per_frame), 0, |
| 2842 | "Samples per frame " |
| 2843 | }, |
| 2844 | { |
| 2845 | "bits_per_sample", T_INT, |
| 2846 | offsetof(PyObj_pjsua_conf_port_info, bits_per_sample), 0, |
| 2847 | "Bits per sample" |
| 2848 | }, |
| 2849 | { |
| 2850 | "listeners", T_OBJECT_EX, |
| 2851 | offsetof(PyObj_pjsua_conf_port_info, listeners), 0, |
| 2852 | "Array of listeners (in other words, ports where this port " |
| 2853 | "is transmitting to" |
| 2854 | }, |
| 2855 | |
| 2856 | {NULL} /* Sentinel */ |
| 2857 | }; |
| 2858 | |
| 2859 | |
| 2860 | |
| 2861 | |
| 2862 | /* |
| 2863 | * PyTyp_pjsua_conf_port_info |
| 2864 | */ |
| 2865 | static PyTypeObject PyTyp_pjsua_conf_port_info = |
| 2866 | { |
| 2867 | PyObject_HEAD_INIT(NULL) |
| 2868 | 0, /*ob_size*/ |
| 2869 | "_pjsua.Conf_Port_Info", /*tp_name*/ |
| 2870 | sizeof(PyObj_pjsua_conf_port_info), /*tp_basicsize*/ |
| 2871 | 0, /*tp_itemsize*/ |
| 2872 | (destructor)conf_port_info_dealloc,/*tp_dealloc*/ |
| 2873 | 0, /*tp_print*/ |
| 2874 | 0, /*tp_getattr*/ |
| 2875 | 0, /*tp_setattr*/ |
| 2876 | 0, /*tp_compare*/ |
| 2877 | 0, /*tp_repr*/ |
| 2878 | 0, /*tp_as_number*/ |
| 2879 | 0, /*tp_as_sequence*/ |
| 2880 | 0, /*tp_as_mapping*/ |
| 2881 | 0, /*tp_hash */ |
| 2882 | 0, /*tp_call*/ |
| 2883 | 0, /*tp_str*/ |
| 2884 | 0, /*tp_getattro*/ |
| 2885 | 0, /*tp_setattro*/ |
| 2886 | 0, /*tp_as_buffer*/ |
| 2887 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2888 | "Conf Port Info objects", /* tp_doc */ |
| 2889 | 0, /* tp_traverse */ |
| 2890 | 0, /* tp_clear */ |
| 2891 | 0, /* tp_richcompare */ |
| 2892 | 0, /* tp_weaklistoffset */ |
| 2893 | 0, /* tp_iter */ |
| 2894 | 0, /* tp_iternext */ |
| 2895 | 0, /* tp_methods */ |
| 2896 | conf_port_info_members, /* tp_members */ |
| 2897 | 0, /* tp_getset */ |
| 2898 | 0, /* tp_base */ |
| 2899 | 0, /* tp_dict */ |
| 2900 | 0, /* tp_descr_get */ |
| 2901 | 0, /* tp_descr_set */ |
| 2902 | 0, /* tp_dictoffset */ |
| 2903 | 0, /* tp_init */ |
| 2904 | 0, /* tp_alloc */ |
| 2905 | conf_port_info_new, /* tp_new */ |
| 2906 | |
| 2907 | }; |
| 2908 | |
| 2909 | ////////////////////////////////////////////////////////////////////////////// |
| 2910 | |
| 2911 | /* |
| 2912 | * PyObj_pjmedia_snd_dev_info |
| 2913 | * PJMedia Snd Dev Info |
| 2914 | */ |
| 2915 | typedef struct |
| 2916 | { |
| 2917 | PyObject_HEAD |
| 2918 | /* Type-specific fields go here. */ |
| 2919 | |
| 2920 | unsigned input_count; |
| 2921 | unsigned output_count; |
| 2922 | unsigned default_samples_per_sec; |
| 2923 | PyObject *name; |
| 2924 | |
| 2925 | } PyObj_pjmedia_snd_dev_info; |
| 2926 | |
| 2927 | /* |
| 2928 | * pjmedia_snd_dev_info_dealloc |
| 2929 | * deletes a pjmedia_snd_dev_info from memory |
| 2930 | */ |
| 2931 | static void pjmedia_snd_dev_info_dealloc(PyObj_pjmedia_snd_dev_info* self) |
| 2932 | { |
| 2933 | Py_XDECREF(self->name); |
| 2934 | self->ob_type->tp_free((PyObject*)self); |
| 2935 | } |
| 2936 | |
| 2937 | /* |
| 2938 | * pjmedia_snd_dev_info_new |
| 2939 | * constructor for pjmedia_snd_dev_info object |
| 2940 | */ |
| 2941 | static PyObject * pjmedia_snd_dev_info_new(PyTypeObject *type, |
| 2942 | PyObject *args, |
| 2943 | PyObject *kwds) |
| 2944 | { |
| 2945 | PyObj_pjmedia_snd_dev_info *self; |
| 2946 | |
| 2947 | PJ_UNUSED_ARG(args); |
| 2948 | PJ_UNUSED_ARG(kwds); |
| 2949 | |
| 2950 | self = (PyObj_pjmedia_snd_dev_info *)type->tp_alloc(type, 0); |
| 2951 | if (self != NULL) { |
| 2952 | self->name = PyString_FromString(""); |
| 2953 | } |
| 2954 | return (PyObject *)self; |
| 2955 | } |
| 2956 | |
| 2957 | /* |
| 2958 | * pjmedia_snd_dev_info_members |
| 2959 | */ |
| 2960 | static PyMemberDef pjmedia_snd_dev_info_members[] = |
| 2961 | { |
| 2962 | { |
| 2963 | "input_count", T_INT, |
| 2964 | offsetof(PyObj_pjmedia_snd_dev_info, input_count), 0, |
| 2965 | "Max number of input channels" |
| 2966 | }, |
| 2967 | { |
| 2968 | "output_count", T_INT, |
| 2969 | offsetof(PyObj_pjmedia_snd_dev_info, output_count), 0, |
| 2970 | "Max number of output channels" |
| 2971 | }, |
| 2972 | { |
| 2973 | "default_samples_per_sec", T_INT, |
| 2974 | offsetof(PyObj_pjmedia_snd_dev_info, default_samples_per_sec), 0, |
| 2975 | "Default sampling rate." |
| 2976 | }, |
| 2977 | { |
| 2978 | "name", T_OBJECT_EX, |
| 2979 | offsetof(PyObj_pjmedia_snd_dev_info, name), 0, |
| 2980 | "Device name" |
| 2981 | }, |
| 2982 | |
| 2983 | {NULL} /* Sentinel */ |
| 2984 | }; |
| 2985 | |
| 2986 | |
| 2987 | /* |
| 2988 | * PyTyp_pjmedia_snd_dev_info |
| 2989 | */ |
| 2990 | static PyTypeObject PyTyp_pjmedia_snd_dev_info = |
| 2991 | { |
| 2992 | PyObject_HEAD_INIT(NULL) |
| 2993 | 0, /*ob_size*/ |
| 2994 | "_pjsua.PJMedia_Snd_Dev_Info", /*tp_name*/ |
| 2995 | sizeof(PyObj_pjmedia_snd_dev_info), /*tp_basicsize*/ |
| 2996 | 0, /*tp_itemsize*/ |
| 2997 | (destructor)pjmedia_snd_dev_info_dealloc,/*tp_dealloc*/ |
| 2998 | 0, /*tp_print*/ |
| 2999 | 0, /*tp_getattr*/ |
| 3000 | 0, /*tp_setattr*/ |
| 3001 | 0, /*tp_compare*/ |
| 3002 | 0, /*tp_repr*/ |
| 3003 | 0, /*tp_as_number*/ |
| 3004 | 0, /*tp_as_sequence*/ |
| 3005 | 0, /*tp_as_mapping*/ |
| 3006 | 0, /*tp_hash */ |
| 3007 | 0, /*tp_call*/ |
| 3008 | 0, /*tp_str*/ |
| 3009 | 0, /*tp_getattro*/ |
| 3010 | 0, /*tp_setattro*/ |
| 3011 | 0, /*tp_as_buffer*/ |
| 3012 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3013 | "PJMedia Snd Dev Info object", /* tp_doc */ |
| 3014 | 0, /* tp_traverse */ |
| 3015 | 0, /* tp_clear */ |
| 3016 | 0, /* tp_richcompare */ |
| 3017 | 0, /* tp_weaklistoffset */ |
| 3018 | 0, /* tp_iter */ |
| 3019 | 0, /* tp_iternext */ |
| 3020 | 0, /* tp_methods */ |
| 3021 | pjmedia_snd_dev_info_members, /* tp_members */ |
| 3022 | 0, /* tp_getset */ |
| 3023 | 0, /* tp_base */ |
| 3024 | 0, /* tp_dict */ |
| 3025 | 0, /* tp_descr_get */ |
| 3026 | 0, /* tp_descr_set */ |
| 3027 | 0, /* tp_dictoffset */ |
| 3028 | 0, /* tp_init */ |
| 3029 | 0, /* tp_alloc */ |
| 3030 | pjmedia_snd_dev_info_new, /* tp_new */ |
| 3031 | |
| 3032 | }; |
| 3033 | |
| 3034 | ////////////////////////////////////////////////////////////////////////////// |
| 3035 | |
| 3036 | /* |
| 3037 | * PyObj_pjmedia_codec_param_info |
| 3038 | * PJMedia Codec Param Info |
| 3039 | */ |
| 3040 | typedef struct |
| 3041 | { |
| 3042 | PyObject_HEAD |
| 3043 | /* Type-specific fields go here. */ |
| 3044 | |
| 3045 | unsigned clock_rate; |
| 3046 | unsigned channel_cnt; |
| 3047 | pj_uint32_t avg_bps; |
| 3048 | pj_uint16_t frm_ptime; |
| 3049 | pj_uint8_t pcm_bits_per_sample; |
| 3050 | pj_uint8_t pt; |
| 3051 | |
| 3052 | } PyObj_pjmedia_codec_param_info; |
| 3053 | |
| 3054 | |
| 3055 | |
| 3056 | /* |
| 3057 | * pjmedia_codec_param_info_members |
| 3058 | */ |
| 3059 | static PyMemberDef pjmedia_codec_param_info_members[] = |
| 3060 | { |
| 3061 | { |
| 3062 | "clock_rate", T_INT, |
| 3063 | offsetof(PyObj_pjmedia_codec_param_info, clock_rate), 0, |
| 3064 | "Sampling rate in Hz" |
| 3065 | }, |
| 3066 | { |
| 3067 | "channel_cnt", T_INT, |
| 3068 | offsetof(PyObj_pjmedia_codec_param_info, channel_cnt), 0, |
| 3069 | "Channel count" |
| 3070 | }, |
| 3071 | { |
| 3072 | "avg_bps", T_INT, |
| 3073 | offsetof(PyObj_pjmedia_codec_param_info, avg_bps), 0, |
| 3074 | "Average bandwidth in bits/sec" |
| 3075 | }, |
| 3076 | { |
| 3077 | "frm_ptime", T_INT, |
| 3078 | offsetof(PyObj_pjmedia_codec_param_info, frm_ptime), 0, |
| 3079 | "Base frame ptime in msec." |
| 3080 | }, |
| 3081 | { |
| 3082 | "pcm_bits_per_sample", T_INT, |
| 3083 | offsetof(PyObj_pjmedia_codec_param_info, pcm_bits_per_sample), 0, |
| 3084 | "Bits/sample in the PCM side" |
| 3085 | }, |
| 3086 | { |
| 3087 | "pt", T_INT, |
| 3088 | offsetof(PyObj_pjmedia_codec_param_info, pt), 0, |
| 3089 | "Payload type" |
| 3090 | }, |
| 3091 | |
| 3092 | {NULL} /* Sentinel */ |
| 3093 | }; |
| 3094 | |
| 3095 | |
| 3096 | /* |
| 3097 | * PyTyp_pjmedia_codec_param_info |
| 3098 | */ |
| 3099 | static PyTypeObject PyTyp_pjmedia_codec_param_info = |
| 3100 | { |
| 3101 | PyObject_HEAD_INIT(NULL) |
| 3102 | 0, /*ob_size*/ |
| 3103 | "_pjsua.PJMedia_Codec_Param_Info", /*tp_name*/ |
| 3104 | sizeof(PyObj_pjmedia_codec_param_info), /*tp_basicsize*/ |
| 3105 | 0, /*tp_itemsize*/ |
| 3106 | 0, /*tp_dealloc*/ |
| 3107 | 0, /*tp_print*/ |
| 3108 | 0, /*tp_getattr*/ |
| 3109 | 0, /*tp_setattr*/ |
| 3110 | 0, /*tp_compare*/ |
| 3111 | 0, /*tp_repr*/ |
| 3112 | 0, /*tp_as_number*/ |
| 3113 | 0, /*tp_as_sequence*/ |
| 3114 | 0, /*tp_as_mapping*/ |
| 3115 | 0, /*tp_hash */ |
| 3116 | 0, /*tp_call*/ |
| 3117 | 0, /*tp_str*/ |
| 3118 | 0, /*tp_getattro*/ |
| 3119 | 0, /*tp_setattro*/ |
| 3120 | 0, /*tp_as_buffer*/ |
| 3121 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3122 | "PJMedia Codec Param Info objects",/* tp_doc */ |
| 3123 | 0, /* tp_traverse */ |
| 3124 | 0, /* tp_clear */ |
| 3125 | 0, /* tp_richcompare */ |
| 3126 | 0, /* tp_weaklistoffset */ |
| 3127 | 0, /* tp_iter */ |
| 3128 | 0, /* tp_iternext */ |
| 3129 | 0, /* tp_methods */ |
| 3130 | pjmedia_codec_param_info_members,/* tp_members */ |
| 3131 | }; |
| 3132 | |
| 3133 | |
| 3134 | ////////////////////////////////////////////////////////////////////////////// |
| 3135 | |
| 3136 | /* |
| 3137 | * PyObj_pjmedia_codec_param_setting |
| 3138 | * PJMedia Codec Param Setting |
| 3139 | */ |
| 3140 | typedef struct |
| 3141 | { |
| 3142 | PyObject_HEAD |
| 3143 | /* Type-specific fields go here. */ |
| 3144 | pj_uint8_t frm_per_pkt; |
| 3145 | unsigned vad; |
| 3146 | unsigned cng; |
| 3147 | unsigned penh; |
| 3148 | unsigned plc; |
| 3149 | #if 0 |
| 3150 | pj_uint8_t enc_fmtp_mode; |
| 3151 | pj_uint8_t dec_fmtp_mode; |
| 3152 | #endif |
| 3153 | |
| 3154 | } PyObj_pjmedia_codec_param_setting; |
| 3155 | |
| 3156 | |
| 3157 | |
| 3158 | /* |
| 3159 | * pjmedia_codec_param_setting_members |
| 3160 | */ |
| 3161 | static PyMemberDef pjmedia_codec_param_setting_members[] = |
| 3162 | { |
| 3163 | { |
| 3164 | "frm_per_pkt", T_INT, |
| 3165 | offsetof(PyObj_pjmedia_codec_param_setting, frm_per_pkt), 0, |
| 3166 | "Number of frames per packet" |
| 3167 | }, |
| 3168 | { |
| 3169 | "vad", T_INT, |
| 3170 | offsetof(PyObj_pjmedia_codec_param_setting, vad), 0, |
| 3171 | "Voice Activity Detector" |
| 3172 | }, |
| 3173 | { |
| 3174 | "cng", T_INT, |
| 3175 | offsetof(PyObj_pjmedia_codec_param_setting, cng), 0, |
| 3176 | "Comfort Noise Generator" |
| 3177 | }, |
| 3178 | { |
| 3179 | "penh", T_INT, |
| 3180 | offsetof(PyObj_pjmedia_codec_param_setting, penh), 0, |
| 3181 | "Perceptual Enhancement" |
| 3182 | }, |
| 3183 | { |
| 3184 | "plc", T_INT, |
| 3185 | offsetof(PyObj_pjmedia_codec_param_setting, plc), 0, |
| 3186 | "Packet loss concealment" |
| 3187 | }, |
| 3188 | #if 0 // no longer valid with latest modification in codec |
| 3189 | { |
| 3190 | "enc_fmtp_mode", T_INT, |
| 3191 | offsetof(PyObj_pjmedia_codec_param_setting, enc_fmtp_mode), 0, |
| 3192 | "Mode param in fmtp (def:0)" |
| 3193 | }, |
| 3194 | { |
| 3195 | "dec_fmtp_mode", T_INT, |
| 3196 | offsetof(PyObj_pjmedia_codec_param_setting, dec_fmtp_mode), 0, |
| 3197 | "Mode param in fmtp (def:0)" |
| 3198 | }, |
| 3199 | #endif |
| 3200 | |
| 3201 | {NULL} /* Sentinel */ |
| 3202 | }; |
| 3203 | |
| 3204 | |
| 3205 | /* |
| 3206 | * PyTyp_pjmedia_codec_param_setting |
| 3207 | */ |
| 3208 | static PyTypeObject PyTyp_pjmedia_codec_param_setting = |
| 3209 | { |
| 3210 | PyObject_HEAD_INIT(NULL) |
| 3211 | 0, /*ob_size*/ |
| 3212 | "_pjsua.PJMedia_Codec_Param_Setting",/*tp_name*/ |
| 3213 | sizeof(PyObj_pjmedia_codec_param_setting), /*tp_basicsize*/ |
| 3214 | 0, /*tp_itemsize*/ |
| 3215 | 0, /*tp_dealloc*/ |
| 3216 | 0, /*tp_print*/ |
| 3217 | 0, /*tp_getattr*/ |
| 3218 | 0, /*tp_setattr*/ |
| 3219 | 0, /*tp_compare*/ |
| 3220 | 0, /*tp_repr*/ |
| 3221 | 0, /*tp_as_number*/ |
| 3222 | 0, /*tp_as_sequence*/ |
| 3223 | 0, /*tp_as_mapping*/ |
| 3224 | 0, /*tp_hash */ |
| 3225 | 0, /*tp_call*/ |
| 3226 | 0, /*tp_str*/ |
| 3227 | 0, /*tp_getattro*/ |
| 3228 | 0, /*tp_setattro*/ |
| 3229 | 0, /*tp_as_buffer*/ |
| 3230 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3231 | "PJMedia Codec Param Setting", /* tp_doc */ |
| 3232 | 0, /* tp_traverse */ |
| 3233 | 0, /* tp_clear */ |
| 3234 | 0, /* tp_richcompare */ |
| 3235 | 0, /* tp_weaklistoffset */ |
| 3236 | 0, /* tp_iter */ |
| 3237 | 0, /* tp_iternext */ |
| 3238 | 0, /* tp_methods */ |
| 3239 | pjmedia_codec_param_setting_members,/* tp_members */ |
| 3240 | }; |
| 3241 | |
| 3242 | ////////////////////////////////////////////////////////////////////////////// |
| 3243 | |
| 3244 | |
| 3245 | /* |
| 3246 | * PyObj_pjmedia_codec_param |
| 3247 | * PJMedia Codec Param |
| 3248 | */ |
| 3249 | typedef struct |
| 3250 | { |
| 3251 | PyObject_HEAD |
| 3252 | /* Type-specific fields go here. */ |
| 3253 | |
| 3254 | PyObj_pjmedia_codec_param_info * info; |
| 3255 | PyObj_pjmedia_codec_param_setting * setting; |
| 3256 | |
| 3257 | } PyObj_pjmedia_codec_param; |
| 3258 | |
| 3259 | /* |
| 3260 | * pjmedia_codec_param_dealloc |
| 3261 | * deletes a pjmedia_codec_param from memory |
| 3262 | */ |
| 3263 | static void pjmedia_codec_param_dealloc(PyObj_pjmedia_codec_param* self) |
| 3264 | { |
| 3265 | Py_XDECREF(self->info); |
| 3266 | Py_XDECREF(self->setting); |
| 3267 | self->ob_type->tp_free((PyObject*)self); |
| 3268 | } |
| 3269 | |
| 3270 | /* |
| 3271 | * pjmedia_codec_param_new |
| 3272 | * constructor for pjmedia_codec_param object |
| 3273 | */ |
| 3274 | static PyObject * pjmedia_codec_param_new(PyTypeObject *type, |
| 3275 | PyObject *args, |
| 3276 | PyObject *kwds) |
| 3277 | { |
| 3278 | PyObj_pjmedia_codec_param *self; |
| 3279 | |
| 3280 | PJ_UNUSED_ARG(args); |
| 3281 | PJ_UNUSED_ARG(kwds); |
| 3282 | |
| 3283 | self = (PyObj_pjmedia_codec_param *)type->tp_alloc(type, 0); |
| 3284 | if (self != NULL) { |
| 3285 | self->info = (PyObj_pjmedia_codec_param_info *) |
| 3286 | PyType_GenericNew(&PyTyp_pjmedia_codec_param_info, |
| 3287 | NULL, NULL); |
| 3288 | self->setting = (PyObj_pjmedia_codec_param_setting *) |
| 3289 | PyType_GenericNew(&PyTyp_pjmedia_codec_param_setting, |
| 3290 | NULL, NULL); |
| 3291 | } |
| 3292 | return (PyObject *)self; |
| 3293 | } |
| 3294 | |
| 3295 | /* |
| 3296 | * pjmedia_codec_param_members |
| 3297 | */ |
| 3298 | static PyMemberDef pjmedia_codec_param_members[] = |
| 3299 | { |
| 3300 | |
| 3301 | { |
| 3302 | "info", T_OBJECT_EX, |
| 3303 | offsetof(PyObj_pjmedia_codec_param, info), 0, |
| 3304 | "The 'info' part of codec param describes the capability of the codec," |
| 3305 | " and the value should NOT be changed by application." |
| 3306 | }, |
| 3307 | { |
| 3308 | "setting", T_OBJECT_EX, |
| 3309 | offsetof(PyObj_pjmedia_codec_param, setting), 0, |
| 3310 | "The 'setting' part of codec param describes various settings to be " |
| 3311 | "applied to the codec. When the codec param is retrieved from the " |
| 3312 | "codec or codec factory, the values of these will be filled by " |
| 3313 | "the capability of the codec. Any features that are supported by " |
| 3314 | "the codec (e.g. vad or plc) will be turned on, so that application " |
| 3315 | "can query which capabilities are supported by the codec. " |
| 3316 | "Application may change the settings here before instantiating " |
| 3317 | "the codec/stream." |
| 3318 | }, |
| 3319 | |
| 3320 | {NULL} /* Sentinel */ |
| 3321 | }; |
| 3322 | |
| 3323 | /* |
| 3324 | * PyTyp_pjmedia_codec_param |
| 3325 | */ |
| 3326 | static PyTypeObject PyTyp_pjmedia_codec_param = |
| 3327 | { |
| 3328 | PyObject_HEAD_INIT(NULL) |
| 3329 | 0, /*ob_size*/ |
| 3330 | "_pjsua.PJMedia_Codec_Param", /*tp_name*/ |
| 3331 | sizeof(PyObj_pjmedia_codec_param),/*tp_basicsize*/ |
| 3332 | 0, /*tp_itemsize*/ |
| 3333 | (destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/ |
| 3334 | 0, /*tp_print*/ |
| 3335 | 0, /*tp_getattr*/ |
| 3336 | 0, /*tp_setattr*/ |
| 3337 | 0, /*tp_compare*/ |
| 3338 | 0, /*tp_repr*/ |
| 3339 | 0, /*tp_as_number*/ |
| 3340 | 0, /*tp_as_sequence*/ |
| 3341 | 0, /*tp_as_mapping*/ |
| 3342 | 0, /*tp_hash */ |
| 3343 | 0, /*tp_call*/ |
| 3344 | 0, /*tp_str*/ |
| 3345 | 0, /*tp_getattro*/ |
| 3346 | 0, /*tp_setattro*/ |
| 3347 | 0, /*tp_as_buffer*/ |
| 3348 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3349 | "PJMedia Codec Param", /* tp_doc */ |
| 3350 | 0, /* tp_traverse */ |
| 3351 | 0, /* tp_clear */ |
| 3352 | 0, /* tp_richcompare */ |
| 3353 | 0, /* tp_weaklistoffset */ |
| 3354 | 0, /* tp_iter */ |
| 3355 | 0, /* tp_iternext */ |
| 3356 | 0, /* tp_methods */ |
| 3357 | pjmedia_codec_param_members, /* tp_members */ |
| 3358 | 0, /* tp_getset */ |
| 3359 | 0, /* tp_base */ |
| 3360 | 0, /* tp_dict */ |
| 3361 | 0, /* tp_descr_get */ |
| 3362 | 0, /* tp_descr_set */ |
| 3363 | 0, /* tp_dictoffset */ |
| 3364 | 0, /* tp_init */ |
| 3365 | 0, /* tp_alloc */ |
| 3366 | pjmedia_codec_param_new, /* tp_new */ |
| 3367 | |
| 3368 | }; |
| 3369 | |
| 3370 | ////////////////////////////////////////////////////////////////////////////// |
| 3371 | |
| 3372 | /* |
| 3373 | * PyObj_pjsua_call_info |
| 3374 | * Call Info |
| 3375 | */ |
| 3376 | typedef struct |
| 3377 | { |
| 3378 | PyObject_HEAD |
| 3379 | /* Type-specific fields go here. */ |
| 3380 | |
| 3381 | int id; |
| 3382 | int role; |
| 3383 | int acc_id; |
| 3384 | PyObject *local_info; |
| 3385 | PyObject *local_contact; |
| 3386 | PyObject *remote_info; |
| 3387 | PyObject *remote_contact; |
| 3388 | PyObject *call_id; |
| 3389 | int state; |
| 3390 | PyObject *state_text; |
| 3391 | int last_status; |
| 3392 | PyObject *last_status_text; |
| 3393 | int media_status; |
| 3394 | int media_dir; |
| 3395 | int conf_slot; |
| 3396 | int connect_duration; |
| 3397 | int total_duration; |
| 3398 | |
| 3399 | } PyObj_pjsua_call_info; |
| 3400 | |
| 3401 | |
| 3402 | /* |
| 3403 | * call_info_dealloc |
| 3404 | * deletes a call_info from memory |
| 3405 | */ |
| 3406 | static void call_info_dealloc(PyObj_pjsua_call_info* self) |
| 3407 | { |
| 3408 | Py_XDECREF(self->local_info); |
| 3409 | Py_XDECREF(self->local_contact); |
| 3410 | Py_XDECREF(self->remote_info); |
| 3411 | Py_XDECREF(self->remote_contact); |
| 3412 | Py_XDECREF(self->call_id); |
| 3413 | Py_XDECREF(self->state_text); |
| 3414 | Py_XDECREF(self->last_status_text); |
| 3415 | self->ob_type->tp_free((PyObject*)self); |
| 3416 | } |
| 3417 | |
| 3418 | |
| 3419 | /* |
| 3420 | * call_info_new |
| 3421 | * constructor for call_info object |
| 3422 | */ |
| 3423 | static PyObject * call_info_new(PyTypeObject *type, PyObject *args, |
| 3424 | PyObject *kwds) |
| 3425 | { |
| 3426 | PyObj_pjsua_call_info *self; |
| 3427 | |
| 3428 | PJ_UNUSED_ARG(args); |
| 3429 | PJ_UNUSED_ARG(kwds); |
| 3430 | |
| 3431 | self = (PyObj_pjsua_call_info *)type->tp_alloc(type, 0); |
| 3432 | if (self != NULL) { |
| 3433 | self->local_info = PyString_FromString(""); |
| 3434 | self->local_contact = PyString_FromString(""); |
| 3435 | self->remote_info = PyString_FromString(""); |
| 3436 | self->remote_contact = PyString_FromString(""); |
| 3437 | self->call_id = PyString_FromString(""); |
| 3438 | self->state_text = PyString_FromString(""); |
| 3439 | self->last_status_text = PyString_FromString(""); |
| 3440 | } |
| 3441 | return (PyObject *)self; |
| 3442 | } |
| 3443 | |
| 3444 | /* |
| 3445 | * call_info_members |
| 3446 | */ |
| 3447 | static PyMemberDef call_info_members[] = |
| 3448 | { |
| 3449 | { |
| 3450 | "id", T_INT, |
| 3451 | offsetof(PyObj_pjsua_call_info, id), 0, |
| 3452 | "Call identification" |
| 3453 | }, |
| 3454 | { |
| 3455 | "role", T_INT, |
| 3456 | offsetof(PyObj_pjsua_call_info, role), 0, |
| 3457 | "Initial call role (UAC == caller)" |
| 3458 | }, |
| 3459 | { |
| 3460 | "acc_id", T_INT, |
| 3461 | offsetof(PyObj_pjsua_call_info, acc_id), 0, |
| 3462 | "The account ID where this call belongs." |
| 3463 | }, |
| 3464 | { |
| 3465 | "local_info", T_OBJECT_EX, |
| 3466 | offsetof(PyObj_pjsua_call_info, local_info), 0, |
| 3467 | "Local URI" |
| 3468 | }, |
| 3469 | { |
| 3470 | "local_contact", T_OBJECT_EX, |
| 3471 | offsetof(PyObj_pjsua_call_info, local_contact), 0, |
| 3472 | "Local Contact" |
| 3473 | }, |
| 3474 | { |
| 3475 | "remote_info", T_OBJECT_EX, |
| 3476 | offsetof(PyObj_pjsua_call_info, remote_info), 0, |
| 3477 | "Remote URI" |
| 3478 | }, |
| 3479 | { |
| 3480 | "remote_contact", T_OBJECT_EX, |
| 3481 | offsetof(PyObj_pjsua_call_info, remote_contact), 0, |
| 3482 | "Remote Contact" |
| 3483 | }, |
| 3484 | { |
| 3485 | "call_id", T_OBJECT_EX, |
| 3486 | offsetof(PyObj_pjsua_call_info, call_id), 0, |
| 3487 | "Dialog Call-ID string" |
| 3488 | }, |
| 3489 | { |
| 3490 | "state", T_INT, |
| 3491 | offsetof(PyObj_pjsua_call_info, state), 0, |
| 3492 | "Call state" |
| 3493 | }, |
| 3494 | { |
| 3495 | "state_text", T_OBJECT_EX, |
| 3496 | offsetof(PyObj_pjsua_call_info, state_text), 0, |
| 3497 | "Text describing the state " |
| 3498 | }, |
| 3499 | { |
| 3500 | "last_status", T_INT, |
| 3501 | offsetof(PyObj_pjsua_call_info, last_status), 0, |
| 3502 | "Last status code heard, which can be used as cause code" |
| 3503 | }, |
| 3504 | { |
| 3505 | "last_status_text", T_OBJECT_EX, |
| 3506 | offsetof(PyObj_pjsua_call_info, last_status_text), 0, |
| 3507 | "The reason phrase describing the status." |
| 3508 | }, |
| 3509 | { |
| 3510 | "media_status", T_INT, |
| 3511 | offsetof(PyObj_pjsua_call_info, media_status), 0, |
| 3512 | "Call media status." |
| 3513 | }, |
| 3514 | { |
| 3515 | "media_dir", T_INT, |
| 3516 | offsetof(PyObj_pjsua_call_info, media_dir), 0, |
| 3517 | "Media direction" |
| 3518 | }, |
| 3519 | { |
| 3520 | "conf_slot", T_INT, |
| 3521 | offsetof(PyObj_pjsua_call_info, conf_slot), 0, |
| 3522 | "The conference port number for the call" |
| 3523 | }, |
| 3524 | { |
| 3525 | "connect_duration", T_INT, |
| 3526 | offsetof(PyObj_pjsua_call_info, connect_duration), 0, |
| 3527 | "Up-to-date call connected duration(zero when call is not established)" |
| 3528 | }, |
| 3529 | { |
| 3530 | "total_duration", T_INT, |
| 3531 | offsetof(PyObj_pjsua_call_info, total_duration), 0, |
| 3532 | "Total call duration, including set-up time" |
| 3533 | }, |
| 3534 | |
| 3535 | {NULL} /* Sentinel */ |
| 3536 | }; |
| 3537 | |
| 3538 | |
| 3539 | |
| 3540 | |
| 3541 | /* |
| 3542 | * PyTyp_pjsua_call_info |
| 3543 | */ |
| 3544 | static PyTypeObject PyTyp_pjsua_call_info = |
| 3545 | { |
| 3546 | PyObject_HEAD_INIT(NULL) |
| 3547 | 0, /*ob_size*/ |
| 3548 | "_pjsua.Call_Info", /*tp_name*/ |
| 3549 | sizeof(PyObj_pjsua_call_info), /*tp_basicsize*/ |
| 3550 | 0, /*tp_itemsize*/ |
| 3551 | (destructor)call_info_dealloc, /*tp_dealloc*/ |
| 3552 | 0, /*tp_print*/ |
| 3553 | 0, /*tp_getattr*/ |
| 3554 | 0, /*tp_setattr*/ |
| 3555 | 0, /*tp_compare*/ |
| 3556 | 0, /*tp_repr*/ |
| 3557 | 0, /*tp_as_number*/ |
| 3558 | 0, /*tp_as_sequence*/ |
| 3559 | 0, /*tp_as_mapping*/ |
| 3560 | 0, /*tp_hash */ |
| 3561 | 0, /*tp_call*/ |
| 3562 | 0, /*tp_str*/ |
| 3563 | 0, /*tp_getattro*/ |
| 3564 | 0, /*tp_setattro*/ |
| 3565 | 0, /*tp_as_buffer*/ |
| 3566 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3567 | "Call Info", /* tp_doc */ |
| 3568 | 0, /* tp_traverse */ |
| 3569 | 0, /* tp_clear */ |
| 3570 | 0, /* tp_richcompare */ |
| 3571 | 0, /* tp_weaklistoffset */ |
| 3572 | 0, /* tp_iter */ |
| 3573 | 0, /* tp_iternext */ |
| 3574 | 0, /* tp_methods */ |
| 3575 | call_info_members, /* tp_members */ |
| 3576 | 0, /* tp_getset */ |
| 3577 | 0, /* tp_base */ |
| 3578 | 0, /* tp_dict */ |
| 3579 | 0, /* tp_descr_get */ |
| 3580 | 0, /* tp_descr_set */ |
| 3581 | 0, /* tp_dictoffset */ |
| 3582 | 0, /* tp_init */ |
| 3583 | 0, /* tp_alloc */ |
| 3584 | call_info_new, /* tp_new */ |
| 3585 | |
| 3586 | }; |
| 3587 | |
| 3588 | |
| 3589 | ////////////////////////////////////////////////////////////////////////////// |
| 3590 | /* |
| 3591 | * PyObj_pjsip_rx_data |
| 3592 | */ |
| 3593 | typedef struct |
| 3594 | { |
| 3595 | PyObject_HEAD |
| 3596 | |
| 3597 | /* Type-specific fields go here. */ |
| 3598 | PyObject *msg_info_buffer; // string |
| 3599 | PyObject *msg_info_info; // string |
| 3600 | |
| 3601 | } PyObj_pjsip_rx_data; |
| 3602 | |
| 3603 | /* |
| 3604 | * PyObj_pjsip_rx_data_dealloc |
| 3605 | * deletes rx_data from memory |
| 3606 | */ |
| 3607 | static void PyObj_pjsip_rx_data_delete(PyObj_pjsip_rx_data* self) |
| 3608 | { |
| 3609 | Py_XDECREF(self->msg_info_buffer); |
| 3610 | Py_XDECREF(self->msg_info_info); |
| 3611 | |
| 3612 | self->ob_type->tp_free((PyObject*)self); |
| 3613 | } |
| 3614 | |
| 3615 | |
| 3616 | static void PyObj_pjsip_rx_data_import(PyObj_pjsip_rx_data *obj, pjsip_rx_data *rx_data) |
| 3617 | { |
| 3618 | Py_XDECREF(obj->msg_info_buffer); |
| 3619 | obj->msg_info_buffer = PyString_FromString(rx_data->msg_info.msg_buf); |
| 3620 | Py_XDECREF(obj->msg_info_info); |
| 3621 | obj->msg_info_info = PyString_FromString(pjsip_rx_data_get_info(rx_data)); |
| 3622 | } |
| 3623 | |
| 3624 | |
| 3625 | /* |
| 3626 | * PyObj_pjsip_rx_data_new |
| 3627 | * constructor for PyObj_pjsip_rx_data object |
| 3628 | */ |
| 3629 | static PyObject * PyObj_pjsip_rx_data_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
| 3630 | { |
| 3631 | PyObj_pjsip_rx_data *self; |
| 3632 | |
| 3633 | PJ_UNUSED_ARG(args); |
| 3634 | PJ_UNUSED_ARG(kwds); |
| 3635 | |
| 3636 | self = (PyObj_pjsip_rx_data *)type->tp_alloc(type, 0); |
| 3637 | if (self != NULL) { |
| 3638 | self->msg_info_buffer = PyString_FromString(""); |
| 3639 | self->msg_info_info = PyString_FromString(""); |
| 3640 | } |
| 3641 | |
| 3642 | return (PyObject *)self; |
| 3643 | } |
| 3644 | |
| 3645 | |
| 3646 | |
| 3647 | /* |
| 3648 | * PyObj_pjsip_rx_data_members |
| 3649 | */ |
| 3650 | static PyMemberDef PyObj_pjsip_rx_data_members[] = |
| 3651 | { |
| 3652 | { |
| 3653 | "msg_info_buffer", T_OBJECT_EX, |
| 3654 | offsetof(PyObj_pjsip_rx_data, msg_info_buffer), 0, |
| 3655 | "Entire SIP-Message" |
| 3656 | }, |
| 3657 | { |
| 3658 | "msg_info_info", T_OBJECT_EX, |
| 3659 | offsetof(PyObj_pjsip_rx_data, msg_info_info), 0, |
| 3660 | "Message Info" |
| 3661 | }, |
| 3662 | |
| 3663 | {NULL} /* Sentinel */ |
| 3664 | }; |
| 3665 | |
| 3666 | /* |
| 3667 | * PyTyp_pjsip_rx_data |
| 3668 | */ |
| 3669 | static PyTypeObject PyTyp_pjsip_rx_data = |
| 3670 | { |
| 3671 | PyObject_HEAD_INIT(NULL) |
| 3672 | 0, /*ob_size*/ |
| 3673 | "_pjsua.Pjsip_Rx_Data", /*tp_name*/ |
| 3674 | sizeof(PyObj_pjsip_rx_data), /*tp_basicsize*/ |
| 3675 | 0, /*tp_itemsize*/ |
| 3676 | (destructor)PyObj_pjsip_rx_data_delete,/*tp_dealloc*/ |
| 3677 | 0, /*tp_print*/ |
| 3678 | 0, /*tp_getattr*/ |
| 3679 | 0, /*tp_setattr*/ |
| 3680 | 0, /*tp_compare*/ |
| 3681 | 0, /*tp_repr*/ |
| 3682 | 0, /*tp_as_number*/ |
| 3683 | 0, /*tp_as_sequence*/ |
| 3684 | 0, /*tp_as_mapping*/ |
| 3685 | 0, /*tp_hash */ |
| 3686 | 0, /*tp_call*/ |
| 3687 | 0, /*tp_str*/ |
| 3688 | 0, /*tp_getattro*/ |
| 3689 | 0, /*tp_setattro*/ |
| 3690 | 0, /*tp_as_buffer*/ |
| 3691 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3692 | "PJSIP request data information", /* tp_doc */ |
| 3693 | 0, /* tp_traverse */ |
| 3694 | 0, /* tp_clear */ |
| 3695 | 0, /* tp_richcompare */ |
| 3696 | 0, /* tp_weaklistoffset */ |
| 3697 | 0, /* tp_iter */ |
| 3698 | 0, /* tp_iternext */ |
| 3699 | 0, /* tp_methods */ |
| 3700 | PyObj_pjsip_rx_data_members, /* tp_members */ |
| 3701 | 0, /* tp_getset */ |
| 3702 | 0, /* tp_base */ |
| 3703 | 0, /* tp_dict */ |
| 3704 | 0, /* tp_descr_get */ |
| 3705 | 0, /* tp_descr_set */ |
| 3706 | 0, /* tp_dictoffset */ |
| 3707 | 0, /* tp_init */ |
| 3708 | 0, /* tp_alloc */ |
| 3709 | PyObj_pjsip_rx_data_new, /* tp_new */ |
| 3710 | |
| 3711 | }; |
| 3712 | |
| 3713 | |
| 3714 | |
| 3715 | ////////////////////////////////////////////////////////////////////////////// |
| 3716 | |
| 3717 | #endif /* __PY_PJSUA_H__ */ |
| 3718 | |