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