mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 07:37:07 +08:00
change rtptime.Encoder signature and initialize time to a random value (#525)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user