Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | 32177c0 | 2008-06-20 22:44:47 +0000 | [diff] [blame] | 3 | * Copyright (C) 2003-2008 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 | 429fa1f | 2008-01-18 17:18:55 +0000 | [diff] [blame] | 38 | static void cb_log_cb(int level, const char *data, int 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 | { |
Benny Prijono | 0c97d53 | 2008-02-14 15:50:46 +0000 | [diff] [blame] | 155 | if (PyCallable_Check(g_obj_callback->on_dtmf_digit)) |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 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( |
Benny Prijono | 0c97d53 | 2008-02-14 15:50:46 +0000 | [diff] [blame] | 164 | g_obj_callback->on_dtmf_digit, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 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; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2406 | PyListObject * listeners; |
| 2407 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2408 | } PyObj_pjsua_conf_port_info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2409 | |
| 2410 | |
| 2411 | /* |
| 2412 | * conf_port_info_dealloc |
| 2413 | * deletes a conf_port_info from memory |
| 2414 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2415 | static void conf_port_info_dealloc(PyObj_pjsua_conf_port_info* self) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2416 | { |
| 2417 | Py_XDECREF(self->name); |
| 2418 | Py_XDECREF(self->listeners); |
| 2419 | self->ob_type->tp_free((PyObject*)self); |
| 2420 | } |
| 2421 | |
| 2422 | |
| 2423 | /* |
| 2424 | * conf_port_info_new |
| 2425 | * constructor for conf_port_info object |
| 2426 | */ |
| 2427 | static PyObject * conf_port_info_new(PyTypeObject *type, PyObject *args, |
| 2428 | PyObject *kwds) |
| 2429 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2430 | PyObj_pjsua_conf_port_info *self; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2431 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2432 | PJ_UNUSED_ARG(args); |
| 2433 | PJ_UNUSED_ARG(kwds); |
| 2434 | |
| 2435 | self = (PyObj_pjsua_conf_port_info *)type->tp_alloc(type, 0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2436 | if (self != NULL) |
| 2437 | { |
| 2438 | self->name = PyString_FromString(""); |
| 2439 | if (self->name == NULL) |
| 2440 | { |
| 2441 | Py_DECREF(self); |
| 2442 | return NULL; |
| 2443 | } |
| 2444 | |
Benny Prijono | d7ea605 | 2007-09-17 15:44:47 +0000 | [diff] [blame] | 2445 | self->listeners = (PyListObject *)PyList_New(0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2446 | if (self->listeners == NULL) |
| 2447 | { |
| 2448 | Py_DECREF(self); |
| 2449 | return NULL; |
| 2450 | } |
| 2451 | } |
| 2452 | return (PyObject *)self; |
| 2453 | } |
| 2454 | |
| 2455 | /* |
| 2456 | * conf_port_info_members |
| 2457 | */ |
| 2458 | static PyMemberDef conf_port_info_members[] = |
| 2459 | { |
| 2460 | { |
| 2461 | "slot_id", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2462 | offsetof(PyObj_pjsua_conf_port_info, slot_id), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2463 | "Conference port number." |
| 2464 | }, |
| 2465 | { |
| 2466 | "name", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2467 | offsetof(PyObj_pjsua_conf_port_info, name), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2468 | "Port name" |
| 2469 | }, |
| 2470 | { |
| 2471 | "clock_rate", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2472 | offsetof(PyObj_pjsua_conf_port_info, clock_rate), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2473 | "Clock rate" |
| 2474 | }, |
| 2475 | { |
| 2476 | "channel_count", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2477 | offsetof(PyObj_pjsua_conf_port_info, channel_count), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2478 | "Number of channels." |
| 2479 | }, |
| 2480 | { |
| 2481 | "samples_per_frame", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2482 | offsetof(PyObj_pjsua_conf_port_info, samples_per_frame), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2483 | "Samples per frame " |
| 2484 | }, |
| 2485 | { |
| 2486 | "bits_per_sample", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2487 | offsetof(PyObj_pjsua_conf_port_info, bits_per_sample), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2488 | "Bits per sample" |
| 2489 | }, |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 2490 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2491 | "listeners", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2492 | offsetof(PyObj_pjsua_conf_port_info, listeners), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2493 | "Array of listeners (in other words, ports where this port " |
| 2494 | "is transmitting to" |
| 2495 | }, |
| 2496 | |
| 2497 | {NULL} /* Sentinel */ |
| 2498 | }; |
| 2499 | |
| 2500 | |
| 2501 | |
| 2502 | |
| 2503 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2504 | * PyTyp_pjsua_conf_port_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2505 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2506 | static PyTypeObject PyTyp_pjsua_conf_port_info = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2507 | { |
| 2508 | PyObject_HEAD_INIT(NULL) |
| 2509 | 0, /*ob_size*/ |
| 2510 | "py_pjsua.Conf_Port_Info", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2511 | sizeof(PyObj_pjsua_conf_port_info), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2512 | 0, /*tp_itemsize*/ |
| 2513 | (destructor)conf_port_info_dealloc,/*tp_dealloc*/ |
| 2514 | 0, /*tp_print*/ |
| 2515 | 0, /*tp_getattr*/ |
| 2516 | 0, /*tp_setattr*/ |
| 2517 | 0, /*tp_compare*/ |
| 2518 | 0, /*tp_repr*/ |
| 2519 | 0, /*tp_as_number*/ |
| 2520 | 0, /*tp_as_sequence*/ |
| 2521 | 0, /*tp_as_mapping*/ |
| 2522 | 0, /*tp_hash */ |
| 2523 | 0, /*tp_call*/ |
| 2524 | 0, /*tp_str*/ |
| 2525 | 0, /*tp_getattro*/ |
| 2526 | 0, /*tp_setattro*/ |
| 2527 | 0, /*tp_as_buffer*/ |
| 2528 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2529 | "Conf Port Info objects", /* tp_doc */ |
| 2530 | 0, /* tp_traverse */ |
| 2531 | 0, /* tp_clear */ |
| 2532 | 0, /* tp_richcompare */ |
| 2533 | 0, /* tp_weaklistoffset */ |
| 2534 | 0, /* tp_iter */ |
| 2535 | 0, /* tp_iternext */ |
| 2536 | 0, /* tp_methods */ |
| 2537 | conf_port_info_members, /* tp_members */ |
| 2538 | 0, /* tp_getset */ |
| 2539 | 0, /* tp_base */ |
| 2540 | 0, /* tp_dict */ |
| 2541 | 0, /* tp_descr_get */ |
| 2542 | 0, /* tp_descr_set */ |
| 2543 | 0, /* tp_dictoffset */ |
| 2544 | 0, /* tp_init */ |
| 2545 | 0, /* tp_alloc */ |
| 2546 | conf_port_info_new, /* tp_new */ |
| 2547 | |
| 2548 | }; |
| 2549 | |
| 2550 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2551 | * PyObj_pjmedia_port |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2552 | */ |
| 2553 | typedef struct |
| 2554 | { |
| 2555 | PyObject_HEAD |
| 2556 | /* Type-specific fields go here. */ |
| 2557 | pjmedia_port * port; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2558 | } PyObj_pjmedia_port; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2559 | |
| 2560 | |
| 2561 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2562 | * PyTyp_pjmedia_port |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2563 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2564 | static PyTypeObject PyTyp_pjmedia_port = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2565 | { |
| 2566 | PyObject_HEAD_INIT(NULL) |
| 2567 | 0, /*ob_size*/ |
| 2568 | "py_pjsua.PJMedia_Port", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2569 | sizeof(PyObj_pjmedia_port), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2570 | 0, /*tp_itemsize*/ |
| 2571 | 0, /*tp_dealloc*/ |
| 2572 | 0, /*tp_print*/ |
| 2573 | 0, /*tp_getattr*/ |
| 2574 | 0, /*tp_setattr*/ |
| 2575 | 0, /*tp_compare*/ |
| 2576 | 0, /*tp_repr*/ |
| 2577 | 0, /*tp_as_number*/ |
| 2578 | 0, /*tp_as_sequence*/ |
| 2579 | 0, /*tp_as_mapping*/ |
| 2580 | 0, /*tp_hash */ |
| 2581 | 0, /*tp_call*/ |
| 2582 | 0, /*tp_str*/ |
| 2583 | 0, /*tp_getattro*/ |
| 2584 | 0, /*tp_setattro*/ |
| 2585 | 0, /*tp_as_buffer*/ |
| 2586 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2587 | "pjmedia_port objects", /* tp_doc */ |
| 2588 | |
| 2589 | }; |
| 2590 | |
| 2591 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2592 | * PyObj_pjmedia_snd_dev_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2593 | * PJMedia Snd Dev Info |
| 2594 | */ |
| 2595 | typedef struct |
| 2596 | { |
| 2597 | PyObject_HEAD |
| 2598 | /* Type-specific fields go here. */ |
| 2599 | |
| 2600 | |
| 2601 | unsigned input_count; |
| 2602 | unsigned output_count; |
| 2603 | unsigned default_samples_per_sec; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 2604 | PyObject * name; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2605 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2606 | } PyObj_pjmedia_snd_dev_info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2607 | |
| 2608 | |
| 2609 | /* |
| 2610 | * pjmedia_snd_dev_info_dealloc |
| 2611 | * deletes a pjmedia_snd_dev_info from memory |
| 2612 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2613 | static void pjmedia_snd_dev_info_dealloc(PyObj_pjmedia_snd_dev_info* self) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2614 | { |
| 2615 | Py_XDECREF(self->name); |
| 2616 | self->ob_type->tp_free((PyObject*)self); |
| 2617 | } |
| 2618 | |
| 2619 | |
| 2620 | /* |
| 2621 | * pjmedia_snd_dev_info_new |
| 2622 | * constructor for pjmedia_snd_dev_info object |
| 2623 | */ |
| 2624 | static PyObject * pjmedia_snd_dev_info_new(PyTypeObject *type, PyObject *args, |
| 2625 | PyObject *kwds) |
| 2626 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2627 | PyObj_pjmedia_snd_dev_info *self; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2628 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2629 | PJ_UNUSED_ARG(args); |
| 2630 | PJ_UNUSED_ARG(kwds); |
| 2631 | |
| 2632 | self = (PyObj_pjmedia_snd_dev_info *)type->tp_alloc(type, 0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2633 | if (self != NULL) |
| 2634 | { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 2635 | self->name = PyString_FromString(""); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2636 | if (self->name == NULL) |
| 2637 | { |
| 2638 | Py_DECREF(self); |
| 2639 | return NULL; |
| 2640 | } |
| 2641 | |
| 2642 | } |
| 2643 | return (PyObject *)self; |
| 2644 | } |
| 2645 | |
| 2646 | /* |
| 2647 | * pjmedia_snd_dev_info_members |
| 2648 | */ |
| 2649 | static PyMemberDef pjmedia_snd_dev_info_members[] = |
| 2650 | { |
| 2651 | |
| 2652 | { |
| 2653 | "name", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2654 | offsetof(PyObj_pjmedia_snd_dev_info, name), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2655 | "Device name" |
| 2656 | }, |
| 2657 | { |
| 2658 | "input_count", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2659 | offsetof(PyObj_pjmedia_snd_dev_info, input_count), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2660 | "Max number of input channels" |
| 2661 | }, |
| 2662 | { |
| 2663 | "output_count", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2664 | offsetof(PyObj_pjmedia_snd_dev_info, output_count), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2665 | "Max number of output channels" |
| 2666 | }, |
| 2667 | { |
| 2668 | "default_samples_per_sec", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2669 | offsetof(PyObj_pjmedia_snd_dev_info, default_samples_per_sec), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2670 | "Default sampling rate." |
| 2671 | }, |
| 2672 | |
| 2673 | |
| 2674 | {NULL} /* Sentinel */ |
| 2675 | }; |
| 2676 | |
| 2677 | |
| 2678 | |
| 2679 | |
| 2680 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2681 | * PyTyp_pjmedia_snd_dev_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2682 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2683 | static PyTypeObject PyTyp_pjmedia_snd_dev_info = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2684 | { |
| 2685 | PyObject_HEAD_INIT(NULL) |
| 2686 | 0, /*ob_size*/ |
| 2687 | "py_pjsua.PJMedia_Snd_Dev_Info", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2688 | sizeof(PyObj_pjmedia_snd_dev_info), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2689 | 0, /*tp_itemsize*/ |
| 2690 | (destructor)pjmedia_snd_dev_info_dealloc,/*tp_dealloc*/ |
| 2691 | 0, /*tp_print*/ |
| 2692 | 0, /*tp_getattr*/ |
| 2693 | 0, /*tp_setattr*/ |
| 2694 | 0, /*tp_compare*/ |
| 2695 | 0, /*tp_repr*/ |
| 2696 | 0, /*tp_as_number*/ |
| 2697 | 0, /*tp_as_sequence*/ |
| 2698 | 0, /*tp_as_mapping*/ |
| 2699 | 0, /*tp_hash */ |
| 2700 | 0, /*tp_call*/ |
| 2701 | 0, /*tp_str*/ |
| 2702 | 0, /*tp_getattro*/ |
| 2703 | 0, /*tp_setattro*/ |
| 2704 | 0, /*tp_as_buffer*/ |
| 2705 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2706 | "PJMedia Snd Dev Info objects", /* tp_doc */ |
| 2707 | 0, /* tp_traverse */ |
| 2708 | 0, /* tp_clear */ |
| 2709 | 0, /* tp_richcompare */ |
| 2710 | 0, /* tp_weaklistoffset */ |
| 2711 | 0, /* tp_iter */ |
| 2712 | 0, /* tp_iternext */ |
| 2713 | 0, /* tp_methods */ |
| 2714 | pjmedia_snd_dev_info_members, /* tp_members */ |
| 2715 | 0, /* tp_getset */ |
| 2716 | 0, /* tp_base */ |
| 2717 | 0, /* tp_dict */ |
| 2718 | 0, /* tp_descr_get */ |
| 2719 | 0, /* tp_descr_set */ |
| 2720 | 0, /* tp_dictoffset */ |
| 2721 | 0, /* tp_init */ |
| 2722 | 0, /* tp_alloc */ |
| 2723 | pjmedia_snd_dev_info_new, /* tp_new */ |
| 2724 | |
| 2725 | }; |
| 2726 | |
| 2727 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2728 | * PyObj_pjmedia_codec_param_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2729 | * PJMedia Codec Param Info |
| 2730 | */ |
| 2731 | typedef struct |
| 2732 | { |
| 2733 | PyObject_HEAD |
| 2734 | /* Type-specific fields go here. */ |
| 2735 | |
| 2736 | unsigned clock_rate; |
| 2737 | unsigned channel_cnt; |
| 2738 | pj_uint32_t avg_bps; |
| 2739 | pj_uint16_t frm_ptime; |
| 2740 | pj_uint8_t pcm_bits_per_sample; |
| 2741 | pj_uint8_t pt; |
| 2742 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2743 | } PyObj_pjmedia_codec_param_info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2744 | |
| 2745 | |
| 2746 | |
| 2747 | /* |
| 2748 | * pjmedia_codec_param_info_members |
| 2749 | */ |
| 2750 | static PyMemberDef pjmedia_codec_param_info_members[] = |
| 2751 | { |
| 2752 | |
| 2753 | { |
| 2754 | "clock_rate", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2755 | offsetof(PyObj_pjmedia_codec_param_info, clock_rate), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2756 | "Sampling rate in Hz" |
| 2757 | }, |
| 2758 | { |
| 2759 | "channel_cnt", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2760 | offsetof(PyObj_pjmedia_codec_param_info, channel_cnt), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2761 | "Channel count" |
| 2762 | }, |
| 2763 | { |
| 2764 | "avg_bps", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2765 | offsetof(PyObj_pjmedia_codec_param_info, avg_bps), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2766 | "Average bandwidth in bits/sec" |
| 2767 | }, |
| 2768 | { |
| 2769 | "frm_ptime", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2770 | offsetof(PyObj_pjmedia_codec_param_info, frm_ptime), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2771 | "Base frame ptime in msec." |
| 2772 | }, |
| 2773 | { |
| 2774 | "pcm_bits_per_sample", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2775 | offsetof(PyObj_pjmedia_codec_param_info, pcm_bits_per_sample), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2776 | "Bits/sample in the PCM side" |
| 2777 | }, |
| 2778 | { |
| 2779 | "pt", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2780 | offsetof(PyObj_pjmedia_codec_param_info, pt), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2781 | "Payload type" |
| 2782 | }, |
| 2783 | |
| 2784 | {NULL} /* Sentinel */ |
| 2785 | }; |
| 2786 | |
| 2787 | |
| 2788 | |
| 2789 | |
| 2790 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2791 | * PyTyp_pjmedia_codec_param_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2792 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2793 | static PyTypeObject PyTyp_pjmedia_codec_param_info = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2794 | { |
| 2795 | PyObject_HEAD_INIT(NULL) |
| 2796 | 0, /*ob_size*/ |
| 2797 | "py_pjsua.PJMedia_Codec_Param_Info", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2798 | sizeof(PyObj_pjmedia_codec_param_info), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2799 | 0, /*tp_itemsize*/ |
| 2800 | 0,/*tp_dealloc*/ |
| 2801 | 0, /*tp_print*/ |
| 2802 | 0, /*tp_getattr*/ |
| 2803 | 0, /*tp_setattr*/ |
| 2804 | 0, /*tp_compare*/ |
| 2805 | 0, /*tp_repr*/ |
| 2806 | 0, /*tp_as_number*/ |
| 2807 | 0, /*tp_as_sequence*/ |
| 2808 | 0, /*tp_as_mapping*/ |
| 2809 | 0, /*tp_hash */ |
| 2810 | 0, /*tp_call*/ |
| 2811 | 0, /*tp_str*/ |
| 2812 | 0, /*tp_getattro*/ |
| 2813 | 0, /*tp_setattro*/ |
| 2814 | 0, /*tp_as_buffer*/ |
| 2815 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2816 | "PJMedia Codec Param Info objects", /* tp_doc */ |
| 2817 | 0, /* tp_traverse */ |
| 2818 | 0, /* tp_clear */ |
| 2819 | 0, /* tp_richcompare */ |
| 2820 | 0, /* tp_weaklistoffset */ |
| 2821 | 0, /* tp_iter */ |
| 2822 | 0, /* tp_iternext */ |
| 2823 | 0, /* tp_methods */ |
| 2824 | pjmedia_codec_param_info_members, /* tp_members */ |
| 2825 | |
| 2826 | |
| 2827 | }; |
| 2828 | |
| 2829 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2830 | * PyObj_pjmedia_codec_param_setting |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2831 | * PJMedia Codec Param Setting |
| 2832 | */ |
| 2833 | typedef struct |
| 2834 | { |
| 2835 | PyObject_HEAD |
| 2836 | /* Type-specific fields go here. */ |
| 2837 | pj_uint8_t frm_per_pkt; |
| 2838 | unsigned vad; |
| 2839 | unsigned cng; |
| 2840 | unsigned penh; |
| 2841 | unsigned plc; |
| 2842 | unsigned reserved; |
| 2843 | pj_uint8_t enc_fmtp_mode; |
| 2844 | pj_uint8_t dec_fmtp_mode; |
| 2845 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2846 | } PyObj_pjmedia_codec_param_setting; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2847 | |
| 2848 | |
| 2849 | |
| 2850 | /* |
| 2851 | * pjmedia_codec_param_setting_members |
| 2852 | */ |
| 2853 | static PyMemberDef pjmedia_codec_param_setting_members[] = |
| 2854 | { |
| 2855 | |
| 2856 | { |
| 2857 | "frm_per_pkt", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2858 | offsetof(PyObj_pjmedia_codec_param_setting, frm_per_pkt), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2859 | "Number of frames per packet" |
| 2860 | }, |
| 2861 | { |
| 2862 | "vad", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2863 | offsetof(PyObj_pjmedia_codec_param_setting, vad), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2864 | "Voice Activity Detector" |
| 2865 | }, |
| 2866 | { |
| 2867 | "penh", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2868 | offsetof(PyObj_pjmedia_codec_param_setting, penh), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2869 | "Perceptual Enhancement" |
| 2870 | }, |
| 2871 | { |
| 2872 | "plc", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2873 | offsetof(PyObj_pjmedia_codec_param_setting, plc), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2874 | "Packet loss concealment" |
| 2875 | }, |
| 2876 | { |
| 2877 | "reserved", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2878 | offsetof(PyObj_pjmedia_codec_param_setting, reserved), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2879 | "Reserved, must be zero" |
| 2880 | }, |
| 2881 | { |
| 2882 | "cng", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2883 | offsetof(PyObj_pjmedia_codec_param_setting, cng), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2884 | "Comfort Noise Generator" |
| 2885 | }, |
| 2886 | { |
| 2887 | "enc_fmtp_mode", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2888 | offsetof(PyObj_pjmedia_codec_param_setting, enc_fmtp_mode), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2889 | "Mode param in fmtp (def:0)" |
| 2890 | }, |
| 2891 | { |
| 2892 | "dec_fmtp_mode", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2893 | offsetof(PyObj_pjmedia_codec_param_setting, dec_fmtp_mode), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2894 | "Mode param in fmtp (def:0)" |
| 2895 | }, |
| 2896 | |
| 2897 | {NULL} /* Sentinel */ |
| 2898 | }; |
| 2899 | |
| 2900 | |
| 2901 | |
| 2902 | |
| 2903 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2904 | * PyTyp_pjmedia_codec_param_setting |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2905 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2906 | static PyTypeObject PyTyp_pjmedia_codec_param_setting = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2907 | { |
| 2908 | PyObject_HEAD_INIT(NULL) |
| 2909 | 0, /*ob_size*/ |
| 2910 | "py_pjsua.PJMedia_Codec_Param_Setting", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2911 | sizeof(PyObj_pjmedia_codec_param_setting), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2912 | 0, /*tp_itemsize*/ |
| 2913 | 0,/*tp_dealloc*/ |
| 2914 | 0, /*tp_print*/ |
| 2915 | 0, /*tp_getattr*/ |
| 2916 | 0, /*tp_setattr*/ |
| 2917 | 0, /*tp_compare*/ |
| 2918 | 0, /*tp_repr*/ |
| 2919 | 0, /*tp_as_number*/ |
| 2920 | 0, /*tp_as_sequence*/ |
| 2921 | 0, /*tp_as_mapping*/ |
| 2922 | 0, /*tp_hash */ |
| 2923 | 0, /*tp_call*/ |
| 2924 | 0, /*tp_str*/ |
| 2925 | 0, /*tp_getattro*/ |
| 2926 | 0, /*tp_setattro*/ |
| 2927 | 0, /*tp_as_buffer*/ |
| 2928 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 2929 | "PJMedia Codec Param Setting objects", /* tp_doc */ |
| 2930 | 0, /* tp_traverse */ |
| 2931 | 0, /* tp_clear */ |
| 2932 | 0, /* tp_richcompare */ |
| 2933 | 0, /* tp_weaklistoffset */ |
| 2934 | 0, /* tp_iter */ |
| 2935 | 0, /* tp_iternext */ |
| 2936 | 0, /* tp_methods */ |
| 2937 | pjmedia_codec_param_setting_members, /* tp_members */ |
| 2938 | |
| 2939 | |
| 2940 | }; |
| 2941 | |
| 2942 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2943 | * PyObj_pjmedia_codec_param |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2944 | * PJMedia Codec Param |
| 2945 | */ |
| 2946 | typedef struct |
| 2947 | { |
| 2948 | PyObject_HEAD |
| 2949 | /* Type-specific fields go here. */ |
| 2950 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2951 | PyObj_pjmedia_codec_param_info * info; |
| 2952 | PyObj_pjmedia_codec_param_setting * setting; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2953 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2954 | } PyObj_pjmedia_codec_param; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2955 | |
| 2956 | |
| 2957 | /* |
| 2958 | * pjmedia_codec_param_dealloc |
| 2959 | * deletes a pjmedia_codec_param from memory |
| 2960 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2961 | static void pjmedia_codec_param_dealloc(PyObj_pjmedia_codec_param* self) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2962 | { |
| 2963 | Py_XDECREF(self->info); |
| 2964 | Py_XDECREF(self->setting); |
| 2965 | self->ob_type->tp_free((PyObject*)self); |
| 2966 | } |
| 2967 | |
| 2968 | |
| 2969 | /* |
| 2970 | * pjmedia_codec_param_new |
| 2971 | * constructor for pjmedia_codec_param object |
| 2972 | */ |
| 2973 | static PyObject * pjmedia_codec_param_new(PyTypeObject *type, PyObject *args, |
| 2974 | PyObject *kwds) |
| 2975 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2976 | PyObj_pjmedia_codec_param *self; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2977 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2978 | PJ_UNUSED_ARG(args); |
| 2979 | PJ_UNUSED_ARG(kwds); |
| 2980 | |
| 2981 | self = (PyObj_pjmedia_codec_param *)type->tp_alloc(type, 0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2982 | if (self != NULL) |
| 2983 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2984 | self->info = (PyObj_pjmedia_codec_param_info *) |
| 2985 | PyType_GenericNew(&PyTyp_pjmedia_codec_param_info, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2986 | if (self->info == NULL) |
| 2987 | { |
| 2988 | Py_DECREF(self); |
| 2989 | return NULL; |
| 2990 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 2991 | self->setting = (PyObj_pjmedia_codec_param_setting *) |
| 2992 | PyType_GenericNew(&PyTyp_pjmedia_codec_param_setting, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 2993 | if (self->setting == NULL) |
| 2994 | { |
| 2995 | Py_DECREF(self); |
| 2996 | return NULL; |
| 2997 | } |
| 2998 | } |
| 2999 | return (PyObject *)self; |
| 3000 | } |
| 3001 | |
| 3002 | /* |
| 3003 | * pjmedia_codec_param_members |
| 3004 | */ |
| 3005 | static PyMemberDef pjmedia_codec_param_members[] = |
| 3006 | { |
| 3007 | |
| 3008 | { |
| 3009 | "info", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3010 | offsetof(PyObj_pjmedia_codec_param, info), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3011 | "The 'info' part of codec param describes the capability of the codec," |
| 3012 | " and the value should NOT be changed by application." |
| 3013 | }, |
| 3014 | { |
| 3015 | "setting", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3016 | offsetof(PyObj_pjmedia_codec_param, setting), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3017 | "The 'setting' part of codec param describes various settings to be " |
| 3018 | "applied to the codec. When the codec param is retrieved from the " |
| 3019 | "codec or codec factory, the values of these will be filled by " |
| 3020 | "the capability of the codec. Any features that are supported by " |
| 3021 | "the codec (e.g. vad or plc) will be turned on, so that application " |
| 3022 | "can query which capabilities are supported by the codec. " |
| 3023 | "Application may change the settings here before instantiating " |
| 3024 | "the codec/stream." |
| 3025 | }, |
| 3026 | |
| 3027 | {NULL} /* Sentinel */ |
| 3028 | }; |
| 3029 | |
| 3030 | |
| 3031 | |
| 3032 | |
| 3033 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3034 | * PyTyp_pjmedia_codec_param |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3035 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3036 | static PyTypeObject PyTyp_pjmedia_codec_param = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3037 | { |
| 3038 | PyObject_HEAD_INIT(NULL) |
| 3039 | 0, /*ob_size*/ |
| 3040 | "py_pjsua.PJMedia_Codec_Param", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3041 | sizeof(PyObj_pjmedia_codec_param), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3042 | 0, /*tp_itemsize*/ |
| 3043 | (destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/ |
| 3044 | 0, /*tp_print*/ |
| 3045 | 0, /*tp_getattr*/ |
| 3046 | 0, /*tp_setattr*/ |
| 3047 | 0, /*tp_compare*/ |
| 3048 | 0, /*tp_repr*/ |
| 3049 | 0, /*tp_as_number*/ |
| 3050 | 0, /*tp_as_sequence*/ |
| 3051 | 0, /*tp_as_mapping*/ |
| 3052 | 0, /*tp_hash */ |
| 3053 | 0, /*tp_call*/ |
| 3054 | 0, /*tp_str*/ |
| 3055 | 0, /*tp_getattro*/ |
| 3056 | 0, /*tp_setattro*/ |
| 3057 | 0, /*tp_as_buffer*/ |
| 3058 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 3059 | "PJMedia Codec Param objects", /* tp_doc */ |
| 3060 | 0, /* tp_traverse */ |
| 3061 | 0, /* tp_clear */ |
| 3062 | 0, /* tp_richcompare */ |
| 3063 | 0, /* tp_weaklistoffset */ |
| 3064 | 0, /* tp_iter */ |
| 3065 | 0, /* tp_iternext */ |
| 3066 | 0, /* tp_methods */ |
| 3067 | pjmedia_codec_param_members, /* tp_members */ |
| 3068 | 0, /* tp_getset */ |
| 3069 | 0, /* tp_base */ |
| 3070 | 0, /* tp_dict */ |
| 3071 | 0, /* tp_descr_get */ |
| 3072 | 0, /* tp_descr_set */ |
| 3073 | 0, /* tp_dictoffset */ |
| 3074 | 0, /* tp_init */ |
| 3075 | 0, /* tp_alloc */ |
| 3076 | pjmedia_codec_param_new, /* tp_new */ |
| 3077 | |
| 3078 | }; |
| 3079 | |
| 3080 | /* |
| 3081 | * py_pjsua_conf_get_max_ports |
| 3082 | */ |
| 3083 | static PyObject *py_pjsua_conf_get_max_ports |
| 3084 | (PyObject *pSelf, PyObject *pArgs) |
| 3085 | { |
| 3086 | int ret; |
| 3087 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3088 | PJ_UNUSED_ARG(pSelf); |
| 3089 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3090 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3091 | { |
| 3092 | return NULL; |
| 3093 | } |
| 3094 | ret = pjsua_conf_get_max_ports(); |
| 3095 | |
| 3096 | return Py_BuildValue("i", ret); |
| 3097 | } |
| 3098 | |
| 3099 | /* |
| 3100 | * py_pjsua_conf_get_active_ports |
| 3101 | */ |
| 3102 | static PyObject *py_pjsua_conf_get_active_ports |
| 3103 | (PyObject *pSelf, PyObject *pArgs) |
| 3104 | { |
| 3105 | int ret; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3106 | |
| 3107 | PJ_UNUSED_ARG(pSelf); |
| 3108 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3109 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3110 | { |
| 3111 | return NULL; |
| 3112 | } |
| 3113 | ret = pjsua_conf_get_active_ports(); |
| 3114 | |
| 3115 | return Py_BuildValue("i", ret); |
| 3116 | } |
| 3117 | |
| 3118 | /* |
| 3119 | * py_pjsua_enum_conf_ports |
| 3120 | * !modified @ 241206 |
| 3121 | */ |
| 3122 | static PyObject *py_pjsua_enum_conf_ports(PyObject *pSelf, PyObject *pArgs) |
| 3123 | { |
| 3124 | pj_status_t status; |
| 3125 | PyObject *list; |
| 3126 | |
| 3127 | pjsua_conf_port_id id[PJSUA_MAX_CONF_PORTS]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3128 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3129 | |
| 3130 | PJ_UNUSED_ARG(pSelf); |
| 3131 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3132 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3133 | { |
| 3134 | return NULL; |
| 3135 | } |
| 3136 | |
| 3137 | c = PJ_ARRAY_SIZE(id); |
| 3138 | status = pjsua_enum_conf_ports(id, &c); |
| 3139 | |
| 3140 | list = PyList_New(c); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3141 | for (i = 0; i < c; i++) |
| 3142 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3143 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3144 | if (ret == -1) |
| 3145 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3146 | return NULL; |
| 3147 | } |
| 3148 | } |
| 3149 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3150 | return Py_BuildValue("O",list); |
| 3151 | } |
| 3152 | |
| 3153 | /* |
| 3154 | * py_pjsua_conf_get_port_info |
| 3155 | */ |
| 3156 | static PyObject *py_pjsua_conf_get_port_info |
| 3157 | (PyObject *pSelf, PyObject *pArgs) |
| 3158 | { |
| 3159 | int id; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3160 | PyObj_pjsua_conf_port_info * obj; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3161 | pjsua_conf_port_info info; |
| 3162 | int status; |
Benny Prijono | d7ea605 | 2007-09-17 15:44:47 +0000 | [diff] [blame] | 3163 | unsigned i; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3164 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3165 | PJ_UNUSED_ARG(pSelf); |
| 3166 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3167 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3168 | { |
| 3169 | return NULL; |
| 3170 | } |
| 3171 | |
| 3172 | |
| 3173 | status = pjsua_conf_get_port_info(id, &info); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3174 | obj = (PyObj_pjsua_conf_port_info *)conf_port_info_new |
| 3175 | (&PyTyp_pjsua_conf_port_info,NULL,NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3176 | obj->bits_per_sample = info.bits_per_sample; |
| 3177 | obj->channel_count = info.bits_per_sample; |
| 3178 | obj->clock_rate = info.clock_rate; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3179 | obj->name = PyString_FromStringAndSize(info.name.ptr, info.name.slen); |
| 3180 | obj->samples_per_frame = info.samples_per_frame; |
| 3181 | obj->slot_id = info.slot_id; |
| 3182 | |
Benny Prijono | d7ea605 | 2007-09-17 15:44:47 +0000 | [diff] [blame] | 3183 | obj->listeners = (PyListObject *)PyList_New(info.listener_cnt); |
| 3184 | for (i = 0; i < info.listener_cnt; i++) { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3185 | PyObject * item = Py_BuildValue("i",info.listeners[i]); |
| 3186 | PyList_SetItem((PyObject *)obj->listeners, i, item); |
| 3187 | } |
| 3188 | return Py_BuildValue("O", obj); |
| 3189 | } |
| 3190 | |
| 3191 | /* |
| 3192 | * py_pjsua_conf_add_port |
| 3193 | */ |
| 3194 | static PyObject *py_pjsua_conf_add_port |
| 3195 | (PyObject *pSelf, PyObject *pArgs) |
| 3196 | { |
| 3197 | int p_id; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3198 | PyObject * oportObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3199 | PyObj_pjmedia_port * oport; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3200 | pjmedia_port * port; |
| 3201 | PyObject * opoolObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3202 | PyObj_pj_pool * opool; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3203 | pj_pool_t * pool; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3204 | |
| 3205 | int status; |
| 3206 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3207 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3208 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3209 | if (!PyArg_ParseTuple(pArgs, "OO", &opoolObj, &oportObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3210 | { |
| 3211 | return NULL; |
| 3212 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3213 | if (opoolObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3214 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3215 | opool = (PyObj_pj_pool *)opoolObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3216 | pool = opool->pool; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3217 | } else { |
| 3218 | opool = NULL; |
| 3219 | pool = NULL; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3220 | } |
| 3221 | if (oportObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3222 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3223 | oport = (PyObj_pjmedia_port *)oportObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3224 | port = oport->port; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3225 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3226 | oport = NULL; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3227 | port = NULL; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3228 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3229 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3230 | status = pjsua_conf_add_port(pool, port, &p_id); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3231 | |
| 3232 | |
| 3233 | return Py_BuildValue("ii", status, p_id); |
| 3234 | } |
| 3235 | |
| 3236 | /* |
| 3237 | * py_pjsua_conf_remove_port |
| 3238 | */ |
| 3239 | static PyObject *py_pjsua_conf_remove_port |
| 3240 | (PyObject *pSelf, PyObject *pArgs) |
| 3241 | { |
| 3242 | int id; |
| 3243 | int status; |
| 3244 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3245 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3246 | |
| 3247 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3248 | { |
| 3249 | return NULL; |
| 3250 | } |
| 3251 | |
| 3252 | status = pjsua_conf_remove_port(id); |
| 3253 | |
| 3254 | |
| 3255 | return Py_BuildValue("i", status); |
| 3256 | } |
| 3257 | |
| 3258 | /* |
| 3259 | * py_pjsua_conf_connect |
| 3260 | */ |
| 3261 | static PyObject *py_pjsua_conf_connect |
| 3262 | (PyObject *pSelf, PyObject *pArgs) |
| 3263 | { |
| 3264 | int source, sink; |
| 3265 | int status; |
| 3266 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3267 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3268 | |
| 3269 | if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) |
| 3270 | { |
| 3271 | return NULL; |
| 3272 | } |
| 3273 | |
| 3274 | status = pjsua_conf_connect(source, sink); |
| 3275 | |
| 3276 | |
| 3277 | return Py_BuildValue("i", status); |
| 3278 | } |
| 3279 | |
| 3280 | /* |
| 3281 | * py_pjsua_conf_disconnect |
| 3282 | */ |
| 3283 | static PyObject *py_pjsua_conf_disconnect |
| 3284 | (PyObject *pSelf, PyObject *pArgs) |
| 3285 | { |
| 3286 | int source, sink; |
| 3287 | int status; |
| 3288 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3289 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3290 | |
| 3291 | if (!PyArg_ParseTuple(pArgs, "ii", &source, &sink)) |
| 3292 | { |
| 3293 | return NULL; |
| 3294 | } |
| 3295 | |
| 3296 | status = pjsua_conf_disconnect(source, sink); |
| 3297 | |
| 3298 | |
| 3299 | return Py_BuildValue("i", status); |
| 3300 | } |
| 3301 | |
| 3302 | /* |
| 3303 | * py_pjsua_player_create |
| 3304 | */ |
| 3305 | static PyObject *py_pjsua_player_create |
| 3306 | (PyObject *pSelf, PyObject *pArgs) |
| 3307 | { |
| 3308 | int id; |
| 3309 | int options; |
| 3310 | PyObject * filename; |
| 3311 | pj_str_t str; |
| 3312 | int status; |
| 3313 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3314 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3315 | |
| 3316 | if (!PyArg_ParseTuple(pArgs, "Oi", &filename, &options)) |
| 3317 | { |
| 3318 | return NULL; |
| 3319 | } |
| 3320 | str.ptr = PyString_AsString(filename); |
| 3321 | str.slen = strlen(PyString_AsString(filename)); |
| 3322 | status = pjsua_player_create(&str, options, &id); |
| 3323 | |
| 3324 | return Py_BuildValue("ii", status, id); |
| 3325 | } |
| 3326 | |
| 3327 | /* |
| 3328 | * py_pjsua_player_get_conf_port |
| 3329 | */ |
| 3330 | static PyObject *py_pjsua_player_get_conf_port |
| 3331 | (PyObject *pSelf, PyObject *pArgs) |
| 3332 | { |
| 3333 | |
| 3334 | int id, port_id; |
| 3335 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3336 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3337 | |
| 3338 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3339 | { |
| 3340 | return NULL; |
| 3341 | } |
| 3342 | |
| 3343 | port_id = pjsua_player_get_conf_port(id); |
| 3344 | |
| 3345 | |
| 3346 | return Py_BuildValue("i", port_id); |
| 3347 | } |
| 3348 | |
| 3349 | /* |
| 3350 | * py_pjsua_player_set_pos |
| 3351 | */ |
| 3352 | static PyObject *py_pjsua_player_set_pos |
| 3353 | (PyObject *pSelf, PyObject *pArgs) |
| 3354 | { |
| 3355 | int id; |
| 3356 | pj_uint32_t samples; |
| 3357 | int status; |
| 3358 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3359 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3360 | |
| 3361 | if (!PyArg_ParseTuple(pArgs, "iI", &id, &samples)) |
| 3362 | { |
| 3363 | return NULL; |
| 3364 | } |
| 3365 | |
| 3366 | status = pjsua_player_set_pos(id, samples); |
| 3367 | |
| 3368 | |
| 3369 | return Py_BuildValue("i", status); |
| 3370 | } |
| 3371 | |
| 3372 | /* |
| 3373 | * py_pjsua_player_destroy |
| 3374 | */ |
| 3375 | static PyObject *py_pjsua_player_destroy |
| 3376 | (PyObject *pSelf, PyObject *pArgs) |
| 3377 | { |
| 3378 | int id; |
| 3379 | int status; |
| 3380 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3381 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3382 | |
| 3383 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3384 | { |
| 3385 | return NULL; |
| 3386 | } |
| 3387 | |
| 3388 | status = pjsua_player_destroy(id); |
| 3389 | |
| 3390 | |
| 3391 | return Py_BuildValue("i", status); |
| 3392 | } |
| 3393 | |
| 3394 | /* |
| 3395 | * py_pjsua_recorder_create |
| 3396 | * !modified @ 261206 |
| 3397 | */ |
| 3398 | static PyObject *py_pjsua_recorder_create |
| 3399 | (PyObject *pSelf, PyObject *pArgs) |
| 3400 | { |
| 3401 | int p_id; |
| 3402 | int options; |
| 3403 | int max_size; |
| 3404 | PyObject * filename; |
| 3405 | pj_str_t str; |
| 3406 | PyObject * enc_param; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3407 | pj_str_t strparam; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3408 | int enc_type; |
| 3409 | |
| 3410 | int status; |
| 3411 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3412 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3413 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3414 | if (!PyArg_ParseTuple(pArgs, "OiOii", &filename, |
| 3415 | &enc_type, &enc_param, &max_size, &options)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3416 | { |
| 3417 | return NULL; |
| 3418 | } |
| 3419 | str.ptr = PyString_AsString(filename); |
| 3420 | str.slen = strlen(PyString_AsString(filename)); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 3421 | if (enc_param != Py_None) |
| 3422 | { |
| 3423 | strparam.ptr = PyString_AsString(enc_param); |
| 3424 | strparam.slen = strlen(PyString_AsString(enc_param)); |
| 3425 | status = pjsua_recorder_create |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3426 | (&str, enc_type, NULL, max_size, options, &p_id); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 3427 | } else { |
| 3428 | status = pjsua_recorder_create |
| 3429 | (&str, enc_type, NULL, max_size, options, &p_id); |
| 3430 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3431 | return Py_BuildValue("ii", status, p_id); |
| 3432 | } |
| 3433 | |
| 3434 | /* |
| 3435 | * py_pjsua_recorder_get_conf_port |
| 3436 | */ |
| 3437 | static PyObject *py_pjsua_recorder_get_conf_port |
| 3438 | (PyObject *pSelf, PyObject *pArgs) |
| 3439 | { |
| 3440 | |
| 3441 | int id, port_id; |
| 3442 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3443 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3444 | |
| 3445 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3446 | { |
| 3447 | return NULL; |
| 3448 | } |
| 3449 | |
| 3450 | port_id = pjsua_recorder_get_conf_port(id); |
| 3451 | |
| 3452 | |
| 3453 | return Py_BuildValue("i", port_id); |
| 3454 | } |
| 3455 | |
| 3456 | /* |
| 3457 | * py_pjsua_recorder_destroy |
| 3458 | */ |
| 3459 | static PyObject *py_pjsua_recorder_destroy |
| 3460 | (PyObject *pSelf, PyObject *pArgs) |
| 3461 | { |
| 3462 | int id; |
| 3463 | int status; |
| 3464 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3465 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3466 | |
| 3467 | if (!PyArg_ParseTuple(pArgs, "i", &id)) |
| 3468 | { |
| 3469 | return NULL; |
| 3470 | } |
| 3471 | |
| 3472 | status = pjsua_recorder_destroy(id); |
| 3473 | |
| 3474 | |
| 3475 | return Py_BuildValue("i", status); |
| 3476 | } |
| 3477 | |
| 3478 | /* |
| 3479 | * py_pjsua_enum_snd_devs |
| 3480 | */ |
| 3481 | static PyObject *py_pjsua_enum_snd_devs(PyObject *pSelf, PyObject *pArgs) |
| 3482 | { |
| 3483 | pj_status_t status; |
| 3484 | PyObject *list; |
| 3485 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3486 | pjmedia_snd_dev_info info[SND_DEV_NUM]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3487 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3488 | |
| 3489 | PJ_UNUSED_ARG(pSelf); |
| 3490 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame] | 3491 | if (!PyArg_ParseTuple(pArgs, "")) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3492 | { |
| 3493 | return NULL; |
| 3494 | } |
| 3495 | |
Fahris | b721aa3 | 2007-01-29 05:07:41 +0000 | [diff] [blame] | 3496 | c = PJ_ARRAY_SIZE(info); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3497 | status = pjsua_enum_snd_devs(info, &c); |
| 3498 | |
| 3499 | list = PyList_New(c); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3500 | for (i = 0; i < c; i++) |
| 3501 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3502 | int ret; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3503 | int j; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 3504 | char * str; |
| 3505 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3506 | PyObj_pjmedia_snd_dev_info * obj; |
| 3507 | obj = (PyObj_pjmedia_snd_dev_info *)pjmedia_snd_dev_info_new |
| 3508 | (&PyTyp_pjmedia_snd_dev_info, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3509 | obj->default_samples_per_sec = info[i].default_samples_per_sec; |
| 3510 | obj->input_count = info[i].input_count; |
| 3511 | obj->output_count = info[i].output_count; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 3512 | str = (char *)malloc(SND_NAME_LEN * sizeof(char)); |
| 3513 | memset(str, 0, SND_NAME_LEN); |
| 3514 | for (j = 0; j < SND_NAME_LEN; j++) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3515 | { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 3516 | str[j] = info[i].name[j]; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3517 | } |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 3518 | obj->name = PyString_FromStringAndSize(str, SND_NAME_LEN); |
| 3519 | free(str); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3520 | ret = PyList_SetItem(list, i, (PyObject *)obj); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3521 | if (ret == -1) |
| 3522 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3523 | return NULL; |
| 3524 | } |
| 3525 | } |
| 3526 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3527 | return Py_BuildValue("O",list); |
| 3528 | } |
| 3529 | |
| 3530 | /* |
| 3531 | * py_pjsua_get_snd_dev |
| 3532 | */ |
| 3533 | static PyObject *py_pjsua_get_snd_dev |
| 3534 | (PyObject *pSelf, PyObject *pArgs) |
| 3535 | { |
| 3536 | int capture_dev, playback_dev; |
| 3537 | int status; |
| 3538 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3539 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3540 | |
| 3541 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3542 | { |
| 3543 | return NULL; |
| 3544 | } |
| 3545 | |
| 3546 | status = pjsua_get_snd_dev(&capture_dev, &playback_dev); |
| 3547 | |
| 3548 | |
| 3549 | return Py_BuildValue("ii", capture_dev, playback_dev); |
| 3550 | } |
| 3551 | |
| 3552 | /* |
| 3553 | * py_pjsua_set_snd_dev |
| 3554 | */ |
| 3555 | static PyObject *py_pjsua_set_snd_dev |
| 3556 | (PyObject *pSelf, PyObject *pArgs) |
| 3557 | { |
| 3558 | int capture_dev, playback_dev; |
| 3559 | int status; |
| 3560 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3561 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3562 | |
| 3563 | if (!PyArg_ParseTuple(pArgs, "ii", &capture_dev, &playback_dev)) |
| 3564 | { |
| 3565 | return NULL; |
| 3566 | } |
| 3567 | |
| 3568 | status = pjsua_set_snd_dev(capture_dev, playback_dev); |
| 3569 | |
| 3570 | |
| 3571 | return Py_BuildValue("i", status); |
| 3572 | } |
| 3573 | |
| 3574 | /* |
| 3575 | * py_pjsua_set_null_snd_dev |
| 3576 | */ |
| 3577 | static PyObject *py_pjsua_set_null_snd_dev |
| 3578 | (PyObject *pSelf, PyObject *pArgs) |
| 3579 | { |
| 3580 | |
| 3581 | int status; |
| 3582 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3583 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3584 | |
| 3585 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3586 | { |
| 3587 | return NULL; |
| 3588 | } |
| 3589 | |
| 3590 | status = pjsua_set_null_snd_dev(); |
| 3591 | |
| 3592 | |
| 3593 | return Py_BuildValue("i", status); |
| 3594 | } |
| 3595 | |
| 3596 | /* |
| 3597 | * py_pjsua_set_no_snd_dev |
| 3598 | */ |
| 3599 | static PyObject *py_pjsua_set_no_snd_dev |
| 3600 | (PyObject *pSelf, PyObject *pArgs) |
| 3601 | { |
| 3602 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3603 | PyObj_pjmedia_port * obj; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3604 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3605 | PJ_UNUSED_ARG(pSelf); |
| 3606 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3607 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3608 | { |
| 3609 | return NULL; |
| 3610 | } |
| 3611 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3612 | obj = (PyObj_pjmedia_port *)PyType_GenericNew |
| 3613 | (&PyTyp_pjmedia_port, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3614 | obj->port = pjsua_set_no_snd_dev(); |
| 3615 | return Py_BuildValue("O", obj); |
| 3616 | } |
| 3617 | |
| 3618 | /* |
| 3619 | * py_pjsua_set_ec |
| 3620 | */ |
| 3621 | static PyObject *py_pjsua_set_ec |
| 3622 | (PyObject *pSelf, PyObject *pArgs) |
| 3623 | { |
| 3624 | int options; |
| 3625 | int tail_ms; |
| 3626 | int status; |
| 3627 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3628 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3629 | |
| 3630 | if (!PyArg_ParseTuple(pArgs, "ii", &tail_ms, &options)) |
| 3631 | { |
| 3632 | return NULL; |
| 3633 | } |
| 3634 | |
| 3635 | status = pjsua_set_ec(tail_ms, options); |
| 3636 | |
| 3637 | |
| 3638 | return Py_BuildValue("i", status); |
| 3639 | } |
| 3640 | |
| 3641 | /* |
| 3642 | * py_pjsua_get_ec_tail |
| 3643 | */ |
| 3644 | static PyObject *py_pjsua_get_ec_tail |
| 3645 | (PyObject *pSelf, PyObject *pArgs) |
| 3646 | { |
| 3647 | |
| 3648 | int status; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3649 | unsigned p_tail_ms; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3650 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3651 | PJ_UNUSED_ARG(pSelf); |
| 3652 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3653 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3654 | { |
| 3655 | return NULL; |
| 3656 | } |
| 3657 | |
| 3658 | status = pjsua_get_ec_tail(&p_tail_ms); |
| 3659 | |
| 3660 | |
| 3661 | return Py_BuildValue("i", p_tail_ms); |
| 3662 | } |
| 3663 | |
| 3664 | /* |
| 3665 | * py_pjsua_enum_codecs |
| 3666 | * !modified @ 261206 |
| 3667 | */ |
| 3668 | static PyObject *py_pjsua_enum_codecs(PyObject *pSelf, PyObject *pArgs) |
| 3669 | { |
| 3670 | pj_status_t status; |
| 3671 | PyObject *list; |
| 3672 | |
| 3673 | pjsua_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3674 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3675 | |
| 3676 | PJ_UNUSED_ARG(pSelf); |
| 3677 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3678 | if (!PyArg_ParseTuple(pArgs, "")) |
| 3679 | { |
| 3680 | return NULL; |
| 3681 | } |
| 3682 | |
| 3683 | c = PJ_ARRAY_SIZE(info); |
| 3684 | status = pjsua_enum_codecs(info, &c); |
| 3685 | |
| 3686 | list = PyList_New(c); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3687 | for (i = 0; i < c; i++) |
| 3688 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3689 | int ret; |
| 3690 | int j; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3691 | PyObj_pjsua_codec_info * obj; |
| 3692 | obj = (PyObj_pjsua_codec_info *)codec_info_new |
| 3693 | (&PyTyp_pjsua_codec_info, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3694 | obj->codec_id = PyString_FromStringAndSize |
| 3695 | (info[i].codec_id.ptr, info[i].codec_id.slen); |
| 3696 | obj->priority = info[i].priority; |
| 3697 | for (j = 0; j < 32; j++) |
| 3698 | { |
| 3699 | obj->buf_[j] = info[i].buf_[j]; |
| 3700 | } |
| 3701 | ret = PyList_SetItem(list, i, (PyObject *)obj); |
| 3702 | if (ret == -1) { |
| 3703 | return NULL; |
| 3704 | } |
| 3705 | } |
| 3706 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3707 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3708 | return Py_BuildValue("O",list); |
| 3709 | } |
| 3710 | |
| 3711 | /* |
| 3712 | * py_pjsua_codec_set_priority |
| 3713 | */ |
| 3714 | static PyObject *py_pjsua_codec_set_priority |
| 3715 | (PyObject *pSelf, PyObject *pArgs) |
| 3716 | { |
| 3717 | |
| 3718 | int status; |
| 3719 | PyObject * id; |
| 3720 | pj_str_t str; |
| 3721 | pj_uint8_t priority; |
| 3722 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3723 | PJ_UNUSED_ARG(pSelf); |
| 3724 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3725 | if (!PyArg_ParseTuple(pArgs, "OB", &id, &priority)) |
| 3726 | { |
| 3727 | return NULL; |
| 3728 | } |
| 3729 | str.ptr = PyString_AsString(id); |
| 3730 | str.slen = strlen(PyString_AsString(id)); |
| 3731 | status = pjsua_codec_set_priority(&str, priority); |
| 3732 | |
| 3733 | |
| 3734 | return Py_BuildValue("i", status); |
| 3735 | } |
| 3736 | |
| 3737 | /* |
| 3738 | * py_pjsua_codec_get_param |
| 3739 | */ |
| 3740 | static PyObject *py_pjsua_codec_get_param |
| 3741 | (PyObject *pSelf, PyObject *pArgs) |
| 3742 | { |
| 3743 | |
| 3744 | int status; |
| 3745 | PyObject * id; |
| 3746 | pj_str_t str; |
| 3747 | pjmedia_codec_param param; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3748 | PyObj_pjmedia_codec_param *obj; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3749 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3750 | PJ_UNUSED_ARG(pSelf); |
| 3751 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3752 | if (!PyArg_ParseTuple(pArgs, "O", &id)) |
| 3753 | { |
| 3754 | return NULL; |
| 3755 | } |
| 3756 | str.ptr = PyString_AsString(id); |
| 3757 | str.slen = strlen(PyString_AsString(id)); |
| 3758 | status = pjsua_codec_get_param(&str, ¶m); |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3759 | obj = (PyObj_pjmedia_codec_param *)pjmedia_codec_param_new |
| 3760 | (&PyTyp_pjmedia_codec_param, NULL, NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3761 | obj->info->avg_bps = param.info.avg_bps; |
| 3762 | obj->info->channel_cnt = param.info.channel_cnt; |
| 3763 | obj->info->clock_rate = param.info.clock_rate; |
| 3764 | obj->info->frm_ptime = param.info.frm_ptime; |
| 3765 | obj->info->pcm_bits_per_sample = param.info.pcm_bits_per_sample; |
| 3766 | obj->info->pt = param.info.pt; |
| 3767 | obj->setting->cng = param.setting.cng; |
| 3768 | obj->setting->dec_fmtp_mode = param.setting.dec_fmtp_mode; |
| 3769 | obj->setting->enc_fmtp_mode = param.setting.enc_fmtp_mode; |
| 3770 | obj->setting->frm_per_pkt = param.setting.frm_per_pkt; |
| 3771 | obj->setting->penh = param.setting.penh; |
| 3772 | obj->setting->plc = param.setting.plc; |
| 3773 | obj->setting->reserved = param.setting.reserved; |
| 3774 | obj->setting->vad = param.setting.vad; |
| 3775 | |
| 3776 | return Py_BuildValue("O", obj); |
| 3777 | } |
| 3778 | /* |
| 3779 | * py_pjsua_codec_set_param |
| 3780 | */ |
| 3781 | static PyObject *py_pjsua_codec_set_param |
| 3782 | (PyObject *pSelf, PyObject *pArgs) |
| 3783 | { |
| 3784 | |
| 3785 | int status; |
| 3786 | PyObject * id; |
| 3787 | pj_str_t str; |
| 3788 | pjmedia_codec_param param; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3789 | PyObject * tmpObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3790 | PyObj_pjmedia_codec_param *obj; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3791 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3792 | PJ_UNUSED_ARG(pSelf); |
| 3793 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3794 | if (!PyArg_ParseTuple(pArgs, "OO", &id, &tmpObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3795 | { |
| 3796 | return NULL; |
| 3797 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3798 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3799 | str.ptr = PyString_AsString(id); |
| 3800 | str.slen = strlen(PyString_AsString(id)); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3801 | if (tmpObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3802 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3803 | obj = (PyObj_pjmedia_codec_param *)tmpObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 3804 | param.info.avg_bps = obj->info->avg_bps; |
| 3805 | param.info.channel_cnt = obj->info->channel_cnt; |
| 3806 | param.info.clock_rate = obj->info->clock_rate; |
| 3807 | param.info.frm_ptime = obj->info->frm_ptime; |
| 3808 | param.info.pcm_bits_per_sample = obj->info->pcm_bits_per_sample; |
| 3809 | param.info.pt = obj->info->pt; |
| 3810 | param.setting.cng = obj->setting->cng; |
| 3811 | param.setting.dec_fmtp_mode = obj->setting->dec_fmtp_mode; |
| 3812 | param.setting.enc_fmtp_mode = obj->setting->enc_fmtp_mode; |
| 3813 | param.setting.frm_per_pkt = obj->setting->frm_per_pkt; |
| 3814 | param.setting.penh = obj->setting->penh; |
| 3815 | param.setting.plc = obj->setting->plc; |
| 3816 | param.setting.reserved = obj->setting->reserved; |
| 3817 | param.setting.vad = obj->setting->vad; |
| 3818 | status = pjsua_codec_set_param(&str, ¶m); |
| 3819 | } else { |
| 3820 | status = pjsua_codec_set_param(&str, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 3821 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3822 | return Py_BuildValue("i", status); |
| 3823 | } |
| 3824 | |
| 3825 | static char pjsua_conf_get_max_ports_doc[] = |
| 3826 | "int py_pjsua.conf_get_max_ports () " |
| 3827 | "Get maxinum number of conference ports."; |
| 3828 | static char pjsua_conf_get_active_ports_doc[] = |
| 3829 | "int py_pjsua.conf_get_active_ports () " |
| 3830 | "Get current number of active ports in the bridge."; |
| 3831 | static char pjsua_enum_conf_ports_doc[] = |
| 3832 | "int[] py_pjsua.enum_conf_ports () " |
| 3833 | "Enumerate all conference ports."; |
| 3834 | static char pjsua_conf_get_port_info_doc[] = |
| 3835 | "py_pjsua.Conf_Port_Info py_pjsua.conf_get_port_info (int id) " |
| 3836 | "Get information about the specified conference port"; |
| 3837 | static char pjsua_conf_add_port_doc[] = |
| 3838 | "int, int py_pjsua.conf_add_port " |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3839 | "(py_pjsua.Pj_Pool pool, py_pjsua.PJMedia_Port port) " |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3840 | "Add arbitrary media port to PJSUA's conference bridge. " |
| 3841 | "Application can use this function to add the media port " |
| 3842 | "that it creates. For media ports that are created by PJSUA-LIB " |
| 3843 | "(such as calls, file player, or file recorder), PJSUA-LIB will " |
| 3844 | "automatically add the port to the bridge."; |
| 3845 | static char pjsua_conf_remove_port_doc[] = |
| 3846 | "int py_pjsua.conf_remove_port (int id) " |
| 3847 | "Remove arbitrary slot from the conference bridge. " |
| 3848 | "Application should only call this function " |
| 3849 | "if it registered the port manually."; |
| 3850 | static char pjsua_conf_connect_doc[] = |
| 3851 | "int py_pjsua.conf_connect (int source, int sink) " |
| 3852 | "Establish unidirectional media flow from souce to sink. " |
| 3853 | "One source may transmit to multiple destinations/sink. " |
| 3854 | "And if multiple sources are transmitting to the same sink, " |
| 3855 | "the media will be mixed together. Source and sink may refer " |
| 3856 | "to the same ID, effectively looping the media. " |
| 3857 | "If bidirectional media flow is desired, application " |
| 3858 | "needs to call this function twice, with the second " |
| 3859 | "one having the arguments reversed."; |
| 3860 | static char pjsua_conf_disconnect_doc[] = |
| 3861 | "int py_pjsua.conf_disconnect (int source, int sink) " |
| 3862 | "Disconnect media flow from the source to destination port."; |
| 3863 | static char pjsua_player_create_doc[] = |
| 3864 | "int, int py_pjsua.player_create (string filename, int options) " |
| 3865 | "Create a file player, and automatically connect " |
| 3866 | "this player to the conference bridge."; |
| 3867 | static char pjsua_player_get_conf_port_doc[] = |
| 3868 | "int py_pjsua.player_get_conf_port (int) " |
| 3869 | "Get conference port ID associated with player."; |
| 3870 | static char pjsua_player_set_pos_doc[] = |
| 3871 | "int py_pjsua.player_set_pos (int id, int samples) " |
| 3872 | "Set playback position."; |
| 3873 | static char pjsua_player_destroy_doc[] = |
| 3874 | "int py_pjsua.player_destroy (int id) " |
| 3875 | "Close the file, remove the player from the bridge, " |
| 3876 | "and free resources associated with the file player."; |
| 3877 | static char pjsua_recorder_create_doc[] = |
| 3878 | "int, int py_pjsua.recorder_create (string filename, " |
| 3879 | "int enc_type, int enc_param, int max_size, int options) " |
| 3880 | "Create a file recorder, and automatically connect this recorder " |
| 3881 | "to the conference bridge. The recorder currently supports recording " |
| 3882 | "WAV file, and on Windows, MP3 file. The type of the recorder to use " |
| 3883 | "is determined by the extension of the file (e.g. '.wav' or '.mp3')."; |
| 3884 | static char pjsua_recorder_get_conf_port_doc[] = |
| 3885 | "int py_pjsua.recorder_get_conf_port (int id) " |
| 3886 | "Get conference port associated with recorder."; |
| 3887 | static char pjsua_recorder_destroy_doc[] = |
| 3888 | "int py_pjsua.recorder_destroy (int id) " |
| 3889 | "Destroy recorder (this will complete recording)."; |
| 3890 | static char pjsua_enum_snd_devs_doc[] = |
| 3891 | "py_pjsua.PJMedia_Snd_Dev_Info[] py_pjsua.enum_snd_devs (int count) " |
| 3892 | "Enum sound devices."; |
| 3893 | static char pjsua_get_snd_dev_doc[] = |
| 3894 | "int, int py_pjsua.get_snd_dev () " |
| 3895 | "Get currently active sound devices. " |
| 3896 | "If sound devices has not been created " |
| 3897 | "(for example when pjsua_start() is not called), " |
| 3898 | "it is possible that the function returns " |
| 3899 | "PJ_SUCCESS with -1 as device IDs."; |
| 3900 | static char pjsua_set_snd_dev_doc[] = |
| 3901 | "int py_pjsua.set_snd_dev (int capture_dev, int playback_dev) " |
| 3902 | "Select or change sound device. Application may call this function " |
| 3903 | "at any time to replace current sound device."; |
| 3904 | static char pjsua_set_null_snd_dev_doc[] = |
| 3905 | "int py_pjsua.set_null_snd_dev () " |
| 3906 | "Set pjsua to use null sound device. The null sound device only " |
| 3907 | "provides the timing needed by the conference bridge, and will not " |
| 3908 | "interract with any hardware."; |
| 3909 | static char pjsua_set_no_snd_dev_doc[] = |
| 3910 | "py_pjsua.PJMedia_Port py_pjsua.set_no_snd_dev () " |
| 3911 | "Disconnect the main conference bridge from any sound devices, " |
| 3912 | "and let application connect the bridge to it's " |
| 3913 | "own sound device/master port."; |
| 3914 | static char pjsua_set_ec_doc[] = |
| 3915 | "int py_pjsua.set_ec (int tail_ms, int options) " |
| 3916 | "Configure the echo canceller tail length of the sound port."; |
| 3917 | static char pjsua_get_ec_tail_doc[] = |
| 3918 | "int py_pjsua.get_ec_tail () " |
| 3919 | "Get current echo canceller tail length."; |
| 3920 | static char pjsua_enum_codecs_doc[] = |
| 3921 | "py_pjsua.Codec_Info[] py_pjsua.enum_codecs () " |
| 3922 | "Enum all supported codecs in the system."; |
| 3923 | static char pjsua_codec_set_priority_doc[] = |
| 3924 | "int py_pjsua.codec_set_priority (string id, int priority) " |
| 3925 | "Change codec priority."; |
| 3926 | static char pjsua_codec_get_param_doc[] = |
| 3927 | "py_pjsua.PJMedia_Codec_Param py_pjsua.codec_get_param (string id) " |
| 3928 | "Get codec parameters"; |
| 3929 | static char pjsua_codec_set_param_doc[] = |
| 3930 | "int py_pjsua.codec_set_param (string id, " |
| 3931 | "py_pjsua.PJMedia_Codec_Param param) " |
| 3932 | "Set codec parameters."; |
| 3933 | |
| 3934 | /* END OF LIB MEDIA */ |
| 3935 | |
| 3936 | /* LIB CALL */ |
| 3937 | |
| 3938 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3939 | * PyObj_pj_time_val |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3940 | * PJ Time Val |
| 3941 | */ |
| 3942 | typedef struct |
| 3943 | { |
| 3944 | PyObject_HEAD |
| 3945 | /* Type-specific fields go here. */ |
| 3946 | long sec; |
| 3947 | long msec; |
| 3948 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3949 | } PyObj_pj_time_val; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3950 | |
| 3951 | |
| 3952 | |
| 3953 | /* |
| 3954 | * pj_time_val_members |
| 3955 | */ |
| 3956 | static PyMemberDef pj_time_val_members[] = |
| 3957 | { |
| 3958 | |
| 3959 | { |
| 3960 | "sec", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3961 | offsetof(PyObj_pj_time_val, sec), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3962 | "The seconds part of the time" |
| 3963 | }, |
| 3964 | { |
| 3965 | "msec", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3966 | offsetof(PyObj_pj_time_val, sec), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3967 | "The milliseconds fraction of the time" |
| 3968 | }, |
| 3969 | |
| 3970 | |
| 3971 | {NULL} /* Sentinel */ |
| 3972 | }; |
| 3973 | |
| 3974 | |
| 3975 | |
| 3976 | |
| 3977 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3978 | * PyTyp_pj_time_val |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3979 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3980 | static PyTypeObject PyTyp_pj_time_val = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3981 | { |
| 3982 | PyObject_HEAD_INIT(NULL) |
| 3983 | 0, /*ob_size*/ |
| 3984 | "py_pjsua.PJ_Time_Val", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 3985 | sizeof(PyObj_pj_time_val), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 3986 | 0, /*tp_itemsize*/ |
| 3987 | 0,/*tp_dealloc*/ |
| 3988 | 0, /*tp_print*/ |
| 3989 | 0, /*tp_getattr*/ |
| 3990 | 0, /*tp_setattr*/ |
| 3991 | 0, /*tp_compare*/ |
| 3992 | 0, /*tp_repr*/ |
| 3993 | 0, /*tp_as_number*/ |
| 3994 | 0, /*tp_as_sequence*/ |
| 3995 | 0, /*tp_as_mapping*/ |
| 3996 | 0, /*tp_hash */ |
| 3997 | 0, /*tp_call*/ |
| 3998 | 0, /*tp_str*/ |
| 3999 | 0, /*tp_getattro*/ |
| 4000 | 0, /*tp_setattro*/ |
| 4001 | 0, /*tp_as_buffer*/ |
| 4002 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 4003 | "PJ Time Val objects", /* tp_doc */ |
| 4004 | 0, /* tp_traverse */ |
| 4005 | 0, /* tp_clear */ |
| 4006 | 0, /* tp_richcompare */ |
| 4007 | 0, /* tp_weaklistoffset */ |
| 4008 | 0, /* tp_iter */ |
| 4009 | 0, /* tp_iternext */ |
| 4010 | 0, /* tp_methods */ |
| 4011 | pj_time_val_members, /* tp_members */ |
| 4012 | |
| 4013 | |
| 4014 | }; |
| 4015 | |
| 4016 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4017 | * PyObj_pjsua_call_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4018 | * Call Info |
| 4019 | */ |
| 4020 | typedef struct |
| 4021 | { |
| 4022 | PyObject_HEAD |
| 4023 | /* Type-specific fields go here. */ |
| 4024 | |
| 4025 | int id; |
| 4026 | int role; |
| 4027 | int acc_id; |
| 4028 | PyObject * local_info; |
| 4029 | PyObject * local_contact; |
| 4030 | PyObject * remote_info; |
| 4031 | PyObject * remote_contact; |
| 4032 | PyObject * call_id; |
| 4033 | int state; |
| 4034 | PyObject * state_text; |
| 4035 | int last_status; |
| 4036 | PyObject * last_status_text; |
| 4037 | int media_status; |
| 4038 | int media_dir; |
| 4039 | int conf_slot; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4040 | PyObj_pj_time_val * connect_duration; |
| 4041 | PyObj_pj_time_val * total_duration; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4042 | struct { |
| 4043 | char local_info[128]; |
| 4044 | char local_contact[128]; |
| 4045 | char remote_info[128]; |
| 4046 | char remote_contact[128]; |
| 4047 | char call_id[128]; |
| 4048 | char last_status_text[128]; |
| 4049 | } buf_; |
| 4050 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4051 | } PyObj_pjsua_call_info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4052 | |
| 4053 | |
| 4054 | /* |
| 4055 | * call_info_dealloc |
| 4056 | * deletes a call_info from memory |
| 4057 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4058 | static void call_info_dealloc(PyObj_pjsua_call_info* self) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4059 | { |
| 4060 | Py_XDECREF(self->local_info); |
| 4061 | Py_XDECREF(self->local_contact); |
| 4062 | Py_XDECREF(self->remote_info); |
| 4063 | Py_XDECREF(self->remote_contact); |
| 4064 | Py_XDECREF(self->call_id); |
| 4065 | Py_XDECREF(self->state_text); |
| 4066 | Py_XDECREF(self->last_status_text); |
| 4067 | Py_XDECREF(self->connect_duration); |
| 4068 | Py_XDECREF(self->total_duration); |
| 4069 | self->ob_type->tp_free((PyObject*)self); |
| 4070 | } |
| 4071 | |
| 4072 | |
| 4073 | /* |
| 4074 | * call_info_new |
| 4075 | * constructor for call_info object |
| 4076 | */ |
| 4077 | static PyObject * call_info_new(PyTypeObject *type, PyObject *args, |
| 4078 | PyObject *kwds) |
| 4079 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4080 | PyObj_pjsua_call_info *self; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4081 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4082 | PJ_UNUSED_ARG(args); |
| 4083 | PJ_UNUSED_ARG(kwds); |
| 4084 | |
| 4085 | self = (PyObj_pjsua_call_info *)type->tp_alloc(type, 0); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4086 | if (self != NULL) |
| 4087 | { |
| 4088 | self->local_info = PyString_FromString(""); |
| 4089 | if (self->local_info == NULL) |
| 4090 | { |
| 4091 | Py_DECREF(self); |
| 4092 | return NULL; |
| 4093 | } |
| 4094 | self->local_contact = PyString_FromString(""); |
| 4095 | if (self->local_contact == NULL) |
| 4096 | { |
| 4097 | Py_DECREF(self); |
| 4098 | return NULL; |
| 4099 | } |
| 4100 | self->remote_info = PyString_FromString(""); |
| 4101 | if (self->remote_info == NULL) |
| 4102 | { |
| 4103 | Py_DECREF(self); |
| 4104 | return NULL; |
| 4105 | } |
| 4106 | self->remote_contact = PyString_FromString(""); |
| 4107 | if (self->remote_contact == NULL) |
| 4108 | { |
| 4109 | Py_DECREF(self); |
| 4110 | return NULL; |
| 4111 | } |
| 4112 | self->call_id = PyString_FromString(""); |
| 4113 | if (self->call_id == NULL) |
| 4114 | { |
| 4115 | Py_DECREF(self); |
| 4116 | return NULL; |
| 4117 | } |
| 4118 | self->state_text = PyString_FromString(""); |
| 4119 | if (self->state_text == NULL) |
| 4120 | { |
| 4121 | Py_DECREF(self); |
| 4122 | return NULL; |
| 4123 | } |
| 4124 | self->last_status_text = PyString_FromString(""); |
| 4125 | if (self->last_status_text == NULL) |
| 4126 | { |
| 4127 | Py_DECREF(self); |
| 4128 | return NULL; |
| 4129 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4130 | self->connect_duration = (PyObj_pj_time_val *)PyType_GenericNew |
| 4131 | (&PyTyp_pj_time_val,NULL,NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4132 | if (self->connect_duration == NULL) |
| 4133 | { |
| 4134 | Py_DECREF(self); |
| 4135 | return NULL; |
| 4136 | } |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4137 | self->total_duration = (PyObj_pj_time_val *)PyType_GenericNew |
| 4138 | (&PyTyp_pj_time_val,NULL,NULL); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4139 | if (self->total_duration == NULL) |
| 4140 | { |
| 4141 | Py_DECREF(self); |
| 4142 | return NULL; |
| 4143 | } |
| 4144 | } |
| 4145 | return (PyObject *)self; |
| 4146 | } |
| 4147 | |
| 4148 | /* |
| 4149 | * call_info_members |
| 4150 | */ |
| 4151 | static PyMemberDef call_info_members[] = |
| 4152 | { |
| 4153 | { |
| 4154 | "id", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4155 | offsetof(PyObj_pjsua_call_info, id), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4156 | "Call identification" |
| 4157 | }, |
| 4158 | { |
| 4159 | "role", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4160 | offsetof(PyObj_pjsua_call_info, role), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4161 | "Initial call role (UAC == caller)" |
| 4162 | }, |
| 4163 | { |
| 4164 | "acc_id", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4165 | offsetof(PyObj_pjsua_call_info, acc_id), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4166 | "The account ID where this call belongs." |
| 4167 | }, |
| 4168 | { |
| 4169 | "local_info", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4170 | offsetof(PyObj_pjsua_call_info, local_info), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4171 | "Local URI" |
| 4172 | }, |
| 4173 | { |
| 4174 | "local_contact", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4175 | offsetof(PyObj_pjsua_call_info, local_contact), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4176 | "Local Contact" |
| 4177 | }, |
| 4178 | { |
| 4179 | "remote_info", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4180 | offsetof(PyObj_pjsua_call_info, remote_info), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4181 | "Remote URI" |
| 4182 | }, |
| 4183 | { |
| 4184 | "remote_contact", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4185 | offsetof(PyObj_pjsua_call_info, remote_contact), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4186 | "Remote Contact" |
| 4187 | }, |
| 4188 | { |
| 4189 | "call_id", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4190 | offsetof(PyObj_pjsua_call_info, call_id), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4191 | "Dialog Call-ID string" |
| 4192 | }, |
| 4193 | { |
| 4194 | "state", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4195 | offsetof(PyObj_pjsua_call_info, state), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4196 | "Call state" |
| 4197 | }, |
| 4198 | { |
| 4199 | "state_text", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4200 | offsetof(PyObj_pjsua_call_info, state_text), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4201 | "Text describing the state " |
| 4202 | }, |
| 4203 | { |
| 4204 | "last_status", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4205 | offsetof(PyObj_pjsua_call_info, last_status), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4206 | "Last status code heard, which can be used as cause code" |
| 4207 | }, |
| 4208 | { |
| 4209 | "last_status_text", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4210 | offsetof(PyObj_pjsua_call_info, last_status_text), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4211 | "The reason phrase describing the status." |
| 4212 | }, |
| 4213 | { |
| 4214 | "media_status", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4215 | offsetof(PyObj_pjsua_call_info, media_status), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4216 | "Call media status." |
| 4217 | }, |
| 4218 | { |
| 4219 | "media_dir", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4220 | offsetof(PyObj_pjsua_call_info, media_dir), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4221 | "Media direction" |
| 4222 | }, |
| 4223 | { |
| 4224 | "conf_slot", T_INT, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4225 | offsetof(PyObj_pjsua_call_info, conf_slot), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4226 | "The conference port number for the call" |
| 4227 | }, |
| 4228 | { |
| 4229 | "connect_duration", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4230 | offsetof(PyObj_pjsua_call_info, connect_duration), 0, |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4231 | "Up-to-date call connected duration(zero when call is not established)" |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4232 | }, |
| 4233 | { |
| 4234 | "total_duration", T_OBJECT_EX, |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4235 | offsetof(PyObj_pjsua_call_info, total_duration), 0, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4236 | "Total call duration, including set-up time" |
| 4237 | }, |
| 4238 | |
| 4239 | {NULL} /* Sentinel */ |
| 4240 | }; |
| 4241 | |
| 4242 | |
| 4243 | |
| 4244 | |
| 4245 | /* |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4246 | * PyTyp_pjsua_call_info |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4247 | */ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4248 | static PyTypeObject PyTyp_pjsua_call_info = |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4249 | { |
| 4250 | PyObject_HEAD_INIT(NULL) |
| 4251 | 0, /*ob_size*/ |
| 4252 | "py_pjsua.Call_Info", /*tp_name*/ |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4253 | sizeof(PyObj_pjsua_call_info), /*tp_basicsize*/ |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4254 | 0, /*tp_itemsize*/ |
| 4255 | (destructor)call_info_dealloc,/*tp_dealloc*/ |
| 4256 | 0, /*tp_print*/ |
| 4257 | 0, /*tp_getattr*/ |
| 4258 | 0, /*tp_setattr*/ |
| 4259 | 0, /*tp_compare*/ |
| 4260 | 0, /*tp_repr*/ |
| 4261 | 0, /*tp_as_number*/ |
| 4262 | 0, /*tp_as_sequence*/ |
| 4263 | 0, /*tp_as_mapping*/ |
| 4264 | 0, /*tp_hash */ |
| 4265 | 0, /*tp_call*/ |
| 4266 | 0, /*tp_str*/ |
| 4267 | 0, /*tp_getattro*/ |
| 4268 | 0, /*tp_setattro*/ |
| 4269 | 0, /*tp_as_buffer*/ |
| 4270 | Py_TPFLAGS_DEFAULT, /*tp_flags*/ |
| 4271 | "Call Info objects", /* tp_doc */ |
| 4272 | 0, /* tp_traverse */ |
| 4273 | 0, /* tp_clear */ |
| 4274 | 0, /* tp_richcompare */ |
| 4275 | 0, /* tp_weaklistoffset */ |
| 4276 | 0, /* tp_iter */ |
| 4277 | 0, /* tp_iternext */ |
| 4278 | 0, /* tp_methods */ |
| 4279 | call_info_members, /* tp_members */ |
| 4280 | 0, /* tp_getset */ |
| 4281 | 0, /* tp_base */ |
| 4282 | 0, /* tp_dict */ |
| 4283 | 0, /* tp_descr_get */ |
| 4284 | 0, /* tp_descr_set */ |
| 4285 | 0, /* tp_dictoffset */ |
| 4286 | 0, /* tp_init */ |
| 4287 | 0, /* tp_alloc */ |
| 4288 | call_info_new, /* tp_new */ |
| 4289 | |
| 4290 | }; |
| 4291 | |
| 4292 | /* |
| 4293 | * py_pjsua_call_get_max_count |
| 4294 | */ |
| 4295 | static PyObject *py_pjsua_call_get_max_count |
| 4296 | (PyObject *pSelf, PyObject *pArgs) |
| 4297 | { |
| 4298 | int count; |
| 4299 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4300 | PJ_UNUSED_ARG(pSelf); |
| 4301 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4302 | if (!PyArg_ParseTuple(pArgs, "")) |
| 4303 | { |
| 4304 | return NULL; |
| 4305 | } |
| 4306 | |
| 4307 | count = pjsua_call_get_max_count(); |
| 4308 | |
| 4309 | |
| 4310 | return Py_BuildValue("i", count); |
| 4311 | } |
| 4312 | |
| 4313 | /* |
| 4314 | * py_pjsua_call_get_count |
| 4315 | */ |
| 4316 | static PyObject *py_pjsua_call_get_count |
| 4317 | (PyObject *pSelf, PyObject *pArgs) |
| 4318 | { |
| 4319 | |
| 4320 | int count; |
| 4321 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4322 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4323 | |
| 4324 | if (!PyArg_ParseTuple(pArgs, "")) |
| 4325 | { |
| 4326 | return NULL; |
| 4327 | } |
| 4328 | |
| 4329 | count = pjsua_call_get_count(); |
| 4330 | |
| 4331 | |
| 4332 | return Py_BuildValue("i", count); |
| 4333 | } |
| 4334 | |
| 4335 | /* |
| 4336 | * py_pjsua_enum_calls |
| 4337 | */ |
| 4338 | static PyObject *py_pjsua_enum_calls(PyObject *pSelf, PyObject *pArgs) |
| 4339 | { |
| 4340 | pj_status_t status; |
| 4341 | PyObject *list; |
| 4342 | |
| 4343 | pjsua_transport_id id[PJSUA_MAX_CALLS]; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4344 | unsigned c, i; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4345 | |
| 4346 | PJ_UNUSED_ARG(pSelf); |
| 4347 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4348 | if (!PyArg_ParseTuple(pArgs, "")) |
| 4349 | { |
| 4350 | return NULL; |
| 4351 | } |
| 4352 | |
| 4353 | c = PJ_ARRAY_SIZE(id); |
| 4354 | status = pjsua_enum_calls(id, &c); |
| 4355 | |
| 4356 | list = PyList_New(c); |
| 4357 | for (i = 0; i < c; i++) |
| 4358 | { |
| 4359 | int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); |
| 4360 | if (ret == -1) |
| 4361 | { |
| 4362 | return NULL; |
| 4363 | } |
| 4364 | } |
| 4365 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4366 | return Py_BuildValue("O",list); |
| 4367 | } |
| 4368 | |
| 4369 | /* |
| 4370 | * py_pjsua_call_make_call |
| 4371 | */ |
| 4372 | static PyObject *py_pjsua_call_make_call |
| 4373 | (PyObject *pSelf, PyObject *pArgs) |
| 4374 | { |
| 4375 | int status; |
| 4376 | int acc_id; |
| 4377 | pj_str_t dst_uri; |
| 4378 | PyObject * sd; |
| 4379 | unsigned options; |
| 4380 | pjsua_msg_data msg_data; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4381 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4382 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4383 | int user_data; |
| 4384 | int call_id; |
| 4385 | pj_pool_t * pool; |
| 4386 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4387 | PJ_UNUSED_ARG(pSelf); |
| 4388 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4389 | if (!PyArg_ParseTuple |
| 4390 | (pArgs, "iOIiO", &acc_id, &sd, &options, &user_data, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4391 | { |
| 4392 | return NULL; |
| 4393 | } |
| 4394 | |
| 4395 | dst_uri.ptr = PyString_AsString(sd); |
| 4396 | dst_uri.slen = strlen(PyString_AsString(sd)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4397 | if (omdObj != Py_None) |
| 4398 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4399 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4400 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4401 | msg_data.content_type.slen = strlen |
| 4402 | (PyString_AsString(omd->content_type)); |
| 4403 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4404 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4405 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4406 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4407 | status = pjsua_call_make_call(acc_id, &dst_uri, |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4408 | options, (void*)user_data, &msg_data, &call_id); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4409 | pj_pool_release(pool); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4410 | } else { |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 4411 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4412 | status = pjsua_call_make_call(acc_id, &dst_uri, |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4413 | options, (void*)user_data, NULL, &call_id); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4414 | } |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 4415 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4416 | return Py_BuildValue("ii",status, call_id); |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 4417 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4418 | } |
| 4419 | |
| 4420 | /* |
| 4421 | * py_pjsua_call_is_active |
| 4422 | */ |
| 4423 | static PyObject *py_pjsua_call_is_active |
| 4424 | (PyObject *pSelf, PyObject *pArgs) |
| 4425 | { |
| 4426 | int call_id; |
| 4427 | int isActive; |
| 4428 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4429 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4430 | |
| 4431 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4432 | { |
| 4433 | return NULL; |
| 4434 | } |
| 4435 | |
| 4436 | isActive = pjsua_call_is_active(call_id); |
| 4437 | |
| 4438 | |
| 4439 | return Py_BuildValue("i", isActive); |
| 4440 | } |
| 4441 | |
| 4442 | /* |
| 4443 | * py_pjsua_call_has_media |
| 4444 | */ |
| 4445 | static PyObject *py_pjsua_call_has_media |
| 4446 | (PyObject *pSelf, PyObject *pArgs) |
| 4447 | { |
| 4448 | int call_id; |
| 4449 | int hasMedia; |
| 4450 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4451 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4452 | |
| 4453 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4454 | { |
| 4455 | return NULL; |
| 4456 | } |
| 4457 | |
| 4458 | hasMedia = pjsua_call_has_media(call_id); |
| 4459 | |
| 4460 | |
| 4461 | return Py_BuildValue("i", hasMedia); |
| 4462 | } |
| 4463 | |
| 4464 | /* |
| 4465 | * py_pjsua_call_get_conf_port |
| 4466 | */ |
| 4467 | static PyObject *py_pjsua_call_get_conf_port |
| 4468 | (PyObject *pSelf, PyObject *pArgs) |
| 4469 | { |
| 4470 | int call_id; |
| 4471 | int port_id; |
| 4472 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4473 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4474 | |
| 4475 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4476 | { |
| 4477 | return NULL; |
| 4478 | } |
| 4479 | |
| 4480 | port_id = pjsua_call_get_conf_port(call_id); |
| 4481 | |
| 4482 | |
| 4483 | return Py_BuildValue("i", port_id); |
| 4484 | } |
| 4485 | |
| 4486 | /* |
| 4487 | * py_pjsua_call_get_info |
| 4488 | */ |
| 4489 | static PyObject *py_pjsua_call_get_info |
| 4490 | (PyObject *pSelf, PyObject *pArgs) |
| 4491 | { |
| 4492 | int call_id; |
| 4493 | int status; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4494 | PyObj_pjsua_call_info * oi; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4495 | pjsua_call_info info; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4496 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4497 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4498 | |
| 4499 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4500 | { |
| 4501 | return NULL; |
| 4502 | } |
| 4503 | |
| 4504 | |
| 4505 | status = pjsua_call_get_info(call_id, &info); |
| 4506 | if (status == PJ_SUCCESS) |
| 4507 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4508 | 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] | 4509 | oi->acc_id = info.acc_id; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4510 | pj_ansi_snprintf(oi->buf_.call_id, sizeof(oi->buf_.call_id), |
| 4511 | "%.*s", (int)info.call_id.slen, info.call_id.ptr); |
| 4512 | pj_ansi_snprintf(oi->buf_.last_status_text, |
| 4513 | sizeof(oi->buf_.last_status_text), |
| 4514 | "%.*s", (int)info.last_status_text.slen, info.last_status_text.ptr); |
| 4515 | pj_ansi_snprintf(oi->buf_.local_contact, sizeof(oi->buf_.local_contact), |
| 4516 | "%.*s", (int)info.local_contact.slen, info.local_contact.ptr); |
| 4517 | pj_ansi_snprintf(oi->buf_.local_info, sizeof(oi->buf_.local_info), |
| 4518 | "%.*s", (int)info.local_info.slen, info.local_info.ptr); |
| 4519 | pj_ansi_snprintf(oi->buf_.remote_contact, |
| 4520 | sizeof(oi->buf_.remote_contact), |
| 4521 | "%.*s", (int)info.remote_contact.slen, info.remote_contact.ptr); |
| 4522 | pj_ansi_snprintf(oi->buf_.remote_info, sizeof(oi->buf_.remote_info), |
| 4523 | "%.*s", (int)info.remote_info.slen, info.remote_info.ptr); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4524 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4525 | oi->call_id = PyString_FromStringAndSize(info.call_id.ptr, |
| 4526 | info.call_id.slen); |
| 4527 | oi->conf_slot = info.conf_slot; |
| 4528 | oi->connect_duration->sec = info.connect_duration.sec; |
| 4529 | oi->connect_duration->msec = info.connect_duration.msec; |
| 4530 | oi->total_duration->sec = info.total_duration.sec; |
| 4531 | oi->total_duration->msec = info.total_duration.msec; |
| 4532 | oi->id = info.id; |
| 4533 | oi->last_status = info.last_status; |
| 4534 | oi->last_status_text = PyString_FromStringAndSize( |
| 4535 | info.last_status_text.ptr, info.last_status_text.slen); |
| 4536 | oi->local_contact = PyString_FromStringAndSize( |
| 4537 | info.local_contact.ptr, info.local_contact.slen); |
| 4538 | oi->local_info = PyString_FromStringAndSize( |
| 4539 | info.local_info.ptr, info.local_info.slen); |
| 4540 | oi->remote_contact = PyString_FromStringAndSize( |
| 4541 | info.remote_contact.ptr, info.remote_contact.slen); |
| 4542 | oi->remote_info = PyString_FromStringAndSize( |
| 4543 | info.remote_info.ptr, info.remote_info.slen); |
| 4544 | oi->media_dir = info.media_dir; |
| 4545 | oi->media_status = info.media_status; |
| 4546 | oi->role = info.role; |
| 4547 | oi->state = info.state; |
| 4548 | oi->state_text = PyString_FromStringAndSize( |
| 4549 | info.state_text.ptr, info.state_text.slen); |
| 4550 | |
| 4551 | return Py_BuildValue("O", oi); |
| 4552 | } else { |
| 4553 | Py_INCREF(Py_None); |
| 4554 | return Py_None; |
| 4555 | } |
| 4556 | } |
| 4557 | |
| 4558 | /* |
| 4559 | * py_pjsua_call_set_user_data |
| 4560 | */ |
| 4561 | static PyObject *py_pjsua_call_set_user_data |
| 4562 | (PyObject *pSelf, PyObject *pArgs) |
| 4563 | { |
| 4564 | int call_id; |
| 4565 | int user_data; |
| 4566 | int status; |
| 4567 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4568 | PJ_UNUSED_ARG(pSelf); |
| 4569 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4570 | if (!PyArg_ParseTuple(pArgs, "ii", &call_id, &user_data)) |
| 4571 | { |
| 4572 | return NULL; |
| 4573 | } |
| 4574 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4575 | status = pjsua_call_set_user_data(call_id, (void*)user_data); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4576 | |
| 4577 | |
| 4578 | return Py_BuildValue("i", status); |
| 4579 | } |
| 4580 | |
| 4581 | /* |
| 4582 | * py_pjsua_call_get_user_data |
| 4583 | */ |
| 4584 | static PyObject *py_pjsua_call_get_user_data |
| 4585 | (PyObject *pSelf, PyObject *pArgs) |
| 4586 | { |
| 4587 | int call_id; |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4588 | void * user_data; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4589 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4590 | PJ_UNUSED_ARG(pSelf); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4591 | |
| 4592 | if (!PyArg_ParseTuple(pArgs, "i", &call_id)) |
| 4593 | { |
| 4594 | return NULL; |
| 4595 | } |
| 4596 | |
| 4597 | user_data = pjsua_call_get_user_data(call_id); |
| 4598 | |
| 4599 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4600 | return Py_BuildValue("i", (int)user_data); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4601 | } |
| 4602 | |
| 4603 | /* |
| 4604 | * py_pjsua_call_answer |
| 4605 | */ |
| 4606 | static PyObject *py_pjsua_call_answer |
| 4607 | (PyObject *pSelf, PyObject *pArgs) |
| 4608 | { |
| 4609 | int status; |
| 4610 | int call_id; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4611 | pj_str_t * reason, tmp_reason; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4612 | PyObject * sr; |
| 4613 | unsigned code; |
| 4614 | pjsua_msg_data msg_data; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4615 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4616 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4617 | pj_pool_t * pool; |
| 4618 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4619 | PJ_UNUSED_ARG(pSelf); |
| 4620 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4621 | if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4622 | { |
| 4623 | return NULL; |
| 4624 | } |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4625 | if (sr == Py_None) |
| 4626 | { |
| 4627 | reason = NULL; |
| 4628 | } else { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4629 | reason = &tmp_reason; |
| 4630 | tmp_reason.ptr = PyString_AsString(sr); |
| 4631 | tmp_reason.slen = strlen(PyString_AsString(sr)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4632 | } |
| 4633 | if (omdObj != Py_None) |
| 4634 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4635 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4636 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4637 | msg_data.content_type.slen = strlen |
| 4638 | (PyString_AsString(omd->content_type)); |
| 4639 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4640 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4641 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4642 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4643 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4644 | status = pjsua_call_answer(call_id, code, reason, &msg_data); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4645 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4646 | pj_pool_release(pool); |
| 4647 | } else { |
| 4648 | |
Fahris | 89ea3d0 | 2007-02-07 08:18:35 +0000 | [diff] [blame] | 4649 | status = pjsua_call_answer(call_id, code, reason, NULL); |
| 4650 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4651 | } |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4652 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4653 | return Py_BuildValue("i",status); |
| 4654 | } |
| 4655 | |
| 4656 | /* |
| 4657 | * py_pjsua_call_hangup |
| 4658 | */ |
| 4659 | static PyObject *py_pjsua_call_hangup |
| 4660 | (PyObject *pSelf, PyObject *pArgs) |
| 4661 | { |
| 4662 | int status; |
| 4663 | int call_id; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4664 | pj_str_t * reason, tmp_reason; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4665 | PyObject * sr; |
| 4666 | unsigned code; |
| 4667 | pjsua_msg_data msg_data; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4668 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4669 | PyObj_pjsua_msg_data * omd; |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4670 | pj_pool_t * pool = NULL; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4671 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4672 | PJ_UNUSED_ARG(pSelf); |
| 4673 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4674 | if (!PyArg_ParseTuple(pArgs, "iIOO", &call_id, &code, &sr, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4675 | { |
| 4676 | return NULL; |
| 4677 | } |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 4678 | if (sr == Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4679 | { |
| 4680 | reason = NULL; |
| 4681 | } else { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4682 | reason = &tmp_reason; |
| 4683 | tmp_reason.ptr = PyString_AsString(sr); |
| 4684 | tmp_reason.slen = strlen(PyString_AsString(sr)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4685 | } |
| 4686 | if (omdObj != Py_None) |
| 4687 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4688 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4689 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4690 | msg_data.content_type.slen = strlen |
| 4691 | (PyString_AsString(omd->content_type)); |
| 4692 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4693 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4694 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4695 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4696 | status = pjsua_call_hangup(call_id, code, reason, &msg_data); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4697 | pj_pool_release(pool); |
Benny Prijono | ed7a5a7 | 2007-01-29 18:36:38 +0000 | [diff] [blame] | 4698 | } else { |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4699 | status = pjsua_call_hangup(call_id, code, reason, NULL); |
| 4700 | } |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4701 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4702 | return Py_BuildValue("i",status); |
| 4703 | } |
| 4704 | |
| 4705 | /* |
| 4706 | * py_pjsua_call_set_hold |
| 4707 | */ |
| 4708 | static PyObject *py_pjsua_call_set_hold |
| 4709 | (PyObject *pSelf, PyObject *pArgs) |
| 4710 | { |
| 4711 | int status; |
| 4712 | int call_id; |
| 4713 | pjsua_msg_data msg_data; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4714 | PyObject * omdObj; |
| 4715 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4716 | pj_pool_t * pool; |
| 4717 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4718 | PJ_UNUSED_ARG(pSelf); |
| 4719 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4720 | if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4721 | { |
| 4722 | return NULL; |
| 4723 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4724 | |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4725 | if (omdObj != Py_None) |
| 4726 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4727 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4728 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4729 | msg_data.content_type.slen = strlen |
| 4730 | (PyString_AsString(omd->content_type)); |
| 4731 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4732 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4733 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4734 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4735 | status = pjsua_call_set_hold(call_id, &msg_data); |
| 4736 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4737 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4738 | status = pjsua_call_set_hold(call_id, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4739 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4740 | return Py_BuildValue("i",status); |
| 4741 | } |
| 4742 | |
| 4743 | /* |
| 4744 | * py_pjsua_call_reinvite |
| 4745 | */ |
| 4746 | static PyObject *py_pjsua_call_reinvite |
| 4747 | (PyObject *pSelf, PyObject *pArgs) |
| 4748 | { |
| 4749 | int status; |
| 4750 | int call_id; |
| 4751 | int unhold; |
| 4752 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4753 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4754 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4755 | pj_pool_t * pool; |
| 4756 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4757 | PJ_UNUSED_ARG(pSelf); |
| 4758 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4759 | if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &unhold, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4760 | { |
| 4761 | return NULL; |
| 4762 | } |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4763 | |
| 4764 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4765 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4766 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4767 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4768 | msg_data.content_type.slen = strlen |
| 4769 | (PyString_AsString(omd->content_type)); |
| 4770 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4771 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4772 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4773 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4774 | status = pjsua_call_reinvite(call_id, unhold, &msg_data); |
| 4775 | pj_pool_release(pool); |
| 4776 | } else { |
| 4777 | status = pjsua_call_reinvite(call_id, unhold, NULL); |
| 4778 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4779 | return Py_BuildValue("i",status); |
| 4780 | } |
| 4781 | |
| 4782 | /* |
| 4783 | * py_pjsua_call_xfer |
| 4784 | */ |
| 4785 | static PyObject *py_pjsua_call_xfer |
| 4786 | (PyObject *pSelf, PyObject *pArgs) |
| 4787 | { |
| 4788 | int status; |
| 4789 | int call_id; |
| 4790 | pj_str_t dest; |
| 4791 | PyObject * sd; |
| 4792 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4793 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4794 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4795 | pj_pool_t * pool; |
| 4796 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4797 | PJ_UNUSED_ARG(pSelf); |
| 4798 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4799 | if (!PyArg_ParseTuple(pArgs, "iOO", &call_id, &sd, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4800 | { |
| 4801 | return NULL; |
| 4802 | } |
| 4803 | |
| 4804 | dest.ptr = PyString_AsString(sd); |
| 4805 | dest.slen = strlen(PyString_AsString(sd)); |
| 4806 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4807 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4808 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4809 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4810 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4811 | msg_data.content_type.slen = strlen |
| 4812 | (PyString_AsString(omd->content_type)); |
| 4813 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4814 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4815 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4816 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4817 | status = pjsua_call_xfer(call_id, &dest, &msg_data); |
| 4818 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4819 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4820 | status = pjsua_call_xfer(call_id, &dest, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4821 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4822 | return Py_BuildValue("i",status); |
| 4823 | } |
| 4824 | |
| 4825 | /* |
| 4826 | * py_pjsua_call_xfer_replaces |
| 4827 | */ |
| 4828 | static PyObject *py_pjsua_call_xfer_replaces |
| 4829 | (PyObject *pSelf, PyObject *pArgs) |
| 4830 | { |
| 4831 | int status; |
| 4832 | int call_id; |
| 4833 | int dest_call_id; |
| 4834 | unsigned options; |
| 4835 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4836 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4837 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4838 | pj_pool_t * pool; |
| 4839 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4840 | PJ_UNUSED_ARG(pSelf); |
| 4841 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4842 | if (!PyArg_ParseTuple |
| 4843 | (pArgs, "iiIO", &call_id, &dest_call_id, &options, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4844 | { |
| 4845 | return NULL; |
| 4846 | } |
| 4847 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4848 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4849 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4850 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4851 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4852 | msg_data.content_type.slen = strlen |
| 4853 | (PyString_AsString(omd->content_type)); |
| 4854 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4855 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4856 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4857 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4858 | status = pjsua_call_xfer_replaces |
| 4859 | (call_id, dest_call_id, options, &msg_data); |
| 4860 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4861 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4862 | status = pjsua_call_xfer_replaces(call_id, dest_call_id,options, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4863 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4864 | return Py_BuildValue("i",status); |
| 4865 | } |
| 4866 | |
| 4867 | /* |
| 4868 | * py_pjsua_call_dial_dtmf |
| 4869 | */ |
| 4870 | static PyObject *py_pjsua_call_dial_dtmf |
| 4871 | (PyObject *pSelf, PyObject *pArgs) |
| 4872 | { |
| 4873 | int call_id; |
| 4874 | PyObject * sd; |
| 4875 | pj_str_t digits; |
| 4876 | int status; |
| 4877 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4878 | PJ_UNUSED_ARG(pSelf); |
| 4879 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4880 | if (!PyArg_ParseTuple(pArgs, "iO", &call_id, &sd)) |
| 4881 | { |
| 4882 | return NULL; |
| 4883 | } |
| 4884 | digits.ptr = PyString_AsString(sd); |
| 4885 | digits.slen = strlen(PyString_AsString(sd)); |
| 4886 | status = pjsua_call_dial_dtmf(call_id, &digits); |
| 4887 | |
| 4888 | return Py_BuildValue("i", status); |
| 4889 | } |
| 4890 | |
| 4891 | /* |
| 4892 | * py_pjsua_call_send_im |
| 4893 | */ |
| 4894 | static PyObject *py_pjsua_call_send_im |
| 4895 | (PyObject *pSelf, PyObject *pArgs) |
| 4896 | { |
| 4897 | int status; |
| 4898 | int call_id; |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4899 | pj_str_t content; |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4900 | pj_str_t * mime_type, tmp_mime_type; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4901 | PyObject * sm; |
| 4902 | PyObject * sc; |
| 4903 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4904 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4905 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4906 | int user_data; |
| 4907 | pj_pool_t * pool; |
| 4908 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4909 | PJ_UNUSED_ARG(pSelf); |
| 4910 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4911 | if (!PyArg_ParseTuple |
| 4912 | (pArgs, "iOOOi", &call_id, &sm, &sc, &omdObj, &user_data)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4913 | { |
| 4914 | return NULL; |
| 4915 | } |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4916 | if (sm == Py_None) |
| 4917 | { |
| 4918 | mime_type = NULL; |
| 4919 | } else { |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4920 | mime_type = &tmp_mime_type; |
| 4921 | tmp_mime_type.ptr = PyString_AsString(sm); |
| 4922 | tmp_mime_type.slen = strlen(PyString_AsString(sm)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4923 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4924 | content.ptr = PyString_AsString(sc); |
| 4925 | content.slen = strlen(PyString_AsString(sc)); |
| 4926 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4927 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4928 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4929 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4930 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4931 | msg_data.content_type.slen = strlen |
| 4932 | (PyString_AsString(omd->content_type)); |
| 4933 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4934 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4935 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4936 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4937 | status = pjsua_call_send_im |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4938 | (call_id, mime_type, &content, &msg_data, (void *)user_data); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4939 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4940 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4941 | status = pjsua_call_send_im |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4942 | (call_id, mime_type, &content, NULL, (void *)user_data); |
| 4943 | } |
Fahris | e314b88 | 2007-02-02 10:52:04 +0000 | [diff] [blame] | 4944 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4945 | return Py_BuildValue("i",status); |
| 4946 | } |
| 4947 | |
| 4948 | /* |
| 4949 | * py_pjsua_call_send_typing_ind |
| 4950 | */ |
| 4951 | static PyObject *py_pjsua_call_send_typing_ind |
| 4952 | (PyObject *pSelf, PyObject *pArgs) |
| 4953 | { |
| 4954 | int status; |
| 4955 | int call_id; |
| 4956 | int is_typing; |
| 4957 | pjsua_msg_data msg_data; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4958 | PyObject * omdObj; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4959 | PyObj_pjsua_msg_data * omd; |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4960 | pj_pool_t * pool; |
| 4961 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4962 | PJ_UNUSED_ARG(pSelf); |
| 4963 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4964 | if (!PyArg_ParseTuple(pArgs, "iiO", &call_id, &is_typing, &omdObj)) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4965 | { |
| 4966 | return NULL; |
| 4967 | } |
| 4968 | |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4969 | if (omdObj != Py_None) |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4970 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4971 | omd = (PyObj_pjsua_msg_data *)omdObj; |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4972 | msg_data.content_type.ptr = PyString_AsString(omd->content_type); |
| 4973 | msg_data.content_type.slen = strlen |
| 4974 | (PyString_AsString(omd->content_type)); |
| 4975 | msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); |
| 4976 | msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4977 | pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4978 | translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); |
| 4979 | status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data); |
| 4980 | pj_pool_release(pool); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4981 | } else { |
Fahris | 17d9181 | 2007-01-29 12:09:33 +0000 | [diff] [blame] | 4982 | status = pjsua_call_send_typing_ind(call_id, is_typing, NULL); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 4983 | } |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4984 | return Py_BuildValue("i",status); |
| 4985 | } |
| 4986 | |
| 4987 | /* |
| 4988 | * py_pjsua_call_hangup_all |
| 4989 | */ |
| 4990 | static PyObject *py_pjsua_call_hangup_all |
| 4991 | (PyObject *pSelf, PyObject *pArgs) |
| 4992 | { |
| 4993 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 4994 | PJ_UNUSED_ARG(pSelf); |
| 4995 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 4996 | if (!PyArg_ParseTuple(pArgs, "")) |
| 4997 | { |
| 4998 | return NULL; |
| 4999 | } |
| 5000 | |
| 5001 | pjsua_call_hangup_all(); |
| 5002 | |
| 5003 | Py_INCREF(Py_None); |
| 5004 | return Py_None; |
| 5005 | } |
| 5006 | |
| 5007 | /* |
| 5008 | * py_pjsua_call_dump |
| 5009 | */ |
| 5010 | static PyObject *py_pjsua_call_dump |
| 5011 | (PyObject *pSelf, PyObject *pArgs) |
| 5012 | { |
| 5013 | int call_id; |
| 5014 | int with_media; |
| 5015 | PyObject * sb; |
| 5016 | PyObject * si; |
| 5017 | char * buffer; |
| 5018 | char * indent; |
| 5019 | unsigned maxlen; |
| 5020 | int status; |
| 5021 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5022 | PJ_UNUSED_ARG(pSelf); |
| 5023 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5024 | if (!PyArg_ParseTuple(pArgs, "iiIO", &call_id, &with_media, &maxlen, &si)) |
| 5025 | { |
| 5026 | return NULL; |
| 5027 | } |
| 5028 | buffer = (char *) malloc (maxlen * sizeof(char)); |
| 5029 | indent = PyString_AsString(si); |
| 5030 | |
| 5031 | status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent); |
| 5032 | sb = PyString_FromStringAndSize(buffer, maxlen); |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 5033 | free(buffer); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5034 | return Py_BuildValue("O", sb); |
| 5035 | } |
| 5036 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 5037 | |
| 5038 | /* |
| 5039 | * py_pjsua_dump |
| 5040 | * Dump application states. |
| 5041 | */ |
| 5042 | static PyObject *py_pjsua_dump(PyObject *pSelf, PyObject *pArgs) |
| 5043 | { |
| 5044 | unsigned old_decor; |
| 5045 | char buf[1024]; |
| 5046 | int detail; |
| 5047 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5048 | PJ_UNUSED_ARG(pSelf); |
| 5049 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 5050 | if (!PyArg_ParseTuple(pArgs, "i", &detail)) |
| 5051 | { |
| 5052 | return NULL; |
| 5053 | } |
| 5054 | |
| 5055 | PJ_LOG(3,(THIS_FILE, "Start dumping application states:")); |
| 5056 | |
| 5057 | old_decor = pj_log_get_decor(); |
| 5058 | pj_log_set_decor(old_decor & (PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR)); |
| 5059 | |
| 5060 | if (detail) |
| 5061 | pj_dump_config(); |
| 5062 | |
| 5063 | pjsip_endpt_dump(pjsua_get_pjsip_endpt(), detail); |
| 5064 | pjmedia_endpt_dump(pjsua_get_pjmedia_endpt()); |
| 5065 | pjsip_tsx_layer_dump(detail); |
| 5066 | pjsip_ua_dump(detail); |
| 5067 | |
| 5068 | |
| 5069 | /* Dump all invite sessions: */ |
| 5070 | PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:")); |
| 5071 | |
| 5072 | if (pjsua_call_get_count() == 0) { |
| 5073 | |
| 5074 | PJ_LOG(3,(THIS_FILE, " - no sessions -")); |
| 5075 | |
| 5076 | } else { |
| 5077 | unsigned i, max; |
| 5078 | |
| 5079 | max = pjsua_call_get_max_count(); |
| 5080 | for (i=0; i<max; ++i) { |
| 5081 | if (pjsua_call_is_active(i)) { |
| 5082 | pjsua_call_dump(i, detail, buf, sizeof(buf), " "); |
| 5083 | PJ_LOG(3,(THIS_FILE, "%s", buf)); |
| 5084 | } |
| 5085 | } |
| 5086 | } |
| 5087 | |
| 5088 | /* Dump presence status */ |
| 5089 | pjsua_pres_dump(detail); |
| 5090 | |
| 5091 | pj_log_set_decor(old_decor); |
| 5092 | PJ_LOG(3,(THIS_FILE, "Dump complete")); |
| 5093 | |
| 5094 | Py_INCREF(Py_None); |
| 5095 | return Py_None; |
| 5096 | } |
| 5097 | |
| 5098 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5099 | static char pjsua_call_get_max_count_doc[] = |
| 5100 | "int py_pjsua.call_get_max_count () " |
| 5101 | "Get maximum number of calls configured in pjsua."; |
| 5102 | static char pjsua_call_get_count_doc[] = |
| 5103 | "int py_pjsua.call_get_count () " |
| 5104 | "Get number of currently active calls."; |
| 5105 | static char pjsua_enum_calls_doc[] = |
| 5106 | "int[] py_pjsua.enum_calls () " |
| 5107 | "Get maximum number of calls configured in pjsua."; |
| 5108 | static char pjsua_call_make_call_doc[] = |
| 5109 | "int,int py_pjsua.call_make_call (int acc_id, string dst_uri, int options," |
| 5110 | "int user_data, py_pjsua.Msg_Data msg_data) " |
| 5111 | "Make outgoing call to the specified URI using the specified account."; |
| 5112 | static char pjsua_call_is_active_doc[] = |
| 5113 | "int py_pjsua.call_is_active (int call_id) " |
| 5114 | "Check if the specified call has active INVITE session and the INVITE " |
| 5115 | "session has not been disconnected."; |
| 5116 | static char pjsua_call_has_media_doc[] = |
| 5117 | "int py_pjsua.call_has_media (int call_id) " |
| 5118 | "Check if call has an active media session."; |
| 5119 | static char pjsua_call_get_conf_port_doc[] = |
| 5120 | "int py_pjsua.call_get_conf_port (int call_id) " |
| 5121 | "Get the conference port identification associated with the call."; |
| 5122 | static char pjsua_call_get_info_doc[] = |
| 5123 | "py_pjsua.Call_Info py_pjsua.call_get_info (int call_id) " |
| 5124 | "Obtain detail information about the specified call."; |
| 5125 | static char pjsua_call_set_user_data_doc[] = |
| 5126 | "int py_pjsua.call_set_user_data (int call_id, int user_data) " |
| 5127 | "Attach application specific data to the call."; |
| 5128 | static char pjsua_call_get_user_data_doc[] = |
| 5129 | "int py_pjsua.call_get_user_data (int call_id) " |
| 5130 | "Get user data attached to the call."; |
| 5131 | static char pjsua_call_answer_doc[] = |
| 5132 | "int py_pjsua.call_answer (int call_id, int code, string reason, " |
| 5133 | "py_pjsua.Msg_Data msg_data) " |
| 5134 | "Send response to incoming INVITE request."; |
| 5135 | static char pjsua_call_hangup_doc[] = |
| 5136 | "int py_pjsua.call_hangup (int call_id, int code, string reason, " |
| 5137 | "py_pjsua.Msg_Data msg_data) " |
| 5138 | "Hangup call by using method that is appropriate according " |
| 5139 | "to the call state."; |
| 5140 | static char pjsua_call_set_hold_doc[] = |
| 5141 | "int py_pjsua.call_set_hold (int call_id, py_pjsua.Msg_Data msg_data) " |
| 5142 | "Put the specified call on hold."; |
| 5143 | static char pjsua_call_reinvite_doc[] = |
| 5144 | "int py_pjsua.call_reinvite (int call_id, int unhold, " |
| 5145 | "py_pjsua.Msg_Data msg_data) " |
| 5146 | "Send re-INVITE (to release hold)."; |
| 5147 | static char pjsua_call_xfer_doc[] = |
| 5148 | "int py_pjsua.call_xfer (int call_id, string dest, " |
| 5149 | "py_pjsua.Msg_Data msg_data) " |
| 5150 | "Initiate call transfer to the specified address. " |
| 5151 | "This function will send REFER request to instruct remote call party " |
| 5152 | "to initiate a new INVITE session to the specified destination/target."; |
| 5153 | static char pjsua_call_xfer_replaces_doc[] = |
| 5154 | "int py_pjsua.call_xfer_replaces (int call_id, int dest_call_id, " |
| 5155 | "int options, py_pjsua.Msg_Data msg_data) " |
| 5156 | "Initiate attended call transfer. This function will send REFER request " |
| 5157 | "to instruct remote call party to initiate new INVITE session to the URL " |
| 5158 | "of dest_call_id. The party at dest_call_id then should 'replace' the call" |
| 5159 | "with us with the new call from the REFER recipient."; |
| 5160 | static char pjsua_call_dial_dtmf_doc[] = |
| 5161 | "int py_pjsua.call_dial_dtmf (int call_id, string digits) " |
| 5162 | "Send DTMF digits to remote using RFC 2833 payload formats."; |
| 5163 | static char pjsua_call_send_im_doc[] = |
| 5164 | "int py_pjsua.call_send_im (int call_id, string mime_type, string content," |
| 5165 | "py_pjsua.Msg_Data msg_data, int user_data) " |
| 5166 | "Send instant messaging inside INVITE session."; |
| 5167 | static char pjsua_call_send_typing_ind_doc[] = |
| 5168 | "int py_pjsua.call_send_typing_ind (int call_id, int is_typing, " |
| 5169 | "py_pjsua.Msg_Data msg_data) " |
| 5170 | "Send IM typing indication inside INVITE session."; |
| 5171 | static char pjsua_call_hangup_all_doc[] = |
| 5172 | "void py_pjsua.call_hangup_all () " |
| 5173 | "Terminate all calls."; |
| 5174 | static char pjsua_call_dump_doc[] = |
| 5175 | "int py_pjsua.call_dump (int call_id, int with_media, int maxlen, " |
| 5176 | "string indent) " |
| 5177 | "Dump call and media statistics to string."; |
| 5178 | |
| 5179 | /* END OF LIB CALL */ |
| 5180 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5181 | /* |
| 5182 | * Map of function names to functions |
| 5183 | */ |
| 5184 | static PyMethodDef py_pjsua_methods[] = |
| 5185 | { |
| 5186 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5187 | "thread_register", py_pjsua_thread_register, METH_VARARGS, |
| 5188 | pjsua_thread_register_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5189 | }, |
| 5190 | { |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5191 | "perror", py_pjsua_perror, METH_VARARGS, pjsua_perror_doc |
| 5192 | }, |
| 5193 | { |
| 5194 | "create", py_pjsua_create, METH_VARARGS, pjsua_create_doc |
| 5195 | }, |
| 5196 | { |
| 5197 | "init", py_pjsua_init, METH_VARARGS, pjsua_init_doc |
| 5198 | }, |
| 5199 | { |
| 5200 | "start", py_pjsua_start, METH_VARARGS, pjsua_start_doc |
| 5201 | }, |
| 5202 | { |
| 5203 | "destroy", py_pjsua_destroy, METH_VARARGS, pjsua_destroy_doc |
| 5204 | }, |
| 5205 | { |
| 5206 | "handle_events", py_pjsua_handle_events, METH_VARARGS, |
| 5207 | pjsua_handle_events_doc |
| 5208 | }, |
| 5209 | { |
| 5210 | "verify_sip_url", py_pjsua_verify_sip_url, METH_VARARGS, |
| 5211 | pjsua_verify_sip_url_doc |
| 5212 | }, |
| 5213 | { |
| 5214 | "pool_create", py_pjsua_pool_create, METH_VARARGS, |
| 5215 | pjsua_pool_create_doc |
| 5216 | }, |
| 5217 | { |
| 5218 | "get_pjsip_endpt", py_pjsua_get_pjsip_endpt, METH_VARARGS, |
| 5219 | pjsua_get_pjsip_endpt_doc |
| 5220 | }, |
| 5221 | { |
| 5222 | "get_pjmedia_endpt", py_pjsua_get_pjmedia_endpt, METH_VARARGS, |
| 5223 | pjsua_get_pjmedia_endpt_doc |
| 5224 | }, |
| 5225 | { |
| 5226 | "get_pool_factory", py_pjsua_get_pool_factory, METH_VARARGS, |
| 5227 | pjsua_get_pool_factory_doc |
| 5228 | }, |
| 5229 | { |
| 5230 | "reconfigure_logging", py_pjsua_reconfigure_logging, METH_VARARGS, |
| 5231 | pjsua_reconfigure_logging_doc |
| 5232 | }, |
| 5233 | { |
| 5234 | "logging_config_default", py_pjsua_logging_config_default, |
| 5235 | METH_VARARGS, pjsua_logging_config_default_doc |
| 5236 | }, |
| 5237 | { |
| 5238 | "config_default", py_pjsua_config_default, METH_VARARGS, |
| 5239 | pjsua_config_default_doc |
| 5240 | }, |
| 5241 | { |
| 5242 | "media_config_default", py_pjsua_media_config_default, METH_VARARGS, |
| 5243 | pjsua_media_config_default_doc |
| 5244 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5245 | |
| 5246 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5247 | { |
| 5248 | "msg_data_init", py_pjsua_msg_data_init, METH_VARARGS, |
| 5249 | pjsua_msg_data_init_doc |
| 5250 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5251 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5252 | "transport_config_default", py_pjsua_transport_config_default, |
| 5253 | METH_VARARGS,pjsua_transport_config_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5254 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5255 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5256 | "transport_create", py_pjsua_transport_create, METH_VARARGS, |
| 5257 | pjsua_transport_create_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5258 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5259 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5260 | "transport_enum_transports", py_pjsua_enum_transports, METH_VARARGS, |
| 5261 | pjsua_enum_transports_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5262 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5263 | { |
| 5264 | "transport_get_info", py_pjsua_transport_get_info, METH_VARARGS, |
| 5265 | pjsua_transport_get_info_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5266 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5267 | { |
| 5268 | "transport_set_enable", py_pjsua_transport_set_enable, METH_VARARGS, |
| 5269 | pjsua_transport_set_enable_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5270 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5271 | { |
| 5272 | "transport_close", py_pjsua_transport_close, METH_VARARGS, |
| 5273 | pjsua_transport_close_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5274 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5275 | { |
| 5276 | "acc_config_default", py_pjsua_acc_config_default, METH_VARARGS, |
| 5277 | pjsua_acc_config_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5278 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5279 | { |
| 5280 | "acc_get_count", py_pjsua_acc_get_count, METH_VARARGS, |
| 5281 | pjsua_acc_get_count_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5282 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5283 | { |
| 5284 | "acc_is_valid", py_pjsua_acc_is_valid, METH_VARARGS, |
| 5285 | pjsua_acc_is_valid_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5286 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5287 | { |
| 5288 | "acc_set_default", py_pjsua_acc_set_default, METH_VARARGS, |
| 5289 | pjsua_acc_set_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5290 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5291 | { |
| 5292 | "acc_get_default", py_pjsua_acc_get_default, METH_VARARGS, |
| 5293 | pjsua_acc_get_default_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5294 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5295 | { |
| 5296 | "acc_add", py_pjsua_acc_add, METH_VARARGS, |
| 5297 | pjsua_acc_add_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5298 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5299 | { |
| 5300 | "acc_add_local", py_pjsua_acc_add_local, METH_VARARGS, |
| 5301 | pjsua_acc_add_local_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5302 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5303 | { |
| 5304 | "acc_del", py_pjsua_acc_del, METH_VARARGS, |
| 5305 | pjsua_acc_del_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5306 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5307 | { |
| 5308 | "acc_modify", py_pjsua_acc_modify, METH_VARARGS, |
| 5309 | pjsua_acc_modify_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5310 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5311 | { |
| 5312 | "acc_set_online_status", py_pjsua_acc_set_online_status, METH_VARARGS, |
| 5313 | pjsua_acc_set_online_status_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5314 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5315 | { |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5316 | "acc_set_online_status2", py_pjsua_acc_set_online_status2, METH_VARARGS, |
| 5317 | pjsua_acc_set_online_status2_doc |
| 5318 | }, |
| 5319 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5320 | "acc_set_registration", py_pjsua_acc_set_registration, METH_VARARGS, |
| 5321 | pjsua_acc_set_registration_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5322 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5323 | { |
| 5324 | "acc_get_info", py_pjsua_acc_get_info, METH_VARARGS, |
| 5325 | pjsua_acc_get_info_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5326 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5327 | { |
| 5328 | "enum_accs", py_pjsua_enum_accs, METH_VARARGS, |
| 5329 | pjsua_enum_accs_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5330 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5331 | { |
| 5332 | "acc_enum_info", py_pjsua_acc_enum_info, METH_VARARGS, |
| 5333 | pjsua_acc_enum_info_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5334 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5335 | { |
| 5336 | "acc_find_for_outgoing", py_pjsua_acc_find_for_outgoing, METH_VARARGS, |
| 5337 | pjsua_acc_find_for_outgoing_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5338 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5339 | { |
| 5340 | "acc_find_for_incoming", py_pjsua_acc_find_for_incoming, METH_VARARGS, |
| 5341 | pjsua_acc_find_for_incoming_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5342 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5343 | { |
| 5344 | "acc_create_uac_contact", py_pjsua_acc_create_uac_contact, METH_VARARGS, |
| 5345 | pjsua_acc_create_uac_contact_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5346 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5347 | { |
| 5348 | "acc_create_uas_contact", py_pjsua_acc_create_uas_contact, METH_VARARGS, |
| 5349 | pjsua_acc_create_uas_contact_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5350 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5351 | { |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 5352 | "buddy_config_default", py_pjsua_buddy_config_default, METH_VARARGS, |
| 5353 | pjsua_buddy_config_default_doc |
| 5354 | }, |
| 5355 | { |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5356 | "get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS, |
| 5357 | pjsua_get_buddy_count_doc |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5358 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5359 | { |
| 5360 | "buddy_is_valid", py_pjsua_buddy_is_valid, METH_VARARGS, |
| 5361 | pjsua_buddy_is_valid_doc |
| 5362 | }, |
| 5363 | { |
| 5364 | "enum_buddies", py_pjsua_enum_buddies, METH_VARARGS, |
| 5365 | pjsua_enum_buddies_doc |
Fahris | 6f35cb8 | 2007-02-01 07:41:26 +0000 | [diff] [blame] | 5366 | }, |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5367 | { |
| 5368 | "buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS, |
| 5369 | pjsua_buddy_get_info_doc |
| 5370 | }, |
| 5371 | { |
| 5372 | "buddy_add", py_pjsua_buddy_add, METH_VARARGS, |
| 5373 | pjsua_buddy_add_doc |
| 5374 | }, |
| 5375 | { |
| 5376 | "buddy_del", py_pjsua_buddy_del, METH_VARARGS, |
| 5377 | pjsua_buddy_del_doc |
| 5378 | }, |
| 5379 | { |
| 5380 | "buddy_subscribe_pres", py_pjsua_buddy_subscribe_pres, METH_VARARGS, |
| 5381 | pjsua_buddy_subscribe_pres_doc |
| 5382 | }, |
| 5383 | { |
| 5384 | "pres_dump", py_pjsua_pres_dump, METH_VARARGS, |
| 5385 | pjsua_pres_dump_doc |
| 5386 | }, |
| 5387 | { |
| 5388 | "im_send", py_pjsua_im_send, METH_VARARGS, |
| 5389 | pjsua_im_send_doc |
| 5390 | }, |
| 5391 | { |
| 5392 | "im_typing", py_pjsua_im_typing, METH_VARARGS, |
| 5393 | pjsua_im_typing_doc |
| 5394 | }, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5395 | { |
| 5396 | "conf_get_max_ports", py_pjsua_conf_get_max_ports, METH_VARARGS, |
| 5397 | pjsua_conf_get_max_ports_doc |
| 5398 | }, |
| 5399 | { |
| 5400 | "conf_get_active_ports", py_pjsua_conf_get_active_ports, METH_VARARGS, |
| 5401 | pjsua_conf_get_active_ports_doc |
| 5402 | }, |
| 5403 | { |
| 5404 | "enum_conf_ports", py_pjsua_enum_conf_ports, METH_VARARGS, |
| 5405 | pjsua_enum_conf_ports_doc |
| 5406 | }, |
| 5407 | { |
| 5408 | "conf_get_port_info", py_pjsua_conf_get_port_info, METH_VARARGS, |
| 5409 | pjsua_conf_get_port_info_doc |
| 5410 | }, |
| 5411 | { |
| 5412 | "conf_add_port", py_pjsua_conf_add_port, METH_VARARGS, |
| 5413 | pjsua_conf_add_port_doc |
| 5414 | }, |
| 5415 | { |
| 5416 | "conf_remove_port", py_pjsua_conf_remove_port, METH_VARARGS, |
| 5417 | pjsua_conf_remove_port_doc |
| 5418 | }, |
| 5419 | { |
| 5420 | "conf_connect", py_pjsua_conf_connect, METH_VARARGS, |
| 5421 | pjsua_conf_connect_doc |
| 5422 | }, |
| 5423 | { |
| 5424 | "conf_disconnect", py_pjsua_conf_disconnect, METH_VARARGS, |
| 5425 | pjsua_conf_disconnect_doc |
| 5426 | }, |
| 5427 | { |
| 5428 | "player_create", py_pjsua_player_create, METH_VARARGS, |
| 5429 | pjsua_player_create_doc |
| 5430 | }, |
| 5431 | { |
| 5432 | "player_get_conf_port", py_pjsua_player_get_conf_port, METH_VARARGS, |
| 5433 | pjsua_player_get_conf_port_doc |
| 5434 | }, |
| 5435 | { |
| 5436 | "player_set_pos", py_pjsua_player_set_pos, METH_VARARGS, |
| 5437 | pjsua_player_set_pos_doc |
| 5438 | }, |
| 5439 | { |
| 5440 | "player_destroy", py_pjsua_player_destroy, METH_VARARGS, |
| 5441 | pjsua_player_destroy_doc |
| 5442 | }, |
| 5443 | { |
| 5444 | "recorder_create", py_pjsua_recorder_create, METH_VARARGS, |
| 5445 | pjsua_recorder_create_doc |
| 5446 | }, |
| 5447 | { |
| 5448 | "recorder_get_conf_port", py_pjsua_recorder_get_conf_port, METH_VARARGS, |
| 5449 | pjsua_recorder_get_conf_port_doc |
| 5450 | }, |
| 5451 | { |
| 5452 | "recorder_destroy", py_pjsua_recorder_destroy, METH_VARARGS, |
| 5453 | pjsua_recorder_destroy_doc |
| 5454 | }, |
| 5455 | { |
| 5456 | "enum_snd_devs", py_pjsua_enum_snd_devs, METH_VARARGS, |
| 5457 | pjsua_enum_snd_devs_doc |
| 5458 | }, |
Benny Prijono | ebdf877 | 2007-02-01 19:25:50 +0000 | [diff] [blame] | 5459 | { |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5460 | "get_snd_dev", py_pjsua_get_snd_dev, METH_VARARGS, |
| 5461 | pjsua_get_snd_dev_doc |
Benny Prijono | ebdf877 | 2007-02-01 19:25:50 +0000 | [diff] [blame] | 5462 | }, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5463 | { |
| 5464 | "set_snd_dev", py_pjsua_set_snd_dev, METH_VARARGS, |
| 5465 | pjsua_set_snd_dev_doc |
| 5466 | }, |
| 5467 | { |
| 5468 | "set_null_snd_dev", py_pjsua_set_null_snd_dev, METH_VARARGS, |
| 5469 | pjsua_set_null_snd_dev_doc |
| 5470 | }, |
| 5471 | { |
| 5472 | "set_no_snd_dev", py_pjsua_set_no_snd_dev, METH_VARARGS, |
| 5473 | pjsua_set_no_snd_dev_doc |
| 5474 | }, |
| 5475 | { |
| 5476 | "set_ec", py_pjsua_set_ec, METH_VARARGS, |
| 5477 | pjsua_set_ec_doc |
| 5478 | }, |
| 5479 | { |
| 5480 | "get_ec_tail", py_pjsua_get_ec_tail, METH_VARARGS, |
| 5481 | pjsua_get_ec_tail_doc |
| 5482 | }, |
| 5483 | { |
| 5484 | "enum_codecs", py_pjsua_enum_codecs, METH_VARARGS, |
| 5485 | pjsua_enum_codecs_doc |
| 5486 | }, |
| 5487 | { |
| 5488 | "codec_set_priority", py_pjsua_codec_set_priority, METH_VARARGS, |
| 5489 | pjsua_codec_set_priority_doc |
| 5490 | }, |
| 5491 | { |
| 5492 | "codec_get_param", py_pjsua_codec_get_param, METH_VARARGS, |
| 5493 | pjsua_codec_get_param_doc |
| 5494 | }, |
| 5495 | { |
| 5496 | "codec_set_param", py_pjsua_codec_set_param, METH_VARARGS, |
| 5497 | pjsua_codec_set_param_doc |
| 5498 | }, |
| 5499 | { |
| 5500 | "call_get_max_count", py_pjsua_call_get_max_count, METH_VARARGS, |
| 5501 | pjsua_call_get_max_count_doc |
| 5502 | }, |
| 5503 | { |
| 5504 | "call_get_count", py_pjsua_call_get_count, METH_VARARGS, |
| 5505 | pjsua_call_get_count_doc |
| 5506 | }, |
| 5507 | { |
| 5508 | "enum_calls", py_pjsua_enum_calls, METH_VARARGS, |
| 5509 | pjsua_enum_calls_doc |
| 5510 | }, |
| 5511 | { |
| 5512 | "call_make_call", py_pjsua_call_make_call, METH_VARARGS, |
| 5513 | pjsua_call_make_call_doc |
| 5514 | }, |
| 5515 | { |
| 5516 | "call_is_active", py_pjsua_call_is_active, METH_VARARGS, |
| 5517 | pjsua_call_is_active_doc |
| 5518 | }, |
| 5519 | { |
| 5520 | "call_has_media", py_pjsua_call_has_media, METH_VARARGS, |
| 5521 | pjsua_call_has_media_doc |
| 5522 | }, |
| 5523 | { |
| 5524 | "call_get_conf_port", py_pjsua_call_get_conf_port, METH_VARARGS, |
| 5525 | pjsua_call_get_conf_port_doc |
| 5526 | }, |
| 5527 | { |
| 5528 | "call_get_info", py_pjsua_call_get_info, METH_VARARGS, |
| 5529 | pjsua_call_get_info_doc |
| 5530 | }, |
| 5531 | { |
| 5532 | "call_set_user_data", py_pjsua_call_set_user_data, METH_VARARGS, |
| 5533 | pjsua_call_set_user_data_doc |
| 5534 | }, |
| 5535 | { |
| 5536 | "call_get_user_data", py_pjsua_call_get_user_data, METH_VARARGS, |
| 5537 | pjsua_call_get_user_data_doc |
| 5538 | }, |
| 5539 | { |
| 5540 | "call_answer", py_pjsua_call_answer, METH_VARARGS, |
| 5541 | pjsua_call_answer_doc |
| 5542 | }, |
| 5543 | { |
| 5544 | "call_hangup", py_pjsua_call_hangup, METH_VARARGS, |
| 5545 | pjsua_call_hangup_doc |
| 5546 | }, |
| 5547 | { |
| 5548 | "call_set_hold", py_pjsua_call_set_hold, METH_VARARGS, |
| 5549 | pjsua_call_set_hold_doc |
| 5550 | }, |
| 5551 | { |
| 5552 | "call_reinvite", py_pjsua_call_reinvite, METH_VARARGS, |
| 5553 | pjsua_call_reinvite_doc |
| 5554 | }, |
| 5555 | { |
| 5556 | "call_xfer", py_pjsua_call_xfer, METH_VARARGS, |
| 5557 | pjsua_call_xfer_doc |
| 5558 | }, |
| 5559 | { |
| 5560 | "call_xfer_replaces", py_pjsua_call_xfer_replaces, METH_VARARGS, |
| 5561 | pjsua_call_xfer_replaces_doc |
| 5562 | }, |
| 5563 | { |
| 5564 | "call_dial_dtmf", py_pjsua_call_dial_dtmf, METH_VARARGS, |
| 5565 | pjsua_call_dial_dtmf_doc |
| 5566 | }, |
| 5567 | { |
| 5568 | "call_send_im", py_pjsua_call_send_im, METH_VARARGS, |
| 5569 | pjsua_call_send_im_doc |
| 5570 | }, |
| 5571 | { |
| 5572 | "call_send_typing_ind", py_pjsua_call_send_typing_ind, METH_VARARGS, |
| 5573 | pjsua_call_send_typing_ind_doc |
| 5574 | }, |
| 5575 | { |
| 5576 | "call_hangup_all", py_pjsua_call_hangup_all, METH_VARARGS, |
| 5577 | pjsua_call_hangup_all_doc |
| 5578 | }, |
| 5579 | { |
| 5580 | "call_dump", py_pjsua_call_dump, METH_VARARGS, |
| 5581 | pjsua_call_dump_doc |
| 5582 | }, |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 5583 | { |
| 5584 | "dump", py_pjsua_dump, METH_VARARGS, "Dump application state" |
| 5585 | }, |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5586 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5587 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5588 | {NULL, NULL} /* end of function list */ |
| 5589 | }; |
| 5590 | |
| 5591 | |
| 5592 | |
| 5593 | /* |
| 5594 | * Mapping C structs from and to Python objects & initializing object |
| 5595 | */ |
| 5596 | DL_EXPORT(void) |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 5597 | initpy_pjsua(void) |
| 5598 | { |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5599 | PyObject* m = NULL; |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5600 | #define ADD_CONSTANT(mod,name) PyModule_AddIntConstant(mod,#name,name) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5601 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5602 | |
Benny Prijono | da275f6 | 2007-02-18 23:49:14 +0000 | [diff] [blame] | 5603 | PyEval_InitThreads(); |
| 5604 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5605 | if (PyType_Ready(&PyTyp_pjsua_callback) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5606 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5607 | if (PyType_Ready(&PyTyp_pjsua_config) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5608 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5609 | if (PyType_Ready(&PyTyp_pjsua_logging_config) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5610 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5611 | if (PyType_Ready(&PyTyp_pjsua_msg_data) < 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 | PyTyp_pjsua_media_config.tp_new = PyType_GenericNew; |
| 5614 | if (PyType_Ready(&PyTyp_pjsua_media_config) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5615 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5616 | PyTyp_pjsip_event.tp_new = PyType_GenericNew; |
| 5617 | if (PyType_Ready(&PyTyp_pjsip_event) < 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_pjsip_rx_data.tp_new = PyType_GenericNew; |
| 5620 | if (PyType_Ready(&PyTyp_pjsip_rx_data) < 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_pj_pool_t.tp_new = PyType_GenericNew; |
| 5623 | if (PyType_Ready(&PyTyp_pj_pool_t) < 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_endpoint.tp_new = PyType_GenericNew; |
| 5626 | if (PyType_Ready(&PyTyp_pjsip_endpoint) < 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_pjmedia_endpt.tp_new = PyType_GenericNew; |
| 5629 | if (PyType_Ready(&PyTyp_pjmedia_endpt) < 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_pj_pool_factory.tp_new = PyType_GenericNew; |
| 5632 | if (PyType_Ready(&PyTyp_pj_pool_factory) < 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_pjsip_cred_info.tp_new = PyType_GenericNew; |
| 5635 | if (PyType_Ready(&PyTyp_pjsip_cred_info) < 0) |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5636 | return; |
| 5637 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5638 | /* LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5639 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5640 | if (PyType_Ready(&PyTyp_pjsua_transport_config) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5641 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5642 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5643 | if (PyType_Ready(&PyTyp_pjsua_transport_info) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5644 | return; |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5645 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5646 | /* END OF LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5647 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5648 | /* LIB ACCOUNT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5649 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5650 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5651 | if (PyType_Ready(&PyTyp_pjsua_acc_config) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5652 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5653 | if (PyType_Ready(&PyTyp_pjsua_acc_info) < 0) |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5654 | return; |
| 5655 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5656 | /* END OF LIB ACCOUNT */ |
| 5657 | |
| 5658 | /* LIB BUDDY */ |
| 5659 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5660 | if (PyType_Ready(&PyTyp_pjsua_buddy_config) < 0) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5661 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5662 | if (PyType_Ready(&PyTyp_pjsua_buddy_info) < 0) |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5663 | return; |
| 5664 | |
| 5665 | /* END OF LIB BUDDY */ |
| 5666 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5667 | /* LIB MEDIA */ |
| 5668 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5669 | if (PyType_Ready(&PyTyp_pjsua_codec_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5670 | return; |
| 5671 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5672 | if (PyType_Ready(&PyTyp_pjsua_conf_port_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5673 | return; |
| 5674 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5675 | PyTyp_pjmedia_port.tp_new = PyType_GenericNew; |
| 5676 | if (PyType_Ready(&PyTyp_pjmedia_port) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5677 | return; |
| 5678 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5679 | if (PyType_Ready(&PyTyp_pjmedia_snd_dev_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5680 | return; |
| 5681 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5682 | PyTyp_pjmedia_codec_param_info.tp_new = PyType_GenericNew; |
| 5683 | if (PyType_Ready(&PyTyp_pjmedia_codec_param_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5684 | return; |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5685 | PyTyp_pjmedia_codec_param_setting.tp_new = PyType_GenericNew; |
| 5686 | if (PyType_Ready(&PyTyp_pjmedia_codec_param_setting) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5687 | return; |
| 5688 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5689 | if (PyType_Ready(&PyTyp_pjmedia_codec_param) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5690 | return; |
| 5691 | |
| 5692 | /* END OF LIB MEDIA */ |
| 5693 | |
| 5694 | /* LIB CALL */ |
| 5695 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5696 | PyTyp_pj_time_val.tp_new = PyType_GenericNew; |
| 5697 | if (PyType_Ready(&PyTyp_pj_time_val) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5698 | return; |
| 5699 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5700 | if (PyType_Ready(&PyTyp_pjsua_call_info) < 0) |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5701 | return; |
| 5702 | |
| 5703 | /* END OF LIB CALL */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5704 | |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5705 | m = Py_InitModule3( |
| 5706 | "py_pjsua", py_pjsua_methods,"PJSUA-lib module for python" |
| 5707 | ); |
| 5708 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5709 | Py_INCREF(&PyTyp_pjsua_callback); |
| 5710 | PyModule_AddObject(m, "Callback", (PyObject *)&PyTyp_pjsua_callback); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5711 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5712 | Py_INCREF(&PyTyp_pjsua_config); |
| 5713 | PyModule_AddObject(m, "Config", (PyObject *)&PyTyp_pjsua_config); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5714 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5715 | Py_INCREF(&PyTyp_pjsua_media_config); |
| 5716 | PyModule_AddObject(m, "Media_Config", (PyObject *)&PyTyp_pjsua_media_config); |
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_logging_config); |
| 5719 | PyModule_AddObject(m, "Logging_Config", (PyObject *)&PyTyp_pjsua_logging_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_msg_data); |
| 5722 | PyModule_AddObject(m, "Msg_Data", (PyObject *)&PyTyp_pjsua_msg_data); |
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_pjsip_event); |
| 5725 | PyModule_AddObject(m, "Pjsip_Event", (PyObject *)&PyTyp_pjsip_event); |
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_pjsip_rx_data); |
| 5728 | PyModule_AddObject(m, "Pjsip_Rx_Data", (PyObject *)&PyTyp_pjsip_rx_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_pj_pool_t); |
| 5731 | PyModule_AddObject(m, "Pj_Pool", (PyObject *)&PyTyp_pj_pool_t); |
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_endpoint); |
| 5734 | PyModule_AddObject(m, "Pjsip_Endpoint", (PyObject *)&PyTyp_pjsip_endpoint); |
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_pjmedia_endpt); |
| 5737 | PyModule_AddObject(m, "Pjmedia_Endpt", (PyObject *)&PyTyp_pjmedia_endpt); |
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_pj_pool_factory); |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5740 | PyModule_AddObject( |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5741 | m, "Pj_Pool_Factory", (PyObject *)&PyTyp_pj_pool_factory |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5742 | ); |
| 5743 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5744 | Py_INCREF(&PyTyp_pjsip_cred_info); |
| 5745 | PyModule_AddObject(m, "Pjsip_Cred_Info", |
| 5746 | (PyObject *)&PyTyp_pjsip_cred_info |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5747 | ); |
| 5748 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5749 | /* LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5750 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5751 | Py_INCREF(&PyTyp_pjsua_transport_config); |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5752 | PyModule_AddObject |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5753 | (m, "Transport_Config", (PyObject *)&PyTyp_pjsua_transport_config); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5754 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5755 | Py_INCREF(&PyTyp_pjsua_transport_info); |
| 5756 | PyModule_AddObject(m, "Transport_Info", (PyObject *)&PyTyp_pjsua_transport_info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5757 | |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5758 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5759 | /* END OF LIB TRANSPORT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5760 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5761 | /* LIB ACCOUNT */ |
Benny Prijono | 9879359 | 2006-12-04 08:33:20 +0000 | [diff] [blame] | 5762 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5763 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5764 | Py_INCREF(&PyTyp_pjsua_acc_config); |
| 5765 | PyModule_AddObject(m, "Acc_Config", (PyObject *)&PyTyp_pjsua_acc_config); |
| 5766 | Py_INCREF(&PyTyp_pjsua_acc_info); |
| 5767 | PyModule_AddObject(m, "Acc_Info", (PyObject *)&PyTyp_pjsua_acc_info); |
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 | /* END OF LIB ACCOUNT */ |
| 5770 | |
| 5771 | /* LIB BUDDY */ |
| 5772 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5773 | Py_INCREF(&PyTyp_pjsua_buddy_config); |
| 5774 | PyModule_AddObject(m, "Buddy_Config", (PyObject *)&PyTyp_pjsua_buddy_config); |
| 5775 | Py_INCREF(&PyTyp_pjsua_buddy_info); |
| 5776 | PyModule_AddObject(m, "Buddy_Info", (PyObject *)&PyTyp_pjsua_buddy_info); |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5777 | |
| 5778 | /* END OF LIB BUDDY */ |
| 5779 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5780 | /* LIB MEDIA */ |
| 5781 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5782 | Py_INCREF(&PyTyp_pjsua_codec_info); |
| 5783 | PyModule_AddObject(m, "Codec_Info", (PyObject *)&PyTyp_pjsua_codec_info); |
| 5784 | Py_INCREF(&PyTyp_pjsua_conf_port_info); |
| 5785 | PyModule_AddObject(m, "Conf_Port_Info", (PyObject *)&PyTyp_pjsua_conf_port_info); |
| 5786 | Py_INCREF(&PyTyp_pjmedia_port); |
| 5787 | PyModule_AddObject(m, "PJMedia_Port", (PyObject *)&PyTyp_pjmedia_port); |
| 5788 | Py_INCREF(&PyTyp_pjmedia_snd_dev_info); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5789 | PyModule_AddObject(m, "PJMedia_Snd_Dev_Info", |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5790 | (PyObject *)&PyTyp_pjmedia_snd_dev_info); |
| 5791 | Py_INCREF(&PyTyp_pjmedia_codec_param_info); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5792 | PyModule_AddObject(m, "PJMedia_Codec_Param_Info", |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5793 | (PyObject *)&PyTyp_pjmedia_codec_param_info); |
| 5794 | Py_INCREF(&PyTyp_pjmedia_codec_param_setting); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5795 | PyModule_AddObject(m, "PJMedia_Codec_Param_Setting", |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5796 | (PyObject *)&PyTyp_pjmedia_codec_param_setting); |
| 5797 | Py_INCREF(&PyTyp_pjmedia_codec_param); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5798 | PyModule_AddObject(m, "PJMedia_Codec_Param", |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5799 | (PyObject *)&PyTyp_pjmedia_codec_param); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5800 | |
| 5801 | /* END OF LIB MEDIA */ |
| 5802 | |
| 5803 | /* LIB CALL */ |
| 5804 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5805 | Py_INCREF(&PyTyp_pj_time_val); |
| 5806 | PyModule_AddObject(m, "PJ_Time_Val", (PyObject *)&PyTyp_pj_time_val); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5807 | |
Benny Prijono | 1f63cc4 | 2007-09-10 16:54:22 +0000 | [diff] [blame] | 5808 | Py_INCREF(&PyTyp_pjsua_call_info); |
| 5809 | PyModule_AddObject(m, "Call_Info", (PyObject *)&PyTyp_pjsua_call_info); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5810 | |
| 5811 | /* END OF LIB CALL */ |
Benny Prijono | 572d485 | 2006-11-23 21:50:02 +0000 | [diff] [blame] | 5812 | |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5813 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5814 | /* |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5815 | * Add various constants. |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5816 | */ |
Benny Prijono | dc30870 | 2006-12-09 00:39:42 +0000 | [diff] [blame] | 5817 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5818 | /* Call states */ |
| 5819 | ADD_CONSTANT(m, PJSIP_INV_STATE_NULL); |
| 5820 | ADD_CONSTANT(m, PJSIP_INV_STATE_CALLING); |
| 5821 | ADD_CONSTANT(m, PJSIP_INV_STATE_INCOMING); |
| 5822 | ADD_CONSTANT(m, PJSIP_INV_STATE_EARLY); |
| 5823 | ADD_CONSTANT(m, PJSIP_INV_STATE_CONNECTING); |
| 5824 | ADD_CONSTANT(m, PJSIP_INV_STATE_CONFIRMED); |
| 5825 | ADD_CONSTANT(m, PJSIP_INV_STATE_DISCONNECTED); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5826 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5827 | /* Call media status (enum pjsua_call_media_status) */ |
| 5828 | ADD_CONSTANT(m, PJSUA_CALL_MEDIA_NONE); |
| 5829 | ADD_CONSTANT(m, PJSUA_CALL_MEDIA_ACTIVE); |
| 5830 | ADD_CONSTANT(m, PJSUA_CALL_MEDIA_LOCAL_HOLD); |
| 5831 | ADD_CONSTANT(m, PJSUA_CALL_MEDIA_REMOTE_HOLD); |
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 | /* Buddy status */ |
| 5834 | ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_UNKNOWN); |
| 5835 | ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_ONLINE); |
| 5836 | ADD_CONSTANT(m, PJSUA_BUDDY_STATUS_OFFLINE); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5837 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5838 | /* PJSIP transport types (enum pjsip_transport_type_e) */ |
| 5839 | ADD_CONSTANT(m, PJSIP_TRANSPORT_UNSPECIFIED); |
| 5840 | ADD_CONSTANT(m, PJSIP_TRANSPORT_UDP); |
| 5841 | ADD_CONSTANT(m, PJSIP_TRANSPORT_TCP); |
| 5842 | ADD_CONSTANT(m, PJSIP_TRANSPORT_TLS); |
| 5843 | ADD_CONSTANT(m, PJSIP_TRANSPORT_SCTP); |
| 5844 | ADD_CONSTANT(m, PJSIP_TRANSPORT_LOOP); |
| 5845 | ADD_CONSTANT(m, PJSIP_TRANSPORT_LOOP_DGRAM); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5846 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5847 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5848 | /* Invalid IDs */ |
| 5849 | ADD_CONSTANT(m, PJSUA_INVALID_ID); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5850 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5851 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5852 | /* Various compile time constants */ |
| 5853 | ADD_CONSTANT(m, PJSUA_ACC_MAX_PROXIES); |
| 5854 | ADD_CONSTANT(m, PJSUA_MAX_ACC); |
| 5855 | ADD_CONSTANT(m, PJSUA_REG_INTERVAL); |
| 5856 | ADD_CONSTANT(m, PJSUA_PUBLISH_EXPIRATION); |
| 5857 | ADD_CONSTANT(m, PJSUA_DEFAULT_ACC_PRIORITY); |
| 5858 | ADD_CONSTANT(m, PJSUA_MAX_BUDDIES); |
| 5859 | ADD_CONSTANT(m, PJSUA_MAX_CONF_PORTS); |
| 5860 | ADD_CONSTANT(m, PJSUA_DEFAULT_CLOCK_RATE); |
| 5861 | ADD_CONSTANT(m, PJSUA_DEFAULT_CODEC_QUALITY); |
| 5862 | ADD_CONSTANT(m, PJSUA_DEFAULT_ILBC_MODE); |
| 5863 | ADD_CONSTANT(m, PJSUA_DEFAULT_EC_TAIL_LEN); |
| 5864 | ADD_CONSTANT(m, PJSUA_MAX_CALLS); |
| 5865 | ADD_CONSTANT(m, PJSUA_XFER_NO_REQUIRE_REPLACES); |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5866 | |
Fahris | dcf8fa4 | 2006-12-28 03:13:48 +0000 | [diff] [blame] | 5867 | |
Benny Prijono | aa28604 | 2007-02-03 17:23:22 +0000 | [diff] [blame] | 5868 | #undef ADD_CONSTANT |
Benny Prijono | 8b8b997 | 2006-11-16 11:18:03 +0000 | [diff] [blame] | 5869 | } |