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
This commit is contained in:
Wim Taymans 2009-03-23 17:37:48 +01:00
parent 20d0351b76
commit 7628319688

View file

@ -1434,7 +1434,7 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
add_chain (GST_PLAY_CHAIN (playsink->videochain), TRUE); add_chain (GST_PLAY_CHAIN (playsink->videochain), TRUE);
activate_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 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_DEBUG_OBJECT (playsink, "ghosting video sinkpad");
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad), gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad),
playsink->videochain->sinkpad); playsink->videochain->sinkpad);
@ -1458,8 +1458,8 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
playsink->audio_tee_vissrc = NULL; playsink->audio_tee_vissrc = NULL;
} }
srcpad = srcpad =
gst_element_get_static_pad (GST_ELEMENT_CAST (playsink-> gst_element_get_static_pad (GST_ELEMENT_CAST (playsink->vischain->
vischain->chain.bin), "src"); chain.bin), "src");
gst_pad_unlink (srcpad, playsink->videochain->sinkpad); gst_pad_unlink (srcpad, playsink->videochain->sinkpad);
} }
add_chain (GST_PLAY_CHAIN (playsink->videochain), FALSE); add_chain (GST_PLAY_CHAIN (playsink->videochain), FALSE);
@ -1484,14 +1484,24 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
playsink->textchain->videosinkpad); playsink->textchain->videosinkpad);
gst_pad_link (playsink->textchain->srcpad, playsink->videochain->sinkpad); gst_pad_link (playsink->textchain->srcpad, playsink->videochain->sinkpad);
activate_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE); activate_chain (GST_PLAY_CHAIN (playsink->textchain), TRUE);
if (playsink->textchain->overlay)
g_object_set (playsink->textchain->overlay, "silent", FALSE, NULL);
} }
} else { } else {
GST_DEBUG_OBJECT (playsink, "no text needed"); GST_DEBUG_OBJECT (playsink, "no text needed");
/* we have no subtitles/text or we are requested to not show them */ /* we have no subtitles/text or we are requested to not show them */
if (playsink->textchain) { if (playsink->textchain) {
if (playsink->text_pad == NULL) {
/* no text pad, remove the chain entirely */
GST_DEBUG_OBJECT (playsink, "removing text chain"); GST_DEBUG_OBJECT (playsink, "removing text chain");
add_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE); add_chain (GST_PLAY_CHAIN (playsink->textchain), FALSE);
activate_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) if (!need_video && playsink->video_pad)
gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (playsink->video_pad), NULL); 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) { if (playsink->vischain) {
GST_DEBUG_OBJECT (playsink, "setting up vis chain"); GST_DEBUG_OBJECT (playsink, "setting up vis chain");
srcpad = srcpad =
gst_element_get_static_pad (GST_ELEMENT_CAST (playsink-> gst_element_get_static_pad (GST_ELEMENT_CAST (playsink->vischain->
vischain->chain.bin), "src"); chain.bin), "src");
add_chain (GST_PLAY_CHAIN (playsink->vischain), TRUE); add_chain (GST_PLAY_CHAIN (playsink->vischain), TRUE);
activate_chain (GST_PLAY_CHAIN (playsink->vischain), TRUE); activate_chain (GST_PLAY_CHAIN (playsink->vischain), TRUE);
if (playsink->audio_tee_vissrc == NULL) { if (playsink->audio_tee_vissrc == NULL) {