Changeset 924 for pjproject/trunk
- Timestamp:
- Feb 1, 2007 7:41:26 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.c
r918 r924 22 22 23 23 #define THIS_FILE "main.c" 24 #define POOL_SIZE 4000 25 #define SND_DEV_NUM 64 24 26 25 27 /* LIB BASE */ … … 195 197 pjsip_event_Object * obj; 196 198 197 199 obj = 198 200 (pjsip_event_Object *)PyType_GenericNew(&pjsip_event_Type, 199 201 NULL, NULL); 200 202 201 203 obj->event = e; 202 204 203 205 PyObject_CallFunctionObjArgs( … … 1303 1305 pj_list_init(hdr); 1304 1306 1305 for (i = 0; i < PyList_Size(py_hdr_list); i++) { 1307 for (i = 0; i < PyList_Size(py_hdr_list); i++) 1308 { 1306 1309 pj_str_t hname, hvalue; 1307 1310 pjsip_generic_string_hdr * new_hdr; 1308 1311 PyObject * tuple = PyList_GetItem(py_hdr_list, i); 1309 1312 1310 if (PyTuple_Check(tuple)) { 1313 if (PyTuple_Check(tuple)) 1314 { 1311 1315 hname.ptr = PyString_AsString(PyTuple_GetItem(tuple,0)); 1312 1316 hname.slen = strlen(PyString_AsString … … 1341 1345 len = pj_list_size(hdr); 1342 1346 1343 if (len > 0) { 1344 p_hdr = hdr; 1347 if (len > 0) 1348 { 1349 p_hdr = hdr; 1345 1350 Py_XDECREF(py_hdr_list); 1346 1351 py_hdr_list = PyList_New(len); 1347 1352 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); 1353 1359 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; 1360 1367 } 1361 1368 } … … 1555 1562 Py_XDECREF(self->realm); 1556 1563 Py_XDECREF(self->scheme); 1557 1558 1564 Py_XDECREF(self->username); 1565 Py_XDECREF(self->data); 1559 1566 self->ob_type->tp_free((PyObject*)self); 1560 1567 } … … 1709 1716 size = PyList_Size(py_desc); 1710 1717 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 { 1713 1722 return NULL; 1714 1723 } … … 1741 1750 1742 1751 pjsua_logging_config_default(&cfg); 1743 1752 obj = (logging_config_Object *) logging_config_new 1744 1753 (&logging_config_Type,NULL,NULL); 1745 1754 obj->msg_logging = cfg.msg_logging; … … 1766 1775 } 1767 1776 pjsua_config_default(&cfg); 1768 1777 obj = (config_Object *) config_new(&config_Type, NULL, NULL); 1769 1778 obj->max_calls = cfg.max_calls; 1770 1779 obj->thread_cnt = cfg.thread_cnt; … … 1840 1849 static PyObject *py_pjsua_reconfigure_logging(PyObject *pSelf, PyObject *pArgs) 1841 1850 { 1842 1851 PyObject * logObj; 1843 1852 logging_config_Object *log; 1844 1853 pjsua_logging_config cfg; … … 1849 1858 return NULL; 1850 1859 } 1851 if (logObj != Py_None) { 1860 if (logObj != Py_None) 1861 { 1852 1862 log = (logging_config_Object *)logObj; 1853 1863 cfg.msg_logging = log->msg_logging; … … 1864 1874 } else { 1865 1875 status = pjsua_reconfigure_logging(NULL); 1866 1876 } 1867 1877 return Py_BuildValue("i",status); 1868 1878 } … … 1989 1999 status = pjsua_create(); 1990 2000 1991 if (status == PJ_SUCCESS) { 2001 if (status == PJ_SUCCESS) 2002 { 1992 2003 status = pj_thread_local_alloc(&thread_id); 1993 2004 if (status == PJ_SUCCESS) … … 2029 2040 pjsua_media_config_default(&cfg_media); 2030 2041 2031 if (ua_cfgObj != Py_None) { 2042 if (ua_cfgObj != Py_None) 2043 { 2032 2044 ua_cfg = (config_Object *)ua_cfgObj; 2033 2045 cfg_ua.cred_count = ua_cfg->cred_count; … … 2068 2080 } 2069 2081 2070 if (log_cfgObj != Py_None) { 2082 if (log_cfgObj != Py_None) 2083 { 2071 2084 log_cfg = (logging_config_Object *)log_cfgObj; 2072 2085 cfg_log.msg_logging = log_cfg->msg_logging; … … 2085 2098 } 2086 2099 2087 if (media_cfgObj != Py_None) { 2100 if (media_cfgObj != Py_None) 2101 { 2088 2102 media_cfg = (media_config_Object *)media_cfgObj; 2089 2103 cfg_media.clock_rate = media_cfg->clock_rate; … … 2184 2198 "void py_pjsua.perror (string sender, string title, int status) " 2185 2199 "Display error message for the specified error code. Parameters: " 2186 2187 2188 2200 "sender: The log sender field; " 2201 "title: Message title for the error; " 2202 "status: Status code."; 2189 2203 2190 2204 static char pjsua_create_doc[] = … … 2202 2216 "optional, and the default values will be used when the config is not " 2203 2217 "specified. Parameters: " 2204 2205 2206 2218 "ua_cfg : User agent configuration; " 2219 "log_cfg : Optional logging configuration; " 2220 "media_cfg : Optional media configuration."; 2207 2221 2208 2222 static char pjsua_start_doc[] = … … 2222 2236 "Poll pjsua for events, and if necessary block the caller thread for the " 2223 2237 "specified maximum interval (in miliseconds) Parameters: " 2224 2238 "msec_timeout: Maximum time to wait, in miliseconds. " 2225 2239 "Returns: The number of events that have been handled during the poll. " 2226 2240 "Negative value indicates error, and application can retrieve the error " … … 2230 2244 "int py_pjsua.verify_sip_url (string c_url) " 2231 2245 "Verify that valid SIP url is given Parameters: " 2232 2246 "c_url: The URL, as NULL terminated string."; 2233 2247 2234 2248 static char pjsua_pool_create_doc[] = … … 2236 2250 "int increment) " 2237 2251 "Create memory pool Parameters: " 2238 2239 2240 2252 "name: Optional pool name; " 2253 "init_size: Initial size of the pool; " 2254 "increment: Increment size."; 2241 2255 2242 2256 static char pjsua_get_pjsip_endpt_doc[] = … … 2260 2274 "Application can call this function at any time (after pjsua_create(), of " 2261 2275 "course) to change logging settings. Parameters: " 2262 2276 "c: Logging configuration."; 2263 2277 2264 2278 static char pjsua_logging_config_default_doc[] = … … 2460 2474 if (self != NULL) 2461 2475 { 2462 2476 self->public_addr = PyString_FromString(""); 2463 2477 if (self->public_addr == NULL) 2464 2478 { … … 2719 2733 /* Type-specific fields go here. */ 2720 2734 PyObject * host; 2721 2735 int port; 2722 2736 } host_port_Object; 2723 2737 … … 3060 3074 3061 3075 pjsua_stun_config_default(&cfg); 3062 3076 obj = (stun_config_Object *)stun_config_new(&stun_config_Type, NULL, NULL); 3063 3077 obj->stun_port1 = cfg.stun_port1; 3064 3078 obj->stun_port2 = cfg.stun_port2; … … 3087 3101 } 3088 3102 pjsua_transport_config_default(&cfg); 3089 3103 obj = (transport_config_Object *)transport_config_new 3090 3104 (&transport_config_Type,NULL,NULL); 3091 3105 obj->public_addr = … … 3117 3131 (PyObject *pSelf, PyObject *pArgs) 3118 3132 { 3119 3133 PyObject * tmpObj; 3120 3134 stun_config_Object *obj; 3121 3135 pjsua_stun_config *cfg; … … 3125 3139 return NULL; 3126 3140 } 3127 3128 3129 3141 if (tmpObj != Py_None) 3142 { 3143 obj = (stun_config_Object *) tmpObj; 3130 3144 cfg = (pjsua_stun_config *)malloc(sizeof(pjsua_stun_config)); 3131 3145 cfg->stun_port1 = obj->stun_port1; … … 3135 3149 cfg->stun_srv2.ptr = PyString_AsString(obj->stun_srv2); 3136 3150 cfg->stun_srv2.slen = strlen(PyString_AsString(obj->stun_srv2)); 3137 3138 3139 3151 } else { 3152 cfg = NULL; 3153 } 3140 3154 pjsua_normalize_stun_config(cfg); 3141 3155 obj->stun_port1 = cfg->stun_port1; … … 3161 3175 int type; 3162 3176 3163 3177 PyObject * tmpObj; 3164 3178 transport_config_Object *obj; 3165 3179 pjsua_transport_config cfg; … … 3169 3183 return NULL; 3170 3184 } 3171 3172 3185 if (tmpObj != Py_None) 3186 { 3173 3187 obj = (transport_config_Object *)tmpObj; 3174 3188 cfg.public_addr.ptr = PyString_AsString(obj->public_addr); … … 3189 3203 strlen(PyString_AsString(obj->stun_config->stun_srv2)); 3190 3204 status = pjsua_transport_create(type, &cfg, &id); 3191 3205 } else { 3192 3206 status = pjsua_transport_create(type, NULL, &id); 3193 3207 } 3194 3208 3195 3209 … … 3204 3218 { 3205 3219 pj_status_t status; 3206 3220 PyObject * tmpObj; 3207 3221 pjsip_transport_Object *obj; 3208 3222 pjsua_transport_id id; … … 3212 3226 } 3213 3227 if (tmpObj != Py_None) 3214 3228 { 3215 3229 obj = (pjsip_transport_Object *)tmpObj; 3216 3230 status = pjsua_transport_register(obj->tp, &id); … … 3683 3697 if (s[0]) 3684 3698 { 3685 self->buf_[idx] = s[0];3699 self->buf_[idx] = s[0]; 3686 3700 } 3687 3701 else … … 3829 3843 obj = (acc_config_Object *)acc_config_new(&acc_config_Type, NULL, NULL); 3830 3844 obj->cred_count = cfg.cred_count; 3831 for (i = 0; i < 8; i++)3845 for (i = 0; i < PJSUA_MAX_ACC; i++) 3832 3846 { 3833 3847 /*obj->cred_info[i] = cfg.cred_info[i];*/ … … 3863 3877 PyString_FromStringAndSize(cfg.reg_uri.ptr, cfg.reg_uri.slen); 3864 3878 obj->proxy_cnt = cfg.proxy_cnt; 3865 for (i = 0; i < 8; i++)3879 for (i = 0; i < PJSUA_MAX_ACC; i++) 3866 3880 { 3867 3881 PyObject * str; … … 3956 3970 { 3957 3971 int is_default; 3958 3972 PyObject * acObj; 3959 3973 acc_config_Object * ac; 3960 3974 pjsua_acc_config cfg; … … 3971 3985 pjsua_acc_config_default(&cfg); 3972 3986 if (acObj != Py_None) 3973 3987 { 3974 3988 ac = (acc_config_Object *)acObj; 3975 3989 cfg.cred_count = ac->cred_count; 3976 for (i = 0; i < 8; i++)3990 for (i = 0; i < PJSUA_MAX_ACC; i++) 3977 3991 { 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 = strlen3987 (PyString_AsString(ci->scheme));3988 cfg.cred_info[i].username.ptr = PyString_AsString(ci->username);3989 cfg.cred_info[i].username.slen = strlen3990 (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_AsString4001 (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_local4019 * !modified @ 0512064020 */4021 static PyObject *py_pjsua_acc_add_local4022 (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_del4044 */4045 static PyObject *py_pjsua_acc_del4046 (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_modify4063 */4064 static PyObject *py_pjsua_acc_modify4065 (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 {4084 3992 /*cfg.cred_info[i] = ac->cred_info[i];*/ 4085 3993 pjsip_cred_info_Object * ci = (pjsip_cred_info_Object *) … … 4095 4003 cfg.cred_info[i].username.slen = strlen 4096 4004 (PyString_AsString(ci->username)); 4097 } 4005 cfg.cred_info[i].data_type = ci->data_type; 4006 } 4098 4007 cfg.force_contact.ptr = PyString_AsString(ac->force_contact); 4099 4008 cfg.force_contact.slen = strlen(PyString_AsString(ac->force_contact)); … … 4101 4010 cfg.id.slen = strlen(PyString_AsString(ac->id)); 4102 4011 cfg.priority = ac->priority; 4103 for (i = 0; i < 8; i++) { 4012 for (i = 0; i < PJSUA_MAX_ACC; i++) 4013 { 4104 4014 /*cfg.proxy[i] = ac->proxy[i];*/ 4105 4015 cfg.proxy[i].ptr = PyString_AsString 4106 4016 (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 */ 4036 static 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 */ 4060 static 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 */ 4079 static 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 } 4108 4124 cfg.proxy_cnt = ac->proxy_cnt; 4109 4125 cfg.publish_enabled = ac->publish_enabled; … … 4112 4128 cfg.reg_uri.slen = strlen(PyString_AsString(ac->reg_uri)); 4113 4129 status = pjsua_acc_modify(acc_id, &cfg); 4114 4115 4116 4130 } else { 4131 status = pjsua_acc_modify(acc_id, NULL); 4132 } 4117 4133 return Py_BuildValue("i", status); 4118 4134 } … … 4178 4194 4179 4195 status = pjsua_acc_get_info(acc_id, &info); 4180 if (status == PJ_SUCCESS) { 4196 if (status == PJ_SUCCESS) 4197 { 4181 4198 obj = (acc_info_Object *)acc_info_new(&acc_info_Type,NULL, NULL); 4182 4199 obj->acc_uri = 4183 4200 PyString_FromStringAndSize(info.acc_uri.ptr, 4184 4201 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 { 4186 4204 obj->buf_[i] = info.buf_[i]; 4187 4205 } … … 4222 4240 4223 4241 list = PyList_New(c); 4224 for (i = 0; i < c; i++) { 4242 for (i = 0; i < c; i++) 4243 { 4225 4244 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 4226 if (ret == -1) { 4245 if (ret == -1) 4246 { 4227 4247 return NULL; 4228 4248 } … … 4252 4272 4253 4273 list = PyList_New(c); 4254 for (i = 0; i < c; i++) { 4274 for (i = 0; i < c; i++) 4275 { 4255 4276 int ret; 4256 4257 4258 4259 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 4260 4281 (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]; 4263 4285 } 4264 4265 4266 4267 4268 4269 4270 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, 4271 4293 info[i].status_text.slen); 4272 4294 ret = PyList_SetItem(list, i, (PyObject *)obj); 4273 4295 if (ret == -1) { 4274 4296 return NULL; 4275 4297 } 4276 4298 } … … 4309 4331 { 4310 4332 int acc_id; 4311 4333 PyObject * tmpObj; 4312 4334 pjsip_rx_data_Object * obj; 4313 4335 pjsip_rx_data * rdata; … … 4318 4340 } 4319 4341 if (tmpObj != Py_None) 4320 4342 { 4321 4343 obj = (pjsip_rx_data_Object *)tmpObj; 4322 4344 rdata = obj->rdata; 4323 4345 acc_id = pjsua_acc_find_for_incoming(rdata); 4324 4346 } else { 4325 4347 acc_id = pjsua_acc_find_for_incoming(NULL); 4326 4348 } 4327 4349 return Py_BuildValue("i", acc_id); 4328 4350 } … … 4337 4359 int status; 4338 4360 int acc_id; 4339 4361 PyObject * pObj; 4340 4362 pj_pool_Object * p; 4341 4363 pj_pool_t * pool; … … 4350 4372 } 4351 4373 if (pObj != Py_None) 4352 4374 { 4353 4375 p = (pj_pool_Object *)pObj; 4354 4376 pool = p->pool; … … 4356 4378 uri.slen = strlen(PyString_AsString(stru)); 4357 4379 status = pjsua_acc_create_uac_contact(pool, &contact, acc_id, &uri); 4358 4380 } else { 4359 4381 status = pjsua_acc_create_uac_contact(NULL, &contact, acc_id, &uri); 4360 4382 } 4361 4383 strc = PyString_FromStringAndSize(contact.ptr, contact.slen); 4362 4384 … … 4373 4395 int status; 4374 4396 int acc_id; 4375 4397 PyObject * pObj; 4376 4398 pj_pool_Object * p; 4377 4399 pj_pool_t * pool; 4378 4400 PyObject * strc; 4379 4401 pj_str_t contact; 4380 4402 PyObject * rObj; 4381 4403 pjsip_rx_data_Object * objr; 4382 4404 pjsip_rx_data * rdata; … … 4387 4409 } 4388 4410 if (pObj != Py_None) 4389 4411 { 4390 4412 p = (pj_pool_Object *)pObj; 4391 4413 pool = p->pool; 4392 4414 } else { 4393 4415 pool = NULL; 4394 4416 } 4395 4417 if (rObj != Py_None) 4396 4397 4418 { 4419 objr = (pjsip_rx_data_Object *)rObj; 4398 4420 rdata = objr->rdata; 4399 4421 } else { 4400 4422 rdata = NULL; 4401 4423 } 4402 4424 status = pjsua_acc_create_uas_contact(pool, &contact, acc_id, rdata); 4403 4425 strc = PyString_FromStringAndSize(contact.ptr, contact.slen); … … 4762 4784 4763 4785 /* 4786 * py_pjsua_buddy_config_default 4787 */ 4788 static 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 /* 4764 4811 * py_pjsua_get_buddy_count 4765 4812 */ … … 4814 4861 status = pjsua_enum_buddies(id, &c); 4815 4862 list = PyList_New(c); 4816 for (i = 0; i < c; i++) { 4863 for (i = 0; i < c; i++) 4864 { 4817 4865 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 4818 if (ret == -1) { 4866 if (ret == -1) 4867 { 4819 4868 return NULL; 4820 4869 } … … 4844 4893 4845 4894 status = pjsua_buddy_get_info(buddy_id, &info); 4846 if (status == PJ_SUCCESS) { 4895 if (status == PJ_SUCCESS) 4896 { 4847 4897 obj = (buddy_info_Object *)buddy_info_new(&buddy_info_Type,NULL,NULL); 4848 4898 obj->id = info.id; … … 4861 4911 info.status_text.slen); 4862 4912 obj->monitor_pres = info.monitor_pres; 4863 for (i = 0; i < 256; i++) { 4913 for (i = 0; i < 256; i++) 4914 { 4864 4915 4865 4916 obj->buf_[i] = info.buf_[i]; … … 4893 4944 } 4894 4945 if (bcObj != Py_None) 4895 4896 4946 { 4947 bc = (buddy_config_Object *)bcObj; 4897 4948 4898 4949 cfg.subscribe = bc->subscribe; … … 4901 4952 4902 4953 status = pjsua_buddy_add(&cfg, &p_buddy_id); 4903 4954 } else { 4904 4955 status = pjsua_buddy_add(NULL, &p_buddy_id); 4905 4956 } … … 4974 5025 int status; 4975 5026 int acc_id; 4976 pj_str_t to, mime_type, content; 5027 pj_str_t * mime_type; 5028 pj_str_t to, content; 4977 5029 PyObject * st; 4978 5030 PyObject * smt; … … 4981 5033 PyObject * omdObj; 4982 5034 msg_data_Object * omd; 5035 4983 5036 int user_data; 4984 5037 pj_pool_t *pool; 4985 5038 5039 4986 5040 if (!PyArg_ParseTuple(pArgs, "iOOOOi", &acc_id, 4987 5041 &st, &smt, &sc, &omdObj, &user_data)) … … 4989 5043 return NULL; 4990 5044 } 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 } 4992 5053 to.ptr = PyString_AsString(st); 4993 5054 to.slen = strlen(PyString_AsString(st)); 4994 mime_type.ptr = PyString_AsString(smt); 4995 mime_type.slen = strlen(PyString_AsString(smt)); 5055 4996 5056 content.ptr = PyString_AsString(sc); 4997 5057 content.slen = strlen(PyString_AsString(sc)); 4998 5058 if (omdObj != Py_None) 4999 5059 { 5000 5060 5001 5061 omd = (msg_data_Object *)omdObj; … … 5005 5065 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 5006 5066 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); 5008 5068 5009 5069 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); 5012 5072 pj_pool_release(pool); 5013 5073 } else { 5014 5074 5015 status = pjsua_im_send(acc_id, &to, NULL,5075 status = pjsua_im_send(acc_id, &to, mime_type, 5016 5076 &content, NULL, NULL); 5017 } 5018 5077 } 5078 if (mime_type != NULL) 5079 { 5080 free(mime_type); 5081 } 5019 5082 return Py_BuildValue("i",status); 5020 5083 } … … 5032 5095 int is_typing; 5033 5096 pjsua_msg_data msg_data; 5034 5097 PyObject * omdObj; 5035 5098 msg_data_Object * omd; 5036 5099 pj_pool_t * pool; … … 5044 5107 to.slen = strlen(PyString_AsString(st)); 5045 5108 if (omdObj != Py_None) 5046 5109 { 5047 5110 omd = (msg_data_Object *)omdObj; 5048 5111 msg_data.content_type.ptr = PyString_AsString(omd->content_type); … … 5051 5114 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 5052 5115 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); 5054 5117 5055 5118 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 5056 5119 status = pjsua_im_typing(acc_id, &to, is_typing, &msg_data); 5057 5120 pj_pool_release(pool); 5058 5121 } else { 5059 5122 status = pjsua_im_typing(acc_id, &to, is_typing, NULL); 5060 5123 } 5061 5124 return Py_BuildValue("i",status); 5062 5125 } 5063 5126 5127 static char pjsua_buddy_config_default_doc[] = 5128 "py_pjsua.Buddy_Config py_pjsua.buddy_config_default () " 5129 "Set default values to the buddy config."; 5064 5130 static char pjsua_get_buddy_count_doc[] = 5065 5131 "int py_pjsua.get_buddy_count () " … … 5281 5347 } 5282 5348 5283 self->listeners = (PyListObject *)PyList_New( 254);5349 self->listeners = (PyListObject *)PyList_New(PJSUA_MAX_CONF_PORTS); 5284 5350 if (self->listeners == NULL) 5285 5351 { … … 5473 5539 if (self != NULL) 5474 5540 { 5475 self->name = (PyListObject *)PyList_New( 64);5541 self->name = (PyListObject *)PyList_New(SND_DEV_NUM); 5476 5542 if (self->name == NULL) 5477 5543 { … … 5968 6034 5969 6035 list = PyList_New(c); 5970 for (i = 0; i < c; i++) { 6036 for (i = 0; i < c; i++) 6037 { 5971 6038 int ret = PyList_SetItem(list, i, Py_BuildValue("i", id[i])); 5972 if (ret == -1) { 6039 if (ret == -1) 6040 { 5973 6041 return NULL; 5974 6042 } … … 6007 6075 obj->slot_id = info.slot_id; 6008 6076 6009 for (i = 0; i < 254; i++) {6077 for (i = 0; i < PJSUA_MAX_CONF_PORTS; i++) { 6010 6078 PyObject * item = Py_BuildValue("i",info.listeners[i]); 6011 6079 PyList_SetItem((PyObject *)obj->listeners, i, item); … … 6021 6089 { 6022 6090 int p_id; 6023 6091 PyObject * oportObj; 6024 6092 pjmedia_port_Object * oport; 6025 6026 6093 pjmedia_port * port; 6094 PyObject * opoolObj; 6027 6095 pj_pool_Object * opool; 6028 6096 pj_pool_t * pool; 6029 6097 6030 6098 int status; … … 6036 6104 } 6037 6105 if (opoolObj != Py_None) 6038 6106 { 6039 6107 opool = (pj_pool_Object *)opoolObj; 6040 6108 pool = opool->pool; 6041 6042 6043 6109 } else { 6110 opool = NULL; 6111 pool = NULL; 6044 6112 } 6045 6113 if (oportObj != Py_None) 6046 6114 { 6047 6115 oport = (pjmedia_port_Object *)oportObj; 6048 6116 port = oport->port; 6049 6117 } else { 6050 6118 oport = NULL; 6051 6119 port = NULL; 6052 6120 } 6053 6121 … … 6222 6290 pj_str_t str; 6223 6291 PyObject * enc_param; 6224 6292 pj_str_t strparam; 6225 6293 int enc_type; 6226 6294 … … 6235 6303 str.ptr = PyString_AsString(filename); 6236 6304 str.slen = strlen(PyString_AsString(filename)); 6237 6238 6305 strparam.ptr = PyString_AsString(enc_param); 6306 strparam.slen = strlen(PyString_AsString(enc_param)); 6239 6307 status = pjsua_recorder_create 6240 6308 (&str, enc_type, NULL, max_size, options, &p_id); … … 6293 6361 PyObject *list; 6294 6362 6295 pjmedia_snd_dev_info info[ 64];6363 pjmedia_snd_dev_info info[SND_DEV_NUM]; 6296 6364 unsigned c, i; 6297 6365 if (!PyArg_ParseTuple(pArgs, "")) … … 6304 6372 6305 6373 list = PyList_New(c); 6306 for (i = 0; i < c; i++) { 6374 for (i = 0; i < c; i++) 6375 { 6307 6376 int ret; 6308 6377 int j; 6309 6378 pjmedia_snd_dev_info_Object * obj; 6310 6379 obj = (pjmedia_snd_dev_info_Object *)pjmedia_snd_dev_info_new … … 6313 6382 obj->input_count = info[i].input_count; 6314 6383 obj->output_count = info[i].output_count; 6315 for (j = 0; j < 64; j++)6384 for (j = 0; j < SND_DEV_NUM; j++) 6316 6385 { 6317 6318 6319 6320 6321 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); 6322 6391 PyList_SetItem((PyObject *)obj->name, j, ostr); 6323 6392 free(str); 6324 6393 } 6325 6394 ret = PyList_SetItem(list, i, (PyObject *)obj); 6326 if (ret == -1) { 6395 if (ret == -1) 6396 { 6327 6397 return NULL; 6328 6398 } … … 6478 6548 6479 6549 list = PyList_New(c); 6480 for (i = 0; i < c; i++) { 6550 for (i = 0; i < c; i++) 6551 { 6481 6552 int ret; 6482 6553 int j; … … 6576 6647 pj_str_t str; 6577 6648 pjmedia_codec_param param; 6578 6649 PyObject * tmpObj; 6579 6650 pjmedia_codec_param_Object *obj; 6580 6651 … … 6588 6659 str.slen = strlen(PyString_AsString(id)); 6589 6660 if (tmpObj != Py_None) 6590 6661 { 6591 6662 obj = (pjmedia_codec_param_Object *)tmpObj; 6592 6663 param.info.avg_bps = obj->info->avg_bps; … … 6607 6678 } else { 6608 6679 status = pjsua_codec_set_param(&str, NULL); 6609 6680 } 6610 6681 return Py_BuildValue("i", status); 6611 6682 } … … 7158 7229 unsigned options; 7159 7230 pjsua_msg_data msg_data; 7160 7231 PyObject * omdObj; 7161 7232 msg_data_Object * omd; 7162 7233 int user_data; … … 7172 7243 dst_uri.ptr = PyString_AsString(sd); 7173 7244 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; 7176 7248 msg_data.content_type.ptr = PyString_AsString(omd->content_type); 7177 7249 msg_data.content_type.slen = strlen … … 7179 7251 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7180 7252 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); 7182 7254 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7183 7255 status = pjsua_call_make_call(acc_id, &dst_uri, … … 7278 7350 oi = (call_info_Object *)call_info_new(&call_info_Type, NULL, NULL); 7279 7351 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); 7292 7366 7293 7367 oi->call_id = PyString_FromStringAndSize(info.call_id.ptr, … … 7374 7448 int status; 7375 7449 int call_id; 7376 pj_str_t reason;7450 pj_str_t * reason; 7377 7451 PyObject * sr; 7378 7452 unsigned code; 7379 7453 pjsua_msg_data msg_data; 7380 7454 PyObject * omdObj; 7381 7455 msg_data_Object * omd; 7382 7456 pj_pool_t * pool; … … 7386 7460 return NULL; 7387 7461 } 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 { 7392 7472 omd = (msg_data_Object *)omdObj; 7393 7473 msg_data.content_type.ptr = PyString_AsString(omd->content_type); … … 7396 7476 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7397 7477 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); 7399 7479 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7400 7480 7401 status = pjsua_call_answer(call_id, code, &reason, &msg_data);7481 status = pjsua_call_answer(call_id, code, reason, &msg_data); 7402 7482 7403 7483 pj_pool_release(pool); 7404 7484 } else { 7405 7485 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 } 7408 7492 return Py_BuildValue("i",status); 7409 7493 } … … 7417 7501 int status; 7418 7502 int call_id; 7419 pj_str_t reason;7503 pj_str_t * reason; 7420 7504 PyObject * sr; 7421 7505 unsigned code; 7422 7506 pjsua_msg_data msg_data; 7423 7507 PyObject * omdObj; 7424 7508 msg_data_Object * omd; 7425 7509 pj_pool_t * pool = NULL; … … 7429 7513 return NULL; 7430 7514 } 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 { 7435 7525 omd = (msg_data_Object *)omdObj; 7436 7526 msg_data.content_type.ptr = PyString_AsString(omd->content_type); … … 7439 7529 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7440 7530 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); 7442 7532 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); 7444 7534 pj_pool_release(pool); 7445 7535 } 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); 7447 7541 } 7448 7542 return Py_BuildValue("i",status); … … 7467 7561 } 7468 7562 7469 if (omdObj != Py_None) { 7563 if (omdObj != Py_None) 7564 { 7470 7565 omd = (msg_data_Object *)omdObj; 7471 7566 msg_data.content_type.ptr = PyString_AsString(omd->content_type); … … 7474 7569 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7475 7570 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); 7477 7572 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7478 7573 status = pjsua_call_set_hold(call_id, &msg_data); 7479 7574 pj_pool_release(pool); 7480 7575 } else { 7481 7576 status = pjsua_call_set_hold(call_id, NULL); 7482 7577 } 7483 7578 return Py_BuildValue("i",status); 7484 7579 } … … 7504 7599 7505 7600 if (omdObj != Py_None) 7506 7601 { 7507 7602 omd = (msg_data_Object *)omdObj; 7508 7603 msg_data.content_type.ptr = PyString_AsString(omd->content_type); … … 7511 7606 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7512 7607 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); 7514 7609 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7515 7610 status = pjsua_call_reinvite(call_id, unhold, &msg_data); … … 7545 7640 7546 7641 if (omdObj != Py_None) 7547 7642 { 7548 7643 omd = (msg_data_Object *)omdObj; 7549 7644 msg_data.content_type.ptr = PyString_AsString(omd->content_type); … … 7552 7647 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7553 7648 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); 7555 7650 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7556 7651 status = pjsua_call_xfer(call_id, &dest, &msg_data); 7557 7652 pj_pool_release(pool); 7558 7653 } else { 7559 7654 status = pjsua_call_xfer(call_id, &dest, NULL); 7560 7655 } 7561 7656 return Py_BuildValue("i",status); 7562 7657 } … … 7584 7679 7585 7680 if (omdObj != Py_None) 7586 7681 { 7587 7682 omd = (msg_data_Object *)omdObj; 7588 7683 msg_data.content_type.ptr = PyString_AsString(omd->content_type); … … 7591 7686 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7592 7687 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); 7594 7689 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7595 7690 status = pjsua_call_xfer_replaces 7596 7691 (call_id, dest_call_id, options, &msg_data); 7597 7692 pj_pool_release(pool); 7598 7693 } else { 7599 7694 status = pjsua_call_xfer_replaces(call_id, dest_call_id,options, NULL); 7600 7695 } 7601 7696 return Py_BuildValue("i",status); 7602 7697 } … … 7632 7727 int status; 7633 7728 int call_id; 7634 pj_str_t mime_type, content; 7729 pj_str_t content; 7730 pj_str_t * mime_type; 7635 7731 PyObject * sm; 7636 7732 PyObject * sc; … … 7646 7742 return NULL; 7647 7743 } 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 } 7651 7752 content.ptr = PyString_AsString(sc); 7652 7753 content.slen = strlen(PyString_AsString(sc)); 7653 7754 7654 7755 if (omdObj != Py_None) 7655 7756 { 7656 7757 omd = (msg_data_Object *)omdObj; 7657 7758 msg_data.content_type.ptr = PyString_AsString(omd->content_type); … … 7660 7761 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7661 7762 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); 7663 7764 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7664 7765 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); 7666 7767 pj_pool_release(pool); 7667 7768 } else { 7668 7769 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 } 7671 7776 return Py_BuildValue("i",status); 7672 7777 } … … 7692 7797 7693 7798 if (omdObj != Py_None) 7694 7799 { 7695 7800 omd = (msg_data_Object *)omdObj; 7696 7801 msg_data.content_type.ptr = PyString_AsString(omd->content_type); … … 7699 7804 msg_data.msg_body.ptr = PyString_AsString(omd->msg_body); 7700 7805 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); 7702 7807 translate_hdr(pool, &msg_data.hdr_list, omd->hdr_list); 7703 7808 status = pjsua_call_send_typing_ind(call_id, is_typing, &msg_data); 7704 7809 pj_pool_release(pool); 7705 7810 } else { 7706 7811 status = pjsua_call_send_typing_ind(call_id, is_typing, NULL); 7707 7812 } 7708 7813 return Py_BuildValue("i",status); 7709 7814 } … … 7751 7856 status = pjsua_call_dump(call_id, with_media, buffer, maxlen, indent); 7752 7857 sb = PyString_FromStringAndSize(buffer, maxlen); 7858 free(buffer); 7753 7859 return Py_BuildValue("O", sb); 7754 7860 } … … 8016 8122 }, 8017 8123 { 8124 "buddy_config_default", py_pjsua_buddy_config_default, METH_VARARGS, 8125 pjsua_buddy_config_default_doc 8126 }, 8127 { 8018 8128 "get_buddy_count", py_pjsua_get_buddy_count, METH_VARARGS, 8019 8129 pjsua_get_buddy_count_doc … … 8026 8136 "enum_buddies", py_pjsua_enum_buddies, METH_VARARGS, 8027 8137 pjsua_enum_buddies_doc 8028 }, 8138 }, 8029 8139 { 8030 8140 "buddy_get_info", py_pjsua_buddy_get_info, METH_VARARGS,
Note: See TracChangeset
for help on using the changeset viewer.