diff --git a/ChangeLog b/ChangeLog index c6985228cf..5d950e94f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2007-12-20 Tim-Philipp Müller + + * ext/pango/gsttextoverlay.c: (gst_text_overlay_class_init): + * gst/playback/gstplaybasebin.c: (set_subtitles_visible), + (set_active_source): + * gst/playback/gstplaybasebin.h: + * gst/playback/gstplaybin.c: (gst_play_bin_class_init), + (setup_sinks), (playbin_set_subtitles_visible): + Make switching off of subtitles work. To avoid all kind of + problems with unlinking of the subtitle input, we just keep + the subtitle inputs linked as they are and tell textoverlay + not to render them. Fixes #373011. + Other subtitle switching issues (esp. when there are both + external and in-stream subtitles) remain. They'll be solved + in playbin2. + 2007-12-18 Wim Taymans * gst/playback/gststreamselector.c: (gst_selector_pad_init): diff --git a/ext/pango/gsttextoverlay.c b/ext/pango/gsttextoverlay.c index 804eeae8ec..934f2c78eb 100644 --- a/ext/pango/gsttextoverlay.c +++ b/ext/pango/gsttextoverlay.c @@ -400,6 +400,7 @@ gst_text_overlay_class_init (GstTextOverlayClass * klass) * * Since: 0.10.15 **/ + /* FIXME 0.11: rename to "visible" or "text-visible" or "render-text" */ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SILENT, g_param_spec_boolean ("silent", "silent", "Whether to render the text string", diff --git a/gst/playback/gstplaybasebin.c b/gst/playback/gstplaybasebin.c index 9e303011f3..150c0c4243 100644 --- a/gst/playback/gstplaybasebin.c +++ b/gst/playback/gstplaybasebin.c @@ -2380,6 +2380,17 @@ muted_group_change_state (GstElement * element, } #endif +static void +set_subtitles_visible (GstPlayBaseBin * play_base_bin, gboolean visible) +{ + GstPlayBaseBinClass *klass = GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin); + + /* we use a vfunc for this since we don't have a reference to the + * textoverlay element, but playbin does */ + if (klass != NULL && klass->set_subtitles_visible != NULL) + klass->set_subtitles_visible (play_base_bin, visible); +} + /* * Caller has group-lock held. */ @@ -2403,6 +2414,17 @@ set_active_source (GstPlayBaseBin * play_base_bin, return; } + /* HACK: instead of unlinking the subtitle input (= lots of hassle, + * especially if subtitles come from an external source), just tell + * textoverlay not to render them */ + if (type == GST_STREAM_TYPE_TEXT) { + gboolean visible = (source_num != -1); + + set_subtitles_visible (play_base_bin, visible); + if (!visible) + return; + } + sel = group->type[type - 1].selector; for (s = group->streaminfo; s; s = s->next) { diff --git a/gst/playback/gstplaybasebin.h b/gst/playback/gstplaybasebin.h index 1a5a864b0b..0767a9ac64 100644 --- a/gst/playback/gstplaybasebin.h +++ b/gst/playback/gstplaybasebin.h @@ -110,6 +110,9 @@ struct _GstPlayBaseBinClass { /* virtual fuctions */ gboolean (*setup_output_pads) (GstPlayBaseBin *play_base_bin, GstPlayBaseGroup *group); + + void (*set_subtitles_visible) (GstPlayBaseBin *play_base_bin, + gboolean visible); }; GType gst_play_base_bin_get_type (void); diff --git a/gst/playback/gstplaybin.c b/gst/playback/gstplaybin.c index e944309031..c5ddf00fed 100644 --- a/gst/playback/gstplaybin.c +++ b/gst/playback/gstplaybin.c @@ -324,6 +324,8 @@ static void gst_play_bin_dispose (GObject * object); static gboolean setup_sinks (GstPlayBaseBin * play_base_bin, GstPlayBaseGroup * group); static void remove_sinks (GstPlayBin * play_bin); +static void playbin_set_subtitles_visible (GstPlayBaseBin * play_base_bin, + gboolean visible); static void gst_play_bin_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec); @@ -428,6 +430,7 @@ gst_play_bin_class_init (GstPlayBinClass * klass) GST_DEBUG_FUNCPTR (gst_play_bin_handle_message); playbasebin_klass->setup_output_pads = setup_sinks; + playbasebin_klass->set_subtitles_visible = playbin_set_subtitles_visible; } static void @@ -1625,6 +1628,20 @@ setup_sinks (GstPlayBaseBin * play_base_bin, GstPlayBaseGroup * group) return res; } +static void +playbin_set_subtitles_visible (GstPlayBaseBin * play_base_bin, gboolean visible) +{ + GstPlayBin *playbin = GST_PLAY_BIN (play_base_bin); + + /* we're ignoring the case of someone setting the 'current-text' property + * before textoverlay is set up (which is probably okay, since playbasebin + * will just select the first subtitle stream as active stream regardless) */ + if (playbin->textoverlay_element != NULL) { + GST_LOG_OBJECT (playbin, "setting subtitle visibility to %d", visible); + g_object_set (playbin->textoverlay_element, "silent", !visible, NULL); + } +} + /* Send an event to our sinks until one of them works; don't then send to the * remaining sinks (unlike GstBin) */