- Timestamp:
- Feb 2, 2007 10:52:04 AM (18 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/py_pjsua
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py
r916 r926 73 73 write_log(3, "Account successfully (un)registered") 74 74 75 76 def on_buddy_state(buddy_id): 77 write_log(3, "On Buddy state called") 78 buddy_info = py_pjsua.buddy_get_info(buddy_id) 79 if buddy_info.status != 0 and buddy_info.status != 200: 80 write_log(3, "Status of " + `buddy_info.uri` + " is " + `buddy_info.status_text`) 81 else: 82 write_log(3, "Status : " + `buddy_info.status`) 83 84 def on_pager(call_id, strfrom, strto, contact, mime_type, text): 85 write_log(3, "MESSAGE from " + `strfrom` + " : " + `text`) 86 87 def on_pager_status(call_id, strto, body, user_data, status, reason): 88 write_log(3, "MESSAGE to " + `strto` + " status " + `status` + " reason " + `reason`) 75 89 76 90 # Utility: display PJ error and exit … … 118 132 ua_cfg.cb.on_reg_state = on_reg_state 119 133 ua_cfg.cb.on_call_state = on_call_state 134 ua_cfg.cb.on_buddy_state = on_buddy_state 135 ua_cfg.cb.on_pager = on_pager 136 ua_cfg.cb.on_pager_status = on_pager_status 137 120 138 121 139 # Create and initialize media config -
pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.c
r925 r926 24 24 #define POOL_SIZE 4000 25 25 #define SND_DEV_NUM 64 26 #define SND_NAME_LEN 64 26 27 27 28 /* LIB BASE */ … … 404 405 /* 405 406 * cb_on_pager 406 * *declares method on_pager for callback struct407 * declares method on_pager for callback struct 407 408 */ 408 409 static void cb_on_pager(pjsua_call_id call_id, const pj_str_t *from, … … 3161 3162 obj->stun_srv2 = 3162 3163 PyString_FromStringAndSize(cfg->stun_srv2.ptr, cfg->stun_srv2.slen); 3163 free(cfg); 3164 if (cfg != NULL) 3165 { 3166 free(cfg); 3167 } 3164 3168 Py_INCREF(Py_None); 3165 3169 return Py_None; … … 5025 5029 int status; 5026 5030 int acc_id; 5027 pj_str_t * mime_type ;5031 pj_str_t * mime_type, tmp_mime_type; 5028 5032 pj_str_t to, content; 5029 5033 PyObject * st; … … 5043 5047 return NULL; 5044 5048 } 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));5049 if (smt != Py_None) 5050 { 5051 mime_type = &tmp_mime_type; 5052 tmp_mime_type.ptr = PyString_AsString(smt); 5053 tmp_mime_type.slen = strlen(PyString_AsString(smt)); 5050 5054 } else { 5051 5055 mime_type = NULL; … … 5076 5080 &content, NULL, NULL); 5077 5081 } 5078 if (mime_type != NULL) 5079 { 5080 free(mime_type); 5081 } 5082 5082 5083 return Py_BuildValue("i",status); 5083 5084 } … … 5511 5512 unsigned output_count; 5512 5513 unsigned default_samples_per_sec; 5513 Py ListObject * name;5514 PyObject * name; 5514 5515 5515 5516 } pjmedia_snd_dev_info_Object; … … 5539 5540 if (self != NULL) 5540 5541 { 5541 self->name = (PyListObject *)PyList_New(SND_DEV_NUM);5542 self->name = PyString_FromString(""); 5542 5543 if (self->name == NULL) 5543 5544 { … … 6376 6377 int ret; 6377 6378 int j; 6379 char * str; 6380 6378 6381 pjmedia_snd_dev_info_Object * obj; 6379 6382 obj = (pjmedia_snd_dev_info_Object *)pjmedia_snd_dev_info_new … … 6382 6385 obj->input_count = info[i].input_count; 6383 6386 obj->output_count = info[i].output_count; 6384 for (j = 0; j < SND_DEV_NUM; j++) 6387 str = (char *)malloc(SND_NAME_LEN * sizeof(char)); 6388 memset(str, 0, SND_NAME_LEN); 6389 for (j = 0; j < SND_NAME_LEN; j++) 6385 6390 { 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); 6391 PyList_SetItem((PyObject *)obj->name, j, ostr); 6392 free(str); 6391 str[j] = info[i].name[j]; 6393 6392 } 6393 obj->name = PyString_FromStringAndSize(str, SND_NAME_LEN); 6394 free(str); 6394 6395 ret = PyList_SetItem(list, i, (PyObject *)obj); 6395 6396 if (ret == -1) … … 7448 7449 int status; 7449 7450 int call_id; 7450 pj_str_t * reason ;7451 pj_str_t * reason, tmp_reason; 7451 7452 PyObject * sr; 7452 7453 unsigned code; … … 7464 7465 reason = NULL; 7465 7466 } else { 7466 reason = (pj_str_t *)malloc(sizeof(pj_str_t));7467 reason->ptr = PyString_AsString(sr);7468 reason->slen = strlen(PyString_AsString(sr));7467 reason = &tmp_reason; 7468 tmp_reason.ptr = PyString_AsString(sr); 7469 tmp_reason.slen = strlen(PyString_AsString(sr)); 7469 7470 } 7470 7471 if (omdObj != Py_None) … … 7486 7487 status = pjsua_call_answer(call_id, code, reason, NULL); 7487 7488 } 7488 if (reason != NULL) 7489 { 7490 free(reason); 7491 } 7489 7492 7490 return Py_BuildValue("i",status); 7493 7491 } … … 7501 7499 int status; 7502 7500 int call_id; 7503 pj_str_t * reason ;7501 pj_str_t * reason, tmp_reason; 7504 7502 PyObject * sr; 7505 7503 unsigned code; … … 7517 7515 reason = NULL; 7518 7516 } else { 7519 reason = (pj_str_t *)malloc(sizeof(pj_str_t));7520 reason->ptr = PyString_AsString(sr);7521 reason->slen = strlen(PyString_AsString(sr));7517 reason = &tmp_reason; 7518 tmp_reason.ptr = PyString_AsString(sr); 7519 tmp_reason.slen = strlen(PyString_AsString(sr)); 7522 7520 } 7523 7521 if (omdObj != Py_None) … … 7536 7534 status = pjsua_call_hangup(call_id, code, reason, NULL); 7537 7535 } 7538 if (reason != NULL) 7539 { 7540 free(reason); 7541 } 7536 7542 7537 return Py_BuildValue("i",status); 7543 7538 } … … 7728 7723 int call_id; 7729 7724 pj_str_t content; 7730 pj_str_t * mime_type ;7725 pj_str_t * mime_type, tmp_mime_type; 7731 7726 PyObject * sm; 7732 7727 PyObject * sc; … … 7746 7741 mime_type = NULL; 7747 7742 } 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));7743 mime_type = &tmp_mime_type; 7744 tmp_mime_type.ptr = PyString_AsString(sm); 7745 tmp_mime_type.slen = strlen(PyString_AsString(sm)); 7751 7746 } 7752 7747 content.ptr = PyString_AsString(sc); … … 7770 7765 (call_id, mime_type, &content, NULL, (void *)user_data); 7771 7766 } 7772 if (mime_type != NULL) 7773 { 7774 free(mime_type); 7775 } 7767 7776 7768 return Py_BuildValue("i",status); 7777 7769 }
Note: See TracChangeset
for help on using the changeset viewer.