From 7d6c986a3949bb1807e9c06e6db517cd6ba1719a Mon Sep 17 00:00:00 2001 From: boks1971 Date: Wed, 1 Nov 2023 14:20:47 +0530 Subject: [PATCH] Fix out of order check A sequence like 66533 -> 0 -> 65534 would have been detected as in-order as 65534 - 0 > 0. --- pkg/report/sender_stream.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/report/sender_stream.go b/pkg/report/sender_stream.go index 6c708bda..44658e24 100644 --- a/pkg/report/sender_stream.go +++ b/pkg/report/sender_stream.go @@ -39,7 +39,8 @@ func (stream *senderStream) processRTP(now time.Time, header *rtp.Header, payloa stream.m.Lock() defer stream.m.Unlock() - if stream.useLatestPacket || stream.packetCount == 0 || int16(header.SequenceNumber-stream.lastRTPSN) > 0 { + diff := header.SequenceNumber - stream.lastRTPSN + if stream.useLatestPacket || stream.packetCount == 0 || (diff > 0 && diff < (1<<15)) { // Told to consider every packet, or this was the first packet, or it's in-order stream.lastRTPSN = header.SequenceNumber stream.lastRTPTimeRTP = header.Timestamp