skip lost sequence number ranges in getIntervalStats (#4166)

This commit is contained in:
Paul Wells authored and GitHub committed 2025-12-17 00:02:51 -08:00
1 parent 898ebe058c
commit 2f2d0a5735
1 file changed
+11 -10
+11 -10
View File
@@ -1268,13 +1268,18 @@ func (r *RTPStatsSender) getIntervalStats(
extEndExclusive uint64,
ehsn uint64,
) (intervalStats intervalStats) {
processESN := func(esn uint64, ehsn uint64) {
slot := r.getSnInfoOutOfOrderSlot(esn, ehsn)
if slot < 0 {
intervalStats.packetsNotFoundMetadata++
return
}
upperBound := ehsn + 1
lowerBound := uint64(0)
if n := uint64(len(r.snInfos)); n != 0 && ehsn >= n-1 {
lowerBound = ehsn - n + 1
}
extStartInclusiveClamped := max(min(extStartInclusive, upperBound), lowerBound)
extEndExclusiveClamped := max(min(extEndExclusive, upperBound), extStartInclusive)
intervalStats.packetsNotFoundMetadata += (extEndExclusive - extStartInclusive) - (extEndExclusiveClamped - extStartInclusiveClamped)
for esn := extStartInclusiveClamped; esn != extEndExclusiveClamped; esn++ {
slot := r.getSnInfoOutOfOrderSlot(esn, ehsn)
snInfo := &r.snInfos[slot]
switch {
case snInfo.pktSize == 0:
@@ -1298,10 +1303,6 @@ func (r *RTPStatsSender) getIntervalStats(
intervalStats.frames++
}
}
for esn := extStartInclusive; esn != extEndExclusive; esn++ {
processESN(esn, ehsn)
}
return
}