vlc | branch: master | Thomas Guillem <[email protected]> | Thu Feb 20 15:28:16 2020 +0100| [6742a42e317685df9b068ffbf4c27cc03f0f6e41] | committer: Thomas Guillem
es_out: add a priv control to change cat ids This control can be used before any tracks are added. In that case, it will just behave like the "cat-track-id" option (future tracks will be selected according to this new str_ids). It will also update the new track list selection by selecting every tracks given by this list and unselecting all others. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6742a42e317685df9b068ffbf4c27cc03f0f6e41 --- src/input/es_out.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ src/input/es_out.h | 10 +++++++ src/input/es_out_timeshift.c | 1 + 3 files changed, 80 insertions(+) diff --git a/src/input/es_out.c b/src/input/es_out.c index d397f2ab33..a2f6b3e0d1 100644 --- a/src/input/es_out.c +++ b/src/input/es_out.c @@ -2585,6 +2585,59 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force ) p_esprops->p_main_es = es; } +static void EsOutSelectListFromProps( es_out_t *out, enum es_format_category_e cat ) +{ + es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out); + es_out_es_props_t *esprops = GetPropsByCat( p_sys, cat ); + if( !esprops || !esprops->str_ids ) + return; + + char *buffer = malloc( strlen( esprops->str_ids ) + 1); + if( !buffer ) + return; + + bool unselect_others = false; + es_out_id_t *other; + foreach_es_then_es_slaves( other ) + { + if( other->fmt.i_cat != cat ) + continue; + + bool select = false; + if( !unselect_others ) + { + /* strtok_r will modify str_ids */ + strcpy( buffer, esprops->str_ids ); + char *saveptr; + for( const char *str_id = strtok_r( buffer, ",", &saveptr ); + str_id != NULL; + str_id = strtok_r( NULL, ",", &saveptr ) ) + { + if( strcmp( other->id.str_id, str_id ) == 0 ) + { + select = true; + break; + } + } + } + + if( !select ) + { + if( EsIsSelected( other ) ) + EsOutUnselectEs( out, other, other->p_pgrm == p_sys->p_pgrm ); + } + else + { + if( !EsIsSelected( other ) ) + EsOutSelectEs( out, other ); + if( esprops->e_policy == ES_OUT_ES_POLICY_EXCLUSIVE ) + unselect_others = true; + } + } + + free( buffer ); +} + static void EsOutSelectList( es_out_t *out, enum es_format_category_e cat, vlc_es_id_t * const*es_id_list ) { @@ -3478,6 +3531,22 @@ static int EsOutVaPrivControlLocked( es_out_t *out, int query, va_list args ) } return EsOutControlLocked( out, p_sys->main_source, new_query, es ); } + case ES_OUT_PRIV_SET_ES_CAT_IDS: + { + enum es_format_category_e cat = va_arg( args, enum es_format_category_e ); + const char *str_ids = va_arg( args, const char * ); + es_out_es_props_t *p_esprops = GetPropsByCat( p_sys, cat ); + free( p_esprops->str_ids ); + p_esprops->str_ids = str_ids ? strdup( str_ids ) : NULL; + + if( p_esprops->str_ids ) + { + /* Update new tracks selection using the new str_ids */ + EsOutSelectListFromProps( out, cat ); + } + + return VLC_SUCCESS; + } case ES_OUT_PRIV_GET_WAKE_UP: { vlc_tick_t *pi_wakeup = va_arg( args, vlc_tick_t* ); diff --git a/src/input/es_out.h b/src/input/es_out.h index 53b9bb0afa..af3fff944d 100644 --- a/src/input/es_out.h +++ b/src/input/es_out.h @@ -60,6 +60,8 @@ enum es_out_query_private_e ES_OUT_PRIV_RESTART_ES_BY_ID, ES_OUT_PRIV_SET_ES_DEFAULT_BY_ID, + ES_OUT_PRIV_SET_ES_CAT_IDS, /* arg1=es_format_category_e arg2=const char *, res=cannot fail */ + /* Stop all selected ES and save the stopped state in a context. free the * context or call ES_OUT_PRIV_STOP_ALL_ES */ ES_OUT_PRIV_STOP_ALL_ES, /* arg1=void ** */ @@ -169,6 +171,14 @@ static inline int es_out_SetEsDefaultById( es_out_t *p_out, int id ) { return es_out_PrivControl( p_out, ES_OUT_PRIV_SET_ES_DEFAULT_BY_ID, id ); } +static inline void es_out_SetEsCatIds( es_out_t *p_out, + enum es_format_category_e cat, + const char *str_ids ) +{ + int ret = es_out_PrivControl( p_out, ES_OUT_PRIV_SET_ES_CAT_IDS, + cat, str_ids ); + assert( ret == VLC_SUCCESS ); +} static inline int es_out_StopAllEs( es_out_t *p_out, void **context ) { return es_out_PrivControl( p_out, ES_OUT_PRIV_STOP_ALL_ES, context ); diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c index 65c1526ee0..9a1ab29996 100644 --- a/src/input/es_out_timeshift.c +++ b/src/input/es_out_timeshift.c @@ -819,6 +819,7 @@ static int PrivControlLocked( es_out_t *p_out, int i_query, va_list args ) case ES_OUT_PRIV_SET_ES: case ES_OUT_PRIV_UNSET_ES: case ES_OUT_PRIV_RESTART_ES: + case ES_OUT_PRIV_SET_ES_CAT_IDS: case ES_OUT_PRIV_SET_ES_LIST: case ES_OUT_PRIV_SET_ES_BY_ID: case ES_OUT_PRIV_RESTART_ES_BY_ID: _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
