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

Submitted by Stepan Salenikovich on Feb. 9, 2017, 9:51 p.m.

Details

Message ID 20170209215141.9949-1-stepan.salenikovich@savoirfairelinux.com
State New
Headers show

Commit Message

Stepan Salenikovich Feb. 9, 2017, 9:51 p.m.
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(-)

Patch hide | download patch | download mbox

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);