playbin3: Inform (uri)decodebin3 of the subtitle caps from playsink
authorEdward Hervey <edward@centricular.com>
Tue, 20 Feb 2024 15:04:09 +0000 (16:04 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 22 Feb 2024 14:39:54 +0000 (14:39 +0000)
Subtitles are better handled by overlayers/renderers within playsink. By
informing (uri)decodebin3 of the formats that can be handled we can avoid those
being "decoded" too early.

Fixes #1081

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6153>

subprojects/gst-plugins-base/gst/playback/gstplaybin3.c

index 51cf97b8a154b571b2bc46a1579efcec5b24edce..047f558954cedfa3a733e0ef39914673cc40fa39 100644 (file)
@@ -1058,6 +1058,8 @@ colorbalance_value_changed_cb (GstColorBalance * balance,
 static void
 gst_play_bin3_init (GstPlayBin3 * playbin)
 {
+  GstCaps *uridecodebin_caps, *subtitle_caps;
+
   g_rec_mutex_init (&playbin->lock);
 
   /* assume we can create an input-selector */
@@ -1073,6 +1075,14 @@ gst_play_bin3_init (GstPlayBin3 * playbin)
   gst_bin_add (GST_BIN_CAST (playbin),
       GST_ELEMENT_CAST (playbin->uridecodebin));
 
+  /* Make sure uridecodebin3 knows of all the subtitle formats that playsink can
+   * handle as-is */
+  subtitle_caps = gst_subtitle_overlay_create_factory_caps ();
+  g_object_get (playbin->uridecodebin, "caps", &uridecodebin_caps, NULL);
+  uridecodebin_caps = gst_caps_merge (uridecodebin_caps, subtitle_caps);
+  g_object_set (playbin->uridecodebin, "caps", uridecodebin_caps, NULL);
+  gst_caps_unref (uridecodebin_caps);
+
   g_signal_connect (playbin->uridecodebin, "pad-added",
       G_CALLBACK (pad_added_cb), playbin);
   g_signal_connect (playbin->uridecodebin, "pad-removed",