[vlc-devel] [RFC PATCHv2 17/18] es_out: use string id for "cat-track" options
Thomas Guillem
thomas at gllm.fr
Tue Feb 18 17:11:30 CET 2020
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.
---
src/input/es_out.c | 8 +++++---
src/input/var.c | 6 +++---
src/libvlc-module.c | 15 ++++++---------
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 3dafeb3bf4d..caafe641411 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -165,6 +165,7 @@ typedef struct
int i_id; /* es id as set by es fmt.id */
int i_demux_id; /* same as previous, demuxer set default value */
int i_channel; /* es number in creation order */
+ char *str_id; /* stream id to select */
char **ppsz_language;
} es_out_es_props_t;
@@ -439,6 +440,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++ )
@@ -460,7 +462,7 @@ static void EsOutPropsInit( es_out_es_props_t *p_props,
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->i_channel = (psz_trackvar) ? var_GetInteger( p_input, psz_trackvar ): -1;
+ p_props->str_id = psz_trackvar ? var_GetNonEmptyString( p_input, psz_trackvar ): NULL;
p_props->i_demux_id = -1;
p_props->p_main_es = NULL;
@@ -2497,9 +2499,9 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
wanted_es = es;
}
/* then per pos */
- else if( p_esprops->i_channel >= 0 )
+ else if( p_esprops->str_id )
{
- if( p_esprops->i_channel == es->i_channel )
+ if( strcmp( p_esprops->str_id, es->id.str_id ) == 0 )
wanted_es = es;
}
else if( p_esprops->ppsz_language )
diff --git a/src/input/var.c b/src/input/var.c
index 9f119a838d4..22d7ff24086 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -46,9 +46,9 @@ void input_ConfigVarInit ( input_thread_t *p_input )
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, "video-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
- var_Create( p_input, "audio-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
- var_Create( p_input, "sub-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+ var_Create( p_input, "video-track", VLC_VAR_STRING|VLC_VAR_DOINHERIT );
+ var_Create( p_input, "audio-track", VLC_VAR_STRING|VLC_VAR_DOINHERIT );
+ var_Create( p_input, "sub-track", VLC_VAR_STRING|VLC_VAR_DOINHERIT );
var_Create( p_input, "audio-language",
VLC_VAR_STRING|VLC_VAR_DOINHERIT );
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 86fc1b1f1ba..ff711c0ce9e 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -603,18 +603,15 @@ static const char *const ppsz_clock_descriptions[] =
/// \todo Document how to find it
#define INPUT_VIDEOTRACK_TEXT N_("Video track")
#define INPUT_VIDEOTRACK_LONGTEXT N_( \
- "Stream number of the video track to use " \
- "(from 0 to n).")
+ "Stream id of the video track to use.")
#define INPUT_AUDIOTRACK_TEXT N_("Audio track")
#define INPUT_AUDIOTRACK_LONGTEXT N_( \
- "Stream number of the audio track to use " \
- "(from 0 to n).")
+ "Stream id of the audio track to use.")
#define INPUT_SUBTRACK_TEXT N_("Subtitle track")
#define INPUT_SUBTRACK_LONGTEXT N_( \
- "Stream number of the subtitle track to use " \
- "(from 0 to n).")
+ "Stream id of the subtitle track to use.")
#define INPUT_AUDIOTRACK_LANG_TEXT N_("Audio language")
#define INPUT_AUDIOTRACK_LANG_LONGTEXT N_( \
@@ -1827,13 +1824,13 @@ vlc_module_begin ()
add_string( "programs", "",
INPUT_PROGRAMS_TEXT, INPUT_PROGRAMS_LONGTEXT, true )
change_safe ()
- add_integer( "video-track", -1,
+ add_string( "video-track", NULL,
INPUT_VIDEOTRACK_TEXT, INPUT_VIDEOTRACK_LONGTEXT, true )
change_safe ()
- add_integer( "audio-track", -1,
+ add_string( "audio-track", NULL,
INPUT_AUDIOTRACK_TEXT, INPUT_AUDIOTRACK_LONGTEXT, true )
change_safe ()
- add_integer( "sub-track", -1,
+ add_string( "sub-track", NULL,
INPUT_SUBTRACK_TEXT, INPUT_SUBTRACK_LONGTEXT, true )
change_safe ()
add_string( "audio-language", "",
--
2.20.1
More information about the vlc-devel
mailing list