From 9ebb4505db6744640280c3e0cbdc611d041fd02a Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 18 Jan 2022 02:52:47 +1100 Subject: [PATCH] playbin3: Reconfigure on streams-selected message. Don't reconfigure outputs when the select-streams event is sent from the app, as the selection may not take effect for some time. Instead, wait for the pipeline to confirm the new set of selected streams when it sends the message. Part-of: --- .../gst/playback/gstplaybin3.c | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/playback/gstplaybin3.c b/subprojects/gst-plugins-base/gst/playback/gstplaybin3.c index a7321607e5..119210149d 100644 --- a/subprojects/gst-plugins-base/gst/playback/gstplaybin3.c +++ b/subprojects/gst-plugins-base/gst/playback/gstplaybin3.c @@ -2300,15 +2300,8 @@ gst_play_bin3_send_event (GstElement * element, GstEvent * event) * the selection with that combiner */ event = update_select_streams_event (playbin, event, group); - if (group->collection) { - group->selected_stream_types = - get_stream_type_for_event (group->collection, event); - playbin->selected_stream_types = - playbin->groups[0].selected_stream_types | playbin->groups[1]. - selected_stream_types; - if (playbin->active_stream_types != playbin->selected_stream_types) - reconfigure_output (playbin); - } + /* Don't reconfigure playsink just yet, until the streams-selected + * message(s) tell us as streams become active / available */ /* Send this event directly to uridecodebin, so it works even * if uridecodebin didn't add any pads yet */ @@ -2585,6 +2578,32 @@ gst_play_bin3_handle_message (GstBin * bin, GstMessage * msg) if (playbin->is_live && GST_STATE_TARGET (playbin) == GST_STATE_PLAYING) { do_reset_time = TRUE; } + } else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED) { + GstSourceGroup *target_group; + + GST_PLAY_BIN3_LOCK (playbin); + + target_group = find_source_group_owner (playbin, msg->src); + if (target_group) { + GstStreamType selected_types = 0; + guint i, nb; + nb = gst_message_streams_selected_get_size (msg); + for (i = 0; i < nb; i++) { + GstStream *stream = gst_message_streams_selected_get_stream (msg, i); + selected_types |= gst_stream_get_stream_type (stream); + gst_object_unref (stream); + } + target_group->selected_stream_types = selected_types; + playbin->selected_stream_types = + playbin->groups[0].selected_stream_types | playbin->groups[1]. + selected_stream_types; + if (playbin->active_stream_types != playbin->selected_stream_types) { + GST_DEBUG_OBJECT (playbin, + "selected stream types changed, reconfiguring output"); + reconfigure_output (playbin); + } + } + GST_PLAY_BIN3_UNLOCK (playbin); } beach: