prevent uint overflow setting packet not found count (#4169)
This commit is contained in:
@@ -256,3 +256,11 @@ func Test_RTPStatsReceiver_Restart(t *testing.T) {
|
|||||||
|
|
||||||
r.Stop()
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1274,9 +1274,9 @@ func (r *RTPStatsSender) getIntervalStats(
|
|||||||
lowerBound = ehsn - n + 1
|
lowerBound = ehsn - n + 1
|
||||||
}
|
}
|
||||||
extStartInclusiveClamped := max(min(extStartInclusive, upperBound), lowerBound)
|
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++ {
|
for esn := extStartInclusiveClamped; esn != extEndExclusiveClamped; esn++ {
|
||||||
slot := r.getSnInfoOutOfOrderSlot(esn, ehsn)
|
slot := r.getSnInfoOutOfOrderSlot(esn, ehsn)
|
||||||
|
|||||||
Reference in New Issue
Block a user