[vlc-devel] [PATCH] libvlc: add a SubtitlesChanged event

Jean-Baptiste Kempf jb at videolan.org
Sun Oct 21 18:31:02 CEST 2012


Why this over a ESChanged event?

On 21 Oct, Edward Wang wrote :
> ---
>  include/vlc/libvlc_events.h |    1 +
>  include/vlc_input.h         |    2 ++
>  lib/event.c                 |    1 +
>  lib/media_player.c          |    5 +++++
>  src/input/event.c           |   10 ++++++++--
>  5 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
> index 2cfedbf..626936f 100644
> --- a/include/vlc/libvlc_events.h
> +++ b/include/vlc/libvlc_events.h
> @@ -72,6 +72,7 @@ enum libvlc_event_e {
>      libvlc_MediaPlayerSnapshotTaken,
>      libvlc_MediaPlayerLengthChanged,
>      libvlc_MediaPlayerVout,
> +    libvlc_MediaPlayerSubtitlesChanged,
>  
>      libvlc_MediaListItemAdded=0x200,
>      libvlc_MediaListWillAddItem,
> diff --git a/include/vlc_input.h b/include/vlc_input.h
> index 7d8320a..3723603 100644
> --- a/include/vlc_input.h
> +++ b/include/vlc_input.h
> @@ -403,6 +403,8 @@ typedef enum input_event_type_e
>      INPUT_EVENT_ES,
>      /* "teletext-es" has changed */
>      INPUT_EVENT_TELETEXT,
> +    /* A subtitle ES has been added or removed */
> +    INPUT_EVENT_SUBTITLE,
>  
>      /* "record" has changed */
>      INPUT_EVENT_RECORD,
> diff --git a/lib/event.c b/lib/event.c
> index c71a48a..d0f4565 100644
> --- a/lib/event.c
> +++ b/lib/event.c
> @@ -279,6 +279,7 @@ static const event_name_t event_list[] = {
>      DEF(MediaPlayerSnapshotTaken)
>      DEF(MediaPlayerLengthChanged)
>      DEF(MediaPlayerVout)
> +    DEF(MediaPlayerSubtitlesChanged)
>  
>      DEF(MediaListItemAdded)
>      DEF(MediaListWillAddItem)
> diff --git a/lib/media_player.c b/lib/media_player.c
> index a41b8c7..0aa695b 100644
> --- a/lib/media_player.c
> +++ b/lib/media_player.c
> @@ -334,6 +334,10 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
>          event.u.media_player_vout.new_count = i_vout;
>          libvlc_event_send( p_mi->p_event_manager, &event );
>      }
> +    else if( newval.i_int == INPUT_EVENT_SUBTITLE ) {
> +        event.type = libvlc_MediaPlayerSubtitlesChanged;
> +        libvlc_event_send( p_mi->p_event_manager, &event );
> +    }
>  
>      return VLC_SUCCESS;
>  }
> @@ -516,6 +520,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
>      register_event(mp, PausableChanged);
>  
>      register_event(mp, Vout);
> +    register_event(mp, SubtitlesChanged);
>  
>      /* Snapshot initialization */
>      register_event(mp, SnapshotTaken);
> diff --git a/src/input/event.c b/src/input/event.c
> index 453e04b..424c423 100644
> --- a/src/input/event.c
> +++ b/src/input/event.c
> @@ -277,14 +277,20 @@ static const char *GetEsVarName( int i_cat )
>  }
>  void input_SendEventEsAdd( input_thread_t *p_input, int i_cat, int i_id, const char *psz_text )
>  {
> -    if( i_cat != UNKNOWN_ES )
> +    if( i_cat != UNKNOWN_ES ) {
>          VarListAdd( p_input, GetEsVarName( i_cat ), INPUT_EVENT_ES,
>                      i_id, psz_text );
> +        if( i_cat == SPU_ES )
> +            Trigger( p_input, INPUT_EVENT_SUBTITLE );
> +    }
>  }
>  void input_SendEventEsDel( input_thread_t *p_input, int i_cat, int i_id )
>  {
> -    if( i_cat != UNKNOWN_ES )
> +    if( i_cat != UNKNOWN_ES ) {
>          VarListDel( p_input, GetEsVarName( i_cat ), INPUT_EVENT_ES, i_id );
> +        if( i_cat == SPU_ES )
> +            Trigger( p_input, INPUT_EVENT_SUBTITLE );
> +    }
>  }
>  /* i_id == -1 will unselect */
>  void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id )
> -- 
> 1.7.5.4
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel

-- 
Best regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device



More information about the vlc-devel mailing list