Changeset 567


Ignore:
Timestamp:
Jun 29, 2006 9:51:09 AM (16 years ago)
Author:
bennylp
Message:

Minor bug fix and enhancements: (1) fixed bug that caused out-of-order status to be raised when incoming sequence number is random, (2) changed RTCP to only calculate jitter when the RTP timestamp of the packet is different than previous one, and (3) change RTP to randomize initial sequence number

Location:
pjproject/trunk/pjmedia
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/rtcp.h

    r537 r567  
    240240     
    241241    pjmedia_rtp_seq_session seq_ctrl;   /**< RTCP sequence number control.  */ 
     242    unsigned                rtp_last_ts;/**< Last timestamp in RX RTP pkt.  */ 
    242243 
    243244    unsigned                clock_rate; /**< Clock rate of the stream       */ 
  • pjproject/trunk/pjmedia/src/pjmedia/rtcp.c

    r537 r567  
    141141    sess->avg_jitter = 0; 
    142142 
     143    /* Last RX timestamp in RTP packet */ 
     144    sess->rtp_last_ts = (unsigned)-1; 
     145 
    143146    /* Name */ 
    144147    sess->name = name ? name : THIS_FILE, 
     
    198201    unsigned last_seq; 
    199202 
     203    if (sess->stat.rx.pkt == 0) { 
     204        /* Init sequence for the first time. */ 
     205        pjmedia_rtp_seq_init(&sess->seq_ctrl, (pj_uint16_t)seq); 
     206    }  
     207 
    200208    sess->stat.rx.pkt++; 
    201209    sess->stat.rx.bytes += payload; 
    202210 
    203     /* Update sequence numbers. */ 
     211    /* Process the RTP packet. */ 
    204212    last_seq = sess->seq_ctrl.max_seq; 
    205213    pjmedia_rtp_seq_update(&sess->seq_ctrl, (pj_uint16_t)seq, &seq_st); 
     214 
    206215    if (seq_st.status.flag.restart) { 
    207216        rtcp_init_seq(sess); 
     
    213222    } 
    214223 
    215     if (seq_st.status.flag.outorder) { 
     224    if (seq_st.status.flag.outorder && !seq_st.status.flag.probation) { 
    216225        sess->stat.rx.reorder++; 
    217226        TRACE_((sess->name, "Out-of-order packet detected")); 
     
    259268 
    260269    /* 
    261      * Calculate jitter only when sequence is good (see RFC 3550 section A.8) 
     270     * Calculate jitter only when sequence is good (see RFC 3550 section A.8), 
     271     * AND only when the timestamp is different than the last packet 
     272     * (see RTP FAQ). 
    262273     */ 
    263     if (seq_st.diff == 1) { 
     274    if (seq_st.diff == 1 && rtp_ts != sess->rtp_last_ts) { 
    264275        /* Get arrival time and convert timestamp to samples */ 
    265276        pj_get_timestamp(&ts); 
     
    310321        } 
    311322    } 
     323 
     324    /* Update timestamp of last RX RTP packet */ 
     325    sess->rtp_last_ts = rtp_ts; 
    312326} 
    313327 
  • pjproject/trunk/pjmedia/src/pjmedia/rtp.c

    r408 r567  
    6060    } 
    6161 
    62     /* Initialize session.  
    63      * Initial sequence number SHOULD be random, according to RFC 3550. 
    64      */ 
     62    /* Initialize session. */ 
     63    pj_memset(ses, 0, sizeof(*ses)); 
     64 
     65    /* Initial sequence number SHOULD be random, according to RFC 3550. */ 
    6566    ses->out_extseq = pj_rand(); 
    6667    ses->peer_ssrc = 0; 
    6768     
    68     /* Sequence number will be initialized when the first RTP packet  
    69      * is receieved. 
    70      */ 
    71  
    7269    /* Build default header for outgoing RTP packet. */ 
    73     pj_memset(ses, 0, sizeof(*ses)); 
    7470    ses->out_hdr.v = RTP_VERSION; 
    7571    ses->out_hdr.p = 0; 
Note: See TracChangeset for help on using the changeset viewer.