Fix forced rollover of RTP time stamp. (#2896)

* Fix forced rollover of RTP time stamp.

Was erroneously forcing a rollover when the timestamp jump actually has
room to accommodate large jumps. For example, before pause ts = 10, then
eight hour pause, restart ts = 10  + (8 * 00 * 60 * 90000) = 2592000010
(at 90000 clock rate for video). In normal processing, it will look like
out-of-order as the difference 2592000000 is more than half the 32-bit
range. But, forcing a roll over is incorrect.

Fix by calculating excess over the full range and then account for wrap
around.

* log potential ts rollover

* clamp at min 0
This commit is contained in:
Raja Subramanian
2024-07-31 12:45:19 +05:30
committed by GitHub
parent d68dd3033d
commit c2c187202f
3 changed files with 26 additions and 9 deletions
+1 -1
View File
@@ -120,7 +120,7 @@ func (w *WrapAround[T, ET]) UndoUpdate(result WrapAroundUpdateResult[ET]) {
}
func (w *WrapAround[T, ET]) Rollover(val T, numCycles int) (result WrapAroundUpdateResult[ET]) {
if !w.initialized || numCycles == 0 {
if !w.initialized || numCycles < 0 {
return w.Update(val)
}
+4 -3
View File
@@ -476,10 +476,11 @@ func TestWrapAroundUint16Rollover(t *testing.T) {
highest: 10,
extendedHighest: 10,
},
// zero cycles - should just do an update
// negative cycles - should just do an update
{
name: "zero",
input: 8,
name: "zero",
input: 8,
numCycles: -1,
updated: WrapAroundUpdateResult[uint32]{
IsUnhandled: true,
// the following fields are not valid when `IsUnhandled = true`, but code fills it in