From d14c14dcc4b3f4e2f1e8fdb3aecd11a7cc00aac0 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sat, 5 Nov 2022 09:19:29 +0100 Subject: [PATCH] decodebin3: Store GstStreamCollection from upstream If upstream provides stream collection, use/store them as soon as possible Part-of: --- .../gst/playback/gstdecodebin3.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c index 9b387ac1ae..0a1437d181 100644 --- a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c +++ b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c @@ -491,6 +491,8 @@ gst_decodebin3_select_stream (GstDecodebin3 * dbin, static GstPad *gst_decodebin3_request_new_pad (GstElement * element, GstPadTemplate * temp, const gchar * name, const GstCaps * caps); +static void handle_stream_collection (GstDecodebin3 * dbin, + GstStreamCollection * collection, DecodebinInput * input); static void gst_decodebin3_handle_message (GstBin * bin, GstMessage * message); static GstStateChangeReturn gst_decodebin3_change_state (GstElement * element, GstStateChange transition); @@ -1062,6 +1064,30 @@ sink_event_function (GstPad * sinkpad, GstDecodebin3 * dbin, GstEvent * event) dbin->upstream_selected = TRUE; break; } + case GST_EVENT_STREAM_COLLECTION: + { + GstStreamCollection *collection = NULL; + gst_event_parse_stream_collection (event, &collection); + if (collection) { + INPUT_LOCK (dbin); + handle_stream_collection (dbin, collection, input); + gst_object_unref (collection); + INPUT_UNLOCK (dbin); + SELECTION_LOCK (dbin); + /* Post the (potentially) updated collection */ + if (dbin->collection) { + GstMessage *msg; + msg = + gst_message_new_stream_collection ((GstObject *) dbin, + dbin->collection); + SELECTION_UNLOCK (dbin); + gst_element_post_message (GST_ELEMENT_CAST (dbin), msg); + update_requested_selection (dbin); + } else + SELECTION_UNLOCK (dbin); + } + break; + } case GST_EVENT_CAPS: { GST_DEBUG_OBJECT (sinkpad,