Changeset 924


Ignore:
Timestamp:
Feb 1, 2007 7:41:26 AM (17 years ago)
Author:
fahris
Message:

py_pjsua update 010207

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.c

    r918 r924  
    2222 
    2323#define THIS_FILE    "main.c" 
     24#define POOL_SIZE    4000 
     25#define SND_DEV_NUM  64 
    2426 
    2527/* LIB BASE */ 
     
    195197        pjsip_event_Object * obj; 
    196198                 
    197             obj = 
     199        obj = 
    198200                (pjsip_event_Object *)PyType_GenericNew(&pjsip_event_Type,  
    199201                                                    NULL, NULL); 
    200202                 
    201             obj->event = e; 
     203        obj->event = e; 
    202204                 
    203205        PyObject_CallFunctionObjArgs( 
     
    13031305        pj_list_init(hdr); 
    13041306 
    1305         for (i = 0; i < PyList_Size(py_hdr_list); i++) {  
     1307        for (i = 0; i < PyList_Size(py_hdr_list); i++)  
     1308        {  
    13061309            pj_str_t hname, hvalue; 
    13071310            pjsip_generic_string_hdr * new_hdr; 
    13081311            PyObject * tuple = PyList_GetItem(py_hdr_list, i); 
    13091312 
    1310             if (PyTuple_Check(tuple)) { 
     1313            if (PyTuple_Check(tuple))  
     1314            { 
    13111315                hname.ptr = PyString_AsString(PyTuple_GetItem(tuple,0)); 
    13121316                hname.slen = strlen(PyString_AsString 
     
    13411345    len = pj_list_size(hdr); 
    13421346     
    1343     if (len > 0) { 
    1344         p_hdr = hdr; 
     1347    if (len > 0)  
     1348    { 
     1349        p_hdr = hdr; 
    13451350        Py_XDECREF(py_hdr_list); 
    13461351        py_hdr_list = PyList_New(len); 
    13471352 
    1348         for (i = 0; i < len && p_hdr != NULL; i++) { 
    1349             PyObject * tuple; 
    1350             PyObject * str; 
    1351  
    1352             tuple = PyTuple_New(2); 
     1353        for (i = 0; i < len && p_hdr != NULL; i++)  
     1354        { 
     1355            PyObject * tuple; 
     1356            PyObject * str; 
     1357 
     1358            tuple = PyTuple_New(2); 
    13531359             
    1354             str = PyString_FromStringAndSize(p_hdr->name.ptr, p_hdr->name.slen); 
    1355             PyTuple_SetItem(tuple, 0, str); 
    1356             str = PyString_FromStringAndSize(hdr->hvalue.ptr, p_hdr->hvalue.slen); 
    1357             PyTuple_SetItem(tuple, 1, str); 
    1358             PyList_SetItem(py_hdr_list, i, tuple); 
    1359             p_hdr = p_hdr->next; 
     1360            str = PyString_FromStringAndSize(p_hdr->name.ptr, p_hdr->name.slen); 
     1361            PyTuple_SetItem(tuple, 0, str); 
     1362            str = PyString_FromStringAndSize 
     1363                (hdr->hvalue.ptr, p_hdr->hvalue.slen); 
     1364            PyTuple_SetItem(tuple, 1, str); 
     1365            PyList_SetItem(py_hdr_list, i, tuple); 
     1366            p_hdr = p_hdr->next; 
    13601367        } 
    13611368    } 
     
    15551562    Py_XDECREF(self->realm); 
    15561563    Py_XDECREF(self->scheme); 
    1557         Py_XDECREF(self->username); 
    1558         Py_XDECREF(self->data); 
     1564    Py_XDECREF(self->username); 
     1565    Py_XDECREF(self->data); 
    15591566    self->ob_type->tp_free((PyObject*)self); 
    15601567} 
     
    17091716    size = PyList_Size(py_desc); 
    17101717    td = (int *)malloc(size * sizeof(int)); 
    1711     for (i = 0; i < size; i++) { 
    1712         if (!PyArg_Parse(PyList_GetItem(py_desc,i),"i", td[i])) { 
     1718    for (i = 0; i < size; i++)  
     1719    { 
     1720        if (!PyArg_Parse(PyList_GetItem(py_desc,i),"i", td[i]))  
     1721        { 
    17131722            return NULL; 
    17141723        } 
     
    17411750     
    17421751    pjsua_logging_config_default(&cfg); 
    1743         obj = (logging_config_Object *) logging_config_new 
     1752    obj = (logging_config_Object *) logging_config_new 
    17441753                (&logging_config_Type,NULL,NULL); 
    17451754    obj->msg_logging = cfg.msg_logging; 
     
    17661775    } 
    17671776    pjsua_config_default(&cfg); 
    1768         obj = (config_Object *) config_new(&config_Type, NULL, NULL); 
     1777    obj = (config_Object *) config_new(&config_Type, NULL, NULL); 
    17691778    obj->max_calls = cfg.max_calls; 
    17701779    obj->thread_cnt = cfg.thread_cnt; 
     
    18401849static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, PyObject *pArgs) 
    18411850{ 
    1842         PyObject * logObj; 
     1851    PyObject * logObj; 
    18431852    logging_config_Object *log; 
    18441853    pjsua_logging_config cfg; 
     
    18491858        return NULL; 
    18501859    } 
    1851     if (logObj != Py_None) { 
     1860    if (logObj != Py_None)  
     1861    { 
    18521862        log = (logging_config_Object *)logObj; 
    18531863        cfg.msg_logging = log->msg_logging; 
     
    18641874    } else { 
    18651875        status = pjsua_reconfigure_logging(NULL); 
    1866         } 
     1876    } 
    18671877    return Py_BuildValue("i",status); 
    18681878} 
     
    19891999    status = pjsua_create(); 
    19902000     
    1991     if (status == PJ_SUCCESS) { 
     2001    if (status == PJ_SUCCESS)  
     2002    { 
    19922003        status = pj_thread_local_alloc(&thread_id); 
    19932004        if (status == PJ_SUCCESS) 
     
    20292040    pjsua_media_config_default(&cfg_media); 
    20302041 
    2031     if (ua_cfgObj != Py_None) { 
     2042    if (ua_cfgObj != Py_None)  
     2043    { 
    20322044        ua_cfg = (config_Object *)ua_cfgObj; 
    20332045        cfg_ua.cred_count = ua_cfg->cred_count; 
     
    20682080    } 
    20692081 
    2070     if (log_cfgObj != Py_None) { 
     2082    if (log_cfgObj != Py_None)  
     2083    { 
    20712084        log_cfg = (logging_config_Object *)log_cfgObj; 
    20722085        cfg_log.msg_logging = log_cfg->msg_logging; 
     
    20852098    } 
    20862099 
    2087     if (media_cfgObj != Py_None) { 
     2100    if (media_cfgObj != Py_None)  
     2101    { 
    20882102        media_cfg = (media_config_Object *)media_cfgObj; 
    20892103        cfg_media.clock_rate = media_cfg->clock_rate; 
     
    21842198    "void py_pjsua.perror (string sender, string title, int status) " 
    21852199    "Display error message for the specified error code. Parameters: " 
    2186         "sender: The log sender field;  " 
    2187         "title: Message title for the error; " 
    2188         "status: Status code."; 
     2200    "sender: The log sender field;  " 
     2201    "title: Message title for the error; " 
     2202    "status: Status code."; 
    21892203 
    21902204static char pjsua_create_doc[] = 
     
    22022216    "optional, and the default values will be used when the config is not " 
    22032217    "specified. Parameters: " 
    2204         "ua_cfg : User agent configuration;  " 
    2205         "log_cfg : Optional logging configuration; " 
    2206         "media_cfg : Optional media configuration."; 
     2218    "ua_cfg : User agent configuration;  " 
     2219    "log_cfg : Optional logging configuration; " 
     2220    "media_cfg : Optional media configuration."; 
    22072221 
    22082222static char pjsua_start_doc[] = 
     
    22222236    "Poll pjsua for events, and if necessary block the caller thread for the " 
    22232237    "specified maximum interval (in miliseconds) Parameters: " 
    2224         "msec_timeout: Maximum time to wait, in miliseconds. " 
     2238    "msec_timeout: Maximum time to wait, in miliseconds. " 
    22252239    "Returns: The number of events that have been handled during the poll. " 
    22262240    "Negative value indicates error, and application can retrieve the error " 
     
    22302244    "int py_pjsua.verify_sip_url (string c_url) " 
    22312245    "Verify that valid SIP url is given Parameters: " 
    2232         "c_url: The URL, as NULL terminated string."; 
     2246    "c_url: The URL, as NULL terminated string."; 
    22332247 
    22342248static char pjsua_pool_create_doc[] = 
     
    22362250                                            "int increment) " 
    22372251    "Create memory pool Parameters: " 
    2238         "name: Optional pool name; " 
    2239         "init_size: Initial size of the pool;  " 
    2240         "increment: Increment size."; 
     2252    "name: Optional pool name; " 
     2253    "init_size: Initial size of the pool;  " 
     2254    "increment: Increment size."; 
    22412255 
    22422256static char pjsua_get_pjsip_endpt_doc[] = 
     
    22602274    "Application can call this function at any time (after pjsua_create(), of " 
    22612275    "course) to change logging settings. Parameters: " 
    2262         "c: Logging configuration."; 
     2276    "c: Logging configuration."; 
    22632277 
    22642278static char pjsua_logging_config_default_doc[] = 
     
    24602474    if (self != NULL) 
    24612475    { 
    2462                 self->public_addr = PyString_FromString(""); 
     2476        self->public_addr = PyString_FromString(""); 
    24632477        if (self->public_addr == NULL) 
    24642478        { 
     
    27192733    /* Type-specific fields go here. */ 
    27202734    PyObject * host; 
    2721         int port; 
     2735    int port; 
    27222736} host_port_Object; 
    27232737 
     
    30603074         
    30613075    pjsua_stun_config_default(&cfg); 
    3062         obj = (stun_config_Object *)stun_config_new(&stun_config_Type, NULL, NULL); 
     3076    obj = (stun_config_Object *)stun_config_new(&stun_config_Type, NULL, NULL); 
    30633077    obj->stun_port1 = cfg.stun_port1; 
    30643078    obj->stun_port2 = cfg.stun_port2; 
     
    30873101    } 
    30883102    pjsua_transport_config_default(&cfg); 
    3089         obj = (transport_config_Object *)transport_config_new 
     3103    obj = (transport_config_Object *)transport_config_new 
    30903104                (&transport_config_Type,NULL,NULL); 
    30913105    obj->public_addr =  
     
    31173131(PyObject *pSelf, PyObject *pArgs) 
    31183132{ 
    3119         PyObject * tmpObj; 
     3133    PyObject * tmpObj; 
    31203134    stun_config_Object *obj; 
    31213135    pjsua_stun_config *cfg; 
     
    31253139        return NULL; 
    31263140    } 
    3127         if (tmpObj != Py_None) 
    3128         { 
    3129                 obj = (stun_config_Object *) tmpObj; 
     3141    if (tmpObj != Py_None) 
     3142    { 
     3143        obj = (stun_config_Object *) tmpObj; 
    31303144        cfg = (pjsua_stun_config *)malloc(sizeof(pjsua_stun_config)); 
    31313145        cfg->stun_port1 = obj->stun_port1; 
     
    31353149        cfg->stun_srv2.ptr = PyString_AsString(obj->stun_srv2); 
    31363150        cfg->stun_srv2.slen = strlen(PyString_AsString(obj->stun_srv2)); 
    3137         } else { 
    3138                 cfg = NULL; 
    3139         } 
     3151    } else { 
     3152        cfg = NULL; 
     3153    } 
    31403154    pjsua_normalize_stun_config(cfg); 
    31413155    obj->stun_port1 = cfg->stun_port1; 
     
    31613175    int type; 
    31623176     
    3163         PyObject * tmpObj; 
     3177    PyObject * tmpObj; 
    31643178    transport_config_Object *obj; 
    31653179    pjsua_transport_config cfg; 
     
    31693183        return NULL; 
    31703184    } 
    3171         if (tmpObj != Py_None) 
    3172         { 
     3185    if (tmpObj != Py_None) 
     3186    { 
    31733187        obj = (transport_config_Object *)tmpObj; 
    31743188        cfg.public_addr.ptr = PyString_AsString(obj->public_addr); 
     
    31893203            strlen(PyString_AsString(obj->stun_config->stun_srv2)); 
    31903204        status = pjsua_transport_create(type, &cfg, &id); 
    3191         } else { 
     3205    } else { 
    31923206        status = pjsua_transport_create(type, NULL, &id); 
    3193         } 
     3207    } 
    31943208     
    31953209     
     
    32043218{ 
    32053219    pj_status_t status;      
    3206         PyObject * tmpObj; 
     3220    PyObject * tmpObj; 
    32073221    pjsip_transport_Object *obj;         
    32083222    pjsua_transport_id id; 
     
    32123226    } 
    32133227    if (tmpObj != Py_None) 
    3214         { 
     3228    { 
    32153229        obj = (pjsip_transport_Object *)tmpObj; 
    32163230        status = pjsua_transport_register(obj->tp, &id); 
     
    36833697        if (s[0])  
    36843698        { 
    3685         self->buf_[idx] = s[0]; 
     3699            self->buf_[idx] = s[0]; 
    36863700        }         
    36873701        else  
     
    38293843    obj = (acc_config_Object *)acc_config_new(&acc_config_Type, NULL, NULL); 
    38303844    obj->cred_count = cfg.cred_count; 
    3831     for (i = 0; i < 8; i++)  
     3845    for (i = 0; i < PJSUA_MAX_ACC; i++)  
    38323846    { 
    38333847        /*obj->cred_info[i] = cfg.cred_info[i];*/ 
     
    38633877        PyString_FromStringAndSize(cfg.reg_uri.ptr, cfg.reg_uri.slen); 
    38643878    obj->proxy_cnt = cfg.proxy_cnt; 
    3865     for (i = 0; i < 8; i++)  
     3879    for (i = 0; i < PJSUA_MAX_ACC; i++)  
    38663880    { 
    38673881        PyObject * str; 
     
    39563970{     
    39573971    int is_default; 
    3958         PyObject * acObj; 
     3972    PyObject * acObj; 
    39593973    acc_config_Object * ac; 
    39603974    pjsua_acc_config cfg; 
     
    39713985    pjsua_acc_config_default(&cfg); 
    39723986    if (acObj != Py_None) 
    3973         { 
     3987    { 
    39743988        ac = (acc_config_Object *)acObj; 
    39753989        cfg.cred_count = ac->cred_count; 
    3976         for (i = 0; i < 8; i++)  
     3990        for (i = 0; i < PJSUA_MAX_ACC; i++)  
    39773991        { 
    3978             /*cfg.cred_info[i] = ac->cred_info[i];*/ 
    3979                 pjsip_cred_info_Object * ci = (pjsip_cred_info_Object *) 
    3980                                 PyList_GetItem((PyObject *)ac->cred_info,i); 
    3981                 cfg.cred_info[i].data.ptr = PyString_AsString(ci->data); 
    3982                 cfg.cred_info[i].data.slen = strlen(PyString_AsString(ci->data)); 
    3983                 cfg.cred_info[i].realm.ptr = PyString_AsString(ci->realm); 
    3984                 cfg.cred_info[i].realm.slen = strlen(PyString_AsString(ci->realm)); 
    3985                 cfg.cred_info[i].scheme.ptr = PyString_AsString(ci->scheme); 
    3986                 cfg.cred_info[i].scheme.slen = strlen 
    3987                                 (PyString_AsString(ci->scheme)); 
    3988                 cfg.cred_info[i].username.ptr = PyString_AsString(ci->username); 
    3989                 cfg.cred_info[i].username.slen = strlen 
    3990                                 (PyString_AsString(ci->username)); 
    3991                 cfg.cred_info[i].data_type = ci->data_type; 
    3992         } 
    3993         cfg.force_contact.ptr = PyString_AsString(ac->force_contact); 
    3994         cfg.force_contact.slen = strlen(PyString_AsString(ac->force_contact)); 
    3995         cfg.id.ptr = PyString_AsString(ac->id); 
    3996         cfg.id.slen = strlen(PyString_AsString(ac->id)); 
    3997         cfg.priority = ac->priority; 
    3998         for (i = 0; i < 8; i++) { 
    3999             /*cfg.proxy[i] = ac->proxy[i];*/ 
    4000                 cfg.proxy[i].ptr = PyString_AsString 
    4001                                 (PyList_GetItem((PyObject *)ac->proxy,i)); 
    4002         } 
    4003         cfg.proxy_cnt = ac->proxy_cnt; 
    4004         cfg.publish_enabled = ac->publish_enabled; 
    4005         cfg.reg_timeout = ac->reg_timeout; 
    4006         cfg.reg_uri.ptr = PyString_AsString(ac->reg_uri); 
    4007         cfg.reg_uri.slen = strlen(PyString_AsString(ac->reg_uri)); 
    4008      
    4009         status = pjsua_acc_add(&cfg, is_default, &p_acc_id); 
    4010     } else { 
    4011         status = pjsua_acc_add(NULL, is_default, &p_acc_id); 
    4012         } 
    4013      
    4014     return Py_BuildValue("ii", status, p_acc_id); 
    4015 } 
    4016  
    4017 /* 
    4018  * py_pjsua_acc_add_local 
    4019  * !modified @ 051206 
    4020  */ 
    4021 static PyObject *py_pjsua_acc_add_local 
    4022 (PyObject *pSelf, PyObject *pArgs) 
    4023 {     
    4024     int is_default; 
    4025     int tid; 
    4026      
    4027     int p_acc_id; 
    4028     int status; 
    4029          
    4030  
    4031     if (!PyArg_ParseTuple(pArgs, "ii", &tid, &is_default)) 
    4032     { 
    4033         return NULL; 
    4034     } 
    4035          
    4036      
    4037     status = pjsua_acc_add_local(tid, is_default, &p_acc_id); 
    4038      
    4039     return Py_BuildValue("ii", status, p_acc_id); 
    4040 } 
    4041  
    4042 /* 
    4043  * py_pjsua_acc_del 
    4044  */ 
    4045 static PyObject *py_pjsua_acc_del 
    4046 (PyObject *pSelf, PyObject *pArgs) 
    4047 {     
    4048     int acc_id; 
    4049     int status; 
    4050  
    4051     if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) 
    4052     { 
    4053         return NULL; 
    4054     } 
    4055          
    4056          
    4057     status = pjsua_acc_del(acc_id);      
    4058     return Py_BuildValue("i", status); 
    4059 } 
    4060  
    4061 /* 
    4062  * py_pjsua_acc_modify 
    4063  */ 
    4064 static PyObject *py_pjsua_acc_modify 
    4065 (PyObject *pSelf, PyObject *pArgs) 
    4066 {        
    4067         PyObject * acObj; 
    4068     acc_config_Object * ac; 
    4069     pjsua_acc_config cfg;        
    4070     int acc_id; 
    4071     int status; 
    4072     int i; 
    4073  
    4074     if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &acObj)) 
    4075     { 
    4076         return NULL; 
    4077     } 
    4078     if (acObj != Py_None) 
    4079         { 
    4080                 ac = (acc_config_Object *)acObj; 
    4081         cfg.cred_count = ac->cred_count; 
    4082         for (i = 0; i < 8; i++)  
    4083                 { 
    40843992            /*cfg.cred_info[i] = ac->cred_info[i];*/ 
    40853993            pjsip_cred_info_Object * ci = (pjsip_cred_info_Object *) 
     
    40954003            cfg.cred_info[i].username.slen = strlen 
    40964004                                (PyString_AsString(ci->username)); 
    4097                 } 
     4005            cfg.cred_info[i].data_type = ci->data_type; 
     4006        } 
    40984007        cfg.force_contact.ptr = PyString_AsString(ac->force_contact); 
    40994008        cfg.force_contact.slen = strlen(PyString_AsString(ac->force_contact)); 
     
    41014010        cfg.id.slen = strlen(PyString_AsString(ac->id)); 
    41024011        cfg.priority = ac->priority; 
    4103         for (i = 0; i < 8; i++) { 
     4012        for (i = 0; i < PJSUA_MAX_ACC; i++)  
     4013        { 
    41044014            /*cfg.proxy[i] = ac->proxy[i];*/ 
    4105                 cfg.proxy[i].ptr = PyString_AsString 
     4015            cfg.proxy[i].ptr = PyString_AsString 
    41064016                                (PyList_GetItem((PyObject *)ac->proxy,i)); 
    4107                 } 
     4017        } 
     4018        cfg.proxy_cnt = ac->proxy_cnt; 
     4019        cfg.publish_enabled = ac->publish_enabled; 
     4020        cfg.reg_timeout = ac->reg_timeout; 
     4021        cfg.reg_uri.ptr = PyString_AsString(ac->reg_uri); 
     4022        cfg.reg_uri.slen = strlen(PyString_AsString(ac->reg_uri)); 
     4023     
     4024        status = pjsua_acc_add(&cfg, is_default, &p_acc_id); 
     4025    } else { 
     4026        status = pjsua_acc_add(NULL, is_default, &p_acc_id); 
     4027    } 
     4028     
     4029    return Py_BuildValue("ii", status, p_acc_id); 
     4030} 
     4031 
     4032/* 
     4033 * py_pjsua_acc_add_local 
     4034 * !modified @ 051206 
     4035 */ 
     4036static PyObject *py_pjsua_acc_add_local 
     4037(PyObject *pSelf, PyObject *pArgs) 
     4038{     
     4039    int is_default; 
     4040    int tid; 
     4041     
     4042    int p_acc_id; 
     4043    int status; 
     4044         
     4045 
     4046    if (!PyArg_ParseTuple(pArgs, "ii", &tid, &is_default)) 
     4047    { 
     4048        return NULL; 
     4049    } 
     4050         
     4051     
     4052    status = pjsua_acc_add_local(tid, is_default, &p_acc_id); 
     4053     
     4054    return Py_BuildValue("ii", status, p_acc_id); 
     4055} 
     4056 
     4057/* 
     4058 * py_pjsua_acc_del 
     4059 */ 
     4060static PyObject *py_pjsua_acc_del 
     4061(PyObject *pSelf, PyObject *pArgs) 
     4062{     
     4063    int acc_id; 
     4064    int status; 
     4065 
     4066    if (!PyArg_ParseTuple(pArgs, "i", &acc_id)) 
     4067    { 
     4068        return NULL; 
     4069    } 
     4070         
     4071         
     4072    status = pjsua_acc_del(acc_id);      
     4073    return Py_BuildValue("i", status); 
     4074} 
     4075 
     4076/* 
     4077 * py_pjsua_acc_modify 
     4078 */ 
     4079static PyObject *py_pjsua_acc_modify 
     4080(PyObject *pSelf, PyObject *pArgs) 
     4081{        
     4082    PyObject * acObj; 
     4083    acc_config_Object * ac; 
     4084    pjsua_acc_config cfg;        
     4085    int acc_id; 
     4086    int status; 
     4087    int i; 
     4088 
     4089    if (!PyArg_ParseTuple(pArgs, "iO", &acc_id, &acObj)) 
     4090    { 
     4091        return NULL; 
     4092    } 
     4093    if (acObj != Py_None) 
     4094    { 
     4095        ac = (acc_config_Object *)acObj; 
     4096        cfg.cred_count = ac->cred_count; 
     4097        for (i = 0; i < PJSUA_MAX_ACC; i++)  
     4098        { 
     4099            /*cfg.cred_info[i] = ac->cred_info[i];*/ 
     4100            pjsip_cred_info_Object * ci = (pjsip_cred_info_Object *) 
     4101                                PyList_GetItem((PyObject *)ac->cred_info,i); 
     4102            cfg.cred_info[i].data.ptr = PyString_AsString(ci->data); 
     4103            cfg.cred_info[i].data.slen = strlen(PyString_AsString(ci->data)); 
     4104            cfg.cred_info[i].realm.ptr = PyString_AsString(ci->realm); 
     4105            cfg.cred_info[i].realm.slen = strlen(PyString_AsString(ci->realm)); 
     4106            cfg.cred_info[i].scheme.ptr = PyString_AsString(ci->scheme); 
     4107            cfg.cred_info[i].scheme.slen = strlen 
     4108                                (PyString_AsString(ci->scheme)); 
     4109            cfg.cred_info[i].username.ptr = PyString_AsString(ci->username); 
     4110            cfg.cred_info[i].username.slen = strlen 
     4111                                (PyString_AsString(ci->username)); 
     4112        } 
     4113        cfg.force_contact.ptr = PyString_AsString(ac->force_contact); 
     4114        cfg.force_contact.slen = strlen(PyString_AsString(ac->force_contact)); 
     4115        cfg.id.ptr = PyString_AsString(ac->id); 
     4116        cfg.id.slen = strlen(PyString_AsString(ac->id)); 
     4117        cfg.priority = ac->priority; 
     4118        for (i = 0; i < PJSUA_MAX_ACC; i++)  
     4119        { 
     4120            /*cfg.proxy[i] = ac->proxy[i];*/ 
     4121             cfg.proxy[i].ptr = PyString_AsString 
     4122                                (PyList_GetItem((PyObject *)ac->proxy,i)); 
     4123        } 
    41084124        cfg.proxy_cnt = ac->proxy_cnt; 
    41094125        cfg.publish_enabled = ac->publish_enabled; 
     
    41124128        cfg.reg_uri.slen = strlen(PyString_AsString(ac->reg_uri));       
    41134129        status = pjsua_acc_modify(acc_id, &cfg); 
    4114         } else { 
    4115                 status = pjsua_acc_modify(acc_id, NULL); 
    4116         } 
     4130    } else { 
     4131        status = pjsua_acc_modify(acc_id, NULL); 
     4132    } 
    41174133    return Py_BuildValue("i", status); 
    41184134} 
     
    41784194     
    41794195    status = pjsua_acc_get_info(acc_id, &info); 
    4180     if (status == PJ_SUCCESS) { 
     4196    if (status == PJ_SUCCESS)  
     4197    { 
    41814198        obj = (acc_info_Object *)acc_info_new(&acc_info_Type,NULL, NULL); 
    41824199        obj->acc_uri = 
    41834200            PyString_FromStringAndSize(info.acc_uri.ptr,  
    41844201            info.acc_uri.slen); 
    4185         for (i = 0; i < PJ_ERR_MSG_SIZE; i++) { 
     4202        for (i = 0; i < PJ_ERR_MSG_SIZE; i++)  
     4203        { 
    41864204            obj->buf_[i] = info.buf_[i]; 
    41874205        } 
     
    42224240     
    42234241    list = PyList_New(c); 
    4224     for (i = 0; i < c; i++) { 
     4242    for (i = 0; i < c; i++)  
     4243    { 
    42254244        int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 
    4226         if (ret == -1) { 
     4245        if (ret == -1)  
     4246        { 
    42274247            return NULL; 
    42284248        } 
     
    42524272     
    42534273    list = PyList_New(c); 
    4254     for (i = 0; i < c; i++) { 
     4274    for (i = 0; i < c; i++)  
     4275    { 
    42554276        int ret; 
    4256         int j; 
    4257         acc_info_Object *obj; 
    4258         obj = (acc_info_Object *)acc_info_new(&acc_info_Type,NULL,NULL); 
    4259         obj->acc_uri = PyString_FromStringAndSize 
     4277        int j; 
     4278        acc_info_Object *obj; 
     4279        obj = (acc_info_Object *)acc_info_new(&acc_info_Type,NULL,NULL); 
     4280        obj->acc_uri = PyString_FromStringAndSize 
    42604281            (info[i].acc_uri.ptr, info[i].acc_uri.slen); 
    4261         for(j = 0; j < PJ_ERR_MSG_SIZE; j++) { 
    4262             obj->buf_[j] = info[i].buf_[j]; 
     4282        for(j = 0; j < PJ_ERR_MSG_SIZE; j++)  
     4283        { 
     4284            obj->buf_[j] = info[i].buf_[j]; 
    42634285        } 
    4264         obj->expires = info[i].expires; 
    4265         obj->has_registration = info[i].has_registration; 
    4266         obj->id = info[i].id; 
    4267         obj->is_default = info[i].is_default; 
    4268         obj->online_status = info[i].online_status; 
    4269         obj->status = info[i].status; 
    4270         obj->status_text = PyString_FromStringAndSize(info[i].status_text.ptr, 
     4286        obj->expires = info[i].expires; 
     4287        obj->has_registration = info[i].has_registration; 
     4288        obj->id = info[i].id; 
     4289        obj->is_default = info[i].is_default; 
     4290        obj->online_status = info[i].online_status; 
     4291        obj->status = info[i].status; 
     4292        obj->status_text = PyString_FromStringAndSize(info[i].status_text.ptr, 
    42714293            info[i].status_text.slen); 
    4272         ret = PyList_SetItem(list, i, (PyObject *)obj); 
     4294        ret = PyList_SetItem(list, i, (PyObject *)obj); 
    42734295        if (ret == -1) { 
    4274             return NULL; 
     4296            return NULL; 
    42754297        } 
    42764298    } 
     
    43094331{        
    43104332    int acc_id;  
    4311         PyObject * tmpObj; 
     4333    PyObject * tmpObj; 
    43124334    pjsip_rx_data_Object * obj; 
    43134335    pjsip_rx_data * rdata; 
     
    43184340    } 
    43194341    if (tmpObj != Py_None) 
    4320         { 
     4342    { 
    43214343        obj = (pjsip_rx_data_Object *)tmpObj; 
    43224344        rdata = obj->rdata; 
    43234345        acc_id = pjsua_acc_find_for_incoming(rdata); 
    4324         } else { 
     4346    } else { 
    43254347        acc_id = pjsua_acc_find_for_incoming(NULL); 
    4326         } 
     4348    } 
    43274349    return Py_BuildValue("i", acc_id); 
    43284350} 
     
    43374359    int status; 
    43384360    int acc_id; 
    4339         PyObject * pObj; 
     4361    PyObject * pObj; 
    43404362    pj_pool_Object * p; 
    43414363    pj_pool_t * pool; 
     
    43504372    } 
    43514373    if (pObj != Py_None) 
    4352         { 
     4374    { 
    43534375        p = (pj_pool_Object *)pObj; 
    43544376        pool = p->pool;     
     
    43564378        uri.slen = strlen(PyString_AsString(stru)); 
    43574379        status = pjsua_acc_create_uac_contact(pool, &contact, acc_id, &uri); 
    4358         } else { 
     4380    } else { 
    43594381        status = pjsua_acc_create_uac_contact(NULL, &contact, acc_id, &uri); 
    4360         } 
     4382    } 
    43614383    strc = PyString_FromStringAndSize(contact.ptr, contact.slen); 
    43624384         
     
    43734395    int status; 
    43744396    int acc_id;  
    4375         PyObject * pObj; 
     4397    PyObject * pObj; 
    43764398    pj_pool_Object * p; 
    43774399    pj_pool_t * pool; 
    43784400    PyObject * strc; 
    43794401    pj_str_t contact; 
    4380         PyObject * rObj; 
     4402    PyObject * rObj; 
    43814403    pjsip_rx_data_Object * objr; 
    43824404    pjsip_rx_data * rdata; 
     
    43874409    } 
    43884410    if (pObj != Py_None) 
    4389         { 
     4411    { 
    43904412        p = (pj_pool_Object *)pObj; 
    43914413        pool = p->pool; 
    43924414    } else { 
    43934415                pool = NULL; 
    4394         } 
     4416    } 
    43954417    if (rObj != Py_None) 
    4396         { 
    4397                 objr = (pjsip_rx_data_Object *)rObj; 
     4418    { 
     4419        objr = (pjsip_rx_data_Object *)rObj; 
    43984420        rdata = objr->rdata; 
    4399         } else { 
     4421    } else { 
    44004422        rdata = NULL; 
    4401         } 
     4423    } 
    44024424    status = pjsua_acc_create_uas_contact(pool, &contact, acc_id, rdata); 
    44034425    strc = PyString_FromStringAndSize(contact.ptr, contact.slen); 
     
    47624784 
    47634785/* 
     4786 * py_pjsua_buddy_config_default 
     4787 */ 
     4788static PyObject *py_pjsua_buddy_config_default 
     4789(PyObject *pSelf, PyObject *pArgs) 
     4790{     
     4791    buddy_config_Object *obj;    
     4792    pjsua_buddy_config cfg; 
     4793 
     4794    if (!PyArg_ParseTuple(pArgs, "")) 
     4795    { 
     4796        return NULL; 
     4797    } 
     4798     
     4799    pjsua_buddy_config_default(&cfg); 
     4800    obj = (buddy_config_Object *) buddy_config_new 
     4801                (&buddy_config_Type,NULL,NULL); 
     4802    obj->uri = PyString_FromStringAndSize( 
     4803        cfg.uri.ptr, cfg.uri.slen 
     4804    ); 
     4805    obj->subscribe = cfg.subscribe; 
     4806     
     4807    return (PyObject *)obj; 
     4808} 
     4809 
     4810/* 
    47644811 * py_pjsua_get_buddy_count 
    47654812 */ 
     
    48144861    status = pjsua_enum_buddies(id, &c); 
    48154862    list = PyList_New(c); 
    4816     for (i = 0; i < c; i++) { 
     4863    for (i = 0; i < c; i++)  
     4864    { 
    48174865        int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 
    4818         if (ret == -1) { 
     4866        if (ret == -1)  
     4867        { 
    48194868            return NULL; 
    48204869        } 
     
    48444893     
    48454894    status = pjsua_buddy_get_info(buddy_id, &info); 
    4846     if (status == PJ_SUCCESS) { 
     4895    if (status == PJ_SUCCESS)  
     4896    { 
    48474897        obj = (buddy_info_Object *)buddy_info_new(&buddy_info_Type,NULL,NULL); 
    48484898        obj->id = info.id; 
     
    48614911            info.status_text.slen); 
    48624912        obj->monitor_pres = info.monitor_pres; 
    4863         for (i = 0; i < 256; i++) { 
     4913        for (i = 0; i < 256; i++)  
     4914        { 
    48644915             
    48654916            obj->buf_[i] = info.buf_[i]; 
     
    48934944    } 
    48944945    if (bcObj != Py_None) 
    4895         { 
    4896                 bc = (buddy_config_Object *)bcObj; 
     4946    { 
     4947        bc = (buddy_config_Object *)bcObj; 
    48974948 
    48984949        cfg.subscribe = bc->subscribe; 
     
    49014952     
    49024953        status = pjsua_buddy_add(&cfg, &p_buddy_id); 
    4903         } else { 
     4954    } else { 
    49044955        status = pjsua_buddy_add(NULL, &p_buddy_id); 
    49054956    } 
     
    49745025    int status; 
    49755026    int acc_id; 
    4976     pj_str_t to, mime_type, content; 
     5027    pj_str_t * mime_type; 
     5028    pj_str_t to, content; 
    49775029    PyObject * st; 
    49785030    PyObject * smt; 
     
    49815033    PyObject * omdObj; 
    49825034    msg_data_Object * omd; 
     5035     
    49835036    int user_data; 
    49845037    pj_pool_t *pool; 
    49855038 
     5039    
    49865040    if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id,  
    49875041                &st, &smt, &sc, &omdObj, &user_data)) 
     
    49895043        return NULL; 
    49905044    } 
    4991          
     5045    if (smt != NULL) 
     5046    { 
     5047        mime_type = (pj_str_t *)malloc(sizeof(pj_str_t)); 
     5048        mime_type->ptr = PyString_AsString(smt); 
     5049        mime_type->slen = strlen(PyString_AsString(smt)); 
     5050    } else { 
     5051        mime_type = NULL; 
     5052    } 
    49925053    to.ptr = PyString_AsString(st); 
    49935054    to.slen = strlen(PyString_AsString(st)); 
    4994     mime_type.ptr = PyString_AsString(smt); 
    4995     mime_type.slen = strlen(PyString_AsString(smt)); 
     5055     
    49965056    content.ptr = PyString_AsString(sc); 
    49975057    content.slen = strlen(PyString_AsString(sc)); 
    49985058    if (omdObj != Py_None) 
    4999         { 
     5059    { 
    50005060                 
    50015061        omd = (msg_data_Object *)omdObj; 
     
    50055065        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    50065066        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    5007         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     5067        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    50085068 
    50095069        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    5010         status = pjsua_im_send(acc_id, &to, &mime_type,  
    5011                         &content, &msg_data, &user_data);        
     5070        status = pjsua_im_send(acc_id, &to, mime_type,  
     5071                        &content, &msg_data, (void *)user_data);         
    50125072        pj_pool_release(pool); 
    5013         } else { 
     5073    } else { 
    50145074                 
    5015         status = pjsua_im_send(acc_id, &to, NULL,  
     5075        status = pjsua_im_send(acc_id, &to, mime_type,  
    50165076                        &content, NULL, NULL);   
    5017         } 
    5018          
     5077    } 
     5078    if (mime_type != NULL) 
     5079    { 
     5080        free(mime_type); 
     5081    } 
    50195082    return Py_BuildValue("i",status); 
    50205083} 
     
    50325095    int is_typing; 
    50335096    pjsua_msg_data msg_data; 
    5034         PyObject * omdObj; 
     5097    PyObject * omdObj; 
    50355098    msg_data_Object * omd; 
    50365099    pj_pool_t * pool; 
     
    50445107    to.slen = strlen(PyString_AsString(st));     
    50455108    if (omdObj != Py_None) 
    5046         { 
     5109    { 
    50475110        omd = (msg_data_Object *)omdObj; 
    50485111        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
     
    50515114        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    50525115        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    5053         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     5116        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    50545117 
    50555118        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    50565119        status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data);     
    50575120        pj_pool_release(pool); 
    5058         } else { 
     5121    } else { 
    50595122        status = pjsua_im_typing(acc_id, &to, is_typing, NULL); 
    5060         } 
     5123    } 
    50615124    return Py_BuildValue("i",status); 
    50625125} 
    50635126 
     5127static char pjsua_buddy_config_default_doc[] = 
     5128    "py_pjsua.Buddy_Config py_pjsua.buddy_config_default () " 
     5129    "Set default values to the buddy config."; 
    50645130static char pjsua_get_buddy_count_doc[] = 
    50655131    "int py_pjsua.get_buddy_count () " 
     
    52815347        }         
    52825348         
    5283         self->listeners = (PyListObject *)PyList_New(254); 
     5349        self->listeners = (PyListObject *)PyList_New(PJSUA_MAX_CONF_PORTS); 
    52845350        if (self->listeners == NULL) 
    52855351        { 
     
    54735539    if (self != NULL) 
    54745540    { 
    5475         self->name = (PyListObject *)PyList_New(64); 
     5541        self->name = (PyListObject *)PyList_New(SND_DEV_NUM); 
    54765542        if (self->name == NULL) 
    54775543        { 
     
    59686034     
    59696035    list = PyList_New(c); 
    5970     for (i = 0; i < c; i++) { 
     6036    for (i = 0; i < c; i++)  
     6037    { 
    59716038        int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 
    5972         if (ret == -1) { 
     6039        if (ret == -1)  
     6040        { 
    59736041            return NULL; 
    59746042        } 
     
    60076075    obj->slot_id = info.slot_id; 
    60086076     
    6009     for (i = 0; i < 254; i++) { 
     6077    for (i = 0; i < PJSUA_MAX_CONF_PORTS; i++) { 
    60106078        PyObject * item = Py_BuildValue("i",info.listeners[i]); 
    60116079        PyList_SetItem((PyObject *)obj->listeners, i, item); 
     
    60216089{        
    60226090    int p_id; 
    6023         PyObject * oportObj; 
     6091    PyObject * oportObj; 
    60246092    pjmedia_port_Object * oport; 
    6025         pjmedia_port * port; 
    6026         PyObject * opoolObj; 
     6093    pjmedia_port * port; 
     6094    PyObject * opoolObj; 
    60276095    pj_pool_Object * opool; 
    6028         pj_pool_t * pool; 
     6096    pj_pool_t * pool; 
    60296097     
    60306098    int status;  
     
    60366104    } 
    60376105    if (opoolObj != Py_None) 
    6038         { 
     6106    { 
    60396107        opool = (pj_pool_Object *)opoolObj; 
    60406108                pool = opool->pool; 
    6041         } else { 
    6042                 opool = NULL; 
    6043                 pool = NULL; 
     6109    } else { 
     6110       opool = NULL; 
     6111       pool = NULL; 
    60446112    } 
    60456113    if (oportObj != Py_None) 
    6046         { 
     6114    { 
    60476115        oport = (pjmedia_port_Object *)oportObj; 
    60486116                port = oport->port; 
    6049         } else { 
     6117    } else { 
    60506118        oport = NULL; 
    6051                 port = NULL; 
     6119        port = NULL; 
    60526120    } 
    60536121 
     
    62226290    pj_str_t str; 
    62236291    PyObject * enc_param; 
    6224         pj_str_t strparam; 
     6292    pj_str_t strparam; 
    62256293    int enc_type; 
    62266294     
     
    62356303    str.ptr = PyString_AsString(filename); 
    62366304    str.slen = strlen(PyString_AsString(filename)); 
    6237         strparam.ptr = PyString_AsString(enc_param); 
    6238         strparam.slen = strlen(PyString_AsString(enc_param)); 
     6305    strparam.ptr = PyString_AsString(enc_param); 
     6306    strparam.slen = strlen(PyString_AsString(enc_param)); 
    62396307    status = pjsua_recorder_create 
    62406308                (&str, enc_type, NULL, max_size, options, &p_id); 
     
    62936361    PyObject *list; 
    62946362     
    6295     pjmedia_snd_dev_info info[64]; 
     6363    pjmedia_snd_dev_info info[SND_DEV_NUM]; 
    62966364    unsigned c, i; 
    62976365    if (!PyArg_ParseTuple(pArgs, "")) 
     
    63046372     
    63056373    list = PyList_New(c); 
    6306     for (i = 0; i < c; i++) { 
     6374    for (i = 0; i < c; i++)  
     6375    { 
    63076376        int ret; 
    6308         int j; 
     6377        int j; 
    63096378        pjmedia_snd_dev_info_Object * obj; 
    63106379        obj = (pjmedia_snd_dev_info_Object *)pjmedia_snd_dev_info_new 
     
    63136382        obj->input_count = info[i].input_count; 
    63146383        obj->output_count = info[i].output_count; 
    6315         for (j = 0; j < 64; j++) 
     6384        for (j = 0; j < SND_DEV_NUM; j++) 
    63166385        { 
    6317             PyObject * ostr; 
    6318             char * str; 
    6319             str = (char *)malloc(sizeof(char)); 
    6320             str[0] = info[i].name[j]; 
    6321             ostr = PyString_FromStringAndSize(str,1); 
     6386            PyObject * ostr; 
     6387            char * str; 
     6388            str = (char *)malloc(sizeof(char)); 
     6389            str[0] = info[i].name[j]; 
     6390            ostr = PyString_FromStringAndSize(str,1); 
    63226391            PyList_SetItem((PyObject *)obj->name, j, ostr); 
    6323             free(str); 
     6392            free(str); 
    63246393        } 
    63256394        ret = PyList_SetItem(list, i, (PyObject *)obj); 
    6326         if (ret == -1) { 
     6395        if (ret == -1)  
     6396        { 
    63276397            return NULL; 
    63286398        } 
     
    64786548     
    64796549    list = PyList_New(c); 
    6480     for (i = 0; i < c; i++) { 
     6550    for (i = 0; i < c; i++)  
     6551    { 
    64816552        int ret; 
    64826553        int j; 
     
    65766647    pj_str_t str; 
    65776648    pjmedia_codec_param param; 
    6578         PyObject * tmpObj; 
     6649    PyObject * tmpObj; 
    65796650    pjmedia_codec_param_Object *obj; 
    65806651     
     
    65886659    str.slen = strlen(PyString_AsString(id)); 
    65896660    if (tmpObj != Py_None) 
    6590         { 
     6661    { 
    65916662        obj = (pjmedia_codec_param_Object *)tmpObj; 
    65926663        param.info.avg_bps = obj->info->avg_bps; 
     
    66076678    } else { 
    66086679        status = pjsua_codec_set_param(&str, NULL); 
    6609         } 
     6680    } 
    66106681    return Py_BuildValue("i", status); 
    66116682} 
     
    71587229    unsigned options; 
    71597230    pjsua_msg_data msg_data; 
    7160         PyObject * omdObj; 
     7231    PyObject * omdObj; 
    71617232    msg_data_Object * omd; 
    71627233    int user_data; 
     
    71727243    dst_uri.ptr = PyString_AsString(sd); 
    71737244    dst_uri.slen = strlen(PyString_AsString(sd)); 
    7174     if (omdObj != Py_None) { 
    7175         omd = (msg_data_Object *)omdObj; 
     7245    if (omdObj != Py_None)  
     7246    { 
     7247        omd = (msg_data_Object *)omdObj; 
    71767248        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
    71777249        msg_data.content_type.slen = strlen 
     
    71797251        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    71807252        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    7181         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     7253        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    71827254        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    71837255        status = pjsua_call_make_call(acc_id, &dst_uri,  
     
    72787350        oi = (call_info_Object *)call_info_new(&call_info_Type, NULL, NULL); 
    72797351        oi->acc_id = info.acc_id; 
    7280         pj_ansi_snprintf(oi->buf_.call_id, sizeof(oi->buf_.call_id), 
    7281                          "%.*s", (int)info.call_id.slen, info.call_id.ptr); 
    7282         pj_ansi_snprintf(oi->buf_.last_status_text, sizeof(oi->buf_.last_status_text), 
    7283                          "%.*s", (int)info.last_status_text.slen, info.last_status_text.ptr); 
    7284         pj_ansi_snprintf(oi->buf_.local_contact, sizeof(oi->buf_.local_contact), 
    7285                          "%.*s", (int)info.local_contact.slen, info.local_contact.ptr); 
    7286         pj_ansi_snprintf(oi->buf_.local_info, sizeof(oi->buf_.local_info), 
    7287                          "%.*s", (int)info.local_info.slen, info.local_info.ptr); 
    7288         pj_ansi_snprintf(oi->buf_.remote_contact, sizeof(oi->buf_.remote_contact), 
    7289                          "%.*s", (int)info.remote_contact.slen, info.remote_contact.ptr); 
    7290         pj_ansi_snprintf(oi->buf_.remote_info, sizeof(oi->buf_.remote_info), 
    7291                          "%.*s", (int)info.remote_info.slen, info.remote_info.ptr); 
     7352        pj_ansi_snprintf(oi->buf_.call_id, sizeof(oi->buf_.call_id), 
     7353            "%.*s", (int)info.call_id.slen, info.call_id.ptr); 
     7354        pj_ansi_snprintf(oi->buf_.last_status_text,  
     7355            sizeof(oi->buf_.last_status_text), 
     7356            "%.*s", (int)info.last_status_text.slen, info.last_status_text.ptr); 
     7357        pj_ansi_snprintf(oi->buf_.local_contact, sizeof(oi->buf_.local_contact), 
     7358            "%.*s", (int)info.local_contact.slen, info.local_contact.ptr); 
     7359        pj_ansi_snprintf(oi->buf_.local_info, sizeof(oi->buf_.local_info), 
     7360            "%.*s", (int)info.local_info.slen, info.local_info.ptr); 
     7361        pj_ansi_snprintf(oi->buf_.remote_contact, 
     7362            sizeof(oi->buf_.remote_contact), 
     7363            "%.*s", (int)info.remote_contact.slen, info.remote_contact.ptr); 
     7364        pj_ansi_snprintf(oi->buf_.remote_info, sizeof(oi->buf_.remote_info), 
     7365            "%.*s", (int)info.remote_info.slen, info.remote_info.ptr); 
    72927366 
    72937367        oi->call_id = PyString_FromStringAndSize(info.call_id.ptr,  
     
    73747448    int status; 
    73757449    int call_id; 
    7376     pj_str_t reason; 
     7450    pj_str_t * reason; 
    73777451    PyObject * sr; 
    73787452    unsigned code; 
    73797453    pjsua_msg_data msg_data; 
    7380         PyObject * omdObj; 
     7454    PyObject * omdObj; 
    73817455    msg_data_Object * omd;     
    73827456    pj_pool_t * pool; 
     
    73867460        return NULL; 
    73877461    } 
    7388  
    7389     reason.ptr = PyString_AsString(sr); 
    7390     reason.slen = strlen(PyString_AsString(sr)); 
    7391     if (omdObj != Py_None) { 
     7462    if (sr == Py_None)  
     7463    { 
     7464        reason = NULL; 
     7465    } else { 
     7466        reason = (pj_str_t *)malloc(sizeof(pj_str_t)); 
     7467        reason->ptr = PyString_AsString(sr); 
     7468        reason->slen = strlen(PyString_AsString(sr)); 
     7469    } 
     7470    if (omdObj != Py_None)  
     7471    { 
    73927472        omd = (msg_data_Object *)omdObj; 
    73937473        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
     
    73967476        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    73977477        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    7398         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     7478        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    73997479        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    74007480         
    7401         status = pjsua_call_answer(call_id, code, &reason, &msg_data);   
     7481        status = pjsua_call_answer(call_id, code, reason, &msg_data);    
    74027482     
    74037483        pj_pool_release(pool); 
    74047484    } else { 
    74057485         
    7406         status = pjsua_call_answer(call_id, code, &reason, NULL);        
    7407         } 
     7486        status = pjsua_call_answer(call_id, code, reason, NULL);         
     7487    } 
     7488    if (reason != NULL) 
     7489    { 
     7490        free(reason); 
     7491    } 
    74087492    return Py_BuildValue("i",status); 
    74097493} 
     
    74177501    int status; 
    74187502    int call_id; 
    7419     pj_str_t reason; 
     7503    pj_str_t * reason; 
    74207504    PyObject * sr; 
    74217505    unsigned code; 
    74227506    pjsua_msg_data msg_data; 
    7423         PyObject * omdObj; 
     7507    PyObject * omdObj; 
    74247508    msg_data_Object * omd;     
    74257509    pj_pool_t * pool = NULL; 
     
    74297513        return NULL; 
    74307514    } 
    7431          
    7432     reason.ptr = PyString_AsString(sr); 
    7433     reason.slen = strlen(PyString_AsString(sr)); 
    7434     if (omdObj != Py_None) { 
     7515    if (sr != Py_None) 
     7516    { 
     7517        reason = NULL; 
     7518    } else { 
     7519        reason = (pj_str_t *)malloc(sizeof(pj_str_t)); 
     7520        reason->ptr = PyString_AsString(sr); 
     7521        reason->slen = strlen(PyString_AsString(sr)); 
     7522    } 
     7523    if (omdObj != Py_None)  
     7524    { 
    74357525        omd = (msg_data_Object *)omdObj; 
    74367526        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
     
    74397529        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    74407530        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    7441         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     7531        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    74427532        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    7443         status = pjsua_call_hangup(call_id, code, &reason, &msg_data);   
     7533        status = pjsua_call_hangup(call_id, code, reason, &msg_data);    
    74447534        pj_pool_release(pool); 
    74457535    } else { 
    7446         status = pjsua_call_hangup(call_id, code, &reason, NULL);        
     7536        status = pjsua_call_hangup(call_id, code, reason, NULL);         
     7537    } 
     7538    if (reason != NULL) 
     7539    { 
     7540        free(reason); 
    74477541    } 
    74487542    return Py_BuildValue("i",status); 
     
    74677561    } 
    74687562 
    7469     if (omdObj != Py_None) { 
     7563    if (omdObj != Py_None)  
     7564    { 
    74707565        omd = (msg_data_Object *)omdObj; 
    74717566        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
     
    74747569        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    74757570        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    7476         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     7571        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    74777572        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    74787573        status = pjsua_call_set_hold(call_id, &msg_data);        
    74797574        pj_pool_release(pool); 
    7480         } else { 
     7575    } else { 
    74817576        status = pjsua_call_set_hold(call_id, NULL);     
    7482         } 
     7577    } 
    74837578    return Py_BuildValue("i",status); 
    74847579} 
     
    75047599 
    75057600    if (omdObj != Py_None) 
    7506         { 
     7601    { 
    75077602        omd = (msg_data_Object *)omdObj; 
    75087603        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
     
    75117606        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    75127607        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    7513         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     7608        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    75147609        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    75157610        status = pjsua_call_reinvite(call_id, unhold, &msg_data);        
     
    75457640     
    75467641    if (omdObj != Py_None) 
    7547         { 
     7642    { 
    75487643        omd = (msg_data_Object *)omdObj; 
    75497644        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
     
    75527647        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    75537648        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    7554         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     7649        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    75557650        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    75567651        status = pjsua_call_xfer(call_id, &dest, &msg_data);     
    75577652        pj_pool_release(pool); 
    7558         } else { 
     7653    } else { 
    75597654        status = pjsua_call_xfer(call_id, &dest, NULL);  
    7560         } 
     7655    } 
    75617656    return Py_BuildValue("i",status); 
    75627657} 
     
    75847679         
    75857680    if (omdObj != Py_None) 
    7586         { 
     7681    { 
    75877682        omd = (msg_data_Object *)omdObj;     
    75887683        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
     
    75917686        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    75927687        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    7593         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     7688        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    75947689        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    75957690        status = pjsua_call_xfer_replaces 
    75967691                        (call_id, dest_call_id, options, &msg_data);     
    75977692        pj_pool_release(pool); 
    7598         } else { 
     7693    } else { 
    75997694        status = pjsua_call_xfer_replaces(call_id, dest_call_id,options, NULL);  
    7600         } 
     7695    } 
    76017696    return Py_BuildValue("i",status); 
    76027697} 
     
    76327727    int status; 
    76337728    int call_id; 
    7634     pj_str_t mime_type, content; 
     7729    pj_str_t content; 
     7730    pj_str_t * mime_type; 
    76357731    PyObject * sm; 
    76367732    PyObject * sc; 
     
    76467742        return NULL; 
    76477743    } 
    7648          
    7649     mime_type.ptr = PyString_AsString(sm); 
    7650     mime_type.slen = strlen(PyString_AsString(sm)); 
     7744    if (sm == Py_None) 
     7745    { 
     7746        mime_type = NULL; 
     7747    } else { 
     7748        mime_type = (pj_str_t *)malloc(sizeof(pj_str_t)); 
     7749        mime_type->ptr = PyString_AsString(sm); 
     7750        mime_type->slen = strlen(PyString_AsString(sm)); 
     7751    } 
    76517752    content.ptr = PyString_AsString(sc); 
    76527753    content.slen = strlen(PyString_AsString(sc)); 
    76537754     
    76547755    if (omdObj != Py_None) 
    7655         { 
     7756    { 
    76567757        omd = (msg_data_Object *)omdObj; 
    76577758        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
     
    76607761        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    76617762        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    7662         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     7763        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    76637764        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    76647765        status = pjsua_call_send_im 
    7665                         (call_id, &mime_type, &content, &msg_data, &user_data);  
     7766                (call_id, mime_type, &content, &msg_data, (void *)user_data);    
    76667767        pj_pool_release(pool); 
    7667         } else { 
     7768    } else { 
    76687769        status = pjsua_call_send_im 
    7669                         (call_id, &mime_type, &content, NULL, &user_data);       
    7670         } 
     7770                        (call_id, mime_type, &content, NULL, (void *)user_data);         
     7771    } 
     7772    if (mime_type != NULL) 
     7773    { 
     7774        free(mime_type); 
     7775    } 
    76717776    return Py_BuildValue("i",status); 
    76727777} 
     
    76927797         
    76937798    if (omdObj != Py_None) 
    7694         { 
     7799    { 
    76957800        omd = (msg_data_Object *)omdObj; 
    76967801        msg_data.content_type.ptr = PyString_AsString(omd->content_type); 
     
    76997804        msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 
    77007805        msg_data.msg_body.slen = strlen(PyString_AsString(omd->msg_body)); 
    7701         pool = pjsua_pool_create("pjsua", 4000, 4000); 
     7806        pool = pjsua_pool_create("pjsua", POOL_SIZE, POOL_SIZE); 
    77027807        translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 
    77037808        status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data);      
    77047809        pj_pool_release(pool); 
    7705         } else { 
     7810    } else { 
    77067811        status = pjsua_call_send_typing_ind(call_id, is_typing, NULL);   
    7707         } 
     7812    } 
    77087813    return Py_BuildValue("i",status); 
    77097814} 
     
    77517856    status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent); 
    77527857    sb = PyString_FromStringAndSize(buffer, maxlen); 
     7858    free(buffer); 
    77537859    return Py_BuildValue("O", sb); 
    77547860} 
     
    80168122    }, 
    80178123    { 
     8124        "buddy_config_default", py_pjsua_buddy_config_default, METH_VARARGS, 
     8125        pjsua_buddy_config_default_doc 
     8126    }, 
     8127    { 
    80188128        "get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS, 
    80198129        pjsua_get_buddy_count_doc 
     
    80268136        "enum_buddies", py_pjsua_enum_buddies, METH_VARARGS, 
    80278137        pjsua_enum_buddies_doc 
    8028     }, 
     8138    },     
    80298139    { 
    80308140        "buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS, 
Note: See TracChangeset for help on using the changeset viewer.