decodebin3: Rename and refactor function

It was doing a bit more than it did initially, update the name accordingly.

Refactor slightly for visibility

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5052>
This commit is contained in:
Edward Hervey 2023-07-18 11:39:34 +02:00 committed by Edward Hervey
parent 1fd7c2c17a
commit 7e7f02f4f4
2 changed files with 45 additions and 49 deletions

View file

@ -84,6 +84,7 @@ static gboolean
all_inputs_are_eos (GstDecodebin3 * dbin) all_inputs_are_eos (GstDecodebin3 * dbin)
{ {
GList *tmp; GList *tmp;
/* First check input streams */ /* First check input streams */
for (tmp = dbin->input_streams; tmp; tmp = tmp->next) { for (tmp = dbin->input_streams; tmp; tmp = tmp->next) {
DecodebinInputStream *input = (DecodebinInputStream *) tmp->data; DecodebinInputStream *input = (DecodebinInputStream *) tmp->data;
@ -91,7 +92,7 @@ all_inputs_are_eos (GstDecodebin3 * dbin)
return FALSE; return FALSE;
} }
GST_DEBUG_OBJECT (dbin, "All streams are EOS"); GST_DEBUG_OBJECT (dbin, "All input streams are EOS");
return TRUE; return TRUE;
} }

View file

@ -2362,70 +2362,65 @@ is_selection_done (GstDecodebin3 * dbin)
return msg; return msg;
} }
/* Must be called with SELECTION_LOCK taken */ /* Must be called with SELECTION_LOCK taken
*
* This code is used to propagate the final EOS if all slots and inputs are
* drained.
**/
static void static void
check_all_slot_for_eos (GstDecodebin3 * dbin, GstEvent * ev) check_inputs_and_slots_for_eos (GstDecodebin3 * dbin, GstEvent * ev)
{ {
gboolean all_drained = TRUE;
GList *iter; GList *iter;
GST_DEBUG_OBJECT (dbin, "check slot for eos"); GST_DEBUG_OBJECT (dbin, "checking slots for eos");
for (iter = dbin->slots; iter; iter = iter->next) { for (iter = dbin->slots; iter; iter = iter->next) {
MultiQueueSlot *slot = iter->data; MultiQueueSlot *slot = iter->data;
if (!slot->output) if (slot->output && !slot->is_drained) {
continue; GST_LOG_OBJECT (slot->sink_pad, "Not drained, not all slots are done");
return;
if (slot->is_drained) {
GST_LOG_OBJECT (slot->sink_pad, "slot %p is drained", slot);
continue;
} }
all_drained = FALSE;
break;
} }
/* Also check with the inputs, data might be pending */ /* Also check with the inputs, data might be pending */
if (all_drained) if (!all_inputs_are_eos (dbin))
all_drained = all_inputs_are_eos (dbin); return;
if (all_drained) { GST_DEBUG_OBJECT (dbin,
GST_DEBUG_OBJECT (dbin, "All active slots are drained, and no pending input, push EOS");
"All active slots are drained, and no pending input, push EOS");
for (iter = dbin->input_streams; iter; iter = iter->next) { for (iter = dbin->input_streams; iter; iter = iter->next) {
DecodebinInputStream *input = (DecodebinInputStream *) iter->data; DecodebinInputStream *input = (DecodebinInputStream *) iter->data;
GstPad *peer = gst_pad_get_peer (input->srcpad); GstPad *peer = gst_pad_get_peer (input->srcpad);
/* Send EOS to all slots */ /* Send EOS to all slots */
if (peer) { if (peer) {
GstEvent *stream_start, *eos; GstEvent *stream_start, *eos;
stream_start = stream_start =
gst_pad_get_sticky_event (input->srcpad, GST_EVENT_STREAM_START, 0); gst_pad_get_sticky_event (input->srcpad, GST_EVENT_STREAM_START, 0);
/* First forward a custom STREAM_START event to reset the EOS status (if any) */ /* First forward a custom STREAM_START event to reset the EOS status (if
if (stream_start) { * any) */
GstStructure *s; if (stream_start) {
GstEvent *custom_stream_start = gst_event_copy (stream_start); GstStructure *s;
gst_event_unref (stream_start); GstEvent *custom_stream_start = gst_event_copy (stream_start);
s = (GstStructure *) gst_event_get_structure (custom_stream_start); gst_event_unref (stream_start);
gst_structure_set (s, "decodebin3-flushing-stream-start", s = (GstStructure *) gst_event_get_structure (custom_stream_start);
G_TYPE_BOOLEAN, TRUE, NULL); gst_structure_set (s, "decodebin3-flushing-stream-start",
gst_pad_send_event (peer, custom_stream_start); G_TYPE_BOOLEAN, TRUE, NULL);
} gst_pad_send_event (peer, custom_stream_start);
}
eos = gst_event_new_eos (); eos = gst_event_new_eos ();
gst_event_set_seqnum (eos, gst_event_get_seqnum (ev)); 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); gst_pad_send_event (peer, eos);
gst_pad_send_event (peer, eos); gst_object_unref (peer);
gst_object_unref (peer); } else
} else GST_DEBUG_OBJECT (dbin, "no output");
GST_DEBUG_OBJECT (dbin, "no output");
}
} }
} }
@ -2568,7 +2563,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, ev); check_inputs_and_slots_for_eos (dbin, ev);
} }
if (ret == GST_PAD_PROBE_HANDLED) if (ret == GST_PAD_PROBE_HANDLED)
gst_event_unref (ev); gst_event_unref (ev);
@ -2615,7 +2610,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, ev); check_inputs_and_slots_for_eos (dbin, ev);
SELECTION_UNLOCK (dbin); SELECTION_UNLOCK (dbin);
} }
} }