diff --git a/pkg/sfu/rtpstats/rtpstats_receiver_test.go b/pkg/sfu/rtpstats/rtpstats_receiver_test.go index 32ca8198e..49066d8bf 100644 --- a/pkg/sfu/rtpstats/rtpstats_receiver_test.go +++ b/pkg/sfu/rtpstats/rtpstats_receiver_test.go @@ -256,3 +256,11 @@ func Test_RTPStatsReceiver_Restart(t *testing.T) { r.Stop() } + +func Test_RTPStatsSender_getIntervalStats(t *testing.T) { + t.Run("packetsNotFoundMetadata should match lost packets", func(t *testing.T) { + r := NewRTPStatsSender(RTPStatsParams{}, 1024) + stats := r.getIntervalStats(0, 10000, 10000) + require.EqualValues(t, 8977, stats.packetsNotFoundMetadata) + }) +} diff --git a/pkg/sfu/rtpstats/rtpstats_sender.go b/pkg/sfu/rtpstats/rtpstats_sender.go index 98fb8312d..b8e092ce5 100644 --- a/pkg/sfu/rtpstats/rtpstats_sender.go +++ b/pkg/sfu/rtpstats/rtpstats_sender.go @@ -1274,9 +1274,9 @@ func (r *RTPStatsSender) getIntervalStats( lowerBound = ehsn - n + 1 } extStartInclusiveClamped := max(min(extStartInclusive, upperBound), lowerBound) - extEndExclusiveClamped := max(min(extEndExclusive, upperBound), extStartInclusive) + extEndExclusiveClamped := max(min(extEndExclusive, upperBound), extStartInclusiveClamped) - intervalStats.packetsNotFoundMetadata += (extEndExclusive - extStartInclusive) - (extEndExclusiveClamped - extStartInclusiveClamped) + intervalStats.packetsNotFoundMetadata = (extEndExclusive - extStartInclusive) - (extEndExclusiveClamped - extStartInclusiveClamped) for esn := extStartInclusiveClamped; esn != extEndExclusiveClamped; esn++ { slot := r.getSnInfoOutOfOrderSlot(esn, ehsn)