From bca8ac2cf0bf88f279ecd0eb04c8cf79b8f86853 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 8 Aug 2017 13:10:15 +0100 Subject: [PATCH] tests: rtp-payloading: add unit test for rtph264pay codec_data Make sure no trailing zero bytes sneak into our SPS or PPS. https://bugzilla.gnome.org/show_bug.cgi?id=732758 --- tests/check/elements/rtp-payloading.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/check/elements/rtp-payloading.c b/tests/check/elements/rtp-payloading.c index c68b2ba..e952207 100644 --- a/tests/check/elements/rtp-payloading.c +++ b/tests/check/elements/rtp-payloading.c @@ -743,6 +743,32 @@ GST_START_TEST (rtp_h264depay_avc) fail_unless (gst_structure_has_field (st, "profile")); val = gst_structure_get_value (st, "codec_data"); fail_unless (val != NULL); + fail_unless (GST_VALUE_HOLDS_BUFFER (val)); + /* check codec_data, shouldn't contain trailing zeros */ + buf = gst_value_get_buffer (val); + fail_unless (gst_buffer_map (buf, &map, GST_MAP_READ)); + { + guint num_sps, num_pps, len; + guint8 *data; + + GST_MEMDUMP ("H.264 codec_data", map.data, map.size); + fail_unless_equals_int (map.data[0], 1); + num_sps = map.data[5] & 0x1f; + data = map.data + 6; + fail_unless_equals_int (num_sps, 1); + len = GST_READ_UINT16_BE (data); + data += 2; + /* make sure there are no trailing zeros in the SPS */ + fail_unless (data[len - 1] != 0); + data += len; + num_pps = *data++; + fail_unless_equals_int (num_pps, 1); + len = GST_READ_UINT16_BE (data); + data += 2; + /* make sure there are no trailing zeros in the PPS */ + fail_unless (data[len - 1] != 0); + } + gst_buffer_unmap (buf, &map); buf = gst_sample_get_buffer (s); fail_unless (gst_buffer_map (buf, &map, GST_MAP_READ)); -- 2.7.4