[gst-cvs] gst-plugins-base: playbin2: allow dynamic swtiching of subtitles

Wim Taymans wtay at kemper.freedesktop.org
Mon Mar 23 09:38:57 PDT 2009


Module: gst-plugins-base
Branch: master
Commit: 7628319688e0fc931d177114c477629bc8ff913c
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=7628319688e0fc931d177114c477629bc8ff913c

Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Mon Mar 23 17:37:48 2009 +0100

playbin2: allow dynamic swtiching of subtitles

When we have the textpad configured, enable and disable the subtitles by setting
the silent flag on the overlay element instead of trying to remove elements.
See #576187

---

 gst/playback/gstplaysink.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/gst/playback/gstplaysink.c b/gst/playback/gstplaysink.c
index cbd42c5..6f4365e 100644
--- a/gst/playback/gstplaysink.c
+++ b/gst/playback/gstplaysink.c
@@ -1434,7 +1434,7 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
       add_chain (GST_PLAY_CHAIN (playsink->videochain), TRUE);
       activate_chain (GST_PLAY_CHAIN (playsink->videochain), TRUE);
       /* if we are not part of vis or subtitles, set the ghostpad target */
-      if (!need_vis && !need_text) {
+      if (!need_vis && !need_text && playsink->text_pad == NULL) {
         GST_DEBUG_OBJECT (playsink, "ghosting video sinkpad");
         gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad),
             playsink->videochain->sinkpad);
@@ -1458,8 +1458,8 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
           playsink->audio_tee_vissrc = NULL;
         }
         srcpad =
-            gst_element_get_static_pad (GST_ELEMENT_CAST (playsink->
-                vischain->chain.bin), "src");
+            gst_element_get_static_pad (GST_ELEMENT_CAST (playsink->vischain->
+                chain.bin), "src");
         gst_pad_unlink (srcpad, playsink->videochain->sinkpad);
       }
       add_chain (GST_PLAY_CHAIN (playsink->videochain), FALSE);
@@ -1484,14 +1484,24 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
           playsink->textchain->videosinkpad);
       gst_pad_link (playsink->textchain->srcpad, playsink->videochain->sinkpad);
       activate_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE);
+      if (playsink->textchain->overlay)
+        g_object_set (playsink->textchain->overlay, "silent", FALSE, NULL);
     }
   } else {
     GST_DEBUG_OBJECT (playsink, "no text needed");
     /* we have no subtitles/text or we are requested to not show them */
     if (playsink->textchain) {
-      GST_DEBUG_OBJECT (playsink, "removing text chain");
-      add_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
-      activate_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
+      if (playsink->text_pad == NULL) {
+        /* no text pad, remove the chain entirely */
+        GST_DEBUG_OBJECT (playsink, "removing text chain");
+        add_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
+        activate_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
+      } else {
+        /* we have a chain and a textpad, turn the subtitles off */
+        GST_DEBUG_OBJECT (playsink, "turning off the text");
+        if (playsink->textchain->overlay)
+          g_object_set (playsink->textchain->overlay, "silent", TRUE, NULL);
+      }
     }
     if (!need_video && playsink->video_pad)
       gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad), NULL);
@@ -1581,8 +1591,8 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
     if (playsink->vischain) {
       GST_DEBUG_OBJECT (playsink, "setting up vis chain");
       srcpad =
-          gst_element_get_static_pad (GST_ELEMENT_CAST (playsink->
-              vischain->chain.bin), "src");
+          gst_element_get_static_pad (GST_ELEMENT_CAST (playsink->vischain->
+              chain.bin), "src");
       add_chain (GST_PLAY_CHAIN (playsink->vischain), TRUE);
       activate_chain (GST_PLAY_CHAIN (playsink->vischain), TRUE);
       if (playsink->audio_tee_vissrc == NULL) {





More information about the Gstreamer-commits mailing list