Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions codecs/h266_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ func (d *H266Depacketizer) Unmarshal(packet []byte) ([]byte, error) { //nolint:
if err != nil {
return nil, err
}
rebuilt.donl = nil
output = append(output, rebuilt.packetize(make([]byte, 0))...)
d.partials = d.partials[:0]

Expand Down Expand Up @@ -690,6 +691,7 @@ func (d *H266Depacketizer) Unmarshal(packet []byte) ([]byte, error) { //nolint:
}
for _, p := range aggregated {
output = append(output, annexbNALUStartCode...)
p.donl = nil
output = p.packetize(output)
}

Expand All @@ -702,6 +704,7 @@ func (d *H266Depacketizer) Unmarshal(packet []byte) ([]byte, error) { //nolint:
return nil, errNalCorrupted
}

single.donl = nil
output = single.packetize(output)

return output, nil
Expand Down
11 changes: 9 additions & 2 deletions codecs/h266_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func TestH266Depacketizer_Roundtrip(t *testing.T) {
}

emitH266Nalus(p, func(b []byte) {
parsed, err := parseH266Packet(b, withDonl)
parsed, err := parseH266Packet(b, false)
assert.Nil(t, err)
if err != nil {
return
Expand All @@ -567,8 +567,10 @@ func TestH266Depacketizer_Roundtrip(t *testing.T) {
// with DONL

basicPacket.donl = &testDonl
packetized := basicPacket.packetize(make([]byte, 0))
basicPacket.donl = nil

testDepacketizer([][]byte{basicPacket.packetize(make([]byte, 0))}, []isH266Packet{basicPacket}, true)
testDepacketizer([][]byte{packetized}, []isH266Packet{basicPacket}, true)

// Multiple NALs aggregated

Expand Down Expand Up @@ -599,6 +601,9 @@ func TestH266Depacketizer_Roundtrip(t *testing.T) {
assert.Nil(t, err)
donlAggregationPacketized := donlAggregation.packetize(make([]byte, 0))

firstPacket.donl = nil
secondPacket.donl = nil

testDepacketizer([][]byte{donlAggregationPacketized}, []isH266Packet{firstPacket, secondPacket}, true)

// Large NAL that gets fragmented
Expand Down Expand Up @@ -636,5 +641,7 @@ func TestH266Depacketizer_Roundtrip(t *testing.T) {
donlFragmentsPacketized = append(donlFragmentsPacketized, f.packetize(make([]byte, 0)))
}

largePacket.donl = nil

testDepacketizer(donlFragmentsPacketized, []isH266Packet{largePacket}, true)
}
Loading