test: rtph264depay: Check handling of STAP-A marker
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Sun, 27 Jan 2019 01:42:40 +0000 (20:42 -0500)
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>
Thu, 31 Jan 2019 19:30:14 +0000 (19:30 +0000)
Related to #557

tests/check/elements/rtph264.c

index 3fab42b..8c16363 100644 (file)
@@ -408,6 +408,79 @@ GST_START_TEST (test_rtph264depay_marker_to_flag)
 
 GST_END_TEST;
 
+
+/* As GStreamer does not have STAP-A yet, this was extracted from
+ * issue #557 provided sample */
+static guint8 rtp_stapa_pps_sps[] = {
+  0x80, 0x60, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+  0xd8, 0xd9, 0x06, 0x7f, 0x38, 0x00, 0x1c, 0x27,
+  0x64, 0x00, 0x29, 0xac, 0x13, 0x16, 0x50, 0x28,
+  0x0f, 0x6c, 0x00, 0x30, 0x30, 0x00, 0x5d, 0xc0,
+  0x00, 0x17, 0x70, 0x5e, 0xf7, 0xc1, 0xda, 0x08,
+  0x84, 0x65, 0x80, 0x00, 0x04, 0x28, 0xef, 0x1f,
+  0x2c
+};
+
+static guint8 rtp_stapa_slices_marker[] = {
+  0x80, 0xe0, 0x00, 0x0c, 0x00, 0x00, 0x57, 0xe4,
+  0xd8, 0xd9, 0x06, 0x7f, 0x38, 0x00, 0x28, 0x21,
+  0xe0, 0x02, 0x00, 0x10, 0x73, 0x84, 0x12, 0xff,
+  0x00, 0x1f, 0x0c, 0xbf, 0x0c, 0xb7, 0xb8, 0x73,
+  0xd3, 0xf2, 0xfc, 0xba, 0x7b, 0xce, 0x3c, 0xaf,
+  0x90, 0x11, 0xb3, 0x15, 0xa2, 0x53, 0x96, 0xc1,
+  0xa8, 0x27, 0x01, 0xdb, 0xde, 0xc8, 0x80, 0x00,
+  0x35, 0x21, 0x00, 0xa0, 0xe0, 0x02, 0x00, 0x10,
+  0x73, 0x84, 0x12, 0xff, 0x79, 0x9d, 0x3b, 0x38,
+  0xc6, 0x26, 0x47, 0x01, 0x02, 0x6b, 0xd6, 0x40,
+  0x17, 0x06, 0x0b, 0x8c, 0x22, 0xd0, 0x04, 0xe4,
+  0xea, 0x5e, 0x3f, 0xb8, 0x6a, 0x03, 0x4e, 0x15,
+  0x1f, 0x74, 0x62, 0x51, 0x78, 0xef, 0x5a, 0xd1,
+  0xf0, 0x3e, 0xb8, 0x56, 0xbb, 0x08, 0x00, 0x2e,
+  0x21, 0x00, 0x50, 0x38, 0x00, 0x80, 0x04, 0x1c,
+  0xe1, 0x04, 0xbf, 0x00, 0xa8, 0x40, 0x67, 0x09,
+  0xa8, 0x4d, 0x95, 0x5b, 0x0e, 0x2b, 0xba, 0x34,
+  0xc7, 0xa6, 0x78, 0x27, 0xe4, 0x5c, 0x74, 0xa0,
+  0xa2, 0xce, 0x30, 0x51, 0x78, 0x30, 0x56, 0xd0,
+  0x7a, 0xcd, 0x12, 0xbc, 0xba, 0xe0, 0x00, 0x1e,
+  0x21, 0x00, 0x78, 0x38, 0x00, 0x80, 0x04, 0x1c,
+  0xe1, 0x04, 0xbf, 0x67, 0x37, 0xc0, 0x86, 0x26,
+  0x7d, 0x4c, 0x52, 0x4b, 0x80, 0x9a, 0x3c, 0xa3,
+  0x02, 0xcd, 0x8d, 0xcd, 0x18, 0xd8
+};
+
+GST_START_TEST (test_rtph264depay_stap_a_marker)
+{
+  GstHarness *h = gst_harness_new ("rtph264depay");
+  GstBuffer *buffer;
+  GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
+  GstFlowReturn ret;
+
+  gst_harness_set_caps_str (h,
+      "application/x-rtp,media=video,clock-rate=90000,encoding-name=H264",
+      "video/x-h264,alignment=au,stream-format=byte-stream");
+
+  ret = gst_harness_push (h,
+      wrap_static_buffer (rtp_stapa_pps_sps, sizeof (rtp_stapa_pps_sps)));
+  fail_unless_equals_int (ret, GST_FLOW_OK);
+  fail_unless_equals_int (gst_harness_buffers_in_queue (h), 0);
+
+  buffer = wrap_static_buffer (rtp_stapa_slices_marker,
+      sizeof (rtp_stapa_slices_marker));
+  fail_unless (gst_rtp_buffer_map (buffer, GST_MAP_WRITE, &rtp));
+  gst_rtp_buffer_set_seq (&rtp, 2);
+  gst_rtp_buffer_unmap (&rtp);
+  ret = gst_harness_push (h, buffer);
+  fail_unless_equals_int (ret, GST_FLOW_OK);
+
+  /* Only one AU should have been pushed */
+  fail_unless_equals_int (gst_harness_buffers_in_queue (h), 1);
+
+  gst_harness_teardown (h);
+}
+
+GST_END_TEST;
+
+
 /* AUD */
 static guint8 h264_aud[] = {
   0x00, 0x00, 0x00, 0x01, 0x09, 0xf0
@@ -694,6 +767,7 @@ rtph264_suite (void)
   tcase_add_test (tc_chain, test_rtph264depay_with_downstream_allocator);
   tcase_add_test (tc_chain, test_rtph264depay_eos);
   tcase_add_test (tc_chain, test_rtph264depay_marker_to_flag);
+  tcase_add_test (tc_chain, test_rtph264depay_stap_a_marker);
 
   tc_chain = tcase_create ("rtph264pay");
   suite_add_tcase (s, tc_chain);