[vlc-devel] [PATCH 03/16] Add variable to enable/disable dual subtitles
Roland Bewick
roland.bewick at gmail.com
Tue May 21 20:08:27 CEST 2019
---
include/vlc_player.h | 33 +++++++++++++++++++++++
modules/gui/macosx/playlist/VLCPlayerController.m | 1 +
modules/gui/qt/components/player_controller.cpp | 1 +
src/input/player.c | 20 ++++++++++++++
src/input/var.c | 1 +
src/libvlccore.sym | 2 ++
6 files changed, 58 insertions(+)
diff --git a/include/vlc_player.h b/include/vlc_player.h
index f2df800797..aa0c736782 100644
--- a/include/vlc_player.h
+++ b/include/vlc_player.h
@@ -697,6 +697,18 @@ struct vlc_player_cbs
float subs_fps, void *data);
/**
+ * Called when dual subtitles enabled has changed
+ *
+ * @see vlc_player_SetDualSubtitlesEnabled()
+ *
+ * @param player locked player instance
+ * @param enabled true if dual subtitle selection is enabled
+ * @param data opaque pointer set by vlc_player_AddListener()
+ */
+ void (*on_dual_subtitles_enabled_changed)(vlc_player_t *player,
+ bool enabled, void *data);
+
+ /**
* Called when a new renderer item is set
*
* @see vlc_player_SetRenderer()
@@ -2286,6 +2298,27 @@ VLC_API float
vlc_player_GetAssociatedSubsFPS(vlc_player_t *player);
/**
+ * Enable or disable the abiltity to select multiple subtitle tracks.
+ *
+ * @note A successful call will trigger the
+ * vlc_player_cbs.on_dual_subtitles_enabled_changed event.
+ *
+ * @param player locked player instance
+ * @param enabled Enable dual subtitle track selection
+ */
+VLC_API void
+vlc_player_SetDualSubtitlesEnabled(vlc_player_t *player, bool enabled);
+
+/**
+ * Get whether dual subtitles are enabled or not
+ *
+ * @param player locked player instance
+ * @return enabled
+ */
+VLC_API bool
+vlc_player_AreDualSubtitlesEnabled(vlc_player_t *player);
+
+/**
* Set the renderer
*
* Valid for the current media and all future ones.
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m b/modules/gui/macosx/playlist/VLCPlayerController.m
index 463bee5946..d23770995f 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -462,6 +462,7 @@ static const struct vlc_player_cbs player_callbacks = {
cb_player_audio_delay_changed,
cb_player_subtitle_delay_changed,
cb_player_associated_subs_fps_changed,
+ NULL, //cb_player_dual_subtitles_enabled_changed
cb_player_renderer_changed,
cb_player_record_changed,
NULL, //cb_player_signal_changed,
diff --git a/modules/gui/qt/components/player_controller.cpp b/modules/gui/qt/components/player_controller.cpp
index e42f7b5b9d..994ba6dae4 100644
--- a/modules/gui/qt/components/player_controller.cpp
+++ b/modules/gui/qt/components/player_controller.cpp
@@ -818,6 +818,7 @@ static const struct vlc_player_cbs player_cbs = {
on_player_audio_delay_changed,
on_player_subtitle_delay_changed,
on_player_associated_subs_fps_changed,
+ NULL, //on_player_dual_subtitles_enabled_changed,
on_player_renderer_changed,
on_player_record_changed,
on_player_signal_changed,
diff --git a/src/input/player.c b/src/input/player.c
index 551b9928f1..66842997ac 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -2241,6 +2241,26 @@ vlc_player_GetAssociatedSubsFPS(vlc_player_t *player)
}
void
+vlc_player_SetDualSubtitlesEnabled(vlc_player_t *player, bool enabled)
+{
+ struct vlc_player_input *input = vlc_player_get_input_locked(player);
+ if (input)
+ {
+ var_SetBool(input->thread, "multiple-spus", enabled);
+ vlc_player_SendEvent(player, on_dual_subtitles_enabled_changed, enabled);
+ vlc_player_vout_OSDMessage(player, _("Dual subtitles %s"),
+ enabled ? _("enabled") : _("disabled"));
+ }
+}
+
+bool
+vlc_player_AreDualSubtitlesEnabled(vlc_player_t *player)
+{
+ struct vlc_player_input *input = vlc_player_get_input_locked(player);
+ return input && var_GetBool(input->thread, "multiple-spus");
+}
+
+void
vlc_player_InvalidateNextMedia(vlc_player_t *player)
{
vlc_player_assert_locked(player);
diff --git a/src/input/var.c b/src/input/var.c
index 7822d66003..9110624eab 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -726,6 +726,7 @@ void input_ConfigVarInit ( input_thread_t *p_input )
var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_input, "spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+ var_Create( p_input, "multiple-spus", VLC_VAR_BOOL);
var_Create( p_input, "video-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Create( p_input, "audio-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 03a503e1ea..887d45301e 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -868,6 +868,8 @@ vlc_player_SetStartPaused
vlc_player_SetSubtitleDelay
vlc_player_SetSubtitleSync
vlc_player_SetSubtitleTextScale
+vlc_player_SetDualSubtitlesEnabled
+vlc_player_AreDualSubtitlesEnabled
vlc_player_SetTeletextEnabled
vlc_player_SetTeletextTransparency
vlc_player_SetTrackCategoryEnabled
--
2.11.0
More information about the vlc-devel
mailing list