1
/* $Id: py_pjsua.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __PY_PJSUA_H__
21
#define __PY_PJSUA_H__
23
#define _CRT_SECURE_NO_DEPRECATE
26
#include <structmember.h>
27
#include <pjsua-lib/pjsua.h>
30
PJ_INLINE(pj_str_t) PyString_to_pj_str(const PyObject *obj)
35
str.ptr = PyString_AS_STRING(obj);
36
str.slen = PyString_GET_SIZE(obj);
46
//////////////////////////////////////////////////////////////////////////////
53
/* Type-specific fields go here. */
61
static PyTypeObject PyTyp_pj_pool_t =
63
PyObject_HEAD_INIT(NULL)
65
"py_pjsua.Pj_Pool", /*tp_name*/
66
sizeof(PyObj_pj_pool), /*tp_basicsize*/
83
Py_TPFLAGS_DEFAULT, /*tp_flags*/
84
"pj_pool_t objects", /* tp_doc */
89
//////////////////////////////////////////////////////////////////////////////
91
* PyObj_pjsip_endpoint
96
/* Type-specific fields go here. */
97
pjsip_endpoint * endpt;
98
} PyObj_pjsip_endpoint;
102
* PyTyp_pjsip_endpoint
104
static PyTypeObject PyTyp_pjsip_endpoint =
106
PyObject_HEAD_INIT(NULL)
108
"py_pjsua.Pjsip_Endpoint", /*tp_name*/
109
sizeof(PyObj_pjsip_endpoint),/*tp_basicsize*/
118
0, /*tp_as_sequence*/
126
Py_TPFLAGS_DEFAULT, /*tp_flags*/
127
"pjsip_endpoint objects", /* tp_doc */
132
* PyObj_pjmedia_endpt
137
/* Type-specific fields go here. */
138
pjmedia_endpt * endpt;
139
} PyObj_pjmedia_endpt;
142
//////////////////////////////////////////////////////////////////////////////
144
* PyTyp_pjmedia_endpt
146
static PyTypeObject PyTyp_pjmedia_endpt =
148
PyObject_HEAD_INIT(NULL)
150
"py_pjsua.Pjmedia_Endpt", /*tp_name*/
151
sizeof(PyObj_pjmedia_endpt), /*tp_basicsize*/
160
0, /*tp_as_sequence*/
168
Py_TPFLAGS_DEFAULT, /*tp_flags*/
169
"pjmedia_endpt objects", /* tp_doc */
174
//////////////////////////////////////////////////////////////////////////////
176
* PyObj_pj_pool_factory
181
/* Type-specific fields go here. */
182
pj_pool_factory * pool_fact;
183
} PyObj_pj_pool_factory;
188
* PyTyp_pj_pool_factory
190
static PyTypeObject PyTyp_pj_pool_factory =
192
PyObject_HEAD_INIT(NULL)
194
"py_pjsua.Pj_Pool_Factory",/*tp_name*/
195
sizeof(PyObj_pj_pool_factory), /*tp_basicsize*/
204
0, /*tp_as_sequence*/
212
Py_TPFLAGS_DEFAULT, /*tp_flags*/
213
"pj_pool_factory objects", /* tp_doc */
218
//////////////////////////////////////////////////////////////////////////////
220
* PyObj_pjsip_cred_info
226
/* Type-specific fields go here. */
233
} PyObj_pjsip_cred_info;
237
* deletes a cred info from memory
239
static void PyObj_pjsip_cred_info_delete(PyObj_pjsip_cred_info* self)
241
Py_XDECREF(self->realm);
242
Py_XDECREF(self->scheme);
243
Py_XDECREF(self->username);
244
Py_XDECREF(self->data);
245
self->ob_type->tp_free((PyObject*)self);
249
static void PyObj_pjsip_cred_info_import(PyObj_pjsip_cred_info *obj,
250
const pjsip_cred_info *cfg)
252
Py_XDECREF(obj->realm);
253
obj->realm = PyString_FromStringAndSize(cfg->realm.ptr, cfg->realm.slen);
254
Py_XDECREF(obj->scheme);
255
obj->scheme = PyString_FromStringAndSize(cfg->scheme.ptr, cfg->scheme.slen);
256
Py_XDECREF(obj->username);
257
obj->username = PyString_FromStringAndSize(cfg->username.ptr, cfg->username.slen);
258
obj->data_type = cfg->data_type;
259
Py_XDECREF(obj->data);
260
obj->data = PyString_FromStringAndSize(cfg->data.ptr, cfg->data.slen);
263
static void PyObj_pjsip_cred_info_export(pjsip_cred_info *cfg,
264
PyObj_pjsip_cred_info *obj)
266
cfg->realm = PyString_to_pj_str(obj->realm);
267
cfg->scheme = PyString_to_pj_str(obj->scheme);
268
cfg->username = PyString_to_pj_str(obj->username);
269
cfg->data_type = obj->data_type;
270
cfg->data = PyString_to_pj_str(obj->data);
276
* constructor for cred_info object
278
static PyObject * PyObj_pjsip_cred_info_new(PyTypeObject *type,
282
PyObj_pjsip_cred_info *self;
287
self = (PyObj_pjsip_cred_info *)type->tp_alloc(type, 0);
290
self->realm = PyString_FromString("");
291
if (self->realm == NULL)
296
self->scheme = PyString_FromString("");
297
if (self->scheme == NULL)
302
self->username = PyString_FromString("");
303
if (self->username == NULL)
308
self->data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
309
self->data = PyString_FromString("");
310
if (self->data == NULL)
317
return (PyObject *)self;
322
* PyObj_pjsip_cred_info_members
324
static PyMemberDef PyObj_pjsip_cred_info_members[] =
327
"realm", T_OBJECT_EX,
328
offsetof(PyObj_pjsip_cred_info, realm), 0,
332
"scheme", T_OBJECT_EX,
333
offsetof(PyObj_pjsip_cred_info, scheme), 0,
337
"username", T_OBJECT_EX,
338
offsetof(PyObj_pjsip_cred_info, username), 0,
343
offsetof(PyObj_pjsip_cred_info, data), 0,
344
"The data, which can be a plaintext password or a hashed digest, "
345
"depending on the value of data_type"
349
offsetof(PyObj_pjsip_cred_info, data_type), 0,
353
{NULL} /* Sentinel */
357
* PyTyp_pjsip_cred_info
359
static PyTypeObject PyTyp_pjsip_cred_info =
361
PyObject_HEAD_INIT(NULL)
363
"py_pjsua.Pjsip_Cred_Info", /*tp_name*/
364
sizeof(PyObj_pjsip_cred_info), /*tp_basicsize*/
366
(destructor)PyObj_pjsip_cred_info_delete,/*tp_dealloc*/
373
0, /*tp_as_sequence*/
381
Py_TPFLAGS_DEFAULT, /*tp_flags*/
382
"PJSIP credential information", /* tp_doc */
385
0, /* tp_richcompare */
386
0, /* tp_weaklistoffset */
390
PyObj_pjsip_cred_info_members, /* tp_members */
394
0, /* tp_descr_get */
395
0, /* tp_descr_set */
396
0, /* tp_dictoffset */
399
PyObj_pjsip_cred_info_new, /* tp_new */
404
//////////////////////////////////////////////////////////////////////////////
407
* C/python typewrapper for event struct
412
/* Type-specific fields go here. */
420
* event struct signatures
422
static PyTypeObject PyTyp_pjsip_event =
424
PyObject_HEAD_INIT(NULL)
426
"py_pjsua.Pjsip_Event", /*tp_name*/
427
sizeof(PyObj_pjsip_event), /*tp_basicsize*/
436
0, /*tp_as_sequence*/
444
Py_TPFLAGS_DEFAULT, /*tp_flags*/
445
"pjsip_event object", /*tp_doc */
449
//////////////////////////////////////////////////////////////////////////////
451
* PyObj_pjsip_rx_data
452
* C/python typewrapper for pjsip_rx_data struct
457
/* Type-specific fields go here. */
458
pjsip_rx_data * rdata;
459
} PyObj_pjsip_rx_data;
463
* PyTyp_pjsip_rx_data
465
static PyTypeObject PyTyp_pjsip_rx_data =
467
PyObject_HEAD_INIT(NULL)
469
"py_pjsua.Pjsip_Rx_Data", /*tp_name*/
470
sizeof(PyObj_pjsip_rx_data), /*tp_basicsize*/
479
0, /*tp_as_sequence*/
487
Py_TPFLAGS_DEFAULT, /*tp_flags*/
488
"pjsip_rx_data object", /*tp_doc*/
493
//////////////////////////////////////////////////////////////////////////////
495
* PyObj_pjsua_callback
496
* C/python typewrapper for callback struct
498
typedef struct PyObj_pjsua_callback
501
/* Type-specific fields go here. */
502
PyObject * on_call_state;
503
PyObject * on_incoming_call;
504
PyObject * on_call_media_state;
505
PyObject * on_dtmf_digit;
506
PyObject * on_call_transfer_request;
507
PyObject * on_call_transfer_status;
508
PyObject * on_call_replace_request;
509
PyObject * on_call_replaced;
510
PyObject * on_reg_state;
511
PyObject * on_buddy_state;
513
PyObject * on_pager_status;
514
PyObject * on_typing;
515
} PyObj_pjsua_callback;
519
* PyObj_pjsua_callback_delete
520
* destructor function for callback struct
522
static void PyObj_pjsua_callback_delete(PyObj_pjsua_callback* self)
524
Py_XDECREF(self->on_call_state);
525
Py_XDECREF(self->on_incoming_call);
526
Py_XDECREF(self->on_call_media_state);
527
Py_XDECREF(self->on_dtmf_digit);
528
Py_XDECREF(self->on_call_transfer_request);
529
Py_XDECREF(self->on_call_transfer_status);
530
Py_XDECREF(self->on_call_replace_request);
531
Py_XDECREF(self->on_call_replaced);
532
Py_XDECREF(self->on_reg_state);
533
Py_XDECREF(self->on_buddy_state);
534
Py_XDECREF(self->on_pager);
535
Py_XDECREF(self->on_pager_status);
536
Py_XDECREF(self->on_typing);
537
self->ob_type->tp_free((PyObject*)self);
542
* PyObj_pjsua_callback_new
543
* * declares constructor for callback struct
545
static PyObject * PyObj_pjsua_callback_new(PyTypeObject *type,
549
PyObj_pjsua_callback *self;
554
self = (PyObj_pjsua_callback *)type->tp_alloc(type, 0);
558
self->on_call_state = Py_None;
559
if (self->on_call_state == NULL)
565
self->on_incoming_call = Py_None;
566
if (self->on_incoming_call == NULL)
572
self->on_call_media_state = Py_None;
573
if (self->on_call_media_state == NULL)
579
self->on_dtmf_digit = Py_None;
580
if (self->on_dtmf_digit == NULL)
586
self->on_call_transfer_request = Py_None;
587
if (self->on_call_transfer_request == NULL)
593
self->on_call_transfer_status = Py_None;
594
if (self->on_call_transfer_status == NULL)
600
self->on_call_replace_request = Py_None;
601
if (self->on_call_replace_request == NULL)
607
self->on_call_replaced = Py_None;
608
if (self->on_call_replaced == NULL)
614
self->on_reg_state = Py_None;
615
if (self->on_reg_state == NULL)
621
self->on_buddy_state = Py_None;
622
if (self->on_buddy_state == NULL)
628
self->on_pager = Py_None;
629
if (self->on_pager == NULL)
635
self->on_pager_status = Py_None;
636
if (self->on_pager_status == NULL)
642
self->on_typing = Py_None;
643
if (self->on_typing == NULL)
650
return (PyObject *)self;
655
* PyObj_pjsua_callback_members
656
* declares available functions for callback object
658
static PyMemberDef PyObj_pjsua_callback_members[] =
661
"on_call_state", T_OBJECT_EX,
662
offsetof(PyObj_pjsua_callback, on_call_state), 0,
663
"Notify application when invite state has changed. Application may "
664
"then query the call info to get the detail call states."
667
"on_incoming_call", T_OBJECT_EX,
668
offsetof(PyObj_pjsua_callback, on_incoming_call), 0,
669
"Notify application on incoming call."
672
"on_call_media_state", T_OBJECT_EX,
673
offsetof(PyObj_pjsua_callback, on_call_media_state), 0,
674
"Notify application when media state in the call has changed. Normal "
675
"application would need to implement this callback, e.g. to connect "
676
"the call's media to sound device."
679
"on_dtmf_digit", T_OBJECT_EX,
680
offsetof(PyObj_pjsua_callback, on_dtmf_digit), 0,
681
"Notify application upon receiving incoming DTMF digit."
684
"on_call_transfer_request", T_OBJECT_EX,
685
offsetof(PyObj_pjsua_callback, on_call_transfer_request), 0,
686
"Notify application on call being transfered. "
687
"Application can decide to accept/reject transfer request "
688
"by setting the code (default is 200). When this callback "
689
"is not defined, the default behavior is to accept the "
693
"on_call_transfer_status", T_OBJECT_EX,
694
offsetof(PyObj_pjsua_callback, on_call_transfer_status), 0,
695
"Notify application of the status of previously sent call "
696
"transfer request. Application can monitor the status of the "
697
"call transfer request, for example to decide whether to "
698
"terminate existing call."
701
"on_call_replace_request", T_OBJECT_EX,
702
offsetof(PyObj_pjsua_callback, on_call_replace_request), 0,
703
"Notify application about incoming INVITE with Replaces header. "
704
"Application may reject the request by setting non-2xx code."
707
"on_call_replaced", T_OBJECT_EX,
708
offsetof(PyObj_pjsua_callback, on_call_replaced), 0,
709
"Notify application that an existing call has been replaced with "
710
"a new call. This happens when PJSUA-API receives incoming INVITE "
711
"request with Replaces header."
713
"After this callback is called, normally PJSUA-API will disconnect "
714
"old_call_id and establish new_call_id."
717
"on_reg_state", T_OBJECT_EX,
718
offsetof(PyObj_pjsua_callback, on_reg_state), 0,
719
"Notify application when registration status has changed. Application "
720
"may then query the account info to get the registration details."
723
"on_buddy_state", T_OBJECT_EX,
724
offsetof(PyObj_pjsua_callback, on_buddy_state), 0,
725
"Notify application when the buddy state has changed. Application may "
726
"then query the buddy into to get the details."
729
"on_pager", T_OBJECT_EX,
730
offsetof(PyObj_pjsua_callback, on_pager), 0,
731
"Notify application on incoming pager (i.e. MESSAGE request). "
732
"Argument call_id will be -1 if MESSAGE request is not related to an "
736
"on_pager_status", T_OBJECT_EX,
737
offsetof(PyObj_pjsua_callback, on_pager_status), 0,
738
"Notify application about the delivery status of outgoing pager "
742
"on_typing", T_OBJECT_EX,
743
offsetof(PyObj_pjsua_callback, on_typing), 0,
744
"Notify application about typing indication."
746
{NULL} /* Sentinel */
751
* PyTyp_pjsua_callback
752
* callback class definition
754
static PyTypeObject PyTyp_pjsua_callback =
756
PyObject_HEAD_INIT(NULL)
758
"py_pjsua.Callback", /*tp_name*/
759
sizeof(PyObj_pjsua_callback), /*tp_basicsize*/
761
(destructor)PyObj_pjsua_callback_delete, /*tp_dealloc*/
768
0, /*tp_as_sequence*/
776
Py_TPFLAGS_DEFAULT, /*tp_flags*/
777
"This structure describes application callback "
778
"to receive various event notifications from "
779
"PJSUA-API", /* tp_doc */
782
0, /* tp_richcompare */
783
0, /* tp_weaklistoffset */
787
PyObj_pjsua_callback_members, /* tp_members */
791
0, /* tp_descr_get */
792
0, /* tp_descr_set */
793
0, /* tp_dictoffset */
796
PyObj_pjsua_callback_new, /* tp_new */
801
//////////////////////////////////////////////////////////////////////////////
803
* PyObj_pjsua_media_config
804
* C/Python wrapper for pjsua_media_config object
809
/* Type-specific fields go here. */
811
unsigned max_media_ports;
818
unsigned tx_drop_pct;
819
unsigned rx_drop_pct;
821
unsigned ec_tail_len;
822
} PyObj_pjsua_media_config;
826
* PyObj_pjsua_media_config_members
827
* declares attributes accessible from both C and Python for media_config file
829
static PyMemberDef PyObj_pjsua_media_config_members[] =
833
offsetof(PyObj_pjsua_media_config, clock_rate), 0,
834
"Clock rate to be applied to the conference bridge. If value is zero, "
835
"default clock rate will be used (16KHz)."
838
"max_media_ports", T_INT,
839
offsetof(PyObj_pjsua_media_config, max_media_ports), 0,
840
"Specify maximum number of media ports to be created in the "
841
"conference bridge. Since all media terminate in the bridge (calls, "
842
"file player, file recorder, etc), the value must be large enough to "
843
"support all of them. However, the larger the value, the more "
844
"computations are performed."
847
"has_ioqueue", T_INT,
848
offsetof(PyObj_pjsua_media_config, has_ioqueue), 0,
849
"Specify whether the media manager should manage its own ioqueue for "
850
"the RTP/RTCP sockets. If yes, ioqueue will be created and at least "
851
"one worker thread will be created too. If no, the RTP/RTCP sockets "
852
"will share the same ioqueue as SIP sockets, and no worker thread is "
857
offsetof(PyObj_pjsua_media_config, thread_cnt), 0,
858
"Specify the number of worker threads to handle incoming RTP packets. "
859
"A value of one is recommended for most applications."
863
offsetof(PyObj_pjsua_media_config, quality), 0,
864
"The media quality also sets speex codec quality/complexity to the "
869
offsetof(PyObj_pjsua_media_config, ptime), 0,
870
"Specify default ptime."
874
offsetof(PyObj_pjsua_media_config, no_vad), 0,
879
offsetof(PyObj_pjsua_media_config, ilbc_mode), 0,
880
"iLBC mode (20 or 30)."
883
"tx_drop_pct", T_INT,
884
offsetof(PyObj_pjsua_media_config, tx_drop_pct), 0,
885
"Percentage of RTP packet to drop in TX direction (to simulate packet "
889
"rx_drop_pct", T_INT,
890
offsetof(PyObj_pjsua_media_config, rx_drop_pct), 0,
891
"Percentage of RTP packet to drop in RX direction (to simulate packet "
895
offsetof(PyObj_pjsua_media_config, ec_options), 0,
896
"Echo canceller options (see pjmedia_echo_create())"
899
"ec_tail_len", T_INT,
900
offsetof(PyObj_pjsua_media_config, ec_tail_len), 0,
901
"Echo canceller tail length, in miliseconds."
903
{NULL} /* Sentinel */
908
* PyTyp_pjsua_media_config
910
static PyTypeObject PyTyp_pjsua_media_config =
912
PyObject_HEAD_INIT(NULL)
914
"py_pjsua.Media_Config", /*tp_name*/
915
sizeof(PyObj_pjsua_media_config),/*tp_basicsize*/
924
0, /*tp_as_sequence*/
932
Py_TPFLAGS_DEFAULT, /*tp_flags*/
933
"Media Config objects", /*tp_doc*/
936
0, /*tp_richcompare*/
937
0, /* tp_weaklistoffset */
941
PyObj_pjsua_media_config_members, /* tp_members */
946
static void PyObj_pjsua_media_config_import(PyObj_pjsua_media_config *obj,
947
const pjsua_media_config *cfg)
949
obj->clock_rate = cfg->clock_rate;
950
obj->max_media_ports = cfg->max_media_ports;
951
obj->has_ioqueue = cfg->has_ioqueue;
952
obj->thread_cnt = cfg->thread_cnt;
953
obj->quality = cfg->quality;
954
obj->ptime = cfg->ptime;
955
obj->no_vad = cfg->no_vad;
956
obj->ilbc_mode = cfg->ilbc_mode;
957
obj->tx_drop_pct = cfg->tx_drop_pct;
958
obj->rx_drop_pct = cfg->rx_drop_pct;
959
obj->ec_options = cfg->ec_options;
960
obj->ec_tail_len = cfg->ec_tail_len;
963
static void PyObj_pjsua_media_config_export(pjsua_media_config *cfg,
964
const PyObj_pjsua_media_config *obj)
966
cfg->clock_rate = obj->clock_rate;
967
cfg->max_media_ports = obj->max_media_ports;
968
cfg->has_ioqueue = obj->has_ioqueue;
969
cfg->thread_cnt = obj->thread_cnt;
970
cfg->quality = obj->quality;
971
cfg->ptime = obj->ptime;
972
cfg->no_vad = obj->no_vad;
973
cfg->ilbc_mode = obj->ilbc_mode;
974
cfg->tx_drop_pct = obj->tx_drop_pct;
975
cfg->rx_drop_pct = obj->rx_drop_pct;
976
cfg->ec_options = obj->ec_options;
977
cfg->ec_tail_len = obj->ec_tail_len;
980
//////////////////////////////////////////////////////////////////////////////
983
* attribute list for config object
988
/* Type-specific fields go here. */
991
PyObject *outbound_proxy;
992
PyObject *stun_domain;
994
PyObject *stun_relay_host;
995
PyObj_pjsua_callback *cb;
996
PyObject *user_agent;
997
} PyObj_pjsua_config;
1000
static void PyObj_pjsua_config_delete(PyObj_pjsua_config* self)
1002
Py_XDECREF(self->outbound_proxy);
1003
Py_XDECREF(self->stun_domain);
1004
Py_XDECREF(self->stun_host);
1005
Py_XDECREF(self->stun_relay_host);
1006
Py_XDECREF(self->cb);
1007
Py_XDECREF(self->user_agent);
1008
self->ob_type->tp_free((PyObject*)self);
1012
static void PyObj_pjsua_config_import(PyObj_pjsua_config *obj,
1013
const pjsua_config *cfg)
1015
obj->max_calls = cfg->max_calls;
1016
obj->thread_cnt = cfg->thread_cnt;
1017
Py_XDECREF(obj->outbound_proxy);
1018
obj->outbound_proxy = PyString_FromStringAndSize(cfg->outbound_proxy[0].ptr,
1019
cfg->outbound_proxy[0].slen);
1020
Py_XDECREF(obj->stun_domain);
1021
obj->stun_domain = PyString_FromStringAndSize(cfg->stun_domain.ptr,
1022
cfg->stun_domain.slen);
1023
Py_XDECREF(obj->stun_host);
1024
obj->stun_host = PyString_FromStringAndSize(cfg->stun_host.ptr,
1025
cfg->stun_host.slen);
1026
Py_XDECREF(obj->stun_relay_host);
1027
obj->stun_relay_host= PyString_FromStringAndSize(cfg->stun_host.ptr,
1028
cfg->stun_host.slen);
1029
Py_XDECREF(obj->user_agent);
1030
obj->user_agent = PyString_FromStringAndSize(cfg->user_agent.ptr,
1031
cfg->user_agent.slen);
1035
static void PyObj_pjsua_config_export(pjsua_config *cfg,
1036
PyObj_pjsua_config *obj)
1038
cfg->max_calls = obj->max_calls;
1039
cfg->thread_cnt = obj->thread_cnt;
1040
if (PyString_Size(obj->outbound_proxy) > 0) {
1041
cfg->outbound_proxy_cnt = 1;
1042
cfg->outbound_proxy[0] = PyString_to_pj_str(obj->outbound_proxy);
1044
cfg->outbound_proxy_cnt = 0;
1046
cfg->stun_domain = PyString_to_pj_str(obj->stun_domain);
1047
cfg->stun_host = PyString_to_pj_str(obj->stun_host);
1048
//cfg->stun_relay_host= PyString_to_pj_str(obj->stun_host);
1049
cfg->user_agent = PyString_to_pj_str(obj->user_agent);
1054
static PyObject *PyObj_pjsua_config_new(PyTypeObject *type,
1058
PyObj_pjsua_config *self;
1060
PJ_UNUSED_ARG(args);
1061
PJ_UNUSED_ARG(kwds);
1063
self = (PyObj_pjsua_config *)type->tp_alloc(type, 0);
1066
self->user_agent = PyString_FromString("");
1067
if (self->user_agent == NULL)
1072
self->outbound_proxy = PyString_FromString("");
1073
if (self->outbound_proxy == NULL)
1078
self->cb = (PyObj_pjsua_callback *)
1079
PyType_GenericNew(&PyTyp_pjsua_callback, NULL, NULL);
1080
if (self->cb == NULL)
1086
return (PyObject *)self;
1091
* PyObj_pjsua_config_members
1092
* attribute list accessible from Python/C
1094
static PyMemberDef PyObj_pjsua_config_members[] =
1098
offsetof(PyObj_pjsua_config, max_calls), 0,
1099
"Maximum calls to support (default: 4) "
1102
"thread_cnt", T_INT,
1103
offsetof(PyObj_pjsua_config, thread_cnt), 0,
1104
"Number of worker threads. Normally application will want to have at "
1105
"least one worker thread, unless when it wants to poll the library "
1106
"periodically, which in this case the worker thread can be set to "
1110
"outbound_proxy", T_OBJECT_EX,
1111
offsetof(PyObj_pjsua_config, outbound_proxy), 0,
1112
"SIP URL of the outbound proxy (optional)"
1115
"stun_domain", T_OBJECT_EX,
1116
offsetof(PyObj_pjsua_config, stun_domain), 0,
1117
"Domain of the STUN server (optional). STUN server will be resolved "
1118
"using DNS SRV resolution only when nameserver is configured. "
1119
"Alternatively, if DNS SRV resolution for STUN is not desired, "
1120
"application can specify the STUN server hostname or IP address "
1121
"in stun_host attribute."
1124
"stun_host", T_OBJECT_EX,
1125
offsetof(PyObj_pjsua_config, stun_host), 0,
1126
"Hostname or IP address of the STUN server (optional)."
1129
"stun_relay_host", T_OBJECT_EX,
1130
offsetof(PyObj_pjsua_config, stun_relay_host), 0,
1131
"Hostname or IP address of the TURN server (optional)."
1134
"cb", T_OBJECT_EX, offsetof(PyObj_pjsua_config, cb), 0,
1135
"Application callback."
1138
"user_agent", T_OBJECT_EX, offsetof(PyObj_pjsua_config, user_agent), 0,
1139
"User agent string (default empty)"
1141
{NULL} /* Sentinel */
1146
* PyTyp_pjsua_config
1147
* type wrapper for config class
1149
static PyTypeObject PyTyp_pjsua_config =
1151
PyObject_HEAD_INIT(NULL)
1153
"py_pjsua.Config", /*tp_name*/
1154
sizeof(PyObj_pjsua_config),/*tp_basicsize*/
1156
(destructor)PyObj_pjsua_config_delete,/*tp_dealloc*/
1163
0, /*tp_as_sequence*/
1164
0, /*tp_as_mapping*/
1171
Py_TPFLAGS_DEFAULT, /*tp_flags*/
1172
"Config object", /* tp_doc */
1173
0, /* tp_traverse */
1175
0, /* tp_richcompare */
1176
0, /* tp_weaklistoffset */
1178
0, /* tp_iternext */
1180
PyObj_pjsua_config_members,/* tp_members */
1184
0, /* tp_descr_get */
1185
0, /* tp_descr_set */
1186
0, /* tp_dictoffset */
1189
PyObj_pjsua_config_new, /* tp_new */
1193
//////////////////////////////////////////////////////////////////////////////
1195
* PyObj_pjsua_logging_config
1196
* configuration class for logging_config object
1201
/* Type-specific fields go here. */
1204
unsigned console_level;
1206
PyObject *log_filename;
1208
} PyObj_pjsua_logging_config;
1212
* PyObj_pjsua_logging_config_delete
1213
* deletes a logging config from memory
1215
static void PyObj_pjsua_logging_config_delete(PyObj_pjsua_logging_config* self)
1217
Py_XDECREF(self->log_filename);
1218
Py_XDECREF(self->cb);
1219
self->ob_type->tp_free((PyObject*)self);
1223
static void PyObj_pjsua_logging_config_import(PyObj_pjsua_logging_config *obj,
1224
const pjsua_logging_config *cfg)
1226
obj->msg_logging = cfg->msg_logging;
1227
obj->level = cfg->level;
1228
obj->console_level = cfg->console_level;
1229
obj->decor = cfg->decor;
1232
static void PyObj_pjsua_logging_config_export(pjsua_logging_config *cfg,
1233
PyObj_pjsua_logging_config *obj)
1235
cfg->msg_logging = obj->msg_logging;
1236
cfg->level = obj->level;
1237
cfg->console_level = obj->console_level;
1238
cfg->decor = obj->decor;
1239
cfg->log_filename = PyString_to_pj_str(obj->log_filename);
1244
* PyObj_pjsua_logging_config_new
1245
* constructor for logging_config object
1247
static PyObject * PyObj_pjsua_logging_config_new(PyTypeObject *type,
1251
PyObj_pjsua_logging_config *self;
1253
PJ_UNUSED_ARG(args);
1254
PJ_UNUSED_ARG(kwds);
1256
self = (PyObj_pjsua_logging_config *)type->tp_alloc(type, 0);
1259
self->log_filename = PyString_FromString("");
1260
if (self->log_filename == NULL)
1267
if (self->cb == NULL)
1274
return (PyObject *)self;
1279
* PyObj_pjsua_logging_config_members
1281
static PyMemberDef PyObj_pjsua_logging_config_members[] =
1284
"msg_logging", T_INT,
1285
offsetof(PyObj_pjsua_logging_config, msg_logging), 0,
1286
"Log incoming and outgoing SIP message? Yes!"
1290
offsetof(PyObj_pjsua_logging_config, level), 0,
1291
"Input verbosity level. Value 5 is reasonable."
1294
"console_level", T_INT,
1295
offsetof(PyObj_pjsua_logging_config, console_level),
1296
0, "Verbosity level for console. Value 4 is reasonable."
1300
offsetof(PyObj_pjsua_logging_config, decor), 0,
1304
"log_filename", T_OBJECT_EX,
1305
offsetof(PyObj_pjsua_logging_config, log_filename), 0,
1306
"Optional log filename"
1310
offsetof(PyObj_pjsua_logging_config, cb), 0,
1311
"Optional callback function to be called to write log to application "
1312
"specific device. This function will be called forlog messages on "
1313
"input verbosity level."
1315
{NULL} /* Sentinel */
1322
* PyTyp_pjsua_logging_config
1324
static PyTypeObject PyTyp_pjsua_logging_config =
1326
PyObject_HEAD_INIT(NULL)
1328
"py_pjsua.Logging_Config", /*tp_name*/
1329
sizeof(PyObj_pjsua_logging_config), /*tp_basicsize*/
1331
(destructor)PyObj_pjsua_logging_config_delete,/*tp_dealloc*/
1338
0, /*tp_as_sequence*/
1339
0, /*tp_as_mapping*/
1346
Py_TPFLAGS_DEFAULT, /*tp_flags*/
1347
"Logging Config objects", /* tp_doc */
1348
0, /* tp_traverse */
1350
0, /* tp_richcompare */
1351
0, /* tp_weaklistoffset */
1353
0, /* tp_iternext */
1355
PyObj_pjsua_logging_config_members,/* tp_members */
1359
0, /* tp_descr_get */
1360
0, /* tp_descr_set */
1361
0, /* tp_dictoffset */
1364
PyObj_pjsua_logging_config_new, /* tp_new */
1369
//////////////////////////////////////////////////////////////////////////////
1371
* PyObj_pjsua_msg_data
1372
* typewrapper for MessageData class
1373
* !modified @ 061206
1378
/* Type-specific fields go here. */
1379
PyObject * hdr_list;
1380
PyObject * content_type;
1381
PyObject * msg_body;
1382
} PyObj_pjsua_msg_data;
1386
* PyObj_pjsua_msg_data_delete
1387
* deletes a msg_data
1388
* !modified @ 061206
1390
static void PyObj_pjsua_msg_data_delete(PyObj_pjsua_msg_data* self)
1392
Py_XDECREF(self->hdr_list);
1393
Py_XDECREF(self->content_type);
1394
Py_XDECREF(self->msg_body);
1395
self->ob_type->tp_free((PyObject*)self);
1400
* PyObj_pjsua_msg_data_new
1401
* constructor for msg_data object
1402
* !modified @ 061206
1404
static PyObject * PyObj_pjsua_msg_data_new(PyTypeObject *type,
1408
PyObj_pjsua_msg_data *self;
1410
PJ_UNUSED_ARG(args);
1411
PJ_UNUSED_ARG(kwds);
1413
self = (PyObj_pjsua_msg_data *)type->tp_alloc(type, 0);
1417
self->hdr_list = Py_None;
1418
if (self->hdr_list == NULL) {
1422
self->content_type = PyString_FromString("");
1423
if (self->content_type == NULL) {
1427
self->msg_body = PyString_FromString("");
1428
if (self->msg_body == NULL) {
1434
return (PyObject *)self;
1439
* PyObj_pjsua_msg_data_members
1440
* !modified @ 061206
1442
static PyMemberDef PyObj_pjsua_msg_data_members[] =
1445
"hdr_list", T_OBJECT_EX,
1446
offsetof(PyObj_pjsua_msg_data, hdr_list), 0,
1447
"Additional message headers as linked list of strings."
1450
"content_type", T_OBJECT_EX,
1451
offsetof(PyObj_pjsua_msg_data, content_type), 0,
1452
"MIME type of optional message body."
1455
"msg_body", T_OBJECT_EX,
1456
offsetof(PyObj_pjsua_msg_data, msg_body), 0,
1457
"Optional message body."
1459
{NULL} /* Sentinel */
1464
* PyTyp_pjsua_msg_data
1466
static PyTypeObject PyTyp_pjsua_msg_data =
1468
PyObject_HEAD_INIT(NULL)
1470
"py_pjsua.Msg_Data", /*tp_name*/
1471
sizeof(PyObj_pjsua_msg_data), /*tp_basicsize*/
1473
(destructor)PyObj_pjsua_msg_data_delete,/*tp_dealloc*/
1480
0, /*tp_as_sequence*/
1481
0, /*tp_as_mapping*/
1488
Py_TPFLAGS_DEFAULT, /*tp_flags*/
1489
"msg_data objects", /* tp_doc */
1490
0, /* tp_traverse */
1492
0, /* tp_richcompare */
1493
0, /* tp_weaklistoffset */
1495
0, /* tp_iternext */
1497
PyObj_pjsua_msg_data_members, /* tp_members */
1501
0, /* tp_descr_get */
1502
0, /* tp_descr_set */
1503
0, /* tp_dictoffset */
1506
PyObj_pjsua_msg_data_new, /* tp_new */
1511
//////////////////////////////////////////////////////////////////////////////
1513
* PyObj_pjsua_transport_config
1514
* Transport configuration for creating UDP transports for both SIP
1520
/* Type-specific fields go here. */
1522
PyObject *public_addr;
1523
PyObject *bound_addr;
1524
} PyObj_pjsua_transport_config;
1528
* PyObj_pjsua_transport_config_delete
1529
* deletes a transport config from memory
1531
static void PyObj_pjsua_transport_config_delete(PyObj_pjsua_transport_config* self)
1533
Py_XDECREF(self->public_addr);
1534
Py_XDECREF(self->bound_addr);
1535
self->ob_type->tp_free((PyObject*)self);
1539
static void PyObj_pjsua_transport_config_export(pjsua_transport_config *cfg,
1540
PyObj_pjsua_transport_config *obj)
1542
cfg->public_addr = PyString_to_pj_str(obj->public_addr);
1543
cfg->bound_addr = PyString_to_pj_str(obj->bound_addr);
1544
cfg->port = obj->port;
1548
static void PyObj_pjsua_transport_config_import(PyObj_pjsua_transport_config *obj,
1549
const pjsua_transport_config *cfg)
1551
Py_XDECREF(obj->public_addr);
1552
obj->public_addr = PyString_FromStringAndSize(cfg->public_addr.ptr,
1553
cfg->public_addr.slen);
1555
Py_XDECREF(obj->bound_addr);
1556
obj->bound_addr = PyString_FromStringAndSize(cfg->bound_addr.ptr,
1557
cfg->bound_addr.slen);
1559
obj->port = cfg->port;
1564
* PyObj_pjsua_transport_config_new
1565
* constructor for transport_config object
1567
static PyObject * PyObj_pjsua_transport_config_new(PyTypeObject *type,
1571
PyObj_pjsua_transport_config *self;
1573
PJ_UNUSED_ARG(args);
1574
PJ_UNUSED_ARG(kwds);
1576
self = (PyObj_pjsua_transport_config *)type->tp_alloc(type, 0);
1578
self->public_addr = PyString_FromString("");
1579
if (self->public_addr == NULL) {
1583
self->bound_addr = PyString_FromString("");
1584
if (self->bound_addr == NULL) {
1590
return (PyObject *)self;
1595
* PyObj_pjsua_transport_config_members
1597
static PyMemberDef PyObj_pjsua_transport_config_members[] =
1601
offsetof(PyObj_pjsua_transport_config, port), 0,
1602
"UDP port number to bind locally. This setting MUST be specified "
1603
"even when default port is desired. If the value is zero, the "
1604
"transport will be bound to any available port, and application "
1605
"can query the port by querying the transport info."
1608
"public_addr", T_OBJECT_EX,
1609
offsetof(PyObj_pjsua_transport_config, public_addr), 0,
1610
"Optional address to advertise as the address of this transport. "
1611
"Application can specify any address or hostname for this field, "
1612
"for example it can point to one of the interface address in the "
1613
"system, or it can point to the public address of a NAT router "
1614
"where port mappings have been configured for the application."
1617
"bound_addr", T_OBJECT_EX,
1618
offsetof(PyObj_pjsua_transport_config, bound_addr), 0,
1619
"Optional address where the socket should be bound to. This option "
1620
"SHOULD only be used to selectively bind the socket to particular "
1621
"interface (instead of 0.0.0.0), and SHOULD NOT be used to set the "
1622
"published address of a transport (the public_addr field should be "
1623
"used for that purpose)."
1625
{NULL} /* Sentinel */
1632
* PyTyp_pjsua_transport_config
1634
static PyTypeObject PyTyp_pjsua_transport_config =
1636
PyObject_HEAD_INIT(NULL)
1638
"py_pjsua.Transport_Config", /*tp_name*/
1639
sizeof(PyObj_pjsua_transport_config), /*tp_basicsize*/
1641
(destructor)PyObj_pjsua_transport_config_delete,/*tp_dealloc*/
1648
0, /*tp_as_sequence*/
1649
0, /*tp_as_mapping*/
1656
Py_TPFLAGS_DEFAULT, /*tp_flags*/
1657
"Transport setting", /* tp_doc */
1658
0, /* tp_traverse */
1660
0, /* tp_richcompare */
1661
0, /* tp_weaklistoffset */
1663
0, /* tp_iternext */
1665
PyObj_pjsua_transport_config_members,/* tp_members */
1669
0, /* tp_descr_get */
1670
0, /* tp_descr_set */
1671
0, /* tp_dictoffset */
1674
PyObj_pjsua_transport_config_new,/* tp_new */
1678
//////////////////////////////////////////////////////////////////////////////
1680
* PyObj_pjsua_transport_info
1686
/* Type-specific fields go here. */
1689
PyObject *type_name;
1694
unsigned usage_count;
1695
} PyObj_pjsua_transport_info;
1699
* PyObj_pjsua_transport_info_delete
1700
* deletes a transport info from memory
1702
static void PyObj_pjsua_transport_info_delete(PyObj_pjsua_transport_info* self)
1704
Py_XDECREF(self->type_name);
1705
Py_XDECREF(self->info);
1706
Py_XDECREF(self->addr);
1707
self->ob_type->tp_free((PyObject*)self);
1711
static void PyObj_pjsua_transport_info_import(PyObj_pjsua_transport_info *obj,
1712
const pjsua_transport_info *info)
1715
obj->type = info->type;
1716
obj->type_name = PyString_FromStringAndSize(info->type_name.ptr,
1717
info->type_name.slen);
1718
obj->info = PyString_FromStringAndSize(info->info.ptr,
1720
obj->flag = info->flag;
1721
obj->addr = PyString_FromStringAndSize(info->local_name.host.ptr,
1722
info->local_name.host.slen);
1723
obj->port = info->local_name.port;
1724
obj->usage_count= info->usage_count;
1728
* PyObj_pjsua_transport_info_new
1729
* constructor for transport_info object
1731
static PyObject * PyObj_pjsua_transport_info_new(PyTypeObject *type,
1735
PyObj_pjsua_transport_info *self;
1737
PJ_UNUSED_ARG(args);
1738
PJ_UNUSED_ARG(kwds);
1740
self = (PyObj_pjsua_transport_info *)type->tp_alloc(type, 0);
1743
self->type_name = PyString_FromString("");
1744
if (self->type_name == NULL) {
1748
self->info = PyString_FromString("");
1749
if (self->info == NULL) {
1753
self->addr = PyString_FromString("");
1754
if (self->addr == NULL) {
1760
return (PyObject *)self;
1765
* PyObj_pjsua_transport_info_members
1767
static PyMemberDef PyObj_pjsua_transport_info_members[] =
1771
offsetof(PyObj_pjsua_transport_info, id), 0,
1772
"PJSUA transport identification."
1776
offsetof(PyObj_pjsua_transport_info, id), 0,
1780
"type_name", T_OBJECT_EX,
1781
offsetof(PyObj_pjsua_transport_info, type_name), 0,
1782
"Transport type name."
1785
"info", T_OBJECT_EX,
1786
offsetof(PyObj_pjsua_transport_info, info), 0,
1787
"Transport string info/description."
1791
offsetof(PyObj_pjsua_transport_info, flag), 0,
1792
"Transport flag (see ##pjsip_transport_flags_e)."
1795
"addr", T_OBJECT_EX,
1796
offsetof(PyObj_pjsua_transport_info, addr), 0,
1797
"Published address (or transport address name)."
1801
offsetof(PyObj_pjsua_transport_info, port), 0,
1802
"Published port number."
1805
"usage_count", T_INT,
1806
offsetof(PyObj_pjsua_transport_info, usage_count), 0,
1807
"Current number of objects currently referencing this transport."
1809
{NULL} /* Sentinel */
1814
* PyTyp_pjsua_transport_info
1816
static PyTypeObject PyTyp_pjsua_transport_info =
1818
PyObject_HEAD_INIT(NULL)
1820
"py_pjsua.Transport_Info", /*tp_name*/
1821
sizeof(PyObj_pjsua_transport_info), /*tp_basicsize*/
1823
(destructor)PyObj_pjsua_transport_info_delete,/*tp_dealloc*/
1830
0, /*tp_as_sequence*/
1831
0, /*tp_as_mapping*/
1838
Py_TPFLAGS_DEFAULT, /*tp_flags*/
1839
"Transport Info objects", /* tp_doc */
1840
0, /* tp_traverse */
1842
0, /* tp_richcompare */
1843
0, /* tp_weaklistoffset */
1845
0, /* tp_iternext */
1847
PyObj_pjsua_transport_info_members, /* tp_members */
1851
0, /* tp_descr_get */
1852
0, /* tp_descr_set */
1853
0, /* tp_dictoffset */
1856
PyObj_pjsua_transport_info_new, /* tp_new */
1861
//////////////////////////////////////////////////////////////////////////////
1864
* PyObj_pjsua_acc_config
1870
/* Type-specific fields go here. */
1874
int publish_enabled;
1875
PyObject *force_contact;
1876
/*pj_str_t proxy[8];*/
1877
PyListObject *proxy;
1878
unsigned reg_timeout;
1879
/*pjsip_cred_info cred_info[8];*/
1880
PyListObject *cred_info;
1882
} PyObj_pjsua_acc_config;
1886
* PyObj_pjsua_acc_config_delete
1887
* deletes a acc_config from memory
1889
static void PyObj_pjsua_acc_config_delete(PyObj_pjsua_acc_config* self)
1891
Py_XDECREF(self->id);
1892
Py_XDECREF(self->reg_uri);
1893
Py_XDECREF(self->force_contact);
1894
Py_XDECREF(self->proxy);
1895
Py_XDECREF(self->cred_info);
1896
self->ob_type->tp_free((PyObject*)self);
1900
static void PyObj_pjsua_acc_config_import(PyObj_pjsua_acc_config *obj,
1901
const pjsua_acc_config *cfg)
1905
obj->priority = cfg->priority;
1906
Py_XDECREF(obj->id);
1907
obj->id = PyString_FromStringAndSize(cfg->id.ptr, cfg->id.slen);
1908
Py_XDECREF(obj->reg_uri);
1909
obj->reg_uri = PyString_FromStringAndSize(cfg->reg_uri.ptr,
1911
obj->publish_enabled = cfg->publish_enabled;
1912
Py_XDECREF(obj->force_contact);
1913
obj->force_contact = PyString_FromStringAndSize(cfg->force_contact.ptr,
1914
cfg->force_contact.slen);
1915
Py_XDECREF(obj->proxy);
1916
obj->proxy = (PyListObject *)PyList_New(0);
1917
for (i=0; i<cfg->proxy_cnt; ++i) {
1919
str = PyString_FromStringAndSize(cfg->proxy[i].ptr,
1920
cfg->proxy[i].slen);
1921
PyList_Append((PyObject *)obj->proxy, str);
1924
obj->reg_timeout = cfg->reg_timeout;
1926
Py_XDECREF(obj->cred_info);
1927
obj->cred_info = (PyListObject *)PyList_New(0);
1928
for (i=0; i<cfg->cred_count; ++i) {
1929
PyObj_pjsip_cred_info * ci;
1931
ci = (PyObj_pjsip_cred_info *)
1932
PyObj_pjsip_cred_info_new(&PyTyp_pjsip_cred_info,NULL,NULL);
1933
PyObj_pjsip_cred_info_import(ci, &cfg->cred_info[i]);
1934
PyList_Append((PyObject *)obj->cred_info, (PyObject *)ci);
1937
obj->transport_id = cfg->transport_id;
1940
static void PyObj_pjsua_acc_config_export(pjsua_acc_config *cfg,
1941
PyObj_pjsua_acc_config *obj)
1945
cfg->priority = obj->priority;
1946
cfg->id = PyString_to_pj_str(obj->id);
1947
cfg->reg_uri = PyString_to_pj_str(obj->reg_uri);
1948
cfg->publish_enabled = obj->publish_enabled;
1949
cfg->force_contact = PyString_to_pj_str(obj->force_contact);
1951
cfg->proxy_cnt = PyList_Size((PyObject*)obj->proxy);
1952
for (i = 0; i < cfg->proxy_cnt; i++) {
1953
/*cfg.proxy[i] = ac->proxy[i];*/
1954
cfg->proxy[i] = PyString_to_pj_str(PyList_GetItem((PyObject *)obj->proxy,i));
1957
cfg->reg_timeout = obj->reg_timeout;
1959
cfg->cred_count = PyList_Size((PyObject*)obj->cred_info);
1960
for (i = 0; i < cfg->cred_count; i++) {
1961
/*cfg.cred_info[i] = ac->cred_info[i];*/
1962
PyObj_pjsip_cred_info *ci;
1963
ci = (PyObj_pjsip_cred_info*)
1964
PyList_GetItem((PyObject *)obj->cred_info,i);
1965
PyObj_pjsip_cred_info_export(&cfg->cred_info[i], ci);
1968
cfg->transport_id = obj->transport_id;
1973
* PyObj_pjsua_acc_config_new
1974
* constructor for acc_config object
1976
static PyObject * PyObj_pjsua_acc_config_new(PyTypeObject *type,
1980
PyObj_pjsua_acc_config *self;
1982
PJ_UNUSED_ARG(args);
1983
PJ_UNUSED_ARG(kwds);
1985
self = (PyObj_pjsua_acc_config *)type->tp_alloc(type, 0);
1987
self->id = PyString_FromString("");
1988
if (self->id == NULL) {
1992
self->reg_uri = PyString_FromString("");
1993
if (self->reg_uri == NULL) {
1997
self->force_contact = PyString_FromString("");
1998
if (self->force_contact == NULL) {
2002
self->proxy = (PyListObject *)PyList_New(0);
2003
if (self->proxy == NULL) {
2007
self->cred_info = (PyListObject *)PyList_New(0);
2008
if (self->cred_info == NULL) {
2014
return (PyObject *)self;
2020
* PyObj_pjsua_acc_config_members
2022
static PyMemberDef PyObj_pjsua_acc_config_members[] =
2025
"priority", T_INT, offsetof(PyObj_pjsua_acc_config, priority), 0,
2026
"Account priority, which is used to control the order of matching "
2027
"incoming/outgoing requests. The higher the number means the higher "
2028
"the priority is, and the account will be matched first. "
2032
offsetof(PyObj_pjsua_acc_config, id), 0,
2033
"The full SIP URL for the account. "
2034
"The value can take name address or URL format, "
2035
"and will look something like 'sip:account@serviceprovider'. "
2036
"This field is mandatory."
2039
"reg_uri", T_OBJECT_EX,
2040
offsetof(PyObj_pjsua_acc_config, reg_uri), 0,
2041
"This is the URL to be put in the request URI for the registration, "
2042
"and will look something like 'sip:serviceprovider'. "
2043
"This field should be specified if registration is desired. "
2044
"If the value is empty, no account registration will be performed. "
2047
"publish_enabled", T_INT,
2048
offsetof(PyObj_pjsua_acc_config, publish_enabled), 0,
2049
"Publish presence? "
2052
"force_contact", T_OBJECT_EX,
2053
offsetof(PyObj_pjsua_acc_config, force_contact), 0,
2054
"Optional URI to be put as Contact for this account. "
2055
"It is recommended that this field is left empty, "
2056
"so that the value will be calculated automatically "
2057
"based on the transport address. "
2060
"proxy", T_OBJECT_EX,
2061
offsetof(PyObj_pjsua_acc_config, proxy), 0,
2062
"Optional URI of the proxies to be visited for all outgoing requests "
2063
"that are using this account (REGISTER, INVITE, etc). Application need "
2064
"to specify these proxies if the service provider requires "
2065
"that requests destined towards its network should go through certain "
2066
"proxies first (for example, border controllers)."
2069
"reg_timeout", T_INT, offsetof(PyObj_pjsua_acc_config, reg_timeout), 0,
2070
"Optional interval for registration, in seconds. "
2071
"If the value is zero, default interval will be used "
2072
"(PJSUA_REG_INTERVAL, 55 seconds). "
2075
"cred_info", T_OBJECT_EX,
2076
offsetof(PyObj_pjsua_acc_config, cred_info), 0,
2077
"Array of credentials. If registration is desired, normally there "
2078
"should be at least one credential specified, to successfully "
2079
"authenticate against the service provider. More credentials can "
2080
"be specified, for example when the requests are expected to be "
2081
"challenged by the proxies in the route set."
2084
"transport_id", T_INT,
2085
offsetof(PyObj_pjsua_acc_config, transport_id), 0,
2086
"Optionally bind this account to specific transport. This normally is"
2087
" not a good idea, as account should be able to send requests using"
2088
" any available transports according to the destination. But some"
2089
" application may want to have explicit control over the transport to"
2090
" use, so in that case it can set this field."
2092
{NULL} /* Sentinel */
2099
* PyTyp_pjsua_acc_config
2101
static PyTypeObject PyTyp_pjsua_acc_config =
2103
PyObject_HEAD_INIT(NULL)
2105
"py_pjsua.Acc_Config", /*tp_name*/
2106
sizeof(PyObj_pjsua_acc_config), /*tp_basicsize*/
2108
(destructor)PyObj_pjsua_acc_config_delete,/*tp_dealloc*/
2115
0, /*tp_as_sequence*/
2116
0, /*tp_as_mapping*/
2123
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2124
"Acc Config objects", /* tp_doc */
2125
0, /* tp_traverse */
2127
0, /* tp_richcompare */
2128
0, /* tp_weaklistoffset */
2130
0, /* tp_iternext */
2131
0/*acc_config_methods*/, /* tp_methods */
2132
PyObj_pjsua_acc_config_members, /* tp_members */
2136
0, /* tp_descr_get */
2137
0, /* tp_descr_set */
2138
0, /* tp_dictoffset */
2141
PyObj_pjsua_acc_config_new, /* tp_new */
2146
//////////////////////////////////////////////////////////////////////////////
2148
* PyObj_pjsua_acc_info
2154
/* Type-specific fields go here. */
2158
int has_registration;
2161
PyObject *status_text;
2163
PyObject *online_status_text;
2164
} PyObj_pjsua_acc_info;
2168
* PyObj_pjsua_acc_info_delete
2169
* deletes a acc_info from memory
2171
static void PyObj_pjsua_acc_info_delete(PyObj_pjsua_acc_info* self)
2173
Py_XDECREF(self->acc_uri);
2174
Py_XDECREF(self->status_text);
2175
Py_XDECREF(self->online_status_text);
2176
self->ob_type->tp_free((PyObject*)self);
2180
static void PyObj_pjsua_acc_info_import(PyObj_pjsua_acc_info *obj,
2181
const pjsua_acc_info *info)
2184
obj->is_default = info->is_default;
2185
obj->acc_uri = PyString_FromStringAndSize(info->acc_uri.ptr,
2186
info->acc_uri.slen);
2187
obj->has_registration = info->has_registration;
2188
obj->expires = info->expires;
2189
obj->status = info->status;
2190
obj->status_text= PyString_FromStringAndSize(info->status_text.ptr,
2191
info->status_text.slen);
2192
obj->online_status = info->online_status;
2193
obj->online_status_text = PyString_FromStringAndSize(info->online_status_text.ptr,
2194
info->online_status_text.slen);
2199
* PyObj_pjsua_acc_info_new
2200
* constructor for acc_info object
2202
static PyObject * PyObj_pjsua_acc_info_new(PyTypeObject *type,
2206
PyObj_pjsua_acc_info *self;
2208
PJ_UNUSED_ARG(args);
2209
PJ_UNUSED_ARG(kwds);
2211
self = (PyObj_pjsua_acc_info *)type->tp_alloc(type, 0);
2213
self->acc_uri = PyString_FromString("");
2214
if (self->acc_uri == NULL) {
2218
self->status_text = PyString_FromString("");
2219
if (self->status_text == NULL) {
2223
self->online_status_text = PyString_FromString("");
2224
if (self->online_status_text == NULL) {
2230
return (PyObject *)self;
2236
static PyMemberDef acc_info_members[] =
2240
offsetof(PyObj_pjsua_acc_info, id), 0,
2244
"is_default", T_INT,
2245
offsetof(PyObj_pjsua_acc_info, is_default), 0,
2246
"Flag to indicate whether this is the default account. "
2249
"acc_uri", T_OBJECT_EX,
2250
offsetof(PyObj_pjsua_acc_info, acc_uri), 0,
2254
"has_registration", T_INT,
2255
offsetof(PyObj_pjsua_acc_info, has_registration), 0,
2256
"Flag to tell whether this account has registration setting "
2257
"(reg_uri is not empty)."
2261
offsetof(PyObj_pjsua_acc_info, expires), 0,
2262
"An up to date expiration interval for account registration session."
2266
offsetof(PyObj_pjsua_acc_info, status), 0,
2267
"Last registration status code. If status code is zero, "
2268
"the account is currently not registered. Any other value indicates "
2269
"the SIP status code of the registration. "
2272
"status_text", T_OBJECT_EX,
2273
offsetof(PyObj_pjsua_acc_info, status_text), 0,
2274
"String describing the registration status."
2277
"online_status", T_INT,
2278
offsetof(PyObj_pjsua_acc_info, online_status), 0,
2279
"Presence online status for this account. "
2282
"online_status_text", T_OBJECT_EX,
2283
offsetof(PyObj_pjsua_acc_info, online_status_text), 0,
2284
"Presence online status text."
2286
{NULL} /* Sentinel */
2293
* PyTyp_pjsua_acc_info
2295
static PyTypeObject PyTyp_pjsua_acc_info =
2297
PyObject_HEAD_INIT(NULL)
2299
"py_pjsua.Acc_Info", /*tp_name*/
2300
sizeof(PyObj_pjsua_acc_info), /*tp_basicsize*/
2302
(destructor)PyObj_pjsua_acc_info_delete,/*tp_dealloc*/
2309
0, /*tp_as_sequence*/
2310
0, /*tp_as_mapping*/
2317
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2318
"Acc Info objects", /* tp_doc */
2319
0, /* tp_traverse */
2321
0, /* tp_richcompare */
2322
0, /* tp_weaklistoffset */
2324
0, /* tp_iternext */
2325
NULL, /* tp_methods */
2326
acc_info_members, /* tp_members */
2330
0, /* tp_descr_get */
2331
0, /* tp_descr_set */
2332
0, /* tp_dictoffset */
2335
PyObj_pjsua_acc_info_new, /* tp_new */
2340
//////////////////////////////////////////////////////////////////////////////
2343
* PyObj_pjsua_buddy_config
2349
/* Type-specific fields go here. */
2352
} PyObj_pjsua_buddy_config;
2356
* PyObj_pjsua_buddy_config_delete
2357
* deletes a buddy_config from memory
2359
static void PyObj_pjsua_buddy_config_delete(PyObj_pjsua_buddy_config* self)
2361
Py_XDECREF(self->uri);
2362
self->ob_type->tp_free((PyObject*)self);
2366
static void PyObj_pjsua_buddy_config_import(PyObj_pjsua_buddy_config *obj,
2367
const pjsua_buddy_config *cfg)
2369
Py_XDECREF(obj->uri);
2370
obj->uri = PyString_FromStringAndSize(cfg->uri.ptr, cfg->uri.slen);
2371
obj->subscribe = cfg->subscribe;
2375
static void PyObj_pjsua_buddy_config_export(pjsua_buddy_config *cfg,
2376
PyObj_pjsua_buddy_config *obj)
2378
cfg->uri = PyString_to_pj_str(obj->uri);
2379
cfg->subscribe = obj->subscribe;
2385
* PyObj_pjsua_buddy_config_new
2386
* constructor for buddy_config object
2388
static PyObject *PyObj_pjsua_buddy_config_new(PyTypeObject *type,
2392
PyObj_pjsua_buddy_config *self;
2394
PJ_UNUSED_ARG(args);
2395
PJ_UNUSED_ARG(kwds);
2397
self = (PyObj_pjsua_buddy_config *)type->tp_alloc(type, 0);
2399
self->uri = PyString_FromString("");
2400
if (self->uri == NULL) {
2405
return (PyObject *)self;
2409
* PyObj_pjsua_buddy_config_members
2411
static PyMemberDef PyObj_pjsua_buddy_config_members[] =
2416
offsetof(PyObj_pjsua_buddy_config, uri), 0,
2417
"TBuddy URL or name address."
2422
offsetof(PyObj_pjsua_buddy_config, subscribe), 0,
2423
"Specify whether presence subscription should start immediately. "
2426
{NULL} /* Sentinel */
2433
* PyTyp_pjsua_buddy_config
2435
static PyTypeObject PyTyp_pjsua_buddy_config =
2437
PyObject_HEAD_INIT(NULL)
2439
"py_pjsua.Buddy_Config", /*tp_name*/
2440
sizeof(PyObj_pjsua_buddy_config),/*tp_basicsize*/
2442
(destructor)PyObj_pjsua_buddy_config_delete,/*tp_dealloc*/
2449
0, /*tp_as_sequence*/
2450
0, /*tp_as_mapping*/
2457
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2458
"Buddy Config objects", /* tp_doc */
2459
0, /* tp_traverse */
2461
0, /* tp_richcompare */
2462
0, /* tp_weaklistoffset */
2464
0, /* tp_iternext */
2466
PyObj_pjsua_buddy_config_members, /* tp_members */
2470
0, /* tp_descr_get */
2471
0, /* tp_descr_set */
2472
0, /* tp_dictoffset */
2475
PyObj_pjsua_buddy_config_new, /* tp_new */
2479
//////////////////////////////////////////////////////////////////////////////
2481
* PyObj_pjsua_buddy_info
2487
/* Type-specific fields go here. */
2492
PyObject *status_text;
2494
} PyObj_pjsua_buddy_info;
2498
* PyObj_pjsua_buddy_info_delete
2499
* deletes a buddy_info from memory
2500
* !modified @ 071206
2502
static void PyObj_pjsua_buddy_info_delete(PyObj_pjsua_buddy_info* self)
2504
Py_XDECREF(self->uri);
2505
Py_XDECREF(self->contact);
2506
Py_XDECREF(self->status_text);
2508
self->ob_type->tp_free((PyObject*)self);
2512
static void PyObj_pjsua_buddy_info_import(PyObj_pjsua_buddy_info *obj,
2513
const pjsua_buddy_info *info)
2516
Py_XDECREF(obj->uri);
2517
obj->uri = PyString_FromStringAndSize(info->uri.ptr, info->uri.slen);
2518
Py_XDECREF(obj->contact);
2519
obj->contact = PyString_FromStringAndSize(info->contact.ptr, info->contact.slen);
2520
obj->status = info->status;
2521
Py_XDECREF(obj->status_text);
2522
obj->status_text = PyString_FromStringAndSize(info->status_text.ptr,
2523
info->status_text.slen);
2524
obj->monitor_pres = info->monitor_pres;
2529
* PyObj_pjsua_buddy_info_new
2530
* constructor for buddy_info object
2531
* !modified @ 071206
2533
static PyObject * PyObj_pjsua_buddy_info_new(PyTypeObject *type,
2537
PyObj_pjsua_buddy_info *self;
2539
PJ_UNUSED_ARG(args);
2540
PJ_UNUSED_ARG(kwds);
2542
self = (PyObj_pjsua_buddy_info *)type->tp_alloc(type, 0);
2544
self->uri = PyString_FromString("");
2545
if (self->uri == NULL) {
2549
self->contact = PyString_FromString("");
2550
if (self->contact == NULL) {
2554
self->status_text = PyString_FromString("");
2555
if (self->status_text == NULL) {
2561
return (PyObject *)self;
2565
* PyObj_pjsua_buddy_info_members
2566
* !modified @ 071206
2568
static PyMemberDef PyObj_pjsua_buddy_info_members[] =
2572
offsetof(PyObj_pjsua_buddy_info, id), 0,
2577
offsetof(PyObj_pjsua_buddy_info, uri), 0,
2578
"The full URI of the buddy, as specified in the configuration. "
2581
"contact", T_OBJECT_EX,
2582
offsetof(PyObj_pjsua_buddy_info, contact), 0,
2583
"Buddy's Contact, only available when presence subscription "
2584
"has been established to the buddy."
2588
offsetof(PyObj_pjsua_buddy_info, status), 0,
2589
"Buddy's online status. "
2592
"status_text", T_OBJECT_EX,
2593
offsetof(PyObj_pjsua_buddy_info, status_text), 0,
2594
"Text to describe buddy's online status."
2597
"monitor_pres", T_INT,
2598
offsetof(PyObj_pjsua_buddy_info, monitor_pres), 0,
2599
"Flag to indicate that we should monitor the presence information "
2600
"for this buddy (normally yes, unless explicitly disabled). "
2604
{NULL} /* Sentinel */
2611
* PyTyp_pjsua_buddy_info
2613
static PyTypeObject PyTyp_pjsua_buddy_info =
2615
PyObject_HEAD_INIT(NULL)
2617
"py_pjsua.Buddy_Info", /*tp_name*/
2618
sizeof(PyObj_pjsua_buddy_info), /*tp_basicsize*/
2620
(destructor)PyObj_pjsua_buddy_info_delete,/*tp_dealloc*/
2627
0, /*tp_as_sequence*/
2628
0, /*tp_as_mapping*/
2635
Py_TPFLAGS_DEFAULT, /*tp_flags*/
2636
"Buddy Info objects", /* tp_doc */
2637
0, /* tp_traverse */
2639
0, /* tp_richcompare */
2640
0, /* tp_weaklistoffset */
2642
0, /* tp_iternext */
2644
PyObj_pjsua_buddy_info_members, /* tp_members */
2648
0, /* tp_descr_get */
2649
0, /* tp_descr_set */
2650
0, /* tp_dictoffset */
2653
PyObj_pjsua_buddy_info_new, /* tp_new */
2661
#endif /* __PY_PJSUA_H__ */