Skip to content

Commit dbe26d3

Browse files
radekgedaniels
authored andcommitted
Adapt an existing test to provide coverage
1 parent 4f40756 commit dbe26d3

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

pkg/media/ivfwriter/ivfwriter_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package ivfwriter
55

66
import (
77
"bytes"
8+
"encoding/binary"
89
"io"
910
"testing"
1011

@@ -257,19 +258,25 @@ func TestIVFWriter_AV1(t *testing.T) {
257258
t.Run("Unfragmented", func(t *testing.T) {
258259
buffer := &bytes.Buffer{}
259260

260-
writer, err := NewWith(buffer, WithCodec(mimeTypeAV1))
261-
assert.NoError(t, err)
261+
expectedTimestamp := uint32(3653407706)
262262

263-
assert.NoError(t, writer.WriteRTP(&rtp.Packet{Payload: []byte{0x00, 0x01, 0xFF}}))
264-
assert.NoError(t, writer.Close())
265-
assert.Equal(t, buffer.Bytes(), []byte{
263+
// the timestamp is an uint32, 4 bytes from offset 36
264+
expectedPayloadWithTimestamp := []byte{
266265
0x44, 0x4b, 0x49, 0x46, 0x0, 0x0, 0x20,
267266
0x0, 0x41, 0x56, 0x30, 0x31, 0x80, 0x2,
268267
0xe0, 0x1, 0x1e, 0x0, 0x0, 0x0, 0x1, 0x0,
269268
0x0, 0x0, 0x84, 0x3, 0x0, 0x0, 0x0, 0x0,
270-
0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
271-
0x0, 0x0, 0x0, 0x0, 0x0, 0xff,
272-
})
269+
0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0xda, 0x93, 0xc2,
270+
0xd9, 0x0, 0x0, 0x0, 0x0, 0xff,
271+
}
272+
273+
writer, err := NewWith(buffer, WithCodec(mimeTypeAV1))
274+
assert.NoError(t, err)
275+
276+
assert.NoError(t, writer.WriteRTP(&rtp.Packet{Header: rtp.Header{Timestamp: expectedTimestamp}, Payload: []byte{0x00, 0x01, 0xFF}}))
277+
assert.NoError(t, writer.Close())
278+
assert.Equal(t, expectedPayloadWithTimestamp, buffer.Bytes())
279+
assert.Equal(t, expectedTimestamp, binary.LittleEndian.Uint32(expectedPayloadWithTimestamp[36:40]))
273280
})
274281

275282
t.Run("Fragmented", func(t *testing.T) {

0 commit comments

Comments
 (0)