Ignore:
Timestamp:
Apr 4, 2006 7:43:24 PM (18 years ago)
Author:
bennylp
Message:

Changed RTCP timing to use high resolution timestamp

File:
1 edited

Legend:

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

    r378 r381  
    2828 
    2929 
     30#define USE_TIMESTAMP   PJ_HAS_HIGH_RES_TIMER 
     31 
    3032 
    3133/* 
     
    4648 
    4749PJ_DEF(void) pjmedia_rtcp_init(pjmedia_rtcp_session *s,  
     50                               unsigned clock_rate, 
    4851                               pj_uint32_t ssrc) 
    4952{ 
     
    5255    pj_memset(rtcp_pkt, 0, sizeof(pjmedia_rtcp_pkt)); 
    5356     
     57    /* Set clock rate */ 
     58    s->clock_rate = clock_rate; 
     59 
    5460    /* Init time */ 
    5561    s->rtcp_lsr.hi = s->rtcp_lsr.lo = 0; 
     
    6571    rtcp_pkt->sr.ssrc = pj_htonl(ssrc); 
    6672     
     73    /* Get timestamp frequency */ 
     74#if USE_TIMESTAMP 
     75    pj_get_timestamp_freq(&s->ts_freq); 
     76#endif 
     77 
    6778    /* RR will be initialized on receipt of the first RTP packet. */ 
    6879} 
     
    91102    pj_uint32_t arrival; 
    92103    pj_int32_t transit; 
    93     unsigned long timer_tick; 
    94     pj_time_val tv; 
    95104    int status; 
    96105 
     
    107116    ++s->received; 
    108117 
    109     pj_gettimeofday(&tv); 
    110     timer_tick = tv.sec * 1000 + tv.msec; 
    111      
    112118    /* 
    113119     * Calculate jitter (s->jitter is in timer tick unit) 
    114120     */ 
    115     PJ_TODO(SUPPORT_JITTER_CALCULATION_FOR_NON_8KHZ_SAMPLE_RATE) 
    116  
    117     arrival = timer_tick << 3;  // 8 samples per ms. 
     121#if USE_TIMESTAMP 
     122    { 
     123        pj_timestamp ts; 
     124 
     125        pj_get_timestamp(&ts); 
     126 
     127        /* Convert timestamp to samples */ 
     128        ts.u64 = ts.u64 * s->clock_rate / s->ts_freq.u64; 
     129        arrival = (pj_uint32_t)ts.u64; 
     130    } 
     131#else 
     132    { 
     133        pj_time_val tv; 
     134        unsigned long timer_tick; 
     135 
     136        pj_gettimeofday(&tv); 
     137        timer_tick = tv.sec * 1000 + tv.msec; 
     138 
     139        /* Convert timer tick to samples */ 
     140        arrival = timer_tick * s->clock_rate / 1000; 
     141    } 
     142#endif 
     143 
    118144    transit = arrival - rtp_ts; 
    119145     
Note: See TracChangeset for help on using the changeset viewer.