decodebin3: fix EOS event sequence

See docs:
https://gstreamer.freedesktop.org/documentation/additional/design/seqnums.html?gi-language=c#seqnums-sequence-numbers

Per docs:
When a sink element receives an EOS event and creates a new EOS
message to post, it should copy the seqnum from the event to the
message because the EOS message is a consequence of the EOS event
being received.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2837>
This commit is contained in:
James Hilliard 2022-06-12 05:35:27 -06:00 committed by Tim-Philipp Müller
parent afa0549c0c
commit 1fff4ef635
2 changed files with 8 additions and 7 deletions

View file

@ -117,7 +117,7 @@ all_inputs_are_eos (GstDecodebin3 * dbin)
/* WITH SELECTION_LOCK TAKEN! */ /* WITH SELECTION_LOCK TAKEN! */
static void static void
check_all_streams_for_eos (GstDecodebin3 * dbin) check_all_streams_for_eos (GstDecodebin3 * dbin, GstEvent * event)
{ {
GList *tmp; GList *tmp;
GList *outputpads = NULL; GList *outputpads = NULL;
@ -144,7 +144,7 @@ check_all_streams_for_eos (GstDecodebin3 * dbin)
GstPad *peer = (GstPad *) tmp->data; GstPad *peer = (GstPad *) tmp->data;
/* Send EOS and then remove elements */ /* Send EOS and then remove elements */
gst_pad_send_event (peer, gst_event_new_eos ()); gst_pad_send_event (peer, gst_event_ref (event));
GST_FIXME_OBJECT (peer, "Remove input stream"); GST_FIXME_OBJECT (peer, "Remove input stream");
gst_object_unref (peer); gst_object_unref (peer);
} }
@ -292,7 +292,7 @@ parse_chain_output_probe (GstPad * pad, GstPadProbeInfo * info,
if (all_inputs_are_eos (input->dbin)) { 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");
SELECTION_LOCK (input->dbin); SELECTION_LOCK (input->dbin);
check_all_streams_for_eos (input->dbin); check_all_streams_for_eos (input->dbin, ev);
SELECTION_UNLOCK (input->dbin); SELECTION_UNLOCK (input->dbin);
} else { } else {
GstPad *peer = gst_pad_get_peer (input->srcpad); GstPad *peer = gst_pad_get_peer (input->srcpad);
@ -553,7 +553,7 @@ parsebin_pending_event_probe (GstPad * pad, GstPadProbeInfo * info,
g_free (ppad); g_free (ppad);
SELECTION_LOCK (dbin); SELECTION_LOCK (dbin);
check_all_streams_for_eos (dbin); check_all_streams_for_eos (dbin, ev);
SELECTION_UNLOCK (dbin); SELECTION_UNLOCK (dbin);
} }
break; break;

View file

@ -1752,7 +1752,7 @@ is_selection_done (GstDecodebin3 * dbin)
/* Must be called with SELECTION_LOCK taken */ /* Must be called with SELECTION_LOCK taken */
static void static void
check_all_slot_for_eos (GstDecodebin3 * dbin) check_all_slot_for_eos (GstDecodebin3 * dbin, GstEvent * ev)
{ {
gboolean all_drained = TRUE; gboolean all_drained = TRUE;
GList *iter; GList *iter;
@ -1817,6 +1817,7 @@ check_all_slot_for_eos (GstDecodebin3 * dbin)
} }
eos = gst_event_new_eos (); eos = gst_event_new_eos ();
gst_event_set_seqnum (eos, gst_event_get_seqnum (ev));
gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (eos), gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (eos),
CUSTOM_FINAL_EOS_QUARK, (gchar *) CUSTOM_FINAL_EOS_QUARK_DATA, CUSTOM_FINAL_EOS_QUARK, (gchar *) CUSTOM_FINAL_EOS_QUARK_DATA,
NULL); NULL);
@ -1947,7 +1948,7 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
free_multiqueue_slot_async (dbin, slot); free_multiqueue_slot_async (dbin, slot);
ret = GST_PAD_PROBE_REMOVE; ret = GST_PAD_PROBE_REMOVE;
} else if (!was_drained) { } else if (!was_drained) {
check_all_slot_for_eos (dbin); check_all_slot_for_eos (dbin, ev);
} }
if (ret == GST_PAD_PROBE_HANDLED) if (ret == GST_PAD_PROBE_HANDLED)
gst_event_unref (ev); gst_event_unref (ev);
@ -1992,7 +1993,7 @@ multiqueue_src_probe (GstPad * pad, GstPadProbeInfo * info,
* when all output streams are also eos */ * when all output streams are also eos */
ret = GST_PAD_PROBE_DROP; ret = GST_PAD_PROBE_DROP;
SELECTION_LOCK (dbin); SELECTION_LOCK (dbin);
check_all_slot_for_eos (dbin); check_all_slot_for_eos (dbin, ev);
SELECTION_UNLOCK (dbin); SELECTION_UNLOCK (dbin);
} }
} }