Revision 3a1cdcc7

View differences:

libavformat/rtpdec.c
123 123
            payload_len = (AV_RB16(buf + 2) + 1) * 4;
124 124

  
125 125
            s->last_rtcp_ntp_time = AV_RB64(buf + 8);
126
            if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE)
127
                s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;
128 126
            s->last_rtcp_timestamp = AV_RB32(buf + 16);
127
            if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) {
128
                s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;
129
                if (!s->base_timestamp)
130
                    s->base_timestamp = s->last_rtcp_timestamp;
131
                s->rtcp_ts_offset = s->last_rtcp_timestamp - s->base_timestamp;
132
            }
129 133

  
130 134
            buf += payload_len;
131 135
            len -= payload_len;
......
440 444
        delta_timestamp = timestamp - s->last_rtcp_timestamp;
441 445
        /* convert to the PTS timebase */
442 446
        addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, s->st->time_base.den, (uint64_t)s->st->time_base.num << 32);
443
        pkt->pts = s->range_start_offset + addend + delta_timestamp;
447
        pkt->pts = s->range_start_offset + s->rtcp_ts_offset + addend +
448
                   delta_timestamp;
449
        return;
444 450
    }
451
    if (timestamp == RTP_NOTS_VALUE)
452
        return;
453
    if (!s->base_timestamp)
454
        s->base_timestamp = timestamp;
455
    pkt->pts = s->range_start_offset + timestamp - s->base_timestamp;
445 456
}
446 457

  
447 458
static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
libavformat/rtpdec.h
172 172
    int64_t last_rtcp_ntp_time;    // TODO: move into statistics
173 173
    int64_t first_rtcp_ntp_time;   // TODO: move into statistics
174 174
    uint32_t last_rtcp_timestamp;  // TODO: move into statistics
175
    int64_t rtcp_ts_offset;
175 176

  
176 177
    /* rtcp sender statistics */
177 178
    unsigned int packet_count;     // TODO: move into statistics (outgoing)
libavformat/rtsp.c
1617 1617
                 * in order to map their timestamp origin to the same ntp time
1618 1618
                 * as this one. */
1619 1619
                int i;
1620
                AVStream *st = NULL;
1621
                if (rtsp_st->stream_index >= 0)
1622
                    st = s->streams[rtsp_st->stream_index];
1620 1623
                for (i = 0; i < rt->nb_rtsp_streams; i++) {
1621 1624
                    RTPDemuxContext *rtpctx2 = rt->rtsp_streams[i]->transport_priv;
1622
                    if (rtpctx2 &&
1623
                        rtpctx2->first_rtcp_ntp_time == AV_NOPTS_VALUE)
1625
                    AVStream *st2 = NULL;
1626
                    if (rt->rtsp_streams[i]->stream_index >= 0)
1627
                        st2 = s->streams[rt->rtsp_streams[i]->stream_index];
1628
                    if (rtpctx2 && st && st2 &&
1629
                        rtpctx2->first_rtcp_ntp_time == AV_NOPTS_VALUE) {
1624 1630
                        rtpctx2->first_rtcp_ntp_time = rtpctx->first_rtcp_ntp_time;
1631
                        rtpctx2->rtcp_ts_offset = av_rescale_q(
1632
                            rtpctx->rtcp_ts_offset, st->time_base,
1633
                            st2->time_base);
1634
                    }
1625 1635
                }
1626 1636
            }
1627 1637
            if (ret == -RTCP_BYE) {
libavformat/rtspdec.c
67 67
                if (reply->range_start != AV_NOPTS_VALUE) {
68 68
                    rtpctx->last_rtcp_ntp_time  = AV_NOPTS_VALUE;
69 69
                    rtpctx->first_rtcp_ntp_time = AV_NOPTS_VALUE;
70
                    rtpctx->base_timestamp      = 0;
71
                    rtpctx->rtcp_ts_offset      = 0;
70 72
                    if (st)
71 73
                        rtpctx->range_start_offset =
72 74
                            av_rescale_q(reply->range_start, AV_TIME_BASE_Q,

Also available in: Unified diff