urisourcebin: Fix parsebin handling

The goal of !3601 was to make sure we don't end up with non-streams-aware
adaptive demuxers. Since we know that parsebin is streams-aware, just remember
that and handle them that way.

Fixes issues with some scenarios where parsebin might add pads *before* the
collection is posted on the bus

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1675

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3658>
This commit is contained in:
Edward Hervey 2022-12-30 08:44:35 +01:00 committed by Edward Hervey
parent 66b96baf23
commit 6beca9f055

View file

@ -110,6 +110,7 @@ struct _ChildSrcPadInfo
GstElement *demuxer; GstElement *demuxer;
gboolean demuxer_handles_buffering; gboolean demuxer_handles_buffering;
gboolean demuxer_streams_aware; gboolean demuxer_streams_aware;
gboolean demuxer_is_parsebin;
/* list of output slots */ /* list of output slots */
GList *outputs; GList *outputs;
@ -755,7 +756,8 @@ new_demuxer_pad_added_cb (GstElement * element, GstPad * pad,
GST_URI_SOURCE_BIN_LOCK (urisrc); GST_URI_SOURCE_BIN_LOCK (urisrc);
/* Double-check that the demuxer is streams-aware by checking if it posted a /* Double-check that the demuxer is streams-aware by checking if it posted a
* collection */ * collection */
if (info->demuxer && !info->demuxer_streams_aware) { if (info->demuxer && !info->demuxer_is_parsebin
&& !info->demuxer_streams_aware) {
GST_ELEMENT_ERROR (urisrc, CORE, MISSING_PLUGIN, (NULL), GST_ELEMENT_ERROR (urisrc, CORE, MISSING_PLUGIN, (NULL),
("Adaptive demuxer is not streams-aware, check your installation")); ("Adaptive demuxer is not streams-aware, check your installation"));
@ -1898,6 +1900,8 @@ setup_parsebin_for_slot (ChildSrcPadInfo * info, GstPad * originating_pad)
gst_element_set_locked_state (info->demuxer, TRUE); gst_element_set_locked_state (info->demuxer, TRUE);
gst_bin_add (GST_BIN_CAST (urisrc), info->demuxer); gst_bin_add (GST_BIN_CAST (urisrc), info->demuxer);
info->demuxer_is_parsebin = TRUE;
if (info->pre_parse_queue) { if (info->pre_parse_queue) {
if (!gst_element_link_pads (info->pre_parse_queue, "src", info->demuxer, if (!gst_element_link_pads (info->pre_parse_queue, "src", info->demuxer,
"sink")) "sink"))
@ -2639,16 +2643,16 @@ handle_message (GstBin * bin, GstMessage * msg)
find_adaptive_demuxer_cspi_for_msg (urisrc, find_adaptive_demuxer_cspi_for_msg (urisrc,
(GstElement *) GST_MESSAGE_SRC (msg)); (GstElement *) GST_MESSAGE_SRC (msg));
if (info) { if (info) {
GST_DEBUG_OBJECT (bin,
"Dropping stream-collection for adaptive demuxer");
info->demuxer_streams_aware = TRUE; info->demuxer_streams_aware = TRUE;
gst_message_unref (msg); if (info->demuxer_is_parsebin) {
msg = NULL; GST_DEBUG_OBJECT (bin, "Dropping stream-collection from parsebin");
} else if (GST_MESSAGE_SRC (msg) != (GstObject *) urisrc->source gst_message_unref (msg);
&& !urisrc->is_adaptive) { msg = NULL;
}
} else if (GST_MESSAGE_SRC (msg) != (GstObject *) urisrc->source) {
GST_LOG_OBJECT (bin, "Collection %" GST_PTR_FORMAT, msg); GST_LOG_OBJECT (bin, "Collection %" GST_PTR_FORMAT, msg);
GST_DEBUG_OBJECT (bin, GST_DEBUG_OBJECT (bin,
"Dropping stream-collection from non-adaptive-demuxer %" "Dropping stream-collection from %"
GST_PTR_FORMAT, GST_MESSAGE_SRC (msg)); GST_PTR_FORMAT, GST_MESSAGE_SRC (msg));
gst_message_unref (msg); gst_message_unref (msg);
msg = NULL; msg = NULL;