change rtptime.Encoder signature and initialize time to a random value (#525)

This commit is contained in:
Alessandro Ros
2024-02-25 23:25:44 +01:00
committed by GitHub
parent f040e20ac4
commit ce46aee084
3 changed files with 60 additions and 19 deletions

View File

@@ -7,8 +7,17 @@ import (
"github.com/stretchr/testify/require"
)
func uint32Ptr(v uint32) *uint32 {
return &v
}
func TestEncoder(t *testing.T) {
e := NewEncoder(90000, 12345)
e := &Encoder{
ClockRate: 90000,
InitialTimestamp: uint32Ptr(12345),
}
err := e.Initialize()
require.NoError(t, err)
ts := e.Encode(0)
require.Equal(t, uint32(12345), ts)
@@ -18,10 +27,13 @@ func TestEncoder(t *testing.T) {
}
func BenchmarkEncoder(b *testing.B) {
e := &Encoder{
ClockRate: 90000,
InitialTimestamp: uint32Ptr(12345),
}
e.Initialize() //nolint:errcheck
for i := 0; i < b.N; i++ {
func() {
d := NewEncoder(90000, 0)
d.Encode(200 * time.Second)
}()
e.Encode(200 * time.Second)
}
}