From 437c45c9bef69477aa2792825b3f4d6976660c5f Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Mon, 15 Apr 2024 18:49:04 +0200 Subject: [PATCH] Avoid usage of OBUElements in av1_packet_test It's deprecated. --- codecs/av1_packet.go | 2 ++ codecs/av1_packet_test.go | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/codecs/av1_packet.go b/codecs/av1_packet.go index a29678c..f951dbf 100644 --- a/codecs/av1_packet.go +++ b/codecs/av1_packet.go @@ -166,6 +166,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..e28dd9d 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.DontParseOBUElements = 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:], - }, + DontParseOBUElements: 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.ParseOBUElements(payload) + if err != nil { + t.Fatal("ParseOBUElements: ", err) + } + + if !reflect.DeepEqual(obus, [][]byte{ + av1Payload[2:14], + av1Payload[14:], + }) { + t.Fatal("Unexpected value ParseOBUElements") } }