Changeset 388


Ignore:
Timestamp:
Apr 5, 2006 7:08:16 PM (18 years ago)
Author:
bennylp
Message:

Added detection/protection against inaccurate timestamp in RTCP

Location:
pjproject/trunk
Files:
2 edited

Legend:

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

    r385 r388  
    3838#   define TRACE_(x)    PJ_LOG(3,x) 
    3939#else 
    40 #   define TRACE_(x) 
     40#   define TRACE_(x)    ; 
    4141#endif 
    4242 
     
    190190    pj_get_timestamp(&session->rx_lsr_time); 
    191191 
     192    TRACE_((THIS_FILE, "Rx RTCP SR: ntp-ts=%p, time=%p",  
     193            session->rx_lsr, 
     194            (pj_uint32_t)(session->rx_lsr_time.u64*65536/session->ts_freq.u64))); 
     195 
    192196    /* Calculate RTT if it has RR */ 
    193197    if (size >= sizeof(pjmedia_rtcp_pkt)) { 
     
    221225            eedelay = (eedelay * 1000000) >> 16; 
    222226 
    223             TRACE_((THIS_FILE, "Rx RTCP: lsr=%p, dlsr=%p (%d:%03dms), " 
     227            TRACE_((THIS_FILE, "Rx RTCP RR: lsr=%p, dlsr=%p (%d:%03dms), " 
    224228                               "now=%p, rtt=%p", 
    225229                    lsr, dlsr, dlsr/65536, (dlsr%65536)*1000/65536, 
     
    232236                session->rtt_us = (pj_uint32_t)eedelay; 
    233237            } else { 
    234                 TRACE_((THIS_FILE, "NTP clock running backwards?")); 
     238                PJ_LOG(3, (THIS_FILE, "Internal NTP clock skew detected")); 
    235239            } 
    236240        } 
     
    302306        pj_uint32_t lsr = session->rx_lsr; 
    303307        pj_uint64_t lsr_time = session->rx_lsr_time.u64; 
    304          
     308        pj_uint32_t dlsr; 
     309         
     310        /* Convert LSR time to 1/65536 seconds resolution */ 
     311        lsr_time = (lsr_time << 16) / session->ts_freq.u64; 
     312 
    305313        /* Fill in LSR. 
    306314           LSR is the middle 32bit of the last SR NTP time received. 
     
    314322 
    315323        /* Convert interval to 1/65536 seconds value */ 
    316         ts.u64 = ((ts.u64 - lsr_time) << 16) / session->ts_freq.u64; 
    317  
    318         rtcp_pkt->rr.dlsr = pj_htonl( (pj_uint32_t)ts.u64 ); 
     324        ts.u64 = (ts.u64 << 16) / session->ts_freq.u64; 
     325 
     326        /* Get DLSR */ 
     327        dlsr = (pj_uint32_t)(ts.u64 - lsr_time); 
     328        rtcp_pkt->rr.dlsr = pj_htonl(dlsr); 
     329 
     330        TRACE_((THIS_FILE, "Tx RTCP RR: lsr=%p, lsr_time=%p, now=%p, dlsr=%p" 
     331                           "(%ds:%03dms)", 
     332                           lsr,  
     333                           (pj_uint32_t)lsr_time, 
     334                           (pj_uint32_t)ts.u64,  
     335                           dlsr, 
     336                           dlsr/65536, 
     337                           (dlsr%65536)*1000/65536 )); 
    319338    } 
    320339     
  • pjproject/trunk/pjsip-apps/src/samples/siprtp.c

    r384 r388  
    176176                       pj_status_t status); 
    177177 
    178  
     178/* Print call */ 
     179static void print_call(int call_index); 
    179180 
    180181 
     
    676677        pj_time_val null_time = {0, 0}; 
    677678 
     679        PJ_LOG(3,(THIS_FILE, "Call #%d disconnected. Reason=%s", 
     680                  call->index, 
     681                  pjsip_get_status_text(inv->cause)->ptr)); 
     682        PJ_LOG(3,(THIS_FILE, "Call #%d statistics:", call->index)); 
     683        print_call(call->index); 
     684 
     685 
    678686        call->inv = NULL; 
    679687        inv->mod_data[mod_siprtp.id] = NULL; 
     
    685693        call->connect_time = null_time; 
    686694 
    687         PJ_LOG(3,(THIS_FILE, "Call #%d disconnected. Reason=%s", 
    688                   call->index, 
    689                   pjsip_get_status_text(inv->cause)->ptr)); 
    690695 
    691696    } else if (inv->state == PJSIP_INV_STATE_CONFIRMED) { 
     
    14721477 
    14731478 
    1474     if (call->media[0].thread == NULL) { 
     1479    if (call->inv == NULL || call->inv->state < PJSIP_INV_STATE_CONFIRMED) { 
    14751480        return; 
    14761481    } 
Note: See TracChangeset for help on using the changeset viewer.