decodebin3: Send custom-eos event to notify drained state

Likewise how urisourcebin is doing, use custom event if other streams
are still alive.

https://bugzilla.gnome.org/show_bug.cgi?id=773341
This commit is contained in:
Seungha Yang 2016-12-03 21:42:30 +09:00 committed by Edward Hervey
parent f4d6aa7167
commit 4fcbcf4e48
2 changed files with 37 additions and 18 deletions

View file

@ -247,32 +247,28 @@ parse_chain_output_probe (GstPad * pad, GstPadProbeInfo * info,
} }
break; break;
case GST_EVENT_EOS: case GST_EVENT_EOS:
/* FIXME : Make sure this makes sense ... */ input->saw_eos = TRUE;
if (TRUE) { if (all_inputs_are_eos (input->dbin)) {
GST_DEBUG_OBJECT (pad, "real input pad, marking as EOS"); GST_DEBUG_OBJECT (pad, "real input pad, marking as EOS");
input->saw_eos = TRUE;
check_all_streams_for_eos (input->dbin); check_all_streams_for_eos (input->dbin);
ret = GST_PAD_PROBE_DROP;
} else { } else {
MultiQueueSlot *slot; GstPad *peer = gst_pad_get_peer (input->srcpad);
if (peer) {
/* Send custom-eos event to multiqueue slot */
GstStructure *s;
GstEvent *event;
g_mutex_lock (&input->dbin->selection_lock);
slot = get_slot_for_input (input->dbin, input);
g_mutex_unlock (&input->dbin->selection_lock);
slot->drain_eos = input->drain_eos;
if (input->drain_eos) {
GST_DEBUG_OBJECT (pad, GST_DEBUG_OBJECT (pad,
"Got EOS at end of input stream (drain_eos:%d) Dropping.", "Got EOS end of input stream, post custom-eos");
input->drain_eos); s = gst_structure_new_empty ("decodebin3-custom-eos");
ret = GST_PAD_PROBE_DROP; event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, s);
gst_pad_send_event (peer, event);
gst_object_unref (peer);
} else { } else {
GST_DEBUG_OBJECT (pad, GST_FIXME_OBJECT (pad, "No peer, what should we do ?");
"Got EOS at end of input stream (drain_eos:%d) Passing.",
input->drain_eos);
} }
} }
ret = GST_PAD_PROBE_DROP;
break; break;
case GST_EVENT_FLUSH_STOP: case GST_EVENT_FLUSH_STOP:
GST_DEBUG_OBJECT (pad, "Clear saw_eos flag"); GST_DEBUG_OBJECT (pad, "Clear saw_eos flag");

View file

@ -319,6 +319,8 @@ typedef struct _MultiQueueSlot
gboolean drain_eos; gboolean drain_eos;
gboolean is_drained;
DecodebinOutputStream *output; DecodebinOutputStream *output;
} MultiQueueSlot; } MultiQueueSlot;
@ -1431,6 +1433,7 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
"Got a STREAM_START event without a GstStream"); "Got a STREAM_START event without a GstStream");
break; break;
} }
slot->is_drained = FALSE;
stream_id = gst_stream_get_stream_id (stream); stream_id = gst_stream_get_stream_id (stream);
GST_DEBUG_OBJECT (pad, "Stream Start '%s'", stream_id); GST_DEBUG_OBJECT (pad, "Stream Start '%s'", stream_id);
if (slot->active_stream == NULL) { if (slot->active_stream == NULL) {
@ -1490,6 +1493,7 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
/* FIXME : Figure out */ /* FIXME : Figure out */
GST_FIXME_OBJECT (pad, "EOS on multiqueue source pad. input:%p", GST_FIXME_OBJECT (pad, "EOS on multiqueue source pad. input:%p",
slot->input); slot->input);
slot->is_drained = TRUE;
if (slot->input == NULL) { if (slot->input == NULL) {
GstPad *peer; GstPad *peer;
GST_DEBUG_OBJECT (pad, GST_DEBUG_OBJECT (pad,
@ -1514,6 +1518,25 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
ret = GST_PAD_PROBE_HANDLED; ret = GST_PAD_PROBE_HANDLED;
} }
break; break;
case GST_EVENT_CUSTOM_DOWNSTREAM:
if (gst_event_has_name (ev, "decodebin3-custom-eos")) {
slot->is_drained = TRUE;
SELECTION_LOCK (dbin);
if (slot->input == NULL) {
GST_DEBUG_OBJECT (pad,
"Got custom-eos from null input stream, remove output stream");
/* Remove the output */
if (slot->output) {
DecodebinOutputStream *output = slot->output;
dbin->output_streams =
g_list_remove (dbin->output_streams, output);
free_output_stream (dbin, output);
}
}
SELECTION_UNLOCK (dbin);
ret = GST_PAD_PROBE_DROP;
}
break;
default: default:
break; break;
} }