[vlc-commits] player: implement vlc_player_SelectCategoryLanguage

Thomas Guillem git at videolan.org
Mon Jun 3 16:16:41 CEST 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jun  3 09:57:49 2019 +0200| [a2ea2da82d2d78b4d96de9d8649ec294fb4bd5a6] | committer: Thomas Guillem

player: implement vlc_player_SelectCategoryLanguage

It replaces vlc_player_SelectDefaultTrack that was unused and not implemented.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a2ea2da82d2d78b4d96de9d8649ec294fb4bd5a6
---

 include/vlc_player.h | 34 +++++++++++++---------------------
 src/input/player.c   | 18 +++++++++++++++---
 src/libvlccore.sym   |  2 +-
 3 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/include/vlc_player.h b/include/vlc_player.h
index 90b8683dbe..dbb905fe71 100644
--- a/include/vlc_player.h
+++ b/include/vlc_player.h
@@ -1838,44 +1838,36 @@ vlc_player_RestartTrackCategory(vlc_player_t *player,
 }
 
 /**
- * Select the default track for an ES category.
+ * Select the language for an ES category
  *
- * Tracks for this category will be automatically chosen according to the
- * language for all future played media.
+ * @warning The language will only be set for all future played media.
  *
  * @param player locked player instance
- * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
- * @param lang language (TODO: define it) or NULL to reset the default state
+ * @param cat AUDIO_ES or SPU_ES
+ * @param lang comma separated, two or three letters country code, 'any' as a
+ * fallback or NULL to reset the default state
  */
 VLC_API void
-vlc_player_SelectDefaultTrack(vlc_player_t *player,
-                              enum es_format_category_e cat, const char *lang);
-
-/**
- * Helper to select the default video track
- */
-static inline void
-vlc_player_SelectDefaultVideoTrack(vlc_player_t *player, const char *lang)
-{
-    vlc_player_SelectDefaultTrack(player, VIDEO_ES, lang);
-}
+vlc_player_SelectCategoryLanguage(vlc_player_t *player,
+                                  enum es_format_category_e cat,
+                                  const char *lang);
 
 /**
- * Helper to select the default audio track
+ * Helper to select the audio language
  */
 static inline void
-vlc_player_SelectDefaultAudioTrack(vlc_player_t *player, const char *lang)
+vlc_player_SelectAudioLanguage(vlc_player_t *player, const char *lang)
 {
-    vlc_player_SelectDefaultTrack(player, AUDIO_ES, lang);
+    vlc_player_SelectCategoryLanguage(player, AUDIO_ES, lang);
 }
 
 /**
- * Helper to select the default spu track
+ * Helper to select the spu language
  */
 static inline void
 vlc_player_SelectDefaultSubtitleTrack(vlc_player_t *player, const char *lang)
 {
-    vlc_player_SelectDefaultTrack(player, SPU_ES, lang);
+    vlc_player_SelectCategoryLanguage(player, SPU_ES, lang);
 }
 
 /**
diff --git a/src/input/player.c b/src/input/player.c
index d7d70f2ed6..da67e65ecc 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -1460,11 +1460,21 @@ vlc_player_RestartTrack(vlc_player_t *player, vlc_es_id_t *id)
 }
 
 void
-vlc_player_SelectDefaultTrack(vlc_player_t *player,
-                              enum es_format_category_e cat, const char *lang)
+vlc_player_SelectCategoryLanguage(vlc_player_t *player,
+                                  enum es_format_category_e cat,
+                                  const char *lang)
 {
     vlc_player_assert_locked(player);
-    /* TODO */ (void) cat; (void) lang;
+    switch (cat)
+    {
+        case AUDIO_ES:
+            var_SetString(player, "audio-language", lang);
+            break;
+        case SPU_ES:
+            var_SetString(player, "sub-language", lang);
+        default:
+            vlc_assert_unreachable();
+    }
 }
 
 static void
@@ -3609,6 +3619,8 @@ vlc_player_New(vlc_object_t *parent, enum vlc_player_lock_type lock_type,
     VAR_CREATE("sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
     VAR_CREATE("spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
     VAR_CREATE("sout-spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
+    VAR_CREATE("audio-language", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
+    VAR_CREATE("sub-language", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
 
     /* TODO: Override these variables since the player handle media ended
      * action itself. */
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index fa090406bf..baae814a1f 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -839,9 +839,9 @@ vlc_player_RestartTrack
 vlc_player_Resume
 vlc_player_SeekByPos
 vlc_player_SeekByTime
+vlc_player_SelectCategoryLanguage
 vlc_player_SelectChapter
 vlc_player_SelectChapterIdx
-vlc_player_SelectDefaultTrack
 vlc_player_SelectNextChapter
 vlc_player_SelectNextTitle
 vlc_player_SelectNextTrack



More information about the vlc-commits mailing list