Changeset aad5f30a8fcac701c6cc4264ca7be45cf2ed34b8

Show
Ignore:
Timestamp:
28/09/08 13:41:58 (2 months ago)
Author:
Rémi Denis-Courmont <rdenis@simphalempin.com>
git-committer:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1222602118 +0300
git-parent:

[08b2e6483a33b00fb48511529e81d2c9c367c91a]

git-author:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1222590056 +0300
Message:

RTP: use the right frequency for jitter computation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/rtpsession.c

    r54f11e3 raad5f30  
    193193} 
    194194 
     195static inline uint8_t rtp_ptype (const block_t *block) 
     196{ 
     197    return block->p_buffer[1] & 0x7F; 
     198} 
    195199 
    196200static inline uint16_t rtp_seq (const block_t *block) 
     
    204208    assert (block->i_buffer >= 12); 
    205209    return GetDWBE (block->p_buffer + 4); 
     210} 
     211 
     212static const struct rtp_pt_t * 
     213rtp_find_ptype (const rtp_session_t *session, rtp_source_t *source, 
     214                const block_t *block, void **pt_data) 
     215{ 
     216    uint8_t ptype = rtp_ptype (block); 
     217 
     218    for (unsigned i = 0; i < session->ptc; i++) 
     219    { 
     220        if (session->ptv[i].number == ptype) 
     221        { 
     222            if (pt_data != NULL) 
     223                *pt_data = source->opaque[i]; 
     224            return &session->ptv[i]; 
     225        } 
     226    } 
     227    return NULL; 
    206228} 
    207229 
     
    279301        /* Cannot compute jitter yet */ 
    280302    } 
    281     else if (session->ptc > 0) 
    282     { 
    283         /* Recompute jitter estimate. That is computed from the RTP timestamps 
    284          * and the system clock. It is independent of RTP sequence. */ 
    285         /* FIXME: payload types have the same frequency? */ 
    286         uint32_t freq = session->ptv[0].frequency; 
    287         uint32_t ts = rtp_timestamp (block); 
    288         int64_t d = ((now - src->last_rx) * freq) / CLOCK_FREQ; 
    289         d        -=    ts - src->last_ts; 
    290         if (d < 0) d = -d; 
    291         src->jitter += ((d - src->jitter) + 8) >> 4; 
     303    else 
     304    { 
     305        const rtp_pt_t *pt = rtp_find_ptype (session, src, block, NULL); 
     306 
     307        if (pt != NULL) 
     308        { 
     309            /* Recompute jitter estimate. 
     310             * That is computed from the RTP timestamps and the system clock. 
     311             * It is independent of RTP sequence. */ 
     312            uint32_t freq = pt->frequency; 
     313            uint32_t ts = rtp_timestamp (block); 
     314            int64_t d = ((now - src->last_rx) * freq) / CLOCK_FREQ; 
     315            d        -=    ts - src->last_ts; 
     316            if (d < 0) d = -d; 
     317            src->jitter += ((d - src->jitter) + 8) >> 4; 
     318        } 
    292319    } 
    293320    src->last_rx = now; 
     
    368395 
    369396    /* Match the payload type */ 
    370     const rtp_pt_t *pt = NULL; 
    371     void *pt_data = NULL; 
    372     const uint8_t   ptype = block->p_buffer[1] & 0x7F; 
    373  
    374     for (unsigned i = 0; i < session->ptc; i++) 
    375     { 
    376         if (session->ptv[i].number == ptype) 
    377         { 
    378             pt = &session->ptv[i]; 
    379             pt_data = src->opaque[i]; 
    380             break; 
    381         } 
    382     } 
    383  
     397    void *pt_data; 
     398    const rtp_pt_t *pt = rtp_find_ptype (session, src, block, &pt_data); 
    384399    if (pt == NULL) 
    385400    { 
    386         msg_Dbg (demux, "ignoring unknown payload (%"PRIu8")", ptype); 
     401        msg_Dbg (demux, "ignoring unknown payload (%"PRIu8")", 
     402                 rtp_ptype (block)); 
    387403        goto drop; 
    388404    }