Ignore:
Timestamp:
Feb 9, 2006 2:01:40 PM (18 years ago)
Author:
bennylp
Message:

Updated with new jitter buffer, and statistics in pjsua

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua/main.c

    r167 r169  
    2626static pjsip_inv_session *inv_session; 
    2727 
     28static const char *inv_state_names[] = 
     29{ 
     30    "NULL      ", 
     31    "CALLING   ", 
     32    "INCOMING  ", 
     33    "EARLY     ", 
     34    "CONNECTING", 
     35    "CONFIRMED ", 
     36    "DISCONNCTD", 
     37    "TERMINATED", 
     38}; 
     39 
    2840/* 
    2941 * Notify UI when invite state has changed. 
     
    3143void pjsua_ui_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e) 
    3244{ 
    33     const char *state_names[] = 
    34     { 
    35         "NULL", 
    36         "CALLING", 
    37         "INCOMING", 
    38         "EARLY", 
    39         "CONNECTING", 
    40         "CONFIRMED", 
    41         "DISCONNECTED", 
    42         "TERMINATED", 
    43     }; 
    44  
    4545    PJ_UNUSED_ARG(e); 
    4646 
    47     PJ_LOG(3,(THIS_FILE, "INVITE session state changed to %s", state_names[inv->state])); 
     47    PJ_LOG(3,(THIS_FILE, "INVITE session state changed to %s",  
     48              inv_state_names[inv->state])); 
    4849 
    4950    if (inv->state == PJSIP_INV_STATE_DISCONNECTED) { 
     
    5859} 
    5960 
     61 
     62static void print_invite_session(const char *title, 
     63                                 struct pjsua_inv_data *inv_data,  
     64                                 char *buf, pj_size_t size) 
     65{ 
     66    int len; 
     67    pjsip_inv_session *inv = inv_data->inv; 
     68    pjsip_dialog *dlg = inv->dlg; 
     69    char userinfo[128]; 
     70 
     71    /* Dump invite sesion info. */ 
     72 
     73    len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 
     74    if (len < 1) 
     75        pj_native_strcpy(userinfo, "<--uri too long-->"); 
     76    else 
     77        userinfo[len] = '\0'; 
     78     
     79    len = pj_snprintf(buf, size, "%s[%s] %s", 
     80                      title, 
     81                      inv_state_names[inv->state], 
     82                      userinfo); 
     83    if (len < 1 || len >= (int)size) { 
     84        pj_native_strcpy(buf, "<--uri too long-->"); 
     85        len = 18; 
     86    } else 
     87        buf[len] = '\0'; 
     88} 
     89 
     90static void dump_media_session(pjmedia_session *session) 
     91{ 
     92    unsigned i; 
     93    pjmedia_session_info info; 
     94 
     95    pjmedia_session_get_info(session, &info); 
     96 
     97    for (i=0; i<info.stream_cnt; ++i) { 
     98        pjmedia_stream_stat strm_stat; 
     99        const char *rem_addr; 
     100        int rem_port; 
     101        const char *dir; 
     102 
     103        pjmedia_session_get_stream_stat(session, i, &strm_stat); 
     104        rem_addr = pj_inet_ntoa(info.stream_info[i].rem_addr.sin_addr); 
     105        rem_port = pj_ntohs(info.stream_info[i].rem_addr.sin_port); 
     106 
     107        if (info.stream_info[i].dir == PJMEDIA_DIR_ENCODING) 
     108            dir = "sendonly"; 
     109        else if (info.stream_info[i].dir == PJMEDIA_DIR_DECODING) 
     110            dir = "recvonly"; 
     111        else if (info.stream_info[i].dir == PJMEDIA_DIR_ENCODING_DECODING) 
     112            dir = "sendrecv"; 
     113        else 
     114            dir = "inactive"; 
     115 
     116         
     117        PJ_LOG(3,(THIS_FILE,  
     118                  "%s[Media strm#%d] %.*s, %s, peer=%s:%d", 
     119                  "               ", 
     120                  i, 
     121                  info.stream_info[i].fmt.encoding_name.slen, 
     122                  info.stream_info[i].fmt.encoding_name.ptr, 
     123                  dir, 
     124                  rem_addr, rem_port)); 
     125        PJ_LOG(3,(THIS_FILE,  
     126                  "%s tx {pkt=%u, bytes=%u} rx {pkt=%u, bytes=%u}", 
     127                  "                             ", 
     128                  strm_stat.enc.pkt, strm_stat.enc.bytes, 
     129                  strm_stat.dec.pkt, strm_stat.dec.bytes)); 
     130 
     131    } 
     132} 
     133 
     134/* 
     135 * Dump application states. 
     136 */ 
     137static void pjsua_dump(void) 
     138{ 
     139    struct pjsua_inv_data *inv_data; 
     140    char buf[128]; 
     141    unsigned log_decor; 
     142 
     143    log_decor = pj_log_get_decor(); 
     144    pj_log_set_decor(PJ_LOG_HAS_NEWLINE); 
     145 
     146    pjsip_endpt_dump(pjsua.endpt, 1); 
     147    pjsip_ua_dump(); 
     148 
     149    /* Dump all invite sessions: */ 
     150    PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:")); 
     151 
     152    if (pj_list_empty(&pjsua.inv_list)) { 
     153 
     154        PJ_LOG(3,(THIS_FILE, "  - no sessions -")); 
     155 
     156    } else { 
     157 
     158        inv_data = pjsua.inv_list.next; 
     159 
     160        while (inv_data != &pjsua.inv_list) { 
     161 
     162            print_invite_session("  ", inv_data, buf, sizeof(buf)); 
     163            PJ_LOG(3,(THIS_FILE, "%s", buf)); 
     164 
     165            if (inv_data->session) 
     166                dump_media_session(inv_data->session); 
     167 
     168            inv_data = inv_data->next; 
     169        } 
     170    } 
     171 
     172    pj_log_set_decor(log_decor); 
     173} 
     174 
     175 
     176/* 
     177 * Show a bit of help. 
     178 */ 
    60179static void ui_help(void) 
    61180{ 
     
    63182    puts("Console keys:"); 
    64183    puts("  m    Make a call/another call"); 
     184    puts("  d    Dump application states"); 
    65185    puts("  a    Answer incoming call"); 
    66186    puts("  h    Hangup current call"); 
     
    122242            break; 
    123243 
     244 
     245        case 'd': 
     246            pjsua_dump(); 
     247            break; 
    124248 
    125249        case 'a': 
Note: See TracChangeset for help on using the changeset viewer.