Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rare SRTP loss decode failure #277

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package rtp

import (
"math"
"sync"
)

Expand All @@ -14,11 +13,18 @@ type Sequencer interface {
RollOverCount() uint64
}

// maxInitialRandomSequenceNumber is the maximum value used for the initial sequence
// number when using NewRandomSequencer().
// This uses only half the potential sequence number space to avoid issues decrypting
// SRTP when the sequence number starts near the rollover and there is packet loss.
// See https://webrtc-review.googlesource.com/c/src/+/358360
const maxInitialRandomSequenceNumber = 1<<15 - 1

// NewRandomSequencer returns a new sequencer starting from a random sequence
// number
func NewRandomSequencer() Sequencer {
return &sequencer{
sequenceNumber: uint16(globalMathRandomGenerator.Intn(math.MaxUint16)),
sequenceNumber: uint16(globalMathRandomGenerator.Intn(maxInitialRandomSequenceNumber)),
}
}

Expand Down
Loading