diff --git a/codec/h264/extract_test.go b/codec/h264/extract_test.go index cf315606..eb82af1e 100644 --- a/codec/h264/extract_test.go +++ b/codec/h264/extract_test.go @@ -76,79 +76,81 @@ func TestRTPLex(t *testing.T) { { packets: [][]byte{ { // Single NAL unit. - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // RTP header. + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // RTP header. typeSingleNALULowBound, // NAL header. - 0x01, 0x02, 0x03, 0x04, // NAL Data. + 1, 2, 3, 4, // NAL Data. }, { // Fragmentation (start packet). - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // RTP header. - typeFUA, // FU indicator. - 0x80 | typeSingleNALULowBound, // FU header. - 0x01, 0x02, 0x03, // FU payload. + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // RTP header. + typeFUA, // FU indicator. + 128 | typeSingleNALULowBound, // FU header. + 1, 2, 3, // FU payload. }, { // Fragmentation (middle packet) - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // RTP header. + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // RTP header. typeFUA, // NAL indicator. typeSingleNALULowBound, // FU header. - 0x04, 0x05, 0x06, // FU payload. + 4, 5, 6, // FU payload. }, { // Fragmentation (end packet) - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // RTP header. + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // RTP header. typeFUA, // NAL indicator. 0x40 | typeSingleNALULowBound, // FU header. - 0x07, 0x08, 0x09, // FU payload + 7, 8, 9, // FU payload }, - { // Aggregation. Make last packet of access unit => marker bit true. - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // RTP header. - typeSTAPA, // NAL header. - 0x00, 0x04, // NAL 1 size. - 0x01, 0x02, 0x03, 0x04, // NAL 1 data. - 0x00, 0x04, // NAL 2 size. - 0x01, 0x02, 0x03, 0x04, // NAL 2 data. + { + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // RTP header. + typeSTAPA, // NAL header. + 0, 4, // NAL 1 size. + 1, 2, 3, 4, // NAL 1 data. + 0, 4, // NAL 2 size. + 1, 2, 3, 4, // NAL 2 data. }, - // Second access unit. { // Single NAL unit. - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // RTP header. + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // RTP header. typeSingleNALULowBound, // NAL header. - 0x01, 0x02, 0x03, 0x04, // NAL Data. + 1, 2, 3, 4, // NAL Data. }, - { // Single NAL. Make last packet of access unit => marker bit true. - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // RTP header. + { + 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // RTP header. typeSingleNALULowBound, // NAL header. - 0x01, 0x02, 0x03, 0x04, // NAL data. + 1, 2, 3, 4, // NAL data. }, }, expect: [][]byte{ - // First access unit. { - // NAL 1 - 0x00, 0x00, 0x00, 0x01, // Start code. - typeSingleNALULowBound, // NAL header. - 0x01, 0x02, 0x03, 0x04, // NAL data. - // NAL 2 - 0x00, 0x00, 0x00, 0x01, // Start code. - typeSingleNALULowBound, - 0x01, 0x02, 0x03, // FU payload. - 0x04, 0x05, 0x06, // FU payload. - 0x07, 0x08, 0x09, // FU payload. - // NAL 3 - 0x00, 0x00, 0x00, 0x01, // Start code. - 0x01, 0x02, 0x03, 0x04, // NAL data. - // NAL 4 - 0x00, 0x00, 0x00, 0x01, // Start code. - 0x01, 0x02, 0x03, 0x04, // NAL 2 data + 0, 0, 1, 9, 240, // AUD }, - // Second access unit. { - // NAL 1 - 0x00, 0x00, 0x00, 0x01, // Start code. + 0, 0, 1, 9, 240, // AUD + 0, 0, 0, 1, // Start code. typeSingleNALULowBound, // NAL header. - 0x01, 0x02, 0x03, 0x04, // Data. - // NAL 2 - 0x00, 0x00, 0x00, 0x01, // Start code. + 1, 2, 3, 4, // NAL data. + }, + { + 0, 0, 1, 9, 240, // AUD + 0, 0, 0, 1, // Start code. + typeSingleNALULowBound, + 1, 2, 3, // FU payload. + 4, 5, 6, // FU payload. + 7, 8, 9, // FU payload. + }, + { + 0, 0, 1, 9, 240, // AUD + 0, 0, 0, 1, // Start code. + 1, 2, 3, 4, // NAL data. + }, + { + 0, 0, 1, 9, 240, // AUD + 0, 0, 0, 1, // Start code. + 1, 2, 3, 4, // NAL data. + }, + { + 0, 0, 1, 9, 240, // AUD + 0, 0, 0, 1, // Start code. typeSingleNALULowBound, // NAL header. - 0x01, 0x02, 0x03, 0x04, // Data. + 1, 2, 3, 4, // NAL data. }, }, },