[vlc-commits] es_out: use string id for "cat-track-id" options

Thomas Guillem git at videolan.org
Fri Feb 28 20:46:31 CET 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Feb 19 10:36:36 2020 +0100| [8f762d125471a63ba8eafcef11e67bfcd9ed9a0d] | committer: Thomas Guillem

es_out: use string id for "cat-track-id" options

We can keep the same variable name since the integers can still be treated as a
string.

Using an integer on these reworked variables won't work to identify any track
and will cause VLC to disable the used category.

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

 src/input/es_out.c  | 9 +++++----
 src/input/var.c     | 6 +++---
 src/libvlc-module.c | 7 +++----
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/input/es_out.c b/src/input/es_out.c
index 1ca5f72e7f..9e53cd83ad 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -161,7 +161,7 @@ typedef struct
 
     /* Parameters used for es selection */
     bool        b_autoselect; /* if we want to select an es when no user prefs */
-    int         i_id;       /* es id as set by es fmt.id */
+    char        *str_id;       /* String id generated by EsOutCreateStrId() */
     int         i_demux_id; /* same as previous, demuxer set default value */
     int         i_channel;  /* es number in creation order */
     char        **ppsz_language;
@@ -438,6 +438,7 @@ static es_out_es_props_t * GetPropsByCat( es_out_sys_t *p_sys, int i_cat )
 
 static void EsOutPropsCleanup( es_out_es_props_t *p_props )
 {
+    free( p_props->str_id );
     if( p_props->ppsz_language )
     {
         for( int i = 0; p_props->ppsz_language[i]; i++ )
@@ -458,7 +459,7 @@ static void EsOutPropsInit( es_out_es_props_t *p_props,
     p_props->e_policy = e_default_policy;
     p_props->i_count = 0;
     p_props->b_autoselect = autoselect;
-    p_props->i_id = (psz_trackidvar) ? var_GetInteger( p_input, psz_trackidvar ): -1;
+    p_props->str_id = (psz_trackidvar) ? var_GetNonEmptyString( p_input, psz_trackidvar ): -1;
     p_props->i_channel = (psz_trackvar) ? var_GetInteger( p_input, psz_trackvar ): -1;
     p_props->i_demux_id = -1;
     p_props->p_main_es = NULL;
@@ -2479,9 +2480,9 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
             return;
 
         /* user designated by ID ES have higher prio than everything */
-        if ( p_esprops->i_id >= 0 )
+        if ( p_esprops->str_id )
         {
-            if( es->fmt.i_id == p_esprops->i_id )
+            if( strcmp( p_esprops->str_id, es->id.str_id ) == 0 )
                 wanted_es = es;
         }
         /* then per pos */
diff --git a/src/input/var.c b/src/input/var.c
index 9f119a838d..b5de58afb6 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -58,11 +58,11 @@ void input_ConfigVarInit ( input_thread_t *p_input )
                     VLC_VAR_STRING|VLC_VAR_DOINHERIT );
 
         var_Create( p_input, "video-track-id",
-                    VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+                    VLC_VAR_STRING|VLC_VAR_DOINHERIT );
         var_Create( p_input, "audio-track-id",
-                    VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+                    VLC_VAR_STRING|VLC_VAR_DOINHERIT );
         var_Create( p_input, "sub-track-id",
-                    VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+                    VLC_VAR_STRING|VLC_VAR_DOINHERIT );
 
         var_Create( p_input, "sub-file", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
         var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index d82ad097f3..1da7fa6e79 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -631,7 +631,6 @@ static const char *const ppsz_clock_descriptions[] =
     "Language of the menus you want to use with DVD/BluRay " \
     "(comma separated, two or three letters country code, you may use 'any' as a fallback).")
 
-/// \todo Document how to find it
 #define INPUT_VIDEOTRACK_ID_TEXT N_("Video track ID")
 #define INPUT_VIDEOTRACK_ID_LONGTEXT N_( \
     "Stream ID of the video track to use.")
@@ -1848,13 +1847,13 @@ vlc_module_begin ()
                  INPUT_MENUTRACK_LANG_TEXT, INPUT_MENUTRACK_LANG_LONGTEXT,
                   false )
         change_safe ()
-    add_integer( "video-track-id", -1, INPUT_VIDEOTRACK_ID_TEXT,
+    add_string( "video-track-id", NULL, INPUT_VIDEOTRACK_ID_TEXT,
                  INPUT_VIDEOTRACK_ID_LONGTEXT, true )
         change_safe ()
-    add_integer( "audio-track-id", -1, INPUT_AUDIOTRACK_ID_TEXT,
+    add_string( "audio-track-id", NULL, INPUT_AUDIOTRACK_ID_TEXT,
                  INPUT_AUDIOTRACK_ID_LONGTEXT, true )
         change_safe ()
-    add_integer( "sub-track-id", -1,
+    add_string( "sub-track-id", NULL,
                  INPUT_SUBTRACK_ID_TEXT, INPUT_SUBTRACK_ID_LONGTEXT, true )
         change_safe ()
     add_integer( "captions", 608,



More information about the vlc-commits mailing list