diff --git a/codecs/av1_packet.go b/codecs/av1_packet.go index a571d9f..ab88262 100644 --- a/codecs/av1_packet.go +++ b/codecs/av1_packet.go @@ -171,6 +171,8 @@ func (p *AV1Packet) Unmarshal(payload []byte) ([]byte, error) { return nil, err } p.OBUElements = elts + } else { + p.OBUElements = nil } return payload[1:], nil diff --git a/codecs/av1_packet_test.go b/codecs/av1_packet_test.go index 2a65c4f..4063a4c 100644 --- a/codecs/av1_packet_test.go +++ b/codecs/av1_packet_test.go @@ -275,20 +275,32 @@ func TestAV1_Unmarshal(t *testing.T) { } av1Pkt := &AV1Packet{} - if _, err := av1Pkt.Unmarshal(av1Payload); err != nil { + av1Pkt.SetDontParseBody(true) + payload, err := av1Pkt.Unmarshal(av1Payload) + if err != nil { t.Fatal(err) } + t.Log(*av1Pkt) if !reflect.DeepEqual(av1Pkt, &AV1Packet{ - Z: false, - Y: true, - W: 2, - N: true, - OBUElements: [][]byte{ - av1Payload[2:14], - av1Payload[14:], - }, + Z: false, + Y: true, + W: 2, + N: true, + dontParseBody: true, }) { - t.Fatal("AV1 Unmarshal didn't store the expected results in the packet") + t.Error("AV1 Unmarshal didn't store the expected results in the packet") + } + + obus, err := av1Pkt.ParseBody(payload) + if err != nil { + t.Fatal("ParseOBUElements: ", err) + } + + if !reflect.DeepEqual(obus, [][]byte{ + av1Payload[2:14], + av1Payload[14:], + }) { + t.Fatal("Unexpected value ParseOBUElements") } }