Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 19 | #include <Python.h> |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 20 | #include "structmember.h" |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 21 | #include <pjsua-lib/pjsua.h> |
| 22 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 23 | #define THIS_FILE "main.c" |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 24 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 25 | /* LIB BASE */ |
| 26 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 27 | static PyObject* obj_reconfigure_logging; |
| 28 | static PyObject* obj_logging_init; |
| 29 | |
| 30 | /* |
| 31 | * cb_reconfigure_logging |
| 32 | * declares method for reconfiguring logging process for callback struct |
| 33 | */ |
| 34 | static void cb_reconfigure_logging(int level, const char *data, pj_size_t len) |
| 35 | { |
| 36 | if (PyCallable_Check(obj_reconfigure_logging)) |
| 37 | { |
| 38 | PyObject_CallFunctionObjArgs( |
| 39 | obj_reconfigure_logging, Py_BuildValue("i",level), |
| 40 | PyString_FromString(data), Py_BuildValue("i",len), NULL |
| 41 | ); |
| 42 | } |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 45 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 46 | /* |
| 47 | * cb_logging_init |
| 48 | * declares method logging_init for callback struct |
| 49 | */ |
| 50 | static void cb_logging_init(int level, const char *data, pj_size_t len) |
| 51 | { |
| 52 | if (PyCallable_Check(obj_logging_init)) |
| 53 | { |
| 54 | //PyObject_CallFunction(obj_logging_init,"iSi",level,data,len); |
| 55 | //printf("level : %d data : %s len : %d\n",level, data, len); |
| 56 | PyObject_CallFunctionObjArgs( |
| 57 | obj_logging_init, Py_BuildValue("i",level), |
| 58 | PyString_FromString(data), Py_BuildValue("i",len), NULL |
| 59 | ); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | |
| 64 | /* |
| 65 | * pjsip_event_Object |
| 66 | * C/python typewrapper for event struct |
| 67 | */ |
| 68 | typedef struct |
| 69 | { |
| 70 | PyObject_HEAD |
| 71 | /* Type-specific fields go here. */ |
| 72 | pjsip_event * event; |
| 73 | } pjsip_event_Object; |
| 74 | |
| 75 | |
| 76 | /* |
| 77 | * pjsip_event_Type |
| 78 | * event struct signatures |
| 79 | */ |
| 80 | static PyTypeObject pjsip_event_Type = |
| 81 | { |
| 82 | PyObject_HEAD_INIT(NULL) |
| 83 | 0, /*ob_size*/ |
| 84 | "py_pjsua.PJSIP_Event", /*tp_name*/ |
| 85 | sizeof(pjsip_event_Object), /*tp_basicsize*/ |
| 86 | 0, /*tp_itemsize*/ |
| 87 | 0, /*tp_dealloc*/ |
| 88 | 0, /*tp_print*/ |
| 89 | 0, /*tp_getattr*/ |
| 90 | 0, /*tp_setattr*/ |
| 91 | 0, /*tp_compare*/ |
| 92 | 0, /*tp_repr*/ |
| 93 | 0, /*tp_as_number*/ |
| 94 | 0, /*tp_as_sequence*/ |
| 95 | 0, /*tp_as_mapping*/ |
| 96 | 0, /*tp_hash */ |
| 97 | 0, /*tp_call*/ |
| 98 | 0, /*tp_str*/ |
| 99 | 0, /*tp_getattro*/ |
| 100 | 0, /*tp_setattro*/ |
| 101 | 0, /*tp_as_buffer*/ |
| 102 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 103 | "pjsip_event objects", /*tp_doc */ |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 107 | /* |
| 108 | * pjsip_rx_data_Object |
| 109 | * C/python typewrapper for RX data struct |
| 110 | */ |
| 111 | typedef struct |
| 112 | { |
| 113 | PyObject_HEAD |
| 114 | /* Type-specific fields go here. */ |
| 115 | pjsip_rx_data * rdata; |
| 116 | } pjsip_rx_data_Object; |
| 117 | |
| 118 | |
| 119 | /* |
| 120 | * pjsip_rx_data_Type |
| 121 | */ |
| 122 | static PyTypeObject pjsip_rx_data_Type = |
| 123 | { |
| 124 | PyObject_HEAD_INIT(NULL) |
| 125 | 0, /*ob_size*/ |
| 126 | "py_pjsua.PJSIP_RX_Data", /*tp_name*/ |
| 127 | sizeof(pjsip_rx_data_Object), /*tp_basicsize*/ |
| 128 | 0, /*tp_itemsize*/ |
| 129 | 0, /*tp_dealloc*/ |
| 130 | 0, /*tp_print*/ |
| 131 | 0, /*tp_getattr*/ |
| 132 | 0, /*tp_setattr*/ |
| 133 | 0, /*tp_compare*/ |
| 134 | 0, /*tp_repr*/ |
| 135 | 0, /*tp_as_number*/ |
| 136 | 0, /*tp_as_sequence*/ |
| 137 | 0, /*tp_as_mapping*/ |
| 138 | 0, /*tp_hash */ |
| 139 | 0, /*tp_call*/ |
| 140 | 0, /*tp_str*/ |
| 141 | 0, /*tp_getattro*/ |
| 142 | 0, /*tp_setattro*/ |
| 143 | 0, /*tp_as_buffer*/ |
| 144 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 145 | "pjsip_rx_data objects", /*tp_doc*/ |
| 146 | }; |
| 147 | |
| 148 | |
| 149 | /* |
| 150 | * callback_Object |
| 151 | * C/python typewrapper for callback struct |
| 152 | */ |
| 153 | typedef struct |
| 154 | { |
| 155 | PyObject_HEAD |
| 156 | /* Type-specific fields go here. */ |
| 157 | PyObject * on_call_state; |
| 158 | PyObject * on_incoming_call; |
| 159 | PyObject * on_call_media_state; |
| 160 | PyObject * on_call_transfer_request; |
| 161 | PyObject * on_call_transfer_status; |
| 162 | PyObject * on_call_replace_request; |
| 163 | PyObject * on_call_replaced; |
| 164 | PyObject * on_reg_state; |
| 165 | PyObject * on_buddy_state; |
| 166 | PyObject * on_pager; |
| 167 | PyObject * on_pager_status; |
| 168 | PyObject * on_typing; |
| 169 | |
| 170 | } callback_Object; |
| 171 | |
| 172 | |
| 173 | /* |
| 174 | * The global callback object. |
| 175 | */ |
| 176 | static callback_Object * obj_callback; |
| 177 | |
| 178 | |
| 179 | /* |
| 180 | * cb_on_call_state |
| 181 | * declares method on_call_state for callback struct |
| 182 | */ |
| 183 | static void cb_on_call_state(pjsua_call_id call_id, pjsip_event *e) |
| 184 | { |
| 185 | if (PyCallable_Check(obj_callback->on_call_state)) |
| 186 | { |
| 187 | pjsip_event_Object * obj = |
| 188 | (pjsip_event_Object *)PyType_GenericNew(&pjsip_event_Type, |
| 189 | NULL, NULL); |
| 190 | obj->event = e; |
| 191 | |
| 192 | PyObject_CallFunctionObjArgs( |
| 193 | obj_callback->on_call_state,Py_BuildValue("i",call_id),obj,NULL |
| 194 | ); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | |
| 199 | /* |
| 200 | * cb_on_incoming_call |
| 201 | * declares method on_incoming_call for callback struct |
| 202 | */ |
| 203 | static void cb_on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, |
| 204 | pjsip_rx_data *rdata) |
| 205 | { |
| 206 | if (PyCallable_Check(obj_callback->on_incoming_call)) |
| 207 | { |
| 208 | pjsip_rx_data_Object * obj = (pjsip_rx_data_Object *) |
| 209 | PyType_GenericNew(&pjsip_rx_data_Type, |
| 210 | NULL, NULL); |
| 211 | obj->rdata = rdata; |
| 212 | |
| 213 | PyObject_CallFunctionObjArgs( |
| 214 | obj_callback->on_incoming_call, |
| 215 | Py_BuildValue("i",acc_id), |
| 216 | Py_BuildValue("i",call_id), |
| 217 | obj, |
| 218 | NULL |
| 219 | ); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | |
| 224 | /* |
| 225 | * cb_on_call_media_state |
| 226 | * declares method on_call_media_state for callback struct |
| 227 | */ |
| 228 | static void cb_on_call_media_state(pjsua_call_id call_id) |
| 229 | { |
| 230 | if (PyCallable_Check(obj_callback->on_call_media_state)) |
| 231 | { |
| 232 | PyObject_CallFunction(obj_callback->on_call_media_state,"i",call_id); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | |
| 237 | /* |
| 238 | * Notify application on call being transfered. |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 239 | * !modified @061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 240 | */ |
| 241 | static void cb_on_call_transfer_request(pjsua_call_id call_id, |
| 242 | const pj_str_t *dst, |
| 243 | pjsip_status_code *code) |
| 244 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 245 | PyObject * ret; |
| 246 | int cd; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 247 | if (PyCallable_Check(obj_callback->on_call_transfer_request)) |
| 248 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 249 | ret = PyObject_CallFunctionObjArgs( |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 250 | obj_callback->on_call_transfer_request, |
| 251 | Py_BuildValue("i",call_id), |
| 252 | PyString_FromStringAndSize(dst->ptr, dst->slen), |
| 253 | Py_BuildValue("i",*code), |
| 254 | NULL |
| 255 | ); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 256 | if (ret != NULL) { |
| 257 | if (ret != Py_None) { |
| 258 | if (PyArg_Parse(ret,"i",&cd)) { |
| 259 | *code = cd; |
| 260 | } |
| 261 | } |
| 262 | } |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 263 | } |
| 264 | } |
| 265 | |
| 266 | |
| 267 | /* |
| 268 | * Notify application of the status of previously sent call |
| 269 | * transfer request. Application can monitor the status of the |
| 270 | * call transfer request, for example to decide whether to |
| 271 | * terminate existing call. |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 272 | * !modified @061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 273 | */ |
| 274 | static void cb_on_call_transfer_status( pjsua_call_id call_id, |
| 275 | int status_code, |
| 276 | const pj_str_t *status_text, |
| 277 | pj_bool_t final, |
| 278 | pj_bool_t *p_cont) |
| 279 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 280 | PyObject * ret; |
| 281 | int cnt; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 282 | if (PyCallable_Check(obj_callback->on_call_transfer_status)) |
| 283 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 284 | ret = PyObject_CallFunctionObjArgs( |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 285 | obj_callback->on_call_transfer_status, |
| 286 | Py_BuildValue("i",call_id), |
| 287 | Py_BuildValue("i",status_code), |
| 288 | PyString_FromStringAndSize(status_text->ptr, status_text->slen), |
| 289 | Py_BuildValue("i",final), |
| 290 | Py_BuildValue("i",*p_cont), |
| 291 | NULL |
| 292 | ); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 293 | if (ret != NULL) { |
| 294 | if (ret != Py_None) { |
| 295 | if (PyArg_Parse(ret,"i",&cnt)) { |
| 296 | *p_cont = cnt; |
| 297 | } |
| 298 | } |
| 299 | } |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | |
| 303 | |
| 304 | /* |
| 305 | * Notify application about incoming INVITE with Replaces header. |
| 306 | * Application may reject the request by setting non-2xx code. |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 307 | * !modified @061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 308 | */ |
| 309 | static void cb_on_call_replace_request( pjsua_call_id call_id, |
| 310 | pjsip_rx_data *rdata, |
| 311 | int *st_code, |
| 312 | pj_str_t *st_text) |
| 313 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 314 | PyObject * ret; |
| 315 | PyObject * txt; |
| 316 | int cd; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 317 | if (PyCallable_Check(obj_callback->on_call_replace_request)) |
| 318 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 319 | pjsip_rx_data_Object * obj = (pjsip_rx_data_Object *) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 320 | PyType_GenericNew(&pjsip_rx_data_Type, |
| 321 | NULL, NULL); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 322 | obj->rdata = rdata; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 323 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 324 | ret = PyObject_CallFunctionObjArgs( |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 325 | obj_callback->on_call_replace_request, |
| 326 | Py_BuildValue("i",call_id), |
| 327 | obj, |
| 328 | Py_BuildValue("i",*st_code), |
| 329 | PyString_FromStringAndSize(st_text->ptr, st_text->slen), |
| 330 | NULL |
| 331 | ); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 332 | if (ret != NULL) { |
| 333 | if (ret != Py_None) { |
| 334 | if (PyArg_ParseTuple(ret,"iO",&cd, &txt)) { |
| 335 | *st_code = cd; |
| 336 | st_text->ptr = PyString_AsString(txt); |
| 337 | st_text->slen = strlen(PyString_AsString(txt)); |
| 338 | } |
| 339 | } |
| 340 | } |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | |
| 344 | |
| 345 | /* |
| 346 | * Notify application that an existing call has been replaced with |
| 347 | * a new call. This happens when PJSUA-API receives incoming INVITE |
| 348 | * request with Replaces header. |
| 349 | */ |
| 350 | static void cb_on_call_replaced(pjsua_call_id old_call_id, |
| 351 | pjsua_call_id new_call_id) |
| 352 | { |
| 353 | if (PyCallable_Check(obj_callback->on_call_replaced)) |
| 354 | { |
| 355 | PyObject_CallFunctionObjArgs( |
| 356 | obj_callback->on_call_replaced, |
| 357 | Py_BuildValue("i",old_call_id), |
| 358 | Py_BuildValue("i",old_call_id), |
| 359 | NULL |
| 360 | ); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | |
| 365 | /* |
| 366 | * cb_on_reg_state |
| 367 | * declares method on_reg_state for callback struct |
| 368 | */ |
| 369 | static void cb_on_reg_state(pjsua_acc_id acc_id) |
| 370 | { |
| 371 | if (PyCallable_Check(obj_callback->on_reg_state)) |
| 372 | { |
| 373 | PyObject_CallFunction(obj_callback->on_reg_state,"i",acc_id); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | |
| 378 | /* |
| 379 | * cb_on_buddy_state |
| 380 | * declares method on_buddy state for callback struct |
| 381 | */ |
| 382 | static void cb_on_buddy_state(pjsua_buddy_id buddy_id) |
| 383 | { |
| 384 | if (PyCallable_Check(obj_callback->on_buddy_state)) |
| 385 | { |
| 386 | PyObject_CallFunction(obj_callback->on_buddy_state,"i",buddy_id); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | /* |
| 391 | * cb_on_pager |
| 392 | * * declares method on_pager for callback struct |
| 393 | */ |
| 394 | static void cb_on_pager(pjsua_call_id call_id, const pj_str_t *from, |
| 395 | const pj_str_t *to, const pj_str_t *contact, |
| 396 | const pj_str_t *mime_type, const pj_str_t *body) |
| 397 | { |
| 398 | if (PyCallable_Check(obj_callback->on_pager)) |
| 399 | { |
| 400 | PyObject_CallFunctionObjArgs( |
| 401 | obj_callback->on_pager,Py_BuildValue("i",call_id), |
| 402 | PyString_FromStringAndSize(from->ptr, from->slen), |
| 403 | PyString_FromStringAndSize(to->ptr, to->slen), |
| 404 | PyString_FromStringAndSize(contact->ptr, contact->slen), |
| 405 | PyString_FromStringAndSize(mime_type->ptr, mime_type->slen), |
| 406 | PyString_FromStringAndSize(body->ptr, body->slen), NULL |
| 407 | ); |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | |
| 412 | /* |
| 413 | * cb_on_pager_status |
| 414 | * declares method on_pager_status for callback struct |
| 415 | */ |
| 416 | static void cb_on_pager_status(pjsua_call_id call_id, const pj_str_t *to, |
| 417 | const pj_str_t *body, void *user_data, |
| 418 | pjsip_status_code status, |
| 419 | const pj_str_t *reason) |
| 420 | { |
| 421 | PyObject * obj = PyType_GenericNew(user_data, NULL, NULL); |
| 422 | if (PyCallable_Check(obj_callback->on_pager)) |
| 423 | { |
| 424 | PyObject_CallFunctionObjArgs( |
| 425 | obj_callback->on_pager,Py_BuildValue("i",call_id), |
| 426 | PyString_FromStringAndSize(to->ptr, to->slen), |
| 427 | PyString_FromStringAndSize(body->ptr, body->slen),obj, |
| 428 | Py_BuildValue("i",status),PyString_FromStringAndSize(reason->ptr, |
| 429 | reason->slen),NULL |
| 430 | ); |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | |
| 435 | /* |
| 436 | * cb_on_typing |
| 437 | * declares method on_typing for callback struct |
| 438 | */ |
| 439 | static void cb_on_typing(pjsua_call_id call_id, const pj_str_t *from, |
| 440 | const pj_str_t *to, const pj_str_t *contact, |
| 441 | pj_bool_t is_typing) |
| 442 | { |
| 443 | if (PyCallable_Check(obj_callback->on_typing)) |
| 444 | { |
| 445 | PyObject_CallFunctionObjArgs( |
| 446 | obj_callback->on_typing,Py_BuildValue("i",call_id), |
| 447 | PyString_FromStringAndSize(from->ptr, from->slen), |
| 448 | PyString_FromStringAndSize(to->ptr, to->slen), |
| 449 | PyString_FromStringAndSize(contact->ptr, contact->slen), |
| 450 | Py_BuildValue("i",is_typing),NULL |
| 451 | ); |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | |
| 456 | /* |
| 457 | * callback_dealloc |
| 458 | * destructor function for callback struct |
| 459 | */ |
| 460 | static void callback_dealloc(callback_Object* self) |
| 461 | { |
| 462 | Py_XDECREF(self->on_call_state); |
| 463 | Py_XDECREF(self->on_incoming_call); |
| 464 | Py_XDECREF(self->on_call_media_state); |
| 465 | Py_XDECREF(self->on_call_transfer_request); |
| 466 | Py_XDECREF(self->on_call_transfer_status); |
| 467 | Py_XDECREF(self->on_call_replace_request); |
| 468 | Py_XDECREF(self->on_call_replaced); |
| 469 | Py_XDECREF(self->on_reg_state); |
| 470 | Py_XDECREF(self->on_buddy_state); |
| 471 | Py_XDECREF(self->on_pager); |
| 472 | Py_XDECREF(self->on_pager_status); |
| 473 | Py_XDECREF(self->on_typing); |
| 474 | self->ob_type->tp_free((PyObject*)self); |
| 475 | } |
| 476 | |
| 477 | |
| 478 | /* |
| 479 | * callback_new |
| 480 | * * declares constructor for callback struct |
| 481 | */ |
| 482 | static PyObject * callback_new(PyTypeObject *type, PyObject *args, |
| 483 | PyObject *kwds) |
| 484 | { |
| 485 | callback_Object *self; |
| 486 | |
| 487 | self = (callback_Object *)type->tp_alloc(type, 0); |
| 488 | if (self != NULL) |
| 489 | { |
| 490 | Py_INCREF(Py_None); |
| 491 | self->on_call_state = Py_None; |
| 492 | if (self->on_call_state == NULL) |
| 493 | { |
| 494 | Py_DECREF(Py_None); |
| 495 | return NULL; |
| 496 | } |
| 497 | Py_INCREF(Py_None); |
| 498 | self->on_incoming_call = Py_None; |
| 499 | if (self->on_incoming_call == NULL) |
| 500 | { |
| 501 | Py_DECREF(Py_None); |
| 502 | return NULL; |
| 503 | } |
| 504 | Py_INCREF(Py_None); |
| 505 | self->on_call_media_state = Py_None; |
| 506 | if (self->on_call_media_state == NULL) |
| 507 | { |
| 508 | Py_DECREF(Py_None); |
| 509 | return NULL; |
| 510 | } |
| 511 | Py_INCREF(Py_None); |
| 512 | self->on_call_transfer_request = Py_None; |
| 513 | if (self->on_call_transfer_request == NULL) |
| 514 | { |
| 515 | Py_DECREF(Py_None); |
| 516 | return NULL; |
| 517 | } |
| 518 | Py_INCREF(Py_None); |
| 519 | self->on_call_transfer_status = Py_None; |
| 520 | if (self->on_call_transfer_status == NULL) |
| 521 | { |
| 522 | Py_DECREF(Py_None); |
| 523 | return NULL; |
| 524 | } |
| 525 | Py_INCREF(Py_None); |
| 526 | self->on_call_replace_request = Py_None; |
| 527 | if (self->on_call_replace_request == NULL) |
| 528 | { |
| 529 | Py_DECREF(Py_None); |
| 530 | return NULL; |
| 531 | } |
| 532 | Py_INCREF(Py_None); |
| 533 | self->on_call_replaced = Py_None; |
| 534 | if (self->on_call_replaced == NULL) |
| 535 | { |
| 536 | Py_DECREF(Py_None); |
| 537 | return NULL; |
| 538 | } |
| 539 | Py_INCREF(Py_None); |
| 540 | self->on_reg_state = Py_None; |
| 541 | if (self->on_reg_state == NULL) |
| 542 | { |
| 543 | Py_DECREF(Py_None); |
| 544 | return NULL; |
| 545 | } |
| 546 | Py_INCREF(Py_None); |
| 547 | self->on_buddy_state = Py_None; |
| 548 | if (self->on_buddy_state == NULL) |
| 549 | { |
| 550 | Py_DECREF(Py_None); |
| 551 | return NULL; |
| 552 | } |
| 553 | Py_INCREF(Py_None); |
| 554 | self->on_pager = Py_None; |
| 555 | if (self->on_pager == NULL) |
| 556 | { |
| 557 | Py_DECREF(Py_None); |
| 558 | return NULL; |
| 559 | } |
| 560 | Py_INCREF(Py_None); |
| 561 | self->on_pager_status = Py_None; |
| 562 | if (self->on_pager_status == NULL) |
| 563 | { |
| 564 | Py_DECREF(Py_None); |
| 565 | return NULL; |
| 566 | } |
| 567 | Py_INCREF(Py_None); |
| 568 | self->on_typing = Py_None; |
| 569 | if (self->on_typing == NULL) |
| 570 | { |
| 571 | Py_DECREF(Py_None); |
| 572 | return NULL; |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | return (PyObject *)self; |
| 577 | } |
| 578 | |
| 579 | |
| 580 | /* |
| 581 | * callback_members |
| 582 | * declares available functions for callback object |
| 583 | */ |
| 584 | static PyMemberDef callback_members[] = |
| 585 | { |
| 586 | { |
| 587 | "on_call_state", T_OBJECT_EX, offsetof(callback_Object, on_call_state), |
| 588 | 0, "Notify application when invite state has changed. Application may " |
| 589 | "then query the call info to get the detail call states." |
| 590 | }, |
| 591 | { |
| 592 | "on_incoming_call", T_OBJECT_EX, |
| 593 | offsetof(callback_Object, on_incoming_call), 0, |
| 594 | "Notify application on incoming call." |
| 595 | }, |
| 596 | { |
| 597 | "on_call_media__state", T_OBJECT_EX, |
| 598 | offsetof(callback_Object, on_call_media_state), 0, |
| 599 | "Notify application when media state in the call has changed. Normal " |
| 600 | "application would need to implement this callback, e.g. to connect " |
| 601 | "the call's media to sound device." |
| 602 | }, |
| 603 | { |
| 604 | "on_call_transfer_request", T_OBJECT_EX, |
| 605 | offsetof(callback_Object, on_call_transfer_request), 0, |
| 606 | "Notify application on call being transfered. " |
| 607 | "Application can decide to accept/reject transfer request " |
| 608 | "by setting the code (default is 200). When this callback " |
| 609 | "is not defined, the default behavior is to accept the " |
| 610 | "transfer." |
| 611 | }, |
| 612 | { |
| 613 | "on_call_transfer_status", T_OBJECT_EX, |
| 614 | offsetof(callback_Object, on_call_transfer_status), 0, |
| 615 | "Notify application of the status of previously sent call " |
| 616 | "transfer request. Application can monitor the status of the " |
| 617 | "call transfer request, for example to decide whether to " |
| 618 | "terminate existing call." |
| 619 | }, |
| 620 | { |
| 621 | "on_call_replace_request", T_OBJECT_EX, |
| 622 | offsetof(callback_Object, on_call_replace_request), 0, |
| 623 | "Notify application about incoming INVITE with Replaces header. " |
| 624 | "Application may reject the request by setting non-2xx code." |
| 625 | }, |
| 626 | { |
| 627 | "on_call_replaced", T_OBJECT_EX, |
| 628 | offsetof(callback_Object, on_call_replaced), 0, |
| 629 | "Notify application that an existing call has been replaced with " |
| 630 | "a new call. This happens when PJSUA-API receives incoming INVITE " |
| 631 | "request with Replaces header." |
| 632 | " " |
| 633 | "After this callback is called, normally PJSUA-API will disconnect " |
| 634 | "old_call_id and establish new_call_id." |
| 635 | }, |
| 636 | { |
| 637 | "on_reg_state", T_OBJECT_EX, |
| 638 | offsetof(callback_Object, on_reg_state), 0, |
| 639 | "Notify application when registration status has changed. Application " |
| 640 | "may then query the account info to get the registration details." |
| 641 | }, |
| 642 | { |
| 643 | "on_buddy_state", T_OBJECT_EX, |
| 644 | offsetof(callback_Object, on_buddy_state), 0, |
| 645 | "Notify application when the buddy state has changed. Application may " |
| 646 | "then query the buddy into to get the details." |
| 647 | }, |
| 648 | { |
| 649 | "on_pager", T_OBJECT_EX, offsetof(callback_Object, on_pager), 0, |
| 650 | "Notify application on incoming pager (i.e. MESSAGE request). " |
| 651 | "Argument call_id will be -1 if MESSAGE request is not related to an " |
| 652 | "existing call." |
| 653 | }, |
| 654 | { |
| 655 | "on_pager_status", T_OBJECT_EX, |
| 656 | offsetof(callback_Object, on_pager_status), 0, |
| 657 | "Notify application about the delivery status of outgoing pager " |
| 658 | "request." |
| 659 | }, |
| 660 | { |
| 661 | "on_typing", T_OBJECT_EX, offsetof(callback_Object, on_typing), 0, |
| 662 | "Notify application about typing indication." |
| 663 | }, |
| 664 | {NULL} /* Sentinel */ |
| 665 | }; |
| 666 | |
| 667 | |
| 668 | /* |
| 669 | * callback_Type |
| 670 | * callback class definition |
| 671 | */ |
| 672 | static PyTypeObject callback_Type = |
| 673 | { |
| 674 | PyObject_HEAD_INIT(NULL) |
| 675 | 0, /*ob_size*/ |
| 676 | "py_pjsua.Callback", /*tp_name*/ |
| 677 | sizeof(callback_Object), /*tp_basicsize*/ |
| 678 | 0, /*tp_itemsize*/ |
| 679 | (destructor)callback_dealloc, /*tp_dealloc*/ |
| 680 | 0, /*tp_print*/ |
| 681 | 0, /*tp_getattr*/ |
| 682 | 0, /*tp_setattr*/ |
| 683 | 0, /*tp_compare*/ |
| 684 | 0, /*tp_repr*/ |
| 685 | 0, /*tp_as_number*/ |
| 686 | 0, /*tp_as_sequence*/ |
| 687 | 0, /*tp_as_mapping*/ |
| 688 | 0, /*tp_hash */ |
| 689 | 0, /*tp_call*/ |
| 690 | 0, /*tp_str*/ |
| 691 | 0, /*tp_getattro*/ |
| 692 | 0, /*tp_setattro*/ |
| 693 | 0, /*tp_as_buffer*/ |
| 694 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 695 | "Callback objects", /* tp_doc */ |
| 696 | 0, /* tp_traverse */ |
| 697 | 0, /* tp_clear */ |
| 698 | 0, /* tp_richcompare */ |
| 699 | 0, /* tp_weaklistoffset */ |
| 700 | 0, /* tp_iter */ |
| 701 | 0, /* tp_iternext */ |
| 702 | 0, /* tp_methods */ |
| 703 | callback_members, /* tp_members */ |
| 704 | 0, /* tp_getset */ |
| 705 | 0, /* tp_base */ |
| 706 | 0, /* tp_dict */ |
| 707 | 0, /* tp_descr_get */ |
| 708 | 0, /* tp_descr_set */ |
| 709 | 0, /* tp_dictoffset */ |
| 710 | 0, /* tp_init */ |
| 711 | 0, /* tp_alloc */ |
| 712 | callback_new, /* tp_new */ |
| 713 | |
| 714 | }; |
| 715 | |
| 716 | |
| 717 | /* |
| 718 | * media_config_Object |
| 719 | * C/Python wrapper for media_config object |
| 720 | */ |
| 721 | typedef struct |
| 722 | { |
| 723 | PyObject_HEAD |
| 724 | /* Type-specific fields go here. */ |
| 725 | unsigned clock_rate; |
| 726 | unsigned max_media_ports; |
| 727 | int has_ioqueue; |
| 728 | unsigned thread_cnt; |
| 729 | unsigned quality; |
| 730 | unsigned ptime; |
| 731 | int no_vad; |
| 732 | unsigned ilbc_mode; |
| 733 | unsigned tx_drop_pct; |
| 734 | unsigned rx_drop_pct; |
| 735 | unsigned ec_options; |
| 736 | unsigned ec_tail_len; |
| 737 | } media_config_Object; |
| 738 | |
| 739 | |
| 740 | /* |
| 741 | * media_config_members |
| 742 | * declares attributes accessible from both C and Python for media_config file |
| 743 | */ |
| 744 | static PyMemberDef media_config_members[] = |
| 745 | { |
| 746 | { |
| 747 | "clock_rate", T_INT, offsetof(media_config_Object, clock_rate), 0, |
| 748 | "Clock rate to be applied to the conference bridge. If value is zero, " |
| 749 | "default clock rate will be used (16KHz)." |
| 750 | }, |
| 751 | { |
| 752 | "max_media_ports", T_INT, |
| 753 | offsetof(media_config_Object, max_media_ports), 0, |
| 754 | "Specify maximum number of media ports to be created in the " |
| 755 | "conference bridge. Since all media terminate in the bridge (calls, " |
| 756 | "file player, file recorder, etc), the value must be large enough to " |
| 757 | "support all of them. However, the larger the value, the more " |
| 758 | "computations are performed." |
| 759 | }, |
| 760 | { |
| 761 | "has_ioqueue", T_INT, offsetof(media_config_Object, has_ioqueue), 0, |
| 762 | "Specify whether the media manager should manage its own ioqueue for " |
| 763 | "the RTP/RTCP sockets. If yes, ioqueue will be created and at least " |
| 764 | "one worker thread will be created too. If no, the RTP/RTCP sockets " |
| 765 | "will share the same ioqueue as SIP sockets, and no worker thread is " |
| 766 | "needed." |
| 767 | }, |
| 768 | { |
| 769 | "thread_cnt", T_INT, offsetof(media_config_Object, thread_cnt), 0, |
| 770 | "Specify the number of worker threads to handle incoming RTP packets. " |
| 771 | "A value of one is recommended for most applications." |
| 772 | }, |
| 773 | { |
| 774 | "quality", T_INT, offsetof(media_config_Object, quality), 0, |
| 775 | "The media quality also sets speex codec quality/complexity to the " |
| 776 | "number." |
| 777 | }, |
| 778 | { |
| 779 | "ptime", T_INT, offsetof(media_config_Object, ptime), 0, |
| 780 | "Specify default ptime." |
| 781 | }, |
| 782 | { |
| 783 | "no_vad", T_INT, offsetof(media_config_Object, no_vad), 0, |
| 784 | "Disable VAD?" |
| 785 | }, |
| 786 | { |
| 787 | "ilbc_mode", T_INT, offsetof(media_config_Object, ilbc_mode), 0, |
| 788 | "iLBC mode (20 or 30)." |
| 789 | }, |
| 790 | { |
| 791 | "tx_drop_pct", T_INT, offsetof(media_config_Object, tx_drop_pct), 0, |
| 792 | "Percentage of RTP packet to drop in TX direction (to simulate packet " |
| 793 | "lost)." |
| 794 | }, |
| 795 | { |
| 796 | "rx_drop_pct", T_INT, offsetof(media_config_Object, rx_drop_pct), 0, |
| 797 | "Percentage of RTP packet to drop in RX direction (to simulate packet " |
| 798 | "lost)."}, |
| 799 | { |
| 800 | "ec_options", T_INT, offsetof(media_config_Object, ec_options), 0, |
| 801 | "Echo canceller options (see #pjmedia_echo_create())" |
| 802 | }, |
| 803 | { |
| 804 | "ec_tail_len", T_INT, offsetof(media_config_Object, ec_tail_len), 0, |
| 805 | "Echo canceller tail length, in miliseconds." |
| 806 | }, |
| 807 | {NULL} /* Sentinel */ |
| 808 | }; |
| 809 | |
| 810 | |
| 811 | /* |
| 812 | * media_config_Type |
| 813 | */ |
| 814 | static PyTypeObject media_config_Type = |
| 815 | { |
| 816 | PyObject_HEAD_INIT(NULL) |
| 817 | 0, /*ob_size*/ |
| 818 | "py_pjsua.Media_Config", /*tp_name*/ |
| 819 | sizeof(media_config_Object), /*tp_basicsize*/ |
| 820 | 0, /*tp_itemsize*/ |
| 821 | 0, /*tp_dealloc*/ |
| 822 | 0, /*tp_print*/ |
| 823 | 0, /*tp_getattr*/ |
| 824 | 0, /*tp_setattr*/ |
| 825 | 0, /*tp_compare*/ |
| 826 | 0, /*tp_repr*/ |
| 827 | 0, /*tp_as_number*/ |
| 828 | 0, /*tp_as_sequence*/ |
| 829 | 0, /*tp_as_mapping*/ |
| 830 | 0, /*tp_hash */ |
| 831 | 0, /*tp_call*/ |
| 832 | 0, /*tp_str*/ |
| 833 | 0, /*tp_getattro*/ |
| 834 | 0, /*tp_setattro*/ |
| 835 | 0, /*tp_as_buffer*/ |
| 836 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 837 | "Media Config objects", /*tp_doc*/ |
| 838 | 0, /*tp_traverse*/ |
| 839 | 0, /*tp_clear*/ |
| 840 | 0, /*tp_richcompare*/ |
| 841 | 0, /* tp_weaklistoffset */ |
| 842 | 0, /* tp_iter */ |
| 843 | 0, /* tp_iternext */ |
| 844 | 0, /* tp_methods */ |
| 845 | media_config_members, /* tp_members */ |
| 846 | |
| 847 | }; |
| 848 | |
| 849 | |
| 850 | /* |
| 851 | * config_Object |
| 852 | * attribute list for config object |
| 853 | */ |
| 854 | typedef struct |
| 855 | { |
| 856 | PyObject_HEAD |
| 857 | /* Type-specific fields go here. */ |
| 858 | unsigned max_calls; |
| 859 | unsigned thread_cnt; |
| 860 | unsigned outbound_proxy_cnt; |
| 861 | pj_str_t outbound_proxy[4]; |
| 862 | unsigned cred_count; |
| 863 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 864 | callback_Object * cb; |
| 865 | PyObject * user_agent; |
| 866 | } config_Object; |
| 867 | |
| 868 | |
| 869 | /* |
| 870 | * config_dealloc |
| 871 | * deallocates a config object |
| 872 | */ |
| 873 | static void config_dealloc(config_Object* self) |
| 874 | { |
| 875 | Py_XDECREF(self->cb); |
| 876 | Py_XDECREF(self->user_agent); |
| 877 | self->ob_type->tp_free((PyObject*)self); |
| 878 | } |
| 879 | |
| 880 | /* |
| 881 | * config_new |
| 882 | * config object constructor |
| 883 | */ |
| 884 | static PyObject *config_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
| 885 | { |
| 886 | config_Object *self; |
| 887 | |
| 888 | self = (config_Object *)type->tp_alloc(type, 0); |
| 889 | if (self != NULL) |
| 890 | { |
| 891 | self->user_agent = PyString_FromString(""); |
| 892 | if (self->user_agent == NULL) |
| 893 | { |
| 894 | Py_DECREF(self); |
| 895 | return NULL; |
| 896 | } |
| 897 | self->cb = (callback_Object *)PyType_GenericNew( |
| 898 | &callback_Type, NULL, NULL |
| 899 | ); |
| 900 | if (self->cb == NULL) |
| 901 | { |
| 902 | Py_DECREF(Py_None); |
| 903 | return NULL; |
| 904 | } |
| 905 | } |
| 906 | return (PyObject *)self; |
| 907 | } |
| 908 | |
| 909 | |
| 910 | /* |
| 911 | * config_members |
| 912 | * attribute list accessible from Python/C |
| 913 | */ |
| 914 | static PyMemberDef config_members[] = |
| 915 | { |
| 916 | { |
| 917 | "max_calls", T_INT, offsetof(config_Object, max_calls), 0, |
| 918 | "Maximum calls to support (default: 4) " |
| 919 | }, |
| 920 | { |
| 921 | "thread_cnt", T_INT, offsetof(config_Object, thread_cnt), 0, |
| 922 | "Number of worker threads. Normally application will want to have at " |
| 923 | "least one worker thread, unless when it wants to poll the library " |
| 924 | "periodically, which in this case the worker thread can be set to " |
| 925 | "zero." |
| 926 | }, |
| 927 | { |
| 928 | "outbound_proxy_cnt", T_INT, |
| 929 | offsetof(config_Object, outbound_proxy_cnt), 0, |
| 930 | "Number of outbound proxies in the array." |
| 931 | }, |
| 932 | { |
| 933 | "cred_count", T_INT, offsetof(config_Object, cred_count), 0, |
| 934 | "Number of credentials in the credential array." |
| 935 | }, |
| 936 | { |
| 937 | "user_agent", T_OBJECT_EX, offsetof(config_Object, user_agent), 0, |
| 938 | "User agent string (default empty)" |
| 939 | }, |
| 940 | { |
| 941 | "cb", T_OBJECT_EX, offsetof(config_Object, cb), 0, |
| 942 | "Application callback." |
| 943 | }, |
| 944 | {NULL} /* Sentinel */ |
| 945 | }; |
| 946 | |
| 947 | |
| 948 | /* |
| 949 | * config_Type |
| 950 | * type wrapper for config class |
| 951 | */ |
| 952 | static PyTypeObject config_Type = |
| 953 | { |
| 954 | PyObject_HEAD_INIT(NULL) |
| 955 | 0, /*ob_size*/ |
| 956 | "py_pjsua.Config", /*tp_name*/ |
| 957 | sizeof(config_Object), /*tp_basicsize*/ |
| 958 | 0, /*tp_itemsize*/ |
| 959 | (destructor)config_dealloc,/*tp_dealloc*/ |
| 960 | 0, /*tp_print*/ |
| 961 | 0, /*tp_getattr*/ |
| 962 | 0, /*tp_setattr*/ |
| 963 | 0, /*tp_compare*/ |
| 964 | 0, /*tp_repr*/ |
| 965 | 0, /*tp_as_number*/ |
| 966 | 0, /*tp_as_sequence*/ |
| 967 | 0, /*tp_as_mapping*/ |
| 968 | 0, /*tp_hash */ |
| 969 | 0, /*tp_call*/ |
| 970 | 0, /*tp_str*/ |
| 971 | 0, /*tp_getattro*/ |
| 972 | 0, /*tp_setattro*/ |
| 973 | 0, /*tp_as_buffer*/ |
| 974 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 975 | "Config objects", /* tp_doc */ |
| 976 | 0, /* tp_traverse */ |
| 977 | 0, /* tp_clear */ |
| 978 | 0, /* tp_richcompare */ |
| 979 | 0, /* tp_weaklistoffset */ |
| 980 | 0, /* tp_iter */ |
| 981 | 0, /* tp_iternext */ |
| 982 | 0, /* tp_methods */ |
| 983 | config_members, /* tp_members */ |
| 984 | 0, /* tp_getset */ |
| 985 | 0, /* tp_base */ |
| 986 | 0, /* tp_dict */ |
| 987 | 0, /* tp_descr_get */ |
| 988 | 0, /* tp_descr_set */ |
| 989 | 0, /* tp_dictoffset */ |
| 990 | 0, /* tp_init */ |
| 991 | 0, /* tp_alloc */ |
| 992 | config_new, /* tp_new */ |
| 993 | |
| 994 | }; |
| 995 | |
| 996 | |
| 997 | /* |
| 998 | * logging_config_Object |
| 999 | * configuration class for logging_config object |
| 1000 | */ |
| 1001 | typedef struct |
| 1002 | { |
| 1003 | PyObject_HEAD |
| 1004 | /* Type-specific fields go here. */ |
| 1005 | int msg_logging; |
| 1006 | unsigned level; |
| 1007 | unsigned console_level; |
| 1008 | unsigned decor; |
| 1009 | PyObject * log_filename; |
| 1010 | PyObject * cb; |
| 1011 | } logging_config_Object; |
| 1012 | |
| 1013 | |
| 1014 | /* |
| 1015 | * logging_config_dealloc |
| 1016 | * deletes a logging config from memory |
| 1017 | */ |
| 1018 | static void logging_config_dealloc(logging_config_Object* self) |
| 1019 | { |
| 1020 | Py_XDECREF(self->log_filename); |
| 1021 | Py_XDECREF(self->cb); |
| 1022 | self->ob_type->tp_free((PyObject*)self); |
| 1023 | } |
| 1024 | |
| 1025 | |
| 1026 | /* |
| 1027 | * logging_config_new |
| 1028 | * constructor for logging_config object |
| 1029 | */ |
| 1030 | static PyObject * logging_config_new(PyTypeObject *type, PyObject *args, |
| 1031 | PyObject *kwds) |
| 1032 | { |
| 1033 | logging_config_Object *self; |
| 1034 | |
| 1035 | self = (logging_config_Object *)type->tp_alloc(type, 0); |
| 1036 | if (self != NULL) |
| 1037 | { |
| 1038 | self->log_filename = PyString_FromString(""); |
| 1039 | if (self->log_filename == NULL) |
| 1040 | { |
| 1041 | Py_DECREF(self); |
| 1042 | return NULL; |
| 1043 | } |
| 1044 | Py_INCREF(Py_None); |
| 1045 | self->cb = Py_None; |
| 1046 | if (self->cb == NULL) |
| 1047 | { |
| 1048 | Py_DECREF(Py_None); |
| 1049 | return NULL; |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | return (PyObject *)self; |
| 1054 | } |
| 1055 | |
| 1056 | |
| 1057 | /* |
| 1058 | * logging_config_members |
| 1059 | */ |
| 1060 | static PyMemberDef logging_config_members[] = |
| 1061 | { |
| 1062 | { |
| 1063 | "msg_logging", T_INT, offsetof(logging_config_Object, msg_logging), 0, |
| 1064 | "Log incoming and outgoing SIP message? Yes!" |
| 1065 | }, |
| 1066 | { |
| 1067 | "level", T_INT, offsetof(logging_config_Object, level), 0, |
| 1068 | "Input verbosity level. Value 5 is reasonable." |
| 1069 | }, |
| 1070 | { |
| 1071 | "console_level", T_INT, offsetof(logging_config_Object, console_level), |
| 1072 | 0, "Verbosity level for console. Value 4 is reasonable." |
| 1073 | }, |
| 1074 | { |
| 1075 | "decor", T_INT, offsetof(logging_config_Object, decor), 0, |
| 1076 | "Log decoration" |
| 1077 | }, |
| 1078 | { |
| 1079 | "log_filename", T_OBJECT_EX, |
| 1080 | offsetof(logging_config_Object, log_filename), 0, |
| 1081 | "Optional log filename" |
| 1082 | }, |
| 1083 | { |
| 1084 | "cb", T_OBJECT_EX, offsetof(logging_config_Object, cb), 0, |
| 1085 | "Optional callback function to be called to write log to application " |
| 1086 | "specific device. This function will be called forlog messages on " |
| 1087 | "input verbosity level." |
| 1088 | }, |
| 1089 | {NULL} /* Sentinel */ |
| 1090 | }; |
| 1091 | |
| 1092 | |
| 1093 | |
| 1094 | |
| 1095 | /* |
| 1096 | * logging_config_Type |
| 1097 | */ |
| 1098 | static PyTypeObject logging_config_Type = |
| 1099 | { |
| 1100 | PyObject_HEAD_INIT(NULL) |
| 1101 | 0, /*ob_size*/ |
| 1102 | "py_pjsua.Logging_Config", /*tp_name*/ |
| 1103 | sizeof(logging_config_Object), /*tp_basicsize*/ |
| 1104 | 0, /*tp_itemsize*/ |
| 1105 | (destructor)logging_config_dealloc,/*tp_dealloc*/ |
| 1106 | 0, /*tp_print*/ |
| 1107 | 0, /*tp_getattr*/ |
| 1108 | 0, /*tp_setattr*/ |
| 1109 | 0, /*tp_compare*/ |
| 1110 | 0, /*tp_repr*/ |
| 1111 | 0, /*tp_as_number*/ |
| 1112 | 0, /*tp_as_sequence*/ |
| 1113 | 0, /*tp_as_mapping*/ |
| 1114 | 0, /*tp_hash */ |
| 1115 | 0, /*tp_call*/ |
| 1116 | 0, /*tp_str*/ |
| 1117 | 0, /*tp_getattro*/ |
| 1118 | 0, /*tp_setattro*/ |
| 1119 | 0, /*tp_as_buffer*/ |
| 1120 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1121 | "Logging Config objects", /* tp_doc */ |
| 1122 | 0, /* tp_traverse */ |
| 1123 | 0, /* tp_clear */ |
| 1124 | 0, /* tp_richcompare */ |
| 1125 | 0, /* tp_weaklistoffset */ |
| 1126 | 0, /* tp_iter */ |
| 1127 | 0, /* tp_iternext */ |
| 1128 | 0, /* tp_methods */ |
| 1129 | logging_config_members, /* tp_members */ |
| 1130 | 0, /* tp_getset */ |
| 1131 | 0, /* tp_base */ |
| 1132 | 0, /* tp_dict */ |
| 1133 | 0, /* tp_descr_get */ |
| 1134 | 0, /* tp_descr_set */ |
| 1135 | 0, /* tp_dictoffset */ |
| 1136 | 0, /* tp_init */ |
| 1137 | 0, /* tp_alloc */ |
| 1138 | logging_config_new, /* tp_new */ |
| 1139 | |
| 1140 | }; |
| 1141 | |
| 1142 | |
| 1143 | /* |
| 1144 | * msg_data_Object |
| 1145 | * typewrapper for MessageData class |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1146 | * !modified @ 061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1147 | */ |
| 1148 | typedef struct |
| 1149 | { |
| 1150 | PyObject_HEAD |
| 1151 | /* Type-specific fields go here. */ |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1152 | /*pjsip_hdr hdr_list;*/ |
| 1153 | PyObject * hdr_list; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1154 | PyObject * content_type; |
| 1155 | PyObject * msg_body; |
| 1156 | } msg_data_Object; |
| 1157 | |
| 1158 | |
| 1159 | /* |
| 1160 | * msg_data_dealloc |
| 1161 | * deletes a msg_data |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1162 | * !modified @ 061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1163 | */ |
| 1164 | static void msg_data_dealloc(msg_data_Object* self) |
| 1165 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1166 | Py_XDECREF(self->hdr_list); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1167 | Py_XDECREF(self->content_type); |
| 1168 | Py_XDECREF(self->msg_body); |
| 1169 | self->ob_type->tp_free((PyObject*)self); |
| 1170 | } |
| 1171 | |
| 1172 | |
| 1173 | /* |
| 1174 | * msg_data_new |
| 1175 | * constructor for msg_data object |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1176 | * !modified @ 061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1177 | */ |
| 1178 | static PyObject * msg_data_new(PyTypeObject *type, PyObject *args, |
| 1179 | PyObject *kwds) |
| 1180 | { |
| 1181 | msg_data_Object *self; |
| 1182 | |
| 1183 | self = (msg_data_Object *)type->tp_alloc(type, 0); |
| 1184 | if (self != NULL) |
| 1185 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1186 | Py_INCREF(Py_None); |
| 1187 | self->hdr_list = Py_None; |
| 1188 | if (self->hdr_list == NULL) |
| 1189 | { |
| 1190 | Py_DECREF(self); |
| 1191 | return NULL; |
| 1192 | } |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1193 | self->content_type = PyString_FromString(""); |
| 1194 | if (self->content_type == NULL) |
| 1195 | { |
| 1196 | Py_DECREF(self); |
| 1197 | return NULL; |
| 1198 | } |
| 1199 | self->msg_body = PyString_FromString(""); |
| 1200 | if (self->msg_body == NULL) |
| 1201 | { |
| 1202 | Py_DECREF(self); |
| 1203 | return NULL; |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | return (PyObject *)self; |
| 1208 | } |
| 1209 | |
| 1210 | |
| 1211 | /* |
| 1212 | * msg_data_members |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1213 | * !modified @ 061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1214 | */ |
| 1215 | static PyMemberDef msg_data_members[] = |
| 1216 | { |
| 1217 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1218 | "hdr_list", T_OBJECT_EX, offsetof(msg_data_Object, hdr_list), |
| 1219 | 0, "Additional message headers as linked list." |
| 1220 | }, |
| 1221 | { |
| 1222 | "content_type", T_OBJECT_EX, offsetof(msg_data_Object, content_type), |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1223 | 0, "MIME type of optional message body." |
| 1224 | }, |
| 1225 | { |
| 1226 | "msg_body", T_OBJECT_EX, offsetof(msg_data_Object, msg_body), 0, |
| 1227 | "Optional message body." |
| 1228 | }, |
| 1229 | {NULL} /* Sentinel */ |
| 1230 | }; |
| 1231 | |
| 1232 | |
| 1233 | /* |
| 1234 | * msg_data_Type |
| 1235 | */ |
| 1236 | static PyTypeObject msg_data_Type = |
| 1237 | { |
| 1238 | PyObject_HEAD_INIT(NULL) |
| 1239 | 0, /*ob_size*/ |
| 1240 | "py_pjsua.Msg_Data", /*tp_name*/ |
| 1241 | sizeof(msg_data_Object), /*tp_basicsize*/ |
| 1242 | 0, /*tp_itemsize*/ |
| 1243 | (destructor)msg_data_dealloc,/*tp_dealloc*/ |
| 1244 | 0, /*tp_print*/ |
| 1245 | 0, /*tp_getattr*/ |
| 1246 | 0, /*tp_setattr*/ |
| 1247 | 0, /*tp_compare*/ |
| 1248 | 0, /*tp_repr*/ |
| 1249 | 0, /*tp_as_number*/ |
| 1250 | 0, /*tp_as_sequence*/ |
| 1251 | 0, /*tp_as_mapping*/ |
| 1252 | 0, /*tp_hash */ |
| 1253 | 0, /*tp_call*/ |
| 1254 | 0, /*tp_str*/ |
| 1255 | 0, /*tp_getattro*/ |
| 1256 | 0, /*tp_setattro*/ |
| 1257 | 0, /*tp_as_buffer*/ |
| 1258 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1259 | "msg_data objects", /* tp_doc */ |
| 1260 | 0, /* tp_traverse */ |
| 1261 | 0, /* tp_clear */ |
| 1262 | 0, /* tp_richcompare */ |
| 1263 | 0, /* tp_weaklistoffset */ |
| 1264 | 0, /* tp_iter */ |
| 1265 | 0, /* tp_iternext */ |
| 1266 | 0, /* tp_methods */ |
| 1267 | msg_data_members, /* tp_members */ |
| 1268 | 0, /* tp_getset */ |
| 1269 | 0, /* tp_base */ |
| 1270 | 0, /* tp_dict */ |
| 1271 | 0, /* tp_descr_get */ |
| 1272 | 0, /* tp_descr_set */ |
| 1273 | 0, /* tp_dictoffset */ |
| 1274 | 0, /* tp_init */ |
| 1275 | 0, /* tp_alloc */ |
| 1276 | msg_data_new, /* tp_new */ |
| 1277 | |
| 1278 | }; |
| 1279 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1280 | /* |
| 1281 | * translate_hdr |
| 1282 | * internal function |
| 1283 | * translate from hdr_list to pjsip_generic_string_hdr |
| 1284 | */ |
| 1285 | void translate_hdr(pj_pool_t *pool, pjsip_hdr *hdr, PyObject *py_hdr_list) |
| 1286 | { |
| 1287 | int i; |
| 1288 | |
| 1289 | if (PyList_Check(py_hdr_list)) { |
| 1290 | pj_list_init(hdr); |
| 1291 | |
| 1292 | for (i = 0; i < PyList_Size(py_hdr_list); i++) { |
| 1293 | pj_str_t hname, hvalue; |
| 1294 | pjsip_generic_string_hdr * new_hdr; |
| 1295 | PyObject * tuple = PyList_GetItem(py_hdr_list, i); |
| 1296 | |
| 1297 | if (PyTuple_Check(tuple)) { |
| 1298 | hname.ptr = PyString_AsString(PyTuple_GetItem(tuple,0)); |
| 1299 | hname.slen = strlen(PyString_AsString(PyTuple_GetItem(tuple,0))); |
| 1300 | hvalue.ptr = PyString_AsString(PyTuple_GetItem(tuple,1)); |
| 1301 | hvalue.slen = strlen(PyString_AsString(PyTuple_GetItem(tuple,1))); |
| 1302 | } else { |
| 1303 | hname.ptr = ""; |
| 1304 | hname.slen = 0; |
| 1305 | hvalue.ptr = ""; |
| 1306 | hvalue.slen = 0; |
| 1307 | } |
| 1308 | new_hdr = pjsip_generic_string_hdr_create(pool, &hname, &hvalue); |
| 1309 | pj_list_push_back((pj_list_type *)hdr, (pj_list_type *)new_hdr); |
| 1310 | } |
| 1311 | } |
| 1312 | } |
| 1313 | |
| 1314 | /* |
| 1315 | * translate_hdr_rev |
| 1316 | * internal function |
| 1317 | * translate from pjsip_generic_string_hdr to hdr_list |
| 1318 | */ |
| 1319 | |
| 1320 | void translate_hdr_rev(pjsip_generic_string_hdr *hdr, PyObject *py_hdr_list) |
| 1321 | { |
| 1322 | int i; |
| 1323 | int len; |
| 1324 | pjsip_generic_string_hdr * p_hdr; |
| 1325 | |
| 1326 | len = pj_list_size(hdr); |
| 1327 | |
| 1328 | if (len > 0) { |
| 1329 | p_hdr = hdr; |
| 1330 | Py_XDECREF(py_hdr_list); |
| 1331 | py_hdr_list = PyList_New(len); |
| 1332 | |
| 1333 | for (i = 0; i < len && p_hdr != NULL; i++) { |
| 1334 | PyObject * tuple; |
| 1335 | PyObject * str; |
| 1336 | |
| 1337 | tuple = PyTuple_New(2); |
| 1338 | |
| 1339 | str = PyString_FromStringAndSize(p_hdr->name.ptr, p_hdr->name.slen); |
| 1340 | PyTuple_SetItem(tuple, 0, str); |
| 1341 | str = PyString_FromStringAndSize(hdr->hvalue.ptr, p_hdr->hvalue.slen); |
| 1342 | PyTuple_SetItem(tuple, 1, str); |
| 1343 | PyList_SetItem(py_hdr_list, i, tuple); |
| 1344 | p_hdr = p_hdr->next; |
| 1345 | } |
| 1346 | } |
| 1347 | |
| 1348 | |
| 1349 | } |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1350 | |
| 1351 | /* |
| 1352 | * pj_pool_Object |
| 1353 | */ |
| 1354 | typedef struct |
| 1355 | { |
| 1356 | PyObject_HEAD |
| 1357 | /* Type-specific fields go here. */ |
| 1358 | pj_pool_t * pool; |
| 1359 | } pj_pool_Object; |
| 1360 | |
| 1361 | |
| 1362 | /* |
| 1363 | * pj_pool_Type |
| 1364 | */ |
| 1365 | static PyTypeObject pj_pool_Type = |
| 1366 | { |
| 1367 | PyObject_HEAD_INIT(NULL) |
| 1368 | 0, /*ob_size*/ |
| 1369 | "py_pjsua.PJ_Pool", /*tp_name*/ |
| 1370 | sizeof(pj_pool_Object), /*tp_basicsize*/ |
| 1371 | 0, /*tp_itemsize*/ |
| 1372 | 0, /*tp_dealloc*/ |
| 1373 | 0, /*tp_print*/ |
| 1374 | 0, /*tp_getattr*/ |
| 1375 | 0, /*tp_setattr*/ |
| 1376 | 0, /*tp_compare*/ |
| 1377 | 0, /*tp_repr*/ |
| 1378 | 0, /*tp_as_number*/ |
| 1379 | 0, /*tp_as_sequence*/ |
| 1380 | 0, /*tp_as_mapping*/ |
| 1381 | 0, /*tp_hash */ |
| 1382 | 0, /*tp_call*/ |
| 1383 | 0, /*tp_str*/ |
| 1384 | 0, /*tp_getattro*/ |
| 1385 | 0, /*tp_setattro*/ |
| 1386 | 0, /*tp_as_buffer*/ |
| 1387 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1388 | "pj_pool_t objects", /* tp_doc */ |
| 1389 | |
| 1390 | }; |
| 1391 | |
| 1392 | |
| 1393 | /* |
| 1394 | * pjsip_endpoint_Object |
| 1395 | */ |
| 1396 | typedef struct |
| 1397 | { |
| 1398 | PyObject_HEAD |
| 1399 | /* Type-specific fields go here. */ |
| 1400 | pjsip_endpoint * endpt; |
| 1401 | } pjsip_endpoint_Object; |
| 1402 | |
| 1403 | |
| 1404 | /* |
| 1405 | * pjsip_endpoint_Type |
| 1406 | */ |
| 1407 | static PyTypeObject pjsip_endpoint_Type = |
| 1408 | { |
| 1409 | PyObject_HEAD_INIT(NULL) |
| 1410 | 0, /*ob_size*/ |
| 1411 | "py_pjsua.PJSIP_Endpoint", /*tp_name*/ |
| 1412 | sizeof(pjsip_endpoint_Object),/*tp_basicsize*/ |
| 1413 | 0, /*tp_itemsize*/ |
| 1414 | 0, /*tp_dealloc*/ |
| 1415 | 0, /*tp_print*/ |
| 1416 | 0, /*tp_getattr*/ |
| 1417 | 0, /*tp_setattr*/ |
| 1418 | 0, /*tp_compare*/ |
| 1419 | 0, /*tp_repr*/ |
| 1420 | 0, /*tp_as_number*/ |
| 1421 | 0, /*tp_as_sequence*/ |
| 1422 | 0, /*tp_as_mapping*/ |
| 1423 | 0, /*tp_hash */ |
| 1424 | 0, /*tp_call*/ |
| 1425 | 0, /*tp_str*/ |
| 1426 | 0, /*tp_getattro*/ |
| 1427 | 0, /*tp_setattro*/ |
| 1428 | 0, /*tp_as_buffer*/ |
| 1429 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1430 | "pjsip_endpoint objects", /* tp_doc */ |
| 1431 | }; |
| 1432 | |
| 1433 | |
| 1434 | /* |
| 1435 | * pjmedia_endpt_Object |
| 1436 | */ |
| 1437 | typedef struct |
| 1438 | { |
| 1439 | PyObject_HEAD |
| 1440 | /* Type-specific fields go here. */ |
| 1441 | pjmedia_endpt * endpt; |
| 1442 | } pjmedia_endpt_Object; |
| 1443 | |
| 1444 | |
| 1445 | /* |
| 1446 | * pjmedia_endpt_Type |
| 1447 | */ |
| 1448 | static PyTypeObject pjmedia_endpt_Type = |
| 1449 | { |
| 1450 | PyObject_HEAD_INIT(NULL) |
| 1451 | 0, /*ob_size*/ |
| 1452 | "py_pjsua.PJMedia_Endpt", /*tp_name*/ |
| 1453 | sizeof(pjmedia_endpt_Object), /*tp_basicsize*/ |
| 1454 | 0, /*tp_itemsize*/ |
| 1455 | 0, /*tp_dealloc*/ |
| 1456 | 0, /*tp_print*/ |
| 1457 | 0, /*tp_getattr*/ |
| 1458 | 0, /*tp_setattr*/ |
| 1459 | 0, /*tp_compare*/ |
| 1460 | 0, /*tp_repr*/ |
| 1461 | 0, /*tp_as_number*/ |
| 1462 | 0, /*tp_as_sequence*/ |
| 1463 | 0, /*tp_as_mapping*/ |
| 1464 | 0, /*tp_hash */ |
| 1465 | 0, /*tp_call*/ |
| 1466 | 0, /*tp_str*/ |
| 1467 | 0, /*tp_getattro*/ |
| 1468 | 0, /*tp_setattro*/ |
| 1469 | 0, /*tp_as_buffer*/ |
| 1470 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1471 | "pjmedia_endpt objects", /* tp_doc */ |
| 1472 | |
| 1473 | }; |
| 1474 | |
| 1475 | |
| 1476 | /* |
| 1477 | * pj_pool_factory_Object |
| 1478 | */ |
| 1479 | typedef struct |
| 1480 | { |
| 1481 | PyObject_HEAD |
| 1482 | /* Type-specific fields go here. */ |
| 1483 | pj_pool_factory * pool_fact; |
| 1484 | } pj_pool_factory_Object; |
| 1485 | |
| 1486 | |
| 1487 | |
| 1488 | /* |
| 1489 | * pj_pool_factory_Type |
| 1490 | */ |
| 1491 | static PyTypeObject pj_pool_factory_Type = |
| 1492 | { |
| 1493 | PyObject_HEAD_INIT(NULL) |
| 1494 | 0, /*ob_size*/ |
| 1495 | "py_pjsua.PJ_Pool_Factory",/*tp_name*/ |
| 1496 | sizeof(pj_pool_factory_Object), /*tp_basicsize*/ |
| 1497 | 0, /*tp_itemsize*/ |
| 1498 | 0, /*tp_dealloc*/ |
| 1499 | 0, /*tp_print*/ |
| 1500 | 0, /*tp_getattr*/ |
| 1501 | 0, /*tp_setattr*/ |
| 1502 | 0, /*tp_compare*/ |
| 1503 | 0, /*tp_repr*/ |
| 1504 | 0, /*tp_as_number*/ |
| 1505 | 0, /*tp_as_sequence*/ |
| 1506 | 0, /*tp_as_mapping*/ |
| 1507 | 0, /*tp_hash */ |
| 1508 | 0, /*tp_call*/ |
| 1509 | 0, /*tp_str*/ |
| 1510 | 0, /*tp_getattro*/ |
| 1511 | 0, /*tp_setattro*/ |
| 1512 | 0, /*tp_as_buffer*/ |
| 1513 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1514 | "pj_pool_factory objects", /* tp_doc */ |
| 1515 | |
| 1516 | }; |
| 1517 | |
| 1518 | |
| 1519 | /* |
| 1520 | * pjsip_cred_info_Object |
| 1521 | */ |
| 1522 | typedef struct |
| 1523 | { |
| 1524 | PyObject_HEAD |
| 1525 | /* Type-specific fields go here. */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1526 | PyObject * realm; |
| 1527 | PyObject * scheme; |
| 1528 | PyObject * username; |
| 1529 | int data_type; |
| 1530 | PyObject * data; |
| 1531 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1532 | } pjsip_cred_info_Object; |
| 1533 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1534 | /* |
| 1535 | * cred_info_dealloc |
| 1536 | * deletes a cred info from memory |
| 1537 | */ |
| 1538 | static void pjsip_cred_info_dealloc(pjsip_cred_info_Object* self) |
| 1539 | { |
| 1540 | Py_XDECREF(self->realm); |
| 1541 | Py_XDECREF(self->scheme); |
| 1542 | Py_XDECREF(self->username); |
| 1543 | Py_XDECREF(self->data); |
| 1544 | self->ob_type->tp_free((PyObject*)self); |
| 1545 | } |
| 1546 | |
| 1547 | |
| 1548 | /* |
| 1549 | * cred_info_new |
| 1550 | * constructor for cred_info object |
| 1551 | */ |
| 1552 | static PyObject * pjsip_cred_info_new(PyTypeObject *type, PyObject *args, |
| 1553 | PyObject *kwds) |
| 1554 | { |
| 1555 | pjsip_cred_info_Object *self; |
| 1556 | |
| 1557 | self = (pjsip_cred_info_Object *)type->tp_alloc(type, 0); |
| 1558 | if (self != NULL) |
| 1559 | { |
| 1560 | self->realm = PyString_FromString(""); |
| 1561 | if (self->realm == NULL) |
| 1562 | { |
| 1563 | Py_DECREF(self); |
| 1564 | return NULL; |
| 1565 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1566 | self->scheme = PyString_FromString(""); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1567 | if (self->scheme == NULL) |
| 1568 | { |
| 1569 | Py_DECREF(self); |
| 1570 | return NULL; |
| 1571 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1572 | self->username = PyString_FromString(""); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1573 | if (self->username == NULL) |
| 1574 | { |
| 1575 | Py_DECREF(self); |
| 1576 | return NULL; |
| 1577 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1578 | self->data = PyString_FromString(""); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1579 | if (self->data == NULL) |
| 1580 | { |
| 1581 | Py_DECREF(self); |
| 1582 | return NULL; |
| 1583 | } |
| 1584 | } |
| 1585 | |
| 1586 | return (PyObject *)self; |
| 1587 | } |
| 1588 | |
| 1589 | |
| 1590 | /* |
| 1591 | * pjsip_cred_info_members |
| 1592 | */ |
| 1593 | static PyMemberDef pjsip_cred_info_members[] = |
| 1594 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1595 | { |
| 1596 | "realm", T_OBJECT_EX, |
| 1597 | offsetof(pjsip_cred_info_Object, realm), 0, |
| 1598 | "Realm" |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1599 | }, |
| 1600 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1601 | "scheme", T_OBJECT_EX, |
| 1602 | offsetof(pjsip_cred_info_Object, scheme), 0, |
| 1603 | "Scheme" |
| 1604 | }, |
| 1605 | { |
| 1606 | "username", T_OBJECT_EX, |
| 1607 | offsetof(pjsip_cred_info_Object, username), 0, |
| 1608 | "User name" |
| 1609 | }, |
| 1610 | { |
| 1611 | "data", T_OBJECT_EX, |
| 1612 | offsetof(pjsip_cred_info_Object, data), 0, |
| 1613 | "The data, which can be a plaintext password or a hashed digest. " |
| 1614 | }, |
| 1615 | { |
| 1616 | "data_type", T_INT, offsetof(pjsip_cred_info_Object, data_type), 0, |
| 1617 | "Type of data" |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1618 | }, |
| 1619 | |
| 1620 | {NULL} /* Sentinel */ |
| 1621 | }; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1622 | |
| 1623 | /* |
| 1624 | * pjsip_cred_info_Type |
| 1625 | */ |
| 1626 | static PyTypeObject pjsip_cred_info_Type = |
| 1627 | { |
| 1628 | PyObject_HEAD_INIT(NULL) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1629 | 0, /*ob_size*/ |
| 1630 | "py_pjsua.PJSIP_Cred_Info", /*tp_name*/ |
| 1631 | sizeof(pjsip_cred_info_Object), /*tp_basicsize*/ |
| 1632 | 0, /*tp_itemsize*/ |
| 1633 | (destructor)pjsip_cred_info_dealloc,/*tp_dealloc*/ |
| 1634 | 0, /*tp_print*/ |
| 1635 | 0, /*tp_getattr*/ |
| 1636 | 0, /*tp_setattr*/ |
| 1637 | 0, /*tp_compare*/ |
| 1638 | 0, /*tp_repr*/ |
| 1639 | 0, /*tp_as_number*/ |
| 1640 | 0, /*tp_as_sequence*/ |
| 1641 | 0, /*tp_as_mapping*/ |
| 1642 | 0, /*tp_hash */ |
| 1643 | 0, /*tp_call*/ |
| 1644 | 0, /*tp_str*/ |
| 1645 | 0, /*tp_getattro*/ |
| 1646 | 0, /*tp_setattro*/ |
| 1647 | 0, /*tp_as_buffer*/ |
| 1648 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 1649 | "PJSIP Cred Info objects", /* tp_doc */ |
| 1650 | 0, /* tp_traverse */ |
| 1651 | 0, /* tp_clear */ |
| 1652 | 0, /* tp_richcompare */ |
| 1653 | 0, /* tp_weaklistoffset */ |
| 1654 | 0, /* tp_iter */ |
| 1655 | 0, /* tp_iternext */ |
| 1656 | 0, /* tp_methods */ |
| 1657 | pjsip_cred_info_members, /* tp_members */ |
| 1658 | 0, /* tp_getset */ |
| 1659 | 0, /* tp_base */ |
| 1660 | 0, /* tp_dict */ |
| 1661 | 0, /* tp_descr_get */ |
| 1662 | 0, /* tp_descr_set */ |
| 1663 | 0, /* tp_dictoffset */ |
| 1664 | 0, /* tp_init */ |
| 1665 | 0, /* tp_alloc */ |
| 1666 | pjsip_cred_info_new, /* tp_new */ |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1667 | |
| 1668 | }; |
| 1669 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1670 | /* |
| 1671 | * py_pjsua_thread_register |
| 1672 | * !added @ 061206 |
| 1673 | */ |
| 1674 | static PyObject *py_pjsua_thread_register(PyObject *pSelf, PyObject |
| 1675 | *pArgs) |
| 1676 | { |
| 1677 | |
| 1678 | pj_status_t status; |
| 1679 | const char *name; |
| 1680 | PyObject *py_desc; |
| 1681 | pj_thread_t *thread; |
| 1682 | void *thread_desc; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1683 | #if 0 |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1684 | int size; |
| 1685 | int i; |
| 1686 | int *td; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1687 | #endif |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1688 | |
| 1689 | if (!PyArg_ParseTuple(pArgs, "sO", &name, &py_desc)) |
| 1690 | { |
| 1691 | return NULL; |
| 1692 | } |
| 1693 | #if 0 |
| 1694 | size = PyList_Size(py_desc); |
| 1695 | td = (int *)malloc(size * sizeof(int)); |
| 1696 | for (i = 0; i < size; i++) { |
| 1697 | if (!PyArg_Parse(PyList_GetItem(py_desc,i),"i", td[i])) { |
| 1698 | return NULL; |
| 1699 | } |
| 1700 | } |
| 1701 | thread_desc = td; |
| 1702 | #else |
| 1703 | thread_desc = malloc(sizeof(pj_thread_desc)); |
| 1704 | #endif |
| 1705 | status = pj_thread_register(name, thread_desc, &thread); |
| 1706 | return Py_BuildValue("i",status); |
| 1707 | } |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1708 | |
| 1709 | /* |
| 1710 | * py_pjsua_logging_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1711 | * !modified @ 051206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1712 | */ |
| 1713 | static PyObject *py_pjsua_logging_config_default(PyObject *pSelf, |
| 1714 | PyObject *pArgs) |
| 1715 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1716 | logging_config_Object *obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1717 | pjsua_logging_config cfg; |
| 1718 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1719 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1720 | { |
| 1721 | return NULL; |
| 1722 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1723 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1724 | pjsua_logging_config_default(&cfg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1725 | obj = (logging_config_Object *) logging_config_new |
| 1726 | (&logging_config_Type,NULL,NULL); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1727 | obj->msg_logging = cfg.msg_logging; |
| 1728 | obj->level = cfg.level; |
| 1729 | obj->console_level = cfg.console_level; |
| 1730 | obj->decor = cfg.decor; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1731 | |
| 1732 | return (PyObject *)obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1733 | } |
| 1734 | |
| 1735 | |
| 1736 | /* |
| 1737 | * py_pjsua_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1738 | * !modified @ 051206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1739 | */ |
| 1740 | static PyObject *py_pjsua_config_default(PyObject *pSelf, PyObject *pArgs) |
| 1741 | { |
| 1742 | config_Object *obj; |
| 1743 | pjsua_config cfg; |
| 1744 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1745 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1746 | { |
| 1747 | return NULL; |
| 1748 | } |
| 1749 | pjsua_config_default(&cfg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1750 | obj = (config_Object *) config_new(&config_Type, NULL, NULL); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1751 | obj->max_calls = cfg.max_calls; |
| 1752 | obj->thread_cnt = cfg.thread_cnt; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1753 | return (PyObject *)obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1754 | } |
| 1755 | |
| 1756 | |
| 1757 | /* |
| 1758 | * py_pjsua_media_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1759 | * !modified @ 051206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1760 | */ |
| 1761 | static PyObject * py_pjsua_media_config_default(PyObject *pSelf, |
| 1762 | PyObject *pArgs) |
| 1763 | { |
| 1764 | media_config_Object *obj; |
| 1765 | pjsua_media_config cfg; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1766 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1767 | { |
| 1768 | return NULL; |
| 1769 | } |
| 1770 | pjsua_media_config_default(&cfg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1771 | obj = (media_config_Object *)PyType_GenericNew(&media_config_Type, NULL, NULL); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1772 | obj->clock_rate = cfg.clock_rate; |
| 1773 | obj->ec_options = cfg.ec_options; |
| 1774 | obj->ec_tail_len = cfg.ec_tail_len; |
| 1775 | obj->has_ioqueue = cfg.has_ioqueue; |
| 1776 | obj->ilbc_mode = cfg.ilbc_mode; |
| 1777 | obj->max_media_ports = cfg.max_media_ports; |
| 1778 | obj->no_vad = cfg.no_vad; |
| 1779 | obj->ptime = cfg.ptime; |
| 1780 | obj->quality = cfg.quality; |
| 1781 | obj->rx_drop_pct = cfg.rx_drop_pct; |
| 1782 | obj->thread_cnt = cfg.thread_cnt; |
| 1783 | obj->tx_drop_pct = cfg.tx_drop_pct; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1784 | return (PyObject *)obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1785 | } |
| 1786 | |
| 1787 | |
| 1788 | /* |
| 1789 | * py_pjsua_msg_data_init |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1790 | * !modified @ 051206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1791 | */ |
| 1792 | static PyObject *py_pjsua_msg_data_init(PyObject *pSelf, PyObject *pArgs) |
| 1793 | { |
| 1794 | msg_data_Object *obj; |
| 1795 | pjsua_msg_data msg; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1796 | |
| 1797 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1798 | { |
| 1799 | return NULL; |
| 1800 | } |
| 1801 | pjsua_msg_data_init(&msg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1802 | obj = (msg_data_Object *)msg_data_new(&msg_data_Type, NULL, NULL); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1803 | Py_XDECREF(obj->content_type); |
| 1804 | obj->content_type = PyString_FromStringAndSize( |
| 1805 | msg.content_type.ptr, msg.content_type.slen |
| 1806 | ); |
| 1807 | Py_XDECREF(obj->msg_body); |
| 1808 | obj->msg_body = PyString_FromStringAndSize( |
| 1809 | msg.msg_body.ptr, msg.msg_body.slen |
| 1810 | ); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1811 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1812 | translate_hdr_rev((pjsip_generic_string_hdr *)&msg.hdr_list, obj->hdr_list); |
| 1813 | |
| 1814 | return (PyObject *)obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1815 | } |
| 1816 | |
| 1817 | |
| 1818 | /* |
| 1819 | * py_pjsua_reconfigure_logging |
| 1820 | */ |
| 1821 | static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, PyObject *pArgs) |
| 1822 | { |
| 1823 | logging_config_Object *log; |
| 1824 | pjsua_logging_config cfg; |
| 1825 | pj_status_t status; |
| 1826 | |
| 1827 | if (!PyArg_ParseTuple(pArgs, "O", &log)) |
| 1828 | { |
| 1829 | return NULL; |
| 1830 | } |
| 1831 | cfg.msg_logging = log->msg_logging; |
| 1832 | cfg.level = log->level; |
| 1833 | cfg.console_level = log->console_level; |
| 1834 | cfg.decor = log->decor; |
| 1835 | cfg.log_filename.ptr = PyString_AsString(log->log_filename); |
| 1836 | cfg.log_filename.slen = strlen(cfg.log_filename.ptr); |
| 1837 | Py_XDECREF(obj_reconfigure_logging); |
| 1838 | obj_reconfigure_logging = log->cb; |
| 1839 | Py_INCREF(obj_reconfigure_logging); |
| 1840 | cfg.cb = &cb_reconfigure_logging; |
| 1841 | status = pjsua_reconfigure_logging(&cfg); |
| 1842 | return Py_BuildValue("i",status); |
| 1843 | } |
| 1844 | |
| 1845 | |
| 1846 | /* |
| 1847 | * py_pjsua_pool_create |
| 1848 | */ |
| 1849 | static PyObject *py_pjsua_pool_create(PyObject *pSelf, PyObject *pArgs) |
| 1850 | { |
| 1851 | pj_size_t init_size; |
| 1852 | pj_size_t increment; |
| 1853 | const char * name; |
| 1854 | pj_pool_t *p; |
| 1855 | pj_pool_Object *pool; |
| 1856 | |
| 1857 | if (!PyArg_ParseTuple(pArgs, "sII", &name, &init_size, &increment)) |
| 1858 | { |
| 1859 | return NULL; |
| 1860 | } |
| 1861 | /*printf("name : %s\n",name); |
| 1862 | printf("init : %d\n", init_size); |
| 1863 | printf("increment : %d\n", increment);*/ |
| 1864 | p = pjsua_pool_create(name, init_size, increment); |
| 1865 | pool = (pj_pool_Object *)PyType_GenericNew(&pj_pool_Type, NULL, NULL); |
| 1866 | pool->pool = p; |
| 1867 | return (PyObject *)pool; |
| 1868 | |
| 1869 | } |
| 1870 | |
| 1871 | |
| 1872 | /* |
| 1873 | * py_pjsua_get_pjsip_endpt |
| 1874 | */ |
| 1875 | static PyObject *py_pjsua_get_pjsip_endpt(PyObject *pSelf, PyObject *pArgs) |
| 1876 | { |
| 1877 | pjsip_endpoint_Object *endpt; |
| 1878 | pjsip_endpoint *e; |
| 1879 | |
| 1880 | if (!PyArg_ParseTuple(pArgs, "")) |
| 1881 | { |
| 1882 | return NULL; |
| 1883 | } |
| 1884 | e = pjsua_get_pjsip_endpt(); |
| 1885 | endpt = (pjsip_endpoint_Object *)PyType_GenericNew( |
| 1886 | &pjsip_endpoint_Type, NULL, NULL |
| 1887 | ); |
| 1888 | endpt->endpt = e; |
| 1889 | return (PyObject *)endpt; |
| 1890 | } |
| 1891 | |
| 1892 | |
| 1893 | /* |
| 1894 | * py_pjsua_get_pjmedia_endpt |
| 1895 | */ |
| 1896 | static PyObject *py_pjsua_get_pjmedia_endpt(PyObject *pSelf, PyObject *pArgs) |
| 1897 | { |
| 1898 | pjmedia_endpt_Object *endpt; |
| 1899 | pjmedia_endpt *e; |
| 1900 | |
| 1901 | if (!PyArg_ParseTuple(pArgs, "")) |
| 1902 | { |
| 1903 | return NULL; |
| 1904 | } |
| 1905 | e = pjsua_get_pjmedia_endpt(); |
| 1906 | endpt = (pjmedia_endpt_Object *)PyType_GenericNew( |
| 1907 | &pjmedia_endpt_Type, NULL, NULL |
| 1908 | ); |
| 1909 | endpt->endpt = e; |
| 1910 | return (PyObject *)endpt; |
| 1911 | } |
| 1912 | |
| 1913 | |
| 1914 | /* |
| 1915 | * py_pjsua_get_pool_factory |
| 1916 | */ |
| 1917 | static PyObject *py_pjsua_get_pool_factory(PyObject *pSelf, PyObject *pArgs) |
| 1918 | { |
| 1919 | pj_pool_factory_Object *pool; |
| 1920 | pj_pool_factory *p; |
| 1921 | |
| 1922 | if (!PyArg_ParseTuple(pArgs, "")) |
| 1923 | { |
| 1924 | return NULL; |
| 1925 | } |
| 1926 | p = pjsua_get_pool_factory(); |
| 1927 | pool = (pj_pool_factory_Object *)PyType_GenericNew( |
| 1928 | &pj_pool_factory_Type, NULL, NULL |
| 1929 | ); |
| 1930 | pool->pool_fact = p; |
| 1931 | return (PyObject *)pool; |
| 1932 | } |
| 1933 | |
| 1934 | |
| 1935 | /* |
| 1936 | * py_pjsua_perror |
| 1937 | */ |
| 1938 | static PyObject *py_pjsua_perror(PyObject *pSelf, PyObject *pArgs) |
| 1939 | { |
| 1940 | const char *sender; |
| 1941 | const char *title; |
| 1942 | pj_status_t status; |
| 1943 | if (!PyArg_ParseTuple(pArgs, "ssi", &sender, &title, &status)) |
| 1944 | { |
| 1945 | return NULL; |
| 1946 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1947 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1948 | pjsua_perror(sender, title, status); |
| 1949 | Py_INCREF(Py_None); |
| 1950 | return Py_None; |
| 1951 | } |
| 1952 | |
| 1953 | |
| 1954 | /* |
| 1955 | * py_pjsua_create |
| 1956 | */ |
| 1957 | static PyObject *py_pjsua_create(PyObject *pSelf, PyObject *pArgs) |
| 1958 | { |
| 1959 | pj_status_t status; |
| 1960 | if (!PyArg_ParseTuple(pArgs, "")) |
| 1961 | { |
| 1962 | return NULL; |
| 1963 | } |
| 1964 | status = pjsua_create(); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1965 | //printf("status %d\n",status); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1966 | return Py_BuildValue("i",status); |
| 1967 | } |
| 1968 | |
| 1969 | |
| 1970 | /* |
| 1971 | * py_pjsua_init |
| 1972 | */ |
| 1973 | static PyObject *py_pjsua_init(PyObject *pSelf, PyObject *pArgs) |
| 1974 | { |
| 1975 | pj_status_t status; |
| 1976 | config_Object * ua_cfg; |
| 1977 | logging_config_Object * log_cfg; |
| 1978 | media_config_Object * media_cfg; |
| 1979 | pjsua_config cfg_ua; |
| 1980 | pjsua_logging_config cfg_log; |
| 1981 | pjsua_media_config cfg_media; |
| 1982 | unsigned i; |
| 1983 | |
| 1984 | if (!PyArg_ParseTuple(pArgs, "OOO", &ua_cfg, &log_cfg, &media_cfg)) |
| 1985 | { |
| 1986 | return NULL; |
| 1987 | } |
| 1988 | |
| 1989 | pjsua_config_default(&cfg_ua); |
| 1990 | pjsua_logging_config_default(&cfg_log); |
| 1991 | pjsua_media_config_default(&cfg_media); |
| 1992 | cfg_ua.cred_count = ua_cfg->cred_count; |
| 1993 | for (i = 0; i < 4; i++) |
| 1994 | { |
| 1995 | cfg_ua.cred_info[i] = ua_cfg->cred_info[i]; |
| 1996 | } |
| 1997 | cfg_ua.max_calls = ua_cfg->max_calls; |
| 1998 | for (i = 0; i < PJSUA_ACC_MAX_PROXIES; i++) |
| 1999 | { |
| 2000 | cfg_ua.outbound_proxy[i] = ua_cfg->outbound_proxy[i]; |
| 2001 | } |
| 2002 | |
| 2003 | cfg_ua.outbound_proxy_cnt = ua_cfg->outbound_proxy_cnt; |
| 2004 | cfg_ua.thread_cnt = ua_cfg->thread_cnt; |
| 2005 | cfg_ua.user_agent.ptr = PyString_AsString(ua_cfg->user_agent); |
| 2006 | cfg_ua.user_agent.slen = strlen(cfg_ua.user_agent.ptr); |
| 2007 | |
| 2008 | obj_callback = ua_cfg->cb; |
| 2009 | cfg_ua.cb.on_call_state = &cb_on_call_state; |
| 2010 | cfg_ua.cb.on_incoming_call = &cb_on_incoming_call; |
| 2011 | cfg_ua.cb.on_call_media_state = &cb_on_call_media_state; |
| 2012 | cfg_ua.cb.on_call_transfer_request = &cb_on_call_transfer_request; |
| 2013 | cfg_ua.cb.on_call_transfer_status = &cb_on_call_transfer_status; |
| 2014 | cfg_ua.cb.on_call_replace_request = &cb_on_call_replace_request; |
| 2015 | cfg_ua.cb.on_call_replaced = &cb_on_call_replaced; |
| 2016 | cfg_ua.cb.on_reg_state = &cb_on_reg_state; |
| 2017 | cfg_ua.cb.on_buddy_state = &cb_on_buddy_state; |
| 2018 | cfg_ua.cb.on_pager = &cb_on_pager; |
| 2019 | cfg_ua.cb.on_pager_status = &cb_on_pager_status; |
| 2020 | cfg_ua.cb.on_typing = &cb_on_typing; |
| 2021 | |
| 2022 | cfg_log.msg_logging = log_cfg->msg_logging; |
| 2023 | cfg_log.level = log_cfg->level; |
| 2024 | cfg_log.console_level = log_cfg->console_level; |
| 2025 | cfg_log.decor = log_cfg->decor; |
| 2026 | cfg_log.log_filename.ptr = PyString_AsString(log_cfg->log_filename); |
| 2027 | cfg_log.log_filename.slen = strlen(cfg_log.log_filename.ptr); |
| 2028 | Py_XDECREF(obj_logging_init); |
| 2029 | obj_logging_init = log_cfg->cb; |
| 2030 | Py_INCREF(obj_logging_init); |
| 2031 | cfg_log.cb = &cb_logging_init; |
| 2032 | |
| 2033 | |
| 2034 | cfg_media.clock_rate = media_cfg->clock_rate; |
| 2035 | cfg_media.ec_options = media_cfg->ec_options; |
| 2036 | cfg_media.ec_tail_len = media_cfg->ec_tail_len; |
| 2037 | cfg_media.has_ioqueue = media_cfg->has_ioqueue; |
| 2038 | cfg_media.ilbc_mode = media_cfg->ilbc_mode; |
| 2039 | cfg_media.max_media_ports = media_cfg->max_media_ports; |
| 2040 | cfg_media.no_vad = media_cfg->no_vad; |
| 2041 | cfg_media.ptime = media_cfg->ptime; |
| 2042 | cfg_media.quality = media_cfg->quality; |
| 2043 | cfg_media.rx_drop_pct = media_cfg->rx_drop_pct; |
| 2044 | cfg_media.thread_cnt = media_cfg->thread_cnt; |
| 2045 | cfg_media.tx_drop_pct = media_cfg->tx_drop_pct; |
| 2046 | |
| 2047 | status = pjsua_init(&cfg_ua, &cfg_log, &cfg_media); |
| 2048 | return Py_BuildValue("i",status); |
| 2049 | } |
| 2050 | |
| 2051 | |
| 2052 | /* |
| 2053 | * py_pjsua_start |
| 2054 | */ |
| 2055 | static PyObject *py_pjsua_start(PyObject *pSelf, PyObject *pArgs) |
| 2056 | { |
| 2057 | pj_status_t status; |
| 2058 | if (!PyArg_ParseTuple(pArgs, "")) |
| 2059 | { |
| 2060 | return NULL; |
| 2061 | } |
| 2062 | status = pjsua_start(); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2063 | //printf("status %d\n",status); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2064 | return Py_BuildValue("i",status); |
| 2065 | } |
| 2066 | |
| 2067 | |
| 2068 | /* |
| 2069 | * py_pjsua_destroy |
| 2070 | */ |
| 2071 | static PyObject *py_pjsua_destroy(PyObject *pSelf, PyObject *pArgs) |
| 2072 | { |
| 2073 | pj_status_t status; |
| 2074 | if (!PyArg_ParseTuple(pArgs, "")) |
| 2075 | { |
| 2076 | return NULL; |
| 2077 | } |
| 2078 | status = pjsua_destroy(); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2079 | //printf("status %d\n",status); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2080 | return Py_BuildValue("i",status); |
| 2081 | } |
| 2082 | |
| 2083 | |
| 2084 | /* |
| 2085 | * py_pjsua_handle_events |
| 2086 | */ |
| 2087 | static PyObject *py_pjsua_handle_events(PyObject *pSelf, PyObject *pArgs) |
| 2088 | { |
| 2089 | int ret; |
| 2090 | unsigned msec; |
| 2091 | if (!PyArg_ParseTuple(pArgs, "i", &msec)) |
| 2092 | { |
| 2093 | return NULL; |
| 2094 | } |
| 2095 | ret = pjsua_handle_events(msec); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2096 | //printf("return %d\n",ret); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2097 | return Py_BuildValue("i",ret); |
| 2098 | } |
| 2099 | |
| 2100 | |
| 2101 | /* |
| 2102 | * py_pjsua_verify_sip_url |
| 2103 | */ |
| 2104 | static PyObject *py_pjsua_verify_sip_url(PyObject *pSelf, PyObject *pArgs) |
| 2105 | { |
| 2106 | pj_status_t status; |
| 2107 | const char *url; |
| 2108 | if (!PyArg_ParseTuple(pArgs, "s", &url)) |
| 2109 | { |
| 2110 | return NULL; |
| 2111 | } |
| 2112 | status = pjsua_verify_sip_url(url); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2113 | //printf("status %d\n",status); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2114 | return Py_BuildValue("i",status); |
| 2115 | } |
| 2116 | |
| 2117 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2118 | /* |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2119 | * function doc |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2120 | */ |
| 2121 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2122 | static char pjsua_thread_register_doc[] = |
| 2123 | "int py_pjsua.thread_register(string name, int[] desc)"; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2124 | static char pjsua_perror_doc[] = |
| 2125 | "void py_pjsua.perror (string sender, string title, int status) " |
| 2126 | "Display error message for the specified error code. Parameters: " |
| 2127 | "sender: The log sender field; " |
| 2128 | "title: Message title for the error; " |
| 2129 | "status: Status code."; |
| 2130 | |
| 2131 | static char pjsua_create_doc[] = |
| 2132 | "int py_pjsua.create (void) " |
| 2133 | "Instantiate pjsua application. Application " |
| 2134 | "must call this function before calling any other functions, to make sure " |
| 2135 | "that the underlying libraries are properly initialized. Once this " |
| 2136 | "function has returned success, application must call pjsua_destroy() " |
| 2137 | "before quitting."; |
| 2138 | |
| 2139 | static char pjsua_init_doc[] = |
| 2140 | "int py_pjsua.init (py_pjsua.Config ua_cfg, " |
| 2141 | "py_pjsua.Logging_Config log_cfg, py_pjsua.Media_Config media_cfg) " |
| 2142 | "Initialize pjsua with the specified settings. All the settings are " |
| 2143 | "optional, and the default values will be used when the config is not " |
| 2144 | "specified. Parameters: " |
| 2145 | "ua_cfg : User agent configuration; " |
| 2146 | "log_cfg : Optional logging configuration; " |
| 2147 | "media_cfg : Optional media configuration."; |
| 2148 | |
| 2149 | static char pjsua_start_doc[] = |
| 2150 | "int py_pjsua.start (void) " |
| 2151 | "Application is recommended to call this function after all " |
| 2152 | "initialization is done, so that the library can do additional checking " |
| 2153 | "set up additional"; |
| 2154 | |
| 2155 | static char pjsua_destroy_doc[] = |
| 2156 | "int py_pjsua.destroy (void) " |
| 2157 | "Destroy pjsua This function must be called once PJSUA is created. To " |
| 2158 | "make it easier for application, application may call this function " |
| 2159 | "several times with no danger."; |
| 2160 | |
| 2161 | static char pjsua_handle_events_doc[] = |
| 2162 | "int py_pjsua.handle_events (int msec_timeout) " |
| 2163 | "Poll pjsua for events, and if necessary block the caller thread for the " |
| 2164 | "specified maximum interval (in miliseconds) Parameters: " |
| 2165 | "msec_timeout: Maximum time to wait, in miliseconds. " |
| 2166 | "Returns: The number of events that have been handled during the poll. " |
| 2167 | "Negative value indicates error, and application can retrieve the error " |
| 2168 | "as (err = -return_value)."; |
| 2169 | |
| 2170 | static char pjsua_verify_sip_url_doc[] = |
| 2171 | "int py_pjsua.verify_sip_url (string c_url) " |
| 2172 | "Verify that valid SIP url is given Parameters: " |
| 2173 | "c_url: The URL, as NULL terminated string."; |
| 2174 | |
| 2175 | static char pjsua_pool_create_doc[] = |
| 2176 | "py_pjsua.PJ_Pool py_pjsua.pool_create (string name, int init_size, " |
| 2177 | "int increment) " |
| 2178 | "Create memory pool Parameters: " |
| 2179 | "name: Optional pool name; " |
| 2180 | "init_size: Initial size of the pool; " |
| 2181 | "increment: Increment size."; |
| 2182 | |
| 2183 | static char pjsua_get_pjsip_endpt_doc[] = |
| 2184 | "py_pjsua.PJSIP_Endpoint py_pjsua.get_pjsip_endpt (void) " |
| 2185 | "Internal function to get SIP endpoint instance of pjsua, which is needed " |
| 2186 | "for example to register module, create transports, etc. Probably is only " |
| 2187 | "valid after pjsua_init() is called."; |
| 2188 | |
| 2189 | static char pjsua_get_pjmedia_endpt_doc[] = |
| 2190 | "py_pjsua.PJMedia_Endpt py_pjsua.get_pjmedia_endpt (void) " |
| 2191 | "Internal function to get media endpoint instance. Only valid after " |
| 2192 | "pjsua_init() is called."; |
| 2193 | |
| 2194 | static char pjsua_get_pool_factory_doc[] = |
| 2195 | "py_pjsua.PJ_Pool_Factory py_pjsua.get_pool_factory (void) " |
| 2196 | "Internal function to get PJSUA pool factory. Only valid after " |
| 2197 | "pjsua_init() is called."; |
| 2198 | |
| 2199 | static char pjsua_reconfigure_logging_doc[] = |
| 2200 | "int py_pjsua.reconfigure_logging (py_pjsua.Logging_Config c) " |
| 2201 | "Application can call this function at any time (after pjsua_create(), of " |
| 2202 | "course) to change logging settings. Parameters: " |
| 2203 | "c: Logging configuration."; |
| 2204 | |
| 2205 | static char pjsua_logging_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2206 | "py_pjsua.Logging_Config py_pjsua.logging_config_default () " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2207 | "Use this function to initialize logging config."; |
| 2208 | |
| 2209 | static char pjsua_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2210 | "py_pjsua.Config py_pjsua.config_default (). Use this function to " |
| 2211 | "initialize pjsua config. "; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2212 | |
| 2213 | static char pjsua_media_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2214 | "py_pjsua.Media_Config py_pjsua.media_config_default (). " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2215 | "Use this function to initialize media config."; |
| 2216 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2217 | static char pjsua_msg_data_init_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2218 | "py_pjsua.Msg_Data void py_pjsua.msg_data_init () " |
| 2219 | "Initialize message data "; |
| 2220 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2221 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2222 | /* END OF LIB BASE */ |
| 2223 | |
| 2224 | /* LIB TRANSPORT */ |
| 2225 | |
| 2226 | /* |
| 2227 | * stun_config_Object |
| 2228 | * STUN configuration |
| 2229 | */ |
| 2230 | typedef struct |
| 2231 | { |
| 2232 | PyObject_HEAD |
| 2233 | /* Type-specific fields go here. */ |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2234 | PyObject * stun_srv1; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2235 | unsigned stun_port1; |
| 2236 | PyObject * stun_srv2; |
| 2237 | unsigned stun_port2; |
| 2238 | } stun_config_Object; |
| 2239 | |
| 2240 | |
| 2241 | /* |
| 2242 | * stun_config_dealloc |
| 2243 | * deletes a stun config from memory |
| 2244 | */ |
| 2245 | static void stun_config_dealloc(stun_config_Object* self) |
| 2246 | { |
| 2247 | Py_XDECREF(self->stun_srv1); |
| 2248 | Py_XDECREF(self->stun_srv2); |
| 2249 | self->ob_type->tp_free((PyObject*)self); |
| 2250 | } |
| 2251 | |
| 2252 | |
| 2253 | /* |
| 2254 | * stun_config_new |
| 2255 | * constructor for stun_config object |
| 2256 | */ |
| 2257 | static PyObject * stun_config_new(PyTypeObject *type, PyObject *args, |
| 2258 | PyObject *kwds) |
| 2259 | { |
| 2260 | stun_config_Object *self; |
| 2261 | self = (stun_config_Object *)type->tp_alloc(type, 0); |
| 2262 | if (self != NULL) |
| 2263 | { |
| 2264 | self->stun_srv1 = PyString_FromString(""); |
| 2265 | if (self->stun_srv1 == NULL) |
| 2266 | { |
| 2267 | Py_DECREF(self); |
| 2268 | return NULL; |
| 2269 | } |
| 2270 | self->stun_srv2 = PyString_FromString(""); |
| 2271 | if (self->stun_srv2 == NULL) |
| 2272 | { |
| 2273 | Py_DECREF(self); |
| 2274 | return NULL; |
| 2275 | } |
| 2276 | } |
| 2277 | |
| 2278 | return (PyObject *)self; |
| 2279 | } |
| 2280 | |
| 2281 | |
| 2282 | /* |
| 2283 | * stun_config_members |
| 2284 | */ |
| 2285 | static PyMemberDef stun_config_members[] = |
| 2286 | { |
| 2287 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2288 | "stun_port1", T_INT, offsetof(stun_config_Object, stun_port1), 0, |
| 2289 | "The first STUN server IP address or hostname." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2290 | }, |
| 2291 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2292 | "stun_port2", T_INT, offsetof(stun_config_Object, stun_port2), 0, |
| 2293 | "Port number of the second STUN server. " |
| 2294 | "If zero, default STUN port will be used." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2295 | }, |
| 2296 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2297 | "stun_srv1", T_OBJECT_EX, |
| 2298 | offsetof(stun_config_Object, stun_srv1), 0, |
| 2299 | "The first STUN server IP address or hostname" |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2300 | }, |
| 2301 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2302 | "stun_srv2", T_OBJECT_EX, |
| 2303 | offsetof(stun_config_Object, stun_srv2), 0, |
| 2304 | "Optional second STUN server IP address or hostname, for which the " |
| 2305 | "result of the mapping request will be compared to. If the value " |
| 2306 | "is empty, only one STUN server will be used" |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2307 | }, |
| 2308 | {NULL} /* Sentinel */ |
| 2309 | }; |
| 2310 | |
| 2311 | |
| 2312 | |
| 2313 | |
| 2314 | /* |
| 2315 | * stun_config_Type |
| 2316 | */ |
| 2317 | static PyTypeObject stun_config_Type = |
| 2318 | { |
| 2319 | PyObject_HEAD_INIT(NULL) |
| 2320 | 0, /*ob_size*/ |
| 2321 | "py_pjsua.STUN_Config", /*tp_name*/ |
| 2322 | sizeof(stun_config_Object), /*tp_basicsize*/ |
| 2323 | 0, /*tp_itemsize*/ |
| 2324 | (destructor)stun_config_dealloc,/*tp_dealloc*/ |
| 2325 | 0, /*tp_print*/ |
| 2326 | 0, /*tp_getattr*/ |
| 2327 | 0, /*tp_setattr*/ |
| 2328 | 0, /*tp_compare*/ |
| 2329 | 0, /*tp_repr*/ |
| 2330 | 0, /*tp_as_number*/ |
| 2331 | 0, /*tp_as_sequence*/ |
| 2332 | 0, /*tp_as_mapping*/ |
| 2333 | 0, /*tp_hash */ |
| 2334 | 0, /*tp_call*/ |
| 2335 | 0, /*tp_str*/ |
| 2336 | 0, /*tp_getattro*/ |
| 2337 | 0, /*tp_setattro*/ |
| 2338 | 0, /*tp_as_buffer*/ |
| 2339 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2340 | "STUN Config objects", /* tp_doc */ |
| 2341 | 0, /* tp_traverse */ |
| 2342 | 0, /* tp_clear */ |
| 2343 | 0, /* tp_richcompare */ |
| 2344 | 0, /* tp_weaklistoffset */ |
| 2345 | 0, /* tp_iter */ |
| 2346 | 0, /* tp_iternext */ |
| 2347 | 0, /* tp_methods */ |
| 2348 | stun_config_members, /* tp_members */ |
| 2349 | 0, /* tp_getset */ |
| 2350 | 0, /* tp_base */ |
| 2351 | 0, /* tp_dict */ |
| 2352 | 0, /* tp_descr_get */ |
| 2353 | 0, /* tp_descr_set */ |
| 2354 | 0, /* tp_dictoffset */ |
| 2355 | 0, /* tp_init */ |
| 2356 | 0, /* tp_alloc */ |
| 2357 | stun_config_new, /* tp_new */ |
| 2358 | |
| 2359 | }; |
| 2360 | |
| 2361 | /* |
| 2362 | * transport_config_Object |
| 2363 | * Transport configuration for creating UDP transports for both SIP |
| 2364 | * and media. |
| 2365 | */ |
| 2366 | typedef struct |
| 2367 | { |
| 2368 | PyObject_HEAD |
| 2369 | /* Type-specific fields go here. */ |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2370 | unsigned port; |
| 2371 | PyObject * public_addr; |
| 2372 | PyObject * bound_addr; |
| 2373 | int use_stun; |
| 2374 | stun_config_Object * stun_config; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2375 | } transport_config_Object; |
| 2376 | |
| 2377 | |
| 2378 | /* |
| 2379 | * transport_config_dealloc |
| 2380 | * deletes a transport config from memory |
| 2381 | */ |
| 2382 | static void transport_config_dealloc(transport_config_Object* self) |
| 2383 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2384 | Py_XDECREF(self->public_addr); |
| 2385 | Py_XDECREF(self->bound_addr); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2386 | Py_XDECREF(self->stun_config); |
| 2387 | self->ob_type->tp_free((PyObject*)self); |
| 2388 | } |
| 2389 | |
| 2390 | |
| 2391 | /* |
| 2392 | * transport_config_new |
| 2393 | * constructor for transport_config object |
| 2394 | */ |
| 2395 | static PyObject * transport_config_new(PyTypeObject *type, PyObject *args, |
| 2396 | PyObject *kwds) |
| 2397 | { |
| 2398 | transport_config_Object *self; |
| 2399 | |
| 2400 | self = (transport_config_Object *)type->tp_alloc(type, 0); |
| 2401 | if (self != NULL) |
| 2402 | { |
| 2403 | self->public_addr = PyString_FromString(""); |
| 2404 | if (self->public_addr == NULL) |
| 2405 | { |
| 2406 | Py_DECREF(self); |
| 2407 | return NULL; |
| 2408 | } |
| 2409 | self->bound_addr = PyString_FromString(""); |
| 2410 | if (self->bound_addr == NULL) |
| 2411 | { |
| 2412 | Py_DECREF(self); |
| 2413 | return NULL; |
| 2414 | } |
| 2415 | self->stun_config = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2416 | (stun_config_Object *)stun_config_new(&stun_config_Type,NULL,NULL); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2417 | if (self->stun_config == NULL) |
| 2418 | { |
| 2419 | Py_DECREF(self); |
| 2420 | return NULL; |
| 2421 | } |
| 2422 | |
| 2423 | } |
| 2424 | |
| 2425 | return (PyObject *)self; |
| 2426 | } |
| 2427 | |
| 2428 | |
| 2429 | /* |
| 2430 | * transport_config_members |
| 2431 | */ |
| 2432 | static PyMemberDef transport_config_members[] = |
| 2433 | { |
| 2434 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2435 | "port", T_INT, offsetof(transport_config_Object, port), 0, |
| 2436 | "UDP port number to bind locally. This setting MUST be specified " |
| 2437 | "even when default port is desired. If the value is zero, the " |
| 2438 | "transport will be bound to any available port, and application " |
| 2439 | "can query the port by querying the transport info." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2440 | }, |
| 2441 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2442 | "public_addr", T_OBJECT_EX, |
| 2443 | offsetof(transport_config_Object, public_addr), 0, |
| 2444 | "Optional address to advertise as the address of this transport. " |
| 2445 | "Application can specify any address or hostname for this field, " |
| 2446 | "for example it can point to one of the interface address in the " |
| 2447 | "system, or it can point to the public address of a NAT router " |
| 2448 | "where port mappings have been configured for the application." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2449 | }, |
| 2450 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2451 | "bound_addr", T_OBJECT_EX, |
| 2452 | offsetof(transport_config_Object, bound_addr), 0, |
| 2453 | "Optional address where the socket should be bound to. This option " |
| 2454 | "SHOULD only be used to selectively bind the socket to particular " |
| 2455 | "interface (instead of 0.0.0.0), and SHOULD NOT be used to set the " |
| 2456 | "published address of a transport (the public_addr field should be " |
| 2457 | "used for that purpose)." |
| 2458 | }, |
| 2459 | { |
| 2460 | "use_stun", T_INT, |
| 2461 | offsetof(transport_config_Object, use_stun), 0, |
| 2462 | "Flag to indicate whether STUN should be used." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2463 | }, |
| 2464 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2465 | "stun_config", T_OBJECT_EX, |
| 2466 | offsetof(transport_config_Object, stun_config), 0, |
| 2467 | "STUN configuration, must be specified when STUN is used." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2468 | }, |
| 2469 | {NULL} /* Sentinel */ |
| 2470 | }; |
| 2471 | |
| 2472 | |
| 2473 | |
| 2474 | |
| 2475 | /* |
| 2476 | * transport_config_Type |
| 2477 | */ |
| 2478 | static PyTypeObject transport_config_Type = |
| 2479 | { |
| 2480 | PyObject_HEAD_INIT(NULL) |
| 2481 | 0, /*ob_size*/ |
| 2482 | "py_pjsua.Transport_Config", /*tp_name*/ |
| 2483 | sizeof(transport_config_Object), /*tp_basicsize*/ |
| 2484 | 0, /*tp_itemsize*/ |
| 2485 | (destructor)transport_config_dealloc,/*tp_dealloc*/ |
| 2486 | 0, /*tp_print*/ |
| 2487 | 0, /*tp_getattr*/ |
| 2488 | 0, /*tp_setattr*/ |
| 2489 | 0, /*tp_compare*/ |
| 2490 | 0, /*tp_repr*/ |
| 2491 | 0, /*tp_as_number*/ |
| 2492 | 0, /*tp_as_sequence*/ |
| 2493 | 0, /*tp_as_mapping*/ |
| 2494 | 0, /*tp_hash */ |
| 2495 | 0, /*tp_call*/ |
| 2496 | 0, /*tp_str*/ |
| 2497 | 0, /*tp_getattro*/ |
| 2498 | 0, /*tp_setattro*/ |
| 2499 | 0, /*tp_as_buffer*/ |
| 2500 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2501 | "Transport Config objects", /* tp_doc */ |
| 2502 | 0, /* tp_traverse */ |
| 2503 | 0, /* tp_clear */ |
| 2504 | 0, /* tp_richcompare */ |
| 2505 | 0, /* tp_weaklistoffset */ |
| 2506 | 0, /* tp_iter */ |
| 2507 | 0, /* tp_iternext */ |
| 2508 | 0, /* tp_methods */ |
| 2509 | transport_config_members, /* tp_members */ |
| 2510 | 0, /* tp_getset */ |
| 2511 | 0, /* tp_base */ |
| 2512 | 0, /* tp_dict */ |
| 2513 | 0, /* tp_descr_get */ |
| 2514 | 0, /* tp_descr_set */ |
| 2515 | 0, /* tp_dictoffset */ |
| 2516 | 0, /* tp_init */ |
| 2517 | 0, /* tp_alloc */ |
| 2518 | transport_config_new, /* tp_new */ |
| 2519 | |
| 2520 | }; |
| 2521 | |
| 2522 | /* |
| 2523 | * sockaddr_Object |
| 2524 | * C/Python wrapper for sockaddr object |
| 2525 | */ |
| 2526 | typedef struct |
| 2527 | { |
| 2528 | PyObject_HEAD |
| 2529 | /* Type-specific fields go here. */ |
| 2530 | #if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 |
| 2531 | pj_uint8_t sa_zero_len; |
| 2532 | pj_uint8_t sa_family; |
| 2533 | #else |
| 2534 | pj_uint16_t sa_family; /**< Common data: address family. */ |
| 2535 | #endif |
| 2536 | PyObject * sa_data; /**< Address data. */ |
| 2537 | } sockaddr_Object; |
| 2538 | |
| 2539 | /* |
| 2540 | * sockaddr_dealloc |
| 2541 | * deletes a sockaddr from memory |
| 2542 | */ |
| 2543 | static void sockaddr_dealloc(sockaddr_Object* self) |
| 2544 | { |
| 2545 | Py_XDECREF(self->sa_data); |
| 2546 | self->ob_type->tp_free((PyObject*)self); |
| 2547 | } |
| 2548 | |
| 2549 | |
| 2550 | /* |
| 2551 | * sockaddr_new |
| 2552 | * constructor for sockaddr object |
| 2553 | */ |
| 2554 | static PyObject * sockaddr_new(PyTypeObject *type, PyObject *args, |
| 2555 | PyObject *kwds) |
| 2556 | { |
| 2557 | sockaddr_Object *self; |
| 2558 | |
| 2559 | self = (sockaddr_Object *)type->tp_alloc(type, 0); |
| 2560 | if (self != NULL) |
| 2561 | { |
| 2562 | self->sa_data = PyString_FromString(""); |
| 2563 | if (self->sa_data == NULL) |
| 2564 | { |
| 2565 | Py_DECREF(self); |
| 2566 | return NULL; |
| 2567 | } |
| 2568 | |
| 2569 | } |
| 2570 | |
| 2571 | return (PyObject *)self; |
| 2572 | } |
| 2573 | |
| 2574 | |
| 2575 | /* |
| 2576 | * sockaddr_members |
| 2577 | * declares attributes accessible from both C and Python for sockaddr object |
| 2578 | */ |
| 2579 | static PyMemberDef sockaddr_members[] = |
| 2580 | { |
| 2581 | #if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 |
| 2582 | { |
| 2583 | "sa_zero_len", T_INT, offsetof(sockaddr_Object, sa_zero_len), 0, |
| 2584 | "" |
| 2585 | }, |
| 2586 | { |
| 2587 | "sa_family", T_INT, |
| 2588 | offsetof(sockaddr_Object, sa_family), 0, |
| 2589 | "Common data: address family." |
| 2590 | }, |
| 2591 | #else |
| 2592 | { |
| 2593 | "sa_family", T_INT, |
| 2594 | offsetof(sockaddr_Object, sa_family), 0, |
| 2595 | "Common data: address family." |
| 2596 | }, |
| 2597 | #endif |
| 2598 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2599 | "sa_data", T_OBJECT_EX, |
| 2600 | offsetof(sockaddr_Object, sa_data), 0, |
| 2601 | "Address data" |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2602 | }, |
| 2603 | {NULL} /* Sentinel */ |
| 2604 | }; |
| 2605 | |
| 2606 | |
| 2607 | /* |
| 2608 | * sockaddr_Type |
| 2609 | */ |
| 2610 | static PyTypeObject sockaddr_Type = |
| 2611 | { |
| 2612 | PyObject_HEAD_INIT(NULL) |
| 2613 | 0, /*ob_size*/ |
| 2614 | "py_pjsua.Sockaddr", /*tp_name*/ |
| 2615 | sizeof(sockaddr_Object), /*tp_basicsize*/ |
| 2616 | 0, /*tp_itemsize*/ |
| 2617 | (destructor)sockaddr_dealloc,/*tp_dealloc*/ |
| 2618 | 0, /*tp_print*/ |
| 2619 | 0, /*tp_getattr*/ |
| 2620 | 0, /*tp_setattr*/ |
| 2621 | 0, /*tp_compare*/ |
| 2622 | 0, /*tp_repr*/ |
| 2623 | 0, /*tp_as_number*/ |
| 2624 | 0, /*tp_as_sequence*/ |
| 2625 | 0, /*tp_as_mapping*/ |
| 2626 | 0, /*tp_hash */ |
| 2627 | 0, /*tp_call*/ |
| 2628 | 0, /*tp_str*/ |
| 2629 | 0, /*tp_getattro*/ |
| 2630 | 0, /*tp_setattro*/ |
| 2631 | 0, /*tp_as_buffer*/ |
| 2632 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2633 | "Sockaddr objects", /*tp_doc*/ |
| 2634 | 0, /*tp_traverse*/ |
| 2635 | 0, /*tp_clear*/ |
| 2636 | 0, /*tp_richcompare*/ |
| 2637 | 0, /* tp_weaklistoffset */ |
| 2638 | 0, /* tp_iter */ |
| 2639 | 0, /* tp_iternext */ |
| 2640 | 0, /* tp_methods */ |
| 2641 | sockaddr_members, /* tp_members */ |
| 2642 | 0, /* tp_getset */ |
| 2643 | 0, /* tp_base */ |
| 2644 | 0, /* tp_dict */ |
| 2645 | 0, /* tp_descr_get */ |
| 2646 | 0, /* tp_descr_set */ |
| 2647 | 0, /* tp_dictoffset */ |
| 2648 | 0, /* tp_init */ |
| 2649 | 0, /* tp_alloc */ |
| 2650 | sockaddr_new, /* tp_new */ |
| 2651 | }; |
| 2652 | |
| 2653 | /* |
| 2654 | * host_port_Object |
| 2655 | * C/Python wrapper for host_port object |
| 2656 | */ |
| 2657 | typedef struct |
| 2658 | { |
| 2659 | PyObject_HEAD |
| 2660 | /* Type-specific fields go here. */ |
| 2661 | PyObject * host; |
| 2662 | int port; |
| 2663 | } host_port_Object; |
| 2664 | |
| 2665 | /* |
| 2666 | * host_port_dealloc |
| 2667 | * deletes a host_port from memory |
| 2668 | */ |
| 2669 | static void host_port_dealloc(host_port_Object* self) |
| 2670 | { |
| 2671 | Py_XDECREF(self->host); |
| 2672 | self->ob_type->tp_free((PyObject*)self); |
| 2673 | } |
| 2674 | |
| 2675 | |
| 2676 | /* |
| 2677 | * host_port_new |
| 2678 | * constructor for host_port object |
| 2679 | */ |
| 2680 | static PyObject * host_port_new(PyTypeObject *type, PyObject *args, |
| 2681 | PyObject *kwds) |
| 2682 | { |
| 2683 | host_port_Object *self; |
| 2684 | |
| 2685 | self = (host_port_Object *)type->tp_alloc(type, 0); |
| 2686 | if (self != NULL) |
| 2687 | { |
| 2688 | self->host = PyString_FromString(""); |
| 2689 | if (self->host == NULL) |
| 2690 | { |
| 2691 | Py_DECREF(self); |
| 2692 | return NULL; |
| 2693 | } |
| 2694 | |
| 2695 | } |
| 2696 | |
| 2697 | return (PyObject *)self; |
| 2698 | } |
| 2699 | |
| 2700 | |
| 2701 | /* |
| 2702 | * host_port_members |
| 2703 | * declares attributes accessible from both C and Python for host_port object |
| 2704 | */ |
| 2705 | static PyMemberDef host_port_members[] = |
| 2706 | { |
| 2707 | { |
| 2708 | "port", T_INT, |
| 2709 | offsetof(host_port_Object, port), 0, |
| 2710 | "Port number." |
| 2711 | }, |
| 2712 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2713 | "host", T_OBJECT_EX, |
| 2714 | offsetof(host_port_Object, host), 0, |
| 2715 | "Host part or IP address." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2716 | }, |
| 2717 | {NULL} /* Sentinel */ |
| 2718 | }; |
| 2719 | |
| 2720 | |
| 2721 | /* |
| 2722 | * host_port_Type |
| 2723 | */ |
| 2724 | static PyTypeObject host_port_Type = |
| 2725 | { |
| 2726 | PyObject_HEAD_INIT(NULL) |
| 2727 | 0, /*ob_size*/ |
| 2728 | "py_pjsua.Host_Port", /*tp_name*/ |
| 2729 | sizeof(host_port_Object), /*tp_basicsize*/ |
| 2730 | 0, /*tp_itemsize*/ |
| 2731 | (destructor)host_port_dealloc,/*tp_dealloc*/ |
| 2732 | 0, /*tp_print*/ |
| 2733 | 0, /*tp_getattr*/ |
| 2734 | 0, /*tp_setattr*/ |
| 2735 | 0, /*tp_compare*/ |
| 2736 | 0, /*tp_repr*/ |
| 2737 | 0, /*tp_as_number*/ |
| 2738 | 0, /*tp_as_sequence*/ |
| 2739 | 0, /*tp_as_mapping*/ |
| 2740 | 0, /*tp_hash */ |
| 2741 | 0, /*tp_call*/ |
| 2742 | 0, /*tp_str*/ |
| 2743 | 0, /*tp_getattro*/ |
| 2744 | 0, /*tp_setattro*/ |
| 2745 | 0, /*tp_as_buffer*/ |
| 2746 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2747 | "Host_port objects", /*tp_doc*/ |
| 2748 | 0, /*tp_traverse*/ |
| 2749 | 0, /*tp_clear*/ |
| 2750 | 0, /*tp_richcompare*/ |
| 2751 | 0, /* tp_weaklistoffset */ |
| 2752 | 0, /* tp_iter */ |
| 2753 | 0, /* tp_iternext */ |
| 2754 | 0, /* tp_methods */ |
| 2755 | host_port_members, /* tp_members */ |
| 2756 | 0, /* tp_getset */ |
| 2757 | 0, /* tp_base */ |
| 2758 | 0, /* tp_dict */ |
| 2759 | 0, /* tp_descr_get */ |
| 2760 | 0, /* tp_descr_set */ |
| 2761 | 0, /* tp_dictoffset */ |
| 2762 | 0, /* tp_init */ |
| 2763 | 0, /* tp_alloc */ |
| 2764 | host_port_new, /* tp_new */ |
| 2765 | }; |
| 2766 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2767 | |
| 2768 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2769 | |
| 2770 | /* |
| 2771 | * transport_info_Object |
| 2772 | * Transport info |
| 2773 | */ |
| 2774 | typedef struct |
| 2775 | { |
| 2776 | PyObject_HEAD |
| 2777 | /* Type-specific fields go here. */ |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2778 | int id; |
| 2779 | int type; |
| 2780 | PyObject * type_name; |
| 2781 | PyObject * info; |
| 2782 | unsigned flag; |
| 2783 | unsigned addr_len; |
| 2784 | sockaddr_Object * local_addr; |
| 2785 | host_port_Object * local_name; |
| 2786 | unsigned usage_count; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2787 | } transport_info_Object; |
| 2788 | |
| 2789 | |
| 2790 | /* |
| 2791 | * transport_info_dealloc |
| 2792 | * deletes a transport info from memory |
| 2793 | */ |
| 2794 | static void transport_info_dealloc(transport_info_Object* self) |
| 2795 | { |
| 2796 | Py_XDECREF(self->type_name); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2797 | Py_XDECREF(self->info); |
| 2798 | Py_XDECREF(self->local_addr); |
| 2799 | Py_XDECREF(self->local_name); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2800 | self->ob_type->tp_free((PyObject*)self); |
| 2801 | } |
| 2802 | |
| 2803 | |
| 2804 | /* |
| 2805 | * transport_info_new |
| 2806 | * constructor for transport_info object |
| 2807 | */ |
| 2808 | static PyObject * transport_info_new(PyTypeObject *type, PyObject *args, |
| 2809 | PyObject *kwds) |
| 2810 | { |
| 2811 | transport_info_Object *self; |
| 2812 | |
| 2813 | self = (transport_info_Object *)type->tp_alloc(type, 0); |
| 2814 | if (self != NULL) |
| 2815 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2816 | self->type_name = PyString_FromString(""); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2817 | if (self->type_name == NULL) |
| 2818 | { |
| 2819 | Py_DECREF(self); |
| 2820 | return NULL; |
| 2821 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2822 | self->info = PyString_FromString(""); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2823 | if (self->info == NULL) |
| 2824 | { |
| 2825 | Py_DECREF(self); |
| 2826 | return NULL; |
| 2827 | } |
| 2828 | self->local_addr = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2829 | (sockaddr_Object *)sockaddr_new(&sockaddr_Type,NULL,NULL); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2830 | if (self->local_addr == NULL) |
| 2831 | { |
| 2832 | Py_DECREF(self); |
| 2833 | return NULL; |
| 2834 | } |
| 2835 | self->local_name = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2836 | (host_port_Object *)host_port_new(&host_port_Type,NULL,NULL); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2837 | if (self->local_name == NULL) |
| 2838 | { |
| 2839 | Py_DECREF(self); |
| 2840 | return NULL; |
| 2841 | } |
| 2842 | } |
| 2843 | |
| 2844 | return (PyObject *)self; |
| 2845 | } |
| 2846 | |
| 2847 | |
| 2848 | /* |
| 2849 | * transport_info_members |
| 2850 | */ |
| 2851 | static PyMemberDef transport_info_members[] = |
| 2852 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2853 | { |
| 2854 | "id", T_INT, offsetof(transport_info_Object, id), 0, |
| 2855 | "PJSUA transport identification." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2856 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2857 | { |
| 2858 | "type", T_INT, offsetof(transport_info_Object, id), 0, |
| 2859 | "Transport type." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2860 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2861 | { |
| 2862 | "type_name", T_OBJECT_EX, |
| 2863 | offsetof(transport_info_Object, type_name), 0, |
| 2864 | "Transport type name." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2865 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2866 | { |
| 2867 | "info", T_OBJECT_EX, |
| 2868 | offsetof(transport_info_Object, info), 0, |
| 2869 | "Transport string info/description." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2870 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2871 | { |
| 2872 | "flag", T_INT, offsetof(transport_info_Object, flag), 0, |
| 2873 | "Transport flag (see ##pjsip_transport_flags_e)." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2874 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2875 | { |
| 2876 | "addr_len", T_INT, offsetof(transport_info_Object, addr_len), 0, |
| 2877 | "Local address length." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2878 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2879 | { |
| 2880 | "local_addr", T_OBJECT_EX, |
| 2881 | offsetof(transport_info_Object, local_addr), 0, |
| 2882 | "Local/bound address." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2883 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2884 | { |
| 2885 | "local_name", T_OBJECT_EX, |
| 2886 | offsetof(transport_info_Object, local_name), 0, |
| 2887 | "Published address (or transport address name)." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2888 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2889 | { |
| 2890 | "usage_count", T_INT, offsetof(transport_info_Object, usage_count), 0, |
| 2891 | "Current number of objects currently referencing this transport." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2892 | }, |
| 2893 | {NULL} /* Sentinel */ |
| 2894 | }; |
| 2895 | |
| 2896 | |
| 2897 | |
| 2898 | |
| 2899 | /* |
| 2900 | * transport_info_Type |
| 2901 | */ |
| 2902 | static PyTypeObject transport_info_Type = |
| 2903 | { |
| 2904 | PyObject_HEAD_INIT(NULL) |
| 2905 | 0, /*ob_size*/ |
| 2906 | "py_pjsua.Transport_Info", /*tp_name*/ |
| 2907 | sizeof(transport_info_Object), /*tp_basicsize*/ |
| 2908 | 0, /*tp_itemsize*/ |
| 2909 | (destructor)transport_info_dealloc,/*tp_dealloc*/ |
| 2910 | 0, /*tp_print*/ |
| 2911 | 0, /*tp_getattr*/ |
| 2912 | 0, /*tp_setattr*/ |
| 2913 | 0, /*tp_compare*/ |
| 2914 | 0, /*tp_repr*/ |
| 2915 | 0, /*tp_as_number*/ |
| 2916 | 0, /*tp_as_sequence*/ |
| 2917 | 0, /*tp_as_mapping*/ |
| 2918 | 0, /*tp_hash */ |
| 2919 | 0, /*tp_call*/ |
| 2920 | 0, /*tp_str*/ |
| 2921 | 0, /*tp_getattro*/ |
| 2922 | 0, /*tp_setattro*/ |
| 2923 | 0, /*tp_as_buffer*/ |
| 2924 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2925 | "Transport Info objects", /* tp_doc */ |
| 2926 | 0, /* tp_traverse */ |
| 2927 | 0, /* tp_clear */ |
| 2928 | 0, /* tp_richcompare */ |
| 2929 | 0, /* tp_weaklistoffset */ |
| 2930 | 0, /* tp_iter */ |
| 2931 | 0, /* tp_iternext */ |
| 2932 | 0, /* tp_methods */ |
| 2933 | transport_info_members, /* tp_members */ |
| 2934 | 0, /* tp_getset */ |
| 2935 | 0, /* tp_base */ |
| 2936 | 0, /* tp_dict */ |
| 2937 | 0, /* tp_descr_get */ |
| 2938 | 0, /* tp_descr_set */ |
| 2939 | 0, /* tp_dictoffset */ |
| 2940 | 0, /* tp_init */ |
| 2941 | 0, /* tp_alloc */ |
| 2942 | transport_info_new, /* tp_new */ |
| 2943 | |
| 2944 | }; |
| 2945 | |
| 2946 | /* |
| 2947 | * pjsip_transport_Object |
| 2948 | * C/python typewrapper for pjsip_transport |
| 2949 | */ |
| 2950 | typedef struct |
| 2951 | { |
| 2952 | PyObject_HEAD |
| 2953 | /* Type-specific fields go here. */ |
| 2954 | pjsip_transport *tp; |
| 2955 | } pjsip_transport_Object; |
| 2956 | |
| 2957 | |
| 2958 | /* |
| 2959 | * pjsip_transport_Type |
| 2960 | */ |
| 2961 | static PyTypeObject pjsip_transport_Type = |
| 2962 | { |
| 2963 | PyObject_HEAD_INIT(NULL) |
| 2964 | 0, /*ob_size*/ |
| 2965 | "py_pjsua.PJSIP_Transport", /*tp_name*/ |
| 2966 | sizeof(pjsip_transport_Object), /*tp_basicsize*/ |
| 2967 | 0, /*tp_itemsize*/ |
| 2968 | 0, /*tp_dealloc*/ |
| 2969 | 0, /*tp_print*/ |
| 2970 | 0, /*tp_getattr*/ |
| 2971 | 0, /*tp_setattr*/ |
| 2972 | 0, /*tp_compare*/ |
| 2973 | 0, /*tp_repr*/ |
| 2974 | 0, /*tp_as_number*/ |
| 2975 | 0, /*tp_as_sequence*/ |
| 2976 | 0, /*tp_as_mapping*/ |
| 2977 | 0, /*tp_hash */ |
| 2978 | 0, /*tp_call*/ |
| 2979 | 0, /*tp_str*/ |
| 2980 | 0, /*tp_getattro*/ |
| 2981 | 0, /*tp_setattro*/ |
| 2982 | 0, /*tp_as_buffer*/ |
| 2983 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2984 | "pjsip_transport objects", /*tp_doc*/ |
| 2985 | }; |
| 2986 | |
| 2987 | |
| 2988 | /* |
| 2989 | * py_pjsua_stun_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2990 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2991 | */ |
| 2992 | static PyObject *py_pjsua_stun_config_default(PyObject *pSelf, PyObject *pArgs) |
| 2993 | { |
| 2994 | stun_config_Object *obj; |
| 2995 | pjsua_stun_config cfg; |
| 2996 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2997 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2998 | { |
| 2999 | return NULL; |
| 3000 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3001 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3002 | pjsua_stun_config_default(&cfg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3003 | obj = (stun_config_Object *)stun_config_new(&stun_config_Type, NULL, NULL); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3004 | obj->stun_port1 = cfg.stun_port1; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3005 | obj->stun_port2 = cfg.stun_port2; |
| 3006 | Py_XDECREF(obj->stun_srv1); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3007 | obj->stun_srv1 = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3008 | PyString_FromStringAndSize(cfg.stun_srv1.ptr, cfg.stun_srv1.slen); |
| 3009 | Py_XDECREF(obj->stun_srv2); |
| 3010 | obj->stun_srv2 = |
| 3011 | PyString_FromStringAndSize(cfg.stun_srv2.ptr, cfg.stun_srv2.slen); |
| 3012 | return (PyObject *)obj; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3013 | } |
| 3014 | |
| 3015 | /* |
| 3016 | * py_pjsua_transport_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3017 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3018 | */ |
| 3019 | static PyObject *py_pjsua_transport_config_default |
| 3020 | (PyObject *pSelf, PyObject *pArgs) |
| 3021 | { |
| 3022 | transport_config_Object *obj; |
| 3023 | pjsua_transport_config cfg; |
| 3024 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3025 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3026 | { |
| 3027 | return NULL; |
| 3028 | } |
| 3029 | pjsua_transport_config_default(&cfg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3030 | obj = (transport_config_Object *)transport_config_new |
| 3031 | (&transport_config_Type,NULL,NULL); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3032 | obj->public_addr = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3033 | PyString_FromStringAndSize(cfg.public_addr.ptr, cfg.public_addr.slen); |
| 3034 | obj->bound_addr = |
| 3035 | PyString_FromStringAndSize(cfg.bound_addr.ptr, cfg.bound_addr.slen); |
| 3036 | obj->port = cfg.port; |
| 3037 | obj->use_stun = cfg.use_stun; |
| 3038 | Py_XDECREF(obj->stun_config); |
| 3039 | obj->stun_config = |
| 3040 | (stun_config_Object *)stun_config_new(&stun_config_Type, NULL, NULL); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3041 | obj->stun_config->stun_port1 = cfg.stun_config.stun_port1; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3042 | obj->stun_config->stun_port2 = cfg.stun_config.stun_port2; |
| 3043 | Py_XDECREF(obj->stun_config->stun_srv1); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3044 | obj->stun_config->stun_srv1 = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3045 | PyString_FromStringAndSize(cfg.stun_config.stun_srv1.ptr, |
| 3046 | cfg.stun_config.stun_srv1.slen); |
| 3047 | Py_XDECREF(obj->stun_config->stun_srv2); |
| 3048 | obj->stun_config->stun_srv2 = |
| 3049 | PyString_FromStringAndSize(cfg.stun_config.stun_srv2.ptr, |
| 3050 | cfg.stun_config.stun_srv2.slen); |
| 3051 | return (PyObject *)obj; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3052 | } |
| 3053 | |
| 3054 | /* |
| 3055 | * py_pjsua_normalize_stun_config |
| 3056 | */ |
| 3057 | static PyObject *py_pjsua_normalize_stun_config |
| 3058 | (PyObject *pSelf, PyObject *pArgs) |
| 3059 | { |
| 3060 | stun_config_Object *obj; |
| 3061 | pjsua_stun_config *cfg; |
| 3062 | |
| 3063 | if (!PyArg_ParseTuple(pArgs, "O", &obj)) |
| 3064 | { |
| 3065 | return NULL; |
| 3066 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3067 | cfg = (pjsua_stun_config *)malloc(sizeof(pjsua_stun_config)); |
| 3068 | cfg->stun_port1 = obj->stun_port1; |
| 3069 | cfg->stun_port2 = obj->stun_port2; |
| 3070 | cfg->stun_srv1.ptr = PyString_AsString(obj->stun_srv1); |
| 3071 | cfg->stun_srv1.slen = strlen(PyString_AsString(obj->stun_srv1)); |
| 3072 | cfg->stun_srv2.ptr = PyString_AsString(obj->stun_srv2); |
| 3073 | cfg->stun_srv2.slen = strlen(PyString_AsString(obj->stun_srv2)); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3074 | pjsua_normalize_stun_config(cfg); |
| 3075 | obj->stun_port1 = cfg->stun_port1; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3076 | obj->stun_port2 = cfg->stun_port2; |
| 3077 | Py_XDECREF(obj->stun_srv1); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3078 | obj->stun_srv1 = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3079 | PyString_FromStringAndSize(cfg->stun_srv1.ptr, cfg->stun_srv1.slen); |
| 3080 | Py_XDECREF(obj->stun_srv2); |
| 3081 | obj->stun_srv2 = |
| 3082 | PyString_FromStringAndSize(cfg->stun_srv2.ptr, cfg->stun_srv2.slen); |
| 3083 | free(cfg); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3084 | Py_INCREF(Py_None); |
| 3085 | return Py_None; |
| 3086 | } |
| 3087 | |
| 3088 | /* |
| 3089 | * py_pjsua_transport_create |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3090 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3091 | */ |
| 3092 | static PyObject *py_pjsua_transport_create(PyObject *pSelf, PyObject *pArgs) |
| 3093 | { |
| 3094 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3095 | int type; |
| 3096 | |
| 3097 | transport_config_Object *obj; |
| 3098 | pjsua_transport_config cfg; |
| 3099 | pjsua_transport_id id; |
| 3100 | if (!PyArg_ParseTuple(pArgs, "iO", &type, &obj)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3101 | { |
| 3102 | return NULL; |
| 3103 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3104 | cfg.public_addr.ptr = PyString_AsString(obj->public_addr); |
| 3105 | cfg.public_addr.slen = strlen(PyString_AsString(obj->public_addr)); |
| 3106 | cfg.bound_addr.ptr = PyString_AsString(obj->bound_addr); |
| 3107 | cfg.bound_addr.slen = strlen(PyString_AsString(obj->bound_addr)); |
| 3108 | cfg.port = obj->port; |
| 3109 | cfg.use_stun = obj->use_stun; |
| 3110 | cfg.stun_config.stun_port1 = obj->stun_config->stun_port1; |
| 3111 | cfg.stun_config.stun_port2 = obj->stun_config->stun_port2; |
| 3112 | cfg.stun_config.stun_srv1.ptr = |
| 3113 | PyString_AsString(obj->stun_config->stun_srv1); |
| 3114 | cfg.stun_config.stun_srv1.slen = |
| 3115 | strlen(PyString_AsString(obj->stun_config->stun_srv1)); |
| 3116 | cfg.stun_config.stun_srv2.ptr = |
| 3117 | PyString_AsString(obj->stun_config->stun_srv2); |
| 3118 | cfg.stun_config.stun_srv2.slen = |
| 3119 | strlen(PyString_AsString(obj->stun_config->stun_srv2)); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3120 | status = pjsua_transport_create(type, &cfg, &id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3121 | |
| 3122 | |
| 3123 | return Py_BuildValue("ii",status,id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3124 | } |
| 3125 | |
| 3126 | /* |
| 3127 | * py_pjsua_transport_register |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3128 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3129 | */ |
| 3130 | static PyObject *py_pjsua_transport_register(PyObject *pSelf, PyObject *pArgs) |
| 3131 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3132 | pj_status_t status; |
| 3133 | pjsip_transport_Object *obj; |
| 3134 | pjsua_transport_id id; |
| 3135 | if (!PyArg_ParseTuple(pArgs, "O", &obj)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3136 | { |
| 3137 | return NULL; |
| 3138 | } |
| 3139 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3140 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3141 | status = pjsua_transport_register(obj->tp, &id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3142 | |
| 3143 | return Py_BuildValue("ii",status, id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3144 | } |
| 3145 | |
| 3146 | /* |
| 3147 | * py_pjsua_enum_transports |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3148 | * !modified @ 261206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3149 | */ |
| 3150 | static PyObject *py_pjsua_enum_transports(PyObject *pSelf, PyObject *pArgs) |
| 3151 | { |
| 3152 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3153 | PyObject *list; |
| 3154 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3155 | pjsua_transport_id id[PJSIP_MAX_TRANSPORTS]; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3156 | int c, i; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3157 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3158 | { |
| 3159 | return NULL; |
| 3160 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3161 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3162 | c = PJ_ARRAY_SIZE(id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3163 | status = pjsua_enum_transports(id, &c); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3164 | |
| 3165 | list = PyList_New(c); |
| 3166 | for (i = 0; i < c; i++) |
| 3167 | { |
| 3168 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 3169 | if (ret == -1) |
| 3170 | { |
| 3171 | return NULL; |
| 3172 | } |
| 3173 | } |
| 3174 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 3175 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3176 | return Py_BuildValue("O",list); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3177 | } |
| 3178 | |
| 3179 | /* |
| 3180 | * py_pjsua_transport_get_info |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3181 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3182 | */ |
| 3183 | static PyObject *py_pjsua_transport_get_info(PyObject *pSelf, PyObject *pArgs) |
| 3184 | { |
| 3185 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3186 | int id; |
| 3187 | transport_info_Object *obj; |
| 3188 | pjsua_transport_info info; |
| 3189 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3190 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3191 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3192 | { |
| 3193 | return NULL; |
| 3194 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3195 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3196 | status = pjsua_transport_get_info(id, &info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3197 | if (status == PJ_SUCCESS) { |
| 3198 | obj = (transport_info_Object *) transport_info_new |
| 3199 | (&transport_info_Type,NULL,NULL); |
| 3200 | obj->addr_len = info.addr_len; |
| 3201 | obj->flag = info.flag; |
| 3202 | obj->id = info.id; |
| 3203 | obj->info = PyString_FromStringAndSize(info.info.ptr, info.info.slen); |
| 3204 | obj->local_addr->sa_data = |
| 3205 | PyString_FromStringAndSize(info.local_addr.sa_data, 14); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3206 | #if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3207 | obj->local_addr->sa_zero_len = info.local_addr.sa_zero_len; |
| 3208 | obj->local_addr->sa_family = info.local_addr.sa_family; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3209 | #else |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3210 | obj->local_addr->sa_family = info.local_addr.sa_family; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3211 | #endif |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3212 | return Py_BuildValue("O", obj); |
| 3213 | } else { |
| 3214 | Py_INCREF(Py_None); |
| 3215 | return Py_None; |
| 3216 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3217 | } |
| 3218 | |
| 3219 | /* |
| 3220 | * py_pjsua_transport_set_enable |
| 3221 | */ |
| 3222 | static PyObject *py_pjsua_transport_set_enable |
| 3223 | (PyObject *pSelf, PyObject *pArgs) |
| 3224 | { |
| 3225 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3226 | int id; |
| 3227 | int enabled; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3228 | if (!PyArg_ParseTuple(pArgs, "ii", &id, &enabled)) |
| 3229 | { |
| 3230 | return NULL; |
| 3231 | } |
| 3232 | status = pjsua_transport_set_enable(id, enabled); |
| 3233 | //printf("status %d\n",status); |
| 3234 | return Py_BuildValue("i",status); |
| 3235 | } |
| 3236 | |
| 3237 | /* |
| 3238 | * py_pjsua_transport_close |
| 3239 | */ |
| 3240 | static PyObject *py_pjsua_transport_close(PyObject *pSelf, PyObject *pArgs) |
| 3241 | { |
| 3242 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3243 | int id; |
| 3244 | int force; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3245 | if (!PyArg_ParseTuple(pArgs, "ii", &id, &force)) |
| 3246 | { |
| 3247 | return NULL; |
| 3248 | } |
| 3249 | status = pjsua_transport_close(id, force); |
| 3250 | //printf("status %d\n",status); |
| 3251 | return Py_BuildValue("i",status); |
| 3252 | } |
| 3253 | |
| 3254 | static char pjsua_stun_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3255 | "py_pjsua.STUN_Config py_pjsua.stun_config_default () " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3256 | "Call this function to initialize STUN config with default values."; |
| 3257 | static char pjsua_transport_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3258 | "py_pjsua.Transport_Config py_pjsua.transport_config_default () " |
| 3259 | "Call this function to initialize UDP config with default values."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3260 | static char pjsua_normalize_stun_config_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3261 | "void py_pjsua.normalize_stun_config (py_pjsua.STUN_Config cfg) " |
| 3262 | "Normalize STUN config. "; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3263 | static char pjsua_transport_create_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3264 | "int, int py_pjsua.transport_create (int type, " |
| 3265 | "py_pjsua.Transport_Config cfg) " |
| 3266 | "Create SIP transport."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3267 | static char pjsua_transport_register_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3268 | "int, int py_pjsua.transport_register " |
| 3269 | "(py_pjsua.PJSIP_Transport tp) " |
| 3270 | "Register transport that has been created by application."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3271 | static char pjsua_enum_transports_doc[] = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3272 | "int[] py_pjsua.enum_transports () " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3273 | "Enumerate all transports currently created in the system."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3274 | static char pjsua_transport_get_info_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3275 | "void py_pjsua.transport_get_info " |
| 3276 | "(py_pjsua.Transport_ID id, py_pjsua.Transport_Info info) " |
| 3277 | "Get information about transports."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3278 | static char pjsua_transport_set_enable_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3279 | "void py_pjsua.transport_set_enable " |
| 3280 | "(py_pjsua.Transport_ID id, int enabled) " |
| 3281 | "Disable a transport or re-enable it. " |
| 3282 | "By default transport is always enabled after it is created. " |
| 3283 | "Disabling a transport does not necessarily close the socket, " |
| 3284 | "it will only discard incoming messages and prevent the transport " |
| 3285 | "from being used to send outgoing messages."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3286 | static char pjsua_transport_close_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3287 | "void py_pjsua.transport_close (py_pjsua.Transport_ID id, int force) " |
| 3288 | "Close the transport. If transport is forcefully closed, " |
| 3289 | "it will be immediately closed, and any pending transactions " |
| 3290 | "that are using the transport may not terminate properly. " |
| 3291 | "Otherwise, the system will wait until all transactions are closed " |
| 3292 | "while preventing new users from using the transport, and will close " |
| 3293 | "the transport when it is safe to do so."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3294 | |
| 3295 | /* END OF LIB TRANSPORT */ |
| 3296 | |
| 3297 | /* LIB ACCOUNT */ |
| 3298 | |
| 3299 | /* |
| 3300 | * acc_config_Object |
| 3301 | * Acc Config |
| 3302 | */ |
| 3303 | typedef struct |
| 3304 | { |
| 3305 | PyObject_HEAD |
| 3306 | /* Type-specific fields go here. */ |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3307 | int priority; |
| 3308 | PyObject * id; |
| 3309 | PyObject * reg_uri; |
| 3310 | int publish_enabled; |
| 3311 | PyObject * force_contact; |
| 3312 | unsigned proxy_cnt; |
| 3313 | /*pj_str_t proxy[8];*/ |
| 3314 | PyListObject * proxy; |
| 3315 | unsigned reg_timeout; |
| 3316 | unsigned cred_count; |
| 3317 | /*pjsip_cred_info cred_info[8];*/ |
| 3318 | PyListObject * cred_info; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3319 | } acc_config_Object; |
| 3320 | |
| 3321 | |
| 3322 | /* |
| 3323 | * acc_config_dealloc |
| 3324 | * deletes a acc_config from memory |
| 3325 | */ |
| 3326 | static void acc_config_dealloc(acc_config_Object* self) |
| 3327 | { |
| 3328 | Py_XDECREF(self->id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3329 | Py_XDECREF(self->reg_uri); |
| 3330 | Py_XDECREF(self->force_contact); |
| 3331 | Py_XDECREF(self->proxy); |
| 3332 | Py_XDECREF(self->cred_info); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3333 | self->ob_type->tp_free((PyObject*)self); |
| 3334 | } |
| 3335 | |
| 3336 | |
| 3337 | /* |
| 3338 | * acc_config_new |
| 3339 | * constructor for acc_config object |
| 3340 | */ |
| 3341 | static PyObject * acc_config_new(PyTypeObject *type, PyObject *args, |
| 3342 | PyObject *kwds) |
| 3343 | { |
| 3344 | acc_config_Object *self; |
| 3345 | |
| 3346 | self = (acc_config_Object *)type->tp_alloc(type, 0); |
| 3347 | if (self != NULL) |
| 3348 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3349 | self->id = PyString_FromString(""); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3350 | if (self->id == NULL) |
| 3351 | { |
| 3352 | Py_DECREF(self); |
| 3353 | return NULL; |
| 3354 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3355 | self->reg_uri = PyString_FromString(""); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3356 | if (self->reg_uri == NULL) |
| 3357 | { |
| 3358 | Py_DECREF(self); |
| 3359 | return NULL; |
| 3360 | } |
| 3361 | self->force_contact = PyString_FromString(""); |
| 3362 | if (self->force_contact == NULL) |
| 3363 | { |
| 3364 | Py_DECREF(self); |
| 3365 | return NULL; |
| 3366 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3367 | self->proxy = (PyListObject *)PyList_New(8); |
| 3368 | if (self->proxy == NULL) |
| 3369 | { |
| 3370 | Py_DECREF(self); |
| 3371 | return NULL; |
| 3372 | } |
| 3373 | self->cred_info = (PyListObject *)PyList_New(8); |
| 3374 | if (self->cred_info == NULL) |
| 3375 | { |
| 3376 | Py_DECREF(self); |
| 3377 | return NULL; |
| 3378 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3379 | } |
| 3380 | |
| 3381 | return (PyObject *)self; |
| 3382 | } |
| 3383 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3384 | |
| 3385 | |
| 3386 | /* |
| 3387 | * acc_config_members |
| 3388 | */ |
| 3389 | static PyMemberDef acc_config_members[] = |
| 3390 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3391 | { |
| 3392 | "priority", T_INT, offsetof(acc_config_Object, priority), 0, |
| 3393 | "Account priority, which is used to control the order of matching " |
| 3394 | "incoming/outgoing requests. The higher the number means the higher " |
| 3395 | "the priority is, and the account will be matched first. " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3396 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3397 | { |
| 3398 | "id", T_OBJECT_EX, |
| 3399 | offsetof(acc_config_Object, id), 0, |
| 3400 | "The full SIP URL for the account. " |
| 3401 | "The value can take name address or URL format, " |
| 3402 | "and will look something like 'sip:account@serviceprovider'. " |
| 3403 | "This field is mandatory." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3404 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3405 | { |
| 3406 | "reg_uri", T_OBJECT_EX, |
| 3407 | offsetof(acc_config_Object, reg_uri), 0, |
| 3408 | "This is the URL to be put in the request URI for the registration, " |
| 3409 | "and will look something like 'sip:serviceprovider'. " |
| 3410 | "This field should be specified if registration is desired. " |
| 3411 | "If the value is empty, no account registration will be performed. " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3412 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3413 | { |
| 3414 | "publish_enabled", T_INT, |
| 3415 | offsetof(acc_config_Object, publish_enabled), 0, |
| 3416 | "Publish presence? " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3417 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3418 | { |
| 3419 | "force_contact", T_OBJECT_EX, |
| 3420 | offsetof(acc_config_Object, force_contact), 0, |
| 3421 | "Optional URI to be put as Contact for this account. " |
| 3422 | "It is recommended that this field is left empty, " |
| 3423 | "so that the value will be calculated automatically " |
| 3424 | "based on the transport address. " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3425 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3426 | { |
| 3427 | "proxy_cnt", T_INT, offsetof(acc_config_Object, proxy_cnt), 0, |
| 3428 | "Number of proxies in the proxy array below. " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3429 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3430 | { |
| 3431 | "proxy", T_OBJECT_EX, |
| 3432 | offsetof(acc_config_Object, proxy), 0, |
| 3433 | "Optional URI of the proxies to be visited for all outgoing requests " |
| 3434 | "that are using this account (REGISTER, INVITE, etc). Application need " |
| 3435 | "to specify these proxies if the service provider requires " |
| 3436 | "that requests destined towards its network should go through certain " |
| 3437 | "proxies first (for example, border controllers)." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3438 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3439 | { |
| 3440 | "reg_timeout", T_INT, offsetof(acc_config_Object, reg_timeout), 0, |
| 3441 | "Optional interval for registration, in seconds. " |
| 3442 | "If the value is zero, default interval will be used " |
| 3443 | "(PJSUA_REG_INTERVAL, 55 seconds). " |
| 3444 | }, |
| 3445 | { |
| 3446 | "cred_count", T_INT, offsetof(acc_config_Object, cred_count), 0, |
| 3447 | "Number of credentials in the credential array. " |
| 3448 | }, |
| 3449 | { |
| 3450 | "cred_info", T_OBJECT_EX, |
| 3451 | offsetof(acc_config_Object, cred_info), 0, |
| 3452 | "Array of credentials. If registration is desired, normally there " |
| 3453 | "should be at least one credential specified, to successfully " |
| 3454 | "authenticate against the service provider. More credentials can " |
| 3455 | "be specified, for example when the requests are expected to be " |
| 3456 | "challenged by the proxies in the route set." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3457 | }, |
| 3458 | {NULL} /* Sentinel */ |
| 3459 | }; |
| 3460 | |
| 3461 | |
| 3462 | |
| 3463 | |
| 3464 | /* |
| 3465 | * acc_config_Type |
| 3466 | */ |
| 3467 | static PyTypeObject acc_config_Type = |
| 3468 | { |
| 3469 | PyObject_HEAD_INIT(NULL) |
| 3470 | 0, /*ob_size*/ |
| 3471 | "py_pjsua.Acc_Config", /*tp_name*/ |
| 3472 | sizeof(acc_config_Object), /*tp_basicsize*/ |
| 3473 | 0, /*tp_itemsize*/ |
| 3474 | (destructor)acc_config_dealloc,/*tp_dealloc*/ |
| 3475 | 0, /*tp_print*/ |
| 3476 | 0, /*tp_getattr*/ |
| 3477 | 0, /*tp_setattr*/ |
| 3478 | 0, /*tp_compare*/ |
| 3479 | 0, /*tp_repr*/ |
| 3480 | 0, /*tp_as_number*/ |
| 3481 | 0, /*tp_as_sequence*/ |
| 3482 | 0, /*tp_as_mapping*/ |
| 3483 | 0, /*tp_hash */ |
| 3484 | 0, /*tp_call*/ |
| 3485 | 0, /*tp_str*/ |
| 3486 | 0, /*tp_getattro*/ |
| 3487 | 0, /*tp_setattro*/ |
| 3488 | 0, /*tp_as_buffer*/ |
| 3489 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3490 | "Acc Config objects", /* tp_doc */ |
| 3491 | 0, /* tp_traverse */ |
| 3492 | 0, /* tp_clear */ |
| 3493 | 0, /* tp_richcompare */ |
| 3494 | 0, /* tp_weaklistoffset */ |
| 3495 | 0, /* tp_iter */ |
| 3496 | 0, /* tp_iternext */ |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3497 | 0/*acc_config_methods*/, /* tp_methods */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3498 | acc_config_members, /* tp_members */ |
| 3499 | 0, /* tp_getset */ |
| 3500 | 0, /* tp_base */ |
| 3501 | 0, /* tp_dict */ |
| 3502 | 0, /* tp_descr_get */ |
| 3503 | 0, /* tp_descr_set */ |
| 3504 | 0, /* tp_dictoffset */ |
| 3505 | 0, /* tp_init */ |
| 3506 | 0, /* tp_alloc */ |
| 3507 | acc_config_new, /* tp_new */ |
| 3508 | |
| 3509 | }; |
| 3510 | |
| 3511 | /* |
| 3512 | * acc_info_Object |
| 3513 | * Acc Info |
| 3514 | */ |
| 3515 | typedef struct |
| 3516 | { |
| 3517 | PyObject_HEAD |
| 3518 | /* Type-specific fields go here. */ |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3519 | int id; |
| 3520 | int is_default; |
| 3521 | PyObject * acc_uri; |
| 3522 | int has_registration; |
| 3523 | int expires; |
| 3524 | int status; |
| 3525 | PyObject * status_text; |
| 3526 | int online_status; |
| 3527 | char buf_[PJ_ERR_MSG_SIZE]; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3528 | } acc_info_Object; |
| 3529 | |
| 3530 | |
| 3531 | /* |
| 3532 | * acc_info_dealloc |
| 3533 | * deletes a acc_info from memory |
| 3534 | */ |
| 3535 | static void acc_info_dealloc(acc_info_Object* self) |
| 3536 | { |
| 3537 | Py_XDECREF(self->acc_uri); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3538 | Py_XDECREF(self->status_text); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3539 | self->ob_type->tp_free((PyObject*)self); |
| 3540 | } |
| 3541 | |
| 3542 | |
| 3543 | /* |
| 3544 | * acc_info_new |
| 3545 | * constructor for acc_info object |
| 3546 | */ |
| 3547 | static PyObject * acc_info_new(PyTypeObject *type, PyObject *args, |
| 3548 | PyObject *kwds) |
| 3549 | { |
| 3550 | acc_info_Object *self; |
| 3551 | |
| 3552 | self = (acc_info_Object *)type->tp_alloc(type, 0); |
| 3553 | if (self != NULL) |
| 3554 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3555 | self->acc_uri = PyString_FromString(""); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3556 | if (self->acc_uri == NULL) |
| 3557 | { |
| 3558 | Py_DECREF(self); |
| 3559 | return NULL; |
| 3560 | } |
| 3561 | self->status_text = PyString_FromString(""); |
| 3562 | if (self->status_text == NULL) |
| 3563 | { |
| 3564 | Py_DECREF(self); |
| 3565 | return NULL; |
| 3566 | } |
| 3567 | |
| 3568 | } |
| 3569 | |
| 3570 | return (PyObject *)self; |
| 3571 | } |
| 3572 | |
| 3573 | static PyObject * acc_info_get_buf |
| 3574 | (acc_info_Object *self, PyObject * args) |
| 3575 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3576 | int idx; |
| 3577 | char elmt; |
| 3578 | if (!PyArg_ParseTuple(args,"i",&idx)) |
| 3579 | { |
| 3580 | return NULL; |
| 3581 | } |
| 3582 | if ((idx >= 0) && (idx < PJ_ERR_MSG_SIZE)) |
| 3583 | { |
| 3584 | elmt = self->buf_[idx]; |
| 3585 | } |
| 3586 | else |
| 3587 | { |
| 3588 | return NULL; |
| 3589 | } |
| 3590 | return PyString_FromStringAndSize(&elmt, 1); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3591 | } |
| 3592 | |
| 3593 | static PyObject * acc_info_set_buf |
| 3594 | (acc_info_Object *self, PyObject * args) |
| 3595 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3596 | int idx; |
| 3597 | PyObject * str; |
| 3598 | char * s; |
| 3599 | if (!PyArg_ParseTuple(args,"iO",&idx, &str)) |
| 3600 | { |
| 3601 | return NULL; |
| 3602 | } |
| 3603 | if ((idx >= 0) && (idx < PJ_ERR_MSG_SIZE)) |
| 3604 | { |
| 3605 | s = PyString_AsString(str); |
| 3606 | if (s[0]) |
| 3607 | { |
| 3608 | self->buf_[idx] = s[0]; |
| 3609 | } |
| 3610 | else |
| 3611 | { |
| 3612 | return NULL; |
| 3613 | } |
| 3614 | } |
| 3615 | else |
| 3616 | { |
| 3617 | return NULL; |
| 3618 | } |
| 3619 | Py_INCREF(Py_None); |
| 3620 | return Py_None; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3621 | } |
| 3622 | |
| 3623 | static PyMethodDef acc_info_methods[] = { |
| 3624 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3625 | "get_buf", (PyCFunction)acc_info_get_buf, METH_VARARGS, |
| 3626 | "Return buf char at specified index" |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3627 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3628 | { |
| 3629 | "set_buf", (PyCFunction)acc_info_set_buf, METH_VARARGS, |
| 3630 | "Set buf at specified index" |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3631 | }, |
| 3632 | |
| 3633 | {NULL} /* Sentinel */ |
| 3634 | }; |
| 3635 | |
| 3636 | |
| 3637 | |
| 3638 | /* |
| 3639 | * acc_info_members |
| 3640 | */ |
| 3641 | static PyMemberDef acc_info_members[] = |
| 3642 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3643 | { |
| 3644 | "id", T_INT, offsetof(acc_info_Object, id), 0, |
| 3645 | "The account ID." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3646 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3647 | { |
| 3648 | "is_default", T_INT, offsetof(acc_info_Object, is_default), 0, |
| 3649 | "Flag to indicate whether this is the default account. " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3650 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3651 | { |
| 3652 | "acc_uri", T_OBJECT_EX, |
| 3653 | offsetof(acc_info_Object, acc_uri), 0, |
| 3654 | "Account URI" |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3655 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3656 | { |
| 3657 | "has_registration", T_INT, offsetof(acc_info_Object, has_registration), |
| 3658 | 0, |
| 3659 | "Flag to tell whether this account has registration setting " |
| 3660 | "(reg_uri is not empty)." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3661 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3662 | { |
| 3663 | "expires", T_INT, offsetof(acc_info_Object, expires), 0, |
| 3664 | "An up to date expiration interval for account registration session." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3665 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3666 | { |
| 3667 | "status", T_INT, offsetof(acc_info_Object, status), 0, |
| 3668 | "Last registration status code. If status code is zero, " |
| 3669 | "the account is currently not registered. Any other value indicates " |
| 3670 | "the SIP status code of the registration. " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3671 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3672 | { |
| 3673 | "status_text", T_OBJECT_EX, |
| 3674 | offsetof(acc_info_Object, status_text), 0, |
| 3675 | "String describing the registration status." |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3676 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3677 | { |
| 3678 | "online_status", T_INT, offsetof(acc_info_Object, online_status), 0, |
| 3679 | "Presence online status for this account. " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3680 | }, |
| 3681 | {NULL} /* Sentinel */ |
| 3682 | }; |
| 3683 | |
| 3684 | |
| 3685 | |
| 3686 | |
| 3687 | /* |
| 3688 | * acc_info_Type |
| 3689 | */ |
| 3690 | static PyTypeObject acc_info_Type = |
| 3691 | { |
| 3692 | PyObject_HEAD_INIT(NULL) |
| 3693 | 0, /*ob_size*/ |
| 3694 | "py_pjsua.Acc_Info", /*tp_name*/ |
| 3695 | sizeof(acc_info_Object), /*tp_basicsize*/ |
| 3696 | 0, /*tp_itemsize*/ |
| 3697 | (destructor)acc_info_dealloc,/*tp_dealloc*/ |
| 3698 | 0, /*tp_print*/ |
| 3699 | 0, /*tp_getattr*/ |
| 3700 | 0, /*tp_setattr*/ |
| 3701 | 0, /*tp_compare*/ |
| 3702 | 0, /*tp_repr*/ |
| 3703 | 0, /*tp_as_number*/ |
| 3704 | 0, /*tp_as_sequence*/ |
| 3705 | 0, /*tp_as_mapping*/ |
| 3706 | 0, /*tp_hash */ |
| 3707 | 0, /*tp_call*/ |
| 3708 | 0, /*tp_str*/ |
| 3709 | 0, /*tp_getattro*/ |
| 3710 | 0, /*tp_setattro*/ |
| 3711 | 0, /*tp_as_buffer*/ |
| 3712 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3713 | "Acc Info objects", /* tp_doc */ |
| 3714 | 0, /* tp_traverse */ |
| 3715 | 0, /* tp_clear */ |
| 3716 | 0, /* tp_richcompare */ |
| 3717 | 0, /* tp_weaklistoffset */ |
| 3718 | 0, /* tp_iter */ |
| 3719 | 0, /* tp_iternext */ |
| 3720 | acc_info_methods, /* tp_methods */ |
| 3721 | acc_info_members, /* tp_members */ |
| 3722 | 0, /* tp_getset */ |
| 3723 | 0, /* tp_base */ |
| 3724 | 0, /* tp_dict */ |
| 3725 | 0, /* tp_descr_get */ |
| 3726 | 0, /* tp_descr_set */ |
| 3727 | 0, /* tp_dictoffset */ |
| 3728 | 0, /* tp_init */ |
| 3729 | 0, /* tp_alloc */ |
| 3730 | acc_info_new, /* tp_new */ |
| 3731 | |
| 3732 | }; |
| 3733 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3734 | |
| 3735 | |
| 3736 | /* |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3737 | * py_pjsua_acc_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3738 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3739 | */ |
| 3740 | static PyObject *py_pjsua_acc_config_default |
| 3741 | (PyObject *pSelf, PyObject *pArgs) |
| 3742 | { |
| 3743 | acc_config_Object *obj; |
| 3744 | pjsua_acc_config cfg; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3745 | int i; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3746 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3747 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3748 | { |
| 3749 | return NULL; |
| 3750 | } |
| 3751 | pjsua_acc_config_default(&cfg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3752 | obj = (acc_config_Object *)acc_config_new(&acc_config_Type, NULL, NULL); |
| 3753 | obj->cred_count = cfg.cred_count; |
| 3754 | for (i = 0; i < 8; i++) |
| 3755 | { |
| 3756 | /*obj->cred_info[i] = cfg.cred_info[i];*/ |
| 3757 | int ret; |
| 3758 | pjsip_cred_info_Object * ci = |
| 3759 | (pjsip_cred_info_Object *)pjsip_cred_info_new |
| 3760 | (&pjsip_cred_info_Type,NULL,NULL); |
| 3761 | ci->data = PyString_FromStringAndSize(cfg.cred_info[i].data.ptr, |
| 3762 | cfg.cred_info[i].data.slen); |
| 3763 | ci->realm = PyString_FromStringAndSize(cfg.cred_info[i].realm.ptr, |
| 3764 | cfg.cred_info[i].realm.slen); |
| 3765 | ci->scheme = PyString_FromStringAndSize(cfg.cred_info[i].scheme.ptr, |
| 3766 | cfg.cred_info[i].scheme.slen); |
| 3767 | ci->username = PyString_FromStringAndSize(cfg.cred_info[i].username.ptr, |
| 3768 | cfg.cred_info[i].username.slen); |
| 3769 | ci->data_type = cfg.cred_info[i].data_type; |
| 3770 | ret = PyList_SetItem((PyObject *)obj->cred_info,i,(PyObject *)ci); |
| 3771 | if (ret == -1) { |
| 3772 | return NULL; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3773 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3774 | } |
| 3775 | |
| 3776 | Py_XDECREF(obj->force_contact); |
| 3777 | obj->force_contact = |
| 3778 | PyString_FromStringAndSize(cfg.force_contact.ptr, |
| 3779 | cfg.force_contact.slen); |
| 3780 | obj->priority = cfg.priority; |
| 3781 | Py_XDECREF(obj->id); |
| 3782 | obj->id = |
| 3783 | PyString_FromStringAndSize(cfg.id.ptr, cfg.id.slen); |
| 3784 | Py_XDECREF(obj->reg_uri); |
| 3785 | obj->reg_uri = |
| 3786 | PyString_FromStringAndSize(cfg.reg_uri.ptr, cfg.reg_uri.slen); |
| 3787 | obj->proxy_cnt = cfg.proxy_cnt; |
| 3788 | for (i = 0; i < 8; i++) |
| 3789 | { |
| 3790 | PyObject * str; |
| 3791 | int ret; |
| 3792 | /*obj->proxy[i] = cfg.proxy[i];*/ |
| 3793 | str = PyString_FromStringAndSize(cfg.proxy[i].ptr, cfg.proxy[i].slen); |
| 3794 | ret = PyList_SetItem((PyObject *)obj->proxy,i,str); |
| 3795 | if (ret == -1) { |
| 3796 | return NULL; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3797 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3798 | } |
| 3799 | obj->publish_enabled = cfg.publish_enabled; |
| 3800 | obj->reg_timeout = cfg.reg_timeout; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3801 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3802 | return (PyObject *)obj; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3803 | } |
| 3804 | |
| 3805 | /* |
| 3806 | * py_pjsua_acc_get_count |
| 3807 | */ |
| 3808 | static PyObject *py_pjsua_acc_get_count |
| 3809 | (PyObject *pSelf, PyObject *pArgs) |
| 3810 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3811 | int count; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3812 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3813 | { |
| 3814 | return NULL; |
| 3815 | } |
| 3816 | count = pjsua_acc_get_count(); |
| 3817 | return Py_BuildValue("i",count); |
| 3818 | } |
| 3819 | |
| 3820 | /* |
| 3821 | * py_pjsua_acc_is_valid |
| 3822 | */ |
| 3823 | static PyObject *py_pjsua_acc_is_valid |
| 3824 | (PyObject *pSelf, PyObject *pArgs) |
| 3825 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3826 | int id; |
| 3827 | int is_valid; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3828 | |
| 3829 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3830 | { |
| 3831 | return NULL; |
| 3832 | } |
| 3833 | is_valid = pjsua_acc_is_valid(id); |
| 3834 | |
| 3835 | return Py_BuildValue("i", is_valid); |
| 3836 | } |
| 3837 | |
| 3838 | /* |
| 3839 | * py_pjsua_acc_set_default |
| 3840 | */ |
| 3841 | static PyObject *py_pjsua_acc_set_default |
| 3842 | (PyObject *pSelf, PyObject *pArgs) |
| 3843 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3844 | int id; |
| 3845 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3846 | |
| 3847 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3848 | { |
| 3849 | return NULL; |
| 3850 | } |
| 3851 | status = pjsua_acc_set_default(id); |
| 3852 | |
| 3853 | return Py_BuildValue("i", status); |
| 3854 | } |
| 3855 | |
| 3856 | /* |
| 3857 | * py_pjsua_acc_get_default |
| 3858 | */ |
| 3859 | static PyObject *py_pjsua_acc_get_default |
| 3860 | (PyObject *pSelf, PyObject *pArgs) |
| 3861 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3862 | int id; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3863 | |
| 3864 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3865 | { |
| 3866 | return NULL; |
| 3867 | } |
| 3868 | id = pjsua_acc_get_default(); |
| 3869 | |
| 3870 | return Py_BuildValue("i", id); |
| 3871 | } |
| 3872 | |
| 3873 | /* |
| 3874 | * py_pjsua_acc_add |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3875 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3876 | */ |
| 3877 | static PyObject *py_pjsua_acc_add |
| 3878 | (PyObject *pSelf, PyObject *pArgs) |
| 3879 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3880 | int is_default; |
| 3881 | acc_config_Object * ac; |
| 3882 | pjsua_acc_config cfg; |
| 3883 | |
| 3884 | int p_acc_id; |
| 3885 | int status; |
| 3886 | int i; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3887 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3888 | if (!PyArg_ParseTuple(pArgs, "Oi", &ac, &is_default)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3889 | { |
| 3890 | return NULL; |
| 3891 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3892 | cfg.cred_count = ac->cred_count; |
| 3893 | for (i = 0; i < 8; i++) |
| 3894 | { |
| 3895 | /*cfg.cred_info[i] = ac->cred_info[i];*/ |
| 3896 | pjsip_cred_info_Object * ci = (pjsip_cred_info_Object *)PyList_GetItem((PyObject *)ac->cred_info,i); |
| 3897 | cfg.cred_info[i].data.ptr = PyString_AsString(ci->data); |
| 3898 | cfg.cred_info[i].data.slen = strlen(PyString_AsString(ci->data)); |
| 3899 | cfg.cred_info[i].realm.ptr = PyString_AsString(ci->realm); |
| 3900 | cfg.cred_info[i].realm.slen = strlen(PyString_AsString(ci->realm)); |
| 3901 | cfg.cred_info[i].scheme.ptr = PyString_AsString(ci->scheme); |
| 3902 | cfg.cred_info[i].scheme.slen = strlen(PyString_AsString(ci->scheme)); |
| 3903 | cfg.cred_info[i].username.ptr = PyString_AsString(ci->username); |
| 3904 | cfg.cred_info[i].username.slen = strlen(PyString_AsString(ci->username)); |
| 3905 | cfg.cred_info[i].data_type = ci->data_type; |
| 3906 | } |
| 3907 | cfg.force_contact.ptr = PyString_AsString(ac->force_contact); |
| 3908 | cfg.force_contact.slen = strlen(PyString_AsString(ac->force_contact)); |
| 3909 | cfg.id.ptr = PyString_AsString(ac->id); |
| 3910 | cfg.id.slen = strlen(PyString_AsString(ac->id)); |
| 3911 | cfg.priority = ac->priority; |
| 3912 | for (i = 0; i < 8; i++) { |
| 3913 | /*cfg.proxy[i] = ac->proxy[i];*/ |
| 3914 | cfg.proxy[i].ptr = PyString_AsString(PyList_GetItem((PyObject *)ac->proxy,i)); |
| 3915 | } |
| 3916 | cfg.proxy_cnt = ac->proxy_cnt; |
| 3917 | cfg.publish_enabled = ac->publish_enabled; |
| 3918 | cfg.reg_timeout = ac->reg_timeout; |
| 3919 | cfg.reg_uri.ptr = PyString_AsString(ac->reg_uri); |
| 3920 | cfg.reg_uri.slen = strlen(PyString_AsString(ac->reg_uri)); |
| 3921 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3922 | status = pjsua_acc_add(&cfg, is_default, &p_acc_id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3923 | |
| 3924 | return Py_BuildValue("ii", status, p_acc_id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3925 | } |
| 3926 | |
| 3927 | /* |
| 3928 | * py_pjsua_acc_add_local |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3929 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3930 | */ |
| 3931 | static PyObject *py_pjsua_acc_add_local |
| 3932 | (PyObject *pSelf, PyObject *pArgs) |
| 3933 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3934 | int is_default; |
| 3935 | int tid; |
| 3936 | |
| 3937 | int p_acc_id; |
| 3938 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3939 | |
| 3940 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3941 | if (!PyArg_ParseTuple(pArgs, "iiO", &tid, &is_default)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3942 | { |
| 3943 | return NULL; |
| 3944 | } |
| 3945 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3946 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3947 | status = pjsua_acc_add_local(tid, is_default, &p_acc_id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3948 | |
| 3949 | return Py_BuildValue("ii", status, p_acc_id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3950 | } |
| 3951 | |
| 3952 | /* |
| 3953 | * py_pjsua_acc_del |
| 3954 | */ |
| 3955 | static PyObject *py_pjsua_acc_del |
| 3956 | (PyObject *pSelf, PyObject *pArgs) |
| 3957 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3958 | int acc_id; |
| 3959 | int status; |
| 3960 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3961 | if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) |
| 3962 | { |
| 3963 | return NULL; |
| 3964 | } |
| 3965 | |
| 3966 | |
| 3967 | status = pjsua_acc_del(acc_id); |
| 3968 | return Py_BuildValue("i", status); |
| 3969 | } |
| 3970 | |
| 3971 | /* |
| 3972 | * py_pjsua_acc_modify |
| 3973 | */ |
| 3974 | static PyObject *py_pjsua_acc_modify |
| 3975 | (PyObject *pSelf, PyObject *pArgs) |
| 3976 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3977 | acc_config_Object * ac; |
| 3978 | pjsua_acc_config cfg; |
| 3979 | int acc_id; |
| 3980 | int status; |
| 3981 | int i; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 3982 | |
| 3983 | if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &ac)) |
| 3984 | { |
| 3985 | return NULL; |
| 3986 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 3987 | cfg.cred_count = ac->cred_count; |
| 3988 | for (i = 0; i < 8; i++) |
| 3989 | { |
| 3990 | /*cfg.cred_info[i] = ac->cred_info[i];*/ |
| 3991 | pjsip_cred_info_Object * ci = (pjsip_cred_info_Object *)PyList_GetItem((PyObject *)ac->cred_info,i); |
| 3992 | cfg.cred_info[i].data.ptr = PyString_AsString(ci->data); |
| 3993 | cfg.cred_info[i].data.slen = strlen(PyString_AsString(ci->data)); |
| 3994 | cfg.cred_info[i].realm.ptr = PyString_AsString(ci->realm); |
| 3995 | cfg.cred_info[i].realm.slen = strlen(PyString_AsString(ci->realm)); |
| 3996 | cfg.cred_info[i].scheme.ptr = PyString_AsString(ci->scheme); |
| 3997 | cfg.cred_info[i].scheme.slen = strlen(PyString_AsString(ci->scheme)); |
| 3998 | cfg.cred_info[i].username.ptr = PyString_AsString(ci->username); |
| 3999 | cfg.cred_info[i].username.slen = strlen(PyString_AsString(ci->username)); |
| 4000 | } |
| 4001 | cfg.force_contact.ptr = PyString_AsString(ac->force_contact); |
| 4002 | cfg.force_contact.slen = strlen(PyString_AsString(ac->force_contact)); |
| 4003 | cfg.id.ptr = PyString_AsString(ac->id); |
| 4004 | cfg.id.slen = strlen(PyString_AsString(ac->id)); |
| 4005 | cfg.priority = ac->priority; |
| 4006 | for (i = 0; i < 8; i++) { |
| 4007 | /*cfg.proxy[i] = ac->proxy[i];*/ |
| 4008 | cfg.proxy[i].ptr = PyString_AsString(PyList_GetItem((PyObject *)ac->proxy,i)); |
| 4009 | } |
| 4010 | cfg.proxy_cnt = ac->proxy_cnt; |
| 4011 | cfg.publish_enabled = ac->publish_enabled; |
| 4012 | cfg.reg_timeout = ac->reg_timeout; |
| 4013 | cfg.reg_uri.ptr = PyString_AsString(ac->reg_uri); |
| 4014 | cfg.reg_uri.slen = strlen(PyString_AsString(ac->reg_uri)); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4015 | status = pjsua_acc_modify(acc_id, &cfg); |
| 4016 | return Py_BuildValue("i", status); |
| 4017 | } |
| 4018 | |
| 4019 | /* |
| 4020 | * py_pjsua_acc_set_online_status |
| 4021 | */ |
| 4022 | static PyObject *py_pjsua_acc_set_online_status |
| 4023 | (PyObject *pSelf, PyObject *pArgs) |
| 4024 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4025 | int is_online; |
| 4026 | int acc_id; |
| 4027 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4028 | |
| 4029 | if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &is_online)) |
| 4030 | { |
| 4031 | return NULL; |
| 4032 | } |
| 4033 | |
| 4034 | status = pjsua_acc_set_online_status(acc_id, is_online); |
| 4035 | |
| 4036 | return Py_BuildValue("i", status); |
| 4037 | } |
| 4038 | |
| 4039 | /* |
| 4040 | * py_pjsua_acc_set_registration |
| 4041 | */ |
| 4042 | static PyObject *py_pjsua_acc_set_registration |
| 4043 | (PyObject *pSelf, PyObject *pArgs) |
| 4044 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4045 | int renew; |
| 4046 | int acc_id; |
| 4047 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4048 | |
| 4049 | if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &renew)) |
| 4050 | { |
| 4051 | return NULL; |
| 4052 | } |
| 4053 | |
| 4054 | status = pjsua_acc_set_registration(acc_id, renew); |
| 4055 | |
| 4056 | return Py_BuildValue("i", status); |
| 4057 | } |
| 4058 | |
| 4059 | /* |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4060 | * py_pjsua_acc_get_info |
| 4061 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4062 | */ |
| 4063 | static PyObject *py_pjsua_acc_get_info |
| 4064 | (PyObject *pSelf, PyObject *pArgs) |
| 4065 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4066 | int acc_id; |
| 4067 | acc_info_Object * obj; |
| 4068 | pjsua_acc_info info; |
| 4069 | int status; |
| 4070 | int i; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4071 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4072 | if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4073 | { |
| 4074 | return NULL; |
| 4075 | } |
| 4076 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4077 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4078 | status = pjsua_acc_get_info(acc_id, &info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4079 | if (status == PJ_SUCCESS) { |
| 4080 | obj = (acc_info_Object *)acc_info_new(&acc_info_Type,NULL, NULL); |
| 4081 | obj->acc_uri = |
| 4082 | PyString_FromStringAndSize(info.acc_uri.ptr, |
| 4083 | info.acc_uri.slen); |
| 4084 | for (i = 0; i < PJ_ERR_MSG_SIZE; i++) { |
| 4085 | obj->buf_[i] = info.buf_[i]; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4086 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4087 | obj->expires = info.expires; |
| 4088 | obj->has_registration = info.has_registration; |
| 4089 | obj->id = info.id; |
| 4090 | obj->is_default = info.is_default; |
| 4091 | obj->online_status = info.online_status; |
| 4092 | obj->status = info.status; |
| 4093 | obj->status_text = |
| 4094 | PyString_FromStringAndSize(info.status_text.ptr, |
| 4095 | info.status_text.slen); |
| 4096 | return Py_BuildValue("O", obj); |
| 4097 | } else { |
| 4098 | Py_INCREF(Py_None); |
| 4099 | return Py_None; |
| 4100 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4101 | } |
| 4102 | |
| 4103 | /* |
| 4104 | * py_pjsua_enum_accs |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4105 | * !modified @ 241206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4106 | */ |
| 4107 | static PyObject *py_pjsua_enum_accs(PyObject *pSelf, PyObject *pArgs) |
| 4108 | { |
| 4109 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4110 | PyObject *list; |
| 4111 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4112 | pjsua_acc_id id[PJSUA_MAX_ACC]; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4113 | int c, i; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4114 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4115 | { |
| 4116 | return NULL; |
| 4117 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4118 | c = PJ_ARRAY_SIZE(id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4119 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4120 | status = pjsua_enum_accs(id, &c); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4121 | |
| 4122 | list = PyList_New(c); |
| 4123 | for (i = 0; i < c; i++) { |
| 4124 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 4125 | if (ret == -1) { |
| 4126 | return NULL; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4127 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4128 | } |
| 4129 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 4130 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4131 | return Py_BuildValue("O",list); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4132 | } |
| 4133 | |
| 4134 | /* |
| 4135 | * py_pjsua_acc_enum_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4136 | * !modified @ 241206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4137 | */ |
| 4138 | static PyObject *py_pjsua_acc_enum_info(PyObject *pSelf, PyObject *pArgs) |
| 4139 | { |
| 4140 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4141 | PyObject *list; |
| 4142 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4143 | pjsua_acc_info info[PJSUA_MAX_ACC]; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4144 | int c, i; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4145 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4146 | { |
| 4147 | return NULL; |
| 4148 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4149 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4150 | c = PJ_ARRAY_SIZE(info); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4151 | status = pjsua_acc_enum_info(info, &c); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4152 | |
| 4153 | list = PyList_New(c); |
| 4154 | for (i = 0; i < c; i++) { |
| 4155 | int ret; |
| 4156 | int j; |
| 4157 | acc_info_Object *obj; |
| 4158 | obj = (acc_info_Object *)acc_info_new(&acc_info_Type,NULL,NULL); |
| 4159 | obj->acc_uri = PyString_FromStringAndSize |
| 4160 | (info[i].acc_uri.ptr, info[i].acc_uri.slen); |
| 4161 | for(j = 0; j < PJ_ERR_MSG_SIZE; j++) { |
| 4162 | obj->buf_[j] = info[i].buf_[j]; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4163 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4164 | obj->expires = info[i].expires; |
| 4165 | obj->has_registration = info[i].has_registration; |
| 4166 | obj->id = info[i].id; |
| 4167 | obj->is_default = info[i].is_default; |
| 4168 | obj->online_status = info[i].online_status; |
| 4169 | obj->status = info[i].status; |
| 4170 | obj->status_text = PyString_FromStringAndSize(info[i].status_text.ptr, |
| 4171 | info[i].status_text.slen); |
| 4172 | ret = PyList_SetItem(list, i, (PyObject *)obj); |
| 4173 | if (ret == -1) { |
| 4174 | return NULL; |
| 4175 | } |
| 4176 | } |
| 4177 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 4178 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4179 | return Py_BuildValue("O",list); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4180 | } |
| 4181 | |
| 4182 | /* |
| 4183 | * py_pjsua_acc_find_for_outgoing |
| 4184 | */ |
| 4185 | static PyObject *py_pjsua_acc_find_for_outgoing |
| 4186 | (PyObject *pSelf, PyObject *pArgs) |
| 4187 | { |
| 4188 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4189 | int acc_id; |
| 4190 | PyObject * url; |
| 4191 | pj_str_t str; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4192 | |
| 4193 | if (!PyArg_ParseTuple(pArgs, "O", &url)) |
| 4194 | { |
| 4195 | return NULL; |
| 4196 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4197 | str.ptr = PyString_AsString(url); |
| 4198 | str.slen = strlen(PyString_AsString(url)); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4199 | |
| 4200 | acc_id = pjsua_acc_find_for_outgoing(&str); |
| 4201 | |
| 4202 | return Py_BuildValue("i", acc_id); |
| 4203 | } |
| 4204 | |
| 4205 | /* |
| 4206 | * py_pjsua_acc_find_for_incoming |
| 4207 | */ |
| 4208 | static PyObject *py_pjsua_acc_find_for_incoming |
| 4209 | (PyObject *pSelf, PyObject *pArgs) |
| 4210 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4211 | int acc_id; |
| 4212 | pjsip_rx_data_Object * obj; |
| 4213 | pjsip_rx_data * rdata; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4214 | |
| 4215 | if (!PyArg_ParseTuple(pArgs, "O", &obj)) |
| 4216 | { |
| 4217 | return NULL; |
| 4218 | } |
| 4219 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4220 | rdata = obj->rdata; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4221 | acc_id = pjsua_acc_find_for_incoming(rdata); |
| 4222 | |
| 4223 | return Py_BuildValue("i", acc_id); |
| 4224 | } |
| 4225 | |
| 4226 | /* |
| 4227 | * py_pjsua_acc_create_uac_contact |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4228 | * !modified @ 061206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4229 | */ |
| 4230 | static PyObject *py_pjsua_acc_create_uac_contact |
| 4231 | (PyObject *pSelf, PyObject *pArgs) |
| 4232 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4233 | int status; |
| 4234 | int acc_id; |
| 4235 | pj_pool_Object * p; |
| 4236 | pj_pool_t * pool; |
| 4237 | PyObject * strc; |
| 4238 | pj_str_t contact; |
| 4239 | PyObject * stru; |
| 4240 | pj_str_t uri; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4241 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4242 | if (!PyArg_ParseTuple(pArgs, "OiO", &p, &acc_id, &stru)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4243 | { |
| 4244 | return NULL; |
| 4245 | } |
| 4246 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4247 | pool = p->pool; |
| 4248 | uri.ptr = PyString_AsString(stru); |
| 4249 | uri.slen = strlen(PyString_AsString(stru)); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4250 | status = pjsua_acc_create_uac_contact(pool, &contact, acc_id, &uri); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4251 | strc = PyString_FromStringAndSize(contact.ptr, contact.slen); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4252 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4253 | return Py_BuildValue("O", strc); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4254 | } |
| 4255 | |
| 4256 | /* |
| 4257 | * py_pjsua_acc_create_uas_contact |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4258 | * !modified @ 061206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4259 | */ |
| 4260 | static PyObject *py_pjsua_acc_create_uas_contact |
| 4261 | (PyObject *pSelf, PyObject *pArgs) |
| 4262 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4263 | int status; |
| 4264 | int acc_id; |
| 4265 | pj_pool_Object * p; |
| 4266 | pj_pool_t * pool; |
| 4267 | PyObject * strc; |
| 4268 | pj_str_t contact; |
| 4269 | pjsip_rx_data_Object * objr; |
| 4270 | pjsip_rx_data * rdata; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4271 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4272 | if (!PyArg_ParseTuple(pArgs, "OiO", &p, &acc_id, &objr)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4273 | { |
| 4274 | return NULL; |
| 4275 | } |
| 4276 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4277 | pool = p->pool; |
| 4278 | |
| 4279 | rdata = objr->rdata; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4280 | status = pjsua_acc_create_uas_contact(pool, &contact, acc_id, rdata); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4281 | strc = PyString_FromStringAndSize(contact.ptr, contact.slen); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4282 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4283 | return Py_BuildValue("O", strc); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4284 | } |
| 4285 | |
| 4286 | static char pjsua_acc_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4287 | "py_pjsua.Acc_Config py_pjsua.acc_config_default () " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4288 | "Call this function to initialize account config with default values."; |
| 4289 | static char pjsua_acc_get_count_doc[] = |
| 4290 | "int py_pjsua.acc_get_count () " |
| 4291 | "Get number of current accounts."; |
| 4292 | static char pjsua_acc_is_valid_doc[] = |
| 4293 | "int py_pjsua.acc_is_valid (int acc_id) " |
| 4294 | "Check if the specified account ID is valid."; |
| 4295 | static char pjsua_acc_set_default_doc[] = |
| 4296 | "int py_pjsua.acc_set_default (int acc_id) " |
| 4297 | "Set default account to be used when incoming " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4298 | "and outgoing requests doesn't match any accounts."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4299 | static char pjsua_acc_get_default_doc[] = |
| 4300 | "int py_pjsua.acc_get_default () " |
| 4301 | "Get default account."; |
| 4302 | static char pjsua_acc_add_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4303 | "int, int py_pjsua.acc_add (py_pjsua.Acc_Config cfg, " |
| 4304 | "int is_default) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4305 | "Add a new account to pjsua. PJSUA must have been initialized " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4306 | "(with pjsua_init()) before calling this function."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4307 | static char pjsua_acc_add_local_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4308 | "int,int py_pjsua.acc_add_local (int tid, " |
| 4309 | "int is_default) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4310 | "Add a local account. A local account is used to identify " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4311 | "local endpoint instead of a specific user, and for this reason, " |
| 4312 | "a transport ID is needed to obtain the local address information."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4313 | static char pjsua_acc_del_doc[] = |
| 4314 | "int py_pjsua.acc_del (int acc_id) " |
| 4315 | "Delete account."; |
| 4316 | static char pjsua_acc_modify_doc[] = |
| 4317 | "int py_pjsua.acc_modify (int acc_id, py_pjsua.Acc_Config cfg) " |
| 4318 | "Modify account information."; |
| 4319 | static char pjsua_acc_set_online_status_doc[] = |
| 4320 | "int py_pjsua.acc_set_online_status (int acc_id, int is_online) " |
| 4321 | "Modify account's presence status to be advertised " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4322 | "to remote/presence subscribers."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4323 | static char pjsua_acc_set_registration_doc[] = |
| 4324 | "int py_pjsua.acc_set_registration (int acc_id, int renew) " |
| 4325 | "Update registration or perform unregistration."; |
| 4326 | static char pjsua_acc_get_info_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4327 | "py_pjsua.Acc_Info py_pjsua.acc_get_info (int acc_id) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4328 | "Get account information."; |
| 4329 | static char pjsua_enum_accs_doc[] = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4330 | "int[] py_pjsua.enum_accs () " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4331 | "Enum accounts all account ids."; |
| 4332 | static char pjsua_acc_enum_info_doc[] = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4333 | "py_pjsua.Acc_Info[] py_pjsua.acc_enum_info () " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4334 | "Enum accounts info."; |
| 4335 | static char pjsua_acc_find_for_outgoing_doc[] = |
| 4336 | "int py_pjsua.acc_find_for_outgoing (string url) " |
| 4337 | "This is an internal function to find the most appropriate account " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4338 | "to used to reach to the specified URL."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4339 | static char pjsua_acc_find_for_incoming_doc[] = |
| 4340 | "int py_pjsua.acc_find_for_incoming (pjsip_rx_data_Object rdata) " |
| 4341 | "This is an internal function to find the most appropriate account " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4342 | "to be used to handle incoming calls."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4343 | static char pjsua_acc_create_uac_contact_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4344 | "string py_pjsua.acc_create_uac_contact (pj_pool_Object pool, " |
| 4345 | "int acc_id, string uri) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4346 | "Create a suitable URI to be put as Contact based on the specified " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4347 | "target URI for the specified account."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4348 | static char pjsua_acc_create_uas_contact_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4349 | "string py_pjsua.acc_create_uas_contact (pj_pool_Object pool, " |
| 4350 | "int acc_id, pjsip_rx_data_Object rdata) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4351 | "Create a suitable URI to be put as Contact based on the information " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4352 | "in the incoming request."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4353 | |
| 4354 | /* END OF LIB ACCOUNT */ |
| 4355 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4356 | /* LIB BUDDY */ |
| 4357 | |
| 4358 | |
| 4359 | |
| 4360 | /* |
| 4361 | * buddy_config_Object |
| 4362 | * Buddy Config |
| 4363 | */ |
| 4364 | typedef struct |
| 4365 | { |
| 4366 | PyObject_HEAD |
| 4367 | /* Type-specific fields go here. */ |
| 4368 | |
| 4369 | PyObject * uri; |
| 4370 | int subscribe; |
| 4371 | } buddy_config_Object; |
| 4372 | |
| 4373 | |
| 4374 | /* |
| 4375 | * buddy_config_dealloc |
| 4376 | * deletes a buddy_config from memory |
| 4377 | */ |
| 4378 | static void buddy_config_dealloc(buddy_config_Object* self) |
| 4379 | { |
| 4380 | Py_XDECREF(self->uri); |
| 4381 | self->ob_type->tp_free((PyObject*)self); |
| 4382 | } |
| 4383 | |
| 4384 | |
| 4385 | /* |
| 4386 | * buddy_config_new |
| 4387 | * constructor for buddy_config object |
| 4388 | */ |
| 4389 | static PyObject * buddy_config_new(PyTypeObject *type, PyObject *args, |
| 4390 | PyObject *kwds) |
| 4391 | { |
| 4392 | buddy_config_Object *self; |
| 4393 | |
| 4394 | self = (buddy_config_Object *)type->tp_alloc(type, 0); |
| 4395 | if (self != NULL) |
| 4396 | { |
| 4397 | self->uri = PyString_FromString(""); |
| 4398 | if (self->uri == NULL) |
| 4399 | { |
| 4400 | Py_DECREF(self); |
| 4401 | return NULL; |
| 4402 | } |
| 4403 | } |
| 4404 | return (PyObject *)self; |
| 4405 | } |
| 4406 | |
| 4407 | /* |
| 4408 | * buddy_config_members |
| 4409 | */ |
| 4410 | static PyMemberDef buddy_config_members[] = |
| 4411 | { |
| 4412 | |
| 4413 | { |
| 4414 | "uri", T_OBJECT_EX, |
| 4415 | offsetof(buddy_config_Object, uri), 0, |
| 4416 | "TBuddy URL or name address." |
| 4417 | }, |
| 4418 | |
| 4419 | { |
| 4420 | "subscribe", T_INT, |
| 4421 | offsetof(buddy_config_Object, subscribe), 0, |
| 4422 | "Specify whether presence subscription should start immediately. " |
| 4423 | }, |
| 4424 | |
| 4425 | {NULL} /* Sentinel */ |
| 4426 | }; |
| 4427 | |
| 4428 | |
| 4429 | |
| 4430 | |
| 4431 | /* |
| 4432 | * buddy_config_Type |
| 4433 | */ |
| 4434 | static PyTypeObject buddy_config_Type = |
| 4435 | { |
| 4436 | PyObject_HEAD_INIT(NULL) |
| 4437 | 0, /*ob_size*/ |
| 4438 | "py_pjsua.Buddy_Config", /*tp_name*/ |
| 4439 | sizeof(buddy_config_Object), /*tp_basicsize*/ |
| 4440 | 0, /*tp_itemsize*/ |
| 4441 | (destructor)buddy_config_dealloc,/*tp_dealloc*/ |
| 4442 | 0, /*tp_print*/ |
| 4443 | 0, /*tp_getattr*/ |
| 4444 | 0, /*tp_setattr*/ |
| 4445 | 0, /*tp_compare*/ |
| 4446 | 0, /*tp_repr*/ |
| 4447 | 0, /*tp_as_number*/ |
| 4448 | 0, /*tp_as_sequence*/ |
| 4449 | 0, /*tp_as_mapping*/ |
| 4450 | 0, /*tp_hash */ |
| 4451 | 0, /*tp_call*/ |
| 4452 | 0, /*tp_str*/ |
| 4453 | 0, /*tp_getattro*/ |
| 4454 | 0, /*tp_setattro*/ |
| 4455 | 0, /*tp_as_buffer*/ |
| 4456 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 4457 | "Buddy Config objects", /* tp_doc */ |
| 4458 | 0, /* tp_traverse */ |
| 4459 | 0, /* tp_clear */ |
| 4460 | 0, /* tp_richcompare */ |
| 4461 | 0, /* tp_weaklistoffset */ |
| 4462 | 0, /* tp_iter */ |
| 4463 | 0, /* tp_iternext */ |
| 4464 | 0, /* tp_methods */ |
| 4465 | buddy_config_members, /* tp_members */ |
| 4466 | 0, /* tp_getset */ |
| 4467 | 0, /* tp_base */ |
| 4468 | 0, /* tp_dict */ |
| 4469 | 0, /* tp_descr_get */ |
| 4470 | 0, /* tp_descr_set */ |
| 4471 | 0, /* tp_dictoffset */ |
| 4472 | 0, /* tp_init */ |
| 4473 | 0, /* tp_alloc */ |
| 4474 | buddy_config_new, /* tp_new */ |
| 4475 | |
| 4476 | }; |
| 4477 | |
| 4478 | /* |
| 4479 | * buddy_info_Object |
| 4480 | * Buddy Info |
| 4481 | * !modified @ 071206 |
| 4482 | */ |
| 4483 | typedef struct |
| 4484 | { |
| 4485 | PyObject_HEAD |
| 4486 | /* Type-specific fields go here. */ |
| 4487 | int id; |
| 4488 | PyObject * uri; |
| 4489 | PyObject * contact; |
| 4490 | int status; |
| 4491 | PyObject * status_text; |
| 4492 | int monitor_pres; |
| 4493 | char buf_[256]; |
| 4494 | } buddy_info_Object; |
| 4495 | |
| 4496 | |
| 4497 | /* |
| 4498 | * buddy_info_dealloc |
| 4499 | * deletes a buddy_info from memory |
| 4500 | * !modified @ 071206 |
| 4501 | */ |
| 4502 | static void buddy_info_dealloc(buddy_info_Object* self) |
| 4503 | { |
| 4504 | Py_XDECREF(self->uri); |
| 4505 | Py_XDECREF(self->contact); |
| 4506 | Py_XDECREF(self->status_text); |
| 4507 | |
| 4508 | self->ob_type->tp_free((PyObject*)self); |
| 4509 | } |
| 4510 | |
| 4511 | |
| 4512 | /* |
| 4513 | * buddy_info_new |
| 4514 | * constructor for buddy_info object |
| 4515 | * !modified @ 071206 |
| 4516 | */ |
| 4517 | static PyObject * buddy_info_new(PyTypeObject *type, PyObject *args, |
| 4518 | PyObject *kwds) |
| 4519 | { |
| 4520 | buddy_info_Object *self; |
| 4521 | |
| 4522 | self = (buddy_info_Object *)type->tp_alloc(type, 0); |
| 4523 | if (self != NULL) |
| 4524 | { |
| 4525 | self->uri = PyString_FromString(""); |
| 4526 | if (self->uri == NULL) |
| 4527 | { |
| 4528 | Py_DECREF(self); |
| 4529 | return NULL; |
| 4530 | } |
| 4531 | self->contact = PyString_FromString(""); |
| 4532 | if (self->contact == NULL) |
| 4533 | { |
| 4534 | Py_DECREF(self); |
| 4535 | return NULL; |
| 4536 | } |
| 4537 | self->status_text = PyString_FromString(""); |
| 4538 | if (self->status_text == NULL) |
| 4539 | { |
| 4540 | Py_DECREF(self); |
| 4541 | return NULL; |
| 4542 | } |
| 4543 | |
| 4544 | } |
| 4545 | return (PyObject *)self; |
| 4546 | } |
| 4547 | |
| 4548 | /* |
| 4549 | * buddy_info_members |
| 4550 | * !modified @ 071206 |
| 4551 | */ |
| 4552 | static PyMemberDef buddy_info_members[] = |
| 4553 | { |
| 4554 | { |
| 4555 | "id", T_INT, |
| 4556 | offsetof(buddy_info_Object, id), 0, |
| 4557 | "The buddy ID." |
| 4558 | }, |
| 4559 | { |
| 4560 | "uri", T_OBJECT_EX, |
| 4561 | offsetof(buddy_info_Object, uri), 0, |
| 4562 | "The full URI of the buddy, as specified in the configuration. " |
| 4563 | }, |
| 4564 | { |
| 4565 | "contact", T_OBJECT_EX, |
| 4566 | offsetof(buddy_info_Object, contact), 0, |
| 4567 | "Buddy's Contact, only available when presence subscription " |
| 4568 | "has been established to the buddy." |
| 4569 | }, |
| 4570 | { |
| 4571 | "status", T_INT, |
| 4572 | offsetof(buddy_info_Object, status), 0, |
| 4573 | "Buddy's online status. " |
| 4574 | }, |
| 4575 | { |
| 4576 | "status_text", T_OBJECT_EX, |
| 4577 | offsetof(buddy_info_Object, status_text), 0, |
| 4578 | "Text to describe buddy's online status." |
| 4579 | }, |
| 4580 | { |
| 4581 | "monitor_pres", T_INT, |
| 4582 | offsetof(buddy_info_Object, monitor_pres), 0, |
| 4583 | "Flag to indicate that we should monitor the presence information " |
| 4584 | "for this buddy (normally yes, unless explicitly disabled). " |
| 4585 | }, |
| 4586 | |
| 4587 | |
| 4588 | {NULL} /* Sentinel */ |
| 4589 | }; |
| 4590 | |
| 4591 | |
| 4592 | |
| 4593 | |
| 4594 | /* |
| 4595 | * buddy_info_Type |
| 4596 | */ |
| 4597 | static PyTypeObject buddy_info_Type = |
| 4598 | { |
| 4599 | PyObject_HEAD_INIT(NULL) |
| 4600 | 0, /*ob_size*/ |
| 4601 | "py_pjsua.Buddy_Info", /*tp_name*/ |
| 4602 | sizeof(buddy_info_Object), /*tp_basicsize*/ |
| 4603 | 0, /*tp_itemsize*/ |
| 4604 | (destructor)buddy_info_dealloc,/*tp_dealloc*/ |
| 4605 | 0, /*tp_print*/ |
| 4606 | 0, /*tp_getattr*/ |
| 4607 | 0, /*tp_setattr*/ |
| 4608 | 0, /*tp_compare*/ |
| 4609 | 0, /*tp_repr*/ |
| 4610 | 0, /*tp_as_number*/ |
| 4611 | 0, /*tp_as_sequence*/ |
| 4612 | 0, /*tp_as_mapping*/ |
| 4613 | 0, /*tp_hash */ |
| 4614 | 0, /*tp_call*/ |
| 4615 | 0, /*tp_str*/ |
| 4616 | 0, /*tp_getattro*/ |
| 4617 | 0, /*tp_setattro*/ |
| 4618 | 0, /*tp_as_buffer*/ |
| 4619 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 4620 | "Buddy Info objects", /* tp_doc */ |
| 4621 | 0, /* tp_traverse */ |
| 4622 | 0, /* tp_clear */ |
| 4623 | 0, /* tp_richcompare */ |
| 4624 | 0, /* tp_weaklistoffset */ |
| 4625 | 0, /* tp_iter */ |
| 4626 | 0, /* tp_iternext */ |
| 4627 | 0, /* tp_methods */ |
| 4628 | buddy_info_members, /* tp_members */ |
| 4629 | 0, /* tp_getset */ |
| 4630 | 0, /* tp_base */ |
| 4631 | 0, /* tp_dict */ |
| 4632 | 0, /* tp_descr_get */ |
| 4633 | 0, /* tp_descr_set */ |
| 4634 | 0, /* tp_dictoffset */ |
| 4635 | 0, /* tp_init */ |
| 4636 | 0, /* tp_alloc */ |
| 4637 | buddy_info_new, /* tp_new */ |
| 4638 | |
| 4639 | }; |
| 4640 | |
| 4641 | /* |
| 4642 | * py_pjsua_get_buddy_count |
| 4643 | */ |
| 4644 | static PyObject *py_pjsua_get_buddy_count |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4645 | (PyObject *pSelf, PyObject *pArgs) |
| 4646 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4647 | int ret; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4648 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4649 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4650 | { |
| 4651 | return NULL; |
| 4652 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4653 | ret = pjsua_get_buddy_count(); |
| 4654 | |
| 4655 | return Py_BuildValue("i", ret); |
| 4656 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4657 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4658 | /* |
| 4659 | * py_pjsua_buddy_is_valid |
| 4660 | */ |
| 4661 | static PyObject *py_pjsua_buddy_is_valid |
| 4662 | (PyObject *pSelf, PyObject *pArgs) |
| 4663 | { |
| 4664 | int id; |
| 4665 | int is_valid; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4666 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4667 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 4668 | { |
| 4669 | return NULL; |
| 4670 | } |
| 4671 | is_valid = pjsua_buddy_is_valid(id); |
| 4672 | |
| 4673 | return Py_BuildValue("i", is_valid); |
| 4674 | } |
| 4675 | |
| 4676 | /* |
| 4677 | * py_pjsua_enum_buddies |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4678 | * !modified @ 241206 |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4679 | */ |
| 4680 | static PyObject *py_pjsua_enum_buddies(PyObject *pSelf, PyObject *pArgs) |
| 4681 | { |
| 4682 | pj_status_t status; |
| 4683 | PyObject *list; |
| 4684 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4685 | pjsua_buddy_id id[PJSUA_MAX_BUDDIES]; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4686 | int c, i; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4687 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4688 | { |
| 4689 | return NULL; |
| 4690 | } |
| 4691 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4692 | c = PJ_ARRAY_SIZE(id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4693 | status = pjsua_enum_buddies(id, &c); |
| 4694 | |
| 4695 | list = PyList_New(c); |
| 4696 | for (i = 0; i < c; i++) { |
| 4697 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 4698 | if (ret == -1) { |
| 4699 | return NULL; |
| 4700 | } |
| 4701 | } |
| 4702 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 4703 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4704 | return Py_BuildValue("O",list); |
| 4705 | } |
| 4706 | |
| 4707 | /* |
| 4708 | * py_pjsua_buddy_get_info |
| 4709 | * !modified @ 071206 |
| 4710 | */ |
| 4711 | static PyObject *py_pjsua_buddy_get_info |
| 4712 | (PyObject *pSelf, PyObject *pArgs) |
| 4713 | { |
| 4714 | int buddy_id; |
| 4715 | buddy_info_Object * obj; |
| 4716 | pjsua_buddy_info info; |
| 4717 | int status; |
| 4718 | int i; |
| 4719 | |
| 4720 | if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) |
| 4721 | { |
| 4722 | return NULL; |
| 4723 | } |
| 4724 | |
| 4725 | |
| 4726 | status = pjsua_buddy_get_info(buddy_id, &info); |
| 4727 | if (status == PJ_SUCCESS) { |
| 4728 | obj = (buddy_info_Object *)buddy_info_new(&buddy_info_Type,NULL,NULL); |
| 4729 | obj->id = info.id; |
| 4730 | Py_XDECREF(obj->uri); |
| 4731 | obj->uri = |
| 4732 | PyString_FromStringAndSize(info.uri.ptr, |
| 4733 | info.uri.slen); |
| 4734 | Py_XDECREF(obj->contact); |
| 4735 | obj->contact = |
| 4736 | PyString_FromStringAndSize(info.contact.ptr, |
| 4737 | info.contact.slen); |
| 4738 | obj->status = info.status; |
| 4739 | Py_XDECREF(obj->status_text); |
| 4740 | obj->status_text = |
| 4741 | PyString_FromStringAndSize(info.status_text.ptr, |
| 4742 | info.status_text.slen); |
| 4743 | obj->monitor_pres = info.monitor_pres; |
| 4744 | for (i = 0; i < 256; i++) { |
| 4745 | |
| 4746 | obj->buf_[i] = info.buf_[i]; |
| 4747 | } |
| 4748 | |
| 4749 | return Py_BuildValue("O", obj); |
| 4750 | } else { |
| 4751 | Py_INCREF(Py_None); |
| 4752 | return Py_None; |
| 4753 | } |
| 4754 | } |
| 4755 | |
| 4756 | /* |
| 4757 | * py_pjsua_buddy_add |
| 4758 | * !modified @ 061206 |
| 4759 | */ |
| 4760 | static PyObject *py_pjsua_buddy_add |
| 4761 | (PyObject *pSelf, PyObject *pArgs) |
| 4762 | { |
| 4763 | buddy_config_Object * bc; |
| 4764 | pjsua_buddy_config cfg; |
| 4765 | |
| 4766 | int p_buddy_id; |
| 4767 | int status; |
| 4768 | |
| 4769 | if (!PyArg_ParseTuple(pArgs, "O", &bc)) |
| 4770 | { |
| 4771 | return NULL; |
| 4772 | } |
| 4773 | cfg.subscribe = bc->subscribe; |
| 4774 | cfg.uri.ptr = PyString_AsString(bc->uri); |
| 4775 | cfg.uri.slen = strlen(PyString_AsString(bc->uri)); |
| 4776 | |
| 4777 | status = pjsua_buddy_add(&cfg, &p_buddy_id); |
| 4778 | |
| 4779 | return Py_BuildValue("ii", status, p_buddy_id); |
| 4780 | } |
| 4781 | |
| 4782 | /* |
| 4783 | * py_pjsua_buddy_del |
| 4784 | */ |
| 4785 | static PyObject *py_pjsua_buddy_del |
| 4786 | (PyObject *pSelf, PyObject *pArgs) |
| 4787 | { |
| 4788 | int buddy_id; |
| 4789 | int status; |
| 4790 | |
| 4791 | if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) |
| 4792 | { |
| 4793 | return NULL; |
| 4794 | } |
| 4795 | |
| 4796 | |
| 4797 | status = pjsua_buddy_del(buddy_id); |
| 4798 | return Py_BuildValue("i", status); |
| 4799 | } |
| 4800 | |
| 4801 | /* |
| 4802 | * py_pjsua_buddy_subscribe_pres |
| 4803 | */ |
| 4804 | static PyObject *py_pjsua_buddy_subscribe_pres |
| 4805 | (PyObject *pSelf, PyObject *pArgs) |
| 4806 | { |
| 4807 | int buddy_id; |
| 4808 | int status; |
| 4809 | int subscribe; |
| 4810 | |
| 4811 | if (!PyArg_ParseTuple(pArgs, "ii", &buddy_id, &subscribe)) |
| 4812 | { |
| 4813 | return NULL; |
| 4814 | } |
| 4815 | |
| 4816 | |
| 4817 | status = pjsua_buddy_subscribe_pres(buddy_id, subscribe); |
| 4818 | return Py_BuildValue("i", status); |
| 4819 | } |
| 4820 | |
| 4821 | /* |
| 4822 | * py_pjsua_pres_dump |
| 4823 | */ |
| 4824 | static PyObject *py_pjsua_pres_dump |
| 4825 | (PyObject *pSelf, PyObject *pArgs) |
| 4826 | { |
| 4827 | int verbose; |
| 4828 | |
| 4829 | if (!PyArg_ParseTuple(pArgs, "i", &verbose)) |
| 4830 | { |
| 4831 | return NULL; |
| 4832 | } |
| 4833 | |
| 4834 | |
| 4835 | pjsua_pres_dump(verbose); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4836 | Py_INCREF(Py_None); |
| 4837 | return Py_None; |
| 4838 | } |
| 4839 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4840 | /* |
| 4841 | * py_pjsua_im_send |
| 4842 | * !modified @ 071206 |
| 4843 | */ |
| 4844 | static PyObject *py_pjsua_im_send |
| 4845 | (PyObject *pSelf, PyObject *pArgs) |
| 4846 | { |
| 4847 | int status; |
| 4848 | int acc_id; |
| 4849 | pj_str_t to, mime_type, content; |
| 4850 | PyObject * st; |
| 4851 | PyObject * smt; |
| 4852 | PyObject * sc; |
| 4853 | pjsua_msg_data msg_data; |
| 4854 | msg_data_Object * omd; |
| 4855 | int user_data; |
| 4856 | pj_pool_t *pool; |
| 4857 | |
| 4858 | if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id, &st, &smt, &sc, &omd, &user_data)) |
| 4859 | { |
| 4860 | return NULL; |
| 4861 | } |
| 4862 | |
| 4863 | to.ptr = PyString_AsString(st); |
| 4864 | to.slen = strlen(PyString_AsString(st)); |
| 4865 | mime_type.ptr = PyString_AsString(smt); |
| 4866 | mime_type.slen = strlen(PyString_AsString(smt)); |
| 4867 | content.ptr = PyString_AsString(sc); |
| 4868 | content.slen = strlen(PyString_AsString(sc)); |
| 4869 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4870 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 4871 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4872 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 4873 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 4874 | |
| 4875 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4876 | status = pjsua_im_send(acc_id, &to, &mime_type, &content, &msg_data, &user_data); |
| 4877 | pj_pool_release(pool); |
| 4878 | return Py_BuildValue("i",status); |
| 4879 | } |
| 4880 | |
| 4881 | /* |
| 4882 | * py_pjsua_im_typing |
| 4883 | */ |
| 4884 | static PyObject *py_pjsua_im_typing |
| 4885 | (PyObject *pSelf, PyObject *pArgs) |
| 4886 | { |
| 4887 | int status; |
| 4888 | int acc_id; |
| 4889 | pj_str_t to; |
| 4890 | PyObject * st; |
| 4891 | int is_typing; |
| 4892 | pjsua_msg_data msg_data; |
| 4893 | msg_data_Object * omd; |
| 4894 | pj_pool_t * pool; |
| 4895 | |
| 4896 | if (!PyArg_ParseTuple(pArgs, "iOiO", &acc_id, &st, &is_typing, &omd)) |
| 4897 | { |
| 4898 | return NULL; |
| 4899 | } |
| 4900 | |
| 4901 | to.ptr = PyString_AsString(st); |
| 4902 | to.slen = strlen(PyString_AsString(st)); |
| 4903 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4904 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 4905 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4906 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 4907 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 4908 | |
| 4909 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4910 | status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data); |
| 4911 | pj_pool_release(pool); |
| 4912 | return Py_BuildValue("i",status); |
| 4913 | } |
| 4914 | |
| 4915 | static char pjsua_get_buddy_count_doc[] = |
| 4916 | "int py_pjsua.get_buddy_count () " |
| 4917 | "Get total number of buddies."; |
| 4918 | static char pjsua_buddy_is_valid_doc[] = |
| 4919 | "int py_pjsua.buddy_is_valid (int buddy_id) " |
| 4920 | "Check if buddy ID is valid."; |
| 4921 | static char pjsua_enum_buddies_doc[] = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4922 | "int[] py_pjsua.enum_buddies () " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 4923 | "Enum buddy IDs."; |
| 4924 | static char pjsua_buddy_get_info_doc[] = |
| 4925 | "py_pjsua.Buddy_Info py_pjsua.buddy_get_info (int buddy_id) " |
| 4926 | "Get detailed buddy info."; |
| 4927 | static char pjsua_buddy_add_doc[] = |
| 4928 | "int,int py_pjsua.buddy_add (py_pjsua.Buddy_Config cfg) " |
| 4929 | "Add new buddy."; |
| 4930 | static char pjsua_buddy_del_doc[] = |
| 4931 | "int py_pjsua.buddy_del (int buddy_id) " |
| 4932 | "Delete buddy."; |
| 4933 | static char pjsua_buddy_subscribe_pres_doc[] = |
| 4934 | "int py_pjsua.buddy_subscribe_pres (int buddy_id, int subscribe) " |
| 4935 | "Enable/disable buddy's presence monitoring."; |
| 4936 | static char pjsua_pres_dump_doc[] = |
| 4937 | "void py_pjsua.pres_dump (int verbose) " |
| 4938 | "Dump presence subscriptions to log file."; |
| 4939 | static char pjsua_im_send_doc[] = |
| 4940 | "int py_pjsua.im_send (int acc_id, string to, string mime_type, " |
| 4941 | "string content, py_pjsua.Msg_Data msg_data, int user_data) " |
| 4942 | "Send instant messaging outside dialog, using the specified account " |
| 4943 | "for route set and authentication."; |
| 4944 | static char pjsua_im_typing_doc[] = |
| 4945 | "int py_pjsua.im_typing (int acc_id, string to, int is_typing, " |
| 4946 | "py_pjsua.Msg_Data msg_data) " |
| 4947 | "Send typing indication outside dialog."; |
| 4948 | |
| 4949 | /* END OF LIB BUDDY */ |
| 4950 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4951 | /* LIB MEDIA */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 4952 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 4953 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4954 | |
| 4955 | /* |
| 4956 | * codec_info_Object |
| 4957 | * Codec Info |
| 4958 | * !modified @ 071206 |
| 4959 | */ |
| 4960 | typedef struct |
| 4961 | { |
| 4962 | PyObject_HEAD |
| 4963 | /* Type-specific fields go here. */ |
| 4964 | |
| 4965 | PyObject * codec_id; |
| 4966 | pj_uint8_t priority; |
| 4967 | char buf_[32]; |
| 4968 | } codec_info_Object; |
| 4969 | |
| 4970 | |
| 4971 | /* |
| 4972 | * codec_info_dealloc |
| 4973 | * deletes a codec_info from memory |
| 4974 | * !modified @ 071206 |
| 4975 | */ |
| 4976 | static void codec_info_dealloc(codec_info_Object* self) |
| 4977 | { |
| 4978 | Py_XDECREF(self->codec_id); |
| 4979 | |
| 4980 | self->ob_type->tp_free((PyObject*)self); |
| 4981 | } |
| 4982 | |
| 4983 | |
| 4984 | /* |
| 4985 | * codec_info_new |
| 4986 | * constructor for codec_info object |
| 4987 | * !modified @ 071206 |
| 4988 | */ |
| 4989 | static PyObject * codec_info_new(PyTypeObject *type, PyObject *args, |
| 4990 | PyObject *kwds) |
| 4991 | { |
| 4992 | codec_info_Object *self; |
| 4993 | |
| 4994 | self = (codec_info_Object *)type->tp_alloc(type, 0); |
| 4995 | if (self != NULL) |
| 4996 | { |
| 4997 | self->codec_id = PyString_FromString(""); |
| 4998 | if (self->codec_id == NULL) |
| 4999 | { |
| 5000 | Py_DECREF(self); |
| 5001 | return NULL; |
| 5002 | } |
| 5003 | |
| 5004 | |
| 5005 | } |
| 5006 | return (PyObject *)self; |
| 5007 | } |
| 5008 | |
| 5009 | /* |
| 5010 | * codec_info_members |
| 5011 | * !modified @ 071206 |
| 5012 | */ |
| 5013 | static PyMemberDef codec_info_members[] = |
| 5014 | { |
| 5015 | { |
| 5016 | "codec_id", T_OBJECT_EX, |
| 5017 | offsetof(codec_info_Object, codec_id), 0, |
| 5018 | "Codec unique identification." |
| 5019 | }, |
| 5020 | |
| 5021 | { |
| 5022 | "priority", T_INT, |
| 5023 | offsetof(codec_info_Object, priority), 0, |
| 5024 | "Codec priority (integer 0-255)." |
| 5025 | }, |
| 5026 | |
| 5027 | |
| 5028 | |
| 5029 | {NULL} /* Sentinel */ |
| 5030 | }; |
| 5031 | |
| 5032 | |
| 5033 | |
| 5034 | |
| 5035 | /* |
| 5036 | * codec_info_Type |
| 5037 | */ |
| 5038 | static PyTypeObject codec_info_Type = |
| 5039 | { |
| 5040 | PyObject_HEAD_INIT(NULL) |
| 5041 | 0, /*ob_size*/ |
| 5042 | "py_pjsua.Codec_Info", /*tp_name*/ |
| 5043 | sizeof(codec_info_Object), /*tp_basicsize*/ |
| 5044 | 0, /*tp_itemsize*/ |
| 5045 | (destructor)codec_info_dealloc,/*tp_dealloc*/ |
| 5046 | 0, /*tp_print*/ |
| 5047 | 0, /*tp_getattr*/ |
| 5048 | 0, /*tp_setattr*/ |
| 5049 | 0, /*tp_compare*/ |
| 5050 | 0, /*tp_repr*/ |
| 5051 | 0, /*tp_as_number*/ |
| 5052 | 0, /*tp_as_sequence*/ |
| 5053 | 0, /*tp_as_mapping*/ |
| 5054 | 0, /*tp_hash */ |
| 5055 | 0, /*tp_call*/ |
| 5056 | 0, /*tp_str*/ |
| 5057 | 0, /*tp_getattro*/ |
| 5058 | 0, /*tp_setattro*/ |
| 5059 | 0, /*tp_as_buffer*/ |
| 5060 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 5061 | "Codec Info objects", /* tp_doc */ |
| 5062 | 0, /* tp_traverse */ |
| 5063 | 0, /* tp_clear */ |
| 5064 | 0, /* tp_richcompare */ |
| 5065 | 0, /* tp_weaklistoffset */ |
| 5066 | 0, /* tp_iter */ |
| 5067 | 0, /* tp_iternext */ |
| 5068 | 0, /* tp_methods */ |
| 5069 | codec_info_members, /* tp_members */ |
| 5070 | 0, /* tp_getset */ |
| 5071 | 0, /* tp_base */ |
| 5072 | 0, /* tp_dict */ |
| 5073 | 0, /* tp_descr_get */ |
| 5074 | 0, /* tp_descr_set */ |
| 5075 | 0, /* tp_dictoffset */ |
| 5076 | 0, /* tp_init */ |
| 5077 | 0, /* tp_alloc */ |
| 5078 | codec_info_new, /* tp_new */ |
| 5079 | |
| 5080 | }; |
| 5081 | |
| 5082 | /* |
| 5083 | * conf_port_info_Object |
| 5084 | * Conf Port Info |
| 5085 | */ |
| 5086 | typedef struct |
| 5087 | { |
| 5088 | PyObject_HEAD |
| 5089 | /* Type-specific fields go here. */ |
| 5090 | |
| 5091 | int slot_id; |
| 5092 | PyObject * name; |
| 5093 | unsigned clock_rate; |
| 5094 | unsigned channel_count; |
| 5095 | unsigned samples_per_frame; |
| 5096 | unsigned bits_per_sample; |
| 5097 | unsigned listener_cnt; |
| 5098 | PyListObject * listeners; |
| 5099 | |
| 5100 | } conf_port_info_Object; |
| 5101 | |
| 5102 | |
| 5103 | /* |
| 5104 | * conf_port_info_dealloc |
| 5105 | * deletes a conf_port_info from memory |
| 5106 | */ |
| 5107 | static void conf_port_info_dealloc(conf_port_info_Object* self) |
| 5108 | { |
| 5109 | Py_XDECREF(self->name); |
| 5110 | Py_XDECREF(self->listeners); |
| 5111 | self->ob_type->tp_free((PyObject*)self); |
| 5112 | } |
| 5113 | |
| 5114 | |
| 5115 | /* |
| 5116 | * conf_port_info_new |
| 5117 | * constructor for conf_port_info object |
| 5118 | */ |
| 5119 | static PyObject * conf_port_info_new(PyTypeObject *type, PyObject *args, |
| 5120 | PyObject *kwds) |
| 5121 | { |
| 5122 | conf_port_info_Object *self; |
| 5123 | |
| 5124 | self = (conf_port_info_Object *)type->tp_alloc(type, 0); |
| 5125 | if (self != NULL) |
| 5126 | { |
| 5127 | self->name = PyString_FromString(""); |
| 5128 | if (self->name == NULL) |
| 5129 | { |
| 5130 | Py_DECREF(self); |
| 5131 | return NULL; |
| 5132 | } |
| 5133 | |
| 5134 | self->listeners = (PyListObject *)PyList_New(254); |
| 5135 | if (self->listeners == NULL) |
| 5136 | { |
| 5137 | Py_DECREF(self); |
| 5138 | return NULL; |
| 5139 | } |
| 5140 | } |
| 5141 | return (PyObject *)self; |
| 5142 | } |
| 5143 | |
| 5144 | /* |
| 5145 | * conf_port_info_members |
| 5146 | */ |
| 5147 | static PyMemberDef conf_port_info_members[] = |
| 5148 | { |
| 5149 | { |
| 5150 | "slot_id", T_INT, |
| 5151 | offsetof(conf_port_info_Object, slot_id), 0, |
| 5152 | "Conference port number." |
| 5153 | }, |
| 5154 | { |
| 5155 | "name", T_OBJECT_EX, |
| 5156 | offsetof(conf_port_info_Object, name), 0, |
| 5157 | "Port name" |
| 5158 | }, |
| 5159 | { |
| 5160 | "clock_rate", T_INT, |
| 5161 | offsetof(conf_port_info_Object, clock_rate), 0, |
| 5162 | "Clock rate" |
| 5163 | }, |
| 5164 | { |
| 5165 | "channel_count", T_INT, |
| 5166 | offsetof(conf_port_info_Object, channel_count), 0, |
| 5167 | "Number of channels." |
| 5168 | }, |
| 5169 | { |
| 5170 | "samples_per_frame", T_INT, |
| 5171 | offsetof(conf_port_info_Object, samples_per_frame), 0, |
| 5172 | "Samples per frame " |
| 5173 | }, |
| 5174 | { |
| 5175 | "bits_per_sample", T_INT, |
| 5176 | offsetof(conf_port_info_Object, bits_per_sample), 0, |
| 5177 | "Bits per sample" |
| 5178 | }, |
| 5179 | /*{ |
| 5180 | "listener_cnt", T_INT, |
| 5181 | offsetof(conf_port_info_Object, listener_cnt), 0, |
| 5182 | "Number of listeners in the array." |
| 5183 | },*/ |
| 5184 | { |
| 5185 | "listeners", T_OBJECT_EX, |
| 5186 | offsetof(conf_port_info_Object, listeners), 0, |
| 5187 | "Array of listeners (in other words, ports where this port " |
| 5188 | "is transmitting to" |
| 5189 | }, |
| 5190 | |
| 5191 | {NULL} /* Sentinel */ |
| 5192 | }; |
| 5193 | |
| 5194 | |
| 5195 | |
| 5196 | |
| 5197 | /* |
| 5198 | * conf_port_info_Type |
| 5199 | */ |
| 5200 | static PyTypeObject conf_port_info_Type = |
| 5201 | { |
| 5202 | PyObject_HEAD_INIT(NULL) |
| 5203 | 0, /*ob_size*/ |
| 5204 | "py_pjsua.Conf_Port_Info", /*tp_name*/ |
| 5205 | sizeof(conf_port_info_Object), /*tp_basicsize*/ |
| 5206 | 0, /*tp_itemsize*/ |
| 5207 | (destructor)conf_port_info_dealloc,/*tp_dealloc*/ |
| 5208 | 0, /*tp_print*/ |
| 5209 | 0, /*tp_getattr*/ |
| 5210 | 0, /*tp_setattr*/ |
| 5211 | 0, /*tp_compare*/ |
| 5212 | 0, /*tp_repr*/ |
| 5213 | 0, /*tp_as_number*/ |
| 5214 | 0, /*tp_as_sequence*/ |
| 5215 | 0, /*tp_as_mapping*/ |
| 5216 | 0, /*tp_hash */ |
| 5217 | 0, /*tp_call*/ |
| 5218 | 0, /*tp_str*/ |
| 5219 | 0, /*tp_getattro*/ |
| 5220 | 0, /*tp_setattro*/ |
| 5221 | 0, /*tp_as_buffer*/ |
| 5222 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 5223 | "Conf Port Info objects", /* tp_doc */ |
| 5224 | 0, /* tp_traverse */ |
| 5225 | 0, /* tp_clear */ |
| 5226 | 0, /* tp_richcompare */ |
| 5227 | 0, /* tp_weaklistoffset */ |
| 5228 | 0, /* tp_iter */ |
| 5229 | 0, /* tp_iternext */ |
| 5230 | 0, /* tp_methods */ |
| 5231 | conf_port_info_members, /* tp_members */ |
| 5232 | 0, /* tp_getset */ |
| 5233 | 0, /* tp_base */ |
| 5234 | 0, /* tp_dict */ |
| 5235 | 0, /* tp_descr_get */ |
| 5236 | 0, /* tp_descr_set */ |
| 5237 | 0, /* tp_dictoffset */ |
| 5238 | 0, /* tp_init */ |
| 5239 | 0, /* tp_alloc */ |
| 5240 | conf_port_info_new, /* tp_new */ |
| 5241 | |
| 5242 | }; |
| 5243 | |
| 5244 | /* |
| 5245 | * pjmedia_port_Object |
| 5246 | */ |
| 5247 | typedef struct |
| 5248 | { |
| 5249 | PyObject_HEAD |
| 5250 | /* Type-specific fields go here. */ |
| 5251 | pjmedia_port * port; |
| 5252 | } pjmedia_port_Object; |
| 5253 | |
| 5254 | |
| 5255 | /* |
| 5256 | * pjmedia_port_Type |
| 5257 | */ |
| 5258 | static PyTypeObject pjmedia_port_Type = |
| 5259 | { |
| 5260 | PyObject_HEAD_INIT(NULL) |
| 5261 | 0, /*ob_size*/ |
| 5262 | "py_pjsua.PJMedia_Port", /*tp_name*/ |
| 5263 | sizeof(pjmedia_port_Object), /*tp_basicsize*/ |
| 5264 | 0, /*tp_itemsize*/ |
| 5265 | 0, /*tp_dealloc*/ |
| 5266 | 0, /*tp_print*/ |
| 5267 | 0, /*tp_getattr*/ |
| 5268 | 0, /*tp_setattr*/ |
| 5269 | 0, /*tp_compare*/ |
| 5270 | 0, /*tp_repr*/ |
| 5271 | 0, /*tp_as_number*/ |
| 5272 | 0, /*tp_as_sequence*/ |
| 5273 | 0, /*tp_as_mapping*/ |
| 5274 | 0, /*tp_hash */ |
| 5275 | 0, /*tp_call*/ |
| 5276 | 0, /*tp_str*/ |
| 5277 | 0, /*tp_getattro*/ |
| 5278 | 0, /*tp_setattro*/ |
| 5279 | 0, /*tp_as_buffer*/ |
| 5280 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 5281 | "pjmedia_port objects", /* tp_doc */ |
| 5282 | |
| 5283 | }; |
| 5284 | |
| 5285 | /* |
| 5286 | * pjmedia_snd_dev_info_Object |
| 5287 | * PJMedia Snd Dev Info |
| 5288 | */ |
| 5289 | typedef struct |
| 5290 | { |
| 5291 | PyObject_HEAD |
| 5292 | /* Type-specific fields go here. */ |
| 5293 | |
| 5294 | |
| 5295 | unsigned input_count; |
| 5296 | unsigned output_count; |
| 5297 | unsigned default_samples_per_sec; |
| 5298 | PyListObject * name; |
| 5299 | |
| 5300 | } pjmedia_snd_dev_info_Object; |
| 5301 | |
| 5302 | |
| 5303 | /* |
| 5304 | * pjmedia_snd_dev_info_dealloc |
| 5305 | * deletes a pjmedia_snd_dev_info from memory |
| 5306 | */ |
| 5307 | static void pjmedia_snd_dev_info_dealloc(pjmedia_snd_dev_info_Object* self) |
| 5308 | { |
| 5309 | Py_XDECREF(self->name); |
| 5310 | self->ob_type->tp_free((PyObject*)self); |
| 5311 | } |
| 5312 | |
| 5313 | |
| 5314 | /* |
| 5315 | * pjmedia_snd_dev_info_new |
| 5316 | * constructor for pjmedia_snd_dev_info object |
| 5317 | */ |
| 5318 | static PyObject * pjmedia_snd_dev_info_new(PyTypeObject *type, PyObject *args, |
| 5319 | PyObject *kwds) |
| 5320 | { |
| 5321 | pjmedia_snd_dev_info_Object *self; |
| 5322 | |
| 5323 | self = (pjmedia_snd_dev_info_Object *)type->tp_alloc(type, 0); |
| 5324 | if (self != NULL) |
| 5325 | { |
| 5326 | self->name = (PyListObject *)PyList_New(64); |
| 5327 | if (self->name == NULL) |
| 5328 | { |
| 5329 | Py_DECREF(self); |
| 5330 | return NULL; |
| 5331 | } |
| 5332 | |
| 5333 | } |
| 5334 | return (PyObject *)self; |
| 5335 | } |
| 5336 | |
| 5337 | /* |
| 5338 | * pjmedia_snd_dev_info_members |
| 5339 | */ |
| 5340 | static PyMemberDef pjmedia_snd_dev_info_members[] = |
| 5341 | { |
| 5342 | |
| 5343 | { |
| 5344 | "name", T_OBJECT_EX, |
| 5345 | offsetof(pjmedia_snd_dev_info_Object, name), 0, |
| 5346 | "Device name" |
| 5347 | }, |
| 5348 | { |
| 5349 | "input_count", T_INT, |
| 5350 | offsetof(pjmedia_snd_dev_info_Object, input_count), 0, |
| 5351 | "Max number of input channels" |
| 5352 | }, |
| 5353 | { |
| 5354 | "output_count", T_INT, |
| 5355 | offsetof(pjmedia_snd_dev_info_Object, output_count), 0, |
| 5356 | "Max number of output channels" |
| 5357 | }, |
| 5358 | { |
| 5359 | "default_samples_per_sec", T_INT, |
| 5360 | offsetof(pjmedia_snd_dev_info_Object, default_samples_per_sec), 0, |
| 5361 | "Default sampling rate." |
| 5362 | }, |
| 5363 | |
| 5364 | |
| 5365 | {NULL} /* Sentinel */ |
| 5366 | }; |
| 5367 | |
| 5368 | |
| 5369 | |
| 5370 | |
| 5371 | /* |
| 5372 | * pjmedia_snd_dev_info_Type |
| 5373 | */ |
| 5374 | static PyTypeObject pjmedia_snd_dev_info_Type = |
| 5375 | { |
| 5376 | PyObject_HEAD_INIT(NULL) |
| 5377 | 0, /*ob_size*/ |
| 5378 | "py_pjsua.PJMedia_Snd_Dev_Info", /*tp_name*/ |
| 5379 | sizeof(pjmedia_snd_dev_info_Object), /*tp_basicsize*/ |
| 5380 | 0, /*tp_itemsize*/ |
| 5381 | (destructor)pjmedia_snd_dev_info_dealloc,/*tp_dealloc*/ |
| 5382 | 0, /*tp_print*/ |
| 5383 | 0, /*tp_getattr*/ |
| 5384 | 0, /*tp_setattr*/ |
| 5385 | 0, /*tp_compare*/ |
| 5386 | 0, /*tp_repr*/ |
| 5387 | 0, /*tp_as_number*/ |
| 5388 | 0, /*tp_as_sequence*/ |
| 5389 | 0, /*tp_as_mapping*/ |
| 5390 | 0, /*tp_hash */ |
| 5391 | 0, /*tp_call*/ |
| 5392 | 0, /*tp_str*/ |
| 5393 | 0, /*tp_getattro*/ |
| 5394 | 0, /*tp_setattro*/ |
| 5395 | 0, /*tp_as_buffer*/ |
| 5396 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 5397 | "PJMedia Snd Dev Info objects", /* tp_doc */ |
| 5398 | 0, /* tp_traverse */ |
| 5399 | 0, /* tp_clear */ |
| 5400 | 0, /* tp_richcompare */ |
| 5401 | 0, /* tp_weaklistoffset */ |
| 5402 | 0, /* tp_iter */ |
| 5403 | 0, /* tp_iternext */ |
| 5404 | 0, /* tp_methods */ |
| 5405 | pjmedia_snd_dev_info_members, /* tp_members */ |
| 5406 | 0, /* tp_getset */ |
| 5407 | 0, /* tp_base */ |
| 5408 | 0, /* tp_dict */ |
| 5409 | 0, /* tp_descr_get */ |
| 5410 | 0, /* tp_descr_set */ |
| 5411 | 0, /* tp_dictoffset */ |
| 5412 | 0, /* tp_init */ |
| 5413 | 0, /* tp_alloc */ |
| 5414 | pjmedia_snd_dev_info_new, /* tp_new */ |
| 5415 | |
| 5416 | }; |
| 5417 | |
| 5418 | /* |
| 5419 | * pjmedia_codec_param_info_Object |
| 5420 | * PJMedia Codec Param Info |
| 5421 | */ |
| 5422 | typedef struct |
| 5423 | { |
| 5424 | PyObject_HEAD |
| 5425 | /* Type-specific fields go here. */ |
| 5426 | |
| 5427 | unsigned clock_rate; |
| 5428 | unsigned channel_cnt; |
| 5429 | pj_uint32_t avg_bps; |
| 5430 | pj_uint16_t frm_ptime; |
| 5431 | pj_uint8_t pcm_bits_per_sample; |
| 5432 | pj_uint8_t pt; |
| 5433 | |
| 5434 | } pjmedia_codec_param_info_Object; |
| 5435 | |
| 5436 | |
| 5437 | |
| 5438 | /* |
| 5439 | * pjmedia_codec_param_info_members |
| 5440 | */ |
| 5441 | static PyMemberDef pjmedia_codec_param_info_members[] = |
| 5442 | { |
| 5443 | |
| 5444 | { |
| 5445 | "clock_rate", T_INT, |
| 5446 | offsetof(pjmedia_codec_param_info_Object, clock_rate), 0, |
| 5447 | "Sampling rate in Hz" |
| 5448 | }, |
| 5449 | { |
| 5450 | "channel_cnt", T_INT, |
| 5451 | offsetof(pjmedia_codec_param_info_Object, channel_cnt), 0, |
| 5452 | "Channel count" |
| 5453 | }, |
| 5454 | { |
| 5455 | "avg_bps", T_INT, |
| 5456 | offsetof(pjmedia_codec_param_info_Object, avg_bps), 0, |
| 5457 | "Average bandwidth in bits/sec" |
| 5458 | }, |
| 5459 | { |
| 5460 | "frm_ptime", T_INT, |
| 5461 | offsetof(pjmedia_codec_param_info_Object, frm_ptime), 0, |
| 5462 | "Base frame ptime in msec." |
| 5463 | }, |
| 5464 | { |
| 5465 | "pcm_bits_per_sample", T_INT, |
| 5466 | offsetof(pjmedia_codec_param_info_Object, pcm_bits_per_sample), 0, |
| 5467 | "Bits/sample in the PCM side" |
| 5468 | }, |
| 5469 | { |
| 5470 | "pt", T_INT, |
| 5471 | offsetof(pjmedia_codec_param_info_Object, pt), 0, |
| 5472 | "Payload type" |
| 5473 | }, |
| 5474 | |
| 5475 | {NULL} /* Sentinel */ |
| 5476 | }; |
| 5477 | |
| 5478 | |
| 5479 | |
| 5480 | |
| 5481 | /* |
| 5482 | * pjmedia_codec_param_info_Type |
| 5483 | */ |
| 5484 | static PyTypeObject pjmedia_codec_param_info_Type = |
| 5485 | { |
| 5486 | PyObject_HEAD_INIT(NULL) |
| 5487 | 0, /*ob_size*/ |
| 5488 | "py_pjsua.PJMedia_Codec_Param_Info", /*tp_name*/ |
| 5489 | sizeof(pjmedia_codec_param_info_Object), /*tp_basicsize*/ |
| 5490 | 0, /*tp_itemsize*/ |
| 5491 | 0,/*tp_dealloc*/ |
| 5492 | 0, /*tp_print*/ |
| 5493 | 0, /*tp_getattr*/ |
| 5494 | 0, /*tp_setattr*/ |
| 5495 | 0, /*tp_compare*/ |
| 5496 | 0, /*tp_repr*/ |
| 5497 | 0, /*tp_as_number*/ |
| 5498 | 0, /*tp_as_sequence*/ |
| 5499 | 0, /*tp_as_mapping*/ |
| 5500 | 0, /*tp_hash */ |
| 5501 | 0, /*tp_call*/ |
| 5502 | 0, /*tp_str*/ |
| 5503 | 0, /*tp_getattro*/ |
| 5504 | 0, /*tp_setattro*/ |
| 5505 | 0, /*tp_as_buffer*/ |
| 5506 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 5507 | "PJMedia Codec Param Info objects", /* tp_doc */ |
| 5508 | 0, /* tp_traverse */ |
| 5509 | 0, /* tp_clear */ |
| 5510 | 0, /* tp_richcompare */ |
| 5511 | 0, /* tp_weaklistoffset */ |
| 5512 | 0, /* tp_iter */ |
| 5513 | 0, /* tp_iternext */ |
| 5514 | 0, /* tp_methods */ |
| 5515 | pjmedia_codec_param_info_members, /* tp_members */ |
| 5516 | |
| 5517 | |
| 5518 | }; |
| 5519 | |
| 5520 | /* |
| 5521 | * pjmedia_codec_param_setting_Object |
| 5522 | * PJMedia Codec Param Setting |
| 5523 | */ |
| 5524 | typedef struct |
| 5525 | { |
| 5526 | PyObject_HEAD |
| 5527 | /* Type-specific fields go here. */ |
| 5528 | pj_uint8_t frm_per_pkt; |
| 5529 | unsigned vad; |
| 5530 | unsigned cng; |
| 5531 | unsigned penh; |
| 5532 | unsigned plc; |
| 5533 | unsigned reserved; |
| 5534 | pj_uint8_t enc_fmtp_mode; |
| 5535 | pj_uint8_t dec_fmtp_mode; |
| 5536 | |
| 5537 | } pjmedia_codec_param_setting_Object; |
| 5538 | |
| 5539 | |
| 5540 | |
| 5541 | /* |
| 5542 | * pjmedia_codec_param_setting_members |
| 5543 | */ |
| 5544 | static PyMemberDef pjmedia_codec_param_setting_members[] = |
| 5545 | { |
| 5546 | |
| 5547 | { |
| 5548 | "frm_per_pkt", T_INT, |
| 5549 | offsetof(pjmedia_codec_param_setting_Object, frm_per_pkt), 0, |
| 5550 | "Number of frames per packet" |
| 5551 | }, |
| 5552 | { |
| 5553 | "vad", T_INT, |
| 5554 | offsetof(pjmedia_codec_param_setting_Object, vad), 0, |
| 5555 | "Voice Activity Detector" |
| 5556 | }, |
| 5557 | { |
| 5558 | "penh", T_INT, |
| 5559 | offsetof(pjmedia_codec_param_setting_Object, penh), 0, |
| 5560 | "Perceptual Enhancement" |
| 5561 | }, |
| 5562 | { |
| 5563 | "plc", T_INT, |
| 5564 | offsetof(pjmedia_codec_param_setting_Object, plc), 0, |
| 5565 | "Packet loss concealment" |
| 5566 | }, |
| 5567 | { |
| 5568 | "reserved", T_INT, |
| 5569 | offsetof(pjmedia_codec_param_setting_Object, reserved), 0, |
| 5570 | "Reserved, must be zero" |
| 5571 | }, |
| 5572 | { |
| 5573 | "cng", T_INT, |
| 5574 | offsetof(pjmedia_codec_param_setting_Object, cng), 0, |
| 5575 | "Comfort Noise Generator" |
| 5576 | }, |
| 5577 | { |
| 5578 | "enc_fmtp_mode", T_INT, |
| 5579 | offsetof(pjmedia_codec_param_setting_Object, enc_fmtp_mode), 0, |
| 5580 | "Mode param in fmtp (def:0)" |
| 5581 | }, |
| 5582 | { |
| 5583 | "dec_fmtp_mode", T_INT, |
| 5584 | offsetof(pjmedia_codec_param_setting_Object, dec_fmtp_mode), 0, |
| 5585 | "Mode param in fmtp (def:0)" |
| 5586 | }, |
| 5587 | |
| 5588 | {NULL} /* Sentinel */ |
| 5589 | }; |
| 5590 | |
| 5591 | |
| 5592 | |
| 5593 | |
| 5594 | /* |
| 5595 | * pjmedia_codec_param_setting_Type |
| 5596 | */ |
| 5597 | static PyTypeObject pjmedia_codec_param_setting_Type = |
| 5598 | { |
| 5599 | PyObject_HEAD_INIT(NULL) |
| 5600 | 0, /*ob_size*/ |
| 5601 | "py_pjsua.PJMedia_Codec_Param_Setting", /*tp_name*/ |
| 5602 | sizeof(pjmedia_codec_param_setting_Object), /*tp_basicsize*/ |
| 5603 | 0, /*tp_itemsize*/ |
| 5604 | 0,/*tp_dealloc*/ |
| 5605 | 0, /*tp_print*/ |
| 5606 | 0, /*tp_getattr*/ |
| 5607 | 0, /*tp_setattr*/ |
| 5608 | 0, /*tp_compare*/ |
| 5609 | 0, /*tp_repr*/ |
| 5610 | 0, /*tp_as_number*/ |
| 5611 | 0, /*tp_as_sequence*/ |
| 5612 | 0, /*tp_as_mapping*/ |
| 5613 | 0, /*tp_hash */ |
| 5614 | 0, /*tp_call*/ |
| 5615 | 0, /*tp_str*/ |
| 5616 | 0, /*tp_getattro*/ |
| 5617 | 0, /*tp_setattro*/ |
| 5618 | 0, /*tp_as_buffer*/ |
| 5619 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 5620 | "PJMedia Codec Param Setting objects", /* tp_doc */ |
| 5621 | 0, /* tp_traverse */ |
| 5622 | 0, /* tp_clear */ |
| 5623 | 0, /* tp_richcompare */ |
| 5624 | 0, /* tp_weaklistoffset */ |
| 5625 | 0, /* tp_iter */ |
| 5626 | 0, /* tp_iternext */ |
| 5627 | 0, /* tp_methods */ |
| 5628 | pjmedia_codec_param_setting_members, /* tp_members */ |
| 5629 | |
| 5630 | |
| 5631 | }; |
| 5632 | |
| 5633 | /* |
| 5634 | * pjmedia_codec_param_Object |
| 5635 | * PJMedia Codec Param |
| 5636 | */ |
| 5637 | typedef struct |
| 5638 | { |
| 5639 | PyObject_HEAD |
| 5640 | /* Type-specific fields go here. */ |
| 5641 | |
| 5642 | pjmedia_codec_param_info_Object * info; |
| 5643 | pjmedia_codec_param_setting_Object * setting; |
| 5644 | |
| 5645 | } pjmedia_codec_param_Object; |
| 5646 | |
| 5647 | |
| 5648 | /* |
| 5649 | * pjmedia_codec_param_dealloc |
| 5650 | * deletes a pjmedia_codec_param from memory |
| 5651 | */ |
| 5652 | static void pjmedia_codec_param_dealloc(pjmedia_codec_param_Object* self) |
| 5653 | { |
| 5654 | Py_XDECREF(self->info); |
| 5655 | Py_XDECREF(self->setting); |
| 5656 | self->ob_type->tp_free((PyObject*)self); |
| 5657 | } |
| 5658 | |
| 5659 | |
| 5660 | /* |
| 5661 | * pjmedia_codec_param_new |
| 5662 | * constructor for pjmedia_codec_param object |
| 5663 | */ |
| 5664 | static PyObject * pjmedia_codec_param_new(PyTypeObject *type, PyObject *args, |
| 5665 | PyObject *kwds) |
| 5666 | { |
| 5667 | pjmedia_codec_param_Object *self; |
| 5668 | |
| 5669 | self = (pjmedia_codec_param_Object *)type->tp_alloc(type, 0); |
| 5670 | if (self != NULL) |
| 5671 | { |
| 5672 | self->info = (pjmedia_codec_param_info_Object *) |
| 5673 | PyType_GenericNew(&pjmedia_codec_param_info_Type, NULL, NULL); |
| 5674 | if (self->info == NULL) |
| 5675 | { |
| 5676 | Py_DECREF(self); |
| 5677 | return NULL; |
| 5678 | } |
| 5679 | self->setting = (pjmedia_codec_param_setting_Object *) |
| 5680 | PyType_GenericNew(&pjmedia_codec_param_setting_Type, NULL, NULL); |
| 5681 | if (self->setting == NULL) |
| 5682 | { |
| 5683 | Py_DECREF(self); |
| 5684 | return NULL; |
| 5685 | } |
| 5686 | } |
| 5687 | return (PyObject *)self; |
| 5688 | } |
| 5689 | |
| 5690 | /* |
| 5691 | * pjmedia_codec_param_members |
| 5692 | */ |
| 5693 | static PyMemberDef pjmedia_codec_param_members[] = |
| 5694 | { |
| 5695 | |
| 5696 | { |
| 5697 | "info", T_OBJECT_EX, |
| 5698 | offsetof(pjmedia_codec_param_Object, info), 0, |
| 5699 | "The 'info' part of codec param describes the capability of the codec," |
| 5700 | " and the value should NOT be changed by application." |
| 5701 | }, |
| 5702 | { |
| 5703 | "setting", T_OBJECT_EX, |
| 5704 | offsetof(pjmedia_codec_param_Object, setting), 0, |
| 5705 | "The 'setting' part of codec param describes various settings to be " |
| 5706 | "applied to the codec. When the codec param is retrieved from the " |
| 5707 | "codec or codec factory, the values of these will be filled by " |
| 5708 | "the capability of the codec. Any features that are supported by " |
| 5709 | "the codec (e.g. vad or plc) will be turned on, so that application " |
| 5710 | "can query which capabilities are supported by the codec. " |
| 5711 | "Application may change the settings here before instantiating " |
| 5712 | "the codec/stream." |
| 5713 | }, |
| 5714 | |
| 5715 | {NULL} /* Sentinel */ |
| 5716 | }; |
| 5717 | |
| 5718 | |
| 5719 | |
| 5720 | |
| 5721 | /* |
| 5722 | * pjmedia_codec_param_Type |
| 5723 | */ |
| 5724 | static PyTypeObject pjmedia_codec_param_Type = |
| 5725 | { |
| 5726 | PyObject_HEAD_INIT(NULL) |
| 5727 | 0, /*ob_size*/ |
| 5728 | "py_pjsua.PJMedia_Codec_Param", /*tp_name*/ |
| 5729 | sizeof(pjmedia_codec_param_Object), /*tp_basicsize*/ |
| 5730 | 0, /*tp_itemsize*/ |
| 5731 | (destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/ |
| 5732 | 0, /*tp_print*/ |
| 5733 | 0, /*tp_getattr*/ |
| 5734 | 0, /*tp_setattr*/ |
| 5735 | 0, /*tp_compare*/ |
| 5736 | 0, /*tp_repr*/ |
| 5737 | 0, /*tp_as_number*/ |
| 5738 | 0, /*tp_as_sequence*/ |
| 5739 | 0, /*tp_as_mapping*/ |
| 5740 | 0, /*tp_hash */ |
| 5741 | 0, /*tp_call*/ |
| 5742 | 0, /*tp_str*/ |
| 5743 | 0, /*tp_getattro*/ |
| 5744 | 0, /*tp_setattro*/ |
| 5745 | 0, /*tp_as_buffer*/ |
| 5746 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 5747 | "PJMedia Codec Param objects", /* tp_doc */ |
| 5748 | 0, /* tp_traverse */ |
| 5749 | 0, /* tp_clear */ |
| 5750 | 0, /* tp_richcompare */ |
| 5751 | 0, /* tp_weaklistoffset */ |
| 5752 | 0, /* tp_iter */ |
| 5753 | 0, /* tp_iternext */ |
| 5754 | 0, /* tp_methods */ |
| 5755 | pjmedia_codec_param_members, /* tp_members */ |
| 5756 | 0, /* tp_getset */ |
| 5757 | 0, /* tp_base */ |
| 5758 | 0, /* tp_dict */ |
| 5759 | 0, /* tp_descr_get */ |
| 5760 | 0, /* tp_descr_set */ |
| 5761 | 0, /* tp_dictoffset */ |
| 5762 | 0, /* tp_init */ |
| 5763 | 0, /* tp_alloc */ |
| 5764 | pjmedia_codec_param_new, /* tp_new */ |
| 5765 | |
| 5766 | }; |
| 5767 | |
| 5768 | /* |
| 5769 | * py_pjsua_conf_get_max_ports |
| 5770 | */ |
| 5771 | static PyObject *py_pjsua_conf_get_max_ports |
| 5772 | (PyObject *pSelf, PyObject *pArgs) |
| 5773 | { |
| 5774 | int ret; |
| 5775 | |
| 5776 | if (!PyArg_ParseTuple(pArgs, "")) |
| 5777 | { |
| 5778 | return NULL; |
| 5779 | } |
| 5780 | ret = pjsua_conf_get_max_ports(); |
| 5781 | |
| 5782 | return Py_BuildValue("i", ret); |
| 5783 | } |
| 5784 | |
| 5785 | /* |
| 5786 | * py_pjsua_conf_get_active_ports |
| 5787 | */ |
| 5788 | static PyObject *py_pjsua_conf_get_active_ports |
| 5789 | (PyObject *pSelf, PyObject *pArgs) |
| 5790 | { |
| 5791 | int ret; |
| 5792 | if (!PyArg_ParseTuple(pArgs, "")) |
| 5793 | { |
| 5794 | return NULL; |
| 5795 | } |
| 5796 | ret = pjsua_conf_get_active_ports(); |
| 5797 | |
| 5798 | return Py_BuildValue("i", ret); |
| 5799 | } |
| 5800 | |
| 5801 | /* |
| 5802 | * py_pjsua_enum_conf_ports |
| 5803 | * !modified @ 241206 |
| 5804 | */ |
| 5805 | static PyObject *py_pjsua_enum_conf_ports(PyObject *pSelf, PyObject *pArgs) |
| 5806 | { |
| 5807 | pj_status_t status; |
| 5808 | PyObject *list; |
| 5809 | |
| 5810 | pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS]; |
| 5811 | int c, i; |
| 5812 | if (!PyArg_ParseTuple(pArgs, "")) |
| 5813 | { |
| 5814 | return NULL; |
| 5815 | } |
| 5816 | |
| 5817 | c = PJ_ARRAY_SIZE(id); |
| 5818 | status = pjsua_enum_conf_ports(id, &c); |
| 5819 | |
| 5820 | list = PyList_New(c); |
| 5821 | for (i = 0; i < c; i++) { |
| 5822 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 5823 | if (ret == -1) { |
| 5824 | return NULL; |
| 5825 | } |
| 5826 | } |
| 5827 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 5828 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5829 | return Py_BuildValue("O",list); |
| 5830 | } |
| 5831 | |
| 5832 | /* |
| 5833 | * py_pjsua_conf_get_port_info |
| 5834 | */ |
| 5835 | static PyObject *py_pjsua_conf_get_port_info |
| 5836 | (PyObject *pSelf, PyObject *pArgs) |
| 5837 | { |
| 5838 | int id; |
| 5839 | conf_port_info_Object * obj; |
| 5840 | pjsua_conf_port_info info; |
| 5841 | int status; |
| 5842 | int i; |
| 5843 | |
| 5844 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 5845 | { |
| 5846 | return NULL; |
| 5847 | } |
| 5848 | |
| 5849 | |
| 5850 | status = pjsua_conf_get_port_info(id, &info); |
| 5851 | obj = (conf_port_info_Object *)conf_port_info_new |
| 5852 | (&conf_port_info_Type,NULL,NULL); |
| 5853 | obj->bits_per_sample = info.bits_per_sample; |
| 5854 | obj->channel_count = info.bits_per_sample; |
| 5855 | obj->clock_rate = info.clock_rate; |
| 5856 | obj->listener_cnt = info.listener_cnt; |
| 5857 | obj->name = PyString_FromStringAndSize(info.name.ptr, info.name.slen); |
| 5858 | obj->samples_per_frame = info.samples_per_frame; |
| 5859 | obj->slot_id = info.slot_id; |
| 5860 | |
| 5861 | for (i = 0; i < 254; i++) { |
| 5862 | PyObject * item = Py_BuildValue("i",info.listeners[i]); |
| 5863 | PyList_SetItem((PyObject *)obj->listeners, i, item); |
| 5864 | } |
| 5865 | return Py_BuildValue("O", obj); |
| 5866 | } |
| 5867 | |
| 5868 | /* |
| 5869 | * py_pjsua_conf_add_port |
| 5870 | */ |
| 5871 | static PyObject *py_pjsua_conf_add_port |
| 5872 | (PyObject *pSelf, PyObject *pArgs) |
| 5873 | { |
| 5874 | int p_id; |
| 5875 | pjmedia_port_Object * oport; |
| 5876 | pj_pool_Object * opool; |
| 5877 | |
| 5878 | int status; |
| 5879 | |
| 5880 | |
| 5881 | if (!PyArg_ParseTuple(pArgs, "OO", &opool, &oport)) |
| 5882 | { |
| 5883 | return NULL; |
| 5884 | } |
| 5885 | |
| 5886 | |
| 5887 | |
| 5888 | status = pjsua_conf_add_port(opool->pool, oport->port, &p_id); |
| 5889 | |
| 5890 | |
| 5891 | return Py_BuildValue("ii", status, p_id); |
| 5892 | } |
| 5893 | |
| 5894 | /* |
| 5895 | * py_pjsua_conf_remove_port |
| 5896 | */ |
| 5897 | static PyObject *py_pjsua_conf_remove_port |
| 5898 | (PyObject *pSelf, PyObject *pArgs) |
| 5899 | { |
| 5900 | int id; |
| 5901 | int status; |
| 5902 | |
| 5903 | |
| 5904 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 5905 | { |
| 5906 | return NULL; |
| 5907 | } |
| 5908 | |
| 5909 | status = pjsua_conf_remove_port(id); |
| 5910 | |
| 5911 | |
| 5912 | return Py_BuildValue("i", status); |
| 5913 | } |
| 5914 | |
| 5915 | /* |
| 5916 | * py_pjsua_conf_connect |
| 5917 | */ |
| 5918 | static PyObject *py_pjsua_conf_connect |
| 5919 | (PyObject *pSelf, PyObject *pArgs) |
| 5920 | { |
| 5921 | int source, sink; |
| 5922 | int status; |
| 5923 | |
| 5924 | |
| 5925 | if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) |
| 5926 | { |
| 5927 | return NULL; |
| 5928 | } |
| 5929 | |
| 5930 | status = pjsua_conf_connect(source, sink); |
| 5931 | |
| 5932 | |
| 5933 | return Py_BuildValue("i", status); |
| 5934 | } |
| 5935 | |
| 5936 | /* |
| 5937 | * py_pjsua_conf_disconnect |
| 5938 | */ |
| 5939 | static PyObject *py_pjsua_conf_disconnect |
| 5940 | (PyObject *pSelf, PyObject *pArgs) |
| 5941 | { |
| 5942 | int source, sink; |
| 5943 | int status; |
| 5944 | |
| 5945 | |
| 5946 | if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) |
| 5947 | { |
| 5948 | return NULL; |
| 5949 | } |
| 5950 | |
| 5951 | status = pjsua_conf_disconnect(source, sink); |
| 5952 | |
| 5953 | |
| 5954 | return Py_BuildValue("i", status); |
| 5955 | } |
| 5956 | |
| 5957 | /* |
| 5958 | * py_pjsua_player_create |
| 5959 | */ |
| 5960 | static PyObject *py_pjsua_player_create |
| 5961 | (PyObject *pSelf, PyObject *pArgs) |
| 5962 | { |
| 5963 | int id; |
| 5964 | int options; |
| 5965 | PyObject * filename; |
| 5966 | pj_str_t str; |
| 5967 | int status; |
| 5968 | |
| 5969 | |
| 5970 | if (!PyArg_ParseTuple(pArgs, "Oi", &filename, &options)) |
| 5971 | { |
| 5972 | return NULL; |
| 5973 | } |
| 5974 | str.ptr = PyString_AsString(filename); |
| 5975 | str.slen = strlen(PyString_AsString(filename)); |
| 5976 | status = pjsua_player_create(&str, options, &id); |
| 5977 | |
| 5978 | return Py_BuildValue("ii", status, id); |
| 5979 | } |
| 5980 | |
| 5981 | /* |
| 5982 | * py_pjsua_player_get_conf_port |
| 5983 | */ |
| 5984 | static PyObject *py_pjsua_player_get_conf_port |
| 5985 | (PyObject *pSelf, PyObject *pArgs) |
| 5986 | { |
| 5987 | |
| 5988 | int id, port_id; |
| 5989 | |
| 5990 | |
| 5991 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 5992 | { |
| 5993 | return NULL; |
| 5994 | } |
| 5995 | |
| 5996 | port_id = pjsua_player_get_conf_port(id); |
| 5997 | |
| 5998 | |
| 5999 | return Py_BuildValue("i", port_id); |
| 6000 | } |
| 6001 | |
| 6002 | /* |
| 6003 | * py_pjsua_player_set_pos |
| 6004 | */ |
| 6005 | static PyObject *py_pjsua_player_set_pos |
| 6006 | (PyObject *pSelf, PyObject *pArgs) |
| 6007 | { |
| 6008 | int id; |
| 6009 | pj_uint32_t samples; |
| 6010 | int status; |
| 6011 | |
| 6012 | |
| 6013 | if (!PyArg_ParseTuple(pArgs, "iI", &id, &samples)) |
| 6014 | { |
| 6015 | return NULL; |
| 6016 | } |
| 6017 | |
| 6018 | status = pjsua_player_set_pos(id, samples); |
| 6019 | |
| 6020 | |
| 6021 | return Py_BuildValue("i", status); |
| 6022 | } |
| 6023 | |
| 6024 | /* |
| 6025 | * py_pjsua_player_destroy |
| 6026 | */ |
| 6027 | static PyObject *py_pjsua_player_destroy |
| 6028 | (PyObject *pSelf, PyObject *pArgs) |
| 6029 | { |
| 6030 | int id; |
| 6031 | int status; |
| 6032 | |
| 6033 | |
| 6034 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 6035 | { |
| 6036 | return NULL; |
| 6037 | } |
| 6038 | |
| 6039 | status = pjsua_player_destroy(id); |
| 6040 | |
| 6041 | |
| 6042 | return Py_BuildValue("i", status); |
| 6043 | } |
| 6044 | |
| 6045 | /* |
| 6046 | * py_pjsua_recorder_create |
| 6047 | * !modified @ 261206 |
| 6048 | */ |
| 6049 | static PyObject *py_pjsua_recorder_create |
| 6050 | (PyObject *pSelf, PyObject *pArgs) |
| 6051 | { |
| 6052 | int p_id; |
| 6053 | int options; |
| 6054 | int max_size; |
| 6055 | PyObject * filename; |
| 6056 | pj_str_t str; |
| 6057 | PyObject * enc_param; |
| 6058 | pj_str_t strparam; |
| 6059 | int enc_type; |
| 6060 | |
| 6061 | int status; |
| 6062 | |
| 6063 | |
| 6064 | if (!PyArg_ParseTuple(pArgs, "OiOii", &filename, &enc_type, &enc_param, &max_size, &options)) |
| 6065 | { |
| 6066 | return NULL; |
| 6067 | } |
| 6068 | str.ptr = PyString_AsString(filename); |
| 6069 | str.slen = strlen(PyString_AsString(filename)); |
| 6070 | strparam.ptr = PyString_AsString(enc_param); |
| 6071 | strparam.slen = strlen(PyString_AsString(enc_param)); |
| 6072 | status = pjsua_recorder_create(&str, enc_type, NULL, max_size, options, &p_id); |
| 6073 | |
| 6074 | return Py_BuildValue("ii", status, p_id); |
| 6075 | } |
| 6076 | |
| 6077 | /* |
| 6078 | * py_pjsua_recorder_get_conf_port |
| 6079 | */ |
| 6080 | static PyObject *py_pjsua_recorder_get_conf_port |
| 6081 | (PyObject *pSelf, PyObject *pArgs) |
| 6082 | { |
| 6083 | |
| 6084 | int id, port_id; |
| 6085 | |
| 6086 | |
| 6087 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 6088 | { |
| 6089 | return NULL; |
| 6090 | } |
| 6091 | |
| 6092 | port_id = pjsua_recorder_get_conf_port(id); |
| 6093 | |
| 6094 | |
| 6095 | return Py_BuildValue("i", port_id); |
| 6096 | } |
| 6097 | |
| 6098 | /* |
| 6099 | * py_pjsua_recorder_destroy |
| 6100 | */ |
| 6101 | static PyObject *py_pjsua_recorder_destroy |
| 6102 | (PyObject *pSelf, PyObject *pArgs) |
| 6103 | { |
| 6104 | int id; |
| 6105 | int status; |
| 6106 | |
| 6107 | |
| 6108 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 6109 | { |
| 6110 | return NULL; |
| 6111 | } |
| 6112 | |
| 6113 | status = pjsua_recorder_destroy(id); |
| 6114 | |
| 6115 | |
| 6116 | return Py_BuildValue("i", status); |
| 6117 | } |
| 6118 | |
| 6119 | /* |
| 6120 | * py_pjsua_enum_snd_devs |
| 6121 | */ |
| 6122 | static PyObject *py_pjsua_enum_snd_devs(PyObject *pSelf, PyObject *pArgs) |
| 6123 | { |
| 6124 | pj_status_t status; |
| 6125 | PyObject *list; |
| 6126 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 6127 | pjmedia_snd_dev_info info[64]; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 6128 | int c, i; |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 6129 | if (!PyArg_ParseTuple(pArgs, "")) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 6130 | { |
| 6131 | return NULL; |
| 6132 | } |
| 6133 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 6134 | c = PJ_ARRAY_SIZE(info); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 6135 | status = pjsua_enum_snd_devs(info, &c); |
| 6136 | |
| 6137 | list = PyList_New(c); |
| 6138 | for (i = 0; i < c; i++) { |
| 6139 | int ret; |
| 6140 | int j; |
| 6141 | pjmedia_snd_dev_info_Object * obj; |
| 6142 | obj = (pjmedia_snd_dev_info_Object *)pjmedia_snd_dev_info_new |
| 6143 | (&pjmedia_snd_dev_info_Type, NULL, NULL); |
| 6144 | obj->default_samples_per_sec = info[i].default_samples_per_sec; |
| 6145 | obj->input_count = info[i].input_count; |
| 6146 | obj->output_count = info[i].output_count; |
| 6147 | for (j = 0; j < 64; j++) |
| 6148 | { |
| 6149 | PyObject * ostr; |
| 6150 | char * str; |
| 6151 | str = (char *)malloc(sizeof(char)); |
| 6152 | str[0] = info[i].name[j]; |
| 6153 | ostr = PyString_FromStringAndSize(str,1); |
| 6154 | PyList_SetItem((PyObject *)obj->name, j, ostr); |
| 6155 | free(str); |
| 6156 | } |
| 6157 | ret = PyList_SetItem(list, i, (PyObject *)obj); |
| 6158 | if (ret == -1) { |
| 6159 | return NULL; |
| 6160 | } |
| 6161 | } |
| 6162 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 6163 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 6164 | return Py_BuildValue("O",list); |
| 6165 | } |
| 6166 | |
| 6167 | /* |
| 6168 | * py_pjsua_get_snd_dev |
| 6169 | */ |
| 6170 | static PyObject *py_pjsua_get_snd_dev |
| 6171 | (PyObject *pSelf, PyObject *pArgs) |
| 6172 | { |
| 6173 | int capture_dev, playback_dev; |
| 6174 | int status; |
| 6175 | |
| 6176 | |
| 6177 | if (!PyArg_ParseTuple(pArgs, "")) |
| 6178 | { |
| 6179 | return NULL; |
| 6180 | } |
| 6181 | |
| 6182 | status = pjsua_get_snd_dev(&capture_dev, &playback_dev); |
| 6183 | |
| 6184 | |
| 6185 | return Py_BuildValue("ii", capture_dev, playback_dev); |
| 6186 | } |
| 6187 | |
| 6188 | /* |
| 6189 | * py_pjsua_set_snd_dev |
| 6190 | */ |
| 6191 | static PyObject *py_pjsua_set_snd_dev |
| 6192 | (PyObject *pSelf, PyObject *pArgs) |
| 6193 | { |
| 6194 | int capture_dev, playback_dev; |
| 6195 | int status; |
| 6196 | |
| 6197 | |
| 6198 | if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev)) |
| 6199 | { |
| 6200 | return NULL; |
| 6201 | } |
| 6202 | |
| 6203 | status = pjsua_set_snd_dev(capture_dev, playback_dev); |
| 6204 | |
| 6205 | |
| 6206 | return Py_BuildValue("i", status); |
| 6207 | } |
| 6208 | |
| 6209 | /* |
| 6210 | * py_pjsua_set_null_snd_dev |
| 6211 | */ |
| 6212 | static PyObject *py_pjsua_set_null_snd_dev |
| 6213 | (PyObject *pSelf, PyObject *pArgs) |
| 6214 | { |
| 6215 | |
| 6216 | int status; |
| 6217 | |
| 6218 | |
| 6219 | if (!PyArg_ParseTuple(pArgs, "")) |
| 6220 | { |
| 6221 | return NULL; |
| 6222 | } |
| 6223 | |
| 6224 | status = pjsua_set_null_snd_dev(); |
| 6225 | |
| 6226 | |
| 6227 | return Py_BuildValue("i", status); |
| 6228 | } |
| 6229 | |
| 6230 | /* |
| 6231 | * py_pjsua_set_no_snd_dev |
| 6232 | */ |
| 6233 | static PyObject *py_pjsua_set_no_snd_dev |
| 6234 | (PyObject *pSelf, PyObject *pArgs) |
| 6235 | { |
| 6236 | |
| 6237 | pjmedia_port_Object * obj; |
| 6238 | |
| 6239 | if (!PyArg_ParseTuple(pArgs, "")) |
| 6240 | { |
| 6241 | return NULL; |
| 6242 | } |
| 6243 | |
| 6244 | obj = (pjmedia_port_Object *)PyType_GenericNew |
| 6245 | (&pjmedia_port_Type, NULL, NULL); |
| 6246 | obj->port = pjsua_set_no_snd_dev(); |
| 6247 | return Py_BuildValue("O", obj); |
| 6248 | } |
| 6249 | |
| 6250 | /* |
| 6251 | * py_pjsua_set_ec |
| 6252 | */ |
| 6253 | static PyObject *py_pjsua_set_ec |
| 6254 | (PyObject *pSelf, PyObject *pArgs) |
| 6255 | { |
| 6256 | int options; |
| 6257 | int tail_ms; |
| 6258 | int status; |
| 6259 | |
| 6260 | |
| 6261 | if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options)) |
| 6262 | { |
| 6263 | return NULL; |
| 6264 | } |
| 6265 | |
| 6266 | status = pjsua_set_ec(tail_ms, options); |
| 6267 | |
| 6268 | |
| 6269 | return Py_BuildValue("i", status); |
| 6270 | } |
| 6271 | |
| 6272 | /* |
| 6273 | * py_pjsua_get_ec_tail |
| 6274 | */ |
| 6275 | static PyObject *py_pjsua_get_ec_tail |
| 6276 | (PyObject *pSelf, PyObject *pArgs) |
| 6277 | { |
| 6278 | |
| 6279 | int status; |
| 6280 | int p_tail_ms; |
| 6281 | |
| 6282 | if (!PyArg_ParseTuple(pArgs, "")) |
| 6283 | { |
| 6284 | return NULL; |
| 6285 | } |
| 6286 | |
| 6287 | status = pjsua_get_ec_tail(&p_tail_ms); |
| 6288 | |
| 6289 | |
| 6290 | return Py_BuildValue("i", p_tail_ms); |
| 6291 | } |
| 6292 | |
| 6293 | /* |
| 6294 | * py_pjsua_enum_codecs |
| 6295 | * !modified @ 261206 |
| 6296 | */ |
| 6297 | static PyObject *py_pjsua_enum_codecs(PyObject *pSelf, PyObject *pArgs) |
| 6298 | { |
| 6299 | pj_status_t status; |
| 6300 | PyObject *list; |
| 6301 | |
| 6302 | pjsua_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS]; |
| 6303 | int c, i; |
| 6304 | if (!PyArg_ParseTuple(pArgs, "")) |
| 6305 | { |
| 6306 | return NULL; |
| 6307 | } |
| 6308 | |
| 6309 | c = PJ_ARRAY_SIZE(info); |
| 6310 | status = pjsua_enum_codecs(info, &c); |
| 6311 | |
| 6312 | list = PyList_New(c); |
| 6313 | for (i = 0; i < c; i++) { |
| 6314 | int ret; |
| 6315 | int j; |
| 6316 | codec_info_Object * obj; |
| 6317 | obj = (codec_info_Object *)codec_info_new |
| 6318 | (&codec_info_Type, NULL, NULL); |
| 6319 | obj->codec_id = PyString_FromStringAndSize |
| 6320 | (info[i].codec_id.ptr, info[i].codec_id.slen); |
| 6321 | obj->priority = info[i].priority; |
| 6322 | for (j = 0; j < 32; j++) |
| 6323 | { |
| 6324 | obj->buf_[j] = info[i].buf_[j]; |
| 6325 | } |
| 6326 | ret = PyList_SetItem(list, i, (PyObject *)obj); |
| 6327 | if (ret == -1) { |
| 6328 | return NULL; |
| 6329 | } |
| 6330 | } |
| 6331 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 6332 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 6333 | return Py_BuildValue("O",list); |
| 6334 | } |
| 6335 | |
| 6336 | /* |
| 6337 | * py_pjsua_codec_set_priority |
| 6338 | */ |
| 6339 | static PyObject *py_pjsua_codec_set_priority |
| 6340 | (PyObject *pSelf, PyObject *pArgs) |
| 6341 | { |
| 6342 | |
| 6343 | int status; |
| 6344 | PyObject * id; |
| 6345 | pj_str_t str; |
| 6346 | pj_uint8_t priority; |
| 6347 | |
| 6348 | if (!PyArg_ParseTuple(pArgs, "OB", &id, &priority)) |
| 6349 | { |
| 6350 | return NULL; |
| 6351 | } |
| 6352 | str.ptr = PyString_AsString(id); |
| 6353 | str.slen = strlen(PyString_AsString(id)); |
| 6354 | status = pjsua_codec_set_priority(&str, priority); |
| 6355 | |
| 6356 | |
| 6357 | return Py_BuildValue("i", status); |
| 6358 | } |
| 6359 | |
| 6360 | /* |
| 6361 | * py_pjsua_codec_get_param |
| 6362 | */ |
| 6363 | static PyObject *py_pjsua_codec_get_param |
| 6364 | (PyObject *pSelf, PyObject *pArgs) |
| 6365 | { |
| 6366 | |
| 6367 | int status; |
| 6368 | PyObject * id; |
| 6369 | pj_str_t str; |
| 6370 | pjmedia_codec_param param; |
| 6371 | pjmedia_codec_param_Object *obj; |
| 6372 | |
| 6373 | |
| 6374 | if (!PyArg_ParseTuple(pArgs, "O", &id)) |
| 6375 | { |
| 6376 | return NULL; |
| 6377 | } |
| 6378 | str.ptr = PyString_AsString(id); |
| 6379 | str.slen = strlen(PyString_AsString(id)); |
| 6380 | status = pjsua_codec_get_param(&str, ¶m); |
| 6381 | obj = (pjmedia_codec_param_Object *)pjmedia_codec_param_new |
| 6382 | (&pjmedia_codec_param_Type, NULL, NULL); |
| 6383 | obj->info->avg_bps = param.info.avg_bps; |
| 6384 | obj->info->channel_cnt = param.info.channel_cnt; |
| 6385 | obj->info->clock_rate = param.info.clock_rate; |
| 6386 | obj->info->frm_ptime = param.info.frm_ptime; |
| 6387 | obj->info->pcm_bits_per_sample = param.info.pcm_bits_per_sample; |
| 6388 | obj->info->pt = param.info.pt; |
| 6389 | obj->setting->cng = param.setting.cng; |
| 6390 | obj->setting->dec_fmtp_mode = param.setting.dec_fmtp_mode; |
| 6391 | obj->setting->enc_fmtp_mode = param.setting.enc_fmtp_mode; |
| 6392 | obj->setting->frm_per_pkt = param.setting.frm_per_pkt; |
| 6393 | obj->setting->penh = param.setting.penh; |
| 6394 | obj->setting->plc = param.setting.plc; |
| 6395 | obj->setting->reserved = param.setting.reserved; |
| 6396 | obj->setting->vad = param.setting.vad; |
| 6397 | |
| 6398 | return Py_BuildValue("O", obj); |
| 6399 | } |
| 6400 | /* |
| 6401 | * py_pjsua_codec_set_param |
| 6402 | */ |
| 6403 | static PyObject *py_pjsua_codec_set_param |
| 6404 | (PyObject *pSelf, PyObject *pArgs) |
| 6405 | { |
| 6406 | |
| 6407 | int status; |
| 6408 | PyObject * id; |
| 6409 | pj_str_t str; |
| 6410 | pjmedia_codec_param param; |
| 6411 | pjmedia_codec_param_Object *obj; |
| 6412 | |
| 6413 | |
| 6414 | if (!PyArg_ParseTuple(pArgs, "OO", &id, &obj)) |
| 6415 | { |
| 6416 | return NULL; |
| 6417 | } |
| 6418 | str.ptr = PyString_AsString(id); |
| 6419 | str.slen = strlen(PyString_AsString(id)); |
| 6420 | param.info.avg_bps = obj->info->avg_bps; |
| 6421 | param.info.channel_cnt = obj->info->channel_cnt; |
| 6422 | param.info.clock_rate = obj->info->clock_rate; |
| 6423 | param.info.frm_ptime = obj->info->frm_ptime; |
| 6424 | param.info.pcm_bits_per_sample = obj->info->pcm_bits_per_sample; |
| 6425 | param.info.pt = obj->info->pt; |
| 6426 | param.setting.cng = obj->setting->cng; |
| 6427 | param.setting.dec_fmtp_mode = obj->setting->dec_fmtp_mode; |
| 6428 | param.setting.enc_fmtp_mode = obj->setting->enc_fmtp_mode; |
| 6429 | param.setting.frm_per_pkt = obj->setting->frm_per_pkt; |
| 6430 | param.setting.penh = obj->setting->penh; |
| 6431 | param.setting.plc = obj->setting->plc; |
| 6432 | param.setting.reserved = obj->setting->reserved; |
| 6433 | param.setting.vad = obj->setting->vad; |
| 6434 | status = pjsua_codec_set_param(&str, ¶m); |
| 6435 | |
| 6436 | return Py_BuildValue("i", status); |
| 6437 | } |
| 6438 | |
| 6439 | static char pjsua_conf_get_max_ports_doc[] = |
| 6440 | "int py_pjsua.conf_get_max_ports () " |
| 6441 | "Get maxinum number of conference ports."; |
| 6442 | static char pjsua_conf_get_active_ports_doc[] = |
| 6443 | "int py_pjsua.conf_get_active_ports () " |
| 6444 | "Get current number of active ports in the bridge."; |
| 6445 | static char pjsua_enum_conf_ports_doc[] = |
| 6446 | "int[] py_pjsua.enum_conf_ports () " |
| 6447 | "Enumerate all conference ports."; |
| 6448 | static char pjsua_conf_get_port_info_doc[] = |
| 6449 | "py_pjsua.Conf_Port_Info py_pjsua.conf_get_port_info (int id) " |
| 6450 | "Get information about the specified conference port"; |
| 6451 | static char pjsua_conf_add_port_doc[] = |
| 6452 | "int, int py_pjsua.conf_add_port " |
| 6453 | "(py_pjsua.PJ_Pool pool, py_pjsua.PJMedia_Port port) " |
| 6454 | "Add arbitrary media port to PJSUA's conference bridge. " |
| 6455 | "Application can use this function to add the media port " |
| 6456 | "that it creates. For media ports that are created by PJSUA-LIB " |
| 6457 | "(such as calls, file player, or file recorder), PJSUA-LIB will " |
| 6458 | "automatically add the port to the bridge."; |
| 6459 | static char pjsua_conf_remove_port_doc[] = |
| 6460 | "int py_pjsua.conf_remove_port (int id) " |
| 6461 | "Remove arbitrary slot from the conference bridge. " |
| 6462 | "Application should only call this function " |
| 6463 | "if it registered the port manually."; |
| 6464 | static char pjsua_conf_connect_doc[] = |
| 6465 | "int py_pjsua.conf_connect (int source, int sink) " |
| 6466 | "Establish unidirectional media flow from souce to sink. " |
| 6467 | "One source may transmit to multiple destinations/sink. " |
| 6468 | "And if multiple sources are transmitting to the same sink, " |
| 6469 | "the media will be mixed together. Source and sink may refer " |
| 6470 | "to the same ID, effectively looping the media. " |
| 6471 | "If bidirectional media flow is desired, application " |
| 6472 | "needs to call this function twice, with the second " |
| 6473 | "one having the arguments reversed."; |
| 6474 | static char pjsua_conf_disconnect_doc[] = |
| 6475 | "int py_pjsua.conf_disconnect (int source, int sink) " |
| 6476 | "Disconnect media flow from the source to destination port."; |
| 6477 | static char pjsua_player_create_doc[] = |
| 6478 | "int, int py_pjsua.player_create (string filename, int options) " |
| 6479 | "Create a file player, and automatically connect " |
| 6480 | "this player to the conference bridge."; |
| 6481 | static char pjsua_player_get_conf_port_doc[] = |
| 6482 | "int py_pjsua.player_get_conf_port (int) " |
| 6483 | "Get conference port ID associated with player."; |
| 6484 | static char pjsua_player_set_pos_doc[] = |
| 6485 | "int py_pjsua.player_set_pos (int id, int samples) " |
| 6486 | "Set playback position."; |
| 6487 | static char pjsua_player_destroy_doc[] = |
| 6488 | "int py_pjsua.player_destroy (int id) " |
| 6489 | "Close the file, remove the player from the bridge, " |
| 6490 | "and free resources associated with the file player."; |
| 6491 | static char pjsua_recorder_create_doc[] = |
| 6492 | "int, int py_pjsua.recorder_create (string filename, " |
| 6493 | "int enc_type, int enc_param, int max_size, int options) " |
| 6494 | "Create a file recorder, and automatically connect this recorder " |
| 6495 | "to the conference bridge. The recorder currently supports recording " |
| 6496 | "WAV file, and on Windows, MP3 file. The type of the recorder to use " |
| 6497 | "is determined by the extension of the file (e.g. '.wav' or '.mp3')."; |
| 6498 | static char pjsua_recorder_get_conf_port_doc[] = |
| 6499 | "int py_pjsua.recorder_get_conf_port (int id) " |
| 6500 | "Get conference port associated with recorder."; |
| 6501 | static char pjsua_recorder_destroy_doc[] = |
| 6502 | "int py_pjsua.recorder_destroy (int id) " |
| 6503 | "Destroy recorder (this will complete recording)."; |
| 6504 | static char pjsua_enum_snd_devs_doc[] = |
| 6505 | "py_pjsua.PJMedia_Snd_Dev_Info[] py_pjsua.enum_snd_devs (int count) " |
| 6506 | "Enum sound devices."; |
| 6507 | static char pjsua_get_snd_dev_doc[] = |
| 6508 | "int, int py_pjsua.get_snd_dev () " |
| 6509 | "Get currently active sound devices. " |
| 6510 | "If sound devices has not been created " |
| 6511 | "(for example when pjsua_start() is not called), " |
| 6512 | "it is possible that the function returns " |
| 6513 | "PJ_SUCCESS with -1 as device IDs."; |
| 6514 | static char pjsua_set_snd_dev_doc[] = |
| 6515 | "int py_pjsua.set_snd_dev (int capture_dev, int playback_dev) " |
| 6516 | "Select or change sound device. Application may call this function " |
| 6517 | "at any time to replace current sound device."; |
| 6518 | static char pjsua_set_null_snd_dev_doc[] = |
| 6519 | "int py_pjsua.set_null_snd_dev () " |
| 6520 | "Set pjsua to use null sound device. The null sound device only " |
| 6521 | "provides the timing needed by the conference bridge, and will not " |
| 6522 | "interract with any hardware."; |
| 6523 | static char pjsua_set_no_snd_dev_doc[] = |
| 6524 | "py_pjsua.PJMedia_Port py_pjsua.set_no_snd_dev () " |
| 6525 | "Disconnect the main conference bridge from any sound devices, " |
| 6526 | "and let application connect the bridge to it's " |
| 6527 | "own sound device/master port."; |
| 6528 | static char pjsua_set_ec_doc[] = |
| 6529 | "int py_pjsua.set_ec (int tail_ms, int options) " |
| 6530 | "Configure the echo canceller tail length of the sound port."; |
| 6531 | static char pjsua_get_ec_tail_doc[] = |
| 6532 | "int py_pjsua.get_ec_tail () " |
| 6533 | "Get current echo canceller tail length."; |
| 6534 | static char pjsua_enum_codecs_doc[] = |
| 6535 | "py_pjsua.Codec_Info[] py_pjsua.enum_codecs () " |
| 6536 | "Enum all supported codecs in the system."; |
| 6537 | static char pjsua_codec_set_priority_doc[] = |
| 6538 | "int py_pjsua.codec_set_priority (string id, int priority) " |
| 6539 | "Change codec priority."; |
| 6540 | static char pjsua_codec_get_param_doc[] = |
| 6541 | "py_pjsua.PJMedia_Codec_Param py_pjsua.codec_get_param (string id) " |
| 6542 | "Get codec parameters"; |
| 6543 | static char pjsua_codec_set_param_doc[] = |
| 6544 | "int py_pjsua.codec_set_param (string id, " |
| 6545 | "py_pjsua.PJMedia_Codec_Param param) " |
| 6546 | "Set codec parameters."; |
| 6547 | |
| 6548 | /* END OF LIB MEDIA */ |
| 6549 | |
| 6550 | /* LIB CALL */ |
| 6551 | |
| 6552 | /* |
| 6553 | * pj_time_val_Object |
| 6554 | * PJ Time Val |
| 6555 | */ |
| 6556 | typedef struct |
| 6557 | { |
| 6558 | PyObject_HEAD |
| 6559 | /* Type-specific fields go here. */ |
| 6560 | long sec; |
| 6561 | long msec; |
| 6562 | |
| 6563 | } pj_time_val_Object; |
| 6564 | |
| 6565 | |
| 6566 | |
| 6567 | /* |
| 6568 | * pj_time_val_members |
| 6569 | */ |
| 6570 | static PyMemberDef pj_time_val_members[] = |
| 6571 | { |
| 6572 | |
| 6573 | { |
| 6574 | "sec", T_INT, |
| 6575 | offsetof(pj_time_val_Object, sec), 0, |
| 6576 | "The seconds part of the time" |
| 6577 | }, |
| 6578 | { |
| 6579 | "msec", T_INT, |
| 6580 | offsetof(pj_time_val_Object, sec), 0, |
| 6581 | "The milliseconds fraction of the time" |
| 6582 | }, |
| 6583 | |
| 6584 | |
| 6585 | {NULL} /* Sentinel */ |
| 6586 | }; |
| 6587 | |
| 6588 | |
| 6589 | |
| 6590 | |
| 6591 | /* |
| 6592 | * pj_time_val_Type |
| 6593 | */ |
| 6594 | static PyTypeObject pj_time_val_Type = |
| 6595 | { |
| 6596 | PyObject_HEAD_INIT(NULL) |
| 6597 | 0, /*ob_size*/ |
| 6598 | "py_pjsua.PJ_Time_Val", /*tp_name*/ |
| 6599 | sizeof(pj_time_val_Object), /*tp_basicsize*/ |
| 6600 | 0, /*tp_itemsize*/ |
| 6601 | 0,/*tp_dealloc*/ |
| 6602 | 0, /*tp_print*/ |
| 6603 | 0, /*tp_getattr*/ |
| 6604 | 0, /*tp_setattr*/ |
| 6605 | 0, /*tp_compare*/ |
| 6606 | 0, /*tp_repr*/ |
| 6607 | 0, /*tp_as_number*/ |
| 6608 | 0, /*tp_as_sequence*/ |
| 6609 | 0, /*tp_as_mapping*/ |
| 6610 | 0, /*tp_hash */ |
| 6611 | 0, /*tp_call*/ |
| 6612 | 0, /*tp_str*/ |
| 6613 | 0, /*tp_getattro*/ |
| 6614 | 0, /*tp_setattro*/ |
| 6615 | 0, /*tp_as_buffer*/ |
| 6616 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 6617 | "PJ Time Val objects", /* tp_doc */ |
| 6618 | 0, /* tp_traverse */ |
| 6619 | 0, /* tp_clear */ |
| 6620 | 0, /* tp_richcompare */ |
| 6621 | 0, /* tp_weaklistoffset */ |
| 6622 | 0, /* tp_iter */ |
| 6623 | 0, /* tp_iternext */ |
| 6624 | 0, /* tp_methods */ |
| 6625 | pj_time_val_members, /* tp_members */ |
| 6626 | |
| 6627 | |
| 6628 | }; |
| 6629 | |
| 6630 | /* |
| 6631 | * call_info_Object |
| 6632 | * Call Info |
| 6633 | */ |
| 6634 | typedef struct |
| 6635 | { |
| 6636 | PyObject_HEAD |
| 6637 | /* Type-specific fields go here. */ |
| 6638 | |
| 6639 | int id; |
| 6640 | int role; |
| 6641 | int acc_id; |
| 6642 | PyObject * local_info; |
| 6643 | PyObject * local_contact; |
| 6644 | PyObject * remote_info; |
| 6645 | PyObject * remote_contact; |
| 6646 | PyObject * call_id; |
| 6647 | int state; |
| 6648 | PyObject * state_text; |
| 6649 | int last_status; |
| 6650 | PyObject * last_status_text; |
| 6651 | int media_status; |
| 6652 | int media_dir; |
| 6653 | int conf_slot; |
| 6654 | pj_time_val_Object * connect_duration; |
| 6655 | pj_time_val_Object * total_duration; |
| 6656 | struct { |
| 6657 | char local_info[128]; |
| 6658 | char local_contact[128]; |
| 6659 | char remote_info[128]; |
| 6660 | char remote_contact[128]; |
| 6661 | char call_id[128]; |
| 6662 | char last_status_text[128]; |
| 6663 | } buf_; |
| 6664 | |
| 6665 | } call_info_Object; |
| 6666 | |
| 6667 | |
| 6668 | /* |
| 6669 | * call_info_dealloc |
| 6670 | * deletes a call_info from memory |
| 6671 | */ |
| 6672 | static void call_info_dealloc(call_info_Object* self) |
| 6673 | { |
| 6674 | Py_XDECREF(self->local_info); |
| 6675 | Py_XDECREF(self->local_contact); |
| 6676 | Py_XDECREF(self->remote_info); |
| 6677 | Py_XDECREF(self->remote_contact); |
| 6678 | Py_XDECREF(self->call_id); |
| 6679 | Py_XDECREF(self->state_text); |
| 6680 | Py_XDECREF(self->last_status_text); |
| 6681 | Py_XDECREF(self->connect_duration); |
| 6682 | Py_XDECREF(self->total_duration); |
| 6683 | self->ob_type->tp_free((PyObject*)self); |
| 6684 | } |
| 6685 | |
| 6686 | |
| 6687 | /* |
| 6688 | * call_info_new |
| 6689 | * constructor for call_info object |
| 6690 | */ |
| 6691 | static PyObject * call_info_new(PyTypeObject *type, PyObject *args, |
| 6692 | PyObject *kwds) |
| 6693 | { |
| 6694 | call_info_Object *self; |
| 6695 | |
| 6696 | self = (call_info_Object *)type->tp_alloc(type, 0); |
| 6697 | if (self != NULL) |
| 6698 | { |
| 6699 | self->local_info = PyString_FromString(""); |
| 6700 | if (self->local_info == NULL) |
| 6701 | { |
| 6702 | Py_DECREF(self); |
| 6703 | return NULL; |
| 6704 | } |
| 6705 | self->local_contact = PyString_FromString(""); |
| 6706 | if (self->local_contact == NULL) |
| 6707 | { |
| 6708 | Py_DECREF(self); |
| 6709 | return NULL; |
| 6710 | } |
| 6711 | self->remote_info = PyString_FromString(""); |
| 6712 | if (self->remote_info == NULL) |
| 6713 | { |
| 6714 | Py_DECREF(self); |
| 6715 | return NULL; |
| 6716 | } |
| 6717 | self->remote_contact = PyString_FromString(""); |
| 6718 | if (self->remote_contact == NULL) |
| 6719 | { |
| 6720 | Py_DECREF(self); |
| 6721 | return NULL; |
| 6722 | } |
| 6723 | self->call_id = PyString_FromString(""); |
| 6724 | if (self->call_id == NULL) |
| 6725 | { |
| 6726 | Py_DECREF(self); |
| 6727 | return NULL; |
| 6728 | } |
| 6729 | self->state_text = PyString_FromString(""); |
| 6730 | if (self->state_text == NULL) |
| 6731 | { |
| 6732 | Py_DECREF(self); |
| 6733 | return NULL; |
| 6734 | } |
| 6735 | self->last_status_text = PyString_FromString(""); |
| 6736 | if (self->last_status_text == NULL) |
| 6737 | { |
| 6738 | Py_DECREF(self); |
| 6739 | return NULL; |
| 6740 | } |
| 6741 | self->connect_duration = (pj_time_val_Object *)PyType_GenericNew |
| 6742 | (&pj_time_val_Type,NULL,NULL); |
| 6743 | if (self->connect_duration == NULL) |
| 6744 | { |
| 6745 | Py_DECREF(self); |
| 6746 | return NULL; |
| 6747 | } |
| 6748 | self->total_duration = (pj_time_val_Object *)PyType_GenericNew |
| 6749 | (&pj_time_val_Type,NULL,NULL); |
| 6750 | if (self->total_duration == NULL) |
| 6751 | { |
| 6752 | Py_DECREF(self); |
| 6753 | return NULL; |
| 6754 | } |
| 6755 | } |
| 6756 | return (PyObject *)self; |
| 6757 | } |
| 6758 | |
| 6759 | /* |
| 6760 | * call_info_members |
| 6761 | */ |
| 6762 | static PyMemberDef call_info_members[] = |
| 6763 | { |
| 6764 | { |
| 6765 | "id", T_INT, |
| 6766 | offsetof(call_info_Object, id), 0, |
| 6767 | "Call identification" |
| 6768 | }, |
| 6769 | { |
| 6770 | "role", T_INT, |
| 6771 | offsetof(call_info_Object, role), 0, |
| 6772 | "Initial call role (UAC == caller)" |
| 6773 | }, |
| 6774 | { |
| 6775 | "acc_id", T_INT, |
| 6776 | offsetof(call_info_Object, acc_id), 0, |
| 6777 | "The account ID where this call belongs." |
| 6778 | }, |
| 6779 | { |
| 6780 | "local_info", T_OBJECT_EX, |
| 6781 | offsetof(call_info_Object, local_info), 0, |
| 6782 | "Local URI" |
| 6783 | }, |
| 6784 | { |
| 6785 | "local_contact", T_OBJECT_EX, |
| 6786 | offsetof(call_info_Object, local_contact), 0, |
| 6787 | "Local Contact" |
| 6788 | }, |
| 6789 | { |
| 6790 | "remote_info", T_OBJECT_EX, |
| 6791 | offsetof(call_info_Object, remote_info), 0, |
| 6792 | "Remote URI" |
| 6793 | }, |
| 6794 | { |
| 6795 | "remote_contact", T_OBJECT_EX, |
| 6796 | offsetof(call_info_Object, remote_contact), 0, |
| 6797 | "Remote Contact" |
| 6798 | }, |
| 6799 | { |
| 6800 | "call_id", T_OBJECT_EX, |
| 6801 | offsetof(call_info_Object, call_id), 0, |
| 6802 | "Dialog Call-ID string" |
| 6803 | }, |
| 6804 | { |
| 6805 | "state", T_INT, |
| 6806 | offsetof(call_info_Object, state), 0, |
| 6807 | "Call state" |
| 6808 | }, |
| 6809 | { |
| 6810 | "state_text", T_OBJECT_EX, |
| 6811 | offsetof(call_info_Object, state_text), 0, |
| 6812 | "Text describing the state " |
| 6813 | }, |
| 6814 | { |
| 6815 | "last_status", T_INT, |
| 6816 | offsetof(call_info_Object, last_status), 0, |
| 6817 | "Last status code heard, which can be used as cause code" |
| 6818 | }, |
| 6819 | { |
| 6820 | "last_status_text", T_OBJECT_EX, |
| 6821 | offsetof(call_info_Object, last_status_text), 0, |
| 6822 | "The reason phrase describing the status." |
| 6823 | }, |
| 6824 | { |
| 6825 | "media_status", T_INT, |
| 6826 | offsetof(call_info_Object, media_status), 0, |
| 6827 | "Call media status." |
| 6828 | }, |
| 6829 | { |
| 6830 | "media_dir", T_INT, |
| 6831 | offsetof(call_info_Object, media_dir), 0, |
| 6832 | "Media direction" |
| 6833 | }, |
| 6834 | { |
| 6835 | "conf_slot", T_INT, |
| 6836 | offsetof(call_info_Object, conf_slot), 0, |
| 6837 | "The conference port number for the call" |
| 6838 | }, |
| 6839 | { |
| 6840 | "connect_duration", T_OBJECT_EX, |
| 6841 | offsetof(call_info_Object, connect_duration), 0, |
| 6842 | "Up-to-date call connected duration (zero when call is not established)" |
| 6843 | }, |
| 6844 | { |
| 6845 | "total_duration", T_OBJECT_EX, |
| 6846 | offsetof(call_info_Object, total_duration), 0, |
| 6847 | "Total call duration, including set-up time" |
| 6848 | }, |
| 6849 | |
| 6850 | {NULL} /* Sentinel */ |
| 6851 | }; |
| 6852 | |
| 6853 | |
| 6854 | |
| 6855 | |
| 6856 | /* |
| 6857 | * call_info_Type |
| 6858 | */ |
| 6859 | static PyTypeObject call_info_Type = |
| 6860 | { |
| 6861 | PyObject_HEAD_INIT(NULL) |
| 6862 | 0, /*ob_size*/ |
| 6863 | "py_pjsua.Call_Info", /*tp_name*/ |
| 6864 | sizeof(call_info_Object), /*tp_basicsize*/ |
| 6865 | 0, /*tp_itemsize*/ |
| 6866 | (destructor)call_info_dealloc,/*tp_dealloc*/ |
| 6867 | 0, /*tp_print*/ |
| 6868 | 0, /*tp_getattr*/ |
| 6869 | 0, /*tp_setattr*/ |
| 6870 | 0, /*tp_compare*/ |
| 6871 | 0, /*tp_repr*/ |
| 6872 | 0, /*tp_as_number*/ |
| 6873 | 0, /*tp_as_sequence*/ |
| 6874 | 0, /*tp_as_mapping*/ |
| 6875 | 0, /*tp_hash */ |
| 6876 | 0, /*tp_call*/ |
| 6877 | 0, /*tp_str*/ |
| 6878 | 0, /*tp_getattro*/ |
| 6879 | 0, /*tp_setattro*/ |
| 6880 | 0, /*tp_as_buffer*/ |
| 6881 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 6882 | "Call Info objects", /* tp_doc */ |
| 6883 | 0, /* tp_traverse */ |
| 6884 | 0, /* tp_clear */ |
| 6885 | 0, /* tp_richcompare */ |
| 6886 | 0, /* tp_weaklistoffset */ |
| 6887 | 0, /* tp_iter */ |
| 6888 | 0, /* tp_iternext */ |
| 6889 | 0, /* tp_methods */ |
| 6890 | call_info_members, /* tp_members */ |
| 6891 | 0, /* tp_getset */ |
| 6892 | 0, /* tp_base */ |
| 6893 | 0, /* tp_dict */ |
| 6894 | 0, /* tp_descr_get */ |
| 6895 | 0, /* tp_descr_set */ |
| 6896 | 0, /* tp_dictoffset */ |
| 6897 | 0, /* tp_init */ |
| 6898 | 0, /* tp_alloc */ |
| 6899 | call_info_new, /* tp_new */ |
| 6900 | |
| 6901 | }; |
| 6902 | |
| 6903 | /* |
| 6904 | * py_pjsua_call_get_max_count |
| 6905 | */ |
| 6906 | static PyObject *py_pjsua_call_get_max_count |
| 6907 | (PyObject *pSelf, PyObject *pArgs) |
| 6908 | { |
| 6909 | int count; |
| 6910 | |
| 6911 | if (!PyArg_ParseTuple(pArgs, "")) |
| 6912 | { |
| 6913 | return NULL; |
| 6914 | } |
| 6915 | |
| 6916 | count = pjsua_call_get_max_count(); |
| 6917 | |
| 6918 | |
| 6919 | return Py_BuildValue("i", count); |
| 6920 | } |
| 6921 | |
| 6922 | /* |
| 6923 | * py_pjsua_call_get_count |
| 6924 | */ |
| 6925 | static PyObject *py_pjsua_call_get_count |
| 6926 | (PyObject *pSelf, PyObject *pArgs) |
| 6927 | { |
| 6928 | |
| 6929 | int count; |
| 6930 | |
| 6931 | |
| 6932 | if (!PyArg_ParseTuple(pArgs, "")) |
| 6933 | { |
| 6934 | return NULL; |
| 6935 | } |
| 6936 | |
| 6937 | count = pjsua_call_get_count(); |
| 6938 | |
| 6939 | |
| 6940 | return Py_BuildValue("i", count); |
| 6941 | } |
| 6942 | |
| 6943 | /* |
| 6944 | * py_pjsua_enum_calls |
| 6945 | */ |
| 6946 | static PyObject *py_pjsua_enum_calls(PyObject *pSelf, PyObject *pArgs) |
| 6947 | { |
| 6948 | pj_status_t status; |
| 6949 | PyObject *list; |
| 6950 | |
| 6951 | pjsua_transport_id id[PJSUA_MAX_CALLS]; |
| 6952 | int c, i; |
| 6953 | if (!PyArg_ParseTuple(pArgs, "")) |
| 6954 | { |
| 6955 | return NULL; |
| 6956 | } |
| 6957 | |
| 6958 | c = PJ_ARRAY_SIZE(id); |
| 6959 | status = pjsua_enum_calls(id, &c); |
| 6960 | |
| 6961 | list = PyList_New(c); |
| 6962 | for (i = 0; i < c; i++) |
| 6963 | { |
| 6964 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 6965 | if (ret == -1) |
| 6966 | { |
| 6967 | return NULL; |
| 6968 | } |
| 6969 | } |
| 6970 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 6971 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 6972 | return Py_BuildValue("O",list); |
| 6973 | } |
| 6974 | |
| 6975 | /* |
| 6976 | * py_pjsua_call_make_call |
| 6977 | */ |
| 6978 | static PyObject *py_pjsua_call_make_call |
| 6979 | (PyObject *pSelf, PyObject *pArgs) |
| 6980 | { |
| 6981 | int status; |
| 6982 | int acc_id; |
| 6983 | pj_str_t dst_uri; |
| 6984 | PyObject * sd; |
| 6985 | unsigned options; |
| 6986 | pjsua_msg_data msg_data; |
| 6987 | msg_data_Object * omd; |
| 6988 | int user_data; |
| 6989 | int call_id; |
| 6990 | pj_pool_t * pool; |
| 6991 | |
| 6992 | if (!PyArg_ParseTuple(pArgs, "iOIiO", &acc_id, &sd, &options, &user_data, &omd)) |
| 6993 | { |
| 6994 | return NULL; |
| 6995 | } |
| 6996 | |
| 6997 | dst_uri.ptr = PyString_AsString(sd); |
| 6998 | dst_uri.slen = strlen(PyString_AsString(sd)); |
| 6999 | |
| 7000 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 7001 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 7002 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 7003 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 7004 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 7005 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 7006 | status = pjsua_call_make_call(acc_id, &dst_uri, options, &user_data, &msg_data, &call_id); |
| 7007 | pj_pool_release(pool); |
| 7008 | return Py_BuildValue("ii",status, call_id); |
| 7009 | } |
| 7010 | |
| 7011 | /* |
| 7012 | * py_pjsua_call_is_active |
| 7013 | */ |
| 7014 | static PyObject *py_pjsua_call_is_active |
| 7015 | (PyObject *pSelf, PyObject *pArgs) |
| 7016 | { |
| 7017 | int call_id; |
| 7018 | int isActive; |
| 7019 | |
| 7020 | |
| 7021 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 7022 | { |
| 7023 | return NULL; |
| 7024 | } |
| 7025 | |
| 7026 | isActive = pjsua_call_is_active(call_id); |
| 7027 | |
| 7028 | |
| 7029 | return Py_BuildValue("i", isActive); |
| 7030 | } |
| 7031 | |
| 7032 | /* |
| 7033 | * py_pjsua_call_has_media |
| 7034 | */ |
| 7035 | static PyObject *py_pjsua_call_has_media |
| 7036 | (PyObject *pSelf, PyObject *pArgs) |
| 7037 | { |
| 7038 | int call_id; |
| 7039 | int hasMedia; |
| 7040 | |
| 7041 | |
| 7042 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 7043 | { |
| 7044 | return NULL; |
| 7045 | } |
| 7046 | |
| 7047 | hasMedia = pjsua_call_has_media(call_id); |
| 7048 | |
| 7049 | |
| 7050 | return Py_BuildValue("i", hasMedia); |
| 7051 | } |
| 7052 | |
| 7053 | /* |
| 7054 | * py_pjsua_call_get_conf_port |
| 7055 | */ |
| 7056 | static PyObject *py_pjsua_call_get_conf_port |
| 7057 | (PyObject *pSelf, PyObject *pArgs) |
| 7058 | { |
| 7059 | int call_id; |
| 7060 | int port_id; |
| 7061 | |
| 7062 | |
| 7063 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 7064 | { |
| 7065 | return NULL; |
| 7066 | } |
| 7067 | |
| 7068 | port_id = pjsua_call_get_conf_port(call_id); |
| 7069 | |
| 7070 | |
| 7071 | return Py_BuildValue("i", port_id); |
| 7072 | } |
| 7073 | |
| 7074 | /* |
| 7075 | * py_pjsua_call_get_info |
| 7076 | */ |
| 7077 | static PyObject *py_pjsua_call_get_info |
| 7078 | (PyObject *pSelf, PyObject *pArgs) |
| 7079 | { |
| 7080 | int call_id; |
| 7081 | int status; |
| 7082 | call_info_Object * oi; |
| 7083 | pjsua_call_info info; |
| 7084 | int i; |
| 7085 | |
| 7086 | |
| 7087 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 7088 | { |
| 7089 | return NULL; |
| 7090 | } |
| 7091 | |
| 7092 | |
| 7093 | status = pjsua_call_get_info(call_id, &info); |
| 7094 | if (status == PJ_SUCCESS) |
| 7095 | { |
| 7096 | oi = (call_info_Object *)call_info_new(&call_info_Type, NULL, NULL); |
| 7097 | oi->acc_id = info.acc_id; |
| 7098 | for (i = 0; i < 128; i++) |
| 7099 | { |
| 7100 | oi->buf_.call_id[i] = info.buf_.call_id[i]; |
| 7101 | oi->buf_.last_status_text[i] = info.buf_.last_status_text[i]; |
| 7102 | oi->buf_.local_contact[i] = info.buf_.local_contact[i]; |
| 7103 | oi->buf_.local_info[i] = info.buf_.local_info[i]; |
| 7104 | oi->buf_.remote_contact[i] = info.buf_.remote_contact[i]; |
| 7105 | oi->buf_.remote_info[i] = info.buf_.remote_info[i]; |
| 7106 | } |
| 7107 | oi->call_id = PyString_FromStringAndSize(info.call_id.ptr, |
| 7108 | info.call_id.slen); |
| 7109 | oi->conf_slot = info.conf_slot; |
| 7110 | oi->connect_duration->sec = info.connect_duration.sec; |
| 7111 | oi->connect_duration->msec = info.connect_duration.msec; |
| 7112 | oi->total_duration->sec = info.total_duration.sec; |
| 7113 | oi->total_duration->msec = info.total_duration.msec; |
| 7114 | oi->id = info.id; |
| 7115 | oi->last_status = info.last_status; |
| 7116 | oi->last_status_text = PyString_FromStringAndSize( |
| 7117 | info.last_status_text.ptr, info.last_status_text.slen); |
| 7118 | oi->local_contact = PyString_FromStringAndSize( |
| 7119 | info.local_contact.ptr, info.local_contact.slen); |
| 7120 | oi->local_info = PyString_FromStringAndSize( |
| 7121 | info.local_info.ptr, info.local_info.slen); |
| 7122 | oi->remote_contact = PyString_FromStringAndSize( |
| 7123 | info.remote_contact.ptr, info.remote_contact.slen); |
| 7124 | oi->remote_info = PyString_FromStringAndSize( |
| 7125 | info.remote_info.ptr, info.remote_info.slen); |
| 7126 | oi->media_dir = info.media_dir; |
| 7127 | oi->media_status = info.media_status; |
| 7128 | oi->role = info.role; |
| 7129 | oi->state = info.state; |
| 7130 | oi->state_text = PyString_FromStringAndSize( |
| 7131 | info.state_text.ptr, info.state_text.slen); |
| 7132 | |
| 7133 | return Py_BuildValue("O", oi); |
| 7134 | } else { |
| 7135 | Py_INCREF(Py_None); |
| 7136 | return Py_None; |
| 7137 | } |
| 7138 | } |
| 7139 | |
| 7140 | /* |
| 7141 | * py_pjsua_call_set_user_data |
| 7142 | */ |
| 7143 | static PyObject *py_pjsua_call_set_user_data |
| 7144 | (PyObject *pSelf, PyObject *pArgs) |
| 7145 | { |
| 7146 | int call_id; |
| 7147 | int user_data; |
| 7148 | int status; |
| 7149 | |
| 7150 | if (!PyArg_ParseTuple(pArgs, "ii", &call_id, &user_data)) |
| 7151 | { |
| 7152 | return NULL; |
| 7153 | } |
| 7154 | |
| 7155 | status = pjsua_call_set_user_data(call_id, &user_data); |
| 7156 | |
| 7157 | |
| 7158 | return Py_BuildValue("i", status); |
| 7159 | } |
| 7160 | |
| 7161 | /* |
| 7162 | * py_pjsua_call_get_user_data |
| 7163 | */ |
| 7164 | static PyObject *py_pjsua_call_get_user_data |
| 7165 | (PyObject *pSelf, PyObject *pArgs) |
| 7166 | { |
| 7167 | int call_id; |
| 7168 | int * user_data; |
| 7169 | |
| 7170 | |
| 7171 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 7172 | { |
| 7173 | return NULL; |
| 7174 | } |
| 7175 | |
| 7176 | user_data = pjsua_call_get_user_data(call_id); |
| 7177 | |
| 7178 | |
| 7179 | return Py_BuildValue("i", *user_data); |
| 7180 | } |
| 7181 | |
| 7182 | /* |
| 7183 | * py_pjsua_call_answer |
| 7184 | */ |
| 7185 | static PyObject *py_pjsua_call_answer |
| 7186 | (PyObject *pSelf, PyObject *pArgs) |
| 7187 | { |
| 7188 | int status; |
| 7189 | int call_id; |
| 7190 | pj_str_t reason; |
| 7191 | PyObject * sr; |
| 7192 | unsigned code; |
| 7193 | pjsua_msg_data msg_data; |
| 7194 | msg_data_Object * omd; |
| 7195 | pj_pool_t * pool; |
| 7196 | |
| 7197 | if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omd)) |
| 7198 | { |
| 7199 | return NULL; |
| 7200 | } |
| 7201 | |
| 7202 | reason.ptr = PyString_AsString(sr); |
| 7203 | reason.slen = strlen(PyString_AsString(sr)); |
| 7204 | |
| 7205 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 7206 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 7207 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 7208 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 7209 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 7210 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 7211 | status = pjsua_call_answer(call_id, code, &reason, &msg_data); |
| 7212 | |
| 7213 | pj_pool_release(pool); |
| 7214 | return Py_BuildValue("i",status); |
| 7215 | } |
| 7216 | |
| 7217 | /* |
| 7218 | * py_pjsua_call_hangup |
| 7219 | */ |
| 7220 | static PyObject *py_pjsua_call_hangup |
| 7221 | (PyObject *pSelf, PyObject *pArgs) |
| 7222 | { |
| 7223 | int status; |
| 7224 | int call_id; |
| 7225 | pj_str_t reason; |
| 7226 | PyObject * sr; |
| 7227 | unsigned code; |
| 7228 | pjsua_msg_data msg_data; |
| 7229 | msg_data_Object * omd; |
| 7230 | pj_pool_t * pool; |
| 7231 | |
| 7232 | if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omd)) |
| 7233 | { |
| 7234 | return NULL; |
| 7235 | } |
| 7236 | |
| 7237 | reason.ptr = PyString_AsString(sr); |
| 7238 | reason.slen = strlen(PyString_AsString(sr)); |
| 7239 | |
| 7240 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 7241 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 7242 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 7243 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 7244 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 7245 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 7246 | status = pjsua_call_hangup(call_id, code, &reason, &msg_data); |
| 7247 | pj_pool_release(pool); |
| 7248 | return Py_BuildValue("i",status); |
| 7249 | } |
| 7250 | |
| 7251 | /* |
| 7252 | * py_pjsua_call_set_hold |
| 7253 | */ |
| 7254 | static PyObject *py_pjsua_call_set_hold |
| 7255 | (PyObject *pSelf, PyObject *pArgs) |
| 7256 | { |
| 7257 | int status; |
| 7258 | int call_id; |
| 7259 | pjsua_msg_data msg_data; |
| 7260 | msg_data_Object * omd; |
| 7261 | pj_pool_t * pool; |
| 7262 | |
| 7263 | if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omd)) |
| 7264 | { |
| 7265 | return NULL; |
| 7266 | } |
| 7267 | |
| 7268 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 7269 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 7270 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 7271 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 7272 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 7273 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 7274 | status = pjsua_call_set_hold(call_id, &msg_data); |
| 7275 | pj_pool_release(pool); |
| 7276 | return Py_BuildValue("i",status); |
| 7277 | } |
| 7278 | |
| 7279 | /* |
| 7280 | * py_pjsua_call_reinvite |
| 7281 | */ |
| 7282 | static PyObject *py_pjsua_call_reinvite |
| 7283 | (PyObject *pSelf, PyObject *pArgs) |
| 7284 | { |
| 7285 | int status; |
| 7286 | int call_id; |
| 7287 | int unhold; |
| 7288 | pjsua_msg_data msg_data; |
| 7289 | msg_data_Object * omd; |
| 7290 | pj_pool_t * pool; |
| 7291 | |
| 7292 | if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omd)) |
| 7293 | { |
| 7294 | return NULL; |
| 7295 | } |
| 7296 | |
| 7297 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 7298 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 7299 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 7300 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 7301 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 7302 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 7303 | status = pjsua_call_reinvite(call_id, unhold, &msg_data); |
| 7304 | pj_pool_release(pool); |
| 7305 | return Py_BuildValue("i",status); |
| 7306 | } |
| 7307 | |
| 7308 | /* |
| 7309 | * py_pjsua_call_xfer |
| 7310 | */ |
| 7311 | static PyObject *py_pjsua_call_xfer |
| 7312 | (PyObject *pSelf, PyObject *pArgs) |
| 7313 | { |
| 7314 | int status; |
| 7315 | int call_id; |
| 7316 | pj_str_t dest; |
| 7317 | PyObject * sd; |
| 7318 | pjsua_msg_data msg_data; |
| 7319 | msg_data_Object * omd; |
| 7320 | pj_pool_t * pool; |
| 7321 | |
| 7322 | if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &sd, &omd)) |
| 7323 | { |
| 7324 | return NULL; |
| 7325 | } |
| 7326 | |
| 7327 | dest.ptr = PyString_AsString(sd); |
| 7328 | dest.slen = strlen(PyString_AsString(sd)); |
| 7329 | |
| 7330 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 7331 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 7332 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 7333 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 7334 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 7335 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 7336 | status = pjsua_call_xfer(call_id, &dest, &msg_data); |
| 7337 | pj_pool_release(pool); |
| 7338 | return Py_BuildValue("i",status); |
| 7339 | } |
| 7340 | |
| 7341 | /* |
| 7342 | * py_pjsua_call_xfer_replaces |
| 7343 | */ |
| 7344 | static PyObject *py_pjsua_call_xfer_replaces |
| 7345 | (PyObject *pSelf, PyObject *pArgs) |
| 7346 | { |
| 7347 | int status; |
| 7348 | int call_id; |
| 7349 | int dest_call_id; |
| 7350 | unsigned options; |
| 7351 | pjsua_msg_data msg_data; |
| 7352 | msg_data_Object * omd; |
| 7353 | pj_pool_t * pool; |
| 7354 | |
| 7355 | if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &dest_call_id, &options, &omd)) |
| 7356 | { |
| 7357 | return NULL; |
| 7358 | } |
| 7359 | |
| 7360 | |
| 7361 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 7362 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 7363 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 7364 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 7365 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 7366 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 7367 | status = pjsua_call_xfer_replaces(call_id, dest_call_id, options, &msg_data); |
| 7368 | pj_pool_release(pool); |
| 7369 | return Py_BuildValue("i",status); |
| 7370 | } |
| 7371 | |
| 7372 | /* |
| 7373 | * py_pjsua_call_dial_dtmf |
| 7374 | */ |
| 7375 | static PyObject *py_pjsua_call_dial_dtmf |
| 7376 | (PyObject *pSelf, PyObject *pArgs) |
| 7377 | { |
| 7378 | int call_id; |
| 7379 | PyObject * sd; |
| 7380 | pj_str_t digits; |
| 7381 | int status; |
| 7382 | |
| 7383 | if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &sd)) |
| 7384 | { |
| 7385 | return NULL; |
| 7386 | } |
| 7387 | digits.ptr = PyString_AsString(sd); |
| 7388 | digits.slen = strlen(PyString_AsString(sd)); |
| 7389 | status = pjsua_call_dial_dtmf(call_id, &digits); |
| 7390 | |
| 7391 | return Py_BuildValue("i", status); |
| 7392 | } |
| 7393 | |
| 7394 | /* |
| 7395 | * py_pjsua_call_send_im |
| 7396 | */ |
| 7397 | static PyObject *py_pjsua_call_send_im |
| 7398 | (PyObject *pSelf, PyObject *pArgs) |
| 7399 | { |
| 7400 | int status; |
| 7401 | int call_id; |
| 7402 | pj_str_t mime_type, content; |
| 7403 | PyObject * sm; |
| 7404 | PyObject * sc; |
| 7405 | pjsua_msg_data msg_data; |
| 7406 | msg_data_Object * omd; |
| 7407 | int user_data; |
| 7408 | pj_pool_t * pool; |
| 7409 | |
| 7410 | if (!PyArg_ParseTuple(pArgs, "iOOOi", &call_id, &sm, &sc, &omd, &user_data)) |
| 7411 | { |
| 7412 | return NULL; |
| 7413 | } |
| 7414 | |
| 7415 | mime_type.ptr = PyString_AsString(sm); |
| 7416 | mime_type.slen = strlen(PyString_AsString(sm)); |
| 7417 | content.ptr = PyString_AsString(sc); |
| 7418 | content.slen = strlen(PyString_AsString(sc)); |
| 7419 | |
| 7420 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 7421 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 7422 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 7423 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 7424 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 7425 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 7426 | status = pjsua_call_send_im(call_id, &mime_type, &content, &msg_data, &user_data); |
| 7427 | pj_pool_release(pool); |
| 7428 | return Py_BuildValue("i",status); |
| 7429 | } |
| 7430 | |
| 7431 | /* |
| 7432 | * py_pjsua_call_send_typing_ind |
| 7433 | */ |
| 7434 | static PyObject *py_pjsua_call_send_typing_ind |
| 7435 | (PyObject *pSelf, PyObject *pArgs) |
| 7436 | { |
| 7437 | int status; |
| 7438 | int call_id; |
| 7439 | int is_typing; |
| 7440 | pjsua_msg_data msg_data; |
| 7441 | msg_data_Object * omd; |
| 7442 | pj_pool_t * pool; |
| 7443 | |
| 7444 | if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omd)) |
| 7445 | { |
| 7446 | return NULL; |
| 7447 | } |
| 7448 | |
| 7449 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 7450 | msg_data.content_type.slen = strlen(PyString_AsString(omd->content_type)); |
| 7451 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 7452 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
| 7453 | pool = pjsua_pool_create("pjsua", 4000, 4000); |
| 7454 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 7455 | status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data); |
| 7456 | pj_pool_release(pool); |
| 7457 | return Py_BuildValue("i",status); |
| 7458 | } |
| 7459 | |
| 7460 | /* |
| 7461 | * py_pjsua_call_hangup_all |
| 7462 | */ |
| 7463 | static PyObject *py_pjsua_call_hangup_all |
| 7464 | (PyObject *pSelf, PyObject *pArgs) |
| 7465 | { |
| 7466 | |
| 7467 | if (!PyArg_ParseTuple(pArgs, "")) |
| 7468 | { |
| 7469 | return NULL; |
| 7470 | } |
| 7471 | |
| 7472 | pjsua_call_hangup_all(); |
| 7473 | |
| 7474 | Py_INCREF(Py_None); |
| 7475 | return Py_None; |
| 7476 | } |
| 7477 | |
| 7478 | /* |
| 7479 | * py_pjsua_call_dump |
| 7480 | */ |
| 7481 | static PyObject *py_pjsua_call_dump |
| 7482 | (PyObject *pSelf, PyObject *pArgs) |
| 7483 | { |
| 7484 | int call_id; |
| 7485 | int with_media; |
| 7486 | PyObject * sb; |
| 7487 | PyObject * si; |
| 7488 | char * buffer; |
| 7489 | char * indent; |
| 7490 | unsigned maxlen; |
| 7491 | int status; |
| 7492 | |
| 7493 | if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media, &maxlen, &si)) |
| 7494 | { |
| 7495 | return NULL; |
| 7496 | } |
| 7497 | buffer = (char *) malloc (maxlen * sizeof(char)); |
| 7498 | indent = PyString_AsString(si); |
| 7499 | |
| 7500 | status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent); |
| 7501 | sb = PyString_FromStringAndSize(buffer, maxlen); |
| 7502 | return Py_BuildValue("O", sb); |
| 7503 | } |
| 7504 | |
| 7505 | static char pjsua_call_get_max_count_doc[] = |
| 7506 | "int py_pjsua.call_get_max_count () " |
| 7507 | "Get maximum number of calls configured in pjsua."; |
| 7508 | static char pjsua_call_get_count_doc[] = |
| 7509 | "int py_pjsua.call_get_count () " |
| 7510 | "Get number of currently active calls."; |
| 7511 | static char pjsua_enum_calls_doc[] = |
| 7512 | "int[] py_pjsua.enum_calls () " |
| 7513 | "Get maximum number of calls configured in pjsua."; |
| 7514 | static char pjsua_call_make_call_doc[] = |
| 7515 | "int,int py_pjsua.call_make_call (int acc_id, string dst_uri, int options," |
| 7516 | "int user_data, py_pjsua.Msg_Data msg_data) " |
| 7517 | "Make outgoing call to the specified URI using the specified account."; |
| 7518 | static char pjsua_call_is_active_doc[] = |
| 7519 | "int py_pjsua.call_is_active (int call_id) " |
| 7520 | "Check if the specified call has active INVITE session and the INVITE " |
| 7521 | "session has not been disconnected."; |
| 7522 | static char pjsua_call_has_media_doc[] = |
| 7523 | "int py_pjsua.call_has_media (int call_id) " |
| 7524 | "Check if call has an active media session."; |
| 7525 | static char pjsua_call_get_conf_port_doc[] = |
| 7526 | "int py_pjsua.call_get_conf_port (int call_id) " |
| 7527 | "Get the conference port identification associated with the call."; |
| 7528 | static char pjsua_call_get_info_doc[] = |
| 7529 | "py_pjsua.Call_Info py_pjsua.call_get_info (int call_id) " |
| 7530 | "Obtain detail information about the specified call."; |
| 7531 | static char pjsua_call_set_user_data_doc[] = |
| 7532 | "int py_pjsua.call_set_user_data (int call_id, int user_data) " |
| 7533 | "Attach application specific data to the call."; |
| 7534 | static char pjsua_call_get_user_data_doc[] = |
| 7535 | "int py_pjsua.call_get_user_data (int call_id) " |
| 7536 | "Get user data attached to the call."; |
| 7537 | static char pjsua_call_answer_doc[] = |
| 7538 | "int py_pjsua.call_answer (int call_id, int code, string reason, " |
| 7539 | "py_pjsua.Msg_Data msg_data) " |
| 7540 | "Send response to incoming INVITE request."; |
| 7541 | static char pjsua_call_hangup_doc[] = |
| 7542 | "int py_pjsua.call_hangup (int call_id, int code, string reason, " |
| 7543 | "py_pjsua.Msg_Data msg_data) " |
| 7544 | "Hangup call by using method that is appropriate according " |
| 7545 | "to the call state."; |
| 7546 | static char pjsua_call_set_hold_doc[] = |
| 7547 | "int py_pjsua.call_set_hold (int call_id, py_pjsua.Msg_Data msg_data) " |
| 7548 | "Put the specified call on hold."; |
| 7549 | static char pjsua_call_reinvite_doc[] = |
| 7550 | "int py_pjsua.call_reinvite (int call_id, int unhold, " |
| 7551 | "py_pjsua.Msg_Data msg_data) " |
| 7552 | "Send re-INVITE (to release hold)."; |
| 7553 | static char pjsua_call_xfer_doc[] = |
| 7554 | "int py_pjsua.call_xfer (int call_id, string dest, " |
| 7555 | "py_pjsua.Msg_Data msg_data) " |
| 7556 | "Initiate call transfer to the specified address. " |
| 7557 | "This function will send REFER request to instruct remote call party " |
| 7558 | "to initiate a new INVITE session to the specified destination/target."; |
| 7559 | static char pjsua_call_xfer_replaces_doc[] = |
| 7560 | "int py_pjsua.call_xfer_replaces (int call_id, int dest_call_id, " |
| 7561 | "int options, py_pjsua.Msg_Data msg_data) " |
| 7562 | "Initiate attended call transfer. This function will send REFER request " |
| 7563 | "to instruct remote call party to initiate new INVITE session to the URL " |
| 7564 | "of dest_call_id. The party at dest_call_id then should 'replace' the call" |
| 7565 | "with us with the new call from the REFER recipient."; |
| 7566 | static char pjsua_call_dial_dtmf_doc[] = |
| 7567 | "int py_pjsua.call_dial_dtmf (int call_id, string digits) " |
| 7568 | "Send DTMF digits to remote using RFC 2833 payload formats."; |
| 7569 | static char pjsua_call_send_im_doc[] = |
| 7570 | "int py_pjsua.call_send_im (int call_id, string mime_type, string content," |
| 7571 | "py_pjsua.Msg_Data msg_data, int user_data) " |
| 7572 | "Send instant messaging inside INVITE session."; |
| 7573 | static char pjsua_call_send_typing_ind_doc[] = |
| 7574 | "int py_pjsua.call_send_typing_ind (int call_id, int is_typing, " |
| 7575 | "py_pjsua.Msg_Data msg_data) " |
| 7576 | "Send IM typing indication inside INVITE session."; |
| 7577 | static char pjsua_call_hangup_all_doc[] = |
| 7578 | "void py_pjsua.call_hangup_all () " |
| 7579 | "Terminate all calls."; |
| 7580 | static char pjsua_call_dump_doc[] = |
| 7581 | "int py_pjsua.call_dump (int call_id, int with_media, int maxlen, " |
| 7582 | "string indent) " |
| 7583 | "Dump call and media statistics to string."; |
| 7584 | |
| 7585 | /* END OF LIB CALL */ |
| 7586 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame^] | 7587 | /* For testing purpose only */ |
| 7588 | |
| 7589 | struct call_data |
| 7590 | { |
| 7591 | pj_timer_entry timer; |
| 7592 | }; |
| 7593 | |
| 7594 | /* |
| 7595 | * call_data_Object |
| 7596 | */ |
| 7597 | typedef struct |
| 7598 | { |
| 7599 | PyObject_HEAD |
| 7600 | /* Type-specific fields go here. */ |
| 7601 | struct call_data * data; |
| 7602 | } call_data_Object; |
| 7603 | |
| 7604 | |
| 7605 | /* |
| 7606 | * call_data_Type |
| 7607 | */ |
| 7608 | static PyTypeObject call_data_Type = |
| 7609 | { |
| 7610 | PyObject_HEAD_INIT(NULL) |
| 7611 | 0, /*ob_size*/ |
| 7612 | "py_pjsua.Call_Data", /*tp_name*/ |
| 7613 | sizeof(call_data_Object), /*tp_basicsize*/ |
| 7614 | 0, /*tp_itemsize*/ |
| 7615 | 0, /*tp_dealloc*/ |
| 7616 | 0, /*tp_print*/ |
| 7617 | 0, /*tp_getattr*/ |
| 7618 | 0, /*tp_setattr*/ |
| 7619 | 0, /*tp_compare*/ |
| 7620 | 0, /*tp_repr*/ |
| 7621 | 0, /*tp_as_number*/ |
| 7622 | 0, /*tp_as_sequence*/ |
| 7623 | 0, /*tp_as_mapping*/ |
| 7624 | 0, /*tp_hash */ |
| 7625 | 0, /*tp_call*/ |
| 7626 | 0, /*tp_str*/ |
| 7627 | 0, /*tp_getattro*/ |
| 7628 | 0, /*tp_setattro*/ |
| 7629 | 0, /*tp_as_buffer*/ |
| 7630 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 7631 | "call_data objects", /*tp_doc*/ |
| 7632 | }; |
| 7633 | |
| 7634 | static void call_timeout_callback(pj_timer_heap_t *timer_heap, |
| 7635 | struct pj_timer_entry *entry, unsigned duration) |
| 7636 | { |
| 7637 | pjsua_call_id call_id = entry->id; |
| 7638 | pjsua_msg_data msg_data; |
| 7639 | pjsip_generic_string_hdr warn; |
| 7640 | pj_str_t hname = pj_str("Warning"); |
| 7641 | pj_str_t hvalue = pj_str("399 pjsua \"Call duration exceeded\""); |
| 7642 | |
| 7643 | PJ_UNUSED_ARG(timer_heap); |
| 7644 | |
| 7645 | if (call_id == PJSUA_INVALID_ID) { |
| 7646 | PJ_LOG(1,(THIS_FILE, "Invalid call ID in timer callback")); |
| 7647 | return; |
| 7648 | } |
| 7649 | |
| 7650 | /* Add warning header */ |
| 7651 | pjsua_msg_data_init(&msg_data); |
| 7652 | pjsip_generic_string_hdr_init2(&warn, &hname, &hvalue); |
| 7653 | pj_list_push_back(&msg_data.hdr_list, &warn); |
| 7654 | |
| 7655 | /* Call duration has been exceeded; disconnect the call */ |
| 7656 | PJ_LOG(3,(THIS_FILE, "Duration (%d seconds) has been exceeded " |
| 7657 | "for call %d, disconnecting the call", |
| 7658 | duration, call_id)); |
| 7659 | entry->id = PJSUA_INVALID_ID; |
| 7660 | pjsua_call_hangup(call_id, 200, NULL, &msg_data); |
| 7661 | } |
| 7662 | |
| 7663 | /*static PyObject *py_pjsua_call_timeout_callback |
| 7664 | (PyObject *pSelf, PyObject *pArgs) |
| 7665 | { |
| 7666 | |
| 7667 | if (!PyArg_ParseTuple(pArgs, "")) |
| 7668 | { |
| 7669 | return NULL; |
| 7670 | } |
| 7671 | |
| 7672 | call_timeout_callback(); |
| 7673 | |
| 7674 | Py_INCREF(Py_None); |
| 7675 | return Py_None; |
| 7676 | }*/ |
| 7677 | |
| 7678 | static void on_call_state_1() { |
| 7679 | /* if app_config.call_data[call_id].timer.id != PJSUA_INVALID_ID) { |
| 7680 | struct call_data *cd = &app_config.call_data[call_id]; |
| 7681 | pjsip_endpoint *endpt = pjsua_get_pjsip_endpt(); |
| 7682 | |
| 7683 | cd->timer.id = PJSUA_INVALID_ID; |
| 7684 | pjsip_endpt_cancel_timer(endpt, &cd->timer); |
| 7685 | } |
| 7686 | |
| 7687 | PJ_LOG(3,(THIS_FILE, "Call %d is DISCONNECTED [reason=%d (%s)]", |
| 7688 | call_id, |
| 7689 | call_info.last_status, |
| 7690 | call_info.last_status_text.ptr));*/ |
| 7691 | } |
| 7692 | |
| 7693 | /* END OF Testing section */ |
| 7694 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 7695 | /* |
| 7696 | * Map of function names to functions |
| 7697 | */ |
| 7698 | static PyMethodDef py_pjsua_methods[] = |
| 7699 | { |
| 7700 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7701 | "thread_register", py_pjsua_thread_register, METH_VARARGS, |
| 7702 | pjsua_thread_register_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7703 | }, |
| 7704 | { |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 7705 | "perror", py_pjsua_perror, METH_VARARGS, pjsua_perror_doc |
| 7706 | }, |
| 7707 | { |
| 7708 | "create", py_pjsua_create, METH_VARARGS, pjsua_create_doc |
| 7709 | }, |
| 7710 | { |
| 7711 | "init", py_pjsua_init, METH_VARARGS, pjsua_init_doc |
| 7712 | }, |
| 7713 | { |
| 7714 | "start", py_pjsua_start, METH_VARARGS, pjsua_start_doc |
| 7715 | }, |
| 7716 | { |
| 7717 | "destroy", py_pjsua_destroy, METH_VARARGS, pjsua_destroy_doc |
| 7718 | }, |
| 7719 | { |
| 7720 | "handle_events", py_pjsua_handle_events, METH_VARARGS, |
| 7721 | pjsua_handle_events_doc |
| 7722 | }, |
| 7723 | { |
| 7724 | "verify_sip_url", py_pjsua_verify_sip_url, METH_VARARGS, |
| 7725 | pjsua_verify_sip_url_doc |
| 7726 | }, |
| 7727 | { |
| 7728 | "pool_create", py_pjsua_pool_create, METH_VARARGS, |
| 7729 | pjsua_pool_create_doc |
| 7730 | }, |
| 7731 | { |
| 7732 | "get_pjsip_endpt", py_pjsua_get_pjsip_endpt, METH_VARARGS, |
| 7733 | pjsua_get_pjsip_endpt_doc |
| 7734 | }, |
| 7735 | { |
| 7736 | "get_pjmedia_endpt", py_pjsua_get_pjmedia_endpt, METH_VARARGS, |
| 7737 | pjsua_get_pjmedia_endpt_doc |
| 7738 | }, |
| 7739 | { |
| 7740 | "get_pool_factory", py_pjsua_get_pool_factory, METH_VARARGS, |
| 7741 | pjsua_get_pool_factory_doc |
| 7742 | }, |
| 7743 | { |
| 7744 | "reconfigure_logging", py_pjsua_reconfigure_logging, METH_VARARGS, |
| 7745 | pjsua_reconfigure_logging_doc |
| 7746 | }, |
| 7747 | { |
| 7748 | "logging_config_default", py_pjsua_logging_config_default, |
| 7749 | METH_VARARGS, pjsua_logging_config_default_doc |
| 7750 | }, |
| 7751 | { |
| 7752 | "config_default", py_pjsua_config_default, METH_VARARGS, |
| 7753 | pjsua_config_default_doc |
| 7754 | }, |
| 7755 | { |
| 7756 | "media_config_default", py_pjsua_media_config_default, METH_VARARGS, |
| 7757 | pjsua_media_config_default_doc |
| 7758 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7759 | |
| 7760 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 7761 | { |
| 7762 | "msg_data_init", py_pjsua_msg_data_init, METH_VARARGS, |
| 7763 | pjsua_msg_data_init_doc |
| 7764 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7765 | { |
| 7766 | "stun_config_default", py_pjsua_stun_config_default, METH_VARARGS, |
| 7767 | pjsua_stun_config_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7768 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7769 | { |
| 7770 | "transport_config_default", py_pjsua_transport_config_default, |
| 7771 | METH_VARARGS,pjsua_transport_config_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7772 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7773 | { |
| 7774 | "normalize_stun_config", py_pjsua_normalize_stun_config, METH_VARARGS, |
| 7775 | pjsua_normalize_stun_config_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7776 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7777 | |
| 7778 | { |
| 7779 | "transport_create", py_pjsua_transport_create, METH_VARARGS, |
| 7780 | pjsua_transport_create_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7781 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7782 | { |
| 7783 | "transport_register", py_pjsua_transport_register, METH_VARARGS, |
| 7784 | pjsua_transport_register_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7785 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7786 | { |
| 7787 | "transport_enum_transports", py_pjsua_enum_transports, METH_VARARGS, |
| 7788 | pjsua_enum_transports_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7789 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7790 | { |
| 7791 | "transport_get_info", py_pjsua_transport_get_info, METH_VARARGS, |
| 7792 | pjsua_transport_get_info_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7793 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7794 | { |
| 7795 | "transport_set_enable", py_pjsua_transport_set_enable, METH_VARARGS, |
| 7796 | pjsua_transport_set_enable_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7797 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7798 | { |
| 7799 | "transport_close", py_pjsua_transport_close, METH_VARARGS, |
| 7800 | pjsua_transport_close_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7801 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7802 | { |
| 7803 | "acc_config_default", py_pjsua_acc_config_default, METH_VARARGS, |
| 7804 | pjsua_acc_config_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7805 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7806 | { |
| 7807 | "acc_get_count", py_pjsua_acc_get_count, METH_VARARGS, |
| 7808 | pjsua_acc_get_count_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7809 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7810 | { |
| 7811 | "acc_is_valid", py_pjsua_acc_is_valid, METH_VARARGS, |
| 7812 | pjsua_acc_is_valid_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7813 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7814 | { |
| 7815 | "acc_set_default", py_pjsua_acc_set_default, METH_VARARGS, |
| 7816 | pjsua_acc_set_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7817 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7818 | { |
| 7819 | "acc_get_default", py_pjsua_acc_get_default, METH_VARARGS, |
| 7820 | pjsua_acc_get_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7821 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7822 | { |
| 7823 | "acc_add", py_pjsua_acc_add, METH_VARARGS, |
| 7824 | pjsua_acc_add_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7825 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7826 | { |
| 7827 | "acc_add_local", py_pjsua_acc_add_local, METH_VARARGS, |
| 7828 | pjsua_acc_add_local_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7829 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7830 | { |
| 7831 | "acc_del", py_pjsua_acc_del, METH_VARARGS, |
| 7832 | pjsua_acc_del_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7833 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7834 | { |
| 7835 | "acc_modify", py_pjsua_acc_modify, METH_VARARGS, |
| 7836 | pjsua_acc_modify_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7837 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7838 | { |
| 7839 | "acc_set_online_status", py_pjsua_acc_set_online_status, METH_VARARGS, |
| 7840 | pjsua_acc_set_online_status_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7841 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7842 | { |
| 7843 | "acc_set_registration", py_pjsua_acc_set_registration, METH_VARARGS, |
| 7844 | pjsua_acc_set_registration_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7845 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7846 | { |
| 7847 | "acc_get_info", py_pjsua_acc_get_info, METH_VARARGS, |
| 7848 | pjsua_acc_get_info_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7849 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7850 | { |
| 7851 | "enum_accs", py_pjsua_enum_accs, METH_VARARGS, |
| 7852 | pjsua_enum_accs_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7853 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7854 | { |
| 7855 | "acc_enum_info", py_pjsua_acc_enum_info, METH_VARARGS, |
| 7856 | pjsua_acc_enum_info_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7857 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7858 | { |
| 7859 | "acc_find_for_outgoing", py_pjsua_acc_find_for_outgoing, METH_VARARGS, |
| 7860 | pjsua_acc_find_for_outgoing_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7861 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7862 | { |
| 7863 | "acc_find_for_incoming", py_pjsua_acc_find_for_incoming, METH_VARARGS, |
| 7864 | pjsua_acc_find_for_incoming_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7865 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7866 | { |
| 7867 | "acc_create_uac_contact", py_pjsua_acc_create_uac_contact, METH_VARARGS, |
| 7868 | pjsua_acc_create_uac_contact_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7869 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7870 | { |
| 7871 | "acc_create_uas_contact", py_pjsua_acc_create_uas_contact, METH_VARARGS, |
| 7872 | pjsua_acc_create_uas_contact_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7873 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7874 | { |
| 7875 | "get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS, |
| 7876 | pjsua_get_buddy_count_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 7877 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 7878 | { |
| 7879 | "buddy_is_valid", py_pjsua_buddy_is_valid, METH_VARARGS, |
| 7880 | pjsua_buddy_is_valid_doc |
| 7881 | }, |
| 7882 | { |
| 7883 | "enum_buddies", py_pjsua_enum_buddies, METH_VARARGS, |
| 7884 | pjsua_enum_buddies_doc |
| 7885 | }, |
| 7886 | { |
| 7887 | "buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS, |
| 7888 | pjsua_buddy_get_info_doc |
| 7889 | }, |
| 7890 | { |
| 7891 | "buddy_add", py_pjsua_buddy_add, METH_VARARGS, |
| 7892 | pjsua_buddy_add_doc |
| 7893 | }, |
| 7894 | { |
| 7895 | "buddy_del", py_pjsua_buddy_del, METH_VARARGS, |
| 7896 | pjsua_buddy_del_doc |
| 7897 | }, |
| 7898 | { |
| 7899 | "buddy_subscribe_pres", py_pjsua_buddy_subscribe_pres, METH_VARARGS, |
| 7900 | pjsua_buddy_subscribe_pres_doc |
| 7901 | }, |
| 7902 | { |
| 7903 | "pres_dump", py_pjsua_pres_dump, METH_VARARGS, |
| 7904 | pjsua_pres_dump_doc |
| 7905 | }, |
| 7906 | { |
| 7907 | "im_send", py_pjsua_im_send, METH_VARARGS, |
| 7908 | pjsua_im_send_doc |
| 7909 | }, |
| 7910 | { |
| 7911 | "im_typing", py_pjsua_im_typing, METH_VARARGS, |
| 7912 | pjsua_im_typing_doc |
| 7913 | }, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 7914 | { |
| 7915 | "conf_get_max_ports", py_pjsua_conf_get_max_ports, METH_VARARGS, |
| 7916 | pjsua_conf_get_max_ports_doc |
| 7917 | }, |
| 7918 | { |
| 7919 | "conf_get_active_ports", py_pjsua_conf_get_active_ports, METH_VARARGS, |
| 7920 | pjsua_conf_get_active_ports_doc |
| 7921 | }, |
| 7922 | { |
| 7923 | "enum_conf_ports", py_pjsua_enum_conf_ports, METH_VARARGS, |
| 7924 | pjsua_enum_conf_ports_doc |
| 7925 | }, |
| 7926 | { |
| 7927 | "conf_get_port_info", py_pjsua_conf_get_port_info, METH_VARARGS, |
| 7928 | pjsua_conf_get_port_info_doc |
| 7929 | }, |
| 7930 | { |
| 7931 | "conf_add_port", py_pjsua_conf_add_port, METH_VARARGS, |
| 7932 | pjsua_conf_add_port_doc |
| 7933 | }, |
| 7934 | { |
| 7935 | "conf_remove_port", py_pjsua_conf_remove_port, METH_VARARGS, |
| 7936 | pjsua_conf_remove_port_doc |
| 7937 | }, |
| 7938 | { |
| 7939 | "conf_connect", py_pjsua_conf_connect, METH_VARARGS, |
| 7940 | pjsua_conf_connect_doc |
| 7941 | }, |
| 7942 | { |
| 7943 | "conf_disconnect", py_pjsua_conf_disconnect, METH_VARARGS, |
| 7944 | pjsua_conf_disconnect_doc |
| 7945 | }, |
| 7946 | { |
| 7947 | "player_create", py_pjsua_player_create, METH_VARARGS, |
| 7948 | pjsua_player_create_doc |
| 7949 | }, |
| 7950 | { |
| 7951 | "player_get_conf_port", py_pjsua_player_get_conf_port, METH_VARARGS, |
| 7952 | pjsua_player_get_conf_port_doc |
| 7953 | }, |
| 7954 | { |
| 7955 | "player_set_pos", py_pjsua_player_set_pos, METH_VARARGS, |
| 7956 | pjsua_player_set_pos_doc |
| 7957 | }, |
| 7958 | { |
| 7959 | "player_destroy", py_pjsua_player_destroy, METH_VARARGS, |
| 7960 | pjsua_player_destroy_doc |
| 7961 | }, |
| 7962 | { |
| 7963 | "recorder_create", py_pjsua_recorder_create, METH_VARARGS, |
| 7964 | pjsua_recorder_create_doc |
| 7965 | }, |
| 7966 | { |
| 7967 | "recorder_get_conf_port", py_pjsua_recorder_get_conf_port, METH_VARARGS, |
| 7968 | pjsua_recorder_get_conf_port_doc |
| 7969 | }, |
| 7970 | { |
| 7971 | "recorder_destroy", py_pjsua_recorder_destroy, METH_VARARGS, |
| 7972 | pjsua_recorder_destroy_doc |
| 7973 | }, |
| 7974 | { |
| 7975 | "enum_snd_devs", py_pjsua_enum_snd_devs, METH_VARARGS, |
| 7976 | pjsua_enum_snd_devs_doc |
| 7977 | }, |
| 7978 | /*{ |
| 7979 | "get_snd_dev", py_pjsua_get_snd_dev, METH_VARARGS, |
| 7980 | pjsua_get_snd_dev_doc |
| 7981 | },*/ |
| 7982 | { |
| 7983 | "set_snd_dev", py_pjsua_set_snd_dev, METH_VARARGS, |
| 7984 | pjsua_set_snd_dev_doc |
| 7985 | }, |
| 7986 | { |
| 7987 | "set_null_snd_dev", py_pjsua_set_null_snd_dev, METH_VARARGS, |
| 7988 | pjsua_set_null_snd_dev_doc |
| 7989 | }, |
| 7990 | { |
| 7991 | "set_no_snd_dev", py_pjsua_set_no_snd_dev, METH_VARARGS, |
| 7992 | pjsua_set_no_snd_dev_doc |
| 7993 | }, |
| 7994 | { |
| 7995 | "set_ec", py_pjsua_set_ec, METH_VARARGS, |
| 7996 | pjsua_set_ec_doc |
| 7997 | }, |
| 7998 | { |
| 7999 | "get_ec_tail", py_pjsua_get_ec_tail, METH_VARARGS, |
| 8000 | pjsua_get_ec_tail_doc |
| 8001 | }, |
| 8002 | { |
| 8003 | "enum_codecs", py_pjsua_enum_codecs, METH_VARARGS, |
| 8004 | pjsua_enum_codecs_doc |
| 8005 | }, |
| 8006 | { |
| 8007 | "codec_set_priority", py_pjsua_codec_set_priority, METH_VARARGS, |
| 8008 | pjsua_codec_set_priority_doc |
| 8009 | }, |
| 8010 | { |
| 8011 | "codec_get_param", py_pjsua_codec_get_param, METH_VARARGS, |
| 8012 | pjsua_codec_get_param_doc |
| 8013 | }, |
| 8014 | { |
| 8015 | "codec_set_param", py_pjsua_codec_set_param, METH_VARARGS, |
| 8016 | pjsua_codec_set_param_doc |
| 8017 | }, |
| 8018 | { |
| 8019 | "call_get_max_count", py_pjsua_call_get_max_count, METH_VARARGS, |
| 8020 | pjsua_call_get_max_count_doc |
| 8021 | }, |
| 8022 | { |
| 8023 | "call_get_count", py_pjsua_call_get_count, METH_VARARGS, |
| 8024 | pjsua_call_get_count_doc |
| 8025 | }, |
| 8026 | { |
| 8027 | "enum_calls", py_pjsua_enum_calls, METH_VARARGS, |
| 8028 | pjsua_enum_calls_doc |
| 8029 | }, |
| 8030 | { |
| 8031 | "call_make_call", py_pjsua_call_make_call, METH_VARARGS, |
| 8032 | pjsua_call_make_call_doc |
| 8033 | }, |
| 8034 | { |
| 8035 | "call_is_active", py_pjsua_call_is_active, METH_VARARGS, |
| 8036 | pjsua_call_is_active_doc |
| 8037 | }, |
| 8038 | { |
| 8039 | "call_has_media", py_pjsua_call_has_media, METH_VARARGS, |
| 8040 | pjsua_call_has_media_doc |
| 8041 | }, |
| 8042 | { |
| 8043 | "call_get_conf_port", py_pjsua_call_get_conf_port, METH_VARARGS, |
| 8044 | pjsua_call_get_conf_port_doc |
| 8045 | }, |
| 8046 | { |
| 8047 | "call_get_info", py_pjsua_call_get_info, METH_VARARGS, |
| 8048 | pjsua_call_get_info_doc |
| 8049 | }, |
| 8050 | { |
| 8051 | "call_set_user_data", py_pjsua_call_set_user_data, METH_VARARGS, |
| 8052 | pjsua_call_set_user_data_doc |
| 8053 | }, |
| 8054 | { |
| 8055 | "call_get_user_data", py_pjsua_call_get_user_data, METH_VARARGS, |
| 8056 | pjsua_call_get_user_data_doc |
| 8057 | }, |
| 8058 | { |
| 8059 | "call_answer", py_pjsua_call_answer, METH_VARARGS, |
| 8060 | pjsua_call_answer_doc |
| 8061 | }, |
| 8062 | { |
| 8063 | "call_hangup", py_pjsua_call_hangup, METH_VARARGS, |
| 8064 | pjsua_call_hangup_doc |
| 8065 | }, |
| 8066 | { |
| 8067 | "call_set_hold", py_pjsua_call_set_hold, METH_VARARGS, |
| 8068 | pjsua_call_set_hold_doc |
| 8069 | }, |
| 8070 | { |
| 8071 | "call_reinvite", py_pjsua_call_reinvite, METH_VARARGS, |
| 8072 | pjsua_call_reinvite_doc |
| 8073 | }, |
| 8074 | { |
| 8075 | "call_xfer", py_pjsua_call_xfer, METH_VARARGS, |
| 8076 | pjsua_call_xfer_doc |
| 8077 | }, |
| 8078 | { |
| 8079 | "call_xfer_replaces", py_pjsua_call_xfer_replaces, METH_VARARGS, |
| 8080 | pjsua_call_xfer_replaces_doc |
| 8081 | }, |
| 8082 | { |
| 8083 | "call_dial_dtmf", py_pjsua_call_dial_dtmf, METH_VARARGS, |
| 8084 | pjsua_call_dial_dtmf_doc |
| 8085 | }, |
| 8086 | { |
| 8087 | "call_send_im", py_pjsua_call_send_im, METH_VARARGS, |
| 8088 | pjsua_call_send_im_doc |
| 8089 | }, |
| 8090 | { |
| 8091 | "call_send_typing_ind", py_pjsua_call_send_typing_ind, METH_VARARGS, |
| 8092 | pjsua_call_send_typing_ind_doc |
| 8093 | }, |
| 8094 | { |
| 8095 | "call_hangup_all", py_pjsua_call_hangup_all, METH_VARARGS, |
| 8096 | pjsua_call_hangup_all_doc |
| 8097 | }, |
| 8098 | { |
| 8099 | "call_dump", py_pjsua_call_dump, METH_VARARGS, |
| 8100 | pjsua_call_dump_doc |
| 8101 | }, |
| 8102 | |
| 8103 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8104 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 8105 | {NULL, NULL} /* end of function list */ |
| 8106 | }; |
| 8107 | |
| 8108 | |
| 8109 | |
| 8110 | /* |
| 8111 | * Mapping C structs from and to Python objects & initializing object |
| 8112 | */ |
| 8113 | DL_EXPORT(void) |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 8114 | initpy_pjsua(void) |
| 8115 | { |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 8116 | PyObject* m = NULL; |
| 8117 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8118 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 8119 | if (PyType_Ready(&callback_Type) < 0) |
| 8120 | return; |
| 8121 | if (PyType_Ready(&config_Type) < 0) |
| 8122 | return; |
| 8123 | if (PyType_Ready(&logging_config_Type) < 0) |
| 8124 | return; |
| 8125 | if (PyType_Ready(&msg_data_Type) < 0) |
| 8126 | return; |
| 8127 | media_config_Type.tp_new = PyType_GenericNew; |
| 8128 | if (PyType_Ready(&media_config_Type) < 0) |
| 8129 | return; |
| 8130 | pjsip_event_Type.tp_new = PyType_GenericNew; |
| 8131 | if (PyType_Ready(&pjsip_event_Type) < 0) |
| 8132 | return; |
| 8133 | pjsip_rx_data_Type.tp_new = PyType_GenericNew; |
| 8134 | if (PyType_Ready(&pjsip_rx_data_Type) < 0) |
| 8135 | return; |
| 8136 | pj_pool_Type.tp_new = PyType_GenericNew; |
| 8137 | if (PyType_Ready(&pj_pool_Type) < 0) |
| 8138 | return; |
| 8139 | pjsip_endpoint_Type.tp_new = PyType_GenericNew; |
| 8140 | if (PyType_Ready(&pjsip_endpoint_Type) < 0) |
| 8141 | return; |
| 8142 | pjmedia_endpt_Type.tp_new = PyType_GenericNew; |
| 8143 | if (PyType_Ready(&pjmedia_endpt_Type) < 0) |
| 8144 | return; |
| 8145 | pj_pool_factory_Type.tp_new = PyType_GenericNew; |
| 8146 | if (PyType_Ready(&pj_pool_factory_Type) < 0) |
| 8147 | return; |
| 8148 | pjsip_cred_info_Type.tp_new = PyType_GenericNew; |
| 8149 | if (PyType_Ready(&pjsip_cred_info_Type) < 0) |
| 8150 | return; |
| 8151 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8152 | /* LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8153 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8154 | if (PyType_Ready(&stun_config_Type) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8155 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8156 | if (PyType_Ready(&transport_config_Type) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8157 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8158 | if (PyType_Ready(&sockaddr_Type) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8159 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8160 | if (PyType_Ready(&host_port_Type) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8161 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8162 | |
| 8163 | if (PyType_Ready(&transport_info_Type) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8164 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8165 | |
| 8166 | pjsip_transport_Type.tp_new = PyType_GenericNew; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8167 | if (PyType_Ready(&pjsip_transport_Type) < 0) |
| 8168 | return; |
| 8169 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8170 | /* END OF LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8171 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8172 | /* LIB ACCOUNT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8173 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8174 | |
| 8175 | if (PyType_Ready(&acc_config_Type) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8176 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8177 | if (PyType_Ready(&acc_info_Type) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8178 | return; |
| 8179 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8180 | /* END OF LIB ACCOUNT */ |
| 8181 | |
| 8182 | /* LIB BUDDY */ |
| 8183 | |
| 8184 | if (PyType_Ready(&buddy_config_Type) < 0) |
| 8185 | return; |
| 8186 | if (PyType_Ready(&buddy_info_Type) < 0) |
| 8187 | return; |
| 8188 | |
| 8189 | /* END OF LIB BUDDY */ |
| 8190 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 8191 | /* LIB MEDIA */ |
| 8192 | |
| 8193 | if (PyType_Ready(&codec_info_Type) < 0) |
| 8194 | return; |
| 8195 | |
| 8196 | if (PyType_Ready(&conf_port_info_Type) < 0) |
| 8197 | return; |
| 8198 | |
| 8199 | pjmedia_port_Type.tp_new = PyType_GenericNew; |
| 8200 | if (PyType_Ready(&pjmedia_port_Type) < 0) |
| 8201 | return; |
| 8202 | |
| 8203 | if (PyType_Ready(&pjmedia_snd_dev_info_Type) < 0) |
| 8204 | return; |
| 8205 | |
| 8206 | pjmedia_codec_param_info_Type.tp_new = PyType_GenericNew; |
| 8207 | if (PyType_Ready(&pjmedia_codec_param_info_Type) < 0) |
| 8208 | return; |
| 8209 | pjmedia_codec_param_setting_Type.tp_new = PyType_GenericNew; |
| 8210 | if (PyType_Ready(&pjmedia_codec_param_setting_Type) < 0) |
| 8211 | return; |
| 8212 | |
| 8213 | if (PyType_Ready(&pjmedia_codec_param_Type) < 0) |
| 8214 | return; |
| 8215 | |
| 8216 | /* END OF LIB MEDIA */ |
| 8217 | |
| 8218 | /* LIB CALL */ |
| 8219 | |
| 8220 | pj_time_val_Type.tp_new = PyType_GenericNew; |
| 8221 | if (PyType_Ready(&pj_time_val_Type) < 0) |
| 8222 | return; |
| 8223 | |
| 8224 | if (PyType_Ready(&call_info_Type) < 0) |
| 8225 | return; |
| 8226 | |
| 8227 | /* END OF LIB CALL */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8228 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 8229 | m = Py_InitModule3( |
| 8230 | "py_pjsua", py_pjsua_methods,"PJSUA-lib module for python" |
| 8231 | ); |
| 8232 | |
| 8233 | Py_INCREF(&callback_Type); |
| 8234 | PyModule_AddObject(m, "Callback", (PyObject *)&callback_Type); |
| 8235 | |
| 8236 | Py_INCREF(&config_Type); |
| 8237 | PyModule_AddObject(m, "Config", (PyObject *)&config_Type); |
| 8238 | |
| 8239 | Py_INCREF(&media_config_Type); |
| 8240 | PyModule_AddObject(m, "Media_Config", (PyObject *)&media_config_Type); |
| 8241 | |
| 8242 | Py_INCREF(&logging_config_Type); |
| 8243 | PyModule_AddObject(m, "Logging_Config", (PyObject *)&logging_config_Type); |
| 8244 | |
| 8245 | Py_INCREF(&msg_data_Type); |
| 8246 | PyModule_AddObject(m, "Msg_Data", (PyObject *)&msg_data_Type); |
| 8247 | |
| 8248 | Py_INCREF(&pjsip_event_Type); |
| 8249 | PyModule_AddObject(m, "PJSIP_Event", (PyObject *)&pjsip_event_Type); |
| 8250 | |
| 8251 | Py_INCREF(&pjsip_rx_data_Type); |
| 8252 | PyModule_AddObject(m, "PJSIP_RX_Data", (PyObject *)&pjsip_rx_data_Type); |
| 8253 | |
| 8254 | Py_INCREF(&pj_pool_Type); |
| 8255 | PyModule_AddObject(m, "PJ_Pool", (PyObject *)&pj_pool_Type); |
| 8256 | |
| 8257 | Py_INCREF(&pjsip_endpoint_Type); |
| 8258 | PyModule_AddObject(m, "PJSIP_Endpoint", (PyObject *)&pjsip_endpoint_Type); |
| 8259 | |
| 8260 | Py_INCREF(&pjmedia_endpt_Type); |
| 8261 | PyModule_AddObject(m, "PJMedia_Endpt", (PyObject *)&pjmedia_endpt_Type); |
| 8262 | |
| 8263 | Py_INCREF(&pj_pool_factory_Type); |
| 8264 | PyModule_AddObject( |
| 8265 | m, "PJ_Pool_Factory", (PyObject *)&pj_pool_factory_Type |
| 8266 | ); |
| 8267 | |
| 8268 | Py_INCREF(&pjsip_cred_info_Type); |
| 8269 | PyModule_AddObject(m, "PJSIP_Cred_Info", |
| 8270 | (PyObject *)&pjsip_cred_info_Type |
| 8271 | ); |
| 8272 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8273 | /* LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8274 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8275 | Py_INCREF(&stun_config_Type); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8276 | PyModule_AddObject(m, "STUN_Config", (PyObject *)&stun_config_Type); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8277 | Py_INCREF(&transport_config_Type); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8278 | PyModule_AddObject |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8279 | (m, "Transport_Config", (PyObject *)&transport_config_Type); |
| 8280 | Py_INCREF(&sockaddr_Type); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8281 | PyModule_AddObject(m, "Sockaddr", (PyObject *)&sockaddr_Type); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8282 | Py_INCREF(&host_port_Type); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8283 | PyModule_AddObject(m, "Host_Port", (PyObject *)&host_port_Type); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8284 | |
| 8285 | Py_INCREF(&transport_info_Type); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8286 | PyModule_AddObject(m, "Transport_Info", (PyObject *)&transport_info_Type); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8287 | |
| 8288 | Py_INCREF(&pjsip_transport_Type); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8289 | PyModule_AddObject(m, "PJSIP_Transport", (PyObject *)&pjsip_transport_Type); |
| 8290 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8291 | /* END OF LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8292 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8293 | /* LIB ACCOUNT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8294 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8295 | |
| 8296 | Py_INCREF(&acc_config_Type); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8297 | PyModule_AddObject(m, "Acc_Config", (PyObject *)&acc_config_Type); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8298 | Py_INCREF(&acc_info_Type); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8299 | PyModule_AddObject(m, "Acc_Info", (PyObject *)&acc_info_Type); |
| 8300 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8301 | /* END OF LIB ACCOUNT */ |
| 8302 | |
| 8303 | /* LIB BUDDY */ |
| 8304 | |
| 8305 | Py_INCREF(&buddy_config_Type); |
| 8306 | PyModule_AddObject(m, "Buddy_Config", (PyObject *)&buddy_config_Type); |
| 8307 | Py_INCREF(&buddy_info_Type); |
| 8308 | PyModule_AddObject(m, "Buddy_Info", (PyObject *)&buddy_info_Type); |
| 8309 | |
| 8310 | /* END OF LIB BUDDY */ |
| 8311 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 8312 | /* LIB MEDIA */ |
| 8313 | |
| 8314 | Py_INCREF(&codec_info_Type); |
| 8315 | PyModule_AddObject(m, "Codec_Info", (PyObject *)&codec_info_Type); |
| 8316 | Py_INCREF(&conf_port_info_Type); |
| 8317 | PyModule_AddObject(m, "Conf_Port_Info", (PyObject *)&conf_port_info_Type); |
| 8318 | Py_INCREF(&pjmedia_port_Type); |
| 8319 | PyModule_AddObject(m, "PJMedia_Port", (PyObject *)&pjmedia_port_Type); |
| 8320 | Py_INCREF(&pjmedia_snd_dev_info_Type); |
| 8321 | PyModule_AddObject(m, "PJMedia_Snd_Dev_Info", |
| 8322 | (PyObject *)&pjmedia_snd_dev_info_Type); |
| 8323 | Py_INCREF(&pjmedia_codec_param_info_Type); |
| 8324 | PyModule_AddObject(m, "PJMedia_Codec_Param_Info", |
| 8325 | (PyObject *)&pjmedia_codec_param_info_Type); |
| 8326 | Py_INCREF(&pjmedia_codec_param_setting_Type); |
| 8327 | PyModule_AddObject(m, "PJMedia_Codec_Param_Setting", |
| 8328 | (PyObject *)&pjmedia_codec_param_setting_Type); |
| 8329 | Py_INCREF(&pjmedia_codec_param_Type); |
| 8330 | PyModule_AddObject(m, "PJMedia_Codec_Param", |
| 8331 | (PyObject *)&pjmedia_codec_param_Type); |
| 8332 | |
| 8333 | /* END OF LIB MEDIA */ |
| 8334 | |
| 8335 | /* LIB CALL */ |
| 8336 | |
| 8337 | Py_INCREF(&pj_time_val_Type); |
| 8338 | PyModule_AddObject(m, "PJ_Time_Val", (PyObject *)&pj_time_val_Type); |
| 8339 | |
| 8340 | Py_INCREF(&call_info_Type); |
| 8341 | PyModule_AddObject(m, "Call_Info", (PyObject *)&call_info_Type); |
| 8342 | |
| 8343 | /* END OF LIB CALL */ |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 8344 | |
| 8345 | #ifdef PJSUA_INVALID_ID |
| 8346 | /* |
| 8347 | * Constant to identify invalid ID for all sorts of IDs. |
| 8348 | */ |
| 8349 | PyModule_AddIntConstant(m, "PJSUA_INVALID_ID", PJSUA_INVALID_ID); |
| 8350 | #endif |
| 8351 | |
| 8352 | #ifdef PJSUA_ACC_MAX_PROXIES |
| 8353 | /* |
| 8354 | * Maximum proxies in account. |
| 8355 | */ |
| 8356 | PyModule_AddIntConstant( |
| 8357 | m, "PJSUA_ACC_MAX_PROXIES ", PJSUA_ACC_MAX_PROXIES |
| 8358 | ); |
| 8359 | #endif |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 8360 | |
| 8361 | #ifdef PJSUA_MAX_ACC |
| 8362 | /* |
| 8363 | * Maximum account. |
| 8364 | */ |
| 8365 | PyModule_AddIntConstant( |
| 8366 | m, "PJSUA_MAX_ACC", PJSUA_MAX_ACC |
| 8367 | ); |
| 8368 | #endif |
| 8369 | |
| 8370 | #ifdef PJSUA_REG_INTERVAL |
| 8371 | /* |
| 8372 | * Default registration interval.. |
| 8373 | */ |
| 8374 | PyModule_AddIntConstant( |
| 8375 | m, "PJSUA_REG_INTERVAL", PJSUA_REG_INTERVAL |
| 8376 | ); |
| 8377 | #endif |
| 8378 | |
| 8379 | #ifdef PJSUA_PUBLISH_EXPIRATION |
| 8380 | /* |
| 8381 | * Default PUBLISH expiration |
| 8382 | */ |
| 8383 | PyModule_AddIntConstant( |
| 8384 | m, "PJSUA_PUBLISH_EXPIRATION", PJSUA_PUBLISH_EXPIRATION |
| 8385 | ); |
| 8386 | #endif |
| 8387 | |
| 8388 | #ifdef PJSUA_DEFAULT_ACC_PRIORITY |
| 8389 | /* |
| 8390 | * Default account priority. |
| 8391 | */ |
| 8392 | PyModule_AddIntConstant( |
| 8393 | m, "PJSUA_DEFAULT_ACC_PRIORITY", PJSUA_DEFAULT_ACC_PRIORITY |
| 8394 | ); |
| 8395 | #endif |
| 8396 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8397 | #ifdef PJSUA_MAX_BUDDIES |
| 8398 | /* |
| 8399 | * Default account priority. |
| 8400 | */ |
| 8401 | PyModule_AddIntConstant( |
| 8402 | m, "PJSUA_MAX_BUDDIES", PJSUA_MAX_BUDDIES |
| 8403 | ); |
| 8404 | #endif |
| 8405 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 8406 | #ifdef PJSUA_MAX_CONF_PORTS |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8407 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 8408 | /* |
| 8409 | * Max ports in the conference bridge. |
| 8410 | */ |
| 8411 | PyModule_AddIntConstant( |
| 8412 | m, "PJSUA_MAX_CONF_PORTS", PJSUA_MAX_CONF_PORTS |
| 8413 | ); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8414 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 8415 | #endif |
| 8416 | |
| 8417 | #ifdef PJSUA_DEFAULT_CLOCK_RATE |
| 8418 | |
| 8419 | PyModule_AddIntConstant( |
| 8420 | m, "PJSUA_DEFAULT_CLOCK_RATE", PJSUA_DEFAULT_CLOCK_RATE |
| 8421 | ); |
| 8422 | |
| 8423 | #endif |
| 8424 | |
| 8425 | #ifdef PJSUA_DEFAULT_CODEC_QUALITY |
| 8426 | |
| 8427 | PyModule_AddIntConstant( |
| 8428 | m, "PJSUA_DEFAULT_CODEC_QUALITY", PJSUA_DEFAULT_CODEC_QUALITY |
| 8429 | ); |
| 8430 | |
| 8431 | #endif |
| 8432 | |
| 8433 | #ifdef PJSUA_DEFAULT_ILBC_MODE |
| 8434 | |
| 8435 | PyModule_AddIntConstant( |
| 8436 | m, "PJSUA_DEFAULT_ILBC_MODE", PJSUA_DEFAULT_ILBC_MODE |
| 8437 | ); |
| 8438 | |
| 8439 | #endif |
| 8440 | |
| 8441 | #ifdef PJSUA_DEFAULT_EC_TAIL_LEN |
| 8442 | |
| 8443 | PyModule_AddIntConstant( |
| 8444 | m, "PJSUA_DEFAULT_EC_TAIL_LEN", PJSUA_DEFAULT_EC_TAIL_LEN |
| 8445 | ); |
| 8446 | |
| 8447 | #endif |
| 8448 | |
| 8449 | #ifdef PJSUA_MAX_CALLS |
| 8450 | |
| 8451 | PyModule_AddIntConstant( |
| 8452 | m, "PJSUA_MAX_CALLS", PJSUA_MAX_CALLS |
| 8453 | ); |
| 8454 | |
| 8455 | #endif |
| 8456 | |
| 8457 | #ifdef PJSUA_XFER_NO_REQUIRE_REPLACES |
| 8458 | |
| 8459 | PyModule_AddIntConstant( |
| 8460 | m, "PJSUA_XFER_NO_REQUIRE_REPLACES", PJSUA_XFER_NO_REQUIRE_REPLACES |
| 8461 | ); |
| 8462 | #endif |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 8463 | |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 8464 | } |