Ignore:
Timestamp:
Mar 18, 2011 7:54:50 AM (13 years ago)
Author:
nanang
Message:

Re #1201:

  • Initial version of video stream integration into pjsua-lib.
  • Replaced audio info array in pjsua_call_info with media info array.
  • Added video media info into call dump.
  • Fixed assertion caused by pjsua_set_state(NULL) logging after pjlib shutdown.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_call.c

    r3457 r3463  
    13251325     
    13261326    /* Build array of media status and dir */ 
    1327     info->audio_cnt = 0; 
     1327    info->media_cnt = 0; 
    13281328    for (mi=0; mi < call->med_cnt && 
    1329                info->audio_cnt < PJ_ARRAY_SIZE(info->audio); ++mi) 
     1329               info->media_cnt < PJ_ARRAY_SIZE(info->media); ++mi) 
    13301330    { 
    13311331        pjsua_call_media *call_med = &call->media[mi]; 
    1332         if (call_med->type != PJMEDIA_TYPE_AUDIO) 
     1332 
     1333        info->media[info->media_cnt].index = mi; 
     1334        info->media[info->media_cnt].status = call_med->state; 
     1335        info->media[info->media_cnt].dir = call_med->dir; 
     1336        info->media[info->media_cnt].type = call_med->type; 
     1337 
     1338        if (call_med->type == PJMEDIA_TYPE_AUDIO) { 
     1339            info->media[info->media_cnt].stream.audio.conf_slot =  
     1340                                                call_med->strm.a.conf_slot; 
     1341        } else if (call_med->type == PJMEDIA_TYPE_VIDEO) { 
     1342            info->media[info->media_cnt].stream.video.capturer = 
     1343                                                call_med->strm.v.capturer; 
     1344            info->media[info->media_cnt].stream.video.renderer = 
     1345                                                call_med->strm.v.renderer; 
     1346        } else { 
    13331347            continue; 
    1334         info->audio[info->audio_cnt].index = mi; 
    1335         info->audio[info->audio_cnt].media_status = call_med->state; 
    1336         info->audio[info->audio_cnt].media_dir = call_med->dir; 
    1337         info->audio[info->audio_cnt].conf_slot = call_med->strm.a.conf_slot; 
    1338         ++info->audio_cnt; 
    1339     } 
    1340  
    1341     if (info->audio_cnt) { 
    1342         info->media_status = info->audio[0].media_status; 
    1343         info->media_dir = info->audio[0].media_dir; 
    1344     } 
    1345  
    1346     /* conference slot number */ 
    1347     info->conf_slot = call->media[call->audio_idx].strm.a.conf_slot; 
     1348        } 
     1349        ++info->media_cnt; 
     1350    } 
     1351 
     1352    if (call->audio_idx != -1) { 
     1353        info->media_status = call->media[call->audio_idx].state; 
     1354        info->media_dir = call->media[call->audio_idx].dir; 
     1355        info->conf_slot = call->media[call->audio_idx].strm.a.conf_slot; 
     1356    } 
    13481357 
    13491358    /* calculate duration */ 
     
    21922201} 
    21932202 
     2203static unsigned dump_media_stat(const char *indent,  
     2204                                char *buf, unsigned maxlen, 
     2205                                const pjmedia_rtcp_stat *stat, 
     2206                                const char *rx_info, const char *tx_info) 
     2207{ 
     2208    char last_update[64]; 
     2209    char packets[32], bytes[32], ipbytes[32], avg_bps[32], avg_ipbps[32]; 
     2210    pj_time_val media_duration, now; 
     2211    char *p = buf, *end = buf+maxlen; 
     2212    int len; 
     2213 
     2214    if (stat->rx.update_cnt == 0) 
     2215        strcpy(last_update, "never"); 
     2216    else { 
     2217        pj_gettimeofday(&now); 
     2218        PJ_TIME_VAL_SUB(now, stat->rx.update); 
     2219        sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", 
     2220                now.sec / 3600, 
     2221                (now.sec % 3600) / 60, 
     2222                now.sec % 60, 
     2223                now.msec); 
     2224    } 
     2225 
     2226    pj_gettimeofday(&media_duration); 
     2227    PJ_TIME_VAL_SUB(media_duration, stat->start); 
     2228    if (PJ_TIME_VAL_MSEC(media_duration) == 0) 
     2229        media_duration.msec = 1; 
     2230 
     2231    len = pj_ansi_snprintf(p, end-p, 
     2232           "%s     RX %s last update:%s\n" 
     2233           "%s        total %spkt %sB (%sB +IP hdr) @avg=%sbps/%sbps\n" 
     2234           "%s        pkt loss=%d (%3.1f%%), discrd=%d (%3.1f%%), dup=%d (%2.1f%%), reord=%d (%3.1f%%)\n" 
     2235           "%s              (msec)    min     avg     max     last    dev\n" 
     2236           "%s        loss period: %7.3f %7.3f %7.3f %7.3f %7.3f\n" 
     2237           "%s        jitter     : %7.3f %7.3f %7.3f %7.3f %7.3f\n" 
     2238#if defined(PJMEDIA_RTCP_STAT_HAS_RAW_JITTER) && PJMEDIA_RTCP_STAT_HAS_RAW_JITTER!=0 
     2239           "%s        raw jitter : %7.3f %7.3f %7.3f %7.3f %7.3f\n" 
     2240#endif 
     2241#if defined(PJMEDIA_RTCP_STAT_HAS_IPDV) && PJMEDIA_RTCP_STAT_HAS_IPDV!=0 
     2242           "%s        IPDV       : %7.3f %7.3f %7.3f %7.3f %7.3f\n" 
     2243#endif 
     2244           "%s", 
     2245           indent, 
     2246           rx_info? rx_info : "", 
     2247           last_update, 
     2248 
     2249           indent, 
     2250           good_number(packets, stat->rx.pkt), 
     2251           good_number(bytes, stat->rx.bytes), 
     2252           good_number(ipbytes, stat->rx.bytes + stat->rx.pkt * 40), 
     2253           good_number(avg_bps, (pj_int32_t)((pj_int64_t)stat->rx.bytes * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))), 
     2254           good_number(avg_ipbps, (pj_int32_t)(((pj_int64_t)stat->rx.bytes + stat->rx.pkt * 40) * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))), 
     2255           indent, 
     2256           stat->rx.loss, 
     2257           (stat->rx.loss? stat->rx.loss * 100.0 / (stat->rx.pkt + stat->rx.loss) : 0), 
     2258           stat->rx.discard,  
     2259           (stat->rx.discard? stat->rx.discard * 100.0 / (stat->rx.pkt + stat->rx.loss) : 0), 
     2260           stat->rx.dup,  
     2261           (stat->rx.dup? stat->rx.dup * 100.0 / (stat->rx.pkt + stat->rx.loss) : 0), 
     2262           stat->rx.reorder,  
     2263           (stat->rx.reorder? stat->rx.reorder * 100.0 / (stat->rx.pkt + stat->rx.loss) : 0), 
     2264           indent, indent, 
     2265           stat->rx.loss_period.min / 1000.0,  
     2266           stat->rx.loss_period.mean / 1000.0,  
     2267           stat->rx.loss_period.max / 1000.0, 
     2268           stat->rx.loss_period.last / 1000.0, 
     2269           pj_math_stat_get_stddev(&stat->rx.loss_period) / 1000.0, 
     2270           indent, 
     2271           stat->rx.jitter.min / 1000.0, 
     2272           stat->rx.jitter.mean / 1000.0, 
     2273           stat->rx.jitter.max / 1000.0, 
     2274           stat->rx.jitter.last / 1000.0, 
     2275           pj_math_stat_get_stddev(&stat->rx.jitter) / 1000.0, 
     2276#if defined(PJMEDIA_RTCP_STAT_HAS_RAW_JITTER) && PJMEDIA_RTCP_STAT_HAS_RAW_JITTER!=0 
     2277           indent, 
     2278           stat->rx_raw_jitter.min / 1000.0, 
     2279           stat->rx_raw_jitter.mean / 1000.0, 
     2280           stat->rx_raw_jitter.max / 1000.0, 
     2281           stat->rx_raw_jitter.last / 1000.0, 
     2282           pj_math_stat_get_stddev(&stat->rx_raw_jitter) / 1000.0, 
     2283#endif 
     2284#if defined(PJMEDIA_RTCP_STAT_HAS_IPDV) && PJMEDIA_RTCP_STAT_HAS_IPDV!=0 
     2285           indent, 
     2286           stat->rx_ipdv.min / 1000.0, 
     2287           stat->rx_ipdv.mean / 1000.0, 
     2288           stat->rx_ipdv.max / 1000.0, 
     2289           stat->rx_ipdv.last / 1000.0, 
     2290           pj_math_stat_get_stddev(&stat->rx_ipdv) / 1000.0, 
     2291#endif 
     2292           "" 
     2293           ); 
     2294 
     2295    if (len < 1 || len > end-p) { 
     2296        *p = '\0'; 
     2297        return (p-buf); 
     2298    } 
     2299    p += len; 
     2300 
     2301    if (stat->tx.update_cnt == 0) 
     2302        strcpy(last_update, "never"); 
     2303    else { 
     2304        pj_gettimeofday(&now); 
     2305        PJ_TIME_VAL_SUB(now, stat->tx.update); 
     2306        sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", 
     2307                now.sec / 3600, 
     2308                (now.sec % 3600) / 60, 
     2309                now.sec % 60, 
     2310                now.msec); 
     2311    } 
     2312 
     2313    len = pj_ansi_snprintf(p, end-p, 
     2314           "%s     TX %s last update:%s\n" 
     2315           "%s        total %spkt %sB (%sB +IP hdr) @avg %sbps/%sbps\n" 
     2316           "%s        pkt loss=%d (%3.1f%%), dup=%d (%3.1f%%), reorder=%d (%3.1f%%)\n" 
     2317           "%s              (msec)    min     avg     max     last    dev \n" 
     2318           "%s        loss period: %7.3f %7.3f %7.3f %7.3f %7.3f\n" 
     2319           "%s        jitter     : %7.3f %7.3f %7.3f %7.3f %7.3f\n", 
     2320           indent, 
     2321           tx_info, 
     2322           last_update, 
     2323 
     2324           indent, 
     2325           good_number(packets, stat->tx.pkt), 
     2326           good_number(bytes, stat->tx.bytes), 
     2327           good_number(ipbytes, stat->tx.bytes + stat->tx.pkt * 40), 
     2328           good_number(avg_bps, (pj_int32_t)((pj_int64_t)stat->tx.bytes * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))), 
     2329           good_number(avg_ipbps, (pj_int32_t)(((pj_int64_t)stat->tx.bytes + stat->tx.pkt * 40) * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))), 
     2330 
     2331           indent, 
     2332           stat->tx.loss, 
     2333           (stat->tx.loss? stat->tx.loss * 100.0 / (stat->tx.pkt + stat->tx.loss) : 0), 
     2334           stat->tx.dup,  
     2335           (stat->tx.dup? stat->tx.dup * 100.0 / (stat->tx.pkt + stat->tx.loss) : 0), 
     2336           stat->tx.reorder,  
     2337           (stat->tx.reorder? stat->tx.reorder * 100.0 / (stat->tx.pkt + stat->tx.loss) : 0), 
     2338 
     2339           indent, indent, 
     2340           stat->tx.loss_period.min / 1000.0,  
     2341           stat->tx.loss_period.mean / 1000.0,  
     2342           stat->tx.loss_period.max / 1000.0, 
     2343           stat->tx.loss_period.last / 1000.0, 
     2344           pj_math_stat_get_stddev(&stat->tx.loss_period) / 1000.0, 
     2345           indent, 
     2346           stat->tx.jitter.min / 1000.0, 
     2347           stat->tx.jitter.mean / 1000.0, 
     2348           stat->tx.jitter.max / 1000.0, 
     2349           stat->tx.jitter.last / 1000.0, 
     2350           pj_math_stat_get_stddev(&stat->tx.jitter) / 1000.0 
     2351           ); 
     2352 
     2353    if (len < 1 || len > end-p) { 
     2354        *p = '\0'; 
     2355        return (p-buf); 
     2356    } 
     2357    p += len; 
     2358 
     2359    len = pj_ansi_snprintf(p, end-p, 
     2360           "%s     RTT msec      : %7.3f %7.3f %7.3f %7.3f %7.3f\n", 
     2361           indent, 
     2362           stat->rtt.min / 1000.0, 
     2363           stat->rtt.mean / 1000.0, 
     2364           stat->rtt.max / 1000.0, 
     2365           stat->rtt.last / 1000.0, 
     2366           pj_math_stat_get_stddev(&stat->rtt) / 1000.0 
     2367           ); 
     2368    if (len < 1 || len > end-p) { 
     2369        *p = '\0'; 
     2370        return (p-buf); 
     2371    } 
     2372    p += len; 
     2373 
     2374    return (p-buf); 
     2375} 
     2376 
    21942377 
    21952378/* Dump media session */ 
     
    22042387    for (i=0; i<call->med_cnt; ++i) { 
    22052388        pjsua_call_media *call_med = &call->media[i]; 
    2206         pjmedia_stream_info info; 
    2207         pjmedia_stream *stream = call_med->strm.a.stream; 
     2389        pjmedia_rtcp_stat stat; 
     2390        pj_bool_t has_stat; 
    22082391        pjmedia_transport_info tp_info; 
    2209         pjmedia_rtcp_stat stat; 
    22102392        char rem_addr_buf[80]; 
     2393        char codec_info[32] = {'0'}; 
     2394        char rx_info[80] = {'\0'}; 
     2395        char tx_info[80] = {'\0'}; 
    22112396        const char *rem_addr; 
    2212         const char *dir; 
    2213         char last_update[64]; 
    2214         char packets[32], bytes[32], ipbytes[32], avg_bps[32], avg_ipbps[32]; 
    2215         pj_time_val media_duration, now; 
     2397        const char *dir_str; 
     2398        const char *media_type_str; 
     2399 
     2400        switch (call_med->type) { 
     2401        case PJMEDIA_TYPE_AUDIO: 
     2402            media_type_str = "audio"; 
     2403            break; 
     2404        case PJMEDIA_TYPE_VIDEO: 
     2405            media_type_str = "video"; 
     2406            break; 
     2407        case PJMEDIA_TYPE_APPLICATION: 
     2408            media_type_str = "application"; 
     2409            break; 
     2410        default: 
     2411            media_type_str = "unknown"; 
     2412            break; 
     2413        } 
    22162414 
    22172415        /* Check if the stream is deactivated */ 
    2218         if (call_med->tp == NULL || stream == NULL) { 
    2219             const char *media_type_str; 
    2220  
    2221             switch (call_med->type) { 
    2222             case PJMEDIA_TYPE_AUDIO: 
    2223                 media_type_str = "audio"; 
    2224                 break; 
    2225             case PJMEDIA_TYPE_VIDEO: 
    2226                 media_type_str = "video"; 
    2227                 break; 
    2228             case PJMEDIA_TYPE_APPLICATION: 
    2229                 media_type_str = "application"; 
    2230                 break; 
    2231             default: 
    2232                 media_type_str = "unknown"; 
    2233                 break; 
    2234             } 
     2416        if (call_med->tp == NULL || 
     2417            (!call_med->strm.a.stream && !call_med->strm.v.stream)) 
     2418        { 
    22352419            len = pj_ansi_snprintf(p, end-p, 
    2236                       "%s  #%d m=%s deactivated\n", 
     2420                      "%s #%d %s deactivated\n", 
    22372421                      indent, i, media_type_str); 
    22382422            if (len < 1 || len > end-p) { 
     
    22472431        pjmedia_transport_info_init(&tp_info); 
    22482432        pjmedia_transport_get_info(call_med->tp, &tp_info); 
    2249  
    2250         pjmedia_stream_get_info(stream, &info); 
    2251         pjmedia_stream_get_stat(stream, &stat); 
    22522433 
    22532434        // rem_addr will contain actual address of RTP originator, instead of 
     
    22682449             * (http://trac.pjsip.org/repos/ticket/1079) 
    22692450             */ 
    2270             dir = "inactive"; 
    2271         } else if (info.dir == PJMEDIA_DIR_ENCODING) 
    2272             dir = "sendonly"; 
    2273         else if (info.dir == PJMEDIA_DIR_DECODING) 
    2274             dir = "recvonly"; 
    2275         else if (info.dir == PJMEDIA_DIR_ENCODING_DECODING) 
    2276             dir = "sendrecv"; 
     2451            dir_str = "inactive"; 
     2452        } else if (call_med->dir == PJMEDIA_DIR_ENCODING) 
     2453            dir_str = "sendonly"; 
     2454        else if (call_med->dir == PJMEDIA_DIR_DECODING) 
     2455            dir_str = "recvonly"; 
     2456        else if (call_med->dir == PJMEDIA_DIR_ENCODING_DECODING) 
     2457            dir_str = "sendrecv"; 
    22772458        else 
    2278             dir = "inactive"; 
    2279  
    2280          
     2459            dir_str = "inactive"; 
     2460 
     2461        if (call_med->type == PJMEDIA_TYPE_AUDIO) { 
     2462            pjmedia_stream *stream = call_med->strm.a.stream; 
     2463            pjmedia_stream_info info; 
     2464 
     2465            pjmedia_stream_get_stat(stream, &stat); 
     2466            has_stat = PJ_TRUE; 
     2467 
     2468            pjmedia_stream_get_info(stream, &info); 
     2469            pj_ansi_snprintf(codec_info, sizeof(codec_info), " %.*s @%dkHz", 
     2470                             info.fmt.encoding_name.slen, 
     2471                             info.fmt.encoding_name.ptr, 
     2472                             info.fmt.clock_rate / 1000); 
     2473            pj_ansi_snprintf(rx_info, sizeof(rx_info), "pt=%d,", 
     2474                             info.fmt.pt); 
     2475            pj_ansi_snprintf(tx_info, sizeof(tx_info), "pt=%d, ptime=%d,", 
     2476                             info.tx_pt, 
     2477                             info.param->setting.frm_per_pkt* 
     2478                             info.param->info.frm_ptime); 
     2479        } else if (call_med->type == PJMEDIA_TYPE_VIDEO) { 
     2480            pjmedia_vid_stream *stream = call_med->strm.v.stream; 
     2481            pjmedia_vid_stream_info info; 
     2482 
     2483            pjmedia_vid_stream_get_stat(stream, &stat); 
     2484            has_stat = PJ_TRUE; 
     2485 
     2486            pjmedia_vid_stream_get_info(stream, &info); 
     2487            pj_ansi_snprintf(codec_info, sizeof(codec_info), " %.*s", 
     2488                             info.codec_info.encoding_name.slen, 
     2489                             info.codec_info.encoding_name.ptr); 
     2490            if (call_med->dir & PJMEDIA_DIR_DECODING) { 
     2491                pjmedia_video_format_detail *vfd; 
     2492                vfd = pjmedia_format_get_video_format_detail( 
     2493                                        &info.codec_param->dec_fmt, PJ_TRUE); 
     2494                pj_ansi_snprintf(rx_info, sizeof(rx_info), 
     2495                                 "pt=%d, size=%dx%d, fps=%.2f,", 
     2496                                 info.rx_pt, 
     2497                                 vfd->size.w, vfd->size.h, 
     2498                                 vfd->fps.num*1.0/vfd->fps.denum); 
     2499            } 
     2500            if (call_med->dir & PJMEDIA_DIR_ENCODING) { 
     2501                pjmedia_video_format_detail *vfd; 
     2502                vfd = pjmedia_format_get_video_format_detail( 
     2503                                        &info.codec_param->enc_fmt, PJ_TRUE); 
     2504                pj_ansi_snprintf(tx_info, sizeof(tx_info), 
     2505                                 "pt=%d, size=%dx%d, fps=%.2f,", 
     2506                                 info.tx_pt, 
     2507                                 vfd->size.w, vfd->size.h, 
     2508                                 vfd->fps.num*1.0/vfd->fps.denum); 
     2509            } 
     2510        } else { 
     2511            has_stat = PJ_FALSE; 
     2512        } 
     2513 
    22812514        len = pj_ansi_snprintf(p, end-p, 
    2282                   "%s  #%d %.*s @%dKHz, %s, peer=%s", 
    2283                   indent, i, 
    2284                   (int)info.fmt.encoding_name.slen, 
    2285                   info.fmt.encoding_name.ptr, 
    2286                   info.fmt.clock_rate / 1000, 
    2287                   dir, 
     2515                  "%s  #%d %s%s, %s, peer=%s\n", 
     2516                  indent, 
     2517                  call_med->idx, 
     2518                  media_type_str, 
     2519                  codec_info, 
     2520                  dir_str, 
    22882521                  rem_addr); 
    22892522        if (len < 1 || len > end-p) { 
     
    22912524            return; 
    22922525        } 
    2293  
    22942526        p += len; 
    2295         *p++ = '\n'; 
    2296         *p = '\0'; 
    2297  
    2298         if (stat.rx.update_cnt == 0) 
    2299             strcpy(last_update, "never"); 
    2300         else { 
    2301             pj_gettimeofday(&now); 
    2302             PJ_TIME_VAL_SUB(now, stat.rx.update); 
    2303             sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", 
    2304                     now.sec / 3600, 
    2305                     (now.sec % 3600) / 60, 
    2306                     now.sec % 60, 
    2307                     now.msec); 
    2308         } 
    2309  
    2310         pj_gettimeofday(&media_duration); 
    2311         PJ_TIME_VAL_SUB(media_duration, stat.start); 
    2312         if (PJ_TIME_VAL_MSEC(media_duration) == 0) 
    2313             media_duration.msec = 1; 
    2314  
    2315         /* protect against division by zero */ 
    2316         if (stat.rx.pkt == 0) 
    2317             stat.rx.pkt = 1; 
    2318         if (stat.tx.pkt == 0) 
    2319             stat.tx.pkt = 1; 
    2320  
    2321         len = pj_ansi_snprintf(p, end-p, 
    2322                "%s     RX pt=%d, stat last update: %s\n" 
    2323                "%s        total %spkt %sB (%sB +IP hdr) @avg=%sbps/%sbps\n" 
    2324                "%s        pkt loss=%d (%3.1f%%), discrd=%d (%3.1f%%), dup=%d (%2.1f%%), reord=%d (%3.1f%%)\n" 
    2325                "%s              (msec)    min     avg     max     last    dev\n" 
    2326                "%s        loss period: %7.3f %7.3f %7.3f %7.3f %7.3f\n" 
    2327                "%s        jitter     : %7.3f %7.3f %7.3f %7.3f %7.3f" 
    2328 #if defined(PJMEDIA_RTCP_STAT_HAS_RAW_JITTER) && PJMEDIA_RTCP_STAT_HAS_RAW_JITTER!=0 
    2329                "\n" 
    2330                "%s        raw jitter : %7.3f %7.3f %7.3f %7.3f %7.3f" 
    2331 #endif 
    2332 #if defined(PJMEDIA_RTCP_STAT_HAS_IPDV) && PJMEDIA_RTCP_STAT_HAS_IPDV!=0 
    2333                "\n" 
    2334                "%s        IPDV       : %7.3f %7.3f %7.3f %7.3f %7.3f" 
    2335 #endif 
    2336                "%s", 
    2337                indent, info.fmt.pt, 
    2338                last_update, 
    2339                indent, 
    2340                good_number(packets, stat.rx.pkt), 
    2341                good_number(bytes, stat.rx.bytes), 
    2342                good_number(ipbytes, stat.rx.bytes + stat.rx.pkt * 40), 
    2343                good_number(avg_bps, (pj_int32_t)((pj_int64_t)stat.rx.bytes * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))), 
    2344                good_number(avg_ipbps, (pj_int32_t)(((pj_int64_t)stat.rx.bytes + stat.rx.pkt * 40) * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))), 
    2345                indent, 
    2346                stat.rx.loss, 
    2347                stat.rx.loss * 100.0 / (stat.rx.pkt + stat.rx.loss), 
    2348                stat.rx.discard,  
    2349                stat.rx.discard * 100.0 / (stat.rx.pkt + stat.rx.loss), 
    2350                stat.rx.dup,  
    2351                stat.rx.dup * 100.0 / (stat.rx.pkt + stat.rx.loss), 
    2352                stat.rx.reorder,  
    2353                stat.rx.reorder * 100.0 / (stat.rx.pkt + stat.rx.loss), 
    2354                indent, indent, 
    2355                stat.rx.loss_period.min / 1000.0,  
    2356                stat.rx.loss_period.mean / 1000.0,  
    2357                stat.rx.loss_period.max / 1000.0, 
    2358                stat.rx.loss_period.last / 1000.0, 
    2359                pj_math_stat_get_stddev(&stat.rx.loss_period) / 1000.0, 
    2360                indent, 
    2361                stat.rx.jitter.min / 1000.0, 
    2362                stat.rx.jitter.mean / 1000.0, 
    2363                stat.rx.jitter.max / 1000.0, 
    2364                stat.rx.jitter.last / 1000.0, 
    2365                pj_math_stat_get_stddev(&stat.rx.jitter) / 1000.0, 
    2366 #if defined(PJMEDIA_RTCP_STAT_HAS_RAW_JITTER) && PJMEDIA_RTCP_STAT_HAS_RAW_JITTER!=0 
    2367                indent, 
    2368                stat.rx_raw_jitter.min / 1000.0, 
    2369                stat.rx_raw_jitter.mean / 1000.0, 
    2370                stat.rx_raw_jitter.max / 1000.0, 
    2371                stat.rx_raw_jitter.last / 1000.0, 
    2372                pj_math_stat_get_stddev(&stat.rx_raw_jitter) / 1000.0, 
    2373 #endif 
    2374 #if defined(PJMEDIA_RTCP_STAT_HAS_IPDV) && PJMEDIA_RTCP_STAT_HAS_IPDV!=0 
    2375                indent, 
    2376                stat.rx_ipdv.min / 1000.0, 
    2377                stat.rx_ipdv.mean / 1000.0, 
    2378                stat.rx_ipdv.max / 1000.0, 
    2379                stat.rx_ipdv.last / 1000.0, 
    2380                pj_math_stat_get_stddev(&stat.rx_ipdv) / 1000.0, 
    2381 #endif 
    2382                "" 
    2383                ); 
    2384  
    2385         if (len < 1 || len > end-p) { 
    2386             *p = '\0'; 
    2387             return; 
    2388         } 
    2389  
    2390         p += len; 
    2391         *p++ = '\n'; 
    2392         *p = '\0'; 
    2393          
    2394         if (stat.tx.update_cnt == 0) 
    2395             strcpy(last_update, "never"); 
    2396         else { 
    2397             pj_gettimeofday(&now); 
    2398             PJ_TIME_VAL_SUB(now, stat.tx.update); 
    2399             sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", 
    2400                     now.sec / 3600, 
    2401                     (now.sec % 3600) / 60, 
    2402                     now.sec % 60, 
    2403                     now.msec); 
    2404         } 
    2405  
    2406         len = pj_ansi_snprintf(p, end-p, 
    2407                "%s     TX pt=%d, ptime=%dms, stat last update: %s\n" 
    2408                "%s        total %spkt %sB (%sB +IP hdr) @avg %sbps/%sbps\n" 
    2409                "%s        pkt loss=%d (%3.1f%%), dup=%d (%3.1f%%), reorder=%d (%3.1f%%)\n" 
    2410                "%s              (msec)    min     avg     max     last    dev \n" 
    2411                "%s        loss period: %7.3f %7.3f %7.3f %7.3f %7.3f\n" 
    2412                "%s        jitter     : %7.3f %7.3f %7.3f %7.3f %7.3f%s", 
    2413                indent, 
    2414                info.tx_pt, 
    2415                info.param->info.frm_ptime * info.param->setting.frm_per_pkt, 
    2416                last_update, 
    2417  
    2418                indent, 
    2419                good_number(packets, stat.tx.pkt), 
    2420                good_number(bytes, stat.tx.bytes), 
    2421                good_number(ipbytes, stat.tx.bytes + stat.tx.pkt * 40), 
    2422                good_number(avg_bps, (pj_int32_t)((pj_int64_t)stat.tx.bytes * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))), 
    2423                good_number(avg_ipbps, (pj_int32_t)(((pj_int64_t)stat.tx.bytes + stat.tx.pkt * 40) * 8 * 1000 / PJ_TIME_VAL_MSEC(media_duration))), 
    2424  
    2425                indent, 
    2426                stat.tx.loss, 
    2427                stat.tx.loss * 100.0 / (stat.tx.pkt + stat.tx.loss), 
    2428                stat.tx.dup,  
    2429                stat.tx.dup * 100.0 / (stat.tx.pkt + stat.tx.loss), 
    2430                stat.tx.reorder,  
    2431                stat.tx.reorder * 100.0 / (stat.tx.pkt + stat.tx.loss), 
    2432  
    2433                indent, indent, 
    2434                stat.tx.loss_period.min / 1000.0,  
    2435                stat.tx.loss_period.mean / 1000.0,  
    2436                stat.tx.loss_period.max / 1000.0, 
    2437                stat.tx.loss_period.last / 1000.0, 
    2438                pj_math_stat_get_stddev(&stat.tx.loss_period) / 1000.0, 
    2439                indent, 
    2440                stat.tx.jitter.min / 1000.0, 
    2441                stat.tx.jitter.mean / 1000.0, 
    2442                stat.tx.jitter.max / 1000.0, 
    2443                stat.tx.jitter.last / 1000.0, 
    2444                pj_math_stat_get_stddev(&stat.tx.jitter) / 1000.0, 
    2445                "" 
    2446                ); 
    2447  
    2448         if (len < 1 || len > end-p) { 
    2449             *p = '\0'; 
    2450             return; 
    2451         } 
    2452  
    2453         p += len; 
    2454         *p++ = '\n'; 
    2455         *p = '\0'; 
    2456  
    2457         len = pj_ansi_snprintf(p, end-p, 
    2458                "%s     RTT msec      : %7.3f %7.3f %7.3f %7.3f %7.3f", 
    2459                indent, 
    2460                stat.rtt.min / 1000.0, 
    2461                stat.rtt.mean / 1000.0, 
    2462                stat.rtt.max / 1000.0, 
    2463                stat.rtt.last / 1000.0, 
    2464                pj_math_stat_get_stddev(&stat.rtt) / 1000.0 
    2465                ); 
    2466         if (len < 1 || len > end-p) { 
    2467             *p = '\0'; 
    2468             return; 
    2469         } 
    2470  
    2471         p += len; 
    2472         *p++ = '\n'; 
    2473         *p = '\0'; 
     2527 
     2528        if (has_stat) { 
     2529            len = dump_media_stat(indent, p, end-p, &stat, 
     2530                                  rx_info, tx_info); 
     2531            p += len; 
     2532        } 
    24742533 
    24752534#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 
Note: See TracChangeset for help on using the changeset viewer.