[vlc-devel] [vlc-commits] input: add infos controls

Thomas Guillem thomas at gllm.fr
Wed Sep 5 09:11:48 CEST 2018


humm sorry, I meant *Hide* info controls.

On Tue, Sep 4, 2018, at 18:06, Thomas Guillem wrote:
> vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Sep  4 
> 18:02:47 2018 +0200| [337886df92c0fdc91819644c57e0773f3dfe2005] | 
> committer: Thomas Guillem
> 
> input: add infos controls
> 
> Since they are only used by es_out.c. Little behavior change: the info event is
> now sent only one time for several info changes.
> 
> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=337886df92c0fdc91819644c57e0773f3dfe2005
> ---
> 
>  include/vlc_input.h |  6 ------
>  src/input/control.c | 44 --------------------------------------------
>  src/input/es_out.c  | 52 ++++++++++++++++++++++++++++++++++++----------------
>  3 files changed, 36 insertions(+), 66 deletions(-)
> 
> diff --git a/include/vlc_input.h b/include/vlc_input.h
> index fddede9fc5..6b50929290 100644
> --- a/include/vlc_input.h
> +++ b/include/vlc_input.h
> @@ -514,12 +514,6 @@ enum input_query_e
>      /** Activate disc Root Menu. res=can fail */
>      INPUT_NAV_MENU,
>  
> -    /* Meta datas */
> -    INPUT_ADD_INFO,   /* arg1= char* arg2= char* arg3=...     res=can 
> fail */
> -    INPUT_REPLACE_INFOS,/* arg1= info_category_t *            
> res=cannot fail */
> -    INPUT_MERGE_INFOS,/* arg1= info_category_t *              
> res=cannot fail */
> -    INPUT_DEL_INFO,   /* arg1= char* arg2= char*              res=can 
> fail */
> -
>      /* bookmarks */
>      INPUT_GET_BOOKMARK,    /* arg1= seekpoint_t *               res=can 
> fail */
>      INPUT_GET_BOOKMARKS,   /* arg1= seekpoint_t *** arg2= int * res=can 
> fail */
> diff --git a/src/input/control.c b/src/input/control.c
> index 77da975d36..dc7b7c6c15 100644
> --- a/src/input/control.c
> +++ b/src/input/control.c
> @@ -82,50 +82,6 @@ int input_vaControl( input_thread_t *p_input, int 
> i_query, va_list args )
>                                 + INPUT_CONTROL_NAV_ACTIVATE, NULL );
>              return VLC_SUCCESS;
>  
> -        case INPUT_ADD_INFO:
> -        {
> -            char *psz_cat = va_arg( args, char * );
> -            char *psz_name = va_arg( args, char * );
> -            char *psz_format = va_arg( args, char * );
> -
> -            char *psz_value;
> -
> -            if( vasprintf( &psz_value, psz_format, args ) == -1 )
> -                return VLC_EGENERIC;
> -
> -            int i_ret = input_item_AddInfo( priv->p_item, psz_cat, 
> psz_name,
> -                                            "%s", psz_value );
> -            free( psz_value );
> -
> -            if( !priv->b_preparsing && !i_ret )
> -                input_SendEventMetaInfo( p_input );
> -            return i_ret;
> -        }
> -        case INPUT_REPLACE_INFOS:
> -        case INPUT_MERGE_INFOS:
> -        {
> -            info_category_t *p_cat = va_arg( args, info_category_t * );
> -
> -            if( i_query == INPUT_REPLACE_INFOS )
> -                input_item_ReplaceInfos( priv->p_item, p_cat );
> -            else
> -                input_item_MergeInfos( priv->p_item, p_cat );
> -
> -            if( !priv->b_preparsing )
> -                input_SendEventMetaInfo( p_input );
> -            return VLC_SUCCESS;
> -        }
> -        case INPUT_DEL_INFO:
> -        {
> -            char *psz_cat = va_arg( args, char * );
> -            char *psz_name = va_arg( args, char * );
> -
> -            int i_ret = input_item_DelInfo( priv->p_item, psz_cat, 
> psz_name );
> -
> -            if( !priv->b_preparsing && !i_ret )
> -                input_SendEventMetaInfo( p_input );
> -            return i_ret;
> -        }
>          case INPUT_ADD_BOOKMARK:
>              p_bkmk = va_arg( args, seekpoint_t * );
>              p_bkmk = vlc_seekpoint_Duplicate( p_bkmk );
> diff --git a/src/input/es_out.c b/src/input/es_out.c
> index 7965836512..45cea092b1 100644
> --- a/src/input/es_out.c
> +++ b/src/input/es_out.c
> @@ -1243,9 +1243,11 @@ static void EsOutProgramMeta( es_out_t *out, int 
> i_group, const vlc_meta_t *p_me
>      es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
>      es_out_pgrm_t     *p_pgrm;
>      input_thread_t    *p_input = p_sys->p_input;
> +    input_item_t      *p_item = input_priv(p_input)->p_item;
>      const char        *psz_title = NULL;
>      const char        *psz_provider = NULL;
>      int i;
> +    bool               b_has_new_infos = false;
>  
>      msg_Dbg( p_input, "EsOutProgramMeta: number=%d", i_group );
>  
> @@ -1280,7 +1282,9 @@ static void EsOutProgramMeta( es_out_t *out, int 
> i_group, const vlc_meta_t *p_me
>          {
>              /* Remove old entries */
>              char *psz_oldinfokey = EsOutProgramGetMetaName( p_pgrm );
> -            input_Control( p_input, INPUT_DEL_INFO, psz_oldinfokey, 
> NULL );
> +
> +            if( !input_item_DelInfo( p_item, psz_oldinfokey, NULL ) )
> +                b_has_new_infos = true;
>              /* TODO update epg name ?
>               * TODO update scrambled info name ? */
>              free( psz_oldinfokey );
> @@ -1357,7 +1361,12 @@ static void EsOutProgramMeta( es_out_t *out, int 
> i_group, const vlc_meta_t *p_me
>                                     "%s",psz_provider );
>      }
>      if( p_cat )
> -        input_Control( p_input, INPUT_MERGE_INFOS, p_cat );
> +    {
> +        input_item_MergeInfos( p_item, p_cat );
> +        b_has_new_infos = true;
> +    }
> +    if( !input_priv(p_input)->b_preparsing && b_has_new_infos )
> +        input_SendEventMetaInfo( p_input );
>  }
>  
>  static void EsOutProgramEpgEvent( es_out_t *out, int i_group, const 
> vlc_epg_event_t *p_event )
> @@ -1440,16 +1449,17 @@ static void EsOutProgramEpg( es_out_t *out, int 
> i_group, const vlc_epg_t *p_epg
>          input_item_SetESNowPlaying( input_priv(p_input)->p_item, 
> psz_nowplaying );
>          input_SendEventMeta( p_input );
>  
> +        const char *now_playing_tr =
> +            vlc_meta_TypeToLocalizedString(vlc_meta_ESNowPlaying);
> +        int ret;
>          if( psz_nowplaying )
> -        {
> -            input_Control( p_input, INPUT_ADD_INFO, psz_cat,
> -                vlc_meta_TypeToLocalizedString(vlc_meta_ESNowPlaying), 
> "%s", psz_nowplaying );
> -        }
> +            ret = input_item_AddInfo( p_item, psz_cat, now_playing_tr,
> +                                      "%s", psz_nowplaying );
>          else
> -        {
> -            input_Control( p_input, INPUT_DEL_INFO, psz_cat,
> -                
> vlc_meta_TypeToLocalizedString(vlc_meta_ESNowPlaying) );
> -        }
> +            ret = input_item_DelInfo( p_item, psz_cat, 
> now_playing_tr );
> +
> +        if( ret == VLC_SUCCESS && !input_priv(p_input)->b_preparsing  )
> +            input_SendEventMetaInfo( p_input );
>      }
>  
>      free( psz_cat );
> @@ -1468,6 +1478,7 @@ static void EsOutProgramUpdateScrambled( es_out_t 
> *p_out, es_out_pgrm_t *p_pgrm
>  {
>      es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
>      input_thread_t  *p_input = p_sys->p_input;
> +    input_item_t    *p_item = input_priv(p_input)->p_item;
>      es_out_id_t *es;
>      bool b_scrambled = false;
>  
> @@ -1484,12 +1495,15 @@ static void 
> EsOutProgramUpdateScrambled( es_out_t *p_out, es_out_pgrm_t *p_pgrm
>      p_pgrm->b_scrambled = b_scrambled;
>      char *psz_cat = EsOutProgramGetMetaName( p_pgrm );
>  
> +    int ret;
>      if( b_scrambled )
> -        input_Control( p_input, INPUT_ADD_INFO, psz_cat, 
> _("Scrambled"), _("Yes") );
> +        ret = input_item_AddInfo( p_item, psz_cat, _("Scrambled"), 
> _("Yes") );
>      else
> -        input_Control( p_input, INPUT_DEL_INFO, psz_cat, 
> _("Scrambled") );
> +        ret = input_item_DelInfo( p_item, psz_cat, _("Scrambled") );
>      free( psz_cat );
>  
> +    if( ret == VLC_SUCCESS && !input_priv(p_input)->b_preparsing  )
> +        input_SendEventMetaInfo( p_input );
>      input_SendEventProgramScrambled( p_input, p_pgrm->i_id, b_scrambled );
>  }
>  
> @@ -3241,6 +3255,7 @@ static void EsOutUpdateInfo( es_out_t *out, 
> es_out_id_t *es, const vlc_meta_t *p
>  {
>      es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
>      input_thread_t *p_input = p_sys->p_input;
> +    input_item_t   *p_item = input_priv(p_input)->p_item;
>      const es_format_t *p_fmt_es = &es->fmt;
>      const es_format_t *fmt = es->fmt_out.i_cat != UNKNOWN_ES ? &es-
> >fmt_out : &es->fmt;
>  
> @@ -3559,20 +3574,25 @@ static void EsOutUpdateInfo( es_out_t *out, 
> es_out_id_t *es, const vlc_meta_t *p
>          free( ppsz_all_keys );
>      }
>      /* */
> -    input_Control( p_input, INPUT_REPLACE_INFOS, p_cat );
> +    input_item_ReplaceInfos( p_item, p_cat );
> +    if( !input_priv(p_input)->b_preparsing  )
> +        input_SendEventMetaInfo( p_input );
>  }
>  
>  static void EsOutDeleteInfoEs( es_out_t *out, es_out_id_t *es )
>  {
>      es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
> +    input_thread_t *p_input = p_sys->p_input;
> +    input_item_t   *p_item = input_priv(p_input)->p_item;
>      char* psz_info_category;
>  
>      if( likely( psz_info_category = EsInfoCategoryName( es ) ) )
>      {
> -        input_Control( p_sys->p_input, INPUT_DEL_INFO,
> -          psz_info_category, NULL );
> -
> +        int ret = input_item_DelInfo( p_item, psz_info_category, NULL );
>          free( psz_info_category );
> +
> +        if( ret == VLC_SUCCESS && !input_priv(p_input)->b_preparsing  )
> +            input_SendEventMetaInfo( p_input );
>      }
>  }
>  
> 
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits


More information about the vlc-devel mailing list