mirror of
https://github.com/livekit/livekit.git
synced 2026-05-14 18:25:24 +00:00
Consistently undo update to sequence number and timestamp when the (#4156)
incoming packet cannot be sequenced.
This commit is contained in:
@@ -22,7 +22,7 @@ require (
|
||||
github.com/jellydator/ttlcache/v3 v3.4.0
|
||||
github.com/jxskiss/base62 v1.1.0
|
||||
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731
|
||||
github.com/livekit/mediatransportutil v0.0.0-20251204091721-6b6e9a44e81f
|
||||
github.com/livekit/mediatransportutil v0.0.0-20251213100503-cc390ae365e9
|
||||
github.com/livekit/protocol v1.43.5-0.20251208162321-aa4dc2f24b2a
|
||||
github.com/livekit/psrpc v0.7.1
|
||||
github.com/mackerelio/go-osstat v0.2.6
|
||||
|
||||
@@ -171,8 +171,8 @@ github.com/lithammer/shortuuid/v4 v4.2.0 h1:LMFOzVB3996a7b8aBuEXxqOBflbfPQAiVzkI
|
||||
github.com/lithammer/shortuuid/v4 v4.2.0/go.mod h1:D5noHZ2oFw/YaKCfGy0YxyE7M0wMbezmMjPdhyEFe6Y=
|
||||
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 h1:9x+U2HGLrSw5ATTo469PQPkqzdoU7be46ryiCDO3boc=
|
||||
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20251204091721-6b6e9a44e81f h1:2zvkGDPaC34ufp0RGDG28AcbhXdWsiOg9giAe2BqiMk=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20251204091721-6b6e9a44e81f/go.mod h1:mSNtYzSf6iY9xM3UX42VEI+STHvMgHmrYzEHPcdhB8A=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20251213100503-cc390ae365e9 h1:ciqzzn+oEex3mCa1n1GmlQrv+ZkGpgUbQPSG3PD0htM=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20251213100503-cc390ae365e9/go.mod h1:mSNtYzSf6iY9xM3UX42VEI+STHvMgHmrYzEHPcdhB8A=
|
||||
github.com/livekit/protocol v1.43.5-0.20251208162321-aa4dc2f24b2a h1:juIQhMi8GNCLI+26BWZJirytNjCHFh+7XDWsajG4spM=
|
||||
github.com/livekit/protocol v1.43.5-0.20251208162321-aa4dc2f24b2a/go.mod h1:n00Ul4P6o2YILGhxw+O57B0h/bF3Je9PzRN36fElCmw=
|
||||
github.com/livekit/psrpc v0.7.1 h1:ms37az0QTD3UXIWuUC5D/SkmKOlRMVRsI261eBWu/Vw=
|
||||
|
||||
@@ -171,6 +171,11 @@ func (r *RTPStatsReceiver) Update(
|
||||
)
|
||||
}
|
||||
|
||||
undoUpdates := func() {
|
||||
r.sequenceNumber.UndoUpdate(resSN)
|
||||
r.timestamp.UndoUpdate(resTS)
|
||||
}
|
||||
|
||||
if !r.initialized {
|
||||
if payloadSize == 0 {
|
||||
// do not start on a padding only packet
|
||||
@@ -208,6 +213,8 @@ func (r *RTPStatsReceiver) Update(
|
||||
}
|
||||
resTS = r.timestamp.Rollover(timestamp, tsRolloverCount)
|
||||
if resTS.IsUnhandled {
|
||||
undoUpdates()
|
||||
|
||||
flowState.IsNotHandled = true
|
||||
return
|
||||
}
|
||||
@@ -226,9 +233,10 @@ func (r *RTPStatsReceiver) Update(
|
||||
if gapSN < 0 && gapTS > 0 {
|
||||
expectedTSJump = int64(r.rtpConverter.ToRTPExt(time.Duration(timeSinceHighest)))
|
||||
if gapTS > int64(float64(expectedTSJump)*cTSJumpTooHighFactor) {
|
||||
r.sequenceNumber.UndoUpdate(resSN)
|
||||
r.timestamp.UndoUpdate(resTS)
|
||||
undoUpdates()
|
||||
|
||||
logger().Warnw("dropping old packet, timestamp", nil)
|
||||
|
||||
flowState.IsNotHandled = true
|
||||
return
|
||||
}
|
||||
@@ -237,9 +245,10 @@ func (r *RTPStatsReceiver) Update(
|
||||
// Case 2:
|
||||
// Sequence number looks like it is moving forward, but it is actually a very old packet.
|
||||
if gapTS < 0 && gapSN > 0 {
|
||||
r.sequenceNumber.UndoUpdate(resSN)
|
||||
r.timestamp.UndoUpdate(resTS)
|
||||
undoUpdates()
|
||||
|
||||
logger().Warnw("dropping old packet, sequence number", nil)
|
||||
|
||||
flowState.IsNotHandled = true
|
||||
return
|
||||
}
|
||||
@@ -253,17 +262,17 @@ func (r *RTPStatsReceiver) Update(
|
||||
snRolloverCount = 1
|
||||
}
|
||||
resSN = r.sequenceNumber.Rollover(sequenceNumber, snRolloverCount)
|
||||
if resSN.IsUnhandled {
|
||||
flowState.IsNotHandled = true
|
||||
return
|
||||
if !resSN.IsUnhandled {
|
||||
logger().Warnw("forcing sequence number rollover", nil)
|
||||
}
|
||||
|
||||
logger().Warnw("forcing sequence number rollover", nil)
|
||||
}
|
||||
|
||||
if resSN.IsUnhandled {
|
||||
flowState.IsNotHandled = true
|
||||
undoUpdates()
|
||||
|
||||
logger().Warnw("dropping packet, cannot find sequence", nil)
|
||||
|
||||
flowState.IsNotHandled = true
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user