commit 2bf186a7a2c73df2e47b900b3b228535d7abfaf9
Author: Krzysztof Konopko <krzysztof.konopko@youview.com>
Date:   Thu Nov 22 10:57:25 2012 +0000

    tsmux element does not propagate flow status

diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c
index 1d61f93..26f18b1 100644
--- a/gst/mpegtsmux/mpegtsmux.c
+++ b/gst/mpegtsmux/mpegtsmux.c
@@ -1172,9 +1172,7 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
     }
   }
   /* flush packet cache */
-  mpegtsmux_push_packets (mux, FALSE);
-
-  return ret;
+  return mpegtsmux_push_packets (mux, FALSE);
 
   /* ERRORS */
 write_fail:
diff --git a/tests/check/elements/mpegtsmux.c b/tests/check/elements/mpegtsmux.c
index 911ee0a..e373917 100644
--- a/tests/check/elements/mpegtsmux.c
+++ b/tests/check/elements/mpegtsmux.c
@@ -620,6 +620,61 @@ GST_START_TEST (test_force_key_unit_event_upstream)
 
 GST_END_TEST;
 
+static GstFlowReturn
+flow_test_stat_chain_func (GstPad * pad, GstObject * parent, GstBuffer * buffer)
+{
+  // the requested status is conveyed in the timestamp
+  GstFlowReturn ret = GST_BUFFER_TIMESTAMP (buffer);
+  return ret;
+}
+
+GST_START_TEST (test_propagate_flow_status)
+{
+  GstElement *mux;
+  gchar *padname;
+  GstSegment segment;
+  GstBuffer *inbuffer;
+  GstCaps *caps;
+  guint i;
+
+  GstFlowReturn expected[] = { GST_FLOW_OK, GST_FLOW_FLUSHING, GST_FLOW_EOS,
+    GST_FLOW_NOT_NEGOTIATED, GST_FLOW_ERROR, GST_FLOW_NOT_SUPPORTED
+  };
+
+  mux = setup_tsmux (&video_src_template, "sink_%d", &padname);
+  gst_pad_set_chain_function (mysinkpad, flow_test_stat_chain_func);
+
+  fail_unless (gst_element_set_state (mux,
+          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+      "could not set to playing");
+
+  gst_segment_init (&segment, GST_FORMAT_TIME);
+  fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
+
+  caps = gst_caps_from_string (VIDEO_CAPS_STRING);
+  gst_pad_set_caps (mysrcpad, caps);
+  gst_caps_unref (caps);
+
+  for (i = 0; i < sizeof expected / sizeof expected[0]; ++i) {
+    GstFlowReturn res;
+
+    inbuffer = gst_buffer_new_and_alloc (1);
+    ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+    // convey the requested status in the timestamp
+    GST_BUFFER_TIMESTAMP (inbuffer) = expected[i];
+    res = gst_pad_push (mysrcpad, inbuffer);
+
+    fail_unless (res == expected[i],
+        "result: %d, expected: %d", res, expected[i]);
+  }
+
+  cleanup_tsmux (mux, padname);
+  g_free (padname);
+}
+
+GST_END_TEST;
+
 static Suite *
 mpegtsmux_suite (void)
 {
@@ -632,6 +687,7 @@ mpegtsmux_suite (void)
   tcase_add_test (tc_chain, test_video);
   tcase_add_test (tc_chain, test_force_key_unit_event_downstream);
   tcase_add_test (tc_chain, test_force_key_unit_event_upstream);
+  tcase_add_test (tc_chain, test_propagate_flow_status);
 
   return s;
 }
