playbin3: Use STREAMS_SELECTED message to update selected stream types
authorSeungha Yang <sh.yang@lge.com>
Thu, 16 Mar 2017 10:53:11 +0000 (19:53 +0900)
committerEdward Hervey <bilboed@bilboed.com>
Fri, 27 Oct 2017 07:55:59 +0000 (09:55 +0200)
Application might choose only specific type among all available types
using select-streams event. In this case, it is desired that reconfigure
of playsink to clear unused stream path.

https://bugzilla.gnome.org/show_bug.cgi?id=778015

gst/playback/gstplaybin3.c

index 611b82cf2af8d747b2b3366c4dafd4953ff2b712..199a406e22ab1851674cc3380514b72965b3bf60 100644 (file)
@@ -2567,7 +2567,8 @@ gst_play_bin3_handle_message (GstBin * bin, GstMessage * msg)
   } else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED) {
     GstStreamCollection *collection = NULL;
     GstObject *src = GST_MESSAGE_SRC (msg);
-    gboolean pstate = playbin->do_stream_selections;
+    GstStreamType chosen_stream_types = 0;
+    gboolean reconfigure_playsink = FALSE;
 
     gst_message_parse_streams_selected (msg, &collection);
     if (collection) {
@@ -2584,16 +2585,24 @@ gst_play_bin3_handle_message (GstBin * bin, GstMessage * msg)
 
         stream = gst_message_streams_selected_get_stream (msg, i);
         set_selected_stream (playbin, stream);
+        chosen_stream_types |= gst_stream_get_stream_type (stream);
         gst_object_unref (stream);
       }
-      if (pstate)
-        playbin->do_stream_selections = FALSE;
-      do_stream_selection (playbin);
-      if (pstate)
-        playbin->do_stream_selections = TRUE;
+
+      if (playbin->selected_stream_types != chosen_stream_types) {
+        GST_DEBUG_OBJECT (playbin, "Chosen stream types are changed");
+        reconfigure_playsink = TRUE;
+      }
+      playbin->selected_stream_types = chosen_stream_types;
       GST_PLAY_BIN3_UNLOCK (playbin);
 
       gst_object_unref (collection);
+
+      if (reconfigure_playsink &&
+          (playbin->selected_stream_types & ~playbin->active_stream_types &
+              (GST_STREAM_TYPE_VIDEO | GST_STREAM_TYPE_AUDIO)) == 0) {
+        no_more_pads_cb (playbin->decodebin, playbin);
+      }
     }
   }