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