summaryrefslogtreecommitdiffstats
path: root/libavformat/rtpdec.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2011-01-01 22:27:16 +0000
committerMartin Storsjö <martin@martin.st>2011-01-01 22:27:16 +0000
commit3a1cdcc798fd7cb60ef69d1d010f5d56218c4b3a (patch)
treea07de61f687827dc5a3bd9b70cae18e6eefb77f0 /libavformat/rtpdec.c
parentdfaa9f3cb328f245cc1f9c56145a21c6d6e58f42 (diff)
downloadffmpeg-streaming-3a1cdcc798fd7cb60ef69d1d010f5d56218c4b3a.zip
ffmpeg-streaming-3a1cdcc798fd7cb60ef69d1d010f5d56218c4b3a.tar.gz
rtpdec: Emit timestamps for packets before the first RTCP packet, too
Emitted timestamps in each stream start from 0, for the first received RTP packet. Once an RTCP packet is received, that one is used for sync, emitting timestamps that fit seamlessly into the earlier ones. Originally committed as revision 26187 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rtpdec.c')
-rw-r--r--libavformat/rtpdec.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 77b59a3..7009249 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -123,9 +123,13 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int l
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;
@@ -440,8 +444,15 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam
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,
OpenPOWER on IntegriCloud