Ignore:
Timestamp:
Apr 9, 2006 4:46:05 PM (18 years ago)
Author:
bennylp
Message:

Added call duration in pjsua

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c

    r393 r398  
    694694        PJ_LOG(3,(THIS_FILE,  
    695695               "                  RX pt=%d, stat last update: %s\n" 
    696                "                     total %s packets %sB received (%sB +IP hdr)%s\n" 
     696               "                     total %spkt %sB (%sB +IP hdr)%s\n" 
    697697               "                     pkt loss=%d (%3.1f%%), dup=%d (%3.1f%%), reorder=%d (%3.1f%%)%s\n" 
    698698               "                           (msec)    min     avg     max     last\n" 
     
    739739        PJ_LOG(3,(THIS_FILE, 
    740740               "                  TX pt=%d, stat last update: %s\n" 
    741                "                     total %s packets %sB received (%sB +IP hdr)%s\n" 
     741               "                     total %spkt %sB (%sB +IP hdr)%s\n" 
    742742               "                     pkt loss=%d (%3.1f%%), dup=%d (%3.1f%%), reorder=%d (%3.1f%%)%s\n" 
    743743               "                           (msec)    min     avg     max     last\n" 
     
    816816        for (i=0; i<pjsua.max_calls; ++i) { 
    817817 
    818             if (pjsua.calls[i].inv == NULL) 
     818            pjsua_call *call = &pjsua.calls[i]; 
     819            pj_time_val duration, res_delay, con_delay; 
     820 
     821            if (call->inv == NULL) 
    819822                continue; 
    820823 
     
    822825            PJ_LOG(3,(THIS_FILE, "%s", buf)); 
    823826 
    824             if (pjsua.calls[i].session) 
    825                 dump_media_session(pjsua.calls[i].session); 
     827            /* Calculate call duration */ 
     828            if (call->inv->state >= PJSIP_INV_STATE_CONFIRMED) { 
     829                pj_gettimeofday(&duration); 
     830                PJ_TIME_VAL_SUB(duration, call->conn_time); 
     831                con_delay = call->conn_time; 
     832                PJ_TIME_VAL_SUB(con_delay, call->start_time); 
     833            } else { 
     834                duration.sec = duration.msec = 0; 
     835                con_delay.sec = con_delay.msec = 0; 
     836            } 
     837 
     838            /* Calculate first response delay */ 
     839            if (call->inv->state >= PJSIP_INV_STATE_EARLY) { 
     840                res_delay = call->res_time; 
     841                PJ_TIME_VAL_SUB(res_delay, call->start_time); 
     842            } else { 
     843                res_delay.sec = res_delay.msec = 0; 
     844            } 
     845 
     846            /* Print duration */ 
     847            PJ_LOG(3,(THIS_FILE,  
     848                      "               Call time: %02dh:%02dm:%02ds, " 
     849                      "1st res in %d ms, conn in %dms", 
     850                      (duration.sec / 3600), 
     851                      ((duration.sec % 3600)/60), 
     852                      (duration.sec % 60), 
     853                      PJ_TIME_VAL_MSEC(res_delay),  
     854                      PJ_TIME_VAL_MSEC(con_delay))); 
     855 
     856            /* Dump session statistics */ 
     857            if (call->session) 
     858                dump_media_session(call->session); 
    826859        } 
    827860    } 
Note: See TracChangeset for help on using the changeset viewer.