avtpcvfpay: Do not hide or modify gst_pad_push errors
authorEderson de Souza <ederson.desouza@intel.com>
Fri, 1 Nov 2019 22:39:25 +0000 (15:39 -0700)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 19 Nov 2019 13:35:00 +0000 (13:35 +0000)
Current code would change any non-ok return from gst_pad_push to
GST_FLOW_ERROR, thus hiding meaningful returns such as GST_FLOW_EOS.

Tests also added.

ext/avtp/gstavtpcvfpay.c
tests/check/elements/avtpcvfpay.c

index 80c61a2..dcbdd9d 100644 (file)
@@ -483,22 +483,24 @@ gst_avtp_cvf_pay_prepare_avtp_packets (GstAvtpCvfPay * avtpcvfpay,
   return TRUE;
 }
 
-static gboolean
+static GstFlowReturn
 gst_avtp_cvf_pay_push_packets (GstAvtpCvfPay * avtpcvfpay,
     GPtrArray * avtp_packets)
 {
   int i;
+  GstFlowReturn ret;
   GstAvtpBasePayload *avtpbasepayload = GST_AVTP_BASE_PAYLOAD (avtpcvfpay);
 
   for (i = 0; i < avtp_packets->len; i++) {
     GstBuffer *packet;
 
     packet = g_ptr_array_index (avtp_packets, i);
-    if (gst_pad_push (avtpbasepayload->srcpad, packet) != GST_FLOW_OK)
-      return FALSE;
+    ret = gst_pad_push (avtpbasepayload->srcpad, packet);
+    if (ret != GST_FLOW_OK)
+      return ret;
   }
 
-  return TRUE;
+  return GST_FLOW_OK;
 }
 
 static GstFlowReturn
@@ -523,8 +525,7 @@ gst_avtp_cvf_pay_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
   avtp_packets = g_ptr_array_new ();
   gst_avtp_cvf_pay_prepare_avtp_packets (avtpcvfpay, nals, avtp_packets);
 
-  if (!gst_avtp_cvf_pay_push_packets (avtpcvfpay, avtp_packets))
-    ret = GST_FLOW_ERROR;
+  ret = gst_avtp_cvf_pay_push_packets (avtpcvfpay, avtp_packets);
 
   /* Contents of both ptr_arrays should be unref'd or transferred
    * to rightful owner by this point, no need to unref them again */
index f3f3c2a..66f8d38 100644 (file)
@@ -137,6 +137,29 @@ compare_h264_avtpdu (struct avtp_stream_pdu *pdu, GstBuffer * buffer)
   return result;
 }
 
+GST_START_TEST (test_payloader_downstream_eos)
+{
+  GstHarness *h;
+  GstBuffer *in;
+
+  /* Create the harness for the avtpcvfpay */
+  h = gst_harness_new_parse
+      ("avtpcvfpay streamid=0xAABBCCDDEEFF0001 mtt=1000000 tu=1000000 processing-deadline=0 ! fakesink num-buffers=1");
+  gst_harness_set_src_caps (h, generate_caps (4));
+
+  /* Buffer must have the nal len (4 bytes) and the nal (4 bytes) */
+  in = gst_harness_create_buffer (h, 8);
+  add_nal (in, 4, 1, 0);
+  GST_BUFFER_DTS (in) = 1000000;
+  GST_BUFFER_PTS (in) = 2000000;
+
+  fail_unless_equals_int (gst_harness_push (h, in), GST_FLOW_EOS);
+
+  gst_harness_teardown (h);
+}
+
+GST_END_TEST;
+
 GST_START_TEST (test_payloader_zero_sized_nal)
 {
   GstHarness *h;
@@ -674,6 +697,7 @@ avtpcvfpay_suite (void)
   tcase_add_test (tc_chain, test_payloader_properties);
   tcase_add_test (tc_chain, test_payloader_no_codec_data);
   tcase_add_test (tc_chain, test_payloader_zero_sized_nal);
+  tcase_add_test (tc_chain, test_payloader_downstream_eos);
 
   return s;
 }