Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 3 | * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org> |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 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 | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 19 | #include "py_pjsua.h" |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 20 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 21 | #define THIS_FILE "main.c" |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 22 | #define POOL_SIZE 4000 |
| 23 | #define SND_DEV_NUM 64 |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 24 | #define SND_NAME_LEN 64 |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 25 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 26 | /* LIB BASE */ |
| 27 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 28 | static PyObject* obj_log_cb; |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 29 | static long thread_id; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 30 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 31 | #define ENTER_PYTHON() PyGILState_STATE state = PyGILState_Ensure() |
| 32 | #define LEAVE_PYTHON() PyGILState_Release(state) |
| 33 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 34 | /* |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 35 | * cb_log_cb |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 36 | * declares method for reconfiguring logging process for callback struct |
| 37 | */ |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 38 | static void cb_log_cb(int level, const char *data, pj_size_t len) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 39 | { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 40 | |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 41 | /* Ignore if this callback is called from alien thread context, |
| 42 | * or otherwise it will crash Python. |
| 43 | */ |
| 44 | if (pj_thread_local_get(thread_id) == 0) |
| 45 | return; |
| 46 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 47 | if (PyCallable_Check(obj_log_cb)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 48 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 49 | ENTER_PYTHON(); |
| 50 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 51 | PyObject_CallFunctionObjArgs( |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 52 | obj_log_cb, Py_BuildValue("i",level), |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 53 | PyString_FromString(data), Py_BuildValue("i",len), NULL |
| 54 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 55 | |
| 56 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 57 | } |
| 58 | } |
| 59 | |
| 60 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 61 | |
| 62 | /* |
| 63 | * The global callback object. |
| 64 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 65 | static PyObj_pjsua_callback * g_obj_callback; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 66 | |
| 67 | |
| 68 | /* |
| 69 | * cb_on_call_state |
| 70 | * declares method on_call_state for callback struct |
| 71 | */ |
| 72 | static void cb_on_call_state(pjsua_call_id call_id, pjsip_event *e) |
| 73 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 74 | if (PyCallable_Check(g_obj_callback->on_call_state)) |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 75 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 76 | PyObj_pjsip_event * obj; |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 77 | |
| 78 | ENTER_PYTHON(); |
| 79 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 80 | obj = (PyObj_pjsip_event *)PyType_GenericNew(&PyTyp_pjsip_event, |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 81 | NULL, NULL); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 82 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 83 | obj->event = e; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 84 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 85 | PyObject_CallFunctionObjArgs( |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 86 | g_obj_callback->on_call_state, |
| 87 | Py_BuildValue("i",call_id), |
| 88 | obj, |
| 89 | NULL |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 90 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 91 | |
| 92 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 93 | } |
| 94 | } |
| 95 | |
| 96 | |
| 97 | /* |
| 98 | * cb_on_incoming_call |
| 99 | * declares method on_incoming_call for callback struct |
| 100 | */ |
| 101 | static void cb_on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, |
| 102 | pjsip_rx_data *rdata) |
| 103 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 104 | if (PyCallable_Check(g_obj_callback->on_incoming_call)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 105 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 106 | PyObj_pjsip_rx_data * obj; |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 107 | |
| 108 | ENTER_PYTHON(); |
| 109 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 110 | obj = (PyObj_pjsip_rx_data *)PyType_GenericNew(&PyTyp_pjsip_rx_data, |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 111 | NULL, NULL); |
| 112 | obj->rdata = rdata; |
| 113 | |
| 114 | PyObject_CallFunctionObjArgs( |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 115 | g_obj_callback->on_incoming_call, |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 116 | Py_BuildValue("i",acc_id), |
| 117 | Py_BuildValue("i",call_id), |
| 118 | obj, |
| 119 | NULL |
| 120 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 121 | |
| 122 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | |
| 126 | |
| 127 | /* |
| 128 | * cb_on_call_media_state |
| 129 | * declares method on_call_media_state for callback struct |
| 130 | */ |
| 131 | static void cb_on_call_media_state(pjsua_call_id call_id) |
| 132 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 133 | if (PyCallable_Check(g_obj_callback->on_call_media_state)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 134 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 135 | ENTER_PYTHON(); |
| 136 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 137 | PyObject_CallFunction( |
| 138 | g_obj_callback->on_call_media_state, |
| 139 | "i", |
| 140 | call_id, |
| 141 | NULL |
| 142 | ); |
| 143 | |
| 144 | LEAVE_PYTHON(); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | |
| 149 | /* |
| 150 | * cb_on_dtmf_digit() |
| 151 | * Callback from PJSUA-LIB on receiving DTMF digit |
| 152 | */ |
| 153 | static void cb_on_dtmf_digit(pjsua_call_id call_id, int digit) |
| 154 | { |
| 155 | if (PyCallable_Check(g_obj_callback->on_call_media_state)) |
| 156 | { |
| 157 | char digit_str[10]; |
| 158 | |
| 159 | ENTER_PYTHON(); |
| 160 | |
| 161 | pj_ansi_snprintf(digit_str, sizeof(digit_str), "%c", digit); |
| 162 | |
| 163 | PyObject_CallFunctionObjArgs( |
| 164 | g_obj_callback->on_call_media_state, |
| 165 | Py_BuildValue("i",call_id), |
| 166 | PyString_FromString(digit_str), |
| 167 | NULL |
| 168 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 169 | |
| 170 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 171 | } |
| 172 | } |
| 173 | |
| 174 | |
| 175 | /* |
| 176 | * Notify application on call being transfered. |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 177 | * !modified @061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 178 | */ |
| 179 | static void cb_on_call_transfer_request(pjsua_call_id call_id, |
| 180 | const pj_str_t *dst, |
| 181 | pjsip_status_code *code) |
| 182 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 183 | if (PyCallable_Check(g_obj_callback->on_call_transfer_request)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 184 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 185 | PyObject * ret; |
| 186 | int cd; |
| 187 | |
| 188 | ENTER_PYTHON(); |
| 189 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 190 | ret = PyObject_CallFunctionObjArgs( |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 191 | g_obj_callback->on_call_transfer_request, |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 192 | Py_BuildValue("i",call_id), |
| 193 | PyString_FromStringAndSize(dst->ptr, dst->slen), |
| 194 | Py_BuildValue("i",*code), |
| 195 | NULL |
| 196 | ); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 197 | if (ret != NULL) { |
| 198 | if (ret != Py_None) { |
| 199 | if (PyArg_Parse(ret,"i",&cd)) { |
| 200 | *code = cd; |
| 201 | } |
| 202 | } |
| 203 | } |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 204 | |
| 205 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | |
| 209 | |
| 210 | /* |
| 211 | * Notify application of the status of previously sent call |
| 212 | * transfer request. Application can monitor the status of the |
| 213 | * call transfer request, for example to decide whether to |
| 214 | * terminate existing call. |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 215 | * !modified @061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 216 | */ |
| 217 | static void cb_on_call_transfer_status( pjsua_call_id call_id, |
| 218 | int status_code, |
| 219 | const pj_str_t *status_text, |
| 220 | pj_bool_t final, |
| 221 | pj_bool_t *p_cont) |
| 222 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 223 | if (PyCallable_Check(g_obj_callback->on_call_transfer_status)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 224 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 225 | PyObject * ret; |
| 226 | int cnt; |
| 227 | |
| 228 | ENTER_PYTHON(); |
| 229 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 230 | ret = PyObject_CallFunctionObjArgs( |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 231 | g_obj_callback->on_call_transfer_status, |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 232 | Py_BuildValue("i",call_id), |
| 233 | Py_BuildValue("i",status_code), |
| 234 | PyString_FromStringAndSize(status_text->ptr, status_text->slen), |
| 235 | Py_BuildValue("i",final), |
| 236 | Py_BuildValue("i",*p_cont), |
| 237 | NULL |
| 238 | ); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 239 | if (ret != NULL) { |
| 240 | if (ret != Py_None) { |
| 241 | if (PyArg_Parse(ret,"i",&cnt)) { |
| 242 | *p_cont = cnt; |
| 243 | } |
| 244 | } |
| 245 | } |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 246 | |
| 247 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | |
| 251 | |
| 252 | /* |
| 253 | * Notify application about incoming INVITE with Replaces header. |
| 254 | * Application may reject the request by setting non-2xx code. |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 255 | * !modified @061206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 256 | */ |
| 257 | static void cb_on_call_replace_request( pjsua_call_id call_id, |
| 258 | pjsip_rx_data *rdata, |
| 259 | int *st_code, |
| 260 | pj_str_t *st_text) |
| 261 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 262 | if (PyCallable_Check(g_obj_callback->on_call_replace_request)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 263 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 264 | PyObject * ret; |
| 265 | PyObject * txt; |
| 266 | int cd; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 267 | PyObj_pjsip_rx_data * obj; |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 268 | |
| 269 | ENTER_PYTHON(); |
| 270 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 271 | obj = (PyObj_pjsip_rx_data *)PyType_GenericNew(&PyTyp_pjsip_rx_data, |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 272 | NULL, NULL); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 273 | obj->rdata = rdata; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 274 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 275 | ret = PyObject_CallFunctionObjArgs( |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 276 | g_obj_callback->on_call_replace_request, |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 277 | Py_BuildValue("i",call_id), |
| 278 | obj, |
| 279 | Py_BuildValue("i",*st_code), |
| 280 | PyString_FromStringAndSize(st_text->ptr, st_text->slen), |
| 281 | NULL |
| 282 | ); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 283 | if (ret != NULL) { |
| 284 | if (ret != Py_None) { |
| 285 | if (PyArg_ParseTuple(ret,"iO",&cd, &txt)) { |
| 286 | *st_code = cd; |
| 287 | st_text->ptr = PyString_AsString(txt); |
| 288 | st_text->slen = strlen(PyString_AsString(txt)); |
| 289 | } |
| 290 | } |
| 291 | } |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 292 | |
| 293 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | |
| 297 | |
| 298 | /* |
| 299 | * Notify application that an existing call has been replaced with |
| 300 | * a new call. This happens when PJSUA-API receives incoming INVITE |
| 301 | * request with Replaces header. |
| 302 | */ |
| 303 | static void cb_on_call_replaced(pjsua_call_id old_call_id, |
| 304 | pjsua_call_id new_call_id) |
| 305 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 306 | if (PyCallable_Check(g_obj_callback->on_call_replaced)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 307 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 308 | ENTER_PYTHON(); |
| 309 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 310 | PyObject_CallFunctionObjArgs( |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 311 | g_obj_callback->on_call_replaced, |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 312 | Py_BuildValue("i",old_call_id), |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 313 | Py_BuildValue("i",new_call_id), |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 314 | NULL |
| 315 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 316 | |
| 317 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 318 | } |
| 319 | } |
| 320 | |
| 321 | |
| 322 | /* |
| 323 | * cb_on_reg_state |
| 324 | * declares method on_reg_state for callback struct |
| 325 | */ |
| 326 | static void cb_on_reg_state(pjsua_acc_id acc_id) |
| 327 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 328 | if (PyCallable_Check(g_obj_callback->on_reg_state)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 329 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 330 | ENTER_PYTHON(); |
| 331 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 332 | PyObject_CallFunction( |
| 333 | g_obj_callback->on_reg_state, |
| 334 | "i", |
| 335 | acc_id, |
| 336 | NULL |
| 337 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 338 | |
| 339 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 340 | } |
| 341 | } |
| 342 | |
| 343 | |
| 344 | /* |
| 345 | * cb_on_buddy_state |
| 346 | * declares method on_buddy state for callback struct |
| 347 | */ |
| 348 | static void cb_on_buddy_state(pjsua_buddy_id buddy_id) |
| 349 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 350 | if (PyCallable_Check(g_obj_callback->on_buddy_state)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 351 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 352 | ENTER_PYTHON(); |
| 353 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 354 | PyObject_CallFunction( |
| 355 | g_obj_callback->on_buddy_state, |
| 356 | "i", |
| 357 | buddy_id, |
| 358 | NULL |
| 359 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 360 | |
| 361 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 362 | } |
| 363 | } |
| 364 | |
| 365 | /* |
| 366 | * cb_on_pager |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 367 | * declares method on_pager for callback struct |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 368 | */ |
| 369 | static void cb_on_pager(pjsua_call_id call_id, const pj_str_t *from, |
| 370 | const pj_str_t *to, const pj_str_t *contact, |
| 371 | const pj_str_t *mime_type, const pj_str_t *body) |
| 372 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 373 | if (PyCallable_Check(g_obj_callback->on_pager)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 374 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 375 | ENTER_PYTHON(); |
| 376 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 377 | PyObject_CallFunctionObjArgs( |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 378 | g_obj_callback->on_pager,Py_BuildValue("i",call_id), |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 379 | PyString_FromStringAndSize(from->ptr, from->slen), |
| 380 | PyString_FromStringAndSize(to->ptr, to->slen), |
| 381 | PyString_FromStringAndSize(contact->ptr, contact->slen), |
| 382 | PyString_FromStringAndSize(mime_type->ptr, mime_type->slen), |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 383 | PyString_FromStringAndSize(body->ptr, body->slen), |
| 384 | NULL |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 385 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 386 | |
| 387 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | |
| 391 | |
| 392 | /* |
| 393 | * cb_on_pager_status |
| 394 | * declares method on_pager_status for callback struct |
| 395 | */ |
| 396 | static void cb_on_pager_status(pjsua_call_id call_id, const pj_str_t *to, |
| 397 | const pj_str_t *body, void *user_data, |
| 398 | pjsip_status_code status, |
| 399 | const pj_str_t *reason) |
| 400 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 401 | if (PyCallable_Check(g_obj_callback->on_pager)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 402 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 403 | PyObject * obj_user_data; |
| 404 | |
| 405 | ENTER_PYTHON(); |
| 406 | |
| 407 | obj_user_data = Py_BuildValue("i", user_data); |
| 408 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 409 | PyObject_CallFunctionObjArgs( |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 410 | g_obj_callback->on_pager_status, |
| 411 | Py_BuildValue("i",call_id), |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 412 | PyString_FromStringAndSize(to->ptr, to->slen), |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 413 | PyString_FromStringAndSize(body->ptr, body->slen), |
| 414 | obj_user_data, |
| 415 | Py_BuildValue("i",status), |
| 416 | PyString_FromStringAndSize(reason->ptr,reason->slen), |
| 417 | NULL |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 418 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 419 | |
| 420 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 421 | } |
| 422 | } |
| 423 | |
| 424 | |
| 425 | /* |
| 426 | * cb_on_typing |
| 427 | * declares method on_typing for callback struct |
| 428 | */ |
| 429 | static void cb_on_typing(pjsua_call_id call_id, const pj_str_t *from, |
| 430 | const pj_str_t *to, const pj_str_t *contact, |
| 431 | pj_bool_t is_typing) |
| 432 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 433 | if (PyCallable_Check(g_obj_callback->on_typing)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 434 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 435 | ENTER_PYTHON(); |
| 436 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 437 | PyObject_CallFunctionObjArgs( |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 438 | g_obj_callback->on_typing,Py_BuildValue("i",call_id), |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 439 | PyString_FromStringAndSize(from->ptr, from->slen), |
| 440 | PyString_FromStringAndSize(to->ptr, to->slen), |
| 441 | PyString_FromStringAndSize(contact->ptr, contact->slen), |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 442 | Py_BuildValue("i",is_typing), |
| 443 | NULL |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 444 | ); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 445 | |
| 446 | LEAVE_PYTHON(); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 447 | } |
| 448 | } |
| 449 | |
| 450 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 451 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 452 | /* |
| 453 | * translate_hdr |
| 454 | * internal function |
| 455 | * translate from hdr_list to pjsip_generic_string_hdr |
| 456 | */ |
| 457 | void translate_hdr(pj_pool_t *pool, pjsip_hdr *hdr, PyObject *py_hdr_list) |
| 458 | { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 459 | pj_list_init(hdr); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 460 | |
| 461 | if (PyList_Check(py_hdr_list)) { |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 462 | int i; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 463 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 464 | for (i = 0; i < PyList_Size(py_hdr_list); i++) |
| 465 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 466 | pj_str_t hname, hvalue; |
| 467 | pjsip_generic_string_hdr * new_hdr; |
| 468 | PyObject * tuple = PyList_GetItem(py_hdr_list, i); |
| 469 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 470 | if (PyTuple_Check(tuple)) |
| 471 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 472 | hname.ptr = PyString_AsString(PyTuple_GetItem(tuple,0)); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 473 | hname.slen = strlen(PyString_AsString |
| 474 | (PyTuple_GetItem(tuple,0))); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 475 | hvalue.ptr = PyString_AsString(PyTuple_GetItem(tuple,1)); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 476 | hvalue.slen = strlen(PyString_AsString |
| 477 | (PyTuple_GetItem(tuple,1))); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 478 | } else { |
| 479 | hname.ptr = ""; |
| 480 | hname.slen = 0; |
| 481 | hvalue.ptr = ""; |
| 482 | hvalue.slen = 0; |
| 483 | } |
| 484 | new_hdr = pjsip_generic_string_hdr_create(pool, &hname, &hvalue); |
| 485 | pj_list_push_back((pj_list_type *)hdr, (pj_list_type *)new_hdr); |
| 486 | } |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | /* |
| 491 | * translate_hdr_rev |
| 492 | * internal function |
| 493 | * translate from pjsip_generic_string_hdr to hdr_list |
| 494 | */ |
| 495 | |
| 496 | void translate_hdr_rev(pjsip_generic_string_hdr *hdr, PyObject *py_hdr_list) |
| 497 | { |
| 498 | int i; |
| 499 | int len; |
| 500 | pjsip_generic_string_hdr * p_hdr; |
| 501 | |
| 502 | len = pj_list_size(hdr); |
| 503 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 504 | if (len > 0) |
| 505 | { |
| 506 | p_hdr = hdr; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 507 | Py_XDECREF(py_hdr_list); |
| 508 | py_hdr_list = PyList_New(len); |
| 509 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 510 | for (i = 0; i < len && p_hdr != NULL; i++) |
| 511 | { |
| 512 | PyObject * tuple; |
| 513 | PyObject * str; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 514 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 515 | tuple = PyTuple_New(2); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 516 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 517 | str = PyString_FromStringAndSize(p_hdr->name.ptr, p_hdr->name.slen); |
| 518 | PyTuple_SetItem(tuple, 0, str); |
| 519 | str = PyString_FromStringAndSize |
| 520 | (hdr->hvalue.ptr, p_hdr->hvalue.slen); |
| 521 | PyTuple_SetItem(tuple, 1, str); |
| 522 | PyList_SetItem(py_hdr_list, i, tuple); |
| 523 | p_hdr = p_hdr->next; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | |
| 527 | |
| 528 | } |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 529 | |
| 530 | /* |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 531 | * py_pjsua_thread_register |
| 532 | * !added @ 061206 |
| 533 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 534 | static PyObject *py_pjsua_thread_register(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 535 | { |
| 536 | |
| 537 | pj_status_t status; |
| 538 | const char *name; |
| 539 | PyObject *py_desc; |
| 540 | pj_thread_t *thread; |
| 541 | void *thread_desc; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 542 | #if 0 |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 543 | int size; |
| 544 | int i; |
| 545 | int *td; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 546 | #endif |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 547 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 548 | PJ_UNUSED_ARG(pSelf); |
| 549 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 550 | if (!PyArg_ParseTuple(pArgs, "sO", &name, &py_desc)) |
| 551 | { |
| 552 | return NULL; |
| 553 | } |
| 554 | #if 0 |
| 555 | size = PyList_Size(py_desc); |
| 556 | td = (int *)malloc(size * sizeof(int)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 557 | for (i = 0; i < size; i++) |
| 558 | { |
| 559 | if (!PyArg_Parse(PyList_GetItem(py_desc,i),"i", td[i])) |
| 560 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 561 | return NULL; |
| 562 | } |
| 563 | } |
| 564 | thread_desc = td; |
| 565 | #else |
| 566 | thread_desc = malloc(sizeof(pj_thread_desc)); |
| 567 | #endif |
| 568 | status = pj_thread_register(name, thread_desc, &thread); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 569 | |
| 570 | if (status == PJ_SUCCESS) |
| 571 | status = pj_thread_local_set(thread_id, (void*)1); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 572 | return Py_BuildValue("i",status); |
| 573 | } |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 574 | |
| 575 | /* |
| 576 | * py_pjsua_logging_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 577 | * !modified @ 051206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 578 | */ |
| 579 | static PyObject *py_pjsua_logging_config_default(PyObject *pSelf, |
| 580 | PyObject *pArgs) |
| 581 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 582 | PyObj_pjsua_logging_config *obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 583 | pjsua_logging_config cfg; |
| 584 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 585 | PJ_UNUSED_ARG(pSelf); |
| 586 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 587 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 588 | { |
| 589 | return NULL; |
| 590 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 591 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 592 | pjsua_logging_config_default(&cfg); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 593 | obj = (PyObj_pjsua_logging_config *) PyObj_pjsua_logging_config_new |
| 594 | (&PyTyp_pjsua_logging_config,NULL,NULL); |
| 595 | PyObj_pjsua_logging_config_import(obj, &cfg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 596 | |
| 597 | return (PyObject *)obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | |
| 601 | /* |
| 602 | * py_pjsua_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 603 | * !modified @ 051206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 604 | */ |
| 605 | static PyObject *py_pjsua_config_default(PyObject *pSelf, PyObject *pArgs) |
| 606 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 607 | PyObj_pjsua_config *obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 608 | pjsua_config cfg; |
| 609 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 610 | PJ_UNUSED_ARG(pSelf); |
| 611 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 612 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 613 | { |
| 614 | return NULL; |
| 615 | } |
| 616 | pjsua_config_default(&cfg); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 617 | obj = (PyObj_pjsua_config *) PyObj_pjsua_config_new(&PyTyp_pjsua_config, NULL, NULL); |
| 618 | PyObj_pjsua_config_import(obj, &cfg); |
| 619 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 620 | return (PyObject *)obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | |
| 624 | /* |
| 625 | * py_pjsua_media_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 626 | * !modified @ 051206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 627 | */ |
| 628 | static PyObject * py_pjsua_media_config_default(PyObject *pSelf, |
| 629 | PyObject *pArgs) |
| 630 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 631 | PyObj_pjsua_media_config *obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 632 | pjsua_media_config cfg; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 633 | |
| 634 | PJ_UNUSED_ARG(pSelf); |
| 635 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 636 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 637 | { |
| 638 | return NULL; |
| 639 | } |
| 640 | pjsua_media_config_default(&cfg); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 641 | obj = (PyObj_pjsua_media_config *) |
| 642 | PyType_GenericNew(&PyTyp_pjsua_media_config, NULL, NULL); |
| 643 | PyObj_pjsua_media_config_import(obj, &cfg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 644 | return (PyObject *)obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | |
| 648 | /* |
| 649 | * py_pjsua_msg_data_init |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 650 | * !modified @ 051206 |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 651 | */ |
| 652 | static PyObject *py_pjsua_msg_data_init(PyObject *pSelf, PyObject *pArgs) |
| 653 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 654 | PyObj_pjsua_msg_data *obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 655 | pjsua_msg_data msg; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 656 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 657 | PJ_UNUSED_ARG(pSelf); |
| 658 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 659 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 660 | { |
| 661 | return NULL; |
| 662 | } |
| 663 | pjsua_msg_data_init(&msg); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 664 | obj = (PyObj_pjsua_msg_data *)PyObj_pjsua_msg_data_new(&PyTyp_pjsua_msg_data, NULL, NULL); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 665 | Py_XDECREF(obj->content_type); |
| 666 | obj->content_type = PyString_FromStringAndSize( |
| 667 | msg.content_type.ptr, msg.content_type.slen |
| 668 | ); |
| 669 | Py_XDECREF(obj->msg_body); |
| 670 | obj->msg_body = PyString_FromStringAndSize( |
| 671 | msg.msg_body.ptr, msg.msg_body.slen |
| 672 | ); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 673 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 674 | translate_hdr_rev((pjsip_generic_string_hdr *)&msg.hdr_list,obj->hdr_list); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 675 | |
| 676 | return (PyObject *)obj; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | |
| 680 | /* |
| 681 | * py_pjsua_reconfigure_logging |
| 682 | */ |
| 683 | static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, PyObject *pArgs) |
| 684 | { |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 685 | PyObject * logObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 686 | PyObj_pjsua_logging_config *log; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 687 | pjsua_logging_config cfg; |
| 688 | pj_status_t status; |
| 689 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 690 | PJ_UNUSED_ARG(pSelf); |
| 691 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 692 | if (!PyArg_ParseTuple(pArgs, "O", &logObj)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 693 | { |
| 694 | return NULL; |
| 695 | } |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 696 | if (logObj != Py_None) |
| 697 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 698 | log = (PyObj_pjsua_logging_config *)logObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 699 | cfg.msg_logging = log->msg_logging; |
| 700 | cfg.level = log->level; |
| 701 | cfg.console_level = log->console_level; |
| 702 | cfg.decor = log->decor; |
| 703 | cfg.log_filename.ptr = PyString_AsString(log->log_filename); |
| 704 | cfg.log_filename.slen = strlen(cfg.log_filename.ptr); |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 705 | Py_XDECREF(obj_log_cb); |
| 706 | obj_log_cb = log->cb; |
| 707 | Py_INCREF(obj_log_cb); |
| 708 | cfg.cb = &cb_log_cb; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 709 | status = pjsua_reconfigure_logging(&cfg); |
| 710 | } else { |
| 711 | status = pjsua_reconfigure_logging(NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 712 | } |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 713 | return Py_BuildValue("i",status); |
| 714 | } |
| 715 | |
| 716 | |
| 717 | /* |
| 718 | * py_pjsua_pool_create |
| 719 | */ |
| 720 | static PyObject *py_pjsua_pool_create(PyObject *pSelf, PyObject *pArgs) |
| 721 | { |
| 722 | pj_size_t init_size; |
| 723 | pj_size_t increment; |
| 724 | const char * name; |
| 725 | pj_pool_t *p; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 726 | PyObj_pj_pool *pool; |
| 727 | |
| 728 | PJ_UNUSED_ARG(pSelf); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 729 | |
| 730 | if (!PyArg_ParseTuple(pArgs, "sII", &name, &init_size, &increment)) |
| 731 | { |
| 732 | return NULL; |
| 733 | } |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 734 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 735 | p = pjsua_pool_create(name, init_size, increment); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 736 | pool = (PyObj_pj_pool *)PyType_GenericNew(&PyTyp_pj_pool_t, NULL, NULL); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 737 | pool->pool = p; |
| 738 | return (PyObject *)pool; |
| 739 | |
| 740 | } |
| 741 | |
| 742 | |
| 743 | /* |
| 744 | * py_pjsua_get_pjsip_endpt |
| 745 | */ |
| 746 | static PyObject *py_pjsua_get_pjsip_endpt(PyObject *pSelf, PyObject *pArgs) |
| 747 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 748 | PyObj_pjsip_endpoint *endpt; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 749 | pjsip_endpoint *e; |
| 750 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 751 | PJ_UNUSED_ARG(pSelf); |
| 752 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 753 | if (!PyArg_ParseTuple(pArgs, "")) |
| 754 | { |
| 755 | return NULL; |
| 756 | } |
| 757 | e = pjsua_get_pjsip_endpt(); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 758 | endpt = (PyObj_pjsip_endpoint *)PyType_GenericNew( |
| 759 | &PyTyp_pjsip_endpoint, NULL, NULL |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 760 | ); |
| 761 | endpt->endpt = e; |
| 762 | return (PyObject *)endpt; |
| 763 | } |
| 764 | |
| 765 | |
| 766 | /* |
| 767 | * py_pjsua_get_pjmedia_endpt |
| 768 | */ |
| 769 | static PyObject *py_pjsua_get_pjmedia_endpt(PyObject *pSelf, PyObject *pArgs) |
| 770 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 771 | PyObj_pjmedia_endpt *endpt; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 772 | pjmedia_endpt *e; |
| 773 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 774 | PJ_UNUSED_ARG(pSelf); |
| 775 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 776 | if (!PyArg_ParseTuple(pArgs, "")) |
| 777 | { |
| 778 | return NULL; |
| 779 | } |
| 780 | e = pjsua_get_pjmedia_endpt(); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 781 | endpt = (PyObj_pjmedia_endpt *)PyType_GenericNew( |
| 782 | &PyTyp_pjmedia_endpt, NULL, NULL |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 783 | ); |
| 784 | endpt->endpt = e; |
| 785 | return (PyObject *)endpt; |
| 786 | } |
| 787 | |
| 788 | |
| 789 | /* |
| 790 | * py_pjsua_get_pool_factory |
| 791 | */ |
| 792 | static PyObject *py_pjsua_get_pool_factory(PyObject *pSelf, PyObject *pArgs) |
| 793 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 794 | PyObj_pj_pool_factory *pool; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 795 | pj_pool_factory *p; |
| 796 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 797 | PJ_UNUSED_ARG(pSelf); |
| 798 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 799 | if (!PyArg_ParseTuple(pArgs, "")) |
| 800 | { |
| 801 | return NULL; |
| 802 | } |
| 803 | p = pjsua_get_pool_factory(); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 804 | pool = (PyObj_pj_pool_factory *)PyType_GenericNew( |
| 805 | &PyTyp_pj_pool_factory, NULL, NULL |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 806 | ); |
| 807 | pool->pool_fact = p; |
| 808 | return (PyObject *)pool; |
| 809 | } |
| 810 | |
| 811 | |
| 812 | /* |
| 813 | * py_pjsua_perror |
| 814 | */ |
| 815 | static PyObject *py_pjsua_perror(PyObject *pSelf, PyObject *pArgs) |
| 816 | { |
| 817 | const char *sender; |
| 818 | const char *title; |
| 819 | pj_status_t status; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 820 | |
| 821 | PJ_UNUSED_ARG(pSelf); |
| 822 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 823 | if (!PyArg_ParseTuple(pArgs, "ssi", &sender, &title, &status)) |
| 824 | { |
| 825 | return NULL; |
| 826 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 827 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 828 | pjsua_perror(sender, title, status); |
| 829 | Py_INCREF(Py_None); |
| 830 | return Py_None; |
| 831 | } |
| 832 | |
| 833 | |
| 834 | /* |
| 835 | * py_pjsua_create |
| 836 | */ |
| 837 | static PyObject *py_pjsua_create(PyObject *pSelf, PyObject *pArgs) |
| 838 | { |
| 839 | pj_status_t status; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 840 | |
| 841 | PJ_UNUSED_ARG(pSelf); |
| 842 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 843 | if (!PyArg_ParseTuple(pArgs, "")) |
| 844 | { |
| 845 | return NULL; |
| 846 | } |
| 847 | status = pjsua_create(); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 848 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 849 | if (status == PJ_SUCCESS) |
| 850 | { |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 851 | status = pj_thread_local_alloc(&thread_id); |
| 852 | if (status == PJ_SUCCESS) |
| 853 | status = pj_thread_local_set(thread_id, (void*)1); |
| 854 | } |
| 855 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 856 | return Py_BuildValue("i",status); |
| 857 | } |
| 858 | |
| 859 | |
| 860 | /* |
| 861 | * py_pjsua_init |
| 862 | */ |
| 863 | static PyObject *py_pjsua_init(PyObject *pSelf, PyObject *pArgs) |
| 864 | { |
| 865 | pj_status_t status; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 866 | PyObject *o_ua_cfg, *o_log_cfg, *o_media_cfg; |
| 867 | pjsua_config cfg_ua, *p_cfg_ua; |
| 868 | pjsua_logging_config cfg_log, *p_cfg_log; |
| 869 | pjsua_media_config cfg_media, *p_cfg_media; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 870 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 871 | PJ_UNUSED_ARG(pSelf); |
| 872 | |
| 873 | if (!PyArg_ParseTuple(pArgs, "OOO", &o_ua_cfg, &o_log_cfg, &o_media_cfg)) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 874 | { |
| 875 | return NULL; |
| 876 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 877 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 878 | pjsua_config_default(&cfg_ua); |
| 879 | pjsua_logging_config_default(&cfg_log); |
| 880 | pjsua_media_config_default(&cfg_media); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 881 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 882 | if (o_ua_cfg != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 883 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 884 | PyObj_pjsua_config *obj_ua_cfg = (PyObj_pjsua_config*)o_ua_cfg; |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 885 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 886 | PyObj_pjsua_config_export(&cfg_ua, obj_ua_cfg); |
| 887 | |
| 888 | g_obj_callback = obj_ua_cfg->cb; |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 889 | Py_INCREF(g_obj_callback); |
| 890 | |
| 891 | cfg_ua.cb.on_call_state = &cb_on_call_state; |
| 892 | cfg_ua.cb.on_incoming_call = &cb_on_incoming_call; |
| 893 | cfg_ua.cb.on_call_media_state = &cb_on_call_media_state; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 894 | cfg_ua.cb.on_dtmf_digit = &cb_on_dtmf_digit; |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 895 | cfg_ua.cb.on_call_transfer_request = &cb_on_call_transfer_request; |
| 896 | cfg_ua.cb.on_call_transfer_status = &cb_on_call_transfer_status; |
| 897 | cfg_ua.cb.on_call_replace_request = &cb_on_call_replace_request; |
| 898 | cfg_ua.cb.on_call_replaced = &cb_on_call_replaced; |
| 899 | cfg_ua.cb.on_reg_state = &cb_on_reg_state; |
| 900 | cfg_ua.cb.on_buddy_state = &cb_on_buddy_state; |
| 901 | cfg_ua.cb.on_pager = &cb_on_pager; |
| 902 | cfg_ua.cb.on_pager_status = &cb_on_pager_status; |
| 903 | cfg_ua.cb.on_typing = &cb_on_typing; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 904 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 905 | p_cfg_ua = &cfg_ua; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 906 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 907 | } else { |
| 908 | p_cfg_ua = NULL; |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 909 | } |
| 910 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 911 | if (o_log_cfg != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 912 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 913 | PyObj_pjsua_logging_config * obj_log; |
| 914 | |
| 915 | obj_log = (PyObj_pjsua_logging_config *)o_log_cfg; |
| 916 | |
| 917 | PyObj_pjsua_logging_config_export(&cfg_log, obj_log); |
| 918 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 919 | Py_XDECREF(obj_log_cb); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 920 | obj_log_cb = obj_log->cb; |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 921 | Py_INCREF(obj_log_cb); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 922 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 923 | cfg_log.cb = &cb_log_cb; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 924 | p_cfg_log = &cfg_log; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 925 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 926 | } else { |
| 927 | p_cfg_log = NULL; |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 928 | } |
| 929 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 930 | if (o_media_cfg != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 931 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 932 | PyObj_pjsua_media_config_export(&cfg_media, |
| 933 | (PyObj_pjsua_media_config*)o_media_cfg); |
| 934 | p_cfg_media = &cfg_media; |
| 935 | |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 936 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 937 | p_cfg_media = NULL; |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 938 | } |
| 939 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 940 | status = pjsua_init(p_cfg_ua, p_cfg_log, p_cfg_media); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 941 | return Py_BuildValue("i",status); |
| 942 | } |
| 943 | |
| 944 | |
| 945 | /* |
| 946 | * py_pjsua_start |
| 947 | */ |
| 948 | static PyObject *py_pjsua_start(PyObject *pSelf, PyObject *pArgs) |
| 949 | { |
| 950 | pj_status_t status; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 951 | |
| 952 | PJ_UNUSED_ARG(pSelf); |
| 953 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 954 | if (!PyArg_ParseTuple(pArgs, "")) |
| 955 | { |
| 956 | return NULL; |
| 957 | } |
| 958 | status = pjsua_start(); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 959 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 960 | return Py_BuildValue("i",status); |
| 961 | } |
| 962 | |
| 963 | |
| 964 | /* |
| 965 | * py_pjsua_destroy |
| 966 | */ |
| 967 | static PyObject *py_pjsua_destroy(PyObject *pSelf, PyObject *pArgs) |
| 968 | { |
| 969 | pj_status_t status; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 970 | |
| 971 | PJ_UNUSED_ARG(pSelf); |
| 972 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 973 | if (!PyArg_ParseTuple(pArgs, "")) |
| 974 | { |
| 975 | return NULL; |
| 976 | } |
| 977 | status = pjsua_destroy(); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 978 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 979 | return Py_BuildValue("i",status); |
| 980 | } |
| 981 | |
| 982 | |
| 983 | /* |
| 984 | * py_pjsua_handle_events |
| 985 | */ |
| 986 | static PyObject *py_pjsua_handle_events(PyObject *pSelf, PyObject *pArgs) |
| 987 | { |
| 988 | int ret; |
| 989 | unsigned msec; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 990 | |
| 991 | PJ_UNUSED_ARG(pSelf); |
| 992 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 993 | if (!PyArg_ParseTuple(pArgs, "i", &msec)) |
| 994 | { |
| 995 | return NULL; |
| 996 | } |
Benny Prijono | 4759f9c | 2007-02-14 02:15:19 +0000 | [diff] [blame] | 997 | |
| 998 | /* Since handle_events() will block, we must wrap it with ALLOW_THREADS |
| 999 | * construct, or otherwise many Python blocking functions (such as |
| 1000 | * time.sleep(), readline(), etc.) may hang/block indefinitely. |
| 1001 | * See http://www.python.org/doc/current/api/threads.html for more info. |
| 1002 | */ |
| 1003 | Py_BEGIN_ALLOW_THREADS |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1004 | ret = pjsua_handle_events(msec); |
Benny Prijono | 4759f9c | 2007-02-14 02:15:19 +0000 | [diff] [blame] | 1005 | Py_END_ALLOW_THREADS |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 1006 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1007 | return Py_BuildValue("i",ret); |
| 1008 | } |
| 1009 | |
| 1010 | |
| 1011 | /* |
| 1012 | * py_pjsua_verify_sip_url |
| 1013 | */ |
| 1014 | static PyObject *py_pjsua_verify_sip_url(PyObject *pSelf, PyObject *pArgs) |
| 1015 | { |
| 1016 | pj_status_t status; |
| 1017 | const char *url; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1018 | |
| 1019 | PJ_UNUSED_ARG(pSelf); |
| 1020 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1021 | if (!PyArg_ParseTuple(pArgs, "s", &url)) |
| 1022 | { |
| 1023 | return NULL; |
| 1024 | } |
| 1025 | status = pjsua_verify_sip_url(url); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 1026 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1027 | return Py_BuildValue("i",status); |
| 1028 | } |
| 1029 | |
| 1030 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1031 | /* |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1032 | * function doc |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1033 | */ |
| 1034 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1035 | static char pjsua_thread_register_doc[] = |
| 1036 | "int py_pjsua.thread_register(string name, int[] desc)"; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1037 | static char pjsua_perror_doc[] = |
| 1038 | "void py_pjsua.perror (string sender, string title, int status) " |
| 1039 | "Display error message for the specified error code. Parameters: " |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1040 | "sender: The log sender field; " |
| 1041 | "title: Message title for the error; " |
| 1042 | "status: Status code."; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1043 | |
| 1044 | static char pjsua_create_doc[] = |
| 1045 | "int py_pjsua.create (void) " |
| 1046 | "Instantiate pjsua application. Application " |
| 1047 | "must call this function before calling any other functions, to make sure " |
| 1048 | "that the underlying libraries are properly initialized. Once this " |
| 1049 | "function has returned success, application must call pjsua_destroy() " |
| 1050 | "before quitting."; |
| 1051 | |
| 1052 | static char pjsua_init_doc[] = |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1053 | "int py_pjsua.init (py_pjsua.Config obj_ua_cfg, " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1054 | "py_pjsua.Logging_Config log_cfg, py_pjsua.Media_Config media_cfg) " |
| 1055 | "Initialize pjsua with the specified settings. All the settings are " |
| 1056 | "optional, and the default values will be used when the config is not " |
| 1057 | "specified. Parameters: " |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1058 | "obj_ua_cfg : User agent configuration; " |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1059 | "log_cfg : Optional logging configuration; " |
| 1060 | "media_cfg : Optional media configuration."; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1061 | |
| 1062 | static char pjsua_start_doc[] = |
| 1063 | "int py_pjsua.start (void) " |
| 1064 | "Application is recommended to call this function after all " |
| 1065 | "initialization is done, so that the library can do additional checking " |
| 1066 | "set up additional"; |
| 1067 | |
| 1068 | static char pjsua_destroy_doc[] = |
| 1069 | "int py_pjsua.destroy (void) " |
| 1070 | "Destroy pjsua This function must be called once PJSUA is created. To " |
| 1071 | "make it easier for application, application may call this function " |
| 1072 | "several times with no danger."; |
| 1073 | |
| 1074 | static char pjsua_handle_events_doc[] = |
| 1075 | "int py_pjsua.handle_events (int msec_timeout) " |
| 1076 | "Poll pjsua for events, and if necessary block the caller thread for the " |
| 1077 | "specified maximum interval (in miliseconds) Parameters: " |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1078 | "msec_timeout: Maximum time to wait, in miliseconds. " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1079 | "Returns: The number of events that have been handled during the poll. " |
| 1080 | "Negative value indicates error, and application can retrieve the error " |
| 1081 | "as (err = -return_value)."; |
| 1082 | |
| 1083 | static char pjsua_verify_sip_url_doc[] = |
| 1084 | "int py_pjsua.verify_sip_url (string c_url) " |
| 1085 | "Verify that valid SIP url is given Parameters: " |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1086 | "c_url: The URL, as NULL terminated string."; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1087 | |
| 1088 | static char pjsua_pool_create_doc[] = |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1089 | "py_pjsua.Pj_Pool py_pjsua.pool_create (string name, int init_size, " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1090 | "int increment) " |
| 1091 | "Create memory pool Parameters: " |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1092 | "name: Optional pool name; " |
| 1093 | "init_size: Initial size of the pool; " |
| 1094 | "increment: Increment size."; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1095 | |
| 1096 | static char pjsua_get_pjsip_endpt_doc[] = |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1097 | "py_pjsua.Pjsip_Endpoint py_pjsua.get_pjsip_endpt (void) " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1098 | "Internal function to get SIP endpoint instance of pjsua, which is needed " |
| 1099 | "for example to register module, create transports, etc. Probably is only " |
| 1100 | "valid after pjsua_init() is called."; |
| 1101 | |
| 1102 | static char pjsua_get_pjmedia_endpt_doc[] = |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1103 | "py_pjsua.Pjmedia_Endpt py_pjsua.get_pjmedia_endpt (void) " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1104 | "Internal function to get media endpoint instance. Only valid after " |
| 1105 | "pjsua_init() is called."; |
| 1106 | |
| 1107 | static char pjsua_get_pool_factory_doc[] = |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1108 | "py_pjsua.Pj_Pool_Factory py_pjsua.get_pool_factory (void) " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1109 | "Internal function to get PJSUA pool factory. Only valid after " |
| 1110 | "pjsua_init() is called."; |
| 1111 | |
| 1112 | static char pjsua_reconfigure_logging_doc[] = |
| 1113 | "int py_pjsua.reconfigure_logging (py_pjsua.Logging_Config c) " |
| 1114 | "Application can call this function at any time (after pjsua_create(), of " |
| 1115 | "course) to change logging settings. Parameters: " |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1116 | "c: Logging configuration."; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1117 | |
| 1118 | static char pjsua_logging_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1119 | "py_pjsua.Logging_Config py_pjsua.logging_config_default () " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1120 | "Use this function to initialize logging config."; |
| 1121 | |
| 1122 | static char pjsua_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1123 | "py_pjsua.Config py_pjsua.config_default (). Use this function to " |
| 1124 | "initialize pjsua config. "; |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1125 | |
| 1126 | static char pjsua_media_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1127 | "py_pjsua.Media_Config py_pjsua.media_config_default (). " |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1128 | "Use this function to initialize media config."; |
| 1129 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1130 | static char pjsua_msg_data_init_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1131 | "py_pjsua.Msg_Data void py_pjsua.msg_data_init () " |
| 1132 | "Initialize message data "; |
| 1133 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1134 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1135 | /* END OF LIB BASE */ |
| 1136 | |
| 1137 | /* LIB TRANSPORT */ |
| 1138 | |
| 1139 | /* |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1140 | * py_pjsua_transport_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1141 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1142 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1143 | static PyObject *py_pjsua_transport_config_default(PyObject *pSelf, |
| 1144 | PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1145 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1146 | PyObj_pjsua_transport_config *obj; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1147 | pjsua_transport_config cfg; |
| 1148 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1149 | PJ_UNUSED_ARG(pSelf); |
| 1150 | |
| 1151 | if (!PyArg_ParseTuple(pArgs, "")) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1152 | return NULL; |
| 1153 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1154 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1155 | pjsua_transport_config_default(&cfg); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1156 | obj = (PyObj_pjsua_transport_config*) |
| 1157 | PyObj_pjsua_transport_config_new(&PyTyp_pjsua_transport_config, |
| 1158 | NULL, NULL); |
| 1159 | PyObj_pjsua_transport_config_import(obj, &cfg); |
| 1160 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1161 | return (PyObject *)obj; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | /* |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1165 | * py_pjsua_transport_create |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1166 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1167 | */ |
| 1168 | static PyObject *py_pjsua_transport_create(PyObject *pSelf, PyObject *pArgs) |
| 1169 | { |
| 1170 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1171 | int type; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1172 | PyObject * tmpObj; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1173 | pjsua_transport_config cfg; |
| 1174 | pjsua_transport_id id; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1175 | |
| 1176 | PJ_UNUSED_ARG(pSelf); |
| 1177 | |
| 1178 | if (!PyArg_ParseTuple(pArgs, "iO", &type, &tmpObj)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1179 | return NULL; |
| 1180 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1181 | |
| 1182 | if (tmpObj != Py_None) { |
| 1183 | PyObj_pjsua_transport_config *obj; |
| 1184 | obj = (PyObj_pjsua_transport_config*)tmpObj; |
| 1185 | PyObj_pjsua_transport_config_export(&cfg, obj); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1186 | status = pjsua_transport_create(type, &cfg, &id); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1187 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1188 | status = pjsua_transport_create(type, NULL, &id); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1189 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1190 | |
| 1191 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1192 | return Py_BuildValue("ii", status, id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1193 | } |
| 1194 | |
| 1195 | /* |
| 1196 | * py_pjsua_enum_transports |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1197 | * !modified @ 261206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1198 | */ |
| 1199 | static PyObject *py_pjsua_enum_transports(PyObject *pSelf, PyObject *pArgs) |
| 1200 | { |
| 1201 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1202 | PyObject *list; |
| 1203 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1204 | pjsua_transport_id id[PJSIP_MAX_TRANSPORTS]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1205 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1206 | |
| 1207 | PJ_UNUSED_ARG(pSelf); |
| 1208 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1209 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1210 | { |
| 1211 | return NULL; |
| 1212 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1213 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1214 | c = PJ_ARRAY_SIZE(id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1215 | status = pjsua_enum_transports(id, &c); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1216 | |
| 1217 | list = PyList_New(c); |
| 1218 | for (i = 0; i < c; i++) |
| 1219 | { |
| 1220 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 1221 | if (ret == -1) |
| 1222 | { |
| 1223 | return NULL; |
| 1224 | } |
| 1225 | } |
| 1226 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1227 | return Py_BuildValue("O",list); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | /* |
| 1231 | * py_pjsua_transport_get_info |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1232 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1233 | */ |
| 1234 | static PyObject *py_pjsua_transport_get_info(PyObject *pSelf, PyObject *pArgs) |
| 1235 | { |
| 1236 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1237 | int id; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1238 | pjsua_transport_info info; |
| 1239 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1240 | PJ_UNUSED_ARG(pSelf); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1241 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1242 | if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1243 | return NULL; |
| 1244 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1245 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1246 | status = pjsua_transport_get_info(id, &info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1247 | if (status == PJ_SUCCESS) { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1248 | PyObj_pjsua_transport_info *obj; |
| 1249 | obj = (PyObj_pjsua_transport_info *) |
| 1250 | PyObj_pjsua_transport_info_new(&PyTyp_pjsua_transport_info, |
| 1251 | NULL, NULL); |
| 1252 | PyObj_pjsua_transport_info_import(obj, &info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1253 | return Py_BuildValue("O", obj); |
| 1254 | } else { |
| 1255 | Py_INCREF(Py_None); |
| 1256 | return Py_None; |
| 1257 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | /* |
| 1261 | * py_pjsua_transport_set_enable |
| 1262 | */ |
| 1263 | static PyObject *py_pjsua_transport_set_enable |
| 1264 | (PyObject *pSelf, PyObject *pArgs) |
| 1265 | { |
| 1266 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1267 | int id; |
| 1268 | int enabled; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1269 | |
| 1270 | PJ_UNUSED_ARG(pSelf); |
| 1271 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1272 | if (!PyArg_ParseTuple(pArgs, "ii", &id, &enabled)) |
| 1273 | { |
| 1274 | return NULL; |
| 1275 | } |
| 1276 | status = pjsua_transport_set_enable(id, enabled); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 1277 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1278 | return Py_BuildValue("i",status); |
| 1279 | } |
| 1280 | |
| 1281 | /* |
| 1282 | * py_pjsua_transport_close |
| 1283 | */ |
| 1284 | static PyObject *py_pjsua_transport_close(PyObject *pSelf, PyObject *pArgs) |
| 1285 | { |
| 1286 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1287 | int id; |
| 1288 | int force; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1289 | |
| 1290 | PJ_UNUSED_ARG(pSelf); |
| 1291 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1292 | if (!PyArg_ParseTuple(pArgs, "ii", &id, &force)) |
| 1293 | { |
| 1294 | return NULL; |
| 1295 | } |
| 1296 | status = pjsua_transport_close(id, force); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 1297 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1298 | return Py_BuildValue("i",status); |
| 1299 | } |
| 1300 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1301 | static char pjsua_transport_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1302 | "py_pjsua.Transport_Config py_pjsua.transport_config_default () " |
| 1303 | "Call this function to initialize UDP config with default values."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1304 | static char pjsua_transport_create_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1305 | "int, int py_pjsua.transport_create (int type, " |
| 1306 | "py_pjsua.Transport_Config cfg) " |
| 1307 | "Create SIP transport."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1308 | static char pjsua_enum_transports_doc[] = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1309 | "int[] py_pjsua.enum_transports () " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1310 | "Enumerate all transports currently created in the system."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1311 | static char pjsua_transport_get_info_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1312 | "void py_pjsua.transport_get_info " |
| 1313 | "(py_pjsua.Transport_ID id, py_pjsua.Transport_Info info) " |
| 1314 | "Get information about transports."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1315 | static char pjsua_transport_set_enable_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1316 | "void py_pjsua.transport_set_enable " |
| 1317 | "(py_pjsua.Transport_ID id, int enabled) " |
| 1318 | "Disable a transport or re-enable it. " |
| 1319 | "By default transport is always enabled after it is created. " |
| 1320 | "Disabling a transport does not necessarily close the socket, " |
| 1321 | "it will only discard incoming messages and prevent the transport " |
| 1322 | "from being used to send outgoing messages."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1323 | static char pjsua_transport_close_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1324 | "void py_pjsua.transport_close (py_pjsua.Transport_ID id, int force) " |
| 1325 | "Close the transport. If transport is forcefully closed, " |
| 1326 | "it will be immediately closed, and any pending transactions " |
| 1327 | "that are using the transport may not terminate properly. " |
| 1328 | "Otherwise, the system will wait until all transactions are closed " |
| 1329 | "while preventing new users from using the transport, and will close " |
| 1330 | "the transport when it is safe to do so."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1331 | |
| 1332 | /* END OF LIB TRANSPORT */ |
| 1333 | |
| 1334 | /* LIB ACCOUNT */ |
| 1335 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1336 | |
| 1337 | /* |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1338 | * py_pjsua_acc_config_default |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1339 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1340 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1341 | static PyObject *py_pjsua_acc_config_default(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1342 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1343 | PyObj_pjsua_acc_config *obj; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1344 | pjsua_acc_config cfg; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1345 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1346 | PJ_UNUSED_ARG(pSelf); |
| 1347 | |
| 1348 | if (!PyArg_ParseTuple(pArgs, "")) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1349 | return NULL; |
| 1350 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1351 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1352 | pjsua_acc_config_default(&cfg); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1353 | obj = (PyObj_pjsua_acc_config *) |
| 1354 | PyObj_pjsua_acc_config_new(&PyTyp_pjsua_acc_config, |
| 1355 | NULL, NULL); |
| 1356 | PyObj_pjsua_acc_config_import(obj, &cfg); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1357 | return (PyObject *)obj; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | /* |
| 1361 | * py_pjsua_acc_get_count |
| 1362 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1363 | static PyObject *py_pjsua_acc_get_count(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1364 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1365 | int count; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1366 | |
| 1367 | PJ_UNUSED_ARG(pSelf); |
| 1368 | |
| 1369 | if (!PyArg_ParseTuple(pArgs, "")) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1370 | return NULL; |
| 1371 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1372 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1373 | count = pjsua_acc_get_count(); |
| 1374 | return Py_BuildValue("i",count); |
| 1375 | } |
| 1376 | |
| 1377 | /* |
| 1378 | * py_pjsua_acc_is_valid |
| 1379 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1380 | static PyObject *py_pjsua_acc_is_valid(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1381 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1382 | int id; |
| 1383 | int is_valid; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1384 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1385 | PJ_UNUSED_ARG(pSelf); |
| 1386 | |
| 1387 | if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1388 | return NULL; |
| 1389 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1390 | |
| 1391 | is_valid = pjsua_acc_is_valid(id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1392 | return Py_BuildValue("i", is_valid); |
| 1393 | } |
| 1394 | |
| 1395 | /* |
| 1396 | * py_pjsua_acc_set_default |
| 1397 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1398 | static PyObject *py_pjsua_acc_set_default(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1399 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1400 | int id; |
| 1401 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1402 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1403 | PJ_UNUSED_ARG(pSelf); |
| 1404 | |
| 1405 | if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1406 | return NULL; |
| 1407 | } |
| 1408 | status = pjsua_acc_set_default(id); |
| 1409 | |
| 1410 | return Py_BuildValue("i", status); |
| 1411 | } |
| 1412 | |
| 1413 | /* |
| 1414 | * py_pjsua_acc_get_default |
| 1415 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1416 | static PyObject *py_pjsua_acc_get_default(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1417 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1418 | int id; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1419 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1420 | PJ_UNUSED_ARG(pSelf); |
| 1421 | |
| 1422 | if (!PyArg_ParseTuple(pArgs, "")) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1423 | return NULL; |
| 1424 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1425 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1426 | id = pjsua_acc_get_default(); |
| 1427 | |
| 1428 | return Py_BuildValue("i", id); |
| 1429 | } |
| 1430 | |
| 1431 | /* |
| 1432 | * py_pjsua_acc_add |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1433 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1434 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1435 | static PyObject *py_pjsua_acc_add(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1436 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1437 | int is_default; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1438 | PyObject * acObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1439 | PyObj_pjsua_acc_config * ac; |
| 1440 | int acc_id; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1441 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1442 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1443 | PJ_UNUSED_ARG(pSelf); |
| 1444 | |
| 1445 | if (!PyArg_ParseTuple(pArgs, "Oi", &acObj, &is_default)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1446 | return NULL; |
| 1447 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1448 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1449 | if (acObj != Py_None) { |
| 1450 | pjsua_acc_config cfg; |
| 1451 | |
| 1452 | pjsua_acc_config_default(&cfg); |
| 1453 | ac = (PyObj_pjsua_acc_config *)acObj; |
| 1454 | PyObj_pjsua_acc_config_export(&cfg, ac); |
| 1455 | status = pjsua_acc_add(&cfg, is_default, &acc_id); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1456 | } else { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1457 | status = PJ_EINVAL; |
| 1458 | acc_id = PJSUA_INVALID_ID; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1459 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1460 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1461 | return Py_BuildValue("ii", status, acc_id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1462 | } |
| 1463 | |
| 1464 | /* |
| 1465 | * py_pjsua_acc_add_local |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1466 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1467 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1468 | static PyObject *py_pjsua_acc_add_local(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1469 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1470 | int is_default; |
| 1471 | int tid; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1472 | int p_acc_id; |
| 1473 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1474 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1475 | PJ_UNUSED_ARG(pSelf); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1476 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1477 | if (!PyArg_ParseTuple(pArgs, "ii", &tid, &is_default)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1478 | return NULL; |
| 1479 | } |
| 1480 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1481 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1482 | status = pjsua_acc_add_local(tid, is_default, &p_acc_id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1483 | |
| 1484 | return Py_BuildValue("ii", status, p_acc_id); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1485 | } |
| 1486 | |
| 1487 | /* |
| 1488 | * py_pjsua_acc_del |
| 1489 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1490 | static PyObject *py_pjsua_acc_del(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1491 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1492 | int acc_id; |
| 1493 | int status; |
| 1494 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1495 | PJ_UNUSED_ARG(pSelf); |
| 1496 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1497 | if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) |
| 1498 | { |
| 1499 | return NULL; |
| 1500 | } |
| 1501 | |
| 1502 | |
| 1503 | status = pjsua_acc_del(acc_id); |
| 1504 | return Py_BuildValue("i", status); |
| 1505 | } |
| 1506 | |
| 1507 | /* |
| 1508 | * py_pjsua_acc_modify |
| 1509 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1510 | static PyObject *py_pjsua_acc_modify(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1511 | { |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1512 | PyObject * acObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1513 | PyObj_pjsua_acc_config * ac; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1514 | int acc_id; |
| 1515 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1516 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1517 | PJ_UNUSED_ARG(pSelf); |
| 1518 | |
| 1519 | if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &acObj)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1520 | return NULL; |
| 1521 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1522 | |
| 1523 | if (acObj != Py_None) { |
| 1524 | pjsua_acc_config cfg; |
| 1525 | |
| 1526 | pjsua_acc_config_default(&cfg); |
| 1527 | ac = (PyObj_pjsua_acc_config *)acObj; |
| 1528 | PyObj_pjsua_acc_config_export(&cfg, ac); |
| 1529 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1530 | status = pjsua_acc_modify(acc_id, &cfg); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1531 | } else { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1532 | status = PJ_EINVAL; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1533 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1534 | return Py_BuildValue("i", status); |
| 1535 | } |
| 1536 | |
| 1537 | /* |
| 1538 | * py_pjsua_acc_set_online_status |
| 1539 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1540 | static PyObject *py_pjsua_acc_set_online_status(PyObject *pSelf, |
| 1541 | PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1542 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1543 | int is_online; |
| 1544 | int acc_id; |
| 1545 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1546 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1547 | PJ_UNUSED_ARG(pSelf); |
| 1548 | |
| 1549 | if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &is_online)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1550 | return NULL; |
| 1551 | } |
| 1552 | |
| 1553 | status = pjsua_acc_set_online_status(acc_id, is_online); |
| 1554 | |
| 1555 | return Py_BuildValue("i", status); |
| 1556 | } |
| 1557 | |
| 1558 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1559 | * py_pjsua_acc_set_online_status2 |
| 1560 | */ |
| 1561 | static PyObject *py_pjsua_acc_set_online_status2(PyObject *pSelf, |
| 1562 | PyObject *pArgs) |
| 1563 | { |
| 1564 | int is_online; |
| 1565 | int acc_id; |
| 1566 | int activity_id; |
| 1567 | const char *activity_text; |
| 1568 | pjrpid_element rpid; |
| 1569 | pj_status_t status; |
| 1570 | |
| 1571 | PJ_UNUSED_ARG(pSelf); |
| 1572 | |
| 1573 | if (!PyArg_ParseTuple(pArgs, "iiis", &acc_id, &is_online, |
| 1574 | &activity_id, &activity_text)) { |
| 1575 | return NULL; |
| 1576 | } |
| 1577 | |
| 1578 | pj_bzero(&rpid, sizeof(rpid)); |
| 1579 | rpid.activity = activity_id; |
| 1580 | rpid.note = pj_str((char*)activity_text); |
| 1581 | |
| 1582 | status = pjsua_acc_set_online_status2(acc_id, is_online, &rpid); |
| 1583 | |
| 1584 | return Py_BuildValue("i", status); |
| 1585 | } |
| 1586 | |
| 1587 | /* |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1588 | * py_pjsua_acc_set_registration |
| 1589 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1590 | static PyObject *py_pjsua_acc_set_registration(PyObject *pSelf, |
| 1591 | PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1592 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1593 | int renew; |
| 1594 | int acc_id; |
| 1595 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1596 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1597 | PJ_UNUSED_ARG(pSelf); |
| 1598 | |
| 1599 | if (!PyArg_ParseTuple(pArgs, "ii", &acc_id, &renew)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1600 | return NULL; |
| 1601 | } |
| 1602 | |
| 1603 | status = pjsua_acc_set_registration(acc_id, renew); |
| 1604 | |
| 1605 | return Py_BuildValue("i", status); |
| 1606 | } |
| 1607 | |
| 1608 | /* |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1609 | * py_pjsua_acc_get_info |
| 1610 | * !modified @ 051206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1611 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1612 | static PyObject *py_pjsua_acc_get_info(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1613 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1614 | int acc_id; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1615 | PyObj_pjsua_acc_info * obj; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1616 | pjsua_acc_info info; |
| 1617 | int status; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1618 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1619 | PJ_UNUSED_ARG(pSelf); |
| 1620 | |
| 1621 | if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1622 | return NULL; |
| 1623 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1624 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1625 | status = pjsua_acc_get_info(acc_id, &info); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1626 | if (status == PJ_SUCCESS) { |
| 1627 | obj = (PyObj_pjsua_acc_info *) |
| 1628 | PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info,NULL, NULL); |
| 1629 | PyObj_pjsua_acc_info_import(obj, &info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1630 | return Py_BuildValue("O", obj); |
| 1631 | } else { |
| 1632 | Py_INCREF(Py_None); |
| 1633 | return Py_None; |
| 1634 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1635 | } |
| 1636 | |
| 1637 | /* |
| 1638 | * py_pjsua_enum_accs |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1639 | * !modified @ 241206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1640 | */ |
| 1641 | static PyObject *py_pjsua_enum_accs(PyObject *pSelf, PyObject *pArgs) |
| 1642 | { |
| 1643 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1644 | PyObject *list; |
| 1645 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1646 | pjsua_acc_id id[PJSUA_MAX_ACC]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1647 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1648 | |
| 1649 | PJ_UNUSED_ARG(pSelf); |
| 1650 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1651 | if (!PyArg_ParseTuple(pArgs, "")) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1652 | { |
| 1653 | return NULL; |
| 1654 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1655 | c = PJ_ARRAY_SIZE(id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1656 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1657 | status = pjsua_enum_accs(id, &c); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1658 | |
| 1659 | list = PyList_New(c); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1660 | for (i = 0; i < c; i++) |
| 1661 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1662 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1663 | if (ret == -1) |
| 1664 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1665 | return NULL; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1666 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1667 | } |
| 1668 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1669 | return Py_BuildValue("O",list); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1670 | } |
| 1671 | |
| 1672 | /* |
| 1673 | * py_pjsua_acc_enum_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1674 | * !modified @ 241206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1675 | */ |
| 1676 | static PyObject *py_pjsua_acc_enum_info(PyObject *pSelf, PyObject *pArgs) |
| 1677 | { |
| 1678 | pj_status_t status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1679 | PyObject *list; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1680 | pjsua_acc_info info[PJSUA_MAX_ACC]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1681 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1682 | |
| 1683 | PJ_UNUSED_ARG(pSelf); |
| 1684 | |
| 1685 | if (!PyArg_ParseTuple(pArgs, "")) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1686 | return NULL; |
| 1687 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1688 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1689 | c = PJ_ARRAY_SIZE(info); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1690 | status = pjsua_acc_enum_info(info, &c); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1691 | |
| 1692 | list = PyList_New(c); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1693 | for (i = 0; i < c; i++) { |
| 1694 | PyObj_pjsua_acc_info *obj; |
| 1695 | obj = (PyObj_pjsua_acc_info *) |
| 1696 | PyObj_pjsua_acc_info_new(&PyTyp_pjsua_acc_info, NULL, NULL); |
| 1697 | |
| 1698 | PyObj_pjsua_acc_info_import(obj, &info[i]); |
| 1699 | |
| 1700 | PyList_SetItem(list, i, (PyObject *)obj); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1701 | } |
| 1702 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1703 | return Py_BuildValue("O",list); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1704 | } |
| 1705 | |
| 1706 | /* |
| 1707 | * py_pjsua_acc_find_for_outgoing |
| 1708 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1709 | static PyObject *py_pjsua_acc_find_for_outgoing(PyObject *pSelf, |
| 1710 | PyObject *pArgs) |
| 1711 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1712 | int acc_id; |
| 1713 | PyObject * url; |
| 1714 | pj_str_t str; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1715 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1716 | PJ_UNUSED_ARG(pSelf); |
| 1717 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1718 | if (!PyArg_ParseTuple(pArgs, "O", &url)) |
| 1719 | { |
| 1720 | return NULL; |
| 1721 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1722 | str.ptr = PyString_AsString(url); |
| 1723 | str.slen = strlen(PyString_AsString(url)); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1724 | |
| 1725 | acc_id = pjsua_acc_find_for_outgoing(&str); |
| 1726 | |
| 1727 | return Py_BuildValue("i", acc_id); |
| 1728 | } |
| 1729 | |
| 1730 | /* |
| 1731 | * py_pjsua_acc_find_for_incoming |
| 1732 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1733 | static PyObject *py_pjsua_acc_find_for_incoming(PyObject *pSelf, |
| 1734 | PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1735 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1736 | int acc_id; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1737 | PyObject * tmpObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1738 | PyObj_pjsip_rx_data * obj; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1739 | pjsip_rx_data * rdata; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1740 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1741 | PJ_UNUSED_ARG(pSelf); |
| 1742 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1743 | if (!PyArg_ParseTuple(pArgs, "O", &tmpObj)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1744 | { |
| 1745 | return NULL; |
| 1746 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1747 | if (tmpObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1748 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1749 | obj = (PyObj_pjsip_rx_data *)tmpObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1750 | rdata = obj->rdata; |
| 1751 | acc_id = pjsua_acc_find_for_incoming(rdata); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1752 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1753 | acc_id = pjsua_acc_find_for_incoming(NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1754 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1755 | return Py_BuildValue("i", acc_id); |
| 1756 | } |
| 1757 | |
| 1758 | /* |
| 1759 | * py_pjsua_acc_create_uac_contact |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1760 | * !modified @ 061206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1761 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1762 | static PyObject *py_pjsua_acc_create_uac_contact(PyObject *pSelf, |
| 1763 | PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1764 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1765 | int status; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1766 | int acc_id; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1767 | PyObject * pObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1768 | PyObj_pj_pool * p; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1769 | pj_pool_t * pool; |
| 1770 | PyObject * strc; |
| 1771 | pj_str_t contact; |
| 1772 | PyObject * stru; |
| 1773 | pj_str_t uri; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1774 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1775 | PJ_UNUSED_ARG(pSelf); |
| 1776 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1777 | if (!PyArg_ParseTuple(pArgs, "OiO", &pObj, &acc_id, &stru)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1778 | { |
| 1779 | return NULL; |
| 1780 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1781 | if (pObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1782 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1783 | p = (PyObj_pj_pool *)pObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1784 | pool = p->pool; |
| 1785 | uri.ptr = PyString_AsString(stru); |
| 1786 | uri.slen = strlen(PyString_AsString(stru)); |
| 1787 | status = pjsua_acc_create_uac_contact(pool, &contact, acc_id, &uri); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1788 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1789 | status = pjsua_acc_create_uac_contact(NULL, &contact, acc_id, &uri); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1790 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1791 | strc = PyString_FromStringAndSize(contact.ptr, contact.slen); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1792 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1793 | return Py_BuildValue("O", strc); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1794 | } |
| 1795 | |
| 1796 | /* |
| 1797 | * py_pjsua_acc_create_uas_contact |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1798 | * !modified @ 061206 |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1799 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1800 | static PyObject *py_pjsua_acc_create_uas_contact(PyObject *pSelf, |
| 1801 | PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1802 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1803 | int status; |
| 1804 | int acc_id; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1805 | PyObject * pObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1806 | PyObj_pj_pool * p; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1807 | pj_pool_t * pool; |
| 1808 | PyObject * strc; |
| 1809 | pj_str_t contact; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1810 | PyObject * rObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1811 | PyObj_pjsip_rx_data * objr; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1812 | pjsip_rx_data * rdata; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1813 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1814 | PJ_UNUSED_ARG(pSelf); |
| 1815 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1816 | if (!PyArg_ParseTuple(pArgs, "OiO", &pObj, &acc_id, &rObj)) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1817 | { |
| 1818 | return NULL; |
| 1819 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1820 | if (pObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1821 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1822 | p = (PyObj_pj_pool *)pObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1823 | pool = p->pool; |
| 1824 | } else { |
| 1825 | pool = NULL; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1826 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1827 | if (rObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1828 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1829 | objr = (PyObj_pjsip_rx_data *)rObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1830 | rdata = objr->rdata; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1831 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1832 | rdata = NULL; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1833 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1834 | status = pjsua_acc_create_uas_contact(pool, &contact, acc_id, rdata); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1835 | strc = PyString_FromStringAndSize(contact.ptr, contact.slen); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1836 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1837 | return Py_BuildValue("O", strc); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1838 | } |
| 1839 | |
| 1840 | static char pjsua_acc_config_default_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1841 | "py_pjsua.Acc_Config py_pjsua.acc_config_default () " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1842 | "Call this function to initialize account config with default values."; |
| 1843 | static char pjsua_acc_get_count_doc[] = |
| 1844 | "int py_pjsua.acc_get_count () " |
| 1845 | "Get number of current accounts."; |
| 1846 | static char pjsua_acc_is_valid_doc[] = |
| 1847 | "int py_pjsua.acc_is_valid (int acc_id) " |
| 1848 | "Check if the specified account ID is valid."; |
| 1849 | static char pjsua_acc_set_default_doc[] = |
| 1850 | "int py_pjsua.acc_set_default (int acc_id) " |
| 1851 | "Set default account to be used when incoming " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1852 | "and outgoing requests doesn't match any accounts."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1853 | static char pjsua_acc_get_default_doc[] = |
| 1854 | "int py_pjsua.acc_get_default () " |
| 1855 | "Get default account."; |
| 1856 | static char pjsua_acc_add_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1857 | "int, int py_pjsua.acc_add (py_pjsua.Acc_Config cfg, " |
| 1858 | "int is_default) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1859 | "Add a new account to pjsua. PJSUA must have been initialized " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1860 | "(with pjsua_init()) before calling this function."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1861 | static char pjsua_acc_add_local_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1862 | "int,int py_pjsua.acc_add_local (int tid, " |
| 1863 | "int is_default) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1864 | "Add a local account. A local account is used to identify " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1865 | "local endpoint instead of a specific user, and for this reason, " |
| 1866 | "a transport ID is needed to obtain the local address information."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1867 | static char pjsua_acc_del_doc[] = |
| 1868 | "int py_pjsua.acc_del (int acc_id) " |
| 1869 | "Delete account."; |
| 1870 | static char pjsua_acc_modify_doc[] = |
| 1871 | "int py_pjsua.acc_modify (int acc_id, py_pjsua.Acc_Config cfg) " |
| 1872 | "Modify account information."; |
| 1873 | static char pjsua_acc_set_online_status_doc[] = |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1874 | "int py_pjsua.acc_set_online_status2(int acc_id, int is_online) " |
| 1875 | "Modify account's presence status to be advertised " |
| 1876 | "to remote/presence subscribers."; |
| 1877 | static char pjsua_acc_set_online_status2_doc[] = |
| 1878 | "int py_pjsua.acc_set_online_status (int acc_id, int is_online, " |
| 1879 | "int activity_id, string activity_text) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1880 | "Modify account's presence status to be advertised " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1881 | "to remote/presence subscribers."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1882 | static char pjsua_acc_set_registration_doc[] = |
| 1883 | "int py_pjsua.acc_set_registration (int acc_id, int renew) " |
| 1884 | "Update registration or perform unregistration."; |
| 1885 | static char pjsua_acc_get_info_doc[] = |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1886 | "py_pjsua.Acc_Info py_pjsua.acc_get_info (int acc_id) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1887 | "Get account information."; |
| 1888 | static char pjsua_enum_accs_doc[] = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1889 | "int[] py_pjsua.enum_accs () " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1890 | "Enum accounts all account ids."; |
| 1891 | static char pjsua_acc_enum_info_doc[] = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1892 | "py_pjsua.Acc_Info[] py_pjsua.acc_enum_info () " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1893 | "Enum accounts info."; |
| 1894 | static char pjsua_acc_find_for_outgoing_doc[] = |
| 1895 | "int py_pjsua.acc_find_for_outgoing (string url) " |
| 1896 | "This is an internal function to find the most appropriate account " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1897 | "to used to reach to the specified URL."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1898 | static char pjsua_acc_find_for_incoming_doc[] = |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1899 | "int py_pjsua.acc_find_for_incoming (PyObj_pjsip_rx_data rdata) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1900 | "This is an internal function to find the most appropriate account " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1901 | "to be used to handle incoming calls."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1902 | static char pjsua_acc_create_uac_contact_doc[] = |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1903 | "string py_pjsua.acc_create_uac_contact (PyObj_pj_pool pool, " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1904 | "int acc_id, string uri) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1905 | "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] | 1906 | "target URI for the specified account."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1907 | static char pjsua_acc_create_uas_contact_doc[] = |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1908 | "string py_pjsua.acc_create_uas_contact (PyObj_pj_pool pool, " |
| 1909 | "int acc_id, PyObj_pjsip_rx_data rdata) " |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1910 | "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] | 1911 | "in the incoming request."; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1912 | |
| 1913 | /* END OF LIB ACCOUNT */ |
| 1914 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1915 | /* LIB BUDDY */ |
| 1916 | |
| 1917 | |
| 1918 | |
| 1919 | /* |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1920 | * py_pjsua_buddy_config_default |
| 1921 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1922 | static PyObject *py_pjsua_buddy_config_default(PyObject *pSelf, |
| 1923 | PyObject *pArgs) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1924 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1925 | PyObj_pjsua_buddy_config *obj; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1926 | pjsua_buddy_config cfg; |
| 1927 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1928 | PJ_UNUSED_ARG(pSelf); |
| 1929 | |
| 1930 | if (!PyArg_ParseTuple(pArgs, "")) { |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1931 | return NULL; |
| 1932 | } |
| 1933 | |
| 1934 | pjsua_buddy_config_default(&cfg); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1935 | obj = (PyObj_pjsua_buddy_config *) |
| 1936 | PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_config, NULL, NULL); |
| 1937 | PyObj_pjsua_buddy_config_import(obj, &cfg); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 1938 | |
| 1939 | return (PyObject *)obj; |
| 1940 | } |
| 1941 | |
| 1942 | /* |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1943 | * py_pjsua_get_buddy_count |
| 1944 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1945 | static PyObject *py_pjsua_get_buddy_count(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1946 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1947 | int ret; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1948 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1949 | PJ_UNUSED_ARG(pSelf); |
| 1950 | |
| 1951 | if (!PyArg_ParseTuple(pArgs, "")) { |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1952 | return NULL; |
| 1953 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1954 | ret = pjsua_get_buddy_count(); |
| 1955 | |
| 1956 | return Py_BuildValue("i", ret); |
| 1957 | } |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1958 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1959 | /* |
| 1960 | * py_pjsua_buddy_is_valid |
| 1961 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1962 | static PyObject *py_pjsua_buddy_is_valid(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1963 | { |
| 1964 | int id; |
| 1965 | int is_valid; |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 1966 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1967 | PJ_UNUSED_ARG(pSelf); |
| 1968 | |
| 1969 | if (!PyArg_ParseTuple(pArgs, "i", &id)) { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1970 | return NULL; |
| 1971 | } |
| 1972 | is_valid = pjsua_buddy_is_valid(id); |
| 1973 | |
| 1974 | return Py_BuildValue("i", is_valid); |
| 1975 | } |
| 1976 | |
| 1977 | /* |
| 1978 | * py_pjsua_enum_buddies |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1979 | * !modified @ 241206 |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1980 | */ |
| 1981 | static PyObject *py_pjsua_enum_buddies(PyObject *pSelf, PyObject *pArgs) |
| 1982 | { |
| 1983 | pj_status_t status; |
| 1984 | PyObject *list; |
| 1985 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1986 | pjsua_buddy_id id[PJSUA_MAX_BUDDIES]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 1987 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1988 | |
| 1989 | PJ_UNUSED_ARG(pSelf); |
| 1990 | |
| 1991 | if (!PyArg_ParseTuple(pArgs, "")) { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1992 | return NULL; |
| 1993 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 1994 | c = PJ_ARRAY_SIZE(id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1995 | status = pjsua_enum_buddies(id, &c); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1996 | list = PyList_New(c); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 1997 | for (i = 0; i < c; i++) { |
| 1998 | PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 1999 | } |
| 2000 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2001 | return Py_BuildValue("O",list); |
| 2002 | } |
| 2003 | |
| 2004 | /* |
| 2005 | * py_pjsua_buddy_get_info |
| 2006 | * !modified @ 071206 |
| 2007 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2008 | static PyObject *py_pjsua_buddy_get_info(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2009 | { |
| 2010 | int buddy_id; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2011 | PyObj_pjsua_buddy_info * obj; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2012 | pjsua_buddy_info info; |
| 2013 | int status; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2014 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2015 | PJ_UNUSED_ARG(pSelf); |
| 2016 | |
| 2017 | if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2018 | return NULL; |
| 2019 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2020 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2021 | status = pjsua_buddy_get_info(buddy_id, &info); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2022 | if (status == PJ_SUCCESS) { |
| 2023 | obj = (PyObj_pjsua_buddy_info *) |
| 2024 | PyObj_pjsua_buddy_config_new(&PyTyp_pjsua_buddy_info,NULL,NULL); |
| 2025 | PyObj_pjsua_buddy_info_import(obj, &info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2026 | return Py_BuildValue("O", obj); |
| 2027 | } else { |
| 2028 | Py_INCREF(Py_None); |
| 2029 | return Py_None; |
| 2030 | } |
| 2031 | } |
| 2032 | |
| 2033 | /* |
| 2034 | * py_pjsua_buddy_add |
| 2035 | * !modified @ 061206 |
| 2036 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2037 | static PyObject *py_pjsua_buddy_add(PyObject *pSelf, PyObject *pArgs) |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2038 | { |
| 2039 | PyObject * bcObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2040 | int buddy_id; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2041 | int status; |
| 2042 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2043 | PJ_UNUSED_ARG(pSelf); |
| 2044 | |
| 2045 | if (!PyArg_ParseTuple(pArgs, "O", &bcObj)) { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2046 | return NULL; |
| 2047 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2048 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2049 | if (bcObj != Py_None) { |
| 2050 | pjsua_buddy_config cfg; |
| 2051 | PyObj_pjsua_buddy_config * bc; |
| 2052 | |
| 2053 | bc = (PyObj_pjsua_buddy_config *)bcObj; |
| 2054 | |
| 2055 | pjsua_buddy_config_default(&cfg); |
| 2056 | PyObj_pjsua_buddy_config_export(&cfg, bc); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2057 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2058 | status = pjsua_buddy_add(&cfg, &buddy_id); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2059 | } else { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2060 | status = PJ_EINVAL; |
| 2061 | buddy_id = PJSUA_INVALID_ID; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2062 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2063 | return Py_BuildValue("ii", status, buddy_id); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2064 | } |
| 2065 | |
| 2066 | /* |
| 2067 | * py_pjsua_buddy_del |
| 2068 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2069 | static PyObject *py_pjsua_buddy_del(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2070 | { |
| 2071 | int buddy_id; |
| 2072 | int status; |
| 2073 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2074 | PJ_UNUSED_ARG(pSelf); |
| 2075 | |
| 2076 | if (!PyArg_ParseTuple(pArgs, "i", &buddy_id)) { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2077 | return NULL; |
| 2078 | } |
| 2079 | |
| 2080 | |
| 2081 | status = pjsua_buddy_del(buddy_id); |
| 2082 | return Py_BuildValue("i", status); |
| 2083 | } |
| 2084 | |
| 2085 | /* |
| 2086 | * py_pjsua_buddy_subscribe_pres |
| 2087 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2088 | static PyObject *py_pjsua_buddy_subscribe_pres(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2089 | { |
| 2090 | int buddy_id; |
| 2091 | int status; |
| 2092 | int subscribe; |
| 2093 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2094 | PJ_UNUSED_ARG(pSelf); |
| 2095 | |
| 2096 | if (!PyArg_ParseTuple(pArgs, "ii", &buddy_id, &subscribe)) { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2097 | return NULL; |
| 2098 | } |
| 2099 | |
| 2100 | |
| 2101 | status = pjsua_buddy_subscribe_pres(buddy_id, subscribe); |
| 2102 | return Py_BuildValue("i", status); |
| 2103 | } |
| 2104 | |
| 2105 | /* |
| 2106 | * py_pjsua_pres_dump |
| 2107 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2108 | static PyObject *py_pjsua_pres_dump(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2109 | { |
| 2110 | int verbose; |
| 2111 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2112 | PJ_UNUSED_ARG(pSelf); |
| 2113 | |
| 2114 | if (!PyArg_ParseTuple(pArgs, "i", &verbose)) { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2115 | return NULL; |
| 2116 | } |
| 2117 | |
| 2118 | |
| 2119 | pjsua_pres_dump(verbose); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2120 | Py_INCREF(Py_None); |
| 2121 | return Py_None; |
| 2122 | } |
| 2123 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2124 | /* |
| 2125 | * py_pjsua_im_send |
| 2126 | * !modified @ 071206 |
| 2127 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2128 | static PyObject *py_pjsua_im_send(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2129 | { |
| 2130 | int status; |
| 2131 | int acc_id; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 2132 | pj_str_t * mime_type, tmp_mime_type; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2133 | pj_str_t to, content; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2134 | PyObject * st; |
| 2135 | PyObject * smt; |
| 2136 | PyObject * sc; |
| 2137 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2138 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2139 | PyObj_pjsua_msg_data * omd; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2140 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2141 | int user_data; |
| 2142 | pj_pool_t *pool; |
| 2143 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2144 | PJ_UNUSED_ARG(pSelf); |
| 2145 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2146 | if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id, |
| 2147 | &st, &smt, &sc, &omdObj, &user_data)) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2148 | { |
| 2149 | return NULL; |
| 2150 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2151 | if (smt != Py_None) { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 2152 | mime_type = &tmp_mime_type; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2153 | tmp_mime_type = PyString_to_pj_str(smt); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2154 | } else { |
| 2155 | mime_type = NULL; |
| 2156 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2157 | to = PyString_to_pj_str(st); |
| 2158 | content = PyString_to_pj_str(sc); |
| 2159 | |
| 2160 | if (omdObj != Py_None) { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2161 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2162 | omd = (PyObj_pjsua_msg_data *)omdObj; |
| 2163 | msg_data.content_type = PyString_to_pj_str(omd->content_type); |
| 2164 | msg_data.msg_body = PyString_to_pj_str(omd->msg_body); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2165 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2166 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2167 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2168 | status = pjsua_im_send(acc_id, &to, mime_type, |
| 2169 | &content, &msg_data, (void *)user_data); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2170 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2171 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2172 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2173 | status = pjsua_im_send(acc_id, &to, mime_type, |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2174 | &content, NULL, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2175 | } |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 2176 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2177 | return Py_BuildValue("i",status); |
| 2178 | } |
| 2179 | |
| 2180 | /* |
| 2181 | * py_pjsua_im_typing |
| 2182 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2183 | static PyObject *py_pjsua_im_typing(PyObject *pSelf, PyObject *pArgs) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2184 | { |
| 2185 | int status; |
| 2186 | int acc_id; |
| 2187 | pj_str_t to; |
| 2188 | PyObject * st; |
| 2189 | int is_typing; |
| 2190 | pjsua_msg_data msg_data; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2191 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2192 | PyObj_pjsua_msg_data * omd; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2193 | pj_pool_t * pool; |
| 2194 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2195 | PJ_UNUSED_ARG(pSelf); |
| 2196 | |
| 2197 | if (!PyArg_ParseTuple(pArgs, "iOiO", &acc_id, &st, &is_typing, &omdObj)) { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2198 | return NULL; |
| 2199 | } |
| 2200 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2201 | to = PyString_to_pj_str(st); |
| 2202 | |
| 2203 | if (omdObj != Py_None) { |
| 2204 | omd = (PyObj_pjsua_msg_data *)omdObj; |
| 2205 | msg_data.content_type = PyString_to_pj_str(omd->content_type); |
| 2206 | msg_data.msg_body = PyString_to_pj_str(omd->msg_body); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2207 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2208 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2209 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 2210 | status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data); |
| 2211 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2212 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 2213 | status = pjsua_im_typing(acc_id, &to, is_typing, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2214 | } |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2215 | return Py_BuildValue("i",status); |
| 2216 | } |
| 2217 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2218 | static char pjsua_buddy_config_default_doc[] = |
| 2219 | "py_pjsua.Buddy_Config py_pjsua.buddy_config_default () " |
| 2220 | "Set default values to the buddy config."; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2221 | static char pjsua_get_buddy_count_doc[] = |
| 2222 | "int py_pjsua.get_buddy_count () " |
| 2223 | "Get total number of buddies."; |
| 2224 | static char pjsua_buddy_is_valid_doc[] = |
| 2225 | "int py_pjsua.buddy_is_valid (int buddy_id) " |
| 2226 | "Check if buddy ID is valid."; |
| 2227 | static char pjsua_enum_buddies_doc[] = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2228 | "int[] py_pjsua.enum_buddies () " |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 2229 | "Enum buddy IDs."; |
| 2230 | static char pjsua_buddy_get_info_doc[] = |
| 2231 | "py_pjsua.Buddy_Info py_pjsua.buddy_get_info (int buddy_id) " |
| 2232 | "Get detailed buddy info."; |
| 2233 | static char pjsua_buddy_add_doc[] = |
| 2234 | "int,int py_pjsua.buddy_add (py_pjsua.Buddy_Config cfg) " |
| 2235 | "Add new buddy."; |
| 2236 | static char pjsua_buddy_del_doc[] = |
| 2237 | "int py_pjsua.buddy_del (int buddy_id) " |
| 2238 | "Delete buddy."; |
| 2239 | static char pjsua_buddy_subscribe_pres_doc[] = |
| 2240 | "int py_pjsua.buddy_subscribe_pres (int buddy_id, int subscribe) " |
| 2241 | "Enable/disable buddy's presence monitoring."; |
| 2242 | static char pjsua_pres_dump_doc[] = |
| 2243 | "void py_pjsua.pres_dump (int verbose) " |
| 2244 | "Dump presence subscriptions to log file."; |
| 2245 | static char pjsua_im_send_doc[] = |
| 2246 | "int py_pjsua.im_send (int acc_id, string to, string mime_type, " |
| 2247 | "string content, py_pjsua.Msg_Data msg_data, int user_data) " |
| 2248 | "Send instant messaging outside dialog, using the specified account " |
| 2249 | "for route set and authentication."; |
| 2250 | static char pjsua_im_typing_doc[] = |
| 2251 | "int py_pjsua.im_typing (int acc_id, string to, int is_typing, " |
| 2252 | "py_pjsua.Msg_Data msg_data) " |
| 2253 | "Send typing indication outside dialog."; |
| 2254 | |
| 2255 | /* END OF LIB BUDDY */ |
| 2256 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2257 | /* LIB MEDIA */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 2258 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 2259 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2260 | |
| 2261 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2262 | * PyObj_pjsua_codec_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2263 | * Codec Info |
| 2264 | * !modified @ 071206 |
| 2265 | */ |
| 2266 | typedef struct |
| 2267 | { |
| 2268 | PyObject_HEAD |
| 2269 | /* Type-specific fields go here. */ |
| 2270 | |
| 2271 | PyObject * codec_id; |
| 2272 | pj_uint8_t priority; |
| 2273 | char buf_[32]; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2274 | } PyObj_pjsua_codec_info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2275 | |
| 2276 | |
| 2277 | /* |
| 2278 | * codec_info_dealloc |
| 2279 | * deletes a codec_info from memory |
| 2280 | * !modified @ 071206 |
| 2281 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2282 | static void codec_info_dealloc(PyObj_pjsua_codec_info* self) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2283 | { |
| 2284 | Py_XDECREF(self->codec_id); |
| 2285 | |
| 2286 | self->ob_type->tp_free((PyObject*)self); |
| 2287 | } |
| 2288 | |
| 2289 | |
| 2290 | /* |
| 2291 | * codec_info_new |
| 2292 | * constructor for codec_info object |
| 2293 | * !modified @ 071206 |
| 2294 | */ |
| 2295 | static PyObject * codec_info_new(PyTypeObject *type, PyObject *args, |
| 2296 | PyObject *kwds) |
| 2297 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2298 | PyObj_pjsua_codec_info *self; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2299 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2300 | PJ_UNUSED_ARG(args); |
| 2301 | PJ_UNUSED_ARG(kwds); |
| 2302 | |
| 2303 | self = (PyObj_pjsua_codec_info *)type->tp_alloc(type, 0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2304 | if (self != NULL) |
| 2305 | { |
| 2306 | self->codec_id = PyString_FromString(""); |
| 2307 | if (self->codec_id == NULL) |
| 2308 | { |
| 2309 | Py_DECREF(self); |
| 2310 | return NULL; |
| 2311 | } |
| 2312 | |
| 2313 | |
| 2314 | } |
| 2315 | return (PyObject *)self; |
| 2316 | } |
| 2317 | |
| 2318 | /* |
| 2319 | * codec_info_members |
| 2320 | * !modified @ 071206 |
| 2321 | */ |
| 2322 | static PyMemberDef codec_info_members[] = |
| 2323 | { |
| 2324 | { |
| 2325 | "codec_id", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2326 | offsetof(PyObj_pjsua_codec_info, codec_id), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2327 | "Codec unique identification." |
| 2328 | }, |
| 2329 | |
| 2330 | { |
| 2331 | "priority", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2332 | offsetof(PyObj_pjsua_codec_info, priority), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2333 | "Codec priority (integer 0-255)." |
| 2334 | }, |
| 2335 | |
| 2336 | |
| 2337 | |
| 2338 | {NULL} /* Sentinel */ |
| 2339 | }; |
| 2340 | |
| 2341 | |
| 2342 | |
| 2343 | |
| 2344 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2345 | * PyTyp_pjsua_codec_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2346 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2347 | static PyTypeObject PyTyp_pjsua_codec_info = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2348 | { |
| 2349 | PyObject_HEAD_INIT(NULL) |
| 2350 | 0, /*ob_size*/ |
| 2351 | "py_pjsua.Codec_Info", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2352 | sizeof(PyObj_pjsua_codec_info), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2353 | 0, /*tp_itemsize*/ |
| 2354 | (destructor)codec_info_dealloc,/*tp_dealloc*/ |
| 2355 | 0, /*tp_print*/ |
| 2356 | 0, /*tp_getattr*/ |
| 2357 | 0, /*tp_setattr*/ |
| 2358 | 0, /*tp_compare*/ |
| 2359 | 0, /*tp_repr*/ |
| 2360 | 0, /*tp_as_number*/ |
| 2361 | 0, /*tp_as_sequence*/ |
| 2362 | 0, /*tp_as_mapping*/ |
| 2363 | 0, /*tp_hash */ |
| 2364 | 0, /*tp_call*/ |
| 2365 | 0, /*tp_str*/ |
| 2366 | 0, /*tp_getattro*/ |
| 2367 | 0, /*tp_setattro*/ |
| 2368 | 0, /*tp_as_buffer*/ |
| 2369 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2370 | "Codec Info objects", /* tp_doc */ |
| 2371 | 0, /* tp_traverse */ |
| 2372 | 0, /* tp_clear */ |
| 2373 | 0, /* tp_richcompare */ |
| 2374 | 0, /* tp_weaklistoffset */ |
| 2375 | 0, /* tp_iter */ |
| 2376 | 0, /* tp_iternext */ |
| 2377 | 0, /* tp_methods */ |
| 2378 | codec_info_members, /* tp_members */ |
| 2379 | 0, /* tp_getset */ |
| 2380 | 0, /* tp_base */ |
| 2381 | 0, /* tp_dict */ |
| 2382 | 0, /* tp_descr_get */ |
| 2383 | 0, /* tp_descr_set */ |
| 2384 | 0, /* tp_dictoffset */ |
| 2385 | 0, /* tp_init */ |
| 2386 | 0, /* tp_alloc */ |
| 2387 | codec_info_new, /* tp_new */ |
| 2388 | |
| 2389 | }; |
| 2390 | |
| 2391 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2392 | * PyObj_pjsua_conf_port_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2393 | * Conf Port Info |
| 2394 | */ |
| 2395 | typedef struct |
| 2396 | { |
| 2397 | PyObject_HEAD |
| 2398 | /* Type-specific fields go here. */ |
| 2399 | |
| 2400 | int slot_id; |
| 2401 | PyObject * name; |
| 2402 | unsigned clock_rate; |
| 2403 | unsigned channel_count; |
| 2404 | unsigned samples_per_frame; |
| 2405 | unsigned bits_per_sample; |
| 2406 | unsigned listener_cnt; |
| 2407 | PyListObject * listeners; |
| 2408 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2409 | } PyObj_pjsua_conf_port_info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2410 | |
| 2411 | |
| 2412 | /* |
| 2413 | * conf_port_info_dealloc |
| 2414 | * deletes a conf_port_info from memory |
| 2415 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2416 | static void conf_port_info_dealloc(PyObj_pjsua_conf_port_info* self) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2417 | { |
| 2418 | Py_XDECREF(self->name); |
| 2419 | Py_XDECREF(self->listeners); |
| 2420 | self->ob_type->tp_free((PyObject*)self); |
| 2421 | } |
| 2422 | |
| 2423 | |
| 2424 | /* |
| 2425 | * conf_port_info_new |
| 2426 | * constructor for conf_port_info object |
| 2427 | */ |
| 2428 | static PyObject * conf_port_info_new(PyTypeObject *type, PyObject *args, |
| 2429 | PyObject *kwds) |
| 2430 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2431 | PyObj_pjsua_conf_port_info *self; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2432 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2433 | PJ_UNUSED_ARG(args); |
| 2434 | PJ_UNUSED_ARG(kwds); |
| 2435 | |
| 2436 | self = (PyObj_pjsua_conf_port_info *)type->tp_alloc(type, 0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2437 | if (self != NULL) |
| 2438 | { |
| 2439 | self->name = PyString_FromString(""); |
| 2440 | if (self->name == NULL) |
| 2441 | { |
| 2442 | Py_DECREF(self); |
| 2443 | return NULL; |
| 2444 | } |
| 2445 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 2446 | self->listeners = (PyListObject *)PyList_New(PJSUA_MAX_CONF_PORTS); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2447 | if (self->listeners == NULL) |
| 2448 | { |
| 2449 | Py_DECREF(self); |
| 2450 | return NULL; |
| 2451 | } |
| 2452 | } |
| 2453 | return (PyObject *)self; |
| 2454 | } |
| 2455 | |
| 2456 | /* |
| 2457 | * conf_port_info_members |
| 2458 | */ |
| 2459 | static PyMemberDef conf_port_info_members[] = |
| 2460 | { |
| 2461 | { |
| 2462 | "slot_id", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2463 | offsetof(PyObj_pjsua_conf_port_info, slot_id), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2464 | "Conference port number." |
| 2465 | }, |
| 2466 | { |
| 2467 | "name", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2468 | offsetof(PyObj_pjsua_conf_port_info, name), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2469 | "Port name" |
| 2470 | }, |
| 2471 | { |
| 2472 | "clock_rate", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2473 | offsetof(PyObj_pjsua_conf_port_info, clock_rate), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2474 | "Clock rate" |
| 2475 | }, |
| 2476 | { |
| 2477 | "channel_count", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2478 | offsetof(PyObj_pjsua_conf_port_info, channel_count), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2479 | "Number of channels." |
| 2480 | }, |
| 2481 | { |
| 2482 | "samples_per_frame", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2483 | offsetof(PyObj_pjsua_conf_port_info, samples_per_frame), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2484 | "Samples per frame " |
| 2485 | }, |
| 2486 | { |
| 2487 | "bits_per_sample", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2488 | offsetof(PyObj_pjsua_conf_port_info, bits_per_sample), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2489 | "Bits per sample" |
| 2490 | }, |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 2491 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2492 | "listener_cnt", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2493 | offsetof(PyObj_pjsua_conf_port_info, listener_cnt), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2494 | "Number of listeners in the array." |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 2495 | }, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2496 | { |
| 2497 | "listeners", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2498 | offsetof(PyObj_pjsua_conf_port_info, listeners), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2499 | "Array of listeners (in other words, ports where this port " |
| 2500 | "is transmitting to" |
| 2501 | }, |
| 2502 | |
| 2503 | {NULL} /* Sentinel */ |
| 2504 | }; |
| 2505 | |
| 2506 | |
| 2507 | |
| 2508 | |
| 2509 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2510 | * PyTyp_pjsua_conf_port_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2511 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2512 | static PyTypeObject PyTyp_pjsua_conf_port_info = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2513 | { |
| 2514 | PyObject_HEAD_INIT(NULL) |
| 2515 | 0, /*ob_size*/ |
| 2516 | "py_pjsua.Conf_Port_Info", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2517 | sizeof(PyObj_pjsua_conf_port_info), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2518 | 0, /*tp_itemsize*/ |
| 2519 | (destructor)conf_port_info_dealloc,/*tp_dealloc*/ |
| 2520 | 0, /*tp_print*/ |
| 2521 | 0, /*tp_getattr*/ |
| 2522 | 0, /*tp_setattr*/ |
| 2523 | 0, /*tp_compare*/ |
| 2524 | 0, /*tp_repr*/ |
| 2525 | 0, /*tp_as_number*/ |
| 2526 | 0, /*tp_as_sequence*/ |
| 2527 | 0, /*tp_as_mapping*/ |
| 2528 | 0, /*tp_hash */ |
| 2529 | 0, /*tp_call*/ |
| 2530 | 0, /*tp_str*/ |
| 2531 | 0, /*tp_getattro*/ |
| 2532 | 0, /*tp_setattro*/ |
| 2533 | 0, /*tp_as_buffer*/ |
| 2534 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2535 | "Conf Port Info objects", /* tp_doc */ |
| 2536 | 0, /* tp_traverse */ |
| 2537 | 0, /* tp_clear */ |
| 2538 | 0, /* tp_richcompare */ |
| 2539 | 0, /* tp_weaklistoffset */ |
| 2540 | 0, /* tp_iter */ |
| 2541 | 0, /* tp_iternext */ |
| 2542 | 0, /* tp_methods */ |
| 2543 | conf_port_info_members, /* tp_members */ |
| 2544 | 0, /* tp_getset */ |
| 2545 | 0, /* tp_base */ |
| 2546 | 0, /* tp_dict */ |
| 2547 | 0, /* tp_descr_get */ |
| 2548 | 0, /* tp_descr_set */ |
| 2549 | 0, /* tp_dictoffset */ |
| 2550 | 0, /* tp_init */ |
| 2551 | 0, /* tp_alloc */ |
| 2552 | conf_port_info_new, /* tp_new */ |
| 2553 | |
| 2554 | }; |
| 2555 | |
| 2556 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2557 | * PyObj_pjmedia_port |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2558 | */ |
| 2559 | typedef struct |
| 2560 | { |
| 2561 | PyObject_HEAD |
| 2562 | /* Type-specific fields go here. */ |
| 2563 | pjmedia_port * port; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2564 | } PyObj_pjmedia_port; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2565 | |
| 2566 | |
| 2567 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2568 | * PyTyp_pjmedia_port |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2569 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2570 | static PyTypeObject PyTyp_pjmedia_port = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2571 | { |
| 2572 | PyObject_HEAD_INIT(NULL) |
| 2573 | 0, /*ob_size*/ |
| 2574 | "py_pjsua.PJMedia_Port", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2575 | sizeof(PyObj_pjmedia_port), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2576 | 0, /*tp_itemsize*/ |
| 2577 | 0, /*tp_dealloc*/ |
| 2578 | 0, /*tp_print*/ |
| 2579 | 0, /*tp_getattr*/ |
| 2580 | 0, /*tp_setattr*/ |
| 2581 | 0, /*tp_compare*/ |
| 2582 | 0, /*tp_repr*/ |
| 2583 | 0, /*tp_as_number*/ |
| 2584 | 0, /*tp_as_sequence*/ |
| 2585 | 0, /*tp_as_mapping*/ |
| 2586 | 0, /*tp_hash */ |
| 2587 | 0, /*tp_call*/ |
| 2588 | 0, /*tp_str*/ |
| 2589 | 0, /*tp_getattro*/ |
| 2590 | 0, /*tp_setattro*/ |
| 2591 | 0, /*tp_as_buffer*/ |
| 2592 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2593 | "pjmedia_port objects", /* tp_doc */ |
| 2594 | |
| 2595 | }; |
| 2596 | |
| 2597 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2598 | * PyObj_pjmedia_snd_dev_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2599 | * PJMedia Snd Dev Info |
| 2600 | */ |
| 2601 | typedef struct |
| 2602 | { |
| 2603 | PyObject_HEAD |
| 2604 | /* Type-specific fields go here. */ |
| 2605 | |
| 2606 | |
| 2607 | unsigned input_count; |
| 2608 | unsigned output_count; |
| 2609 | unsigned default_samples_per_sec; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 2610 | PyObject * name; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2611 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2612 | } PyObj_pjmedia_snd_dev_info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2613 | |
| 2614 | |
| 2615 | /* |
| 2616 | * pjmedia_snd_dev_info_dealloc |
| 2617 | * deletes a pjmedia_snd_dev_info from memory |
| 2618 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2619 | static void pjmedia_snd_dev_info_dealloc(PyObj_pjmedia_snd_dev_info* self) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2620 | { |
| 2621 | Py_XDECREF(self->name); |
| 2622 | self->ob_type->tp_free((PyObject*)self); |
| 2623 | } |
| 2624 | |
| 2625 | |
| 2626 | /* |
| 2627 | * pjmedia_snd_dev_info_new |
| 2628 | * constructor for pjmedia_snd_dev_info object |
| 2629 | */ |
| 2630 | static PyObject * pjmedia_snd_dev_info_new(PyTypeObject *type, PyObject *args, |
| 2631 | PyObject *kwds) |
| 2632 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2633 | PyObj_pjmedia_snd_dev_info *self; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2634 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2635 | PJ_UNUSED_ARG(args); |
| 2636 | PJ_UNUSED_ARG(kwds); |
| 2637 | |
| 2638 | self = (PyObj_pjmedia_snd_dev_info *)type->tp_alloc(type, 0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2639 | if (self != NULL) |
| 2640 | { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 2641 | self->name = PyString_FromString(""); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2642 | if (self->name == NULL) |
| 2643 | { |
| 2644 | Py_DECREF(self); |
| 2645 | return NULL; |
| 2646 | } |
| 2647 | |
| 2648 | } |
| 2649 | return (PyObject *)self; |
| 2650 | } |
| 2651 | |
| 2652 | /* |
| 2653 | * pjmedia_snd_dev_info_members |
| 2654 | */ |
| 2655 | static PyMemberDef pjmedia_snd_dev_info_members[] = |
| 2656 | { |
| 2657 | |
| 2658 | { |
| 2659 | "name", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2660 | offsetof(PyObj_pjmedia_snd_dev_info, name), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2661 | "Device name" |
| 2662 | }, |
| 2663 | { |
| 2664 | "input_count", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2665 | offsetof(PyObj_pjmedia_snd_dev_info, input_count), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2666 | "Max number of input channels" |
| 2667 | }, |
| 2668 | { |
| 2669 | "output_count", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2670 | offsetof(PyObj_pjmedia_snd_dev_info, output_count), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2671 | "Max number of output channels" |
| 2672 | }, |
| 2673 | { |
| 2674 | "default_samples_per_sec", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2675 | offsetof(PyObj_pjmedia_snd_dev_info, default_samples_per_sec), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2676 | "Default sampling rate." |
| 2677 | }, |
| 2678 | |
| 2679 | |
| 2680 | {NULL} /* Sentinel */ |
| 2681 | }; |
| 2682 | |
| 2683 | |
| 2684 | |
| 2685 | |
| 2686 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2687 | * PyTyp_pjmedia_snd_dev_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2688 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2689 | static PyTypeObject PyTyp_pjmedia_snd_dev_info = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2690 | { |
| 2691 | PyObject_HEAD_INIT(NULL) |
| 2692 | 0, /*ob_size*/ |
| 2693 | "py_pjsua.PJMedia_Snd_Dev_Info", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2694 | sizeof(PyObj_pjmedia_snd_dev_info), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2695 | 0, /*tp_itemsize*/ |
| 2696 | (destructor)pjmedia_snd_dev_info_dealloc,/*tp_dealloc*/ |
| 2697 | 0, /*tp_print*/ |
| 2698 | 0, /*tp_getattr*/ |
| 2699 | 0, /*tp_setattr*/ |
| 2700 | 0, /*tp_compare*/ |
| 2701 | 0, /*tp_repr*/ |
| 2702 | 0, /*tp_as_number*/ |
| 2703 | 0, /*tp_as_sequence*/ |
| 2704 | 0, /*tp_as_mapping*/ |
| 2705 | 0, /*tp_hash */ |
| 2706 | 0, /*tp_call*/ |
| 2707 | 0, /*tp_str*/ |
| 2708 | 0, /*tp_getattro*/ |
| 2709 | 0, /*tp_setattro*/ |
| 2710 | 0, /*tp_as_buffer*/ |
| 2711 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2712 | "PJMedia Snd Dev Info objects", /* tp_doc */ |
| 2713 | 0, /* tp_traverse */ |
| 2714 | 0, /* tp_clear */ |
| 2715 | 0, /* tp_richcompare */ |
| 2716 | 0, /* tp_weaklistoffset */ |
| 2717 | 0, /* tp_iter */ |
| 2718 | 0, /* tp_iternext */ |
| 2719 | 0, /* tp_methods */ |
| 2720 | pjmedia_snd_dev_info_members, /* tp_members */ |
| 2721 | 0, /* tp_getset */ |
| 2722 | 0, /* tp_base */ |
| 2723 | 0, /* tp_dict */ |
| 2724 | 0, /* tp_descr_get */ |
| 2725 | 0, /* tp_descr_set */ |
| 2726 | 0, /* tp_dictoffset */ |
| 2727 | 0, /* tp_init */ |
| 2728 | 0, /* tp_alloc */ |
| 2729 | pjmedia_snd_dev_info_new, /* tp_new */ |
| 2730 | |
| 2731 | }; |
| 2732 | |
| 2733 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2734 | * PyObj_pjmedia_codec_param_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2735 | * PJMedia Codec Param Info |
| 2736 | */ |
| 2737 | typedef struct |
| 2738 | { |
| 2739 | PyObject_HEAD |
| 2740 | /* Type-specific fields go here. */ |
| 2741 | |
| 2742 | unsigned clock_rate; |
| 2743 | unsigned channel_cnt; |
| 2744 | pj_uint32_t avg_bps; |
| 2745 | pj_uint16_t frm_ptime; |
| 2746 | pj_uint8_t pcm_bits_per_sample; |
| 2747 | pj_uint8_t pt; |
| 2748 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2749 | } PyObj_pjmedia_codec_param_info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2750 | |
| 2751 | |
| 2752 | |
| 2753 | /* |
| 2754 | * pjmedia_codec_param_info_members |
| 2755 | */ |
| 2756 | static PyMemberDef pjmedia_codec_param_info_members[] = |
| 2757 | { |
| 2758 | |
| 2759 | { |
| 2760 | "clock_rate", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2761 | offsetof(PyObj_pjmedia_codec_param_info, clock_rate), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2762 | "Sampling rate in Hz" |
| 2763 | }, |
| 2764 | { |
| 2765 | "channel_cnt", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2766 | offsetof(PyObj_pjmedia_codec_param_info, channel_cnt), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2767 | "Channel count" |
| 2768 | }, |
| 2769 | { |
| 2770 | "avg_bps", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2771 | offsetof(PyObj_pjmedia_codec_param_info, avg_bps), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2772 | "Average bandwidth in bits/sec" |
| 2773 | }, |
| 2774 | { |
| 2775 | "frm_ptime", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2776 | offsetof(PyObj_pjmedia_codec_param_info, frm_ptime), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2777 | "Base frame ptime in msec." |
| 2778 | }, |
| 2779 | { |
| 2780 | "pcm_bits_per_sample", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2781 | offsetof(PyObj_pjmedia_codec_param_info, pcm_bits_per_sample), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2782 | "Bits/sample in the PCM side" |
| 2783 | }, |
| 2784 | { |
| 2785 | "pt", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2786 | offsetof(PyObj_pjmedia_codec_param_info, pt), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2787 | "Payload type" |
| 2788 | }, |
| 2789 | |
| 2790 | {NULL} /* Sentinel */ |
| 2791 | }; |
| 2792 | |
| 2793 | |
| 2794 | |
| 2795 | |
| 2796 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2797 | * PyTyp_pjmedia_codec_param_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2798 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2799 | static PyTypeObject PyTyp_pjmedia_codec_param_info = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2800 | { |
| 2801 | PyObject_HEAD_INIT(NULL) |
| 2802 | 0, /*ob_size*/ |
| 2803 | "py_pjsua.PJMedia_Codec_Param_Info", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2804 | sizeof(PyObj_pjmedia_codec_param_info), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2805 | 0, /*tp_itemsize*/ |
| 2806 | 0,/*tp_dealloc*/ |
| 2807 | 0, /*tp_print*/ |
| 2808 | 0, /*tp_getattr*/ |
| 2809 | 0, /*tp_setattr*/ |
| 2810 | 0, /*tp_compare*/ |
| 2811 | 0, /*tp_repr*/ |
| 2812 | 0, /*tp_as_number*/ |
| 2813 | 0, /*tp_as_sequence*/ |
| 2814 | 0, /*tp_as_mapping*/ |
| 2815 | 0, /*tp_hash */ |
| 2816 | 0, /*tp_call*/ |
| 2817 | 0, /*tp_str*/ |
| 2818 | 0, /*tp_getattro*/ |
| 2819 | 0, /*tp_setattro*/ |
| 2820 | 0, /*tp_as_buffer*/ |
| 2821 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2822 | "PJMedia Codec Param Info objects", /* tp_doc */ |
| 2823 | 0, /* tp_traverse */ |
| 2824 | 0, /* tp_clear */ |
| 2825 | 0, /* tp_richcompare */ |
| 2826 | 0, /* tp_weaklistoffset */ |
| 2827 | 0, /* tp_iter */ |
| 2828 | 0, /* tp_iternext */ |
| 2829 | 0, /* tp_methods */ |
| 2830 | pjmedia_codec_param_info_members, /* tp_members */ |
| 2831 | |
| 2832 | |
| 2833 | }; |
| 2834 | |
| 2835 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2836 | * PyObj_pjmedia_codec_param_setting |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2837 | * PJMedia Codec Param Setting |
| 2838 | */ |
| 2839 | typedef struct |
| 2840 | { |
| 2841 | PyObject_HEAD |
| 2842 | /* Type-specific fields go here. */ |
| 2843 | pj_uint8_t frm_per_pkt; |
| 2844 | unsigned vad; |
| 2845 | unsigned cng; |
| 2846 | unsigned penh; |
| 2847 | unsigned plc; |
| 2848 | unsigned reserved; |
| 2849 | pj_uint8_t enc_fmtp_mode; |
| 2850 | pj_uint8_t dec_fmtp_mode; |
| 2851 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2852 | } PyObj_pjmedia_codec_param_setting; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2853 | |
| 2854 | |
| 2855 | |
| 2856 | /* |
| 2857 | * pjmedia_codec_param_setting_members |
| 2858 | */ |
| 2859 | static PyMemberDef pjmedia_codec_param_setting_members[] = |
| 2860 | { |
| 2861 | |
| 2862 | { |
| 2863 | "frm_per_pkt", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2864 | offsetof(PyObj_pjmedia_codec_param_setting, frm_per_pkt), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2865 | "Number of frames per packet" |
| 2866 | }, |
| 2867 | { |
| 2868 | "vad", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2869 | offsetof(PyObj_pjmedia_codec_param_setting, vad), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2870 | "Voice Activity Detector" |
| 2871 | }, |
| 2872 | { |
| 2873 | "penh", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2874 | offsetof(PyObj_pjmedia_codec_param_setting, penh), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2875 | "Perceptual Enhancement" |
| 2876 | }, |
| 2877 | { |
| 2878 | "plc", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2879 | offsetof(PyObj_pjmedia_codec_param_setting, plc), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2880 | "Packet loss concealment" |
| 2881 | }, |
| 2882 | { |
| 2883 | "reserved", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2884 | offsetof(PyObj_pjmedia_codec_param_setting, reserved), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2885 | "Reserved, must be zero" |
| 2886 | }, |
| 2887 | { |
| 2888 | "cng", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2889 | offsetof(PyObj_pjmedia_codec_param_setting, cng), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2890 | "Comfort Noise Generator" |
| 2891 | }, |
| 2892 | { |
| 2893 | "enc_fmtp_mode", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2894 | offsetof(PyObj_pjmedia_codec_param_setting, enc_fmtp_mode), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2895 | "Mode param in fmtp (def:0)" |
| 2896 | }, |
| 2897 | { |
| 2898 | "dec_fmtp_mode", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2899 | offsetof(PyObj_pjmedia_codec_param_setting, dec_fmtp_mode), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2900 | "Mode param in fmtp (def:0)" |
| 2901 | }, |
| 2902 | |
| 2903 | {NULL} /* Sentinel */ |
| 2904 | }; |
| 2905 | |
| 2906 | |
| 2907 | |
| 2908 | |
| 2909 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2910 | * PyTyp_pjmedia_codec_param_setting |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2911 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2912 | static PyTypeObject PyTyp_pjmedia_codec_param_setting = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2913 | { |
| 2914 | PyObject_HEAD_INIT(NULL) |
| 2915 | 0, /*ob_size*/ |
| 2916 | "py_pjsua.PJMedia_Codec_Param_Setting", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2917 | sizeof(PyObj_pjmedia_codec_param_setting), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2918 | 0, /*tp_itemsize*/ |
| 2919 | 0,/*tp_dealloc*/ |
| 2920 | 0, /*tp_print*/ |
| 2921 | 0, /*tp_getattr*/ |
| 2922 | 0, /*tp_setattr*/ |
| 2923 | 0, /*tp_compare*/ |
| 2924 | 0, /*tp_repr*/ |
| 2925 | 0, /*tp_as_number*/ |
| 2926 | 0, /*tp_as_sequence*/ |
| 2927 | 0, /*tp_as_mapping*/ |
| 2928 | 0, /*tp_hash */ |
| 2929 | 0, /*tp_call*/ |
| 2930 | 0, /*tp_str*/ |
| 2931 | 0, /*tp_getattro*/ |
| 2932 | 0, /*tp_setattro*/ |
| 2933 | 0, /*tp_as_buffer*/ |
| 2934 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2935 | "PJMedia Codec Param Setting objects", /* tp_doc */ |
| 2936 | 0, /* tp_traverse */ |
| 2937 | 0, /* tp_clear */ |
| 2938 | 0, /* tp_richcompare */ |
| 2939 | 0, /* tp_weaklistoffset */ |
| 2940 | 0, /* tp_iter */ |
| 2941 | 0, /* tp_iternext */ |
| 2942 | 0, /* tp_methods */ |
| 2943 | pjmedia_codec_param_setting_members, /* tp_members */ |
| 2944 | |
| 2945 | |
| 2946 | }; |
| 2947 | |
| 2948 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2949 | * PyObj_pjmedia_codec_param |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2950 | * PJMedia Codec Param |
| 2951 | */ |
| 2952 | typedef struct |
| 2953 | { |
| 2954 | PyObject_HEAD |
| 2955 | /* Type-specific fields go here. */ |
| 2956 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2957 | PyObj_pjmedia_codec_param_info * info; |
| 2958 | PyObj_pjmedia_codec_param_setting * setting; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2959 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2960 | } PyObj_pjmedia_codec_param; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2961 | |
| 2962 | |
| 2963 | /* |
| 2964 | * pjmedia_codec_param_dealloc |
| 2965 | * deletes a pjmedia_codec_param from memory |
| 2966 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2967 | static void pjmedia_codec_param_dealloc(PyObj_pjmedia_codec_param* self) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2968 | { |
| 2969 | Py_XDECREF(self->info); |
| 2970 | Py_XDECREF(self->setting); |
| 2971 | self->ob_type->tp_free((PyObject*)self); |
| 2972 | } |
| 2973 | |
| 2974 | |
| 2975 | /* |
| 2976 | * pjmedia_codec_param_new |
| 2977 | * constructor for pjmedia_codec_param object |
| 2978 | */ |
| 2979 | static PyObject * pjmedia_codec_param_new(PyTypeObject *type, PyObject *args, |
| 2980 | PyObject *kwds) |
| 2981 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2982 | PyObj_pjmedia_codec_param *self; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2983 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2984 | PJ_UNUSED_ARG(args); |
| 2985 | PJ_UNUSED_ARG(kwds); |
| 2986 | |
| 2987 | self = (PyObj_pjmedia_codec_param *)type->tp_alloc(type, 0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2988 | if (self != NULL) |
| 2989 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2990 | self->info = (PyObj_pjmedia_codec_param_info *) |
| 2991 | PyType_GenericNew(&PyTyp_pjmedia_codec_param_info, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2992 | if (self->info == NULL) |
| 2993 | { |
| 2994 | Py_DECREF(self); |
| 2995 | return NULL; |
| 2996 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 2997 | self->setting = (PyObj_pjmedia_codec_param_setting *) |
| 2998 | PyType_GenericNew(&PyTyp_pjmedia_codec_param_setting, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2999 | if (self->setting == NULL) |
| 3000 | { |
| 3001 | Py_DECREF(self); |
| 3002 | return NULL; |
| 3003 | } |
| 3004 | } |
| 3005 | return (PyObject *)self; |
| 3006 | } |
| 3007 | |
| 3008 | /* |
| 3009 | * pjmedia_codec_param_members |
| 3010 | */ |
| 3011 | static PyMemberDef pjmedia_codec_param_members[] = |
| 3012 | { |
| 3013 | |
| 3014 | { |
| 3015 | "info", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3016 | offsetof(PyObj_pjmedia_codec_param, info), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3017 | "The 'info' part of codec param describes the capability of the codec," |
| 3018 | " and the value should NOT be changed by application." |
| 3019 | }, |
| 3020 | { |
| 3021 | "setting", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3022 | offsetof(PyObj_pjmedia_codec_param, setting), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3023 | "The 'setting' part of codec param describes various settings to be " |
| 3024 | "applied to the codec. When the codec param is retrieved from the " |
| 3025 | "codec or codec factory, the values of these will be filled by " |
| 3026 | "the capability of the codec. Any features that are supported by " |
| 3027 | "the codec (e.g. vad or plc) will be turned on, so that application " |
| 3028 | "can query which capabilities are supported by the codec. " |
| 3029 | "Application may change the settings here before instantiating " |
| 3030 | "the codec/stream." |
| 3031 | }, |
| 3032 | |
| 3033 | {NULL} /* Sentinel */ |
| 3034 | }; |
| 3035 | |
| 3036 | |
| 3037 | |
| 3038 | |
| 3039 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3040 | * PyTyp_pjmedia_codec_param |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3041 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3042 | static PyTypeObject PyTyp_pjmedia_codec_param = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3043 | { |
| 3044 | PyObject_HEAD_INIT(NULL) |
| 3045 | 0, /*ob_size*/ |
| 3046 | "py_pjsua.PJMedia_Codec_Param", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3047 | sizeof(PyObj_pjmedia_codec_param), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3048 | 0, /*tp_itemsize*/ |
| 3049 | (destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/ |
| 3050 | 0, /*tp_print*/ |
| 3051 | 0, /*tp_getattr*/ |
| 3052 | 0, /*tp_setattr*/ |
| 3053 | 0, /*tp_compare*/ |
| 3054 | 0, /*tp_repr*/ |
| 3055 | 0, /*tp_as_number*/ |
| 3056 | 0, /*tp_as_sequence*/ |
| 3057 | 0, /*tp_as_mapping*/ |
| 3058 | 0, /*tp_hash */ |
| 3059 | 0, /*tp_call*/ |
| 3060 | 0, /*tp_str*/ |
| 3061 | 0, /*tp_getattro*/ |
| 3062 | 0, /*tp_setattro*/ |
| 3063 | 0, /*tp_as_buffer*/ |
| 3064 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3065 | "PJMedia Codec Param objects", /* tp_doc */ |
| 3066 | 0, /* tp_traverse */ |
| 3067 | 0, /* tp_clear */ |
| 3068 | 0, /* tp_richcompare */ |
| 3069 | 0, /* tp_weaklistoffset */ |
| 3070 | 0, /* tp_iter */ |
| 3071 | 0, /* tp_iternext */ |
| 3072 | 0, /* tp_methods */ |
| 3073 | pjmedia_codec_param_members, /* tp_members */ |
| 3074 | 0, /* tp_getset */ |
| 3075 | 0, /* tp_base */ |
| 3076 | 0, /* tp_dict */ |
| 3077 | 0, /* tp_descr_get */ |
| 3078 | 0, /* tp_descr_set */ |
| 3079 | 0, /* tp_dictoffset */ |
| 3080 | 0, /* tp_init */ |
| 3081 | 0, /* tp_alloc */ |
| 3082 | pjmedia_codec_param_new, /* tp_new */ |
| 3083 | |
| 3084 | }; |
| 3085 | |
| 3086 | /* |
| 3087 | * py_pjsua_conf_get_max_ports |
| 3088 | */ |
| 3089 | static PyObject *py_pjsua_conf_get_max_ports |
| 3090 | (PyObject *pSelf, PyObject *pArgs) |
| 3091 | { |
| 3092 | int ret; |
| 3093 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3094 | PJ_UNUSED_ARG(pSelf); |
| 3095 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3096 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3097 | { |
| 3098 | return NULL; |
| 3099 | } |
| 3100 | ret = pjsua_conf_get_max_ports(); |
| 3101 | |
| 3102 | return Py_BuildValue("i", ret); |
| 3103 | } |
| 3104 | |
| 3105 | /* |
| 3106 | * py_pjsua_conf_get_active_ports |
| 3107 | */ |
| 3108 | static PyObject *py_pjsua_conf_get_active_ports |
| 3109 | (PyObject *pSelf, PyObject *pArgs) |
| 3110 | { |
| 3111 | int ret; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3112 | |
| 3113 | PJ_UNUSED_ARG(pSelf); |
| 3114 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3115 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3116 | { |
| 3117 | return NULL; |
| 3118 | } |
| 3119 | ret = pjsua_conf_get_active_ports(); |
| 3120 | |
| 3121 | return Py_BuildValue("i", ret); |
| 3122 | } |
| 3123 | |
| 3124 | /* |
| 3125 | * py_pjsua_enum_conf_ports |
| 3126 | * !modified @ 241206 |
| 3127 | */ |
| 3128 | static PyObject *py_pjsua_enum_conf_ports(PyObject *pSelf, PyObject *pArgs) |
| 3129 | { |
| 3130 | pj_status_t status; |
| 3131 | PyObject *list; |
| 3132 | |
| 3133 | pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3134 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3135 | |
| 3136 | PJ_UNUSED_ARG(pSelf); |
| 3137 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3138 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3139 | { |
| 3140 | return NULL; |
| 3141 | } |
| 3142 | |
| 3143 | c = PJ_ARRAY_SIZE(id); |
| 3144 | status = pjsua_enum_conf_ports(id, &c); |
| 3145 | |
| 3146 | list = PyList_New(c); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3147 | for (i = 0; i < c; i++) |
| 3148 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3149 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3150 | if (ret == -1) |
| 3151 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3152 | return NULL; |
| 3153 | } |
| 3154 | } |
| 3155 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3156 | return Py_BuildValue("O",list); |
| 3157 | } |
| 3158 | |
| 3159 | /* |
| 3160 | * py_pjsua_conf_get_port_info |
| 3161 | */ |
| 3162 | static PyObject *py_pjsua_conf_get_port_info |
| 3163 | (PyObject *pSelf, PyObject *pArgs) |
| 3164 | { |
| 3165 | int id; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3166 | PyObj_pjsua_conf_port_info * obj; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3167 | pjsua_conf_port_info info; |
| 3168 | int status; |
| 3169 | int i; |
| 3170 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3171 | PJ_UNUSED_ARG(pSelf); |
| 3172 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3173 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3174 | { |
| 3175 | return NULL; |
| 3176 | } |
| 3177 | |
| 3178 | |
| 3179 | status = pjsua_conf_get_port_info(id, &info); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3180 | obj = (PyObj_pjsua_conf_port_info *)conf_port_info_new |
| 3181 | (&PyTyp_pjsua_conf_port_info,NULL,NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3182 | obj->bits_per_sample = info.bits_per_sample; |
| 3183 | obj->channel_count = info.bits_per_sample; |
| 3184 | obj->clock_rate = info.clock_rate; |
| 3185 | obj->listener_cnt = info.listener_cnt; |
| 3186 | obj->name = PyString_FromStringAndSize(info.name.ptr, info.name.slen); |
| 3187 | obj->samples_per_frame = info.samples_per_frame; |
| 3188 | obj->slot_id = info.slot_id; |
| 3189 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3190 | for (i = 0; i < PJSUA_MAX_CONF_PORTS; i++) { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3191 | PyObject * item = Py_BuildValue("i",info.listeners[i]); |
| 3192 | PyList_SetItem((PyObject *)obj->listeners, i, item); |
| 3193 | } |
| 3194 | return Py_BuildValue("O", obj); |
| 3195 | } |
| 3196 | |
| 3197 | /* |
| 3198 | * py_pjsua_conf_add_port |
| 3199 | */ |
| 3200 | static PyObject *py_pjsua_conf_add_port |
| 3201 | (PyObject *pSelf, PyObject *pArgs) |
| 3202 | { |
| 3203 | int p_id; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3204 | PyObject * oportObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3205 | PyObj_pjmedia_port * oport; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3206 | pjmedia_port * port; |
| 3207 | PyObject * opoolObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3208 | PyObj_pj_pool * opool; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3209 | pj_pool_t * pool; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3210 | |
| 3211 | int status; |
| 3212 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3213 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3214 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3215 | if (!PyArg_ParseTuple(pArgs, "OO", &opoolObj, &oportObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3216 | { |
| 3217 | return NULL; |
| 3218 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3219 | if (opoolObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3220 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3221 | opool = (PyObj_pj_pool *)opoolObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3222 | pool = opool->pool; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3223 | } else { |
| 3224 | opool = NULL; |
| 3225 | pool = NULL; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3226 | } |
| 3227 | if (oportObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3228 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3229 | oport = (PyObj_pjmedia_port *)oportObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3230 | port = oport->port; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3231 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3232 | oport = NULL; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3233 | port = NULL; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3234 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3235 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3236 | status = pjsua_conf_add_port(pool, port, &p_id); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3237 | |
| 3238 | |
| 3239 | return Py_BuildValue("ii", status, p_id); |
| 3240 | } |
| 3241 | |
| 3242 | /* |
| 3243 | * py_pjsua_conf_remove_port |
| 3244 | */ |
| 3245 | static PyObject *py_pjsua_conf_remove_port |
| 3246 | (PyObject *pSelf, PyObject *pArgs) |
| 3247 | { |
| 3248 | int id; |
| 3249 | int status; |
| 3250 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3251 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3252 | |
| 3253 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3254 | { |
| 3255 | return NULL; |
| 3256 | } |
| 3257 | |
| 3258 | status = pjsua_conf_remove_port(id); |
| 3259 | |
| 3260 | |
| 3261 | return Py_BuildValue("i", status); |
| 3262 | } |
| 3263 | |
| 3264 | /* |
| 3265 | * py_pjsua_conf_connect |
| 3266 | */ |
| 3267 | static PyObject *py_pjsua_conf_connect |
| 3268 | (PyObject *pSelf, PyObject *pArgs) |
| 3269 | { |
| 3270 | int source, sink; |
| 3271 | int status; |
| 3272 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3273 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3274 | |
| 3275 | if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) |
| 3276 | { |
| 3277 | return NULL; |
| 3278 | } |
| 3279 | |
| 3280 | status = pjsua_conf_connect(source, sink); |
| 3281 | |
| 3282 | |
| 3283 | return Py_BuildValue("i", status); |
| 3284 | } |
| 3285 | |
| 3286 | /* |
| 3287 | * py_pjsua_conf_disconnect |
| 3288 | */ |
| 3289 | static PyObject *py_pjsua_conf_disconnect |
| 3290 | (PyObject *pSelf, PyObject *pArgs) |
| 3291 | { |
| 3292 | int source, sink; |
| 3293 | int status; |
| 3294 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3295 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3296 | |
| 3297 | if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) |
| 3298 | { |
| 3299 | return NULL; |
| 3300 | } |
| 3301 | |
| 3302 | status = pjsua_conf_disconnect(source, sink); |
| 3303 | |
| 3304 | |
| 3305 | return Py_BuildValue("i", status); |
| 3306 | } |
| 3307 | |
| 3308 | /* |
| 3309 | * py_pjsua_player_create |
| 3310 | */ |
| 3311 | static PyObject *py_pjsua_player_create |
| 3312 | (PyObject *pSelf, PyObject *pArgs) |
| 3313 | { |
| 3314 | int id; |
| 3315 | int options; |
| 3316 | PyObject * filename; |
| 3317 | pj_str_t str; |
| 3318 | int status; |
| 3319 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3320 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3321 | |
| 3322 | if (!PyArg_ParseTuple(pArgs, "Oi", &filename, &options)) |
| 3323 | { |
| 3324 | return NULL; |
| 3325 | } |
| 3326 | str.ptr = PyString_AsString(filename); |
| 3327 | str.slen = strlen(PyString_AsString(filename)); |
| 3328 | status = pjsua_player_create(&str, options, &id); |
| 3329 | |
| 3330 | return Py_BuildValue("ii", status, id); |
| 3331 | } |
| 3332 | |
| 3333 | /* |
| 3334 | * py_pjsua_player_get_conf_port |
| 3335 | */ |
| 3336 | static PyObject *py_pjsua_player_get_conf_port |
| 3337 | (PyObject *pSelf, PyObject *pArgs) |
| 3338 | { |
| 3339 | |
| 3340 | int id, port_id; |
| 3341 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3342 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3343 | |
| 3344 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3345 | { |
| 3346 | return NULL; |
| 3347 | } |
| 3348 | |
| 3349 | port_id = pjsua_player_get_conf_port(id); |
| 3350 | |
| 3351 | |
| 3352 | return Py_BuildValue("i", port_id); |
| 3353 | } |
| 3354 | |
| 3355 | /* |
| 3356 | * py_pjsua_player_set_pos |
| 3357 | */ |
| 3358 | static PyObject *py_pjsua_player_set_pos |
| 3359 | (PyObject *pSelf, PyObject *pArgs) |
| 3360 | { |
| 3361 | int id; |
| 3362 | pj_uint32_t samples; |
| 3363 | int status; |
| 3364 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3365 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3366 | |
| 3367 | if (!PyArg_ParseTuple(pArgs, "iI", &id, &samples)) |
| 3368 | { |
| 3369 | return NULL; |
| 3370 | } |
| 3371 | |
| 3372 | status = pjsua_player_set_pos(id, samples); |
| 3373 | |
| 3374 | |
| 3375 | return Py_BuildValue("i", status); |
| 3376 | } |
| 3377 | |
| 3378 | /* |
| 3379 | * py_pjsua_player_destroy |
| 3380 | */ |
| 3381 | static PyObject *py_pjsua_player_destroy |
| 3382 | (PyObject *pSelf, PyObject *pArgs) |
| 3383 | { |
| 3384 | int id; |
| 3385 | int status; |
| 3386 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3387 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3388 | |
| 3389 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3390 | { |
| 3391 | return NULL; |
| 3392 | } |
| 3393 | |
| 3394 | status = pjsua_player_destroy(id); |
| 3395 | |
| 3396 | |
| 3397 | return Py_BuildValue("i", status); |
| 3398 | } |
| 3399 | |
| 3400 | /* |
| 3401 | * py_pjsua_recorder_create |
| 3402 | * !modified @ 261206 |
| 3403 | */ |
| 3404 | static PyObject *py_pjsua_recorder_create |
| 3405 | (PyObject *pSelf, PyObject *pArgs) |
| 3406 | { |
| 3407 | int p_id; |
| 3408 | int options; |
| 3409 | int max_size; |
| 3410 | PyObject * filename; |
| 3411 | pj_str_t str; |
| 3412 | PyObject * enc_param; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3413 | pj_str_t strparam; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3414 | int enc_type; |
| 3415 | |
| 3416 | int status; |
| 3417 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3418 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3419 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3420 | if (!PyArg_ParseTuple(pArgs, "OiOii", &filename, |
| 3421 | &enc_type, &enc_param, &max_size, &options)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3422 | { |
| 3423 | return NULL; |
| 3424 | } |
| 3425 | str.ptr = PyString_AsString(filename); |
| 3426 | str.slen = strlen(PyString_AsString(filename)); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 3427 | if (enc_param != Py_None) |
| 3428 | { |
| 3429 | strparam.ptr = PyString_AsString(enc_param); |
| 3430 | strparam.slen = strlen(PyString_AsString(enc_param)); |
| 3431 | status = pjsua_recorder_create |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3432 | (&str, enc_type, NULL, max_size, options, &p_id); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 3433 | } else { |
| 3434 | status = pjsua_recorder_create |
| 3435 | (&str, enc_type, NULL, max_size, options, &p_id); |
| 3436 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3437 | return Py_BuildValue("ii", status, p_id); |
| 3438 | } |
| 3439 | |
| 3440 | /* |
| 3441 | * py_pjsua_recorder_get_conf_port |
| 3442 | */ |
| 3443 | static PyObject *py_pjsua_recorder_get_conf_port |
| 3444 | (PyObject *pSelf, PyObject *pArgs) |
| 3445 | { |
| 3446 | |
| 3447 | int id, port_id; |
| 3448 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3449 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3450 | |
| 3451 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3452 | { |
| 3453 | return NULL; |
| 3454 | } |
| 3455 | |
| 3456 | port_id = pjsua_recorder_get_conf_port(id); |
| 3457 | |
| 3458 | |
| 3459 | return Py_BuildValue("i", port_id); |
| 3460 | } |
| 3461 | |
| 3462 | /* |
| 3463 | * py_pjsua_recorder_destroy |
| 3464 | */ |
| 3465 | static PyObject *py_pjsua_recorder_destroy |
| 3466 | (PyObject *pSelf, PyObject *pArgs) |
| 3467 | { |
| 3468 | int id; |
| 3469 | int status; |
| 3470 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3471 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3472 | |
| 3473 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3474 | { |
| 3475 | return NULL; |
| 3476 | } |
| 3477 | |
| 3478 | status = pjsua_recorder_destroy(id); |
| 3479 | |
| 3480 | |
| 3481 | return Py_BuildValue("i", status); |
| 3482 | } |
| 3483 | |
| 3484 | /* |
| 3485 | * py_pjsua_enum_snd_devs |
| 3486 | */ |
| 3487 | static PyObject *py_pjsua_enum_snd_devs(PyObject *pSelf, PyObject *pArgs) |
| 3488 | { |
| 3489 | pj_status_t status; |
| 3490 | PyObject *list; |
| 3491 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3492 | pjmedia_snd_dev_info info[SND_DEV_NUM]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3493 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3494 | |
| 3495 | PJ_UNUSED_ARG(pSelf); |
| 3496 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame] | 3497 | if (!PyArg_ParseTuple(pArgs, "")) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3498 | { |
| 3499 | return NULL; |
| 3500 | } |
| 3501 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame] | 3502 | c = PJ_ARRAY_SIZE(info); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3503 | status = pjsua_enum_snd_devs(info, &c); |
| 3504 | |
| 3505 | list = PyList_New(c); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3506 | for (i = 0; i < c; i++) |
| 3507 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3508 | int ret; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3509 | int j; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 3510 | char * str; |
| 3511 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3512 | PyObj_pjmedia_snd_dev_info * obj; |
| 3513 | obj = (PyObj_pjmedia_snd_dev_info *)pjmedia_snd_dev_info_new |
| 3514 | (&PyTyp_pjmedia_snd_dev_info, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3515 | obj->default_samples_per_sec = info[i].default_samples_per_sec; |
| 3516 | obj->input_count = info[i].input_count; |
| 3517 | obj->output_count = info[i].output_count; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 3518 | str = (char *)malloc(SND_NAME_LEN * sizeof(char)); |
| 3519 | memset(str, 0, SND_NAME_LEN); |
| 3520 | for (j = 0; j < SND_NAME_LEN; j++) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3521 | { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 3522 | str[j] = info[i].name[j]; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3523 | } |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 3524 | obj->name = PyString_FromStringAndSize(str, SND_NAME_LEN); |
| 3525 | free(str); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3526 | ret = PyList_SetItem(list, i, (PyObject *)obj); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3527 | if (ret == -1) |
| 3528 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3529 | return NULL; |
| 3530 | } |
| 3531 | } |
| 3532 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3533 | return Py_BuildValue("O",list); |
| 3534 | } |
| 3535 | |
| 3536 | /* |
| 3537 | * py_pjsua_get_snd_dev |
| 3538 | */ |
| 3539 | static PyObject *py_pjsua_get_snd_dev |
| 3540 | (PyObject *pSelf, PyObject *pArgs) |
| 3541 | { |
| 3542 | int capture_dev, playback_dev; |
| 3543 | int status; |
| 3544 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3545 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3546 | |
| 3547 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3548 | { |
| 3549 | return NULL; |
| 3550 | } |
| 3551 | |
| 3552 | status = pjsua_get_snd_dev(&capture_dev, &playback_dev); |
| 3553 | |
| 3554 | |
| 3555 | return Py_BuildValue("ii", capture_dev, playback_dev); |
| 3556 | } |
| 3557 | |
| 3558 | /* |
| 3559 | * py_pjsua_set_snd_dev |
| 3560 | */ |
| 3561 | static PyObject *py_pjsua_set_snd_dev |
| 3562 | (PyObject *pSelf, PyObject *pArgs) |
| 3563 | { |
| 3564 | int capture_dev, playback_dev; |
| 3565 | int status; |
| 3566 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3567 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3568 | |
| 3569 | if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev)) |
| 3570 | { |
| 3571 | return NULL; |
| 3572 | } |
| 3573 | |
| 3574 | status = pjsua_set_snd_dev(capture_dev, playback_dev); |
| 3575 | |
| 3576 | |
| 3577 | return Py_BuildValue("i", status); |
| 3578 | } |
| 3579 | |
| 3580 | /* |
| 3581 | * py_pjsua_set_null_snd_dev |
| 3582 | */ |
| 3583 | static PyObject *py_pjsua_set_null_snd_dev |
| 3584 | (PyObject *pSelf, PyObject *pArgs) |
| 3585 | { |
| 3586 | |
| 3587 | int status; |
| 3588 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3589 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3590 | |
| 3591 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3592 | { |
| 3593 | return NULL; |
| 3594 | } |
| 3595 | |
| 3596 | status = pjsua_set_null_snd_dev(); |
| 3597 | |
| 3598 | |
| 3599 | return Py_BuildValue("i", status); |
| 3600 | } |
| 3601 | |
| 3602 | /* |
| 3603 | * py_pjsua_set_no_snd_dev |
| 3604 | */ |
| 3605 | static PyObject *py_pjsua_set_no_snd_dev |
| 3606 | (PyObject *pSelf, PyObject *pArgs) |
| 3607 | { |
| 3608 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3609 | PyObj_pjmedia_port * obj; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3610 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3611 | PJ_UNUSED_ARG(pSelf); |
| 3612 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3613 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3614 | { |
| 3615 | return NULL; |
| 3616 | } |
| 3617 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3618 | obj = (PyObj_pjmedia_port *)PyType_GenericNew |
| 3619 | (&PyTyp_pjmedia_port, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3620 | obj->port = pjsua_set_no_snd_dev(); |
| 3621 | return Py_BuildValue("O", obj); |
| 3622 | } |
| 3623 | |
| 3624 | /* |
| 3625 | * py_pjsua_set_ec |
| 3626 | */ |
| 3627 | static PyObject *py_pjsua_set_ec |
| 3628 | (PyObject *pSelf, PyObject *pArgs) |
| 3629 | { |
| 3630 | int options; |
| 3631 | int tail_ms; |
| 3632 | int status; |
| 3633 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3634 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3635 | |
| 3636 | if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options)) |
| 3637 | { |
| 3638 | return NULL; |
| 3639 | } |
| 3640 | |
| 3641 | status = pjsua_set_ec(tail_ms, options); |
| 3642 | |
| 3643 | |
| 3644 | return Py_BuildValue("i", status); |
| 3645 | } |
| 3646 | |
| 3647 | /* |
| 3648 | * py_pjsua_get_ec_tail |
| 3649 | */ |
| 3650 | static PyObject *py_pjsua_get_ec_tail |
| 3651 | (PyObject *pSelf, PyObject *pArgs) |
| 3652 | { |
| 3653 | |
| 3654 | int status; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3655 | unsigned p_tail_ms; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3656 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3657 | PJ_UNUSED_ARG(pSelf); |
| 3658 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3659 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3660 | { |
| 3661 | return NULL; |
| 3662 | } |
| 3663 | |
| 3664 | status = pjsua_get_ec_tail(&p_tail_ms); |
| 3665 | |
| 3666 | |
| 3667 | return Py_BuildValue("i", p_tail_ms); |
| 3668 | } |
| 3669 | |
| 3670 | /* |
| 3671 | * py_pjsua_enum_codecs |
| 3672 | * !modified @ 261206 |
| 3673 | */ |
| 3674 | static PyObject *py_pjsua_enum_codecs(PyObject *pSelf, PyObject *pArgs) |
| 3675 | { |
| 3676 | pj_status_t status; |
| 3677 | PyObject *list; |
| 3678 | |
| 3679 | pjsua_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3680 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3681 | |
| 3682 | PJ_UNUSED_ARG(pSelf); |
| 3683 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3684 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3685 | { |
| 3686 | return NULL; |
| 3687 | } |
| 3688 | |
| 3689 | c = PJ_ARRAY_SIZE(info); |
| 3690 | status = pjsua_enum_codecs(info, &c); |
| 3691 | |
| 3692 | list = PyList_New(c); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3693 | for (i = 0; i < c; i++) |
| 3694 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3695 | int ret; |
| 3696 | int j; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3697 | PyObj_pjsua_codec_info * obj; |
| 3698 | obj = (PyObj_pjsua_codec_info *)codec_info_new |
| 3699 | (&PyTyp_pjsua_codec_info, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3700 | obj->codec_id = PyString_FromStringAndSize |
| 3701 | (info[i].codec_id.ptr, info[i].codec_id.slen); |
| 3702 | obj->priority = info[i].priority; |
| 3703 | for (j = 0; j < 32; j++) |
| 3704 | { |
| 3705 | obj->buf_[j] = info[i].buf_[j]; |
| 3706 | } |
| 3707 | ret = PyList_SetItem(list, i, (PyObject *)obj); |
| 3708 | if (ret == -1) { |
| 3709 | return NULL; |
| 3710 | } |
| 3711 | } |
| 3712 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3713 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3714 | return Py_BuildValue("O",list); |
| 3715 | } |
| 3716 | |
| 3717 | /* |
| 3718 | * py_pjsua_codec_set_priority |
| 3719 | */ |
| 3720 | static PyObject *py_pjsua_codec_set_priority |
| 3721 | (PyObject *pSelf, PyObject *pArgs) |
| 3722 | { |
| 3723 | |
| 3724 | int status; |
| 3725 | PyObject * id; |
| 3726 | pj_str_t str; |
| 3727 | pj_uint8_t priority; |
| 3728 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3729 | PJ_UNUSED_ARG(pSelf); |
| 3730 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3731 | if (!PyArg_ParseTuple(pArgs, "OB", &id, &priority)) |
| 3732 | { |
| 3733 | return NULL; |
| 3734 | } |
| 3735 | str.ptr = PyString_AsString(id); |
| 3736 | str.slen = strlen(PyString_AsString(id)); |
| 3737 | status = pjsua_codec_set_priority(&str, priority); |
| 3738 | |
| 3739 | |
| 3740 | return Py_BuildValue("i", status); |
| 3741 | } |
| 3742 | |
| 3743 | /* |
| 3744 | * py_pjsua_codec_get_param |
| 3745 | */ |
| 3746 | static PyObject *py_pjsua_codec_get_param |
| 3747 | (PyObject *pSelf, PyObject *pArgs) |
| 3748 | { |
| 3749 | |
| 3750 | int status; |
| 3751 | PyObject * id; |
| 3752 | pj_str_t str; |
| 3753 | pjmedia_codec_param param; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3754 | PyObj_pjmedia_codec_param *obj; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3755 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3756 | PJ_UNUSED_ARG(pSelf); |
| 3757 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3758 | if (!PyArg_ParseTuple(pArgs, "O", &id)) |
| 3759 | { |
| 3760 | return NULL; |
| 3761 | } |
| 3762 | str.ptr = PyString_AsString(id); |
| 3763 | str.slen = strlen(PyString_AsString(id)); |
| 3764 | status = pjsua_codec_get_param(&str, ¶m); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3765 | obj = (PyObj_pjmedia_codec_param *)pjmedia_codec_param_new |
| 3766 | (&PyTyp_pjmedia_codec_param, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3767 | obj->info->avg_bps = param.info.avg_bps; |
| 3768 | obj->info->channel_cnt = param.info.channel_cnt; |
| 3769 | obj->info->clock_rate = param.info.clock_rate; |
| 3770 | obj->info->frm_ptime = param.info.frm_ptime; |
| 3771 | obj->info->pcm_bits_per_sample = param.info.pcm_bits_per_sample; |
| 3772 | obj->info->pt = param.info.pt; |
| 3773 | obj->setting->cng = param.setting.cng; |
| 3774 | obj->setting->dec_fmtp_mode = param.setting.dec_fmtp_mode; |
| 3775 | obj->setting->enc_fmtp_mode = param.setting.enc_fmtp_mode; |
| 3776 | obj->setting->frm_per_pkt = param.setting.frm_per_pkt; |
| 3777 | obj->setting->penh = param.setting.penh; |
| 3778 | obj->setting->plc = param.setting.plc; |
| 3779 | obj->setting->reserved = param.setting.reserved; |
| 3780 | obj->setting->vad = param.setting.vad; |
| 3781 | |
| 3782 | return Py_BuildValue("O", obj); |
| 3783 | } |
| 3784 | /* |
| 3785 | * py_pjsua_codec_set_param |
| 3786 | */ |
| 3787 | static PyObject *py_pjsua_codec_set_param |
| 3788 | (PyObject *pSelf, PyObject *pArgs) |
| 3789 | { |
| 3790 | |
| 3791 | int status; |
| 3792 | PyObject * id; |
| 3793 | pj_str_t str; |
| 3794 | pjmedia_codec_param param; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3795 | PyObject * tmpObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3796 | PyObj_pjmedia_codec_param *obj; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3797 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3798 | PJ_UNUSED_ARG(pSelf); |
| 3799 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3800 | if (!PyArg_ParseTuple(pArgs, "OO", &id, &tmpObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3801 | { |
| 3802 | return NULL; |
| 3803 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3804 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3805 | str.ptr = PyString_AsString(id); |
| 3806 | str.slen = strlen(PyString_AsString(id)); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3807 | if (tmpObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3808 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3809 | obj = (PyObj_pjmedia_codec_param *)tmpObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3810 | param.info.avg_bps = obj->info->avg_bps; |
| 3811 | param.info.channel_cnt = obj->info->channel_cnt; |
| 3812 | param.info.clock_rate = obj->info->clock_rate; |
| 3813 | param.info.frm_ptime = obj->info->frm_ptime; |
| 3814 | param.info.pcm_bits_per_sample = obj->info->pcm_bits_per_sample; |
| 3815 | param.info.pt = obj->info->pt; |
| 3816 | param.setting.cng = obj->setting->cng; |
| 3817 | param.setting.dec_fmtp_mode = obj->setting->dec_fmtp_mode; |
| 3818 | param.setting.enc_fmtp_mode = obj->setting->enc_fmtp_mode; |
| 3819 | param.setting.frm_per_pkt = obj->setting->frm_per_pkt; |
| 3820 | param.setting.penh = obj->setting->penh; |
| 3821 | param.setting.plc = obj->setting->plc; |
| 3822 | param.setting.reserved = obj->setting->reserved; |
| 3823 | param.setting.vad = obj->setting->vad; |
| 3824 | status = pjsua_codec_set_param(&str, ¶m); |
| 3825 | } else { |
| 3826 | status = pjsua_codec_set_param(&str, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3827 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3828 | return Py_BuildValue("i", status); |
| 3829 | } |
| 3830 | |
| 3831 | static char pjsua_conf_get_max_ports_doc[] = |
| 3832 | "int py_pjsua.conf_get_max_ports () " |
| 3833 | "Get maxinum number of conference ports."; |
| 3834 | static char pjsua_conf_get_active_ports_doc[] = |
| 3835 | "int py_pjsua.conf_get_active_ports () " |
| 3836 | "Get current number of active ports in the bridge."; |
| 3837 | static char pjsua_enum_conf_ports_doc[] = |
| 3838 | "int[] py_pjsua.enum_conf_ports () " |
| 3839 | "Enumerate all conference ports."; |
| 3840 | static char pjsua_conf_get_port_info_doc[] = |
| 3841 | "py_pjsua.Conf_Port_Info py_pjsua.conf_get_port_info (int id) " |
| 3842 | "Get information about the specified conference port"; |
| 3843 | static char pjsua_conf_add_port_doc[] = |
| 3844 | "int, int py_pjsua.conf_add_port " |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3845 | "(py_pjsua.Pj_Pool pool, py_pjsua.PJMedia_Port port) " |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3846 | "Add arbitrary media port to PJSUA's conference bridge. " |
| 3847 | "Application can use this function to add the media port " |
| 3848 | "that it creates. For media ports that are created by PJSUA-LIB " |
| 3849 | "(such as calls, file player, or file recorder), PJSUA-LIB will " |
| 3850 | "automatically add the port to the bridge."; |
| 3851 | static char pjsua_conf_remove_port_doc[] = |
| 3852 | "int py_pjsua.conf_remove_port (int id) " |
| 3853 | "Remove arbitrary slot from the conference bridge. " |
| 3854 | "Application should only call this function " |
| 3855 | "if it registered the port manually."; |
| 3856 | static char pjsua_conf_connect_doc[] = |
| 3857 | "int py_pjsua.conf_connect (int source, int sink) " |
| 3858 | "Establish unidirectional media flow from souce to sink. " |
| 3859 | "One source may transmit to multiple destinations/sink. " |
| 3860 | "And if multiple sources are transmitting to the same sink, " |
| 3861 | "the media will be mixed together. Source and sink may refer " |
| 3862 | "to the same ID, effectively looping the media. " |
| 3863 | "If bidirectional media flow is desired, application " |
| 3864 | "needs to call this function twice, with the second " |
| 3865 | "one having the arguments reversed."; |
| 3866 | static char pjsua_conf_disconnect_doc[] = |
| 3867 | "int py_pjsua.conf_disconnect (int source, int sink) " |
| 3868 | "Disconnect media flow from the source to destination port."; |
| 3869 | static char pjsua_player_create_doc[] = |
| 3870 | "int, int py_pjsua.player_create (string filename, int options) " |
| 3871 | "Create a file player, and automatically connect " |
| 3872 | "this player to the conference bridge."; |
| 3873 | static char pjsua_player_get_conf_port_doc[] = |
| 3874 | "int py_pjsua.player_get_conf_port (int) " |
| 3875 | "Get conference port ID associated with player."; |
| 3876 | static char pjsua_player_set_pos_doc[] = |
| 3877 | "int py_pjsua.player_set_pos (int id, int samples) " |
| 3878 | "Set playback position."; |
| 3879 | static char pjsua_player_destroy_doc[] = |
| 3880 | "int py_pjsua.player_destroy (int id) " |
| 3881 | "Close the file, remove the player from the bridge, " |
| 3882 | "and free resources associated with the file player."; |
| 3883 | static char pjsua_recorder_create_doc[] = |
| 3884 | "int, int py_pjsua.recorder_create (string filename, " |
| 3885 | "int enc_type, int enc_param, int max_size, int options) " |
| 3886 | "Create a file recorder, and automatically connect this recorder " |
| 3887 | "to the conference bridge. The recorder currently supports recording " |
| 3888 | "WAV file, and on Windows, MP3 file. The type of the recorder to use " |
| 3889 | "is determined by the extension of the file (e.g. '.wav' or '.mp3')."; |
| 3890 | static char pjsua_recorder_get_conf_port_doc[] = |
| 3891 | "int py_pjsua.recorder_get_conf_port (int id) " |
| 3892 | "Get conference port associated with recorder."; |
| 3893 | static char pjsua_recorder_destroy_doc[] = |
| 3894 | "int py_pjsua.recorder_destroy (int id) " |
| 3895 | "Destroy recorder (this will complete recording)."; |
| 3896 | static char pjsua_enum_snd_devs_doc[] = |
| 3897 | "py_pjsua.PJMedia_Snd_Dev_Info[] py_pjsua.enum_snd_devs (int count) " |
| 3898 | "Enum sound devices."; |
| 3899 | static char pjsua_get_snd_dev_doc[] = |
| 3900 | "int, int py_pjsua.get_snd_dev () " |
| 3901 | "Get currently active sound devices. " |
| 3902 | "If sound devices has not been created " |
| 3903 | "(for example when pjsua_start() is not called), " |
| 3904 | "it is possible that the function returns " |
| 3905 | "PJ_SUCCESS with -1 as device IDs."; |
| 3906 | static char pjsua_set_snd_dev_doc[] = |
| 3907 | "int py_pjsua.set_snd_dev (int capture_dev, int playback_dev) " |
| 3908 | "Select or change sound device. Application may call this function " |
| 3909 | "at any time to replace current sound device."; |
| 3910 | static char pjsua_set_null_snd_dev_doc[] = |
| 3911 | "int py_pjsua.set_null_snd_dev () " |
| 3912 | "Set pjsua to use null sound device. The null sound device only " |
| 3913 | "provides the timing needed by the conference bridge, and will not " |
| 3914 | "interract with any hardware."; |
| 3915 | static char pjsua_set_no_snd_dev_doc[] = |
| 3916 | "py_pjsua.PJMedia_Port py_pjsua.set_no_snd_dev () " |
| 3917 | "Disconnect the main conference bridge from any sound devices, " |
| 3918 | "and let application connect the bridge to it's " |
| 3919 | "own sound device/master port."; |
| 3920 | static char pjsua_set_ec_doc[] = |
| 3921 | "int py_pjsua.set_ec (int tail_ms, int options) " |
| 3922 | "Configure the echo canceller tail length of the sound port."; |
| 3923 | static char pjsua_get_ec_tail_doc[] = |
| 3924 | "int py_pjsua.get_ec_tail () " |
| 3925 | "Get current echo canceller tail length."; |
| 3926 | static char pjsua_enum_codecs_doc[] = |
| 3927 | "py_pjsua.Codec_Info[] py_pjsua.enum_codecs () " |
| 3928 | "Enum all supported codecs in the system."; |
| 3929 | static char pjsua_codec_set_priority_doc[] = |
| 3930 | "int py_pjsua.codec_set_priority (string id, int priority) " |
| 3931 | "Change codec priority."; |
| 3932 | static char pjsua_codec_get_param_doc[] = |
| 3933 | "py_pjsua.PJMedia_Codec_Param py_pjsua.codec_get_param (string id) " |
| 3934 | "Get codec parameters"; |
| 3935 | static char pjsua_codec_set_param_doc[] = |
| 3936 | "int py_pjsua.codec_set_param (string id, " |
| 3937 | "py_pjsua.PJMedia_Codec_Param param) " |
| 3938 | "Set codec parameters."; |
| 3939 | |
| 3940 | /* END OF LIB MEDIA */ |
| 3941 | |
| 3942 | /* LIB CALL */ |
| 3943 | |
| 3944 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3945 | * PyObj_pj_time_val |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3946 | * PJ Time Val |
| 3947 | */ |
| 3948 | typedef struct |
| 3949 | { |
| 3950 | PyObject_HEAD |
| 3951 | /* Type-specific fields go here. */ |
| 3952 | long sec; |
| 3953 | long msec; |
| 3954 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3955 | } PyObj_pj_time_val; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3956 | |
| 3957 | |
| 3958 | |
| 3959 | /* |
| 3960 | * pj_time_val_members |
| 3961 | */ |
| 3962 | static PyMemberDef pj_time_val_members[] = |
| 3963 | { |
| 3964 | |
| 3965 | { |
| 3966 | "sec", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3967 | offsetof(PyObj_pj_time_val, sec), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3968 | "The seconds part of the time" |
| 3969 | }, |
| 3970 | { |
| 3971 | "msec", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3972 | offsetof(PyObj_pj_time_val, sec), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3973 | "The milliseconds fraction of the time" |
| 3974 | }, |
| 3975 | |
| 3976 | |
| 3977 | {NULL} /* Sentinel */ |
| 3978 | }; |
| 3979 | |
| 3980 | |
| 3981 | |
| 3982 | |
| 3983 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3984 | * PyTyp_pj_time_val |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3985 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3986 | static PyTypeObject PyTyp_pj_time_val = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3987 | { |
| 3988 | PyObject_HEAD_INIT(NULL) |
| 3989 | 0, /*ob_size*/ |
| 3990 | "py_pjsua.PJ_Time_Val", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 3991 | sizeof(PyObj_pj_time_val), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3992 | 0, /*tp_itemsize*/ |
| 3993 | 0,/*tp_dealloc*/ |
| 3994 | 0, /*tp_print*/ |
| 3995 | 0, /*tp_getattr*/ |
| 3996 | 0, /*tp_setattr*/ |
| 3997 | 0, /*tp_compare*/ |
| 3998 | 0, /*tp_repr*/ |
| 3999 | 0, /*tp_as_number*/ |
| 4000 | 0, /*tp_as_sequence*/ |
| 4001 | 0, /*tp_as_mapping*/ |
| 4002 | 0, /*tp_hash */ |
| 4003 | 0, /*tp_call*/ |
| 4004 | 0, /*tp_str*/ |
| 4005 | 0, /*tp_getattro*/ |
| 4006 | 0, /*tp_setattro*/ |
| 4007 | 0, /*tp_as_buffer*/ |
| 4008 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 4009 | "PJ Time Val objects", /* tp_doc */ |
| 4010 | 0, /* tp_traverse */ |
| 4011 | 0, /* tp_clear */ |
| 4012 | 0, /* tp_richcompare */ |
| 4013 | 0, /* tp_weaklistoffset */ |
| 4014 | 0, /* tp_iter */ |
| 4015 | 0, /* tp_iternext */ |
| 4016 | 0, /* tp_methods */ |
| 4017 | pj_time_val_members, /* tp_members */ |
| 4018 | |
| 4019 | |
| 4020 | }; |
| 4021 | |
| 4022 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4023 | * PyObj_pjsua_call_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4024 | * Call Info |
| 4025 | */ |
| 4026 | typedef struct |
| 4027 | { |
| 4028 | PyObject_HEAD |
| 4029 | /* Type-specific fields go here. */ |
| 4030 | |
| 4031 | int id; |
| 4032 | int role; |
| 4033 | int acc_id; |
| 4034 | PyObject * local_info; |
| 4035 | PyObject * local_contact; |
| 4036 | PyObject * remote_info; |
| 4037 | PyObject * remote_contact; |
| 4038 | PyObject * call_id; |
| 4039 | int state; |
| 4040 | PyObject * state_text; |
| 4041 | int last_status; |
| 4042 | PyObject * last_status_text; |
| 4043 | int media_status; |
| 4044 | int media_dir; |
| 4045 | int conf_slot; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4046 | PyObj_pj_time_val * connect_duration; |
| 4047 | PyObj_pj_time_val * total_duration; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4048 | struct { |
| 4049 | char local_info[128]; |
| 4050 | char local_contact[128]; |
| 4051 | char remote_info[128]; |
| 4052 | char remote_contact[128]; |
| 4053 | char call_id[128]; |
| 4054 | char last_status_text[128]; |
| 4055 | } buf_; |
| 4056 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4057 | } PyObj_pjsua_call_info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4058 | |
| 4059 | |
| 4060 | /* |
| 4061 | * call_info_dealloc |
| 4062 | * deletes a call_info from memory |
| 4063 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4064 | static void call_info_dealloc(PyObj_pjsua_call_info* self) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4065 | { |
| 4066 | Py_XDECREF(self->local_info); |
| 4067 | Py_XDECREF(self->local_contact); |
| 4068 | Py_XDECREF(self->remote_info); |
| 4069 | Py_XDECREF(self->remote_contact); |
| 4070 | Py_XDECREF(self->call_id); |
| 4071 | Py_XDECREF(self->state_text); |
| 4072 | Py_XDECREF(self->last_status_text); |
| 4073 | Py_XDECREF(self->connect_duration); |
| 4074 | Py_XDECREF(self->total_duration); |
| 4075 | self->ob_type->tp_free((PyObject*)self); |
| 4076 | } |
| 4077 | |
| 4078 | |
| 4079 | /* |
| 4080 | * call_info_new |
| 4081 | * constructor for call_info object |
| 4082 | */ |
| 4083 | static PyObject * call_info_new(PyTypeObject *type, PyObject *args, |
| 4084 | PyObject *kwds) |
| 4085 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4086 | PyObj_pjsua_call_info *self; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4087 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4088 | PJ_UNUSED_ARG(args); |
| 4089 | PJ_UNUSED_ARG(kwds); |
| 4090 | |
| 4091 | self = (PyObj_pjsua_call_info *)type->tp_alloc(type, 0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4092 | if (self != NULL) |
| 4093 | { |
| 4094 | self->local_info = PyString_FromString(""); |
| 4095 | if (self->local_info == NULL) |
| 4096 | { |
| 4097 | Py_DECREF(self); |
| 4098 | return NULL; |
| 4099 | } |
| 4100 | self->local_contact = PyString_FromString(""); |
| 4101 | if (self->local_contact == NULL) |
| 4102 | { |
| 4103 | Py_DECREF(self); |
| 4104 | return NULL; |
| 4105 | } |
| 4106 | self->remote_info = PyString_FromString(""); |
| 4107 | if (self->remote_info == NULL) |
| 4108 | { |
| 4109 | Py_DECREF(self); |
| 4110 | return NULL; |
| 4111 | } |
| 4112 | self->remote_contact = PyString_FromString(""); |
| 4113 | if (self->remote_contact == NULL) |
| 4114 | { |
| 4115 | Py_DECREF(self); |
| 4116 | return NULL; |
| 4117 | } |
| 4118 | self->call_id = PyString_FromString(""); |
| 4119 | if (self->call_id == NULL) |
| 4120 | { |
| 4121 | Py_DECREF(self); |
| 4122 | return NULL; |
| 4123 | } |
| 4124 | self->state_text = PyString_FromString(""); |
| 4125 | if (self->state_text == NULL) |
| 4126 | { |
| 4127 | Py_DECREF(self); |
| 4128 | return NULL; |
| 4129 | } |
| 4130 | self->last_status_text = PyString_FromString(""); |
| 4131 | if (self->last_status_text == NULL) |
| 4132 | { |
| 4133 | Py_DECREF(self); |
| 4134 | return NULL; |
| 4135 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4136 | self->connect_duration = (PyObj_pj_time_val *)PyType_GenericNew |
| 4137 | (&PyTyp_pj_time_val,NULL,NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4138 | if (self->connect_duration == NULL) |
| 4139 | { |
| 4140 | Py_DECREF(self); |
| 4141 | return NULL; |
| 4142 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4143 | self->total_duration = (PyObj_pj_time_val *)PyType_GenericNew |
| 4144 | (&PyTyp_pj_time_val,NULL,NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4145 | if (self->total_duration == NULL) |
| 4146 | { |
| 4147 | Py_DECREF(self); |
| 4148 | return NULL; |
| 4149 | } |
| 4150 | } |
| 4151 | return (PyObject *)self; |
| 4152 | } |
| 4153 | |
| 4154 | /* |
| 4155 | * call_info_members |
| 4156 | */ |
| 4157 | static PyMemberDef call_info_members[] = |
| 4158 | { |
| 4159 | { |
| 4160 | "id", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4161 | offsetof(PyObj_pjsua_call_info, id), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4162 | "Call identification" |
| 4163 | }, |
| 4164 | { |
| 4165 | "role", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4166 | offsetof(PyObj_pjsua_call_info, role), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4167 | "Initial call role (UAC == caller)" |
| 4168 | }, |
| 4169 | { |
| 4170 | "acc_id", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4171 | offsetof(PyObj_pjsua_call_info, acc_id), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4172 | "The account ID where this call belongs." |
| 4173 | }, |
| 4174 | { |
| 4175 | "local_info", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4176 | offsetof(PyObj_pjsua_call_info, local_info), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4177 | "Local URI" |
| 4178 | }, |
| 4179 | { |
| 4180 | "local_contact", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4181 | offsetof(PyObj_pjsua_call_info, local_contact), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4182 | "Local Contact" |
| 4183 | }, |
| 4184 | { |
| 4185 | "remote_info", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4186 | offsetof(PyObj_pjsua_call_info, remote_info), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4187 | "Remote URI" |
| 4188 | }, |
| 4189 | { |
| 4190 | "remote_contact", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4191 | offsetof(PyObj_pjsua_call_info, remote_contact), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4192 | "Remote Contact" |
| 4193 | }, |
| 4194 | { |
| 4195 | "call_id", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4196 | offsetof(PyObj_pjsua_call_info, call_id), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4197 | "Dialog Call-ID string" |
| 4198 | }, |
| 4199 | { |
| 4200 | "state", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4201 | offsetof(PyObj_pjsua_call_info, state), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4202 | "Call state" |
| 4203 | }, |
| 4204 | { |
| 4205 | "state_text", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4206 | offsetof(PyObj_pjsua_call_info, state_text), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4207 | "Text describing the state " |
| 4208 | }, |
| 4209 | { |
| 4210 | "last_status", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4211 | offsetof(PyObj_pjsua_call_info, last_status), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4212 | "Last status code heard, which can be used as cause code" |
| 4213 | }, |
| 4214 | { |
| 4215 | "last_status_text", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4216 | offsetof(PyObj_pjsua_call_info, last_status_text), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4217 | "The reason phrase describing the status." |
| 4218 | }, |
| 4219 | { |
| 4220 | "media_status", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4221 | offsetof(PyObj_pjsua_call_info, media_status), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4222 | "Call media status." |
| 4223 | }, |
| 4224 | { |
| 4225 | "media_dir", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4226 | offsetof(PyObj_pjsua_call_info, media_dir), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4227 | "Media direction" |
| 4228 | }, |
| 4229 | { |
| 4230 | "conf_slot", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4231 | offsetof(PyObj_pjsua_call_info, conf_slot), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4232 | "The conference port number for the call" |
| 4233 | }, |
| 4234 | { |
| 4235 | "connect_duration", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4236 | offsetof(PyObj_pjsua_call_info, connect_duration), 0, |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4237 | "Up-to-date call connected duration(zero when call is not established)" |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4238 | }, |
| 4239 | { |
| 4240 | "total_duration", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4241 | offsetof(PyObj_pjsua_call_info, total_duration), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4242 | "Total call duration, including set-up time" |
| 4243 | }, |
| 4244 | |
| 4245 | {NULL} /* Sentinel */ |
| 4246 | }; |
| 4247 | |
| 4248 | |
| 4249 | |
| 4250 | |
| 4251 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4252 | * PyTyp_pjsua_call_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4253 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4254 | static PyTypeObject PyTyp_pjsua_call_info = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4255 | { |
| 4256 | PyObject_HEAD_INIT(NULL) |
| 4257 | 0, /*ob_size*/ |
| 4258 | "py_pjsua.Call_Info", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4259 | sizeof(PyObj_pjsua_call_info), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4260 | 0, /*tp_itemsize*/ |
| 4261 | (destructor)call_info_dealloc,/*tp_dealloc*/ |
| 4262 | 0, /*tp_print*/ |
| 4263 | 0, /*tp_getattr*/ |
| 4264 | 0, /*tp_setattr*/ |
| 4265 | 0, /*tp_compare*/ |
| 4266 | 0, /*tp_repr*/ |
| 4267 | 0, /*tp_as_number*/ |
| 4268 | 0, /*tp_as_sequence*/ |
| 4269 | 0, /*tp_as_mapping*/ |
| 4270 | 0, /*tp_hash */ |
| 4271 | 0, /*tp_call*/ |
| 4272 | 0, /*tp_str*/ |
| 4273 | 0, /*tp_getattro*/ |
| 4274 | 0, /*tp_setattro*/ |
| 4275 | 0, /*tp_as_buffer*/ |
| 4276 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 4277 | "Call Info objects", /* tp_doc */ |
| 4278 | 0, /* tp_traverse */ |
| 4279 | 0, /* tp_clear */ |
| 4280 | 0, /* tp_richcompare */ |
| 4281 | 0, /* tp_weaklistoffset */ |
| 4282 | 0, /* tp_iter */ |
| 4283 | 0, /* tp_iternext */ |
| 4284 | 0, /* tp_methods */ |
| 4285 | call_info_members, /* tp_members */ |
| 4286 | 0, /* tp_getset */ |
| 4287 | 0, /* tp_base */ |
| 4288 | 0, /* tp_dict */ |
| 4289 | 0, /* tp_descr_get */ |
| 4290 | 0, /* tp_descr_set */ |
| 4291 | 0, /* tp_dictoffset */ |
| 4292 | 0, /* tp_init */ |
| 4293 | 0, /* tp_alloc */ |
| 4294 | call_info_new, /* tp_new */ |
| 4295 | |
| 4296 | }; |
| 4297 | |
| 4298 | /* |
| 4299 | * py_pjsua_call_get_max_count |
| 4300 | */ |
| 4301 | static PyObject *py_pjsua_call_get_max_count |
| 4302 | (PyObject *pSelf, PyObject *pArgs) |
| 4303 | { |
| 4304 | int count; |
| 4305 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4306 | PJ_UNUSED_ARG(pSelf); |
| 4307 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4308 | if (!PyArg_ParseTuple(pArgs, "")) |
| 4309 | { |
| 4310 | return NULL; |
| 4311 | } |
| 4312 | |
| 4313 | count = pjsua_call_get_max_count(); |
| 4314 | |
| 4315 | |
| 4316 | return Py_BuildValue("i", count); |
| 4317 | } |
| 4318 | |
| 4319 | /* |
| 4320 | * py_pjsua_call_get_count |
| 4321 | */ |
| 4322 | static PyObject *py_pjsua_call_get_count |
| 4323 | (PyObject *pSelf, PyObject *pArgs) |
| 4324 | { |
| 4325 | |
| 4326 | int count; |
| 4327 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4328 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4329 | |
| 4330 | if (!PyArg_ParseTuple(pArgs, "")) |
| 4331 | { |
| 4332 | return NULL; |
| 4333 | } |
| 4334 | |
| 4335 | count = pjsua_call_get_count(); |
| 4336 | |
| 4337 | |
| 4338 | return Py_BuildValue("i", count); |
| 4339 | } |
| 4340 | |
| 4341 | /* |
| 4342 | * py_pjsua_enum_calls |
| 4343 | */ |
| 4344 | static PyObject *py_pjsua_enum_calls(PyObject *pSelf, PyObject *pArgs) |
| 4345 | { |
| 4346 | pj_status_t status; |
| 4347 | PyObject *list; |
| 4348 | |
| 4349 | pjsua_transport_id id[PJSUA_MAX_CALLS]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4350 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4351 | |
| 4352 | PJ_UNUSED_ARG(pSelf); |
| 4353 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4354 | if (!PyArg_ParseTuple(pArgs, "")) |
| 4355 | { |
| 4356 | return NULL; |
| 4357 | } |
| 4358 | |
| 4359 | c = PJ_ARRAY_SIZE(id); |
| 4360 | status = pjsua_enum_calls(id, &c); |
| 4361 | |
| 4362 | list = PyList_New(c); |
| 4363 | for (i = 0; i < c; i++) |
| 4364 | { |
| 4365 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 4366 | if (ret == -1) |
| 4367 | { |
| 4368 | return NULL; |
| 4369 | } |
| 4370 | } |
| 4371 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4372 | return Py_BuildValue("O",list); |
| 4373 | } |
| 4374 | |
| 4375 | /* |
| 4376 | * py_pjsua_call_make_call |
| 4377 | */ |
| 4378 | static PyObject *py_pjsua_call_make_call |
| 4379 | (PyObject *pSelf, PyObject *pArgs) |
| 4380 | { |
| 4381 | int status; |
| 4382 | int acc_id; |
| 4383 | pj_str_t dst_uri; |
| 4384 | PyObject * sd; |
| 4385 | unsigned options; |
| 4386 | pjsua_msg_data msg_data; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4387 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4388 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4389 | int user_data; |
| 4390 | int call_id; |
| 4391 | pj_pool_t * pool; |
| 4392 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4393 | PJ_UNUSED_ARG(pSelf); |
| 4394 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4395 | if (!PyArg_ParseTuple |
| 4396 | (pArgs, "iOIiO", &acc_id, &sd, &options, &user_data, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4397 | { |
| 4398 | return NULL; |
| 4399 | } |
| 4400 | |
| 4401 | dst_uri.ptr = PyString_AsString(sd); |
| 4402 | dst_uri.slen = strlen(PyString_AsString(sd)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4403 | if (omdObj != Py_None) |
| 4404 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4405 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4406 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4407 | msg_data.content_type.slen = strlen |
| 4408 | (PyString_AsString(omd->content_type)); |
| 4409 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4410 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4411 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4412 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4413 | status = pjsua_call_make_call(acc_id, &dst_uri, |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4414 | options, (void*)user_data, &msg_data, &call_id); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4415 | pj_pool_release(pool); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4416 | } else { |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 4417 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4418 | status = pjsua_call_make_call(acc_id, &dst_uri, |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4419 | options, (void*)user_data, NULL, &call_id); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4420 | } |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 4421 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4422 | return Py_BuildValue("ii",status, call_id); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 4423 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4424 | } |
| 4425 | |
| 4426 | /* |
| 4427 | * py_pjsua_call_is_active |
| 4428 | */ |
| 4429 | static PyObject *py_pjsua_call_is_active |
| 4430 | (PyObject *pSelf, PyObject *pArgs) |
| 4431 | { |
| 4432 | int call_id; |
| 4433 | int isActive; |
| 4434 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4435 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4436 | |
| 4437 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4438 | { |
| 4439 | return NULL; |
| 4440 | } |
| 4441 | |
| 4442 | isActive = pjsua_call_is_active(call_id); |
| 4443 | |
| 4444 | |
| 4445 | return Py_BuildValue("i", isActive); |
| 4446 | } |
| 4447 | |
| 4448 | /* |
| 4449 | * py_pjsua_call_has_media |
| 4450 | */ |
| 4451 | static PyObject *py_pjsua_call_has_media |
| 4452 | (PyObject *pSelf, PyObject *pArgs) |
| 4453 | { |
| 4454 | int call_id; |
| 4455 | int hasMedia; |
| 4456 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4457 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4458 | |
| 4459 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4460 | { |
| 4461 | return NULL; |
| 4462 | } |
| 4463 | |
| 4464 | hasMedia = pjsua_call_has_media(call_id); |
| 4465 | |
| 4466 | |
| 4467 | return Py_BuildValue("i", hasMedia); |
| 4468 | } |
| 4469 | |
| 4470 | /* |
| 4471 | * py_pjsua_call_get_conf_port |
| 4472 | */ |
| 4473 | static PyObject *py_pjsua_call_get_conf_port |
| 4474 | (PyObject *pSelf, PyObject *pArgs) |
| 4475 | { |
| 4476 | int call_id; |
| 4477 | int port_id; |
| 4478 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4479 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4480 | |
| 4481 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4482 | { |
| 4483 | return NULL; |
| 4484 | } |
| 4485 | |
| 4486 | port_id = pjsua_call_get_conf_port(call_id); |
| 4487 | |
| 4488 | |
| 4489 | return Py_BuildValue("i", port_id); |
| 4490 | } |
| 4491 | |
| 4492 | /* |
| 4493 | * py_pjsua_call_get_info |
| 4494 | */ |
| 4495 | static PyObject *py_pjsua_call_get_info |
| 4496 | (PyObject *pSelf, PyObject *pArgs) |
| 4497 | { |
| 4498 | int call_id; |
| 4499 | int status; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4500 | PyObj_pjsua_call_info * oi; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4501 | pjsua_call_info info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4502 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4503 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4504 | |
| 4505 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4506 | { |
| 4507 | return NULL; |
| 4508 | } |
| 4509 | |
| 4510 | |
| 4511 | status = pjsua_call_get_info(call_id, &info); |
| 4512 | if (status == PJ_SUCCESS) |
| 4513 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4514 | oi = (PyObj_pjsua_call_info *)call_info_new(&PyTyp_pjsua_call_info, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4515 | oi->acc_id = info.acc_id; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4516 | pj_ansi_snprintf(oi->buf_.call_id, sizeof(oi->buf_.call_id), |
| 4517 | "%.*s", (int)info.call_id.slen, info.call_id.ptr); |
| 4518 | pj_ansi_snprintf(oi->buf_.last_status_text, |
| 4519 | sizeof(oi->buf_.last_status_text), |
| 4520 | "%.*s", (int)info.last_status_text.slen, info.last_status_text.ptr); |
| 4521 | pj_ansi_snprintf(oi->buf_.local_contact, sizeof(oi->buf_.local_contact), |
| 4522 | "%.*s", (int)info.local_contact.slen, info.local_contact.ptr); |
| 4523 | pj_ansi_snprintf(oi->buf_.local_info, sizeof(oi->buf_.local_info), |
| 4524 | "%.*s", (int)info.local_info.slen, info.local_info.ptr); |
| 4525 | pj_ansi_snprintf(oi->buf_.remote_contact, |
| 4526 | sizeof(oi->buf_.remote_contact), |
| 4527 | "%.*s", (int)info.remote_contact.slen, info.remote_contact.ptr); |
| 4528 | pj_ansi_snprintf(oi->buf_.remote_info, sizeof(oi->buf_.remote_info), |
| 4529 | "%.*s", (int)info.remote_info.slen, info.remote_info.ptr); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4530 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4531 | oi->call_id = PyString_FromStringAndSize(info.call_id.ptr, |
| 4532 | info.call_id.slen); |
| 4533 | oi->conf_slot = info.conf_slot; |
| 4534 | oi->connect_duration->sec = info.connect_duration.sec; |
| 4535 | oi->connect_duration->msec = info.connect_duration.msec; |
| 4536 | oi->total_duration->sec = info.total_duration.sec; |
| 4537 | oi->total_duration->msec = info.total_duration.msec; |
| 4538 | oi->id = info.id; |
| 4539 | oi->last_status = info.last_status; |
| 4540 | oi->last_status_text = PyString_FromStringAndSize( |
| 4541 | info.last_status_text.ptr, info.last_status_text.slen); |
| 4542 | oi->local_contact = PyString_FromStringAndSize( |
| 4543 | info.local_contact.ptr, info.local_contact.slen); |
| 4544 | oi->local_info = PyString_FromStringAndSize( |
| 4545 | info.local_info.ptr, info.local_info.slen); |
| 4546 | oi->remote_contact = PyString_FromStringAndSize( |
| 4547 | info.remote_contact.ptr, info.remote_contact.slen); |
| 4548 | oi->remote_info = PyString_FromStringAndSize( |
| 4549 | info.remote_info.ptr, info.remote_info.slen); |
| 4550 | oi->media_dir = info.media_dir; |
| 4551 | oi->media_status = info.media_status; |
| 4552 | oi->role = info.role; |
| 4553 | oi->state = info.state; |
| 4554 | oi->state_text = PyString_FromStringAndSize( |
| 4555 | info.state_text.ptr, info.state_text.slen); |
| 4556 | |
| 4557 | return Py_BuildValue("O", oi); |
| 4558 | } else { |
| 4559 | Py_INCREF(Py_None); |
| 4560 | return Py_None; |
| 4561 | } |
| 4562 | } |
| 4563 | |
| 4564 | /* |
| 4565 | * py_pjsua_call_set_user_data |
| 4566 | */ |
| 4567 | static PyObject *py_pjsua_call_set_user_data |
| 4568 | (PyObject *pSelf, PyObject *pArgs) |
| 4569 | { |
| 4570 | int call_id; |
| 4571 | int user_data; |
| 4572 | int status; |
| 4573 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4574 | PJ_UNUSED_ARG(pSelf); |
| 4575 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4576 | if (!PyArg_ParseTuple(pArgs, "ii", &call_id, &user_data)) |
| 4577 | { |
| 4578 | return NULL; |
| 4579 | } |
| 4580 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4581 | status = pjsua_call_set_user_data(call_id, (void*)user_data); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4582 | |
| 4583 | |
| 4584 | return Py_BuildValue("i", status); |
| 4585 | } |
| 4586 | |
| 4587 | /* |
| 4588 | * py_pjsua_call_get_user_data |
| 4589 | */ |
| 4590 | static PyObject *py_pjsua_call_get_user_data |
| 4591 | (PyObject *pSelf, PyObject *pArgs) |
| 4592 | { |
| 4593 | int call_id; |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4594 | void * user_data; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4595 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4596 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4597 | |
| 4598 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4599 | { |
| 4600 | return NULL; |
| 4601 | } |
| 4602 | |
| 4603 | user_data = pjsua_call_get_user_data(call_id); |
| 4604 | |
| 4605 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4606 | return Py_BuildValue("i", (int)user_data); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4607 | } |
| 4608 | |
| 4609 | /* |
| 4610 | * py_pjsua_call_answer |
| 4611 | */ |
| 4612 | static PyObject *py_pjsua_call_answer |
| 4613 | (PyObject *pSelf, PyObject *pArgs) |
| 4614 | { |
| 4615 | int status; |
| 4616 | int call_id; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4617 | pj_str_t * reason, tmp_reason; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4618 | PyObject * sr; |
| 4619 | unsigned code; |
| 4620 | pjsua_msg_data msg_data; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4621 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4622 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4623 | pj_pool_t * pool; |
| 4624 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4625 | PJ_UNUSED_ARG(pSelf); |
| 4626 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4627 | if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4628 | { |
| 4629 | return NULL; |
| 4630 | } |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4631 | if (sr == Py_None) |
| 4632 | { |
| 4633 | reason = NULL; |
| 4634 | } else { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4635 | reason = &tmp_reason; |
| 4636 | tmp_reason.ptr = PyString_AsString(sr); |
| 4637 | tmp_reason.slen = strlen(PyString_AsString(sr)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4638 | } |
| 4639 | if (omdObj != Py_None) |
| 4640 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4641 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4642 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4643 | msg_data.content_type.slen = strlen |
| 4644 | (PyString_AsString(omd->content_type)); |
| 4645 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4646 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4647 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4648 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4649 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4650 | status = pjsua_call_answer(call_id, code, reason, &msg_data); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4651 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4652 | pj_pool_release(pool); |
| 4653 | } else { |
| 4654 | |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 4655 | status = pjsua_call_answer(call_id, code, reason, NULL); |
| 4656 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4657 | } |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4658 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4659 | return Py_BuildValue("i",status); |
| 4660 | } |
| 4661 | |
| 4662 | /* |
| 4663 | * py_pjsua_call_hangup |
| 4664 | */ |
| 4665 | static PyObject *py_pjsua_call_hangup |
| 4666 | (PyObject *pSelf, PyObject *pArgs) |
| 4667 | { |
| 4668 | int status; |
| 4669 | int call_id; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4670 | pj_str_t * reason, tmp_reason; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4671 | PyObject * sr; |
| 4672 | unsigned code; |
| 4673 | pjsua_msg_data msg_data; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4674 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4675 | PyObj_pjsua_msg_data * omd; |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4676 | pj_pool_t * pool = NULL; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4677 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4678 | PJ_UNUSED_ARG(pSelf); |
| 4679 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4680 | if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4681 | { |
| 4682 | return NULL; |
| 4683 | } |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 4684 | if (sr == Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4685 | { |
| 4686 | reason = NULL; |
| 4687 | } else { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4688 | reason = &tmp_reason; |
| 4689 | tmp_reason.ptr = PyString_AsString(sr); |
| 4690 | tmp_reason.slen = strlen(PyString_AsString(sr)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4691 | } |
| 4692 | if (omdObj != Py_None) |
| 4693 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4694 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4695 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4696 | msg_data.content_type.slen = strlen |
| 4697 | (PyString_AsString(omd->content_type)); |
| 4698 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4699 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4700 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4701 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4702 | status = pjsua_call_hangup(call_id, code, reason, &msg_data); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4703 | pj_pool_release(pool); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4704 | } else { |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4705 | status = pjsua_call_hangup(call_id, code, reason, NULL); |
| 4706 | } |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4707 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4708 | return Py_BuildValue("i",status); |
| 4709 | } |
| 4710 | |
| 4711 | /* |
| 4712 | * py_pjsua_call_set_hold |
| 4713 | */ |
| 4714 | static PyObject *py_pjsua_call_set_hold |
| 4715 | (PyObject *pSelf, PyObject *pArgs) |
| 4716 | { |
| 4717 | int status; |
| 4718 | int call_id; |
| 4719 | pjsua_msg_data msg_data; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4720 | PyObject * omdObj; |
| 4721 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4722 | pj_pool_t * pool; |
| 4723 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4724 | PJ_UNUSED_ARG(pSelf); |
| 4725 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4726 | if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4727 | { |
| 4728 | return NULL; |
| 4729 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4730 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4731 | if (omdObj != Py_None) |
| 4732 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4733 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4734 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4735 | msg_data.content_type.slen = strlen |
| 4736 | (PyString_AsString(omd->content_type)); |
| 4737 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4738 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4739 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4740 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4741 | status = pjsua_call_set_hold(call_id, &msg_data); |
| 4742 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4743 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4744 | status = pjsua_call_set_hold(call_id, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4745 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4746 | return Py_BuildValue("i",status); |
| 4747 | } |
| 4748 | |
| 4749 | /* |
| 4750 | * py_pjsua_call_reinvite |
| 4751 | */ |
| 4752 | static PyObject *py_pjsua_call_reinvite |
| 4753 | (PyObject *pSelf, PyObject *pArgs) |
| 4754 | { |
| 4755 | int status; |
| 4756 | int call_id; |
| 4757 | int unhold; |
| 4758 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4759 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4760 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4761 | pj_pool_t * pool; |
| 4762 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4763 | PJ_UNUSED_ARG(pSelf); |
| 4764 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4765 | if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4766 | { |
| 4767 | return NULL; |
| 4768 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4769 | |
| 4770 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4771 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4772 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4773 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4774 | msg_data.content_type.slen = strlen |
| 4775 | (PyString_AsString(omd->content_type)); |
| 4776 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4777 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4778 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4779 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4780 | status = pjsua_call_reinvite(call_id, unhold, &msg_data); |
| 4781 | pj_pool_release(pool); |
| 4782 | } else { |
| 4783 | status = pjsua_call_reinvite(call_id, unhold, NULL); |
| 4784 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4785 | return Py_BuildValue("i",status); |
| 4786 | } |
| 4787 | |
| 4788 | /* |
| 4789 | * py_pjsua_call_xfer |
| 4790 | */ |
| 4791 | static PyObject *py_pjsua_call_xfer |
| 4792 | (PyObject *pSelf, PyObject *pArgs) |
| 4793 | { |
| 4794 | int status; |
| 4795 | int call_id; |
| 4796 | pj_str_t dest; |
| 4797 | PyObject * sd; |
| 4798 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4799 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4800 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4801 | pj_pool_t * pool; |
| 4802 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4803 | PJ_UNUSED_ARG(pSelf); |
| 4804 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4805 | if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &sd, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4806 | { |
| 4807 | return NULL; |
| 4808 | } |
| 4809 | |
| 4810 | dest.ptr = PyString_AsString(sd); |
| 4811 | dest.slen = strlen(PyString_AsString(sd)); |
| 4812 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4813 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4814 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4815 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4816 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4817 | msg_data.content_type.slen = strlen |
| 4818 | (PyString_AsString(omd->content_type)); |
| 4819 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4820 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4821 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4822 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4823 | status = pjsua_call_xfer(call_id, &dest, &msg_data); |
| 4824 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4825 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4826 | status = pjsua_call_xfer(call_id, &dest, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4827 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4828 | return Py_BuildValue("i",status); |
| 4829 | } |
| 4830 | |
| 4831 | /* |
| 4832 | * py_pjsua_call_xfer_replaces |
| 4833 | */ |
| 4834 | static PyObject *py_pjsua_call_xfer_replaces |
| 4835 | (PyObject *pSelf, PyObject *pArgs) |
| 4836 | { |
| 4837 | int status; |
| 4838 | int call_id; |
| 4839 | int dest_call_id; |
| 4840 | unsigned options; |
| 4841 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4842 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4843 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4844 | pj_pool_t * pool; |
| 4845 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4846 | PJ_UNUSED_ARG(pSelf); |
| 4847 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4848 | if (!PyArg_ParseTuple |
| 4849 | (pArgs, "iiIO", &call_id, &dest_call_id, &options, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4850 | { |
| 4851 | return NULL; |
| 4852 | } |
| 4853 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4854 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4855 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4856 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4857 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4858 | msg_data.content_type.slen = strlen |
| 4859 | (PyString_AsString(omd->content_type)); |
| 4860 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4861 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4862 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4863 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4864 | status = pjsua_call_xfer_replaces |
| 4865 | (call_id, dest_call_id, options, &msg_data); |
| 4866 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4867 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4868 | status = pjsua_call_xfer_replaces(call_id, dest_call_id,options, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4869 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4870 | return Py_BuildValue("i",status); |
| 4871 | } |
| 4872 | |
| 4873 | /* |
| 4874 | * py_pjsua_call_dial_dtmf |
| 4875 | */ |
| 4876 | static PyObject *py_pjsua_call_dial_dtmf |
| 4877 | (PyObject *pSelf, PyObject *pArgs) |
| 4878 | { |
| 4879 | int call_id; |
| 4880 | PyObject * sd; |
| 4881 | pj_str_t digits; |
| 4882 | int status; |
| 4883 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4884 | PJ_UNUSED_ARG(pSelf); |
| 4885 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4886 | if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &sd)) |
| 4887 | { |
| 4888 | return NULL; |
| 4889 | } |
| 4890 | digits.ptr = PyString_AsString(sd); |
| 4891 | digits.slen = strlen(PyString_AsString(sd)); |
| 4892 | status = pjsua_call_dial_dtmf(call_id, &digits); |
| 4893 | |
| 4894 | return Py_BuildValue("i", status); |
| 4895 | } |
| 4896 | |
| 4897 | /* |
| 4898 | * py_pjsua_call_send_im |
| 4899 | */ |
| 4900 | static PyObject *py_pjsua_call_send_im |
| 4901 | (PyObject *pSelf, PyObject *pArgs) |
| 4902 | { |
| 4903 | int status; |
| 4904 | int call_id; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4905 | pj_str_t content; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4906 | pj_str_t * mime_type, tmp_mime_type; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4907 | PyObject * sm; |
| 4908 | PyObject * sc; |
| 4909 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4910 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4911 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4912 | int user_data; |
| 4913 | pj_pool_t * pool; |
| 4914 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4915 | PJ_UNUSED_ARG(pSelf); |
| 4916 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4917 | if (!PyArg_ParseTuple |
| 4918 | (pArgs, "iOOOi", &call_id, &sm, &sc, &omdObj, &user_data)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4919 | { |
| 4920 | return NULL; |
| 4921 | } |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4922 | if (sm == Py_None) |
| 4923 | { |
| 4924 | mime_type = NULL; |
| 4925 | } else { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4926 | mime_type = &tmp_mime_type; |
| 4927 | tmp_mime_type.ptr = PyString_AsString(sm); |
| 4928 | tmp_mime_type.slen = strlen(PyString_AsString(sm)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4929 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4930 | content.ptr = PyString_AsString(sc); |
| 4931 | content.slen = strlen(PyString_AsString(sc)); |
| 4932 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4933 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4934 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4935 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4936 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4937 | msg_data.content_type.slen = strlen |
| 4938 | (PyString_AsString(omd->content_type)); |
| 4939 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4940 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4941 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4942 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4943 | status = pjsua_call_send_im |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4944 | (call_id, mime_type, &content, &msg_data, (void *)user_data); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4945 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4946 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4947 | status = pjsua_call_send_im |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4948 | (call_id, mime_type, &content, NULL, (void *)user_data); |
| 4949 | } |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4950 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4951 | return Py_BuildValue("i",status); |
| 4952 | } |
| 4953 | |
| 4954 | /* |
| 4955 | * py_pjsua_call_send_typing_ind |
| 4956 | */ |
| 4957 | static PyObject *py_pjsua_call_send_typing_ind |
| 4958 | (PyObject *pSelf, PyObject *pArgs) |
| 4959 | { |
| 4960 | int status; |
| 4961 | int call_id; |
| 4962 | int is_typing; |
| 4963 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4964 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4965 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4966 | pj_pool_t * pool; |
| 4967 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4968 | PJ_UNUSED_ARG(pSelf); |
| 4969 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4970 | if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4971 | { |
| 4972 | return NULL; |
| 4973 | } |
| 4974 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4975 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4976 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 4977 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4978 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4979 | msg_data.content_type.slen = strlen |
| 4980 | (PyString_AsString(omd->content_type)); |
| 4981 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4982 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4983 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4984 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4985 | status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data); |
| 4986 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4987 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4988 | status = pjsua_call_send_typing_ind(call_id, is_typing, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4989 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4990 | return Py_BuildValue("i",status); |
| 4991 | } |
| 4992 | |
| 4993 | /* |
| 4994 | * py_pjsua_call_hangup_all |
| 4995 | */ |
| 4996 | static PyObject *py_pjsua_call_hangup_all |
| 4997 | (PyObject *pSelf, PyObject *pArgs) |
| 4998 | { |
| 4999 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5000 | PJ_UNUSED_ARG(pSelf); |
| 5001 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5002 | if (!PyArg_ParseTuple(pArgs, "")) |
| 5003 | { |
| 5004 | return NULL; |
| 5005 | } |
| 5006 | |
| 5007 | pjsua_call_hangup_all(); |
| 5008 | |
| 5009 | Py_INCREF(Py_None); |
| 5010 | return Py_None; |
| 5011 | } |
| 5012 | |
| 5013 | /* |
| 5014 | * py_pjsua_call_dump |
| 5015 | */ |
| 5016 | static PyObject *py_pjsua_call_dump |
| 5017 | (PyObject *pSelf, PyObject *pArgs) |
| 5018 | { |
| 5019 | int call_id; |
| 5020 | int with_media; |
| 5021 | PyObject * sb; |
| 5022 | PyObject * si; |
| 5023 | char * buffer; |
| 5024 | char * indent; |
| 5025 | unsigned maxlen; |
| 5026 | int status; |
| 5027 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5028 | PJ_UNUSED_ARG(pSelf); |
| 5029 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5030 | if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media, &maxlen, &si)) |
| 5031 | { |
| 5032 | return NULL; |
| 5033 | } |
| 5034 | buffer = (char *) malloc (maxlen * sizeof(char)); |
| 5035 | indent = PyString_AsString(si); |
| 5036 | |
| 5037 | status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent); |
| 5038 | sb = PyString_FromStringAndSize(buffer, maxlen); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 5039 | free(buffer); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5040 | return Py_BuildValue("O", sb); |
| 5041 | } |
| 5042 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 5043 | |
| 5044 | /* |
| 5045 | * py_pjsua_dump |
| 5046 | * Dump application states. |
| 5047 | */ |
| 5048 | static PyObject *py_pjsua_dump(PyObject *pSelf, PyObject *pArgs) |
| 5049 | { |
| 5050 | unsigned old_decor; |
| 5051 | char buf[1024]; |
| 5052 | int detail; |
| 5053 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5054 | PJ_UNUSED_ARG(pSelf); |
| 5055 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 5056 | if (!PyArg_ParseTuple(pArgs, "i", &detail)) |
| 5057 | { |
| 5058 | return NULL; |
| 5059 | } |
| 5060 | |
| 5061 | PJ_LOG(3,(THIS_FILE, "Start dumping application states:")); |
| 5062 | |
| 5063 | old_decor = pj_log_get_decor(); |
| 5064 | pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR)); |
| 5065 | |
| 5066 | if (detail) |
| 5067 | pj_dump_config(); |
| 5068 | |
| 5069 | pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail); |
| 5070 | pjmedia_endpt_dump(pjsua_get_pjmedia_endpt()); |
| 5071 | pjsip_tsx_layer_dump(detail); |
| 5072 | pjsip_ua_dump(detail); |
| 5073 | |
| 5074 | |
| 5075 | /* Dump all invite sessions: */ |
| 5076 | PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:")); |
| 5077 | |
| 5078 | if (pjsua_call_get_count() == 0) { |
| 5079 | |
| 5080 | PJ_LOG(3,(THIS_FILE, " - no sessions -")); |
| 5081 | |
| 5082 | } else { |
| 5083 | unsigned i, max; |
| 5084 | |
| 5085 | max = pjsua_call_get_max_count(); |
| 5086 | for (i=0; i<max; ++i) { |
| 5087 | if (pjsua_call_is_active(i)) { |
| 5088 | pjsua_call_dump(i, detail, buf, sizeof(buf), " "); |
| 5089 | PJ_LOG(3,(THIS_FILE, "%s", buf)); |
| 5090 | } |
| 5091 | } |
| 5092 | } |
| 5093 | |
| 5094 | /* Dump presence status */ |
| 5095 | pjsua_pres_dump(detail); |
| 5096 | |
| 5097 | pj_log_set_decor(old_decor); |
| 5098 | PJ_LOG(3,(THIS_FILE, "Dump complete")); |
| 5099 | |
| 5100 | Py_INCREF(Py_None); |
| 5101 | return Py_None; |
| 5102 | } |
| 5103 | |
| 5104 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5105 | static char pjsua_call_get_max_count_doc[] = |
| 5106 | "int py_pjsua.call_get_max_count () " |
| 5107 | "Get maximum number of calls configured in pjsua."; |
| 5108 | static char pjsua_call_get_count_doc[] = |
| 5109 | "int py_pjsua.call_get_count () " |
| 5110 | "Get number of currently active calls."; |
| 5111 | static char pjsua_enum_calls_doc[] = |
| 5112 | "int[] py_pjsua.enum_calls () " |
| 5113 | "Get maximum number of calls configured in pjsua."; |
| 5114 | static char pjsua_call_make_call_doc[] = |
| 5115 | "int,int py_pjsua.call_make_call (int acc_id, string dst_uri, int options," |
| 5116 | "int user_data, py_pjsua.Msg_Data msg_data) " |
| 5117 | "Make outgoing call to the specified URI using the specified account."; |
| 5118 | static char pjsua_call_is_active_doc[] = |
| 5119 | "int py_pjsua.call_is_active (int call_id) " |
| 5120 | "Check if the specified call has active INVITE session and the INVITE " |
| 5121 | "session has not been disconnected."; |
| 5122 | static char pjsua_call_has_media_doc[] = |
| 5123 | "int py_pjsua.call_has_media (int call_id) " |
| 5124 | "Check if call has an active media session."; |
| 5125 | static char pjsua_call_get_conf_port_doc[] = |
| 5126 | "int py_pjsua.call_get_conf_port (int call_id) " |
| 5127 | "Get the conference port identification associated with the call."; |
| 5128 | static char pjsua_call_get_info_doc[] = |
| 5129 | "py_pjsua.Call_Info py_pjsua.call_get_info (int call_id) " |
| 5130 | "Obtain detail information about the specified call."; |
| 5131 | static char pjsua_call_set_user_data_doc[] = |
| 5132 | "int py_pjsua.call_set_user_data (int call_id, int user_data) " |
| 5133 | "Attach application specific data to the call."; |
| 5134 | static char pjsua_call_get_user_data_doc[] = |
| 5135 | "int py_pjsua.call_get_user_data (int call_id) " |
| 5136 | "Get user data attached to the call."; |
| 5137 | static char pjsua_call_answer_doc[] = |
| 5138 | "int py_pjsua.call_answer (int call_id, int code, string reason, " |
| 5139 | "py_pjsua.Msg_Data msg_data) " |
| 5140 | "Send response to incoming INVITE request."; |
| 5141 | static char pjsua_call_hangup_doc[] = |
| 5142 | "int py_pjsua.call_hangup (int call_id, int code, string reason, " |
| 5143 | "py_pjsua.Msg_Data msg_data) " |
| 5144 | "Hangup call by using method that is appropriate according " |
| 5145 | "to the call state."; |
| 5146 | static char pjsua_call_set_hold_doc[] = |
| 5147 | "int py_pjsua.call_set_hold (int call_id, py_pjsua.Msg_Data msg_data) " |
| 5148 | "Put the specified call on hold."; |
| 5149 | static char pjsua_call_reinvite_doc[] = |
| 5150 | "int py_pjsua.call_reinvite (int call_id, int unhold, " |
| 5151 | "py_pjsua.Msg_Data msg_data) " |
| 5152 | "Send re-INVITE (to release hold)."; |
| 5153 | static char pjsua_call_xfer_doc[] = |
| 5154 | "int py_pjsua.call_xfer (int call_id, string dest, " |
| 5155 | "py_pjsua.Msg_Data msg_data) " |
| 5156 | "Initiate call transfer to the specified address. " |
| 5157 | "This function will send REFER request to instruct remote call party " |
| 5158 | "to initiate a new INVITE session to the specified destination/target."; |
| 5159 | static char pjsua_call_xfer_replaces_doc[] = |
| 5160 | "int py_pjsua.call_xfer_replaces (int call_id, int dest_call_id, " |
| 5161 | "int options, py_pjsua.Msg_Data msg_data) " |
| 5162 | "Initiate attended call transfer. This function will send REFER request " |
| 5163 | "to instruct remote call party to initiate new INVITE session to the URL " |
| 5164 | "of dest_call_id. The party at dest_call_id then should 'replace' the call" |
| 5165 | "with us with the new call from the REFER recipient."; |
| 5166 | static char pjsua_call_dial_dtmf_doc[] = |
| 5167 | "int py_pjsua.call_dial_dtmf (int call_id, string digits) " |
| 5168 | "Send DTMF digits to remote using RFC 2833 payload formats."; |
| 5169 | static char pjsua_call_send_im_doc[] = |
| 5170 | "int py_pjsua.call_send_im (int call_id, string mime_type, string content," |
| 5171 | "py_pjsua.Msg_Data msg_data, int user_data) " |
| 5172 | "Send instant messaging inside INVITE session."; |
| 5173 | static char pjsua_call_send_typing_ind_doc[] = |
| 5174 | "int py_pjsua.call_send_typing_ind (int call_id, int is_typing, " |
| 5175 | "py_pjsua.Msg_Data msg_data) " |
| 5176 | "Send IM typing indication inside INVITE session."; |
| 5177 | static char pjsua_call_hangup_all_doc[] = |
| 5178 | "void py_pjsua.call_hangup_all () " |
| 5179 | "Terminate all calls."; |
| 5180 | static char pjsua_call_dump_doc[] = |
| 5181 | "int py_pjsua.call_dump (int call_id, int with_media, int maxlen, " |
| 5182 | "string indent) " |
| 5183 | "Dump call and media statistics to string."; |
| 5184 | |
| 5185 | /* END OF LIB CALL */ |
| 5186 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5187 | /* |
| 5188 | * Map of function names to functions |
| 5189 | */ |
| 5190 | static PyMethodDef py_pjsua_methods[] = |
| 5191 | { |
| 5192 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5193 | "thread_register", py_pjsua_thread_register, METH_VARARGS, |
| 5194 | pjsua_thread_register_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5195 | }, |
| 5196 | { |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5197 | "perror", py_pjsua_perror, METH_VARARGS, pjsua_perror_doc |
| 5198 | }, |
| 5199 | { |
| 5200 | "create", py_pjsua_create, METH_VARARGS, pjsua_create_doc |
| 5201 | }, |
| 5202 | { |
| 5203 | "init", py_pjsua_init, METH_VARARGS, pjsua_init_doc |
| 5204 | }, |
| 5205 | { |
| 5206 | "start", py_pjsua_start, METH_VARARGS, pjsua_start_doc |
| 5207 | }, |
| 5208 | { |
| 5209 | "destroy", py_pjsua_destroy, METH_VARARGS, pjsua_destroy_doc |
| 5210 | }, |
| 5211 | { |
| 5212 | "handle_events", py_pjsua_handle_events, METH_VARARGS, |
| 5213 | pjsua_handle_events_doc |
| 5214 | }, |
| 5215 | { |
| 5216 | "verify_sip_url", py_pjsua_verify_sip_url, METH_VARARGS, |
| 5217 | pjsua_verify_sip_url_doc |
| 5218 | }, |
| 5219 | { |
| 5220 | "pool_create", py_pjsua_pool_create, METH_VARARGS, |
| 5221 | pjsua_pool_create_doc |
| 5222 | }, |
| 5223 | { |
| 5224 | "get_pjsip_endpt", py_pjsua_get_pjsip_endpt, METH_VARARGS, |
| 5225 | pjsua_get_pjsip_endpt_doc |
| 5226 | }, |
| 5227 | { |
| 5228 | "get_pjmedia_endpt", py_pjsua_get_pjmedia_endpt, METH_VARARGS, |
| 5229 | pjsua_get_pjmedia_endpt_doc |
| 5230 | }, |
| 5231 | { |
| 5232 | "get_pool_factory", py_pjsua_get_pool_factory, METH_VARARGS, |
| 5233 | pjsua_get_pool_factory_doc |
| 5234 | }, |
| 5235 | { |
| 5236 | "reconfigure_logging", py_pjsua_reconfigure_logging, METH_VARARGS, |
| 5237 | pjsua_reconfigure_logging_doc |
| 5238 | }, |
| 5239 | { |
| 5240 | "logging_config_default", py_pjsua_logging_config_default, |
| 5241 | METH_VARARGS, pjsua_logging_config_default_doc |
| 5242 | }, |
| 5243 | { |
| 5244 | "config_default", py_pjsua_config_default, METH_VARARGS, |
| 5245 | pjsua_config_default_doc |
| 5246 | }, |
| 5247 | { |
| 5248 | "media_config_default", py_pjsua_media_config_default, METH_VARARGS, |
| 5249 | pjsua_media_config_default_doc |
| 5250 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5251 | |
| 5252 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5253 | { |
| 5254 | "msg_data_init", py_pjsua_msg_data_init, METH_VARARGS, |
| 5255 | pjsua_msg_data_init_doc |
| 5256 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5257 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5258 | "transport_config_default", py_pjsua_transport_config_default, |
| 5259 | METH_VARARGS,pjsua_transport_config_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5260 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5261 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5262 | "transport_create", py_pjsua_transport_create, METH_VARARGS, |
| 5263 | pjsua_transport_create_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5264 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5265 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5266 | "transport_enum_transports", py_pjsua_enum_transports, METH_VARARGS, |
| 5267 | pjsua_enum_transports_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5268 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5269 | { |
| 5270 | "transport_get_info", py_pjsua_transport_get_info, METH_VARARGS, |
| 5271 | pjsua_transport_get_info_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5272 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5273 | { |
| 5274 | "transport_set_enable", py_pjsua_transport_set_enable, METH_VARARGS, |
| 5275 | pjsua_transport_set_enable_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5276 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5277 | { |
| 5278 | "transport_close", py_pjsua_transport_close, METH_VARARGS, |
| 5279 | pjsua_transport_close_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5280 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5281 | { |
| 5282 | "acc_config_default", py_pjsua_acc_config_default, METH_VARARGS, |
| 5283 | pjsua_acc_config_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5284 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5285 | { |
| 5286 | "acc_get_count", py_pjsua_acc_get_count, METH_VARARGS, |
| 5287 | pjsua_acc_get_count_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5288 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5289 | { |
| 5290 | "acc_is_valid", py_pjsua_acc_is_valid, METH_VARARGS, |
| 5291 | pjsua_acc_is_valid_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5292 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5293 | { |
| 5294 | "acc_set_default", py_pjsua_acc_set_default, METH_VARARGS, |
| 5295 | pjsua_acc_set_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5296 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5297 | { |
| 5298 | "acc_get_default", py_pjsua_acc_get_default, METH_VARARGS, |
| 5299 | pjsua_acc_get_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5300 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5301 | { |
| 5302 | "acc_add", py_pjsua_acc_add, METH_VARARGS, |
| 5303 | pjsua_acc_add_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5304 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5305 | { |
| 5306 | "acc_add_local", py_pjsua_acc_add_local, METH_VARARGS, |
| 5307 | pjsua_acc_add_local_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5308 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5309 | { |
| 5310 | "acc_del", py_pjsua_acc_del, METH_VARARGS, |
| 5311 | pjsua_acc_del_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5312 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5313 | { |
| 5314 | "acc_modify", py_pjsua_acc_modify, METH_VARARGS, |
| 5315 | pjsua_acc_modify_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5316 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5317 | { |
| 5318 | "acc_set_online_status", py_pjsua_acc_set_online_status, METH_VARARGS, |
| 5319 | pjsua_acc_set_online_status_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5320 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5321 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5322 | "acc_set_online_status2", py_pjsua_acc_set_online_status2, METH_VARARGS, |
| 5323 | pjsua_acc_set_online_status2_doc |
| 5324 | }, |
| 5325 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5326 | "acc_set_registration", py_pjsua_acc_set_registration, METH_VARARGS, |
| 5327 | pjsua_acc_set_registration_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5328 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5329 | { |
| 5330 | "acc_get_info", py_pjsua_acc_get_info, METH_VARARGS, |
| 5331 | pjsua_acc_get_info_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5332 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5333 | { |
| 5334 | "enum_accs", py_pjsua_enum_accs, METH_VARARGS, |
| 5335 | pjsua_enum_accs_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5336 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5337 | { |
| 5338 | "acc_enum_info", py_pjsua_acc_enum_info, METH_VARARGS, |
| 5339 | pjsua_acc_enum_info_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5340 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5341 | { |
| 5342 | "acc_find_for_outgoing", py_pjsua_acc_find_for_outgoing, METH_VARARGS, |
| 5343 | pjsua_acc_find_for_outgoing_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5344 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5345 | { |
| 5346 | "acc_find_for_incoming", py_pjsua_acc_find_for_incoming, METH_VARARGS, |
| 5347 | pjsua_acc_find_for_incoming_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5348 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5349 | { |
| 5350 | "acc_create_uac_contact", py_pjsua_acc_create_uac_contact, METH_VARARGS, |
| 5351 | pjsua_acc_create_uac_contact_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5352 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5353 | { |
| 5354 | "acc_create_uas_contact", py_pjsua_acc_create_uas_contact, METH_VARARGS, |
| 5355 | pjsua_acc_create_uas_contact_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5356 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5357 | { |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 5358 | "buddy_config_default", py_pjsua_buddy_config_default, METH_VARARGS, |
| 5359 | pjsua_buddy_config_default_doc |
| 5360 | }, |
| 5361 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5362 | "get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS, |
| 5363 | pjsua_get_buddy_count_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5364 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5365 | { |
| 5366 | "buddy_is_valid", py_pjsua_buddy_is_valid, METH_VARARGS, |
| 5367 | pjsua_buddy_is_valid_doc |
| 5368 | }, |
| 5369 | { |
| 5370 | "enum_buddies", py_pjsua_enum_buddies, METH_VARARGS, |
| 5371 | pjsua_enum_buddies_doc |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 5372 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5373 | { |
| 5374 | "buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS, |
| 5375 | pjsua_buddy_get_info_doc |
| 5376 | }, |
| 5377 | { |
| 5378 | "buddy_add", py_pjsua_buddy_add, METH_VARARGS, |
| 5379 | pjsua_buddy_add_doc |
| 5380 | }, |
| 5381 | { |
| 5382 | "buddy_del", py_pjsua_buddy_del, METH_VARARGS, |
| 5383 | pjsua_buddy_del_doc |
| 5384 | }, |
| 5385 | { |
| 5386 | "buddy_subscribe_pres", py_pjsua_buddy_subscribe_pres, METH_VARARGS, |
| 5387 | pjsua_buddy_subscribe_pres_doc |
| 5388 | }, |
| 5389 | { |
| 5390 | "pres_dump", py_pjsua_pres_dump, METH_VARARGS, |
| 5391 | pjsua_pres_dump_doc |
| 5392 | }, |
| 5393 | { |
| 5394 | "im_send", py_pjsua_im_send, METH_VARARGS, |
| 5395 | pjsua_im_send_doc |
| 5396 | }, |
| 5397 | { |
| 5398 | "im_typing", py_pjsua_im_typing, METH_VARARGS, |
| 5399 | pjsua_im_typing_doc |
| 5400 | }, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5401 | { |
| 5402 | "conf_get_max_ports", py_pjsua_conf_get_max_ports, METH_VARARGS, |
| 5403 | pjsua_conf_get_max_ports_doc |
| 5404 | }, |
| 5405 | { |
| 5406 | "conf_get_active_ports", py_pjsua_conf_get_active_ports, METH_VARARGS, |
| 5407 | pjsua_conf_get_active_ports_doc |
| 5408 | }, |
| 5409 | { |
| 5410 | "enum_conf_ports", py_pjsua_enum_conf_ports, METH_VARARGS, |
| 5411 | pjsua_enum_conf_ports_doc |
| 5412 | }, |
| 5413 | { |
| 5414 | "conf_get_port_info", py_pjsua_conf_get_port_info, METH_VARARGS, |
| 5415 | pjsua_conf_get_port_info_doc |
| 5416 | }, |
| 5417 | { |
| 5418 | "conf_add_port", py_pjsua_conf_add_port, METH_VARARGS, |
| 5419 | pjsua_conf_add_port_doc |
| 5420 | }, |
| 5421 | { |
| 5422 | "conf_remove_port", py_pjsua_conf_remove_port, METH_VARARGS, |
| 5423 | pjsua_conf_remove_port_doc |
| 5424 | }, |
| 5425 | { |
| 5426 | "conf_connect", py_pjsua_conf_connect, METH_VARARGS, |
| 5427 | pjsua_conf_connect_doc |
| 5428 | }, |
| 5429 | { |
| 5430 | "conf_disconnect", py_pjsua_conf_disconnect, METH_VARARGS, |
| 5431 | pjsua_conf_disconnect_doc |
| 5432 | }, |
| 5433 | { |
| 5434 | "player_create", py_pjsua_player_create, METH_VARARGS, |
| 5435 | pjsua_player_create_doc |
| 5436 | }, |
| 5437 | { |
| 5438 | "player_get_conf_port", py_pjsua_player_get_conf_port, METH_VARARGS, |
| 5439 | pjsua_player_get_conf_port_doc |
| 5440 | }, |
| 5441 | { |
| 5442 | "player_set_pos", py_pjsua_player_set_pos, METH_VARARGS, |
| 5443 | pjsua_player_set_pos_doc |
| 5444 | }, |
| 5445 | { |
| 5446 | "player_destroy", py_pjsua_player_destroy, METH_VARARGS, |
| 5447 | pjsua_player_destroy_doc |
| 5448 | }, |
| 5449 | { |
| 5450 | "recorder_create", py_pjsua_recorder_create, METH_VARARGS, |
| 5451 | pjsua_recorder_create_doc |
| 5452 | }, |
| 5453 | { |
| 5454 | "recorder_get_conf_port", py_pjsua_recorder_get_conf_port, METH_VARARGS, |
| 5455 | pjsua_recorder_get_conf_port_doc |
| 5456 | }, |
| 5457 | { |
| 5458 | "recorder_destroy", py_pjsua_recorder_destroy, METH_VARARGS, |
| 5459 | pjsua_recorder_destroy_doc |
| 5460 | }, |
| 5461 | { |
| 5462 | "enum_snd_devs", py_pjsua_enum_snd_devs, METH_VARARGS, |
| 5463 | pjsua_enum_snd_devs_doc |
| 5464 | }, |
Benny Prijono | ebdf877 | 2007-02-01 19:25:50 +0000 | [diff] [blame] | 5465 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5466 | "get_snd_dev", py_pjsua_get_snd_dev, METH_VARARGS, |
| 5467 | pjsua_get_snd_dev_doc |
Benny Prijono | ebdf877 | 2007-02-01 19:25:50 +0000 | [diff] [blame] | 5468 | }, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5469 | { |
| 5470 | "set_snd_dev", py_pjsua_set_snd_dev, METH_VARARGS, |
| 5471 | pjsua_set_snd_dev_doc |
| 5472 | }, |
| 5473 | { |
| 5474 | "set_null_snd_dev", py_pjsua_set_null_snd_dev, METH_VARARGS, |
| 5475 | pjsua_set_null_snd_dev_doc |
| 5476 | }, |
| 5477 | { |
| 5478 | "set_no_snd_dev", py_pjsua_set_no_snd_dev, METH_VARARGS, |
| 5479 | pjsua_set_no_snd_dev_doc |
| 5480 | }, |
| 5481 | { |
| 5482 | "set_ec", py_pjsua_set_ec, METH_VARARGS, |
| 5483 | pjsua_set_ec_doc |
| 5484 | }, |
| 5485 | { |
| 5486 | "get_ec_tail", py_pjsua_get_ec_tail, METH_VARARGS, |
| 5487 | pjsua_get_ec_tail_doc |
| 5488 | }, |
| 5489 | { |
| 5490 | "enum_codecs", py_pjsua_enum_codecs, METH_VARARGS, |
| 5491 | pjsua_enum_codecs_doc |
| 5492 | }, |
| 5493 | { |
| 5494 | "codec_set_priority", py_pjsua_codec_set_priority, METH_VARARGS, |
| 5495 | pjsua_codec_set_priority_doc |
| 5496 | }, |
| 5497 | { |
| 5498 | "codec_get_param", py_pjsua_codec_get_param, METH_VARARGS, |
| 5499 | pjsua_codec_get_param_doc |
| 5500 | }, |
| 5501 | { |
| 5502 | "codec_set_param", py_pjsua_codec_set_param, METH_VARARGS, |
| 5503 | pjsua_codec_set_param_doc |
| 5504 | }, |
| 5505 | { |
| 5506 | "call_get_max_count", py_pjsua_call_get_max_count, METH_VARARGS, |
| 5507 | pjsua_call_get_max_count_doc |
| 5508 | }, |
| 5509 | { |
| 5510 | "call_get_count", py_pjsua_call_get_count, METH_VARARGS, |
| 5511 | pjsua_call_get_count_doc |
| 5512 | }, |
| 5513 | { |
| 5514 | "enum_calls", py_pjsua_enum_calls, METH_VARARGS, |
| 5515 | pjsua_enum_calls_doc |
| 5516 | }, |
| 5517 | { |
| 5518 | "call_make_call", py_pjsua_call_make_call, METH_VARARGS, |
| 5519 | pjsua_call_make_call_doc |
| 5520 | }, |
| 5521 | { |
| 5522 | "call_is_active", py_pjsua_call_is_active, METH_VARARGS, |
| 5523 | pjsua_call_is_active_doc |
| 5524 | }, |
| 5525 | { |
| 5526 | "call_has_media", py_pjsua_call_has_media, METH_VARARGS, |
| 5527 | pjsua_call_has_media_doc |
| 5528 | }, |
| 5529 | { |
| 5530 | "call_get_conf_port", py_pjsua_call_get_conf_port, METH_VARARGS, |
| 5531 | pjsua_call_get_conf_port_doc |
| 5532 | }, |
| 5533 | { |
| 5534 | "call_get_info", py_pjsua_call_get_info, METH_VARARGS, |
| 5535 | pjsua_call_get_info_doc |
| 5536 | }, |
| 5537 | { |
| 5538 | "call_set_user_data", py_pjsua_call_set_user_data, METH_VARARGS, |
| 5539 | pjsua_call_set_user_data_doc |
| 5540 | }, |
| 5541 | { |
| 5542 | "call_get_user_data", py_pjsua_call_get_user_data, METH_VARARGS, |
| 5543 | pjsua_call_get_user_data_doc |
| 5544 | }, |
| 5545 | { |
| 5546 | "call_answer", py_pjsua_call_answer, METH_VARARGS, |
| 5547 | pjsua_call_answer_doc |
| 5548 | }, |
| 5549 | { |
| 5550 | "call_hangup", py_pjsua_call_hangup, METH_VARARGS, |
| 5551 | pjsua_call_hangup_doc |
| 5552 | }, |
| 5553 | { |
| 5554 | "call_set_hold", py_pjsua_call_set_hold, METH_VARARGS, |
| 5555 | pjsua_call_set_hold_doc |
| 5556 | }, |
| 5557 | { |
| 5558 | "call_reinvite", py_pjsua_call_reinvite, METH_VARARGS, |
| 5559 | pjsua_call_reinvite_doc |
| 5560 | }, |
| 5561 | { |
| 5562 | "call_xfer", py_pjsua_call_xfer, METH_VARARGS, |
| 5563 | pjsua_call_xfer_doc |
| 5564 | }, |
| 5565 | { |
| 5566 | "call_xfer_replaces", py_pjsua_call_xfer_replaces, METH_VARARGS, |
| 5567 | pjsua_call_xfer_replaces_doc |
| 5568 | }, |
| 5569 | { |
| 5570 | "call_dial_dtmf", py_pjsua_call_dial_dtmf, METH_VARARGS, |
| 5571 | pjsua_call_dial_dtmf_doc |
| 5572 | }, |
| 5573 | { |
| 5574 | "call_send_im", py_pjsua_call_send_im, METH_VARARGS, |
| 5575 | pjsua_call_send_im_doc |
| 5576 | }, |
| 5577 | { |
| 5578 | "call_send_typing_ind", py_pjsua_call_send_typing_ind, METH_VARARGS, |
| 5579 | pjsua_call_send_typing_ind_doc |
| 5580 | }, |
| 5581 | { |
| 5582 | "call_hangup_all", py_pjsua_call_hangup_all, METH_VARARGS, |
| 5583 | pjsua_call_hangup_all_doc |
| 5584 | }, |
| 5585 | { |
| 5586 | "call_dump", py_pjsua_call_dump, METH_VARARGS, |
| 5587 | pjsua_call_dump_doc |
| 5588 | }, |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 5589 | { |
| 5590 | "dump", py_pjsua_dump, METH_VARARGS, "Dump application state" |
| 5591 | }, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5592 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5593 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5594 | {NULL, NULL} /* end of function list */ |
| 5595 | }; |
| 5596 | |
| 5597 | |
| 5598 | |
| 5599 | /* |
| 5600 | * Mapping C structs from and to Python objects & initializing object |
| 5601 | */ |
| 5602 | DL_EXPORT(void) |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 5603 | initpy_pjsua(void) |
| 5604 | { |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5605 | PyObject* m = NULL; |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5606 | #define ADD_CONSTANT(mod,name) PyModule_AddIntConstant(mod,#name,name) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5607 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5608 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 5609 | PyEval_InitThreads(); |
| 5610 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5611 | if (PyType_Ready(&PyTyp_pjsua_callback) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5612 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5613 | if (PyType_Ready(&PyTyp_pjsua_config) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5614 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5615 | if (PyType_Ready(&PyTyp_pjsua_logging_config) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5616 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5617 | if (PyType_Ready(&PyTyp_pjsua_msg_data) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5618 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5619 | PyTyp_pjsua_media_config.tp_new = PyType_GenericNew; |
| 5620 | if (PyType_Ready(&PyTyp_pjsua_media_config) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5621 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5622 | PyTyp_pjsip_event.tp_new = PyType_GenericNew; |
| 5623 | if (PyType_Ready(&PyTyp_pjsip_event) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5624 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5625 | PyTyp_pjsip_rx_data.tp_new = PyType_GenericNew; |
| 5626 | if (PyType_Ready(&PyTyp_pjsip_rx_data) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5627 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5628 | PyTyp_pj_pool_t.tp_new = PyType_GenericNew; |
| 5629 | if (PyType_Ready(&PyTyp_pj_pool_t) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5630 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5631 | PyTyp_pjsip_endpoint.tp_new = PyType_GenericNew; |
| 5632 | if (PyType_Ready(&PyTyp_pjsip_endpoint) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5633 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5634 | PyTyp_pjmedia_endpt.tp_new = PyType_GenericNew; |
| 5635 | if (PyType_Ready(&PyTyp_pjmedia_endpt) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5636 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5637 | PyTyp_pj_pool_factory.tp_new = PyType_GenericNew; |
| 5638 | if (PyType_Ready(&PyTyp_pj_pool_factory) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5639 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5640 | PyTyp_pjsip_cred_info.tp_new = PyType_GenericNew; |
| 5641 | if (PyType_Ready(&PyTyp_pjsip_cred_info) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5642 | return; |
| 5643 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5644 | /* LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5645 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5646 | if (PyType_Ready(&PyTyp_pjsua_transport_config) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5647 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5648 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5649 | if (PyType_Ready(&PyTyp_pjsua_transport_info) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5650 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5651 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5652 | /* END OF LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5653 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5654 | /* LIB ACCOUNT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5655 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5656 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5657 | if (PyType_Ready(&PyTyp_pjsua_acc_config) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5658 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5659 | if (PyType_Ready(&PyTyp_pjsua_acc_info) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5660 | return; |
| 5661 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5662 | /* END OF LIB ACCOUNT */ |
| 5663 | |
| 5664 | /* LIB BUDDY */ |
| 5665 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5666 | if (PyType_Ready(&PyTyp_pjsua_buddy_config) < 0) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5667 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5668 | if (PyType_Ready(&PyTyp_pjsua_buddy_info) < 0) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5669 | return; |
| 5670 | |
| 5671 | /* END OF LIB BUDDY */ |
| 5672 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5673 | /* LIB MEDIA */ |
| 5674 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5675 | if (PyType_Ready(&PyTyp_pjsua_codec_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5676 | return; |
| 5677 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5678 | if (PyType_Ready(&PyTyp_pjsua_conf_port_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5679 | return; |
| 5680 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5681 | PyTyp_pjmedia_port.tp_new = PyType_GenericNew; |
| 5682 | if (PyType_Ready(&PyTyp_pjmedia_port) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5683 | return; |
| 5684 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5685 | if (PyType_Ready(&PyTyp_pjmedia_snd_dev_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5686 | return; |
| 5687 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5688 | PyTyp_pjmedia_codec_param_info.tp_new = PyType_GenericNew; |
| 5689 | if (PyType_Ready(&PyTyp_pjmedia_codec_param_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5690 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5691 | PyTyp_pjmedia_codec_param_setting.tp_new = PyType_GenericNew; |
| 5692 | if (PyType_Ready(&PyTyp_pjmedia_codec_param_setting) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5693 | return; |
| 5694 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5695 | if (PyType_Ready(&PyTyp_pjmedia_codec_param) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5696 | return; |
| 5697 | |
| 5698 | /* END OF LIB MEDIA */ |
| 5699 | |
| 5700 | /* LIB CALL */ |
| 5701 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5702 | PyTyp_pj_time_val.tp_new = PyType_GenericNew; |
| 5703 | if (PyType_Ready(&PyTyp_pj_time_val) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5704 | return; |
| 5705 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5706 | if (PyType_Ready(&PyTyp_pjsua_call_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5707 | return; |
| 5708 | |
| 5709 | /* END OF LIB CALL */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5710 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5711 | m = Py_InitModule3( |
| 5712 | "py_pjsua", py_pjsua_methods,"PJSUA-lib module for python" |
| 5713 | ); |
| 5714 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5715 | Py_INCREF(&PyTyp_pjsua_callback); |
| 5716 | PyModule_AddObject(m, "Callback", (PyObject *)&PyTyp_pjsua_callback); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5717 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5718 | Py_INCREF(&PyTyp_pjsua_config); |
| 5719 | PyModule_AddObject(m, "Config", (PyObject *)&PyTyp_pjsua_config); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5720 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5721 | Py_INCREF(&PyTyp_pjsua_media_config); |
| 5722 | PyModule_AddObject(m, "Media_Config", (PyObject *)&PyTyp_pjsua_media_config); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5723 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5724 | Py_INCREF(&PyTyp_pjsua_logging_config); |
| 5725 | PyModule_AddObject(m, "Logging_Config", (PyObject *)&PyTyp_pjsua_logging_config); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5726 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5727 | Py_INCREF(&PyTyp_pjsua_msg_data); |
| 5728 | PyModule_AddObject(m, "Msg_Data", (PyObject *)&PyTyp_pjsua_msg_data); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5729 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5730 | Py_INCREF(&PyTyp_pjsip_event); |
| 5731 | PyModule_AddObject(m, "Pjsip_Event", (PyObject *)&PyTyp_pjsip_event); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5732 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5733 | Py_INCREF(&PyTyp_pjsip_rx_data); |
| 5734 | PyModule_AddObject(m, "Pjsip_Rx_Data", (PyObject *)&PyTyp_pjsip_rx_data); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5735 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5736 | Py_INCREF(&PyTyp_pj_pool_t); |
| 5737 | PyModule_AddObject(m, "Pj_Pool", (PyObject *)&PyTyp_pj_pool_t); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5738 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5739 | Py_INCREF(&PyTyp_pjsip_endpoint); |
| 5740 | PyModule_AddObject(m, "Pjsip_Endpoint", (PyObject *)&PyTyp_pjsip_endpoint); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5741 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5742 | Py_INCREF(&PyTyp_pjmedia_endpt); |
| 5743 | PyModule_AddObject(m, "Pjmedia_Endpt", (PyObject *)&PyTyp_pjmedia_endpt); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5744 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5745 | Py_INCREF(&PyTyp_pj_pool_factory); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5746 | PyModule_AddObject( |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5747 | m, "Pj_Pool_Factory", (PyObject *)&PyTyp_pj_pool_factory |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5748 | ); |
| 5749 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5750 | Py_INCREF(&PyTyp_pjsip_cred_info); |
| 5751 | PyModule_AddObject(m, "Pjsip_Cred_Info", |
| 5752 | (PyObject *)&PyTyp_pjsip_cred_info |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5753 | ); |
| 5754 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5755 | /* LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5756 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5757 | Py_INCREF(&PyTyp_pjsua_transport_config); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5758 | PyModule_AddObject |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5759 | (m, "Transport_Config", (PyObject *)&PyTyp_pjsua_transport_config); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5760 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5761 | Py_INCREF(&PyTyp_pjsua_transport_info); |
| 5762 | PyModule_AddObject(m, "Transport_Info", (PyObject *)&PyTyp_pjsua_transport_info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5763 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5764 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5765 | /* END OF LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5766 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5767 | /* LIB ACCOUNT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5768 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5769 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5770 | Py_INCREF(&PyTyp_pjsua_acc_config); |
| 5771 | PyModule_AddObject(m, "Acc_Config", (PyObject *)&PyTyp_pjsua_acc_config); |
| 5772 | Py_INCREF(&PyTyp_pjsua_acc_info); |
| 5773 | PyModule_AddObject(m, "Acc_Info", (PyObject *)&PyTyp_pjsua_acc_info); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5774 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5775 | /* END OF LIB ACCOUNT */ |
| 5776 | |
| 5777 | /* LIB BUDDY */ |
| 5778 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5779 | Py_INCREF(&PyTyp_pjsua_buddy_config); |
| 5780 | PyModule_AddObject(m, "Buddy_Config", (PyObject *)&PyTyp_pjsua_buddy_config); |
| 5781 | Py_INCREF(&PyTyp_pjsua_buddy_info); |
| 5782 | PyModule_AddObject(m, "Buddy_Info", (PyObject *)&PyTyp_pjsua_buddy_info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5783 | |
| 5784 | /* END OF LIB BUDDY */ |
| 5785 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5786 | /* LIB MEDIA */ |
| 5787 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5788 | Py_INCREF(&PyTyp_pjsua_codec_info); |
| 5789 | PyModule_AddObject(m, "Codec_Info", (PyObject *)&PyTyp_pjsua_codec_info); |
| 5790 | Py_INCREF(&PyTyp_pjsua_conf_port_info); |
| 5791 | PyModule_AddObject(m, "Conf_Port_Info", (PyObject *)&PyTyp_pjsua_conf_port_info); |
| 5792 | Py_INCREF(&PyTyp_pjmedia_port); |
| 5793 | PyModule_AddObject(m, "PJMedia_Port", (PyObject *)&PyTyp_pjmedia_port); |
| 5794 | Py_INCREF(&PyTyp_pjmedia_snd_dev_info); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5795 | PyModule_AddObject(m, "PJMedia_Snd_Dev_Info", |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5796 | (PyObject *)&PyTyp_pjmedia_snd_dev_info); |
| 5797 | Py_INCREF(&PyTyp_pjmedia_codec_param_info); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5798 | PyModule_AddObject(m, "PJMedia_Codec_Param_Info", |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5799 | (PyObject *)&PyTyp_pjmedia_codec_param_info); |
| 5800 | Py_INCREF(&PyTyp_pjmedia_codec_param_setting); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5801 | PyModule_AddObject(m, "PJMedia_Codec_Param_Setting", |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5802 | (PyObject *)&PyTyp_pjmedia_codec_param_setting); |
| 5803 | Py_INCREF(&PyTyp_pjmedia_codec_param); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5804 | PyModule_AddObject(m, "PJMedia_Codec_Param", |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5805 | (PyObject *)&PyTyp_pjmedia_codec_param); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5806 | |
| 5807 | /* END OF LIB MEDIA */ |
| 5808 | |
| 5809 | /* LIB CALL */ |
| 5810 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5811 | Py_INCREF(&PyTyp_pj_time_val); |
| 5812 | PyModule_AddObject(m, "PJ_Time_Val", (PyObject *)&PyTyp_pj_time_val); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5813 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame^] | 5814 | Py_INCREF(&PyTyp_pjsua_call_info); |
| 5815 | PyModule_AddObject(m, "Call_Info", (PyObject *)&PyTyp_pjsua_call_info); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5816 | |
| 5817 | /* END OF LIB CALL */ |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5818 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5819 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5820 | /* |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5821 | * Add various constants. |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5822 | */ |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5823 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5824 | /* Call states */ |
| 5825 | ADD_CONSTANT(m, PJSIP_INV_STATE_NULL); |
| 5826 | ADD_CONSTANT(m, PJSIP_INV_STATE_CALLING); |
| 5827 | ADD_CONSTANT(m, PJSIP_INV_STATE_INCOMING); |
| 5828 | ADD_CONSTANT(m, PJSIP_INV_STATE_EARLY); |
| 5829 | ADD_CONSTANT(m, PJSIP_INV_STATE_CONNECTING); |
| 5830 | ADD_CONSTANT(m, PJSIP_INV_STATE_CONFIRMED); |
| 5831 | ADD_CONSTANT(m, PJSIP_INV_STATE_DISCONNECTED); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5832 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5833 | /* Call media status (enum pjsua_call_media_status) */ |
| 5834 | ADD_CONSTANT(m, PJSUA_CALL_MEDIA_NONE); |
| 5835 | ADD_CONSTANT(m, PJSUA_CALL_MEDIA_ACTIVE); |
| 5836 | ADD_CONSTANT(m, PJSUA_CALL_MEDIA_LOCAL_HOLD); |
| 5837 | ADD_CONSTANT(m, PJSUA_CALL_MEDIA_REMOTE_HOLD); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5838 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5839 | /* Buddy status */ |
| 5840 | ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_UNKNOWN); |
| 5841 | ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_ONLINE); |
| 5842 | ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_OFFLINE); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5843 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5844 | /* PJSIP transport types (enum pjsip_transport_type_e) */ |
| 5845 | ADD_CONSTANT(m, PJSIP_TRANSPORT_UNSPECIFIED); |
| 5846 | ADD_CONSTANT(m, PJSIP_TRANSPORT_UDP); |
| 5847 | ADD_CONSTANT(m, PJSIP_TRANSPORT_TCP); |
| 5848 | ADD_CONSTANT(m, PJSIP_TRANSPORT_TLS); |
| 5849 | ADD_CONSTANT(m, PJSIP_TRANSPORT_SCTP); |
| 5850 | ADD_CONSTANT(m, PJSIP_TRANSPORT_LOOP); |
| 5851 | ADD_CONSTANT(m, PJSIP_TRANSPORT_LOOP_DGRAM); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5852 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5853 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5854 | /* Invalid IDs */ |
| 5855 | ADD_CONSTANT(m, PJSUA_INVALID_ID); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5856 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5857 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5858 | /* Various compile time constants */ |
| 5859 | ADD_CONSTANT(m, PJSUA_ACC_MAX_PROXIES); |
| 5860 | ADD_CONSTANT(m, PJSUA_MAX_ACC); |
| 5861 | ADD_CONSTANT(m, PJSUA_REG_INTERVAL); |
| 5862 | ADD_CONSTANT(m, PJSUA_PUBLISH_EXPIRATION); |
| 5863 | ADD_CONSTANT(m, PJSUA_DEFAULT_ACC_PRIORITY); |
| 5864 | ADD_CONSTANT(m, PJSUA_MAX_BUDDIES); |
| 5865 | ADD_CONSTANT(m, PJSUA_MAX_CONF_PORTS); |
| 5866 | ADD_CONSTANT(m, PJSUA_DEFAULT_CLOCK_RATE); |
| 5867 | ADD_CONSTANT(m, PJSUA_DEFAULT_CODEC_QUALITY); |
| 5868 | ADD_CONSTANT(m, PJSUA_DEFAULT_ILBC_MODE); |
| 5869 | ADD_CONSTANT(m, PJSUA_DEFAULT_EC_TAIL_LEN); |
| 5870 | ADD_CONSTANT(m, PJSUA_MAX_CALLS); |
| 5871 | ADD_CONSTANT(m, PJSUA_XFER_NO_REQUIRE_REPLACES); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5872 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5873 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5874 | #undef ADD_CONSTANT |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 5875 | } |