[vlc-devel] [PATCH 06/14] es_out: add a control to change cat ids

Thomas Guillem thomas at gllm.fr
Mon Feb 24 10:20:20 CET 2020



On Sat, Feb 22, 2020, at 08:49, Rémi Denis-Courmont wrote:
> Le perjantaina 21. helmikuuta 2020, 17.59.37 EET Thomas Guillem a écrit :
> > 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.
> > ---
> >  src/input/es_out.c           | 70 ++++++++++++++++++++++++++++++++++++
> 
> The file is really too big now.

How would you split it ?

> 
> >  src/input/es_out.h           |  2 ++
> >  src/input/es_out_timeshift.c |  1 +
> >  3 files changed, 73 insertions(+)
> > 
> > diff --git a/src/input/es_out.c b/src/input/es_out.c
> > index b645dc21e7a..b168d4991ae 100644
> > --- a/src/input/es_out.c
> > +++ b/src/input/es_out.c
> > @@ -2597,6 +2597,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 )
> >  {
> > @@ -2981,6 +3034,23 @@ static int EsOutVaControlLocked( es_out_t *out,
> > es_out_ctx_t *ctx, return VLC_SUCCESS;
> >      }
> > 
> > +    case ES_OUT_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_GET_GROUP_FORCED:
> >      {
> >          int *pi_group = va_arg( args, int * );
> > diff --git a/src/input/es_out.h b/src/input/es_out.h
> > index 5d4b4e05b33..6321099ce5b 100644
> > --- a/src/input/es_out.h
> > +++ b/src/input/es_out.h
> > @@ -48,6 +48,8 @@ enum es_out_query_private_e
> >      ES_OUT_RESTART_ES_BY_ID,
> >      ES_OUT_SET_ES_DEFAULT_BY_ID,
> > 
> > +    ES_OUT_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_STOP_ALL_ES */
> >      ES_OUT_STOP_ALL_ES,                             /* arg1=void ** */
> 
> And while it's a preexisting condition, mixing up input/player and demux 
> controls seems just wrong.

input/player controls are hidden from the demux.
But yes, it's not ideal.

> 
> > diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
> > index a3fd11eb680..2fa842f5b18 100644
> > --- a/src/input/es_out_timeshift.c
> > +++ b/src/input/es_out_timeshift.c
> > @@ -773,6 +773,7 @@ static int ControlLocked( es_out_t *p_out, es_out_ctx_t
> > *p_ctx, int i_query, case ES_OUT_SET_RECORD_STATE:
> >      case ES_OUT_SET_VBI_PAGE:
> >      case ES_OUT_SET_VBI_TRANSPARENCY:
> > +    case ES_OUT_SET_ES_CAT_IDS:
> >      default:
> >          vlc_assert_unreachable();
> >          return VLC_EGENERIC;
> 
> 
> -- 
> Rémi Denis-Courmont
> http://www.remlab.net/
> 
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list