summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2017-08-08 13:10:15 +0100
committerTim-Philipp Müller <tim@centricular.com>2017-11-23 09:36:15 +0100
commitbca8ac2cf0bf88f279ecd0eb04c8cf79b8f86853 (patch)
tree37eab8bcbe91bfb97d6b8287d3d9615071fce612 /tests
parentec11b228a44a6d21c0fa593549010534b6a7f568 (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/rtp-payloading.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/check/elements/rtp-payloading.c b/tests/check/elements/rtp-payloading.c
index c68b2ba7b..e952207c4 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));