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