payload_len = (AV_RB16(buf + 2) + 1) * 4;
s->last_rtcp_ntp_time = AV_RB64(buf + 8);
- if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE)
- s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;
s->last_rtcp_timestamp = AV_RB32(buf + 16);
+ if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) {
+ s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;
+ if (!s->base_timestamp)
+ s->base_timestamp = s->last_rtcp_timestamp;
+ s->rtcp_ts_offset = s->last_rtcp_timestamp - s->base_timestamp;
+ }
buf += payload_len;
len -= payload_len;
delta_timestamp = timestamp - s->last_rtcp_timestamp;
/* convert to the PTS timebase */
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);
- pkt->pts = s->range_start_offset + addend + delta_timestamp;
+ pkt->pts = s->range_start_offset + s->rtcp_ts_offset + addend +
+ delta_timestamp;
+ return;
}
+ if (timestamp == RTP_NOTS_VALUE)
+ return;
+ if (!s->base_timestamp)
+ s->base_timestamp = timestamp;
+ pkt->pts = s->range_start_offset + timestamp - s->base_timestamp;
}
static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
int64_t last_rtcp_ntp_time; // TODO: move into statistics
int64_t first_rtcp_ntp_time; // TODO: move into statistics
uint32_t last_rtcp_timestamp; // TODO: move into statistics
+ int64_t rtcp_ts_offset;
/* rtcp sender statistics */
unsigned int packet_count; // TODO: move into statistics (outgoing)
* in order to map their timestamp origin to the same ntp time
* as this one. */
int i;
+ AVStream *st = NULL;
+ if (rtsp_st->stream_index >= 0)
+ st = s->streams[rtsp_st->stream_index];
for (i = 0; i < rt->nb_rtsp_streams; i++) {
RTPDemuxContext *rtpctx2 = rt->rtsp_streams[i]->transport_priv;
- if (rtpctx2 &&
- rtpctx2->first_rtcp_ntp_time == AV_NOPTS_VALUE)
+ AVStream *st2 = NULL;
+ if (rt->rtsp_streams[i]->stream_index >= 0)
+ st2 = s->streams[rt->rtsp_streams[i]->stream_index];
+ if (rtpctx2 && st && st2 &&
+ rtpctx2->first_rtcp_ntp_time == AV_NOPTS_VALUE) {
rtpctx2->first_rtcp_ntp_time = rtpctx->first_rtcp_ntp_time;
+ rtpctx2->rtcp_ts_offset = av_rescale_q(
+ rtpctx->rtcp_ts_offset, st->time_base,
+ st2->time_base);
+ }
}
}
if (ret == -RTCP_BYE) {
if (reply->range_start != AV_NOPTS_VALUE) {
rtpctx->last_rtcp_ntp_time = AV_NOPTS_VALUE;
rtpctx->first_rtcp_ntp_time = AV_NOPTS_VALUE;
+ rtpctx->base_timestamp = 0;
+ rtpctx->rtcp_ts_offset = 0;
if (st)
rtpctx->range_start_offset =
av_rescale_q(reply->range_start, AV_TIME_BASE_Q,