fix framenumber test (#2942)

This commit is contained in:
cnderrauber
2024-08-19 16:35:38 +08:00
committed by GitHub
parent 1fb8964814
commit 15bf920f2c
2 changed files with 14 additions and 2 deletions
@@ -65,6 +65,12 @@ func TestFrameNumberWrapper(t *testing.T) {
// frame out of order
firstF = secondF
secondF = getFrame(firstF, false)
// it is possile that an out of order non-keyframe has been converted to in order frame number if the diff is 32768
// that is ok because the client can't decode in such case and always need to wait for the key frame.
// so it is just a failure of test case and increase the frame number here.
if secondF-firstF == 0x8000 {
secondF++
}
testFrameOrder(firstF, false, secondF, false, false)
// key frame in order
@@ -92,5 +98,11 @@ func getFrame(base uint16, inorder bool) uint16 {
if inorder {
return base + uint16(rand.Intn(0x8000))
}
return base + uint16(rand.Intn(0x8000)) + 0x8000
for {
ret := base + uint16(rand.Intn(0x8000)) + 0x8000
if !inOrder(ret, base) {
return ret
}
}
}