Skip to content

Commit c431838

Browse files
committed
SampleBuilder: Remove PopWithTimestamp
Use Sample.PacketTimestamp field instead. Migration example: - sample, timestamp := s.PopWithTimestamp() + sample := s.Pop() + timestamp := sample.PacketTimestamp BREAKING CHANGE: SampleBuilder.PopWithTimestamp method is removed
1 parent 3f6d94a commit c431838

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

pkg/media/samplebuilder/samplebuilder.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,17 +334,6 @@ func (s *SampleBuilder) Pop() *media.Sample {
334334
return result
335335
}
336336

337-
// PopWithTimestamp compiles pushed RTP packets into media samples and then
338-
// returns the next valid sample with its associated RTP timestamp (or nil, 0 if
339-
// no sample is compiled).
340-
func (s *SampleBuilder) PopWithTimestamp() (*media.Sample, uint32) {
341-
sample := s.Pop()
342-
if sample == nil {
343-
return nil, 0
344-
}
345-
return sample, sample.PacketTimestamp
346-
}
347-
348337
// seqnumDistance computes the distance between two sequence numbers
349338
func seqnumDistance(x, y uint16) uint16 {
350339
diff := int16(x - y)

pkg/media/samplebuilder/samplebuilder_test.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -490,15 +490,6 @@ func TestSampleBuilderWithPacketHeadHandler(t *testing.T) {
490490
assert.Equal(t, 2, headCount, "two sample heads should have been inspected")
491491
}
492492

493-
func TestPopWithTimestamp(t *testing.T) {
494-
t.Run("Crash on nil", func(t *testing.T) {
495-
s := New(0, &fakeDepacketizer{}, 1)
496-
sample, timestamp := s.PopWithTimestamp()
497-
assert.Nil(t, sample)
498-
assert.Equal(t, uint32(0), timestamp)
499-
})
500-
}
501-
502493
type truePartitionHeadChecker struct{}
503494

504495
func (f *truePartitionHeadChecker) IsPartitionHead([]byte) bool {
@@ -520,11 +511,11 @@ func TestSampleBuilderData(t *testing.T) {
520511
}
521512
s.Push(&p)
522513
for {
523-
sample, ts := s.PopWithTimestamp()
514+
sample := s.Pop()
524515
if sample == nil {
525516
break
526517
}
527-
assert.Equal(t, ts, uint32(j+42), "timestamp")
518+
assert.Equal(t, sample.PacketTimestamp, uint32(j+42), "timestamp")
528519
assert.Equal(t, len(sample.Data), 1, "data length")
529520
assert.Equal(t, byte(j), sample.Data[0], "data")
530521
j++

0 commit comments

Comments
 (0)