Revision 2cab6b48

View differences:

libavformat/rtpdec.c
80 80
    if (buf[1] != 200)
81 81
        return -1;
82 82
    s->last_rtcp_ntp_time = AV_RB64(buf + 8);
83
    if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE)
84
        s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;
83 85
    s->last_rtcp_timestamp = AV_RB32(buf + 16);
84 86
    return 0;
85 87
}
......
326 328
        return NULL;
327 329
    s->payload_type = payload_type;
328 330
    s->last_rtcp_ntp_time = AV_NOPTS_VALUE;
331
    s->first_rtcp_ntp_time = AV_NOPTS_VALUE;
329 332
    s->ic = s1;
330 333
    s->st = st;
331 334
    s->rtp_payload_data = rtp_payload_data;
......
433 436
        /* compute pts from timestamp with received ntp_time */
434 437
        delta_timestamp = timestamp - s->last_rtcp_timestamp;
435 438
        /* convert to the PTS timebase */
436
        addend = av_rescale(s->last_rtcp_ntp_time, s->st->time_base.den, (uint64_t)s->st->time_base.num << 32);
439
        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);
437 440
        pkt->pts = addend + delta_timestamp;
438 441
    }
439 442
}
libavformat/rtpdec.h
174 174

  
175 175
    /* rtcp sender statistics receive */
176 176
    int64_t last_rtcp_ntp_time;    // TODO: move into statistics
177
    int64_t first_rtcp_ntp_time;   // TODO: move into statistics
177 178
    uint32_t last_rtcp_timestamp;  // TODO: move into statistics
178 179

  
179 180
    /* rtcp sender statistics */
libavformat/rtsp.c
1796 1796
        return AVERROR_EOF;
1797 1797
    if (rt->transport == RTSP_TRANSPORT_RDT) {
1798 1798
        ret = ff_rdt_parse_packet(rtsp_st->transport_priv, pkt, buf, len);
1799
    } else
1799
    } else {
1800 1800
        ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, buf, len);
1801
        if (ret < 0) {
1802
            /* Either bad packet, or a RTCP packet. Check if the
1803
             * first_rtcp_ntp_time field was initialized. */
1804
            RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
1805
            if (rtpctx->first_rtcp_ntp_time != AV_NOPTS_VALUE) {
1806
                /* first_rtcp_ntp_time has been initialized for this stream,
1807
                 * copy the same value to all other uninitialized streams,
1808
                 * in order to map their timestamp origin to the same ntp time
1809
                 * as this one. */
1810
                int i;
1811
                for (i = 0; i < rt->nb_rtsp_streams; i++) {
1812
                    RTPDemuxContext *rtpctx2 = rtsp_st->transport_priv;
1813
                    if (rtpctx2 &&
1814
                        rtpctx2->first_rtcp_ntp_time == AV_NOPTS_VALUE)
1815
                        rtpctx2->first_rtcp_ntp_time = rtpctx->first_rtcp_ntp_time;
1816
                }
1817
            }
1818
        }
1819
    }
1801 1820
    if (ret < 0)
1802 1821
        goto redo;
1803 1822
    if (ret == 1)

Also available in: Unified diff