Ignore:
Timestamp:
Jul 21, 2008 6:20:57 PM (16 years ago)
Author:
bennylp
Message:

Major modifications in Python module and pjsua.py wrapper:

  • replaced call/acc/buddy dictionaries with user data attachment
  • recommended to install callback when creating the object, to prevent missing some events
  • fixed circular references by using weakref
  • protect access to pjsua with mutex; found out that without this there will be deadlock in Python
  • fixed memory leaks in the _pjsua.c module (objects reference counter not properly maintained)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/python/_pjsua.h

    r2156 r2163  
    2727 
    2828 
    29 PJ_INLINE(pj_str_t) PyString_to_pj_str(const PyObject *obj) 
     29PJ_INLINE(pj_str_t) PyString_ToPJ(const PyObject *obj) 
    3030{ 
    3131    pj_str_t str; 
    3232 
    33     if (obj) { 
     33    if (obj && PyString_Check(obj)) { 
    3434        str.ptr = PyString_AS_STRING(obj); 
    3535        str.slen = PyString_GET_SIZE(obj); 
     
    4242} 
    4343 
    44  
    45 ////////////////////////////////////////////////////////////////////////////// 
    46 /* 
    47  * PyObj_pj_pool 
    48  */ 
    49 typedef struct 
    50 { 
    51     PyObject_HEAD 
    52     /* Type-specific fields go here. */ 
    53     pj_pool_t * pool; 
    54 } PyObj_pj_pool; 
    55  
    56  
    57 /* 
    58  * PyTyp_pj_pool_t 
    59  */ 
    60 static PyTypeObject PyTyp_pj_pool_t = 
    61 { 
    62     PyObject_HEAD_INIT(NULL) 
    63     0,                         /*ob_size*/ 
    64     "_pjsua.Pj_Pool",        /*tp_name*/ 
    65     sizeof(PyObj_pj_pool),    /*tp_basicsize*/ 
    66     0,                         /*tp_itemsize*/ 
    67     0,                         /*tp_dealloc*/ 
    68     0,                         /*tp_print*/ 
    69     0,                         /*tp_getattr*/ 
    70     0,                         /*tp_setattr*/ 
    71     0,                         /*tp_compare*/ 
    72     0,                         /*tp_repr*/ 
    73     0,                         /*tp_as_number*/ 
    74     0,                         /*tp_as_sequence*/ 
    75     0,                         /*tp_as_mapping*/ 
    76     0,                         /*tp_hash */ 
    77     0,                         /*tp_call*/ 
    78     0,                         /*tp_str*/ 
    79     0,                         /*tp_getattro*/ 
    80     0,                         /*tp_setattro*/ 
    81     0,                         /*tp_as_buffer*/ 
    82     Py_TPFLAGS_DEFAULT,        /*tp_flags*/ 
    83     "pj_pool_t objects",       /* tp_doc */ 
    84  
    85 }; 
    86  
    87  
    88 ////////////////////////////////////////////////////////////////////////////// 
    89 /* 
    90  * PyObj_pjsip_endpoint 
    91  */ 
    92 typedef struct 
    93 { 
    94     PyObject_HEAD 
    95     /* Type-specific fields go here. */ 
    96     pjsip_endpoint * endpt; 
    97 } PyObj_pjsip_endpoint; 
    98  
    99  
    100 /* 
    101  * PyTyp_pjsip_endpoint 
    102  */ 
    103 static PyTypeObject PyTyp_pjsip_endpoint = 
    104 { 
    105     PyObject_HEAD_INIT(NULL) 
    106     0,                         /*ob_size*/ 
    107     "_pjsua.Pjsip_Endpoint", /*tp_name*/ 
    108     sizeof(PyObj_pjsip_endpoint),/*tp_basicsize*/ 
    109     0,                         /*tp_itemsize*/ 
    110     0,                         /*tp_dealloc*/ 
    111     0,                         /*tp_print*/ 
    112     0,                         /*tp_getattr*/ 
    113     0,                         /*tp_setattr*/ 
    114     0,                         /*tp_compare*/ 
    115     0,                         /*tp_repr*/ 
    116     0,                         /*tp_as_number*/ 
    117     0,                         /*tp_as_sequence*/ 
    118     0,                         /*tp_as_mapping*/ 
    119     0,                         /*tp_hash */ 
    120     0,                         /*tp_call*/ 
    121     0,                         /*tp_str*/ 
    122     0,                         /*tp_getattro*/ 
    123     0,                         /*tp_setattro*/ 
    124     0,                         /*tp_as_buffer*/ 
    125     Py_TPFLAGS_DEFAULT,        /*tp_flags*/ 
    126     "pjsip_endpoint objects",  /* tp_doc */ 
    127 }; 
    128  
    129  
    130 /* 
    131  * PyObj_pjmedia_endpt 
    132  */ 
    133 typedef struct 
    134 { 
    135     PyObject_HEAD 
    136     /* Type-specific fields go here. */ 
    137     pjmedia_endpt * endpt; 
    138 } PyObj_pjmedia_endpt; 
    139  
    140  
    141 ////////////////////////////////////////////////////////////////////////////// 
    142 /* 
    143  * PyTyp_pjmedia_endpt 
    144  */ 
    145 static PyTypeObject PyTyp_pjmedia_endpt = 
    146 { 
    147     PyObject_HEAD_INIT(NULL) 
    148     0,                         /*ob_size*/ 
    149     "_pjsua.Pjmedia_Endpt",  /*tp_name*/ 
    150     sizeof(PyObj_pjmedia_endpt), /*tp_basicsize*/ 
    151     0,                         /*tp_itemsize*/ 
    152     0,                         /*tp_dealloc*/ 
    153     0,                         /*tp_print*/ 
    154     0,                         /*tp_getattr*/ 
    155     0,                         /*tp_setattr*/ 
    156     0,                         /*tp_compare*/ 
    157     0,                         /*tp_repr*/ 
    158     0,                         /*tp_as_number*/ 
    159     0,                         /*tp_as_sequence*/ 
    160     0,                         /*tp_as_mapping*/ 
    161     0,                         /*tp_hash */ 
    162     0,                         /*tp_call*/ 
    163     0,                         /*tp_str*/ 
    164     0,                         /*tp_getattro*/ 
    165     0,                         /*tp_setattro*/ 
    166     0,                         /*tp_as_buffer*/ 
    167     Py_TPFLAGS_DEFAULT,        /*tp_flags*/ 
    168     "pjmedia_endpt objects",   /* tp_doc */ 
    169  
    170 }; 
    171  
    172  
    173 ////////////////////////////////////////////////////////////////////////////// 
    174 /* 
    175  * PyObj_pj_pool_factory 
    176  */ 
    177 typedef struct 
    178 { 
    179     PyObject_HEAD 
    180     /* Type-specific fields go here. */ 
    181     pj_pool_factory * pool_fact; 
    182 } PyObj_pj_pool_factory; 
    183  
    184  
    185  
    186 /* 
    187  * PyTyp_pj_pool_factory 
    188  */ 
    189 static PyTypeObject PyTyp_pj_pool_factory = 
    190 { 
    191     PyObject_HEAD_INIT(NULL) 
    192     0,                         /*ob_size*/ 
    193     "_pjsua.Pj_Pool_Factory",/*tp_name*/ 
    194     sizeof(PyObj_pj_pool_factory), /*tp_basicsize*/ 
    195     0,                         /*tp_itemsize*/ 
    196     0,                         /*tp_dealloc*/ 
    197     0,                         /*tp_print*/ 
    198     0,                         /*tp_getattr*/ 
    199     0,                         /*tp_setattr*/ 
    200     0,                         /*tp_compare*/ 
    201     0,                         /*tp_repr*/ 
    202     0,                         /*tp_as_number*/ 
    203     0,                         /*tp_as_sequence*/ 
    204     0,                         /*tp_as_mapping*/ 
    205     0,                         /*tp_hash */ 
    206     0,                         /*tp_call*/ 
    207     0,                         /*tp_str*/ 
    208     0,                         /*tp_getattro*/ 
    209     0,                         /*tp_setattro*/ 
    210     0,                         /*tp_as_buffer*/ 
    211     Py_TPFLAGS_DEFAULT,        /*tp_flags*/ 
    212     "pj_pool_factory objects", /* tp_doc */ 
    213  
    214 }; 
    215  
     44PJ_INLINE(PyObject*) PyString_FromPJ(const pj_str_t *str) 
     45{ 
     46    return PyString_FromStringAndSize(str->ptr, str->slen); 
     47} 
    21648 
    21749////////////////////////////////////////////////////////////////////////////// 
     
    25082{ 
    25183    Py_XDECREF(obj->realm); 
    252     obj->realm = PyString_FromStringAndSize(cfg->realm.ptr, cfg->realm.slen); 
     84    obj->realm = PyString_FromPJ(&cfg->realm); 
    25385    Py_XDECREF(obj->scheme); 
    254     obj->scheme = PyString_FromStringAndSize(cfg->scheme.ptr, cfg->scheme.slen); 
     86    obj->scheme = PyString_FromPJ(&cfg->scheme); 
    25587    Py_XDECREF(obj->username); 
    256     obj->username = PyString_FromStringAndSize(cfg->username.ptr, cfg->username.slen); 
     88    obj->username = PyString_FromPJ(&cfg->username); 
    25789    obj->data_type = cfg->data_type; 
    25890    Py_XDECREF(obj->data); 
    259     obj->data = PyString_FromStringAndSize(cfg->data.ptr, cfg->data.slen); 
     91    obj->data = PyString_FromPJ(&cfg->data); 
    26092} 
    26193 
     
    26395                                         PyObj_pjsip_cred_info *obj) 
    26496{ 
    265     cfg->realm  = PyString_to_pj_str(obj->realm); 
    266     cfg->scheme = PyString_to_pj_str(obj->scheme); 
    267     cfg->username = PyString_to_pj_str(obj->username); 
     97    cfg->realm  = PyString_ToPJ(obj->realm); 
     98    cfg->scheme = PyString_ToPJ(obj->scheme); 
     99    cfg->username = PyString_ToPJ(obj->username); 
    268100    cfg->data_type = obj->data_type; 
    269     cfg->data   = PyString_to_pj_str(obj->data); 
     101    cfg->data   = PyString_ToPJ(obj->data); 
    270102} 
    271103 
     
    285117 
    286118    self = (PyObj_pjsip_cred_info *)type->tp_alloc(type, 0); 
    287     if (self != NULL) 
    288     { 
     119    if (self != NULL) { 
    289120        self->realm = PyString_FromString(""); 
    290         if (self->realm == NULL) 
    291         { 
    292             Py_DECREF(self); 
    293             return NULL; 
    294         } 
    295121        self->scheme = PyString_FromString(""); 
    296         if (self->scheme == NULL) 
    297         { 
    298             Py_DECREF(self); 
    299             return NULL; 
    300         } 
    301122        self->username = PyString_FromString(""); 
    302         if (self->username == NULL) 
    303         { 
    304             Py_DECREF(self); 
    305             return NULL; 
    306         } 
    307123        self->data_type = PJSIP_CRED_DATA_PLAIN_PASSWD; 
    308124        self->data = PyString_FromString(""); 
    309         if (self->data == NULL) 
    310         { 
    311             Py_DECREF(self); 
    312             return NULL; 
    313         } 
    314125    } 
    315126 
     
    387198    0,                              /* tp_iternext */ 
    388199    0,                              /* tp_methods */ 
    389     PyObj_pjsip_cred_info_members,         /* tp_members */ 
     200    PyObj_pjsip_cred_info_members,  /* tp_members */ 
    390201    0,                              /* tp_getset */ 
    391202    0,                              /* tp_base */ 
     
    396207    0,                              /* tp_init */ 
    397208    0,                              /* tp_alloc */ 
    398     PyObj_pjsip_cred_info_new,             /* tp_new */ 
    399  
    400 }; 
    401  
    402  
    403 ////////////////////////////////////////////////////////////////////////////// 
    404 /* 
    405  * PyObj_pjsip_event 
    406  * C/python typewrapper for event struct 
    407  */ 
    408 typedef struct 
    409 { 
    410     PyObject_HEAD 
    411     /* Type-specific fields go here. */ 
    412     pjsip_event * event; 
    413 } PyObj_pjsip_event; 
    414  
    415  
    416  
    417 /* 
    418  * PyTyp_pjsip_event 
    419  * event struct signatures 
    420  */ 
    421 static PyTypeObject PyTyp_pjsip_event = 
    422 { 
    423     PyObject_HEAD_INIT(NULL) 
    424     0,                          /*ob_size*/ 
    425     "_pjsua.Pjsip_Event",     /*tp_name*/ 
    426     sizeof(PyObj_pjsip_event),  /*tp_basicsize*/ 
    427     0,                          /*tp_itemsize*/ 
    428     0,                          /*tp_dealloc*/ 
    429     0,                          /*tp_print*/ 
    430     0,                          /*tp_getattr*/ 
    431     0,                          /*tp_setattr*/ 
    432     0,                          /*tp_compare*/ 
    433     0,                          /*tp_repr*/ 
    434     0,                          /*tp_as_number*/ 
    435     0,                          /*tp_as_sequence*/ 
    436     0,                          /*tp_as_mapping*/ 
    437     0,                          /*tp_hash */ 
    438     0,                          /*tp_call*/ 
    439     0,                          /*tp_str*/ 
    440     0,                          /*tp_getattro*/ 
    441     0,                          /*tp_setattro*/ 
    442     0,                          /*tp_as_buffer*/ 
    443     Py_TPFLAGS_DEFAULT,         /*tp_flags*/ 
    444     "pjsip_event object",       /*tp_doc */ 
    445 }; 
    446  
    447  
    448 ////////////////////////////////////////////////////////////////////////////// 
    449 /* 
    450  * PyObj_pjsip_rx_data 
    451  * C/python typewrapper for pjsip_rx_data struct 
    452  */ 
    453 typedef struct 
    454 { 
    455     PyObject_HEAD 
    456     /* Type-specific fields go here. */ 
    457     pjsip_rx_data * rdata; 
    458 } PyObj_pjsip_rx_data; 
    459  
    460  
    461 /* 
    462  * PyTyp_pjsip_rx_data 
    463  */ 
    464 static PyTypeObject PyTyp_pjsip_rx_data = 
    465 { 
    466     PyObject_HEAD_INIT(NULL) 
    467     0,                              /*ob_size*/ 
    468     "_pjsua.Pjsip_Rx_Data",       /*tp_name*/ 
    469     sizeof(PyObj_pjsip_rx_data),    /*tp_basicsize*/ 
    470     0,                              /*tp_itemsize*/ 
    471     0,                              /*tp_dealloc*/ 
    472     0,                              /*tp_print*/ 
    473     0,                              /*tp_getattr*/ 
    474     0,                              /*tp_setattr*/ 
    475     0,                              /*tp_compare*/ 
    476     0,                              /*tp_repr*/ 
    477     0,                              /*tp_as_number*/ 
    478     0,                              /*tp_as_sequence*/ 
    479     0,                              /*tp_as_mapping*/ 
    480     0,                              /*tp_hash */ 
    481     0,                              /*tp_call*/ 
    482     0,                              /*tp_str*/ 
    483     0,                              /*tp_getattro*/ 
    484     0,                              /*tp_setattro*/ 
    485     0,                              /*tp_as_buffer*/ 
    486     Py_TPFLAGS_DEFAULT,             /*tp_flags*/ 
    487     "pjsip_rx_data object",         /*tp_doc*/ 
    488 }; 
    489  
     209    PyObj_pjsip_cred_info_new,      /* tp_new */ 
     210 
     211}; 
    490212 
    491213 
     
    554276 
    555277    self = (PyObj_pjsua_callback *)type->tp_alloc(type, 0); 
    556     if (self != NULL) 
    557     { 
    558         Py_INCREF(Py_None); 
    559         self->on_call_state = Py_None; 
    560         if (self->on_call_state == NULL) 
    561         { 
    562             Py_DECREF(Py_None); 
    563             return NULL; 
    564         } 
    565         Py_INCREF(Py_None); 
    566         self->on_incoming_call = Py_None; 
    567         if (self->on_incoming_call == NULL) 
    568         { 
    569             Py_DECREF(Py_None); 
    570             return NULL; 
    571         } 
    572         Py_INCREF(Py_None); 
    573         self->on_call_media_state = Py_None; 
    574         if (self->on_call_media_state == NULL) 
    575         { 
    576             Py_DECREF(Py_None); 
    577             return NULL; 
    578         } 
    579         Py_INCREF(Py_None); 
    580         self->on_dtmf_digit = Py_None; 
    581         if (self->on_dtmf_digit == NULL) 
    582         { 
    583             Py_DECREF(Py_None); 
    584             return NULL; 
    585         } 
    586         Py_INCREF(Py_None); 
    587         self->on_call_transfer_request = Py_None; 
    588         if (self->on_call_transfer_request == NULL) 
    589         { 
    590             Py_DECREF(Py_None); 
    591             return NULL; 
    592         } 
    593         Py_INCREF(Py_None); 
    594         self->on_call_transfer_status = Py_None; 
    595         if (self->on_call_transfer_status == NULL) 
    596         { 
    597             Py_DECREF(Py_None); 
    598             return NULL; 
    599         } 
    600         Py_INCREF(Py_None); 
    601         self->on_call_replace_request = Py_None; 
    602         if (self->on_call_replace_request == NULL) 
    603         { 
    604             Py_DECREF(Py_None); 
    605             return NULL; 
    606         } 
    607         Py_INCREF(Py_None); 
    608         self->on_call_replaced = Py_None; 
    609         if (self->on_call_replaced == NULL) 
    610         { 
    611             Py_DECREF(Py_None); 
    612             return NULL; 
    613         } 
    614         Py_INCREF(Py_None); 
    615         self->on_reg_state = Py_None; 
    616         if (self->on_reg_state == NULL) 
    617         { 
    618             Py_DECREF(Py_None); 
    619             return NULL; 
    620         } 
    621         Py_INCREF(Py_None); 
    622         self->on_incoming_subscribe = Py_None; 
    623         Py_INCREF(Py_None); 
    624         self->on_buddy_state = Py_None; 
    625         if (self->on_buddy_state == NULL) 
    626         { 
    627             Py_DECREF(Py_None); 
    628             return NULL; 
    629         } 
    630         Py_INCREF(Py_None); 
    631         self->on_pager = Py_None; 
    632         if (self->on_pager == NULL) 
    633         { 
    634             Py_DECREF(Py_None); 
    635             return NULL; 
    636         } 
    637         Py_INCREF(Py_None); 
    638         self->on_pager_status = Py_None; 
    639         if (self->on_pager_status == NULL) 
    640         { 
    641             Py_DECREF(Py_None); 
    642             return NULL; 
    643         } 
    644         Py_INCREF(Py_None); 
    645         self->on_typing = Py_None; 
    646         if (self->on_typing == NULL) 
    647         { 
    648             Py_DECREF(Py_None); 
    649             return NULL; 
    650         } 
     278    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(""); 
    651293    } 
    652294 
     
    989631    }, 
    990632    { 
    991         "turn_passw", T_OBJECT_EX, 
     633        "turn_passwd", T_OBJECT_EX, 
    992634        offsetof(PyObj_pjsua_media_config, turn_passwd), 0, 
    993635        "Specify the TURN password." 
     
    1008650 
    1009651    self = (PyObj_pjsua_media_config*)type->tp_alloc(type, 0); 
    1010     if (self != NULL) 
    1011     { 
     652    if (self != NULL) { 
    1012653        self->turn_server = PyString_FromString(""); 
    1013654        self->turn_realm = PyString_FromString(""); 
     
    1052693    obj->enable_turn        = cfg->enable_turn; 
    1053694    Py_XDECREF(obj->turn_server); 
    1054     obj->turn_server        = PyString_FromStringAndSize(cfg->turn_server.ptr,  
    1055                                                          cfg->turn_server.slen); 
     695    obj->turn_server        = PyString_FromPJ(&cfg->turn_server); 
    1056696    obj->turn_conn_type     = cfg->turn_conn_type; 
    1057697    if (cfg->turn_auth_cred.type == PJ_STUN_AUTH_CRED_STATIC) { 
     
    1059699 
    1060700        Py_XDECREF(obj->turn_realm); 
    1061         obj->turn_realm = PyString_FromStringAndSize(cred->data.static_cred.realm.ptr,  
    1062                                                      cred->data.static_cred.realm.slen); 
     701        obj->turn_realm = PyString_FromPJ(&cred->data.static_cred.realm); 
    1063702        Py_XDECREF(obj->turn_username); 
    1064         obj->turn_username = PyString_FromStringAndSize(cred->data.static_cred.username.ptr,  
    1065                                                         cred->data.static_cred.username.slen); 
     703        obj->turn_username = PyString_FromPJ(&cred->data.static_cred.username); 
    1066704        obj->turn_passwd_type = cred->data.static_cred.data_type; 
    1067705        Py_XDECREF(obj->turn_passwd); 
    1068         obj->turn_passwd = PyString_FromStringAndSize(cred->data.static_cred.data.ptr,  
    1069                                                       cred->data.static_cred.data.slen); 
     706        obj->turn_passwd = PyString_FromPJ(&cred->data.static_cred.data); 
    1070707    } else { 
    1071708        Py_XDECREF(obj->turn_realm); 
     
    1104741 
    1105742    if (cfg->enable_turn) { 
    1106         cfg->turn_server = PyString_to_pj_str(obj->turn_server); 
     743        cfg->turn_server = PyString_ToPJ(obj->turn_server); 
    1107744        cfg->turn_conn_type = obj->turn_conn_type; 
    1108745        cfg->turn_auth_cred.type = PJ_STUN_AUTH_CRED_STATIC; 
    1109         cfg->turn_auth_cred.data.static_cred.realm = PyString_to_pj_str(obj->turn_realm); 
    1110         cfg->turn_auth_cred.data.static_cred.username = PyString_to_pj_str(obj->turn_username); 
     746        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); 
    1111748        cfg->turn_auth_cred.data.static_cred.data_type= obj->turn_passwd_type; 
    1112         cfg->turn_auth_cred.data.static_cred.data = PyString_to_pj_str(obj->turn_passwd); 
     749        cfg->turn_auth_cred.data.static_cred.data = PyString_ToPJ(obj->turn_passwd); 
    1113750    } 
    1114751} 
     
    1202839    obj->thread_cnt     = cfg->thread_cnt; 
    1203840    Py_XDECREF(obj->outbound_proxy); 
    1204     obj->outbound_proxy = PyString_FromStringAndSize(cfg->outbound_proxy[0].ptr, 
    1205                                                      cfg->outbound_proxy[0].slen); 
     841    if (cfg->outbound_proxy_cnt) 
     842        obj->outbound_proxy = PyString_FromPJ(&cfg->outbound_proxy[0]); 
     843    else 
     844        obj->outbound_proxy = PyString_FromString(""); 
     845 
    1206846    Py_XDECREF(obj->stun_domain); 
    1207     obj->stun_domain    = PyString_FromStringAndSize(cfg->stun_domain.ptr, 
    1208                                                      cfg->stun_domain.slen); 
     847    obj->stun_domain    = PyString_FromPJ(&cfg->stun_domain); 
    1209848    Py_XDECREF(obj->stun_host); 
    1210     obj->stun_host      = PyString_FromStringAndSize(cfg->stun_host.ptr, 
    1211                                                      cfg->stun_host.slen); 
     849    obj->stun_host      = PyString_FromPJ(&cfg->stun_host); 
    1212850    Py_XDECREF(obj->nameserver); 
    1213851    obj->nameserver = (PyListObject *)PyList_New(0); 
    1214852    for (i=0; i<cfg->nameserver_count; ++i) { 
    1215853        PyObject * str; 
    1216         str = PyString_FromStringAndSize(cfg->nameserver[i].ptr,  
    1217                                          cfg->nameserver[i].slen); 
     854        str = PyString_FromPJ(&cfg->nameserver[i]); 
    1218855        PyList_Append((PyObject *)obj->nameserver, str); 
    1219856    } 
    1220857    Py_XDECREF(obj->user_agent); 
    1221     obj->user_agent     = PyString_FromStringAndSize(cfg->user_agent.ptr, 
    1222                                                      cfg->user_agent.slen); 
     858    obj->user_agent     = PyString_FromPJ(&cfg->user_agent); 
    1223859} 
    1224860 
     
    1233869    if (PyString_Size(obj->outbound_proxy) > 0) { 
    1234870        cfg->outbound_proxy_cnt = 1; 
    1235         cfg->outbound_proxy[0] = PyString_to_pj_str(obj->outbound_proxy); 
     871        cfg->outbound_proxy[0] = PyString_ToPJ(obj->outbound_proxy); 
    1236872    } else { 
    1237873        cfg->outbound_proxy_cnt = 0; 
     
    1241877        cfg->nameserver_count = PJ_ARRAY_SIZE(cfg->nameserver); 
    1242878    for (i = 0; i < cfg->nameserver_count; i++) { 
    1243         cfg->nameserver[i] = PyString_to_pj_str(PyList_GetItem((PyObject *)obj->nameserver,i)); 
     879        PyObject *item = PyList_GetItem((PyObject *)obj->nameserver,i); 
     880        cfg->nameserver[i] = PyString_ToPJ(item); 
    1244881    } 
    1245     cfg->stun_domain    = PyString_to_pj_str(obj->stun_domain); 
    1246     cfg->stun_host      = PyString_to_pj_str(obj->stun_host); 
    1247     cfg->user_agent     = PyString_to_pj_str(obj->user_agent); 
     882    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); 
    1248885 
    1249886} 
     
    1260897 
    1261898    self = (PyObj_pjsua_config *)type->tp_alloc(type, 0); 
    1262     if (self != NULL) 
    1263     { 
     899    if (self != NULL) { 
    1264900        self->user_agent = PyString_FromString(""); 
    1265         if (self->user_agent == NULL) 
    1266         { 
    1267             Py_DECREF(self); 
    1268             return NULL; 
    1269         } 
    1270901        self->outbound_proxy = PyString_FromString(""); 
    1271         if (self->outbound_proxy == NULL) 
    1272         { 
    1273             Py_DECREF(self); 
    1274             return NULL; 
    1275         } 
     902        self->stun_domain = PyString_FromString(""); 
     903        self->stun_host = PyString_FromString(""); 
    1276904        self->cb = (PyObj_pjsua_callback *) 
    1277905                   PyType_GenericNew(&PyTyp_pjsua_callback, NULL, NULL); 
    1278         if (self->cb == NULL) 
    1279         { 
    1280             Py_DECREF(Py_None); 
    1281             return NULL; 
    1282         } 
    1283906    } 
    1284907    return (PyObject *)self; 
     
    14261049    obj->console_level  = cfg->console_level; 
    14271050    obj->decor          = cfg->decor; 
     1051    Py_XDECREF(obj->log_filename); 
     1052    obj->log_filename = PyString_FromPJ(&cfg->log_filename); 
    14281053} 
    14291054 
     
    14351060    cfg->console_level  = obj->console_level; 
    14361061    cfg->decor          = obj->decor; 
    1437     cfg->log_filename   = PyString_to_pj_str(obj->log_filename); 
     1062    cfg->log_filename   = PyString_ToPJ(obj->log_filename); 
    14381063} 
    14391064 
     
    14531078 
    14541079    self = (PyObj_pjsua_logging_config *)type->tp_alloc(type, 0); 
    1455     if (self != NULL) 
    1456     { 
     1080    if (self != NULL) { 
    14571081        self->log_filename = PyString_FromString(""); 
    1458         if (self->log_filename == NULL) 
    1459         { 
    1460             Py_DECREF(self); 
    1461             return NULL; 
    1462         } 
    1463         Py_INCREF(Py_None); 
    1464         self->cb = Py_None; 
    1465         if (self->cb == NULL) 
    1466         { 
    1467             Py_DECREF(Py_None); 
    1468             return NULL; 
    1469         } 
     1082        self->cb = Py_BuildValue(""); 
    14701083    } 
    14711084 
     
    16101223 
    16111224    self = (PyObj_pjsua_msg_data *)type->tp_alloc(type, 0); 
    1612     if (self != NULL) 
    1613     { 
    1614         Py_INCREF(Py_None); 
    1615         self->hdr_list = Py_None; 
    1616         if (self->hdr_list == NULL) { 
    1617             Py_DECREF(self); 
    1618             return NULL; 
    1619         } 
     1225    if (self != NULL) { 
     1226        self->hdr_list = PyList_New(0); 
    16201227        self->content_type = PyString_FromString(""); 
    1621         if (self->content_type == NULL) { 
    1622             Py_DECREF(self); 
    1623             return NULL; 
    1624         } 
    16251228        self->msg_body = PyString_FromString(""); 
    1626         if (self->msg_body == NULL) { 
    1627             Py_DECREF(self); 
    1628             return NULL; 
    1629         } 
    16301229    } 
    16311230 
     
    17381337                                                PyObj_pjsua_transport_config *obj) 
    17391338{ 
    1740     cfg->public_addr    = PyString_to_pj_str(obj->public_addr); 
    1741     cfg->bound_addr     = PyString_to_pj_str(obj->bound_addr); 
     1339    cfg->public_addr    = PyString_ToPJ(obj->public_addr); 
     1340    cfg->bound_addr     = PyString_ToPJ(obj->bound_addr); 
    17421341    cfg->port           = obj->port; 
    17431342 
     
    17481347{ 
    17491348    Py_XDECREF(obj->public_addr);     
    1750     obj->public_addr = PyString_FromStringAndSize(cfg->public_addr.ptr,  
    1751                                                   cfg->public_addr.slen); 
     1349    obj->public_addr = PyString_FromPJ(&cfg->public_addr); 
    17521350 
    17531351    Py_XDECREF(obj->bound_addr);     
    1754     obj->bound_addr = PyString_FromStringAndSize(cfg->bound_addr.ptr,  
    1755                                                  cfg->bound_addr.slen); 
     1352    obj->bound_addr = PyString_FromPJ(&cfg->bound_addr); 
    17561353 
    17571354    obj->port = cfg->port; 
     
    17751372    if (self != NULL) { 
    17761373        self->public_addr = PyString_FromString(""); 
    1777         if (self->public_addr == NULL) { 
    1778             Py_DECREF(self); 
    1779             return NULL; 
    1780         } 
    17811374        self->bound_addr = PyString_FromString(""); 
    1782         if (self->bound_addr == NULL) { 
    1783             Py_DECREF(self); 
    1784             return NULL; 
    1785         } 
    17861375    } 
    17871376 
     
    19121501    obj->id         = info->id; 
    19131502    obj->type       = info->type; 
    1914     obj->type_name  = PyString_FromStringAndSize(info->type_name.ptr, 
    1915                                                  info->type_name.slen); 
    1916     obj->info       = PyString_FromStringAndSize(info->info.ptr, 
    1917                                                  info->info.slen); 
     1503    obj->type_name  = PyString_FromPJ(&info->type_name); 
     1504    obj->info       = PyString_FromPJ(&info->info); 
    19181505    obj->flag       = info->flag; 
    1919     obj->addr       = PyString_FromStringAndSize(info->local_name.host.ptr, 
    1920                                                  info->local_name.host.slen); 
     1506    obj->addr       = PyString_FromPJ(&info->local_name.host); 
    19211507    obj->port       = info->local_name.port; 
    19221508    obj->usage_count= info->usage_count; 
     
    19401526    { 
    19411527        self->type_name = PyString_FromString(""); 
    1942         if (self->type_name == NULL) { 
    1943             Py_DECREF(self); 
    1944             return NULL; 
    1945         } 
    19461528        self->info = PyString_FromString("");  
    1947         if (self->info == NULL) { 
    1948             Py_DECREF(self); 
    1949             return NULL; 
    1950         } 
    19511529        self->addr = PyString_FromString(""); 
    1952         if (self->addr == NULL) { 
    1953             Py_DECREF(self); 
    1954             return NULL; 
    1955         } 
    19561530    } 
    19571531 
     
    19721546    { 
    19731547        "type", T_INT,  
    1974         offsetof(PyObj_pjsua_transport_info, id), 0, 
     1548        offsetof(PyObj_pjsua_transport_info, type), 0, 
    19751549        "Transport type." 
    19761550    }, 
     
    20721646    int              publish_enabled; 
    20731647    PyObject        *force_contact; 
    2074     /*pj_str_t proxy[8];*/ 
    20751648    PyListObject    *proxy; 
    20761649    unsigned         reg_timeout; 
    2077     /*pjsip_cred_info cred_info[8];*/ 
    20781650    PyListObject    *cred_info; 
    20791651    int              transport_id; 
    2080  
    20811652    int              auth_initial_send; 
    20821653    PyObject        *auth_initial_algorithm; 
     
    21161687    obj->priority   = cfg->priority; 
    21171688    Py_XDECREF(obj->id); 
    2118     obj->id         = PyString_FromStringAndSize(cfg->id.ptr, cfg->id.slen); 
     1689    obj->id         = PyString_FromPJ(&cfg->id); 
    21191690    Py_XDECREF(obj->reg_uri); 
    2120     obj->reg_uri    = PyString_FromStringAndSize(cfg->reg_uri.ptr,  
    2121                                                  cfg->reg_uri.slen); 
     1691    obj->reg_uri    = PyString_FromPJ(&cfg->reg_uri); 
    21221692    obj->publish_enabled = cfg->publish_enabled; 
    21231693    Py_XDECREF(obj->force_contact); 
    2124     obj->force_contact = PyString_FromStringAndSize(cfg->force_contact.ptr, 
    2125                                                     cfg->force_contact.slen); 
     1694    obj->force_contact = PyString_FromPJ(&cfg->force_contact); 
    21261695    Py_XDECREF(obj->proxy); 
    21271696    obj->proxy = (PyListObject *)PyList_New(0); 
    21281697    for (i=0; i<cfg->proxy_cnt; ++i) { 
    21291698        PyObject * str; 
    2130         str = PyString_FromStringAndSize(cfg->proxy[i].ptr,  
    2131                                          cfg->proxy[i].slen); 
     1699        str = PyString_FromPJ(&cfg->proxy[i]); 
    21321700        PyList_Append((PyObject *)obj->proxy, str); 
    21331701    } 
     
    21501718    obj->auth_initial_send = cfg->auth_pref.initial_auth; 
    21511719    Py_XDECREF(obj->auth_initial_algorithm); 
    2152     obj->auth_initial_algorithm = PyString_FromStringAndSize(cfg->auth_pref.algorithm.ptr,  
    2153                                                              cfg->auth_pref.algorithm.slen); 
     1720    obj->auth_initial_algorithm = PyString_FromPJ(&cfg->auth_pref.algorithm); 
    21541721    Py_XDECREF(obj->pidf_tuple_id); 
    2155     obj->pidf_tuple_id = PyString_FromStringAndSize(cfg->pidf_tuple_id.ptr,  
    2156                                                     cfg->pidf_tuple_id.slen); 
     1722    obj->pidf_tuple_id = PyString_FromPJ(&cfg->pidf_tuple_id); 
    21571723    obj->require_100rel = cfg->require_100rel; 
    21581724    obj->allow_contact_rewrite = cfg->allow_contact_rewrite; 
    21591725    obj->ka_interval = cfg->ka_interval; 
    21601726    Py_XDECREF(obj->ka_data); 
    2161     obj->ka_data = PyString_FromStringAndSize(cfg->ka_data.ptr, cfg->ka_data.slen); 
     1727    obj->ka_data = PyString_FromPJ(&cfg->ka_data); 
    21621728    obj->use_srtp = cfg->use_srtp; 
    21631729    obj->srtp_secure_signaling = cfg->srtp_secure_signaling; 
     
    21701736 
    21711737    cfg->priority   = obj->priority; 
    2172     cfg->id         = PyString_to_pj_str(obj->id); 
    2173     cfg->reg_uri    = PyString_to_pj_str(obj->reg_uri); 
     1738    cfg->id         = PyString_ToPJ(obj->id); 
     1739    cfg->reg_uri    = PyString_ToPJ(obj->reg_uri); 
    21741740    cfg->publish_enabled = obj->publish_enabled; 
    2175     cfg->force_contact = PyString_to_pj_str(obj->force_contact); 
     1741    cfg->force_contact = PyString_ToPJ(obj->force_contact); 
    21761742 
    21771743    cfg->proxy_cnt = PyList_Size((PyObject*)obj->proxy); 
     1744    if (cfg->proxy_cnt > PJ_ARRAY_SIZE(cfg->proxy)) 
     1745        cfg->proxy_cnt = PJ_ARRAY_SIZE(cfg->proxy); 
    21781746    for (i = 0; i < cfg->proxy_cnt; i++) { 
    2179         /*cfg.proxy[i] = ac->proxy[i];*/ 
    2180         cfg->proxy[i] = PyString_to_pj_str(PyList_GetItem((PyObject *)obj->proxy,i)); 
     1747        PyObject *item = PyList_GetItem((PyObject *)obj->proxy, i); 
     1748        cfg->proxy[i] = PyString_ToPJ(item); 
    21811749    } 
    21821750 
     
    21841752 
    21851753    cfg->cred_count = PyList_Size((PyObject*)obj->cred_info); 
     1754    if (cfg->cred_count > PJ_ARRAY_SIZE(cfg->cred_info)) 
     1755        cfg->cred_count = PJ_ARRAY_SIZE(cfg->cred_info); 
    21861756    for (i = 0; i < cfg->cred_count; i++) { 
    2187         /*cfg.cred_info[i] = ac->cred_info[i];*/ 
    21881757        PyObj_pjsip_cred_info *ci; 
    21891758        ci = (PyObj_pjsip_cred_info*)  
    2190              PyList_GetItem((PyObject *)obj->cred_info,i); 
     1759             PyList_GetItem((PyObject *)obj->cred_info, i); 
    21911760        PyObj_pjsip_cred_info_export(&cfg->cred_info[i], ci); 
    21921761    } 
     
    21941763    cfg->transport_id = obj->transport_id; 
    21951764    cfg->auth_pref.initial_auth = obj->auth_initial_send; 
    2196     cfg->auth_pref.algorithm = PyString_to_pj_str(obj->auth_initial_algorithm); 
    2197     cfg->pidf_tuple_id = PyString_to_pj_str(obj->pidf_tuple_id); 
     1765    cfg->auth_pref.algorithm = PyString_ToPJ(obj->auth_initial_algorithm); 
     1766    cfg->pidf_tuple_id = PyString_ToPJ(obj->pidf_tuple_id); 
    21981767    cfg->require_100rel = obj->require_100rel; 
    21991768    cfg->allow_contact_rewrite = obj->allow_contact_rewrite; 
    22001769    cfg->ka_interval = obj->ka_interval; 
    2201     cfg->ka_data = PyString_to_pj_str(obj->ka_data); 
     1770    cfg->ka_data = PyString_ToPJ(obj->ka_data); 
    22021771    cfg->use_srtp = obj->use_srtp; 
    22031772    cfg->srtp_secure_signaling = obj->srtp_secure_signaling; 
     
    22211790    if (self != NULL) { 
    22221791        self->id = PyString_FromString(""); 
    2223         if (self->id == NULL) { 
    2224             Py_DECREF(self); 
    2225             return NULL; 
    2226         } 
    22271792        self->reg_uri = PyString_FromString(""); 
    2228         if (self->reg_uri == NULL) { 
    2229             Py_DECREF(self); 
    2230             return NULL; 
    2231         } 
    22321793        self->force_contact = PyString_FromString(""); 
    2233         if (self->force_contact == NULL) { 
    2234             Py_DECREF(self); 
    2235             return NULL; 
    2236         } 
    22371794        self->proxy = (PyListObject *)PyList_New(0); 
    2238         if (self->proxy == NULL) { 
    2239             Py_DECREF(self); 
    2240             return NULL; 
    2241         } 
    22421795        self->cred_info = (PyListObject *)PyList_New(0); 
    2243         if (self->cred_info == NULL) { 
    2244             Py_DECREF(self); 
    2245             return NULL; 
    2246         } 
    22471796        self->auth_initial_algorithm = PyString_FromString(""); 
    22481797        self->pidf_tuple_id = PyString_FromString(""); 
     
    23051854    }, 
    23061855    { 
    2307         "reg_timeout", T_INT, offsetof(PyObj_pjsua_acc_config, reg_timeout), 0, 
     1856        "reg_timeout", T_INT,  
     1857        offsetof(PyObj_pjsua_acc_config, reg_timeout), 0, 
    23081858        "Optional interval for registration, in seconds. " 
    23091859        "If the value is zero, default interval will be used " 
     
    23281878        " use, so in that case it can set this field." 
    23291879    }, 
    2330      
    23311880    { 
    23321881        "auth_initial_send", T_INT, 
     
    23881937    PyObject_HEAD_INIT(NULL) 
    23891938    0,                              /*ob_size*/ 
    2390     "_pjsua.Acc_Config",      /*tp_name*/ 
    2391     sizeof(PyObj_pjsua_acc_config),  /*tp_basicsize*/ 
     1939    "_pjsua.Acc_Config",            /*tp_name*/ 
     1940    sizeof(PyObj_pjsua_acc_config), /*tp_basicsize*/ 
    23921941    0,                              /*tp_itemsize*/ 
    23931942    (destructor)PyObj_pjsua_acc_config_delete,/*tp_dealloc*/ 
     
    24071956    0,                              /*tp_as_buffer*/ 
    24081957    Py_TPFLAGS_DEFAULT,             /*tp_flags*/ 
    2409     "Acc Config objects",       /* tp_doc */ 
     1958    "Account settings",             /* tp_doc */ 
    24101959    0,                              /* tp_traverse */ 
    24111960    0,                              /* tp_clear */ 
     
    24141963    0,                              /* tp_iter */ 
    24151964    0,                              /* tp_iternext */ 
    2416     0/*acc_config_methods*/,                              /* tp_methods */ 
    2417     PyObj_pjsua_acc_config_members,         /* tp_members */ 
     1965    0,                              /* tp_methods */ 
     1966    PyObj_pjsua_acc_config_members, /* tp_members */ 
    24181967    0,                              /* tp_getset */ 
    24191968    0,                              /* tp_base */ 
     
    24241973    0,                              /* tp_init */ 
    24251974    0,                              /* tp_alloc */ 
    2426     PyObj_pjsua_acc_config_new,             /* tp_new */ 
     1975    PyObj_pjsua_acc_config_new,     /* tp_new */ 
    24271976 
    24281977}; 
     
    24682017    obj->id         = info->id; 
    24692018    obj->is_default = info->is_default; 
    2470     obj->acc_uri    = PyString_FromStringAndSize(info->acc_uri.ptr,  
    2471                                                  info->acc_uri.slen); 
     2019    Py_XDECREF(obj->acc_uri); 
     2020    obj->acc_uri    = PyString_FromPJ(&info->acc_uri); 
    24722021    obj->has_registration = info->has_registration; 
    24732022    obj->expires    = info->expires; 
    24742023    obj->status     = info->status; 
    2475     obj->status_text= PyString_FromStringAndSize(info->status_text.ptr, 
    2476                                                  info->status_text.slen); 
     2024    Py_XDECREF(obj->status_text); 
     2025    obj->status_text= PyString_FromPJ(&info->status_text); 
    24772026    obj->online_status = info->online_status; 
    2478     obj->online_status_text = PyString_FromStringAndSize(info->online_status_text.ptr, 
    2479                                                          info->online_status_text.slen); 
     2027    Py_XDECREF(obj->online_status_text); 
     2028    obj->online_status_text = PyString_FromPJ(&info->online_status_text); 
    24802029} 
    24812030 
     
    24972046    if (self != NULL) { 
    24982047        self->acc_uri = PyString_FromString(""); 
    2499         if (self->acc_uri == NULL) { 
    2500             Py_DECREF(self); 
    2501             return NULL; 
    2502         } 
    25032048        self->status_text = PyString_FromString(""); 
    2504         if (self->status_text == NULL) { 
    2505             Py_DECREF(self); 
    2506             return NULL; 
    2507         } 
    25082049        self->online_status_text = PyString_FromString(""); 
    2509         if (self->online_status_text == NULL) { 
    2510             Py_DECREF(self); 
    2511             return NULL; 
    2512         }         
    25132050    } 
    25142051 
     
    25822119    PyObject_HEAD_INIT(NULL) 
    25832120    0,                              /*ob_size*/ 
    2584     "_pjsua.Acc_Info",      /*tp_name*/ 
    2585     sizeof(PyObj_pjsua_acc_info),  /*tp_basicsize*/ 
     2121    "_pjsua.Acc_Info",              /*tp_name*/ 
     2122    sizeof(PyObj_pjsua_acc_info),   /*tp_basicsize*/ 
    25862123    0,                              /*tp_itemsize*/ 
    25872124    (destructor)PyObj_pjsua_acc_info_delete,/*tp_dealloc*/ 
     
    26012138    0,                              /*tp_as_buffer*/ 
    26022139    Py_TPFLAGS_DEFAULT,             /*tp_flags*/ 
    2603     "Acc Info objects",             /* tp_doc */ 
     2140    "Account info",                 /* tp_doc */ 
    26042141    0,                              /* tp_traverse */ 
    26052142    0,                              /* tp_clear */ 
     
    26532190{ 
    26542191    Py_XDECREF(obj->uri); 
    2655     obj->uri = PyString_FromStringAndSize(cfg->uri.ptr, cfg->uri.slen); 
     2192    obj->uri = PyString_FromPJ(&cfg->uri); 
    26562193    obj->subscribe = cfg->subscribe; 
    26572194} 
     
    26612198                                            PyObj_pjsua_buddy_config *obj) 
    26622199{ 
    2663     cfg->uri = PyString_to_pj_str(obj->uri); 
     2200    cfg->uri = PyString_ToPJ(obj->uri); 
    26642201    cfg->subscribe = obj->subscribe; 
    2665 } 
    2666  
     2202    cfg->user_data = NULL; 
     2203} 
    26672204 
    26682205 
     
    26832220    if (self != NULL) { 
    26842221        self->uri = PyString_FromString(""); 
    2685         if (self->uri == NULL) { 
    2686             Py_DECREF(self); 
    2687             return NULL; 
    2688         }         
    26892222    } 
    26902223    return (PyObject *)self; 
     
    27412274    0,                              /*tp_as_buffer*/ 
    27422275    Py_TPFLAGS_DEFAULT,             /*tp_flags*/ 
    2743     "Buddy Config objects",         /* tp_doc */ 
     2276    "Buddy config",                 /* tp_doc */ 
    27442277    0,                              /* tp_traverse */ 
    27452278    0,                              /* tp_clear */ 
     
    27492282    0,                              /* tp_iternext */ 
    27502283    0,                              /* tp_methods */ 
    2751     PyObj_pjsua_buddy_config_members,         /* tp_members */ 
     2284    PyObj_pjsua_buddy_config_members,/* tp_members */ 
    27522285    0,                              /* tp_getset */ 
    27532286    0,                              /* tp_base */ 
     
    28042337    obj->id = info->id; 
    28052338    Py_XDECREF(obj->uri); 
    2806     obj->uri = PyString_FromStringAndSize(info->uri.ptr, info->uri.slen); 
     2339    obj->uri = PyString_FromPJ(&info->uri); 
    28072340    Py_XDECREF(obj->contact); 
    2808     obj->contact = PyString_FromStringAndSize(info->contact.ptr, info->contact.slen); 
     2341    obj->contact = PyString_FromPJ(&info->contact); 
    28092342    obj->status = info->status; 
    28102343    Py_XDECREF(obj->status_text); 
    2811     obj->status_text = PyString_FromStringAndSize(info->status_text.ptr,  
    2812                                                   info->status_text.slen); 
     2344    obj->status_text = PyString_FromPJ(&info->status_text); 
    28132345    obj->monitor_pres = info->monitor_pres; 
    28142346    obj->activity = info->rpid.activity; 
    28152347    obj->sub_state = info->sub_state; 
    28162348    Py_XDECREF(obj->sub_term_reason); 
    2817     obj->sub_term_reason = PyString_FromStringAndSize(info->sub_term_reason.ptr,  
    2818                                                       info->sub_term_reason.slen); 
     2349    obj->sub_term_reason = PyString_FromPJ(&info->sub_term_reason); 
    28192350} 
    28202351 
     
    28372368    if (self != NULL) { 
    28382369        self->uri = PyString_FromString(""); 
    2839         if (self->uri == NULL) { 
    2840             Py_DECREF(self); 
    2841             return NULL; 
    2842         } 
    28432370        self->contact = PyString_FromString(""); 
    2844         if (self->contact == NULL) { 
    2845             Py_DECREF(self); 
    2846             return NULL; 
    2847         } 
    28482371        self->status_text = PyString_FromString(""); 
    2849         if (self->status_text == NULL) { 
    2850             Py_DECREF(self); 
    2851             return NULL; 
    2852         } 
    28532372        self->sub_term_reason = PyString_FromString(""); 
    28542373    } 
     
    29242443    PyObject_HEAD_INIT(NULL) 
    29252444    0,                              /*ob_size*/ 
    2926     "_pjsua.Buddy_Info",      /*tp_name*/ 
    2927     sizeof(PyObj_pjsua_buddy_info),  /*tp_basicsize*/ 
     2445    "_pjsua.Buddy_Info",            /*tp_name*/ 
     2446    sizeof(PyObj_pjsua_buddy_info), /*tp_basicsize*/ 
    29282447    0,                              /*tp_itemsize*/ 
    29292448    (destructor)PyObj_pjsua_buddy_info_delete,/*tp_dealloc*/ 
     
    29432462    0,                              /*tp_as_buffer*/ 
    29442463    Py_TPFLAGS_DEFAULT,             /*tp_flags*/ 
    2945     "Buddy Info objects",       /* tp_doc */ 
     2464    "Buddy Info object",            /* tp_doc */ 
    29462465    0,                              /* tp_traverse */ 
    29472466    0,                              /* tp_clear */ 
     
    29512470    0,                              /* tp_iternext */ 
    29522471    0,                              /* tp_methods */ 
    2953     PyObj_pjsua_buddy_info_members,         /* tp_members */ 
     2472    PyObj_pjsua_buddy_info_members, /* tp_members */ 
    29542473    0,                              /* tp_getset */ 
    29552474    0,                              /* tp_base */ 
     
    29602479    0,                              /* tp_init */ 
    29612480    0,                              /* tp_alloc */ 
    2962     PyObj_pjsua_buddy_info_new,             /* tp_new */ 
    2963  
    2964 }; 
    2965  
    2966  
    2967  
    2968  
     2481    PyObj_pjsua_buddy_info_new,     /* tp_new */ 
     2482 
     2483}; 
     2484 
     2485 
     2486////////////////////////////////////////////////////////////////////////////// 
     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 
     2700 
     2701 
     2702/* 
     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; 
     2989    pj_uint8_t  enc_fmtp_mode; 
     2990    pj_uint8_t  dec_fmtp_mode;  
     2991 
     2992} PyObj_pjmedia_codec_param_setting; 
     2993 
     2994 
     2995 
     2996/* 
     2997 * pjmedia_codec_param_setting_members 
     2998 */ 
     2999static PyMemberDef pjmedia_codec_param_setting_members[] = 
     3000{ 
     3001    { 
     3002        "frm_per_pkt", T_INT,  
     3003        offsetof(PyObj_pjmedia_codec_param_setting, frm_per_pkt), 0, 
     3004        "Number of frames per packet" 
     3005    }, 
     3006    { 
     3007        "vad", T_INT,  
     3008        offsetof(PyObj_pjmedia_codec_param_setting, vad), 0, 
     3009        "Voice Activity Detector" 
     3010    }, 
     3011    { 
     3012        "cng", T_INT,  
     3013        offsetof(PyObj_pjmedia_codec_param_setting, cng), 0, 
     3014        "Comfort Noise Generator" 
     3015    }, 
     3016    { 
     3017        "penh", T_INT,  
     3018        offsetof(PyObj_pjmedia_codec_param_setting, penh), 0, 
     3019        "Perceptual Enhancement" 
     3020    }, 
     3021    { 
     3022        "plc", T_INT,  
     3023        offsetof(PyObj_pjmedia_codec_param_setting, plc), 0, 
     3024        "Packet loss concealment" 
     3025    }, 
     3026    { 
     3027        "enc_fmtp_mode", T_INT,  
     3028        offsetof(PyObj_pjmedia_codec_param_setting, enc_fmtp_mode), 0, 
     3029        "Mode param in fmtp (def:0)" 
     3030    }, 
     3031    { 
     3032        "dec_fmtp_mode", T_INT,  
     3033        offsetof(PyObj_pjmedia_codec_param_setting, dec_fmtp_mode), 0, 
     3034        "Mode param in fmtp (def:0)" 
     3035    }, 
     3036     
     3037    {NULL}  /* Sentinel */ 
     3038}; 
     3039 
     3040 
     3041/* 
     3042 * PyTyp_pjmedia_codec_param_setting 
     3043 */ 
     3044static PyTypeObject PyTyp_pjmedia_codec_param_setting = 
     3045{ 
     3046    PyObject_HEAD_INIT(NULL) 
     3047    0,                              /*ob_size*/ 
     3048    "_pjsua.PJMedia_Codec_Param_Setting",/*tp_name*/ 
     3049    sizeof(PyObj_pjmedia_codec_param_setting),  /*tp_basicsize*/ 
     3050    0,                              /*tp_itemsize*/ 
     3051    0,                              /*tp_dealloc*/ 
     3052    0,                              /*tp_print*/ 
     3053    0,                              /*tp_getattr*/ 
     3054    0,                              /*tp_setattr*/ 
     3055    0,                              /*tp_compare*/ 
     3056    0,                              /*tp_repr*/ 
     3057    0,                              /*tp_as_number*/ 
     3058    0,                              /*tp_as_sequence*/ 
     3059    0,                              /*tp_as_mapping*/ 
     3060    0,                              /*tp_hash */ 
     3061    0,                              /*tp_call*/ 
     3062    0,                              /*tp_str*/ 
     3063    0,                              /*tp_getattro*/ 
     3064    0,                              /*tp_setattro*/ 
     3065    0,                              /*tp_as_buffer*/ 
     3066    Py_TPFLAGS_DEFAULT,             /*tp_flags*/ 
     3067    "PJMedia Codec Param Setting",  /* tp_doc */ 
     3068    0,                              /* tp_traverse */ 
     3069    0,                              /* tp_clear */ 
     3070    0,                              /* tp_richcompare */ 
     3071    0,                              /* tp_weaklistoffset */ 
     3072    0,                              /* tp_iter */ 
     3073    0,                              /* tp_iternext */ 
     3074    0,                              /* tp_methods */ 
     3075    pjmedia_codec_param_setting_members,/* tp_members */ 
     3076}; 
     3077 
     3078////////////////////////////////////////////////////////////////////////////// 
     3079 
     3080 
     3081/* 
     3082 * PyObj_pjmedia_codec_param 
     3083 * PJMedia Codec Param 
     3084 */ 
     3085typedef struct 
     3086{ 
     3087    PyObject_HEAD 
     3088    /* Type-specific fields go here. */  
     3089     
     3090    PyObj_pjmedia_codec_param_info * info; 
     3091    PyObj_pjmedia_codec_param_setting * setting; 
     3092 
     3093} PyObj_pjmedia_codec_param; 
     3094 
     3095/* 
     3096 * pjmedia_codec_param_dealloc 
     3097 * deletes a pjmedia_codec_param from memory 
     3098 */ 
     3099static void pjmedia_codec_param_dealloc(PyObj_pjmedia_codec_param* self) 
     3100{ 
     3101    Py_XDECREF(self->info);         
     3102    Py_XDECREF(self->setting);         
     3103    self->ob_type->tp_free((PyObject*)self); 
     3104} 
     3105 
     3106/* 
     3107 * pjmedia_codec_param_new 
     3108 * constructor for pjmedia_codec_param object 
     3109 */ 
     3110static PyObject * pjmedia_codec_param_new(PyTypeObject *type,  
     3111                                          PyObject *args, 
     3112                                          PyObject *kwds) 
     3113{ 
     3114    PyObj_pjmedia_codec_param *self; 
     3115 
     3116    PJ_UNUSED_ARG(args); 
     3117    PJ_UNUSED_ARG(kwds); 
     3118 
     3119    self = (PyObj_pjmedia_codec_param *)type->tp_alloc(type, 0); 
     3120    if (self != NULL) { 
     3121        self->info = (PyObj_pjmedia_codec_param_info *) 
     3122                     PyType_GenericNew(&PyTyp_pjmedia_codec_param_info,  
     3123                                       NULL, NULL); 
     3124        self->setting = (PyObj_pjmedia_codec_param_setting *) 
     3125                        PyType_GenericNew(&PyTyp_pjmedia_codec_param_setting, 
     3126                                          NULL, NULL); 
     3127    } 
     3128    return (PyObject *)self; 
     3129} 
     3130 
     3131/* 
     3132 * pjmedia_codec_param_members 
     3133 */ 
     3134static PyMemberDef pjmedia_codec_param_members[] = 
     3135{    
     3136     
     3137    { 
     3138        "info", T_OBJECT_EX, 
     3139        offsetof(PyObj_pjmedia_codec_param, info), 0, 
     3140        "The 'info' part of codec param describes the capability of the codec," 
     3141        " and the value should NOT be changed by application."         
     3142    }, 
     3143    { 
     3144        "setting", T_OBJECT_EX, 
     3145        offsetof(PyObj_pjmedia_codec_param, setting), 0,  
     3146        "The 'setting' part of codec param describes various settings to be " 
     3147        "applied to the codec. When the codec param is retrieved from the " 
     3148        "codec or codec factory, the values of these will be filled by " 
     3149        "the capability of the codec. Any features that are supported by " 
     3150        "the codec (e.g. vad or plc) will be turned on, so that application " 
     3151        "can query which capabilities are supported by the codec. " 
     3152        "Application may change the settings here before instantiating " 
     3153        "the codec/stream."         
     3154    }, 
     3155     
     3156    {NULL}  /* Sentinel */ 
     3157}; 
     3158 
     3159/* 
     3160 * PyTyp_pjmedia_codec_param 
     3161 */ 
     3162static PyTypeObject PyTyp_pjmedia_codec_param = 
     3163{ 
     3164    PyObject_HEAD_INIT(NULL) 
     3165    0,                              /*ob_size*/ 
     3166    "_pjsua.PJMedia_Codec_Param",   /*tp_name*/ 
     3167    sizeof(PyObj_pjmedia_codec_param),/*tp_basicsize*/ 
     3168    0,                              /*tp_itemsize*/ 
     3169    (destructor)pjmedia_codec_param_dealloc,/*tp_dealloc*/ 
     3170    0,                              /*tp_print*/ 
     3171    0,                              /*tp_getattr*/ 
     3172    0,                              /*tp_setattr*/ 
     3173    0,                              /*tp_compare*/ 
     3174    0,                              /*tp_repr*/ 
     3175    0,                              /*tp_as_number*/ 
     3176    0,                              /*tp_as_sequence*/ 
     3177    0,                              /*tp_as_mapping*/ 
     3178    0,                              /*tp_hash */ 
     3179    0,                              /*tp_call*/ 
     3180    0,                              /*tp_str*/ 
     3181    0,                              /*tp_getattro*/ 
     3182    0,                              /*tp_setattro*/ 
     3183    0,                              /*tp_as_buffer*/ 
     3184    Py_TPFLAGS_DEFAULT,             /*tp_flags*/ 
     3185    "PJMedia Codec Param",          /* tp_doc */ 
     3186    0,                              /* tp_traverse */ 
     3187    0,                              /* tp_clear */ 
     3188    0,                              /* tp_richcompare */ 
     3189    0,                              /* tp_weaklistoffset */ 
     3190    0,                              /* tp_iter */ 
     3191    0,                              /* tp_iternext */ 
     3192    0,                              /* tp_methods */ 
     3193    pjmedia_codec_param_members,    /* tp_members */ 
     3194    0,                              /* tp_getset */ 
     3195    0,                              /* tp_base */ 
     3196    0,                              /* tp_dict */ 
     3197    0,                              /* tp_descr_get */ 
     3198    0,                              /* tp_descr_set */ 
     3199    0,                              /* tp_dictoffset */ 
     3200    0,                              /* tp_init */ 
     3201    0,                              /* tp_alloc */ 
     3202    pjmedia_codec_param_new,        /* tp_new */ 
     3203 
     3204}; 
     3205 
     3206////////////////////////////////////////////////////////////////////////////// 
     3207 
     3208/* 
     3209 * PyObj_pjsua_call_info 
     3210 * Call Info 
     3211 */ 
     3212typedef struct 
     3213{ 
     3214    PyObject_HEAD 
     3215    /* Type-specific fields go here. */  
     3216     
     3217    int          id; 
     3218    int          role; 
     3219    int          acc_id; 
     3220    PyObject    *local_info; 
     3221    PyObject    *local_contact; 
     3222    PyObject    *remote_info; 
     3223    PyObject    *remote_contact; 
     3224    PyObject    *call_id; 
     3225    int          state; 
     3226    PyObject    *state_text; 
     3227    int          last_status; 
     3228    PyObject    *last_status_text; 
     3229    int          media_status; 
     3230    int          media_dir; 
     3231    int          conf_slot; 
     3232    int          connect_duration; 
     3233    int          total_duration; 
     3234 
     3235} PyObj_pjsua_call_info; 
     3236 
     3237 
     3238/* 
     3239 * call_info_dealloc 
     3240 * deletes a call_info from memory 
     3241 */ 
     3242static void call_info_dealloc(PyObj_pjsua_call_info* self) 
     3243{ 
     3244    Py_XDECREF(self->local_info); 
     3245    Py_XDECREF(self->local_contact); 
     3246    Py_XDECREF(self->remote_info); 
     3247    Py_XDECREF(self->remote_contact); 
     3248    Py_XDECREF(self->call_id); 
     3249    Py_XDECREF(self->state_text); 
     3250    Py_XDECREF(self->last_status_text); 
     3251    self->ob_type->tp_free((PyObject*)self); 
     3252} 
     3253 
     3254 
     3255/* 
     3256 * call_info_new 
     3257 * constructor for call_info object 
     3258 */ 
     3259static PyObject * call_info_new(PyTypeObject *type, PyObject *args, 
     3260                                    PyObject *kwds) 
     3261{ 
     3262    PyObj_pjsua_call_info *self; 
     3263 
     3264    PJ_UNUSED_ARG(args); 
     3265    PJ_UNUSED_ARG(kwds); 
     3266 
     3267    self = (PyObj_pjsua_call_info *)type->tp_alloc(type, 0); 
     3268    if (self != NULL) { 
     3269        self->local_info = PyString_FromString(""); 
     3270        self->local_contact = PyString_FromString(""); 
     3271        self->remote_info = PyString_FromString(""); 
     3272        self->remote_contact = PyString_FromString(""); 
     3273        self->call_id = PyString_FromString(""); 
     3274        self->state_text = PyString_FromString(""); 
     3275        self->last_status_text = PyString_FromString(""); 
     3276    } 
     3277    return (PyObject *)self; 
     3278} 
     3279 
     3280/* 
     3281 * call_info_members 
     3282 */ 
     3283static PyMemberDef call_info_members[] = 
     3284{    
     3285    { 
     3286        "id", T_INT,  
     3287        offsetof(PyObj_pjsua_call_info, id), 0, 
     3288        "Call identification" 
     3289    }, 
     3290    { 
     3291        "role", T_INT,  
     3292        offsetof(PyObj_pjsua_call_info, role), 0, 
     3293        "Initial call role (UAC == caller)" 
     3294    }, 
     3295    { 
     3296        "acc_id", T_INT,  
     3297        offsetof(PyObj_pjsua_call_info, acc_id), 0, 
     3298        "The account ID where this call belongs." 
     3299    }, 
     3300    { 
     3301        "local_info", T_OBJECT_EX, 
     3302        offsetof(PyObj_pjsua_call_info, local_info), 0, 
     3303        "Local URI"         
     3304    }, 
     3305    { 
     3306        "local_contact", T_OBJECT_EX, 
     3307        offsetof(PyObj_pjsua_call_info, local_contact), 0, 
     3308        "Local Contact"         
     3309    }, 
     3310    { 
     3311        "remote_info", T_OBJECT_EX, 
     3312        offsetof(PyObj_pjsua_call_info, remote_info), 0, 
     3313        "Remote URI"         
     3314    }, 
     3315    { 
     3316        "remote_contact", T_OBJECT_EX, 
     3317        offsetof(PyObj_pjsua_call_info, remote_contact), 0, 
     3318        "Remote Contact"         
     3319    }, 
     3320    { 
     3321        "call_id", T_OBJECT_EX, 
     3322        offsetof(PyObj_pjsua_call_info, call_id), 0, 
     3323        "Dialog Call-ID string"         
     3324    }, 
     3325    { 
     3326        "state", T_INT,  
     3327        offsetof(PyObj_pjsua_call_info, state), 0, 
     3328        "Call state" 
     3329    }, 
     3330    { 
     3331        "state_text", T_OBJECT_EX, 
     3332        offsetof(PyObj_pjsua_call_info, state_text), 0, 
     3333        "Text describing the state "         
     3334    }, 
     3335    { 
     3336        "last_status", T_INT,  
     3337        offsetof(PyObj_pjsua_call_info, last_status), 0, 
     3338        "Last status code heard, which can be used as cause code" 
     3339    }, 
     3340    { 
     3341        "last_status_text", T_OBJECT_EX, 
     3342        offsetof(PyObj_pjsua_call_info, last_status_text), 0, 
     3343        "The reason phrase describing the status."         
     3344    }, 
     3345    { 
     3346        "media_status", T_INT,  
     3347        offsetof(PyObj_pjsua_call_info, media_status), 0, 
     3348        "Call media status." 
     3349    }, 
     3350    { 
     3351        "media_dir", T_INT,  
     3352        offsetof(PyObj_pjsua_call_info, media_dir), 0, 
     3353        "Media direction" 
     3354    }, 
     3355    { 
     3356        "conf_slot", T_INT,  
     3357        offsetof(PyObj_pjsua_call_info, conf_slot), 0, 
     3358        "The conference port number for the call" 
     3359    }, 
     3360    { 
     3361        "connect_duration", T_INT, 
     3362        offsetof(PyObj_pjsua_call_info, connect_duration), 0, 
     3363        "Up-to-date call connected duration(zero when call is not established)" 
     3364    }, 
     3365    { 
     3366        "total_duration", T_INT, 
     3367        offsetof(PyObj_pjsua_call_info, total_duration), 0, 
     3368        "Total call duration, including set-up time"         
     3369    }, 
     3370     
     3371    {NULL}  /* Sentinel */ 
     3372}; 
     3373 
     3374 
     3375 
     3376 
     3377/* 
     3378 * PyTyp_pjsua_call_info 
     3379 */ 
     3380static PyTypeObject PyTyp_pjsua_call_info = 
     3381{ 
     3382    PyObject_HEAD_INIT(NULL) 
     3383    0,                              /*ob_size*/ 
     3384    "_pjsua.Call_Info",             /*tp_name*/ 
     3385    sizeof(PyObj_pjsua_call_info),  /*tp_basicsize*/ 
     3386    0,                              /*tp_itemsize*/ 
     3387    (destructor)call_info_dealloc,  /*tp_dealloc*/ 
     3388    0,                              /*tp_print*/ 
     3389    0,                              /*tp_getattr*/ 
     3390    0,                              /*tp_setattr*/ 
     3391    0,                              /*tp_compare*/ 
     3392    0,                              /*tp_repr*/ 
     3393    0,                              /*tp_as_number*/ 
     3394    0,                              /*tp_as_sequence*/ 
     3395    0,                              /*tp_as_mapping*/ 
     3396    0,                              /*tp_hash */ 
     3397    0,                              /*tp_call*/ 
     3398    0,                              /*tp_str*/ 
     3399    0,                              /*tp_getattro*/ 
     3400    0,                              /*tp_setattro*/ 
     3401    0,                              /*tp_as_buffer*/ 
     3402    Py_TPFLAGS_DEFAULT,             /*tp_flags*/ 
     3403    "Call Info",                    /* tp_doc */ 
     3404    0,                              /* tp_traverse */ 
     3405    0,                              /* tp_clear */ 
     3406    0,                              /* tp_richcompare */ 
     3407    0,                              /* tp_weaklistoffset */ 
     3408    0,                              /* tp_iter */ 
     3409    0,                              /* tp_iternext */ 
     3410    0,                              /* tp_methods */ 
     3411    call_info_members,              /* tp_members */ 
     3412    0,                              /* tp_getset */ 
     3413    0,                              /* tp_base */ 
     3414    0,                              /* tp_dict */ 
     3415    0,                              /* tp_descr_get */ 
     3416    0,                              /* tp_descr_set */ 
     3417    0,                              /* tp_dictoffset */ 
     3418    0,                              /* tp_init */ 
     3419    0,                              /* tp_alloc */ 
     3420    call_info_new,                  /* tp_new */ 
     3421 
     3422}; 
     3423 
     3424 
     3425 
     3426////////////////////////////////////////////////////////////////////////////// 
    29693427 
    29703428#endif  /* __PY_PJSUA_H__ */ 
Note: See TracChangeset for help on using the changeset viewer.