Changeset 926


Ignore:
Timestamp:
Feb 2, 2007 10:52:04 AM (17 years ago)
Author:
fahris
Message:

py_pjsuaupdated 020207

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  
    7373                write_log(3, "Account successfully (un)registered") 
    7474 
     75 
     76def 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                 
     84def on_pager(call_id, strfrom, strto, contact, mime_type, text): 
     85        write_log(3, "MESSAGE from " + `strfrom` + " : " + `text`) 
     86         
     87def on_pager_status(call_id, strto, body, user_data, status, reason): 
     88        write_log(3, "MESSAGE to " + `strto` + " status " + `status` + " reason " + `reason`) 
    7589 
    7690# Utility: display PJ error and exit 
     
    118132        ua_cfg.cb.on_reg_state = on_reg_state 
    119133        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         
    120138 
    121139        # Create and initialize media config 
  • pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.c

    r925 r926  
    2424#define POOL_SIZE    4000 
    2525#define SND_DEV_NUM  64 
     26#define SND_NAME_LEN  64 
    2627 
    2728/* LIB BASE */ 
     
    404405/* 
    405406 * cb_on_pager 
    406  * * declares method on_pager for callback struct 
     407 * declares method on_pager for callback struct 
    407408 */ 
    408409static void cb_on_pager(pjsua_call_id call_id, const pj_str_t *from, 
     
    31613162    obj->stun_srv2 =  
    31623163        PyString_FromStringAndSize(cfg->stun_srv2.ptr, cfg->stun_srv2.slen); 
    3163     free(cfg); 
     3164    if (cfg != NULL) 
     3165    { 
     3166        free(cfg); 
     3167    } 
    31643168    Py_INCREF(Py_None); 
    31653169    return Py_None; 
     
    50255029    int status; 
    50265030    int acc_id; 
    5027     pj_str_t * mime_type; 
     5031    pj_str_t * mime_type, tmp_mime_type; 
    50285032    pj_str_t to, content; 
    50295033    PyObject * st; 
     
    50435047        return NULL; 
    50445048    } 
    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)); 
    50505054    } else { 
    50515055        mime_type = NULL; 
     
    50765080                        &content, NULL, NULL);   
    50775081    } 
    5078     if (mime_type != NULL) 
    5079     { 
    5080         free(mime_type); 
    5081     } 
     5082     
    50825083    return Py_BuildValue("i",status); 
    50835084} 
     
    55115512    unsigned  output_count; 
    55125513    unsigned  default_samples_per_sec;     
    5513     PyListObject * name; 
     5514    PyObject * name; 
    55145515 
    55155516} pjmedia_snd_dev_info_Object; 
     
    55395540    if (self != NULL) 
    55405541    { 
    5541         self->name = (PyListObject *)PyList_New(SND_DEV_NUM); 
     5542        self->name = PyString_FromString(""); 
    55425543        if (self->name == NULL) 
    55435544        { 
     
    63766377        int ret; 
    63776378        int j; 
     6379        char * str; 
     6380         
    63786381        pjmedia_snd_dev_info_Object * obj; 
    63796382        obj = (pjmedia_snd_dev_info_Object *)pjmedia_snd_dev_info_new 
     
    63826385        obj->input_count = info[i].input_count; 
    63836386        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++) 
    63856390        { 
    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]; 
    63936392        } 
     6393        obj->name = PyString_FromStringAndSize(str, SND_NAME_LEN); 
     6394        free(str); 
    63946395        ret = PyList_SetItem(list, i, (PyObject *)obj); 
    63956396        if (ret == -1)  
     
    74487449    int status; 
    74497450    int call_id; 
    7450     pj_str_t * reason; 
     7451    pj_str_t * reason, tmp_reason; 
    74517452    PyObject * sr; 
    74527453    unsigned code; 
     
    74647465        reason = NULL; 
    74657466    } 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)); 
    74697470    } 
    74707471    if (omdObj != Py_None)  
     
    74867487        status = pjsua_call_answer(call_id, code, reason, NULL);         
    74877488    } 
    7488     if (reason != NULL) 
    7489     { 
    7490         free(reason); 
    7491     } 
     7489     
    74927490    return Py_BuildValue("i",status); 
    74937491} 
     
    75017499    int status; 
    75027500    int call_id; 
    7503     pj_str_t * reason; 
     7501    pj_str_t * reason, tmp_reason; 
    75047502    PyObject * sr; 
    75057503    unsigned code; 
     
    75177515        reason = NULL; 
    75187516    } 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)); 
    75227520    } 
    75237521    if (omdObj != Py_None)  
     
    75367534        status = pjsua_call_hangup(call_id, code, reason, NULL);         
    75377535    } 
    7538     if (reason != NULL) 
    7539     { 
    7540         free(reason); 
    7541     } 
     7536     
    75427537    return Py_BuildValue("i",status); 
    75437538} 
     
    77287723    int call_id; 
    77297724    pj_str_t content; 
    7730     pj_str_t * mime_type; 
     7725    pj_str_t * mime_type, tmp_mime_type; 
    77317726    PyObject * sm; 
    77327727    PyObject * sc; 
     
    77467741        mime_type = NULL; 
    77477742    } 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)); 
    77517746    } 
    77527747    content.ptr = PyString_AsString(sc); 
     
    77707765                        (call_id, mime_type, &content, NULL, (void *)user_data);         
    77717766    } 
    7772     if (mime_type != NULL) 
    7773     { 
    7774         free(mime_type); 
    7775     } 
     7767     
    77767768    return Py_BuildValue("i",status); 
    77777769} 
Note: See TracChangeset for help on using the changeset viewer.