Changeset 4059


Ignore:
Timestamp:
Apr 17, 2012 7:18:52 AM (7 years ago)
Author:
bennylp
Message:

Re #1476: for simple blocking, the bandwidth typically needs to be set to larger value than the avg_bitrage, otherwise the simple_blocking will slow down the transmission too much, causing video and audio unsync. This patch force the bandwidth to at least three times avg_bps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c

    r4043 r4059  
    4646#define SIGNATURE                       PJMEDIA_SIG_PORT_VID_STREAM 
    4747 
     48#define TRACE_RC                        0 
     49 
    4850/* Tracing jitter buffer operations in a stream session to a CSV file. 
    4951 * The trace will contain JB operation timestamp, frame info, RTP info, and 
     
    159161 
    160162    pj_timestamp             ts_freq;       /**< Timestamp frequency.       */ 
     163 
     164#if TRACE_RC 
     165    unsigned                 rc_total_sleep; 
     166    unsigned                 rc_total_pkt; 
     167    unsigned                 rc_total_img; 
     168    pj_timestamp             tx_start; 
     169    pj_timestamp             tx_end; 
     170#endif 
    161171}; 
    162172 
     
    918928    } 
    919929 
    920 #if 0 
     930#if TRACE_RC 
    921931    /* Trace log for rate control */ 
    922932    { 
    923933        pj_timestamp end_time; 
     934        unsigned total_sleep; 
     935 
    924936        pj_get_timestamp(&end_time); 
     937        total_sleep = pj_elapsed_msec(&initial_time, &end_time); 
    925938        PJ_LOG(5, (stream->name.ptr, "total pkt=%d size=%d sleep=%d", 
    926                    pkt_cnt, total_sent, 
    927                    pj_elapsed_msec(&initial_time, &end_time))); 
     939                   pkt_cnt, total_sent, total_sleep)); 
     940 
     941        if (stream->tx_start.u64 == 0) 
     942            stream->tx_start = initial_time; 
     943        stream->tx_end = end_time; 
     944        stream->rc_total_pkt += pkt_cnt; 
     945        stream->rc_total_sleep += total_sleep; 
     946        stream->rc_total_img++; 
    928947    } 
    929948#endif 
     
    14581477    pj_get_timestamp_freq(&stream->ts_freq); 
    14591478    if (info->rc_cfg.bandwidth == 0) 
    1460         info->rc_cfg.bandwidth = vfd_enc->max_bps * 150 / 100; 
     1479        info->rc_cfg.bandwidth = vfd_enc->max_bps; 
     1480 
     1481    /* For simple blocking, need to have bandwidth large enough, otherwise 
     1482     * we can slow down the transmission too much 
     1483     */ 
     1484    if (info->rc_cfg.method==PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING && 
     1485        info->rc_cfg.bandwidth < vfd_enc->avg_bps * 3) 
     1486    { 
     1487        info->rc_cfg.bandwidth = vfd_enc->avg_bps * 3; 
     1488    } 
    14611489 
    14621490    /* Override the initial framerate in the decoding direction. This initial 
     
    14741502    if (status != PJ_SUCCESS) 
    14751503        return status; 
    1476  
    14771504 
    14781505    /* Create encoder channel */ 
     
    16311658    PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL); 
    16321659 
     1660#if TRACE_RC 
     1661    { 
     1662        unsigned total_time; 
     1663 
     1664        total_time = pj_elapsed_msec(&stream->tx_start, &stream->tx_end); 
     1665        PJ_LOG(5, (stream->name.ptr,  
     1666                   "RC stat: pkt_cnt=%.2f/image, sleep=%.2fms/s, fps=%.2f", 
     1667                   stream->rc_total_pkt*1.0/stream->rc_total_img, 
     1668                   stream->rc_total_sleep*1000.0/total_time, 
     1669                   stream->rc_total_img*1000.0/total_time)); 
     1670    } 
     1671#endif 
     1672 
    16331673    /* Send RTCP BYE (also SDES) */ 
    16341674    if (!stream->rtcp_sdes_bye_disabled) { 
Note: See TracChangeset for help on using the changeset viewer.