Skip to content

Commit

Permalink
SampleBuilder: Remove WithPartitionHeadChecker
Browse files Browse the repository at this point in the history
Deprecated by #1928

BREAKING CHANGE: samplebuilder.WithPartitionHeadChecker
                 option is removed.
  • Loading branch information
at-wat committed Mar 14, 2024
1 parent c431838 commit 34f44c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
6 changes: 0 additions & 6 deletions pkg/media/samplebuilder/samplebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,6 @@ func timestampDistance(x, y uint32) uint32 {
// An Option configures a SampleBuilder.
type Option func(o *SampleBuilder)

// WithPartitionHeadChecker is obsolete, it does nothing.
func WithPartitionHeadChecker(interface{}) Option {
return func(o *SampleBuilder) {
}
}

// WithPacketReleaseHandler set a callback when the builder is about to release
// some packet.
func WithPacketReleaseHandler(h func(*rtp.Packet)) Option {
Expand Down
18 changes: 9 additions & 9 deletions pkg/media/samplebuilder/samplebuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type sampleBuilderTest struct {
type fakeDepacketizer struct {
headChecker bool
headBytes []byte
alwaysHead bool
}

func (f *fakeDepacketizer) Unmarshal(r []byte) ([]byte, error) {
Expand All @@ -45,6 +46,10 @@ func (f *fakeDepacketizer) IsPartitionHead(payload []byte) bool {
return false
}

if f.alwaysHead {
return true
}

for _, b := range f.headBytes {
if payload[0] == b {
return true
Expand Down Expand Up @@ -490,16 +495,11 @@ func TestSampleBuilderWithPacketHeadHandler(t *testing.T) {
assert.Equal(t, 2, headCount, "two sample heads should have been inspected")
}

type truePartitionHeadChecker struct{}

func (f *truePartitionHeadChecker) IsPartitionHead([]byte) bool {
return true
}

func TestSampleBuilderData(t *testing.T) {
s := New(10, &fakeDepacketizer{}, 1,
WithPartitionHeadChecker(&truePartitionHeadChecker{}),
)
s := New(10, &fakeDepacketizer{
headChecker: true,
alwaysHead: true,
}, 1)
j := 0
for i := 0; i < 0x20000; i++ {
p := rtp.Packet{
Expand Down

0 comments on commit 34f44c9

Please sign in to comment.