X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Frtpdec.c;h=7170e97ec92d7aae8220ae3fb7b123ee3e7bc8fe;hb=b5a69e79c579e6e15e2019ffd34ef0e09aeab586;hp=20e5bd7e82be6959064a978745eaa8c2c2bca362;hpb=6d91045d835635fe889f684bdf77f68e00b15d0b;p=ffmpeg diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 20e5bd7e82b..7170e97ec92 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -299,7 +299,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) avio_w8(pb, RTCP_SDES); len = strlen(s->hostname); avio_wb16(pb, (6 + len + 3) / 4); /* length in words - 1 */ - avio_wb32(pb, s->ssrc); + avio_wb32(pb, s->ssrc + 1); avio_w8(pb, 0x01); avio_w8(pb, len); avio_write(pb, s->hostname, len); @@ -426,7 +426,10 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam { if (pkt->pts != AV_NOPTS_VALUE || pkt->dts != AV_NOPTS_VALUE) return; /* Timestamp already set by depacketizer */ - if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE && timestamp != RTP_NOTS_VALUE) { + if (timestamp == RTP_NOTS_VALUE) + return; + + if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE && s->ic->nb_streams > 1) { int64_t addend; int delta_timestamp; @@ -438,11 +441,16 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam 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; + /* assume that the difference is INT32_MIN < x < INT32_MAX, but allow the first timestamp to exceed INT32_MAX */ + if (!s->timestamp) + s->unwrapped_timestamp += timestamp; + else + s->unwrapped_timestamp += (int32_t)(timestamp - s->timestamp); + s->timestamp = timestamp; + pkt->pts = s->unwrapped_timestamp + s->range_start_offset - s->base_timestamp; } static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,