[FFmpeg-devel] [PATCH] rtpdec: fix negative missed packet count

Stepan Salenikovich stepan.salenikovich at savoirfairelinux.com
Thu Feb 9 23:51:41 EET 2017


Account for the RTP seq num restarting after 65535 when logging the
number of missed RTP packets.

Change-Id: I3510c2dfb830614e25f7b93de9b3b10aa724d00c
---
 libavformat/rtpdec.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 53cdad7..c674060 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -748,9 +748,15 @@ static int rtp_parse_queued_packet(RTPDemuxContext *s, AVPacket *pkt)
     if (s->queue_len <= 0)
         return -1;
 
-    if (!has_next_packet(s))
+    if (!has_next_packet(s)) {
+        int missed = s->queue->seq - s->seq - 1;
+
+        if (missed < 0)
+            missed = UINT16_MAX - missed;
+
         av_log(s->ic, AV_LOG_WARNING,
-               "RTP: missed %d packets\n", s->queue->seq - s->seq - 1);
+               "RTP: missed %d packets\n", missed);
+    }
 
     /* Parse the first packet in the queue, and dequeue it */
     rv   = rtp_parse_packet_internal(s, pkt, s->queue->buf, s->queue->len);
-- 
2.9.3



More information about the ffmpeg-devel mailing list