diff --git a/codec/h265/lex.go b/codec/h265/lex.go index f9197af0..0c901791 100644 --- a/codec/h265/lex.go +++ b/codec/h265/lex.go @@ -155,7 +155,7 @@ func (l *Lexer) handleFragmentation(d []byte) { case !s && !e: l.writeNoPrefix(_d) default: - panic("bad fragmentation unit") + panic("bad fragmentation packet") } } diff --git a/codec/h265/lex_test.go b/codec/h265/lex_test.go index 2ae042d4..f2e239e2 100644 --- a/codec/h265/lex_test.go +++ b/codec/h265/lex_test.go @@ -58,7 +58,7 @@ func (d *destination) Write(p []byte) (int, error) { return len(p), nil } -func TestLex(t *testing.T) { +func TestLexNo(t *testing.T) { const rtpVer = 2 packets := []rtp.Pkt{ @@ -66,23 +66,17 @@ func TestLex(t *testing.T) { rtp.Pkt{ V: rtpVer, Payload: []byte{ - // NAL header (type=32 VPS) - 0x40, 0x00, - // NAL data - 0x01, 0x02, 0x03, 0x04, + 0x40, 0x00, // NAL header (type=32 VPS). + 0x01, 0x02, 0x03, 0x04, // NAL Data. }, }, - - // Fragmentation (start packet) + // Fragmentation (start packet). rtp.Pkt{ V: rtpVer, Payload: []byte{ - // NAL header (type 49) - 0x62, 0x00, - // FU header - 0x80, - // FU Payload - 0x01, 0x02, 0x03, + 0x62, 0x00, // NAL header (type49). + 0x80, // FU header. + 0x01, 0x02, 0x03, // FU payload. }, }, @@ -90,12 +84,9 @@ func TestLex(t *testing.T) { rtp.Pkt{ V: rtpVer, Payload: []byte{ - // NAL header (type 49) - 0x62, 0x00, - // FU header - 0x00, - // FU Payload - 0x04, 0x05, 0x06, + 0x62, 0x00, // NAL header (type 49). + 0x00, // FU header. + 0x04, 0x05, 0x06, // FU payload. }, }, @@ -103,31 +94,23 @@ func TestLex(t *testing.T) { rtp.Pkt{ V: rtpVer, Payload: []byte{ - // NAL header (type 49) - 0x62, 0x00, - // FU header - 0x40, - // FU Payload - 0x07, 0x08, 0x09, + 0x62, 0x00, // NAL header (type 49). + 0x40, // FU header. + 0x07, 0x08, 0x09, // FU payload }, }, // Aggregation. - // This is the last bit of data for the access unit, so set M true + // Consider last packet of access unit - M true rtp.Pkt{ V: rtpVer, M: true, Payload: []byte{ - // NAL header (type 49) - 0x60, 0x00, - // NAL1 Size - 0x00, 0x04, - // NAL1 data - 0x01, 0x02, 0x03, 0x04, - // NAL2 Size - 0x00, 0x04, - // NAL2 data - 0x01, 0x02, 0x03, 0x04, + 0x60, 0x00, // NAL header (type 49). + 0x00, 0x04, // NAL 1 size. + 0x01, 0x02, 0x03, 0x04, // NAL 1 data. + 0x00, 0x04, // NAL 2 size. + 0x01, 0x02, 0x03, 0x04, // NAL 2 data. }, }, @@ -135,10 +118,8 @@ func TestLex(t *testing.T) { rtp.Pkt{ V: rtpVer, Payload: []byte{ - // NAL header (type=32 VPS) - 0x40, 0x00, - // NAL data - 0x01, 0x02, 0x03, 0x04, + 0x40, 0x00, // NAL header (type=32 VPS). + 0x01, 0x02, 0x03, 0x04, // NAL data. }, }, @@ -147,62 +128,45 @@ func TestLex(t *testing.T) { V: rtpVer, M: true, Payload: []byte{ - // NAL header (type=32 VPS) - 0x40, 0x00, - // NAL data - 0x01, 0x02, 0x03, 0x04, + 0x40, 0x00, // NAL header (type=32 VPS). + 0x01, 0x02, 0x03, 0x04, // NAL data. }, }, } expect := [][]byte{ + // First access unit. { // NAL 1 - // Start code - 0x00, 0x00, 0x00, 0x01, - // NAL header (type=32 VPS) - 0x40, 0x00, - // NAL data - 0x01, 0x02, 0x03, 0x04, + 0x00, 0x00, 0x00, 0x01, // Start code. + 0x40, 0x00, // NAL header (type=32 VPS). + 0x01, 0x02, 0x03, 0x04, // NAL data. // NAL 2 - // Start code - 0x00, 0x00, 0x00, 0x01, - // FU Payload - 0x01, 0x02, 0x03, - // FU Payload - 0x04, 0x05, 0x06, - // FU Payload - 0x07, 0x08, 0x09, + 0x00, 0x00, 0x00, 0x01, // Start code. + 0x01, 0x02, 0x03, // FU payload. + 0x04, 0x05, 0x06, // FU payload. + 0x07, 0x08, 0x09, // FU payload. // NAL 3 - // Start code - 0x00, 0x00, 0x00, 0x01, - // NAL data - 0x01, 0x02, 0x03, 0x04, + 0x00, 0x00, 0x00, 0x01, // Start code. + 0x01, 0x02, 0x03, 0x04, // NAL data. // NAL 4 - // Start code - 0x00, 0x00, 0x00, 0x01, - // NAL2 data - 0x01, 0x02, 0x03, 0x04, + 0x00, 0x00, 0x00, 0x01, // Start code. + 0x01, 0x02, 0x03, 0x04, // NAL 2 data }, + // Second access unit. { // NAL 1 - //Start code - 0x00, 0x00, 0x00, 0x01, - // NAL header (type=32 VPS) - 0x40, 0x00, - // Data - 0x01, 0x02, 0x03, 0x04, + 0x00, 0x00, 0x00, 0x01, // Start code. + 0x40, 0x00, // NAL header (type=32 VPS). + 0x01, 0x02, 0x03, 0x04, // Data. // NAL 2 - //Start code - 0x00, 0x00, 0x00, 0x01, - // NAL header (type=32 VPS) - 0x40, 0x00, - // Data - 0x01, 0x02, 0x03, 0x04, + 0x00, 0x00, 0x00, 0x01, // Start code. + 0x40, 0x00, // NAL header (type=32 VPS). + 0x01, 0x02, 0x03, 0x04, // Data. }, }