summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2017-12-08 16:46:21 +0100
committerEdward Hervey <bilboed@bilboed.com>2017-12-08 17:42:03 +0100
commitbd8efd6714f33b6c717e94335050ac1c73b07864 (patch)
tree36fdc7b315e1ca098a5d2cf694ed704572582b81
parent36166363f801da1b60278ab97cdfee073c74ac27 (diff)
decodebin3: Handle dual-output of STREAM_START/EOSuridecodebin3-1.12
In order to flush out multiqueue, we send again a STREAM_START and then a EOS event. The problem was that was that we might end up pushing out on the output of multiqueue (and therefore decodebin3) a series of: * EOS / STREAM_START / EOS Apart from the uglyness of such output, If decodebin3 is used with elements such as concat on their output, they might potentially block on that second STREAM_START. In order to make sure we don't end up in that situation we send a custom STREAM_START event when refreshing multiqueue (which we drop on the output) and we don't special case EOS events on streams on which we already got EOS. At worst we now end up sending at most two EOS on the output of multiqueue (and decodebin3).
-rw-r--r--gst/playback/gstdecodebin3.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/gst/playback/gstdecodebin3.c b/gst/playback/gstdecodebin3.c
index c8218b771..adbc52728 100644
--- a/gst/playback/gstdecodebin3.c
+++ b/gst/playback/gstdecodebin3.c
@@ -1587,9 +1587,17 @@ check_all_slot_for_eos (GstDecodebin3 * dbin)
if (peer) {
GstEvent *stream_start =
gst_pad_get_sticky_event (input->srcpad, GST_EVENT_STREAM_START, 0);
- /* First forward the STREAM_START event to reset the EOS status (if any) */
- if (stream_start)
- gst_pad_send_event (peer, stream_start);
+
+ /* First forward a custom STREAM_START event to reset the EOS status (if any) */
+ if (stream_start) {
+ GstStructure *s;
+ GstEvent *custom_stream_start = gst_event_copy (stream_start);
+ gst_event_unref (stream_start);
+ s = (GstStructure *) gst_event_get_structure (custom_stream_start);
+ gst_structure_set (s, "decodebin3-flushing-stream-start",
+ G_TYPE_BOOLEAN, TRUE, NULL);
+ gst_pad_send_event (peer, custom_stream_start);
+ }
gst_pad_send_event (peer, gst_event_new_eos ());
gst_object_unref (peer);
} else
@@ -1613,7 +1621,16 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
case GST_EVENT_STREAM_START:
{
GstStream *stream = NULL;
- const gchar *stream_id;
+ const GstStructure *s = gst_event_get_structure (ev);
+
+ /* Drop STREAM_START events used to cleanup multiqueue */
+ if (s
+ && gst_structure_has_field (s,
+ "decodebin3-flushing-stream-start")) {
+ ret = GST_PAD_PROBE_HANDLED;
+ gst_event_unref (ev);
+ break;
+ }
gst_event_parse_stream (ev, &stream);
if (stream == NULL) {
@@ -1622,8 +1639,8 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
break;
}
slot->is_drained = FALSE;
- stream_id = gst_stream_get_stream_id (stream);
- GST_DEBUG_OBJECT (pad, "Stream Start '%s'", stream_id);
+ GST_DEBUG_OBJECT (pad, "Stream Start '%s'",
+ gst_stream_get_stream_id (stream));
if (slot->active_stream == NULL) {
slot->active_stream = stream;
} else if (slot->active_stream != stream) {
@@ -1680,11 +1697,13 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
case GST_EVENT_EOS:
{
const GstStructure *s = gst_event_get_structure (ev);
+ gboolean was_drained = slot->is_drained;
slot->is_drained = TRUE;
/* Custom EOS handling first */
if (s && gst_structure_has_field (s, "decodebin3-custom-eos")) {
- ret = GST_PAD_PROBE_DROP;
+ GST_LOG_OBJECT (pad, "Received custom EOS");
+ ret = GST_PAD_PROBE_HANDLED;
SELECTION_LOCK (dbin);
if (slot->input == NULL) {
GST_DEBUG_OBJECT (pad,
@@ -1700,12 +1719,13 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
dbin->slots = g_list_remove (dbin->slots, slot);
free_multiqueue_slot_async (dbin, slot);
ret = GST_PAD_PROBE_REMOVE;
- } else {
+ } else if (!was_drained) {
check_all_slot_for_eos (dbin);
}
SELECTION_UNLOCK (dbin);
break;
}
+
GST_FIXME_OBJECT (pad, "EOS on multiqueue source pad. input:%p",
slot->input);
if (slot->input == NULL) {
@@ -1734,7 +1754,7 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
free_multiqueue_slot_async (dbin, slot);
ret = GST_PAD_PROBE_REMOVE;
- } else {
+ } else if (!was_drained) {
GST_DEBUG_OBJECT (pad, "What happens with event ?");
SELECTION_LOCK (dbin);
check_all_slot_for_eos (dbin);