Skip to content

Commit

Permalink
jitterbuffer: Improve performance for SampleBuilder use
Browse files Browse the repository at this point in the history
  • Loading branch information
thatsnotright committed Nov 26, 2024
1 parent 749922a commit 8e20454
Show file tree
Hide file tree
Showing 4 changed files with 881 additions and 263 deletions.
4 changes: 1 addition & 3 deletions pkg/jitterbuffer/jitter_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type (
// order, and allows removing in either sequence number order or via a
// provided timestamp
type JitterBuffer struct {
packets *PriorityQueue
packets *RBTree
minStartCount uint16
lastSequence uint16
playoutHead uint16
Expand Down Expand Up @@ -246,8 +246,6 @@ func (jb *JitterBuffer) PopAtSequence(sq uint16) (*rtp.Packet, error) {
// PeekAtSequence will return an RTP packet from the jitter buffer at the specified Sequence
// without removing it from the buffer
func (jb *JitterBuffer) PeekAtSequence(sq uint16) (*rtp.Packet, error) {
jb.mutex.Lock()
defer jb.mutex.Unlock()
packet, err := jb.packets.Find(sq)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions pkg/jitterbuffer/jitter_buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func TestJitterBuffer(t *testing.T) {
assert.Equal(jb.packets.Length(), uint16(100))
assert.Equal(jb.state, Emitting)
head, err := jb.PopAtTimestamp(uint32(513))
assert.NotNil(head)
assert.Equal(head.SequenceNumber, uint16(math.MaxUint16-32+1))
assert.Equal(err, nil)
head, err = jb.PopAtTimestamp(uint32(513))
Expand Down
Loading

0 comments on commit 8e20454

Please sign in to comment.