summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhoonhee.lee <hoonhee.lee@lge.com>2014-12-05 14:16:52 +0900
committerOlivier CrĂȘte <olivier.crete@collabora.com>2015-03-10 16:15:35 -0400
commit8ce1f4d470d337d734d88daab2d31f40512c3f81 (patch)
treeb9a4ebada774dbd38b4890d10847e2353d6a0b9a
parent58f9c1dd71c953548d8c88a88ffb31b50b6e3696 (diff)
funnel: handle GAP event to forwards sticky events into downstream
If no data is coming and funnel receive GAP event, need to forwards sticky events into downstream if it needs. https://bugzilla.gnome.org/show_bug.cgi?id=738202
-rw-r--r--plugins/elements/gstfunnel.c9
-rw-r--r--tests/check/elements/funnel.c130
2 files changed, 139 insertions, 0 deletions
diff --git a/plugins/elements/gstfunnel.c b/plugins/elements/gstfunnel.c
index f5dedcca8..6c6af2baa 100644
--- a/plugins/elements/gstfunnel.c
+++ b/plugins/elements/gstfunnel.c
@@ -317,6 +317,15 @@ gst_funnel_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
GST_OBJECT_LOCK (funnel);
fpad->got_eos = FALSE;
GST_OBJECT_UNLOCK (funnel);
+ } else if (GST_EVENT_TYPE (event) == GST_EVENT_GAP) {
+ /* If no data is coming and we receive GAP event, need to forward sticky events. */
+ unlock = TRUE;
+ GST_PAD_STREAM_LOCK (funnel->srcpad);
+ GST_OBJECT_LOCK (funnel);
+ gst_object_replace ((GstObject **) & funnel->last_sinkpad,
+ GST_OBJECT (pad));
+ GST_OBJECT_UNLOCK (funnel);
+ gst_pad_sticky_events_foreach (pad, forward_events, funnel->srcpad);
}
if (forward)
diff --git a/tests/check/elements/funnel.c b/tests/check/elements/funnel.c
index e5fe75f6b..313dd4866 100644
--- a/tests/check/elements/funnel.c
+++ b/tests/check/elements/funnel.c
@@ -243,6 +243,135 @@ GST_START_TEST (test_funnel_eos)
GST_END_TEST;
+guint nb_stream_start_event = 0;
+guint nb_caps_event = 0;
+guint nb_segment_event = 0;
+guint nb_gap_event = 0;
+
+static GstPadProbeReturn
+event_counter (GstObject * pad, GstPadProbeInfo * info, gpointer user_data)
+{
+ GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
+
+ fail_unless (event != NULL);
+ fail_unless (GST_IS_EVENT (event));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_STREAM_START:
+ ++nb_stream_start_event;
+ break;
+ case GST_EVENT_CAPS:
+ ++nb_caps_event;
+ break;
+ case GST_EVENT_SEGMENT:
+ ++nb_segment_event;
+ break;
+ case GST_EVENT_GAP:
+ ++nb_gap_event;
+ break;
+ default:
+ break;
+ }
+
+ return GST_PAD_PROBE_OK;
+}
+
+/*
+ * Push GAP events into funnel to forward sticky events.
+ * Funnel element shoud also treat GAP events likes buffers.
+ * For example, funnel can be used for internal subtitle with streamiddemux.
+ * +--------------------------------------------------------------------------+
+ * | playbin +--------------------------------+ |
+ * | +--------------+ +----------------+ | +------------+ playsink | |
+ * | | uridecodebin | | input-selector | | | video-sink | | |
+ * | | | +----------------+ | +------------+ | |
+ * | | | | | |
+ * | | | +----------------+ | +------------+ | |
+ * | | | | input-selector | | | audio-sink | | |
+ * | | | +----------------+ | +------------+ | |
+ * | | | | | |
+ * | | | +----------------+ | +---------------+ +----------+ | |
+ * | | | | funnel | | | streamiddemux | | appsink0 | | |
+ * | +--------------+ +----------------+ | +---------------+ +----------+ | |
+ * | | +----------+ | |
+ * | | | appsinkn | | |
+ * | | +----------+ | |
+ * | +--------------------------------+ |
+ * +--------------------------------------------------------------------------+
+ * If no data was received in funnel and then sticky events can be pending continuously.
+ * And streamiddemux only receive gap events continuously.
+ * Thus, pipeline can not be constructed completely.
+ * For support it, need to handle GAP events likes buffers.
+ */
+GST_START_TEST (test_funnel_gap_event)
+{
+ struct TestData td;
+ guint probe = 0;
+
+ setup_test_objects (&td, chain_ok);
+
+ nb_stream_start_event = 0;
+ nb_caps_event = 0;
+ nb_segment_event = 0;
+ nb_gap_event = 0;
+ bufcount = 0;
+
+ probe = gst_pad_add_probe (td.mysink, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
+ (GstPadProbeCallback) event_counter, NULL, NULL);
+
+ /* push a gap event to srcpad1 to push sticky events */
+ fail_unless (gst_pad_push_event (td.mysrc1, gst_event_new_gap (0,
+ GST_SECOND)));
+
+ fail_unless (nb_stream_start_event == 1);
+ fail_unless (nb_caps_event == 1);
+ fail_unless (nb_segment_event == 1);
+ fail_unless (nb_gap_event == 1);
+
+ /* push a gap event to srcpad2 to push sticky events */
+ fail_unless (gst_pad_push_event (td.mysrc2, gst_event_new_gap (0,
+ GST_SECOND)));
+
+ fail_unless (nb_stream_start_event == 2);
+ fail_unless (nb_caps_event == 2);
+ fail_unless (nb_segment_event == 2);
+ fail_unless (nb_gap_event == 2);
+
+ /* push a gap event to srcpad2 */
+ fail_unless (gst_pad_push_event (td.mysrc2, gst_event_new_gap (0,
+ GST_SECOND)));
+
+ fail_unless (nb_stream_start_event == 2);
+ fail_unless (nb_caps_event == 2);
+ fail_unless (nb_segment_event == 2);
+ fail_unless (nb_gap_event == 3);
+
+ /* push a gap event to srcpad1 */
+ fail_unless (gst_pad_push_event (td.mysrc1, gst_event_new_gap (0,
+ GST_SECOND)));
+
+ fail_unless (nb_stream_start_event == 3);
+ fail_unless (nb_caps_event == 3);
+ fail_unless (nb_segment_event == 3);
+ fail_unless (nb_gap_event == 4);
+
+ /* push buffer */
+ fail_unless (gst_pad_push (td.mysrc1, gst_buffer_new ()) == GST_FLOW_OK);
+ fail_unless (gst_pad_push (td.mysrc2, gst_buffer_new ()) == GST_FLOW_OK);
+
+ fail_unless (nb_stream_start_event == 4);
+ fail_unless (nb_caps_event == 4);
+ fail_unless (nb_segment_event == 4);
+ fail_unless (nb_gap_event == 4);
+ fail_unless (bufcount == 2);
+
+ gst_pad_remove_probe (td.mysink, probe);
+
+ release_test_objects (&td);
+}
+
+GST_END_TEST;
+
static Suite *
funnel_suite (void)
{
@@ -252,6 +381,7 @@ funnel_suite (void)
tc_chain = tcase_create ("funnel simple");
tcase_add_test (tc_chain, test_funnel_simple);
tcase_add_test (tc_chain, test_funnel_eos);
+ tcase_add_test (tc_chain, test_funnel_gap_event);
suite_add_tcase (s, tc_chain);
return s;