[vlc-commits] es_out: allow multi selection from "cat-track-id"
Thomas Guillem
git at videolan.org
Fri Feb 28 20:46:35 CET 2020
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Feb 20 13:10:12 2020 +0100| [af4ae13cd8edda2118e0c3756b42e39575e70861] | committer: Thomas Guillem
es_out: allow multi selection from "cat-track-id"
Example: --sub-track-id "spu/3,spu/4"
A track-id can't contain the ',' character.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=af4ae13cd8edda2118e0c3756b42e39575e70861
---
src/input/es_out.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/src/input/es_out.c b/src/input/es_out.c
index d12e71df2f..d397f2ab33 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 */
- char *str_id; /* String id generated by EsOutCreateStrId() */
+ char *str_ids; /* List of string id generated by EsOutCreateStrId() (delimited by ',') */
int i_demux_id; /* same as previous, demuxer set default value */
int i_channel; /* es number in creation order */
char **ppsz_language;
@@ -438,7 +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 );
+ free( p_props->str_ids );
if( p_props->ppsz_language )
{
for( int i = 0; p_props->ppsz_language[i]; i++ )
@@ -459,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->str_id = (psz_trackidvar) ? var_GetNonEmptyString( p_input, psz_trackidvar ): -1;
+ p_props->str_ids = (psz_trackidvar) ? var_GetNonEmptyString( p_input, psz_trackidvar ) : NULL;
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;
@@ -1953,6 +1953,9 @@ static char *EsOutCreateStrId( es_out_id_t *es, bool stable, const char *id,
}
else if ( id )
{
+ /* ',' is used as a delimiter */
+ assert( strchr( id, ',' ) == NULL);
+
vlc_memstream_puts( &ms, id );
vlc_memstream_putc( &ms, '/' );
}
@@ -2437,8 +2440,17 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
return;
}
+ enum es_out_policy_e policy = p_esprops->e_policy;
+ if( policy == ES_OUT_ES_POLICY_AUTO )
+ {
+ if( p_esprops->str_ids && strchr( p_esprops->str_ids, ',' ) != NULL )
+ policy = ES_OUT_ES_POLICY_SIMULTANEOUS;
+ else
+ policy = ES_OUT_ES_POLICY_EXCLUSIVE;
+ }
+
bool b_auto_unselect = p_esprops && p_sys->i_mode == ES_OUT_MODE_AUTO &&
- p_esprops->e_policy == ES_OUT_ES_POLICY_EXCLUSIVE &&
+ policy == ES_OUT_ES_POLICY_EXCLUSIVE &&
p_esprops->p_main_es && p_esprops->p_main_es != es;
if( p_sys->i_mode == ES_OUT_MODE_ALL || b_force )
@@ -2480,10 +2492,20 @@ 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->str_id )
+ if ( p_esprops->str_ids )
{
- if( strcmp( p_esprops->str_id, es->id.str_id ) == 0 )
- wanted_es = es;
+ char *saveptr, *str_ids = strdup( p_esprops->str_ids );
+ if( str_ids )
+ {
+ for( const char *str_id = strtok_r( str_ids, ",", &saveptr );
+ str_id != NULL && wanted_es != es;
+ str_id = strtok_r( NULL, ",", &saveptr ) )
+ {
+ if( strcmp( str_id, es->id.str_id ) == 0 )
+ wanted_es = es;
+ }
+ }
+ free( str_ids );
}
/* then per pos */
else if( p_esprops->i_channel >= 0 )
More information about the vlc-commits
mailing list