mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Adapt an existing test to provide coverage
This commit is contained in:

committed by
Eric Daniels

parent
4f40756d9c
commit
dbe26d34d8
@@ -5,6 +5,7 @@ package ivfwriter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -257,19 +258,25 @@ func TestIVFWriter_AV1(t *testing.T) {
|
|||||||
t.Run("Unfragmented", func(t *testing.T) {
|
t.Run("Unfragmented", func(t *testing.T) {
|
||||||
buffer := &bytes.Buffer{}
|
buffer := &bytes.Buffer{}
|
||||||
|
|
||||||
writer, err := NewWith(buffer, WithCodec(mimeTypeAV1))
|
expectedTimestamp := uint32(3653407706)
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
assert.NoError(t, writer.WriteRTP(&rtp.Packet{Payload: []byte{0x00, 0x01, 0xFF}}))
|
// the timestamp is an uint32, 4 bytes from offset 36
|
||||||
assert.NoError(t, writer.Close())
|
expectedPayloadWithTimestamp := []byte{
|
||||||
assert.Equal(t, buffer.Bytes(), []byte{
|
|
||||||
0x44, 0x4b, 0x49, 0x46, 0x0, 0x0, 0x20,
|
0x44, 0x4b, 0x49, 0x46, 0x0, 0x0, 0x20,
|
||||||
0x0, 0x41, 0x56, 0x30, 0x31, 0x80, 0x2,
|
0x0, 0x41, 0x56, 0x30, 0x31, 0x80, 0x2,
|
||||||
0xe0, 0x1, 0x1e, 0x0, 0x0, 0x0, 0x1, 0x0,
|
0xe0, 0x1, 0x1e, 0x0, 0x0, 0x0, 0x1, 0x0,
|
||||||
0x0, 0x0, 0x84, 0x3, 0x0, 0x0, 0x0, 0x0,
|
0x0, 0x0, 0x84, 0x3, 0x0, 0x0, 0x0, 0x0,
|
||||||
0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0xda, 0x93, 0xc2,
|
||||||
0x0, 0x0, 0x0, 0x0, 0x0, 0xff,
|
0xd9, 0x0, 0x0, 0x0, 0x0, 0xff,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
writer, err := NewWith(buffer, WithCodec(mimeTypeAV1))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
assert.NoError(t, writer.WriteRTP(&rtp.Packet{Header: rtp.Header{Timestamp: expectedTimestamp}, Payload: []byte{0x00, 0x01, 0xFF}}))
|
||||||
|
assert.NoError(t, writer.Close())
|
||||||
|
assert.Equal(t, expectedPayloadWithTimestamp, buffer.Bytes())
|
||||||
|
assert.Equal(t, expectedTimestamp, binary.LittleEndian.Uint32(expectedPayloadWithTimestamp[36:40]))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Fragmented", func(t *testing.T) {
|
t.Run("Fragmented", func(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user