mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
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
This commit is contained in:
parent
58f9c1dd71
commit
8ce1f4d470
2 changed files with 139 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue