[vlc-devel] [PATCH] libvlc: add API to control display of the video title.

Rémi Denis-Courmont remi at remlab.net
Tue Jul 2 22:08:08 CEST 2013


Le mardi 2 juillet 2013 22:48:02, Mark Lee a écrit :
>  * libvlc_media_player_set_video_title_show
>  * libvlc_media_player_get_video_title_show
>  * libvlc_media_player_set_video_title_position
>  * libvlc_media_player_get_video_title_position
>  * libvlc_media_player_set_video_title_timeout
>  * libvlc_media_player_get_video_title_timeout
> ---
>  include/vlc/libvlc_media_player.h | 68
> +++++++++++++++++++++++++++++++++++++++ lib/libvlc.sym                   
> |  6 ++++
>  lib/media_player.c                | 35 ++++++++++++++++++++
>  3 files changed, 109 insertions(+)
> 
> diff --git a/include/vlc/libvlc_media_player.h
> b/include/vlc/libvlc_media_player.h index bd93201..7b2e222 100644
> --- a/include/vlc/libvlc_media_player.h
> +++ b/include/vlc/libvlc_media_player.h
> @@ -824,6 +824,74 @@ LIBVLC_API void libvlc_media_player_navigate(
> libvlc_media_player_t* p_mi, unsigned navigate );
> 
>  /**
> + * Enumeration of values used to set the video title position.
> + */
> +typedef enum libvlc_title_position_t {
> +    libvlc_title_centre=0,

For consistency, please stick to American English for identifiers.

> +    libvlc_title_left,
> +    libvlc_title_right,
> +    libvlc_title_top,
> +    libvlc_title_top_left,
> +    libvlc_title_top_right,
> +    libvlc_title_bottom,
> +    libvlc_title_bottom_left,
> +    libvlc_title_bottom_right
> +} libvlc_title_position_t;

This is not really title-specific, even if it is only used for the title at 
this point.

> +
> +/**
> + * Set whether or not the video title will be shown when media is played.
> + *
> + * \param p_mi the media player
> + * \param show true to show the title; otherwise false
> + * \version libVLC 2.1.0 or later
> + */
> +LIBVLC_API void libvlc_media_player_set_video_title_show(
> libvlc_media_player_t *p_mi, bool show );

Is there really a need for so many new functions? It should be possible to 
merge timeout and position in a single setter, and use a special value to 
disable completely (0, -1, libvlc_position_disable, whatever).

> +
> +/**
> + * Will the video title be shown when media is played?
> + *
> + * \param p_mi the media player
> + * \return true if the title will be shown; false if it will not
> + * \version libVLC 2.1.0 or later
> + */
> +LIBVLC_API bool libvlc_media_player_get_video_title_show(
> libvlc_media_player_t *p_mi ); +
> +/**
> + * Set the video title position.
> + *
> + * \param p_mi the media player
> + * \pos position
> + * \version libVLC 2.1.0 or later
> + */
> +LIBVLC_API void libvlc_media_player_set_video_title_position(
> libvlc_media_player_t *p_mi, libvlc_title_position_t pos );
> +
> +/**
> + * Get the video title position.
> + *
> + * \param p_mi the media player
> + * \return position
> + * \version libVLC 2.1.0 or later
> + */
> +LIBVLC_API libvlc_title_position_t
> libvlc_media_player_get_video_title_position( libvlc_media_player_t *p_mi
> ); +
> +/**
> + * Set the video title timeout.
> + *
> + * \param p_mi the media player
> + * \param timeout timeout (milliseconds)
> + * \version libVLC 2.1.0 or later
> + */
> +LIBVLC_API void libvlc_media_player_set_video_title_timeout(
> libvlc_media_player_t *p_mi, unsigned timeout );
> +
> +/**
> + * Get the video title timeout.
> + *
> + * \return timeout (milliseconds)
> + * \version libVLC 2.1.0 or later
> + */
> +LIBVLC_API unsigned libvlc_media_player_get_video_title_timeout(
> libvlc_media_player_t *p_mi );
> +
> +/**
>   * Release (free) libvlc_track_description_t
>   *
>   * \param p_track_description the structure to release
> diff --git a/lib/libvlc.sym b/lib/libvlc.sym
> index c19628a..f532890 100644
> --- a/lib/libvlc.sym
> +++ b/lib/libvlc.sym
> @@ -164,6 +164,12 @@ libvlc_media_player_set_xwindow
>  libvlc_media_player_stop
>  libvlc_media_player_will_play
>  libvlc_media_player_navigate
> +libvlc_media_player_set_video_title_show
> +libvlc_media_player_get_video_title_show
> +libvlc_media_player_set_video_title_position
> +libvlc_media_player_get_video_title_position
> +libvlc_media_player_set_video_title_timeout
> +libvlc_media_player_get_video_title_timeout
>  libvlc_media_release
>  libvlc_media_retain
>  libvlc_media_save_meta
> diff --git a/lib/media_player.c b/lib/media_player.c
> index c48daa4..a0f38e6 100644
> --- a/lib/media_player.c
> +++ b/lib/media_player.c
> @@ -457,6 +457,11 @@ libvlc_media_player_new( libvlc_instance_t *instance )
>      var_Create (mp, "amem-rate", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
>      var_Create (mp, "amem-channels", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
> 
> +    /* Video Title */
> +    var_Create (mp, "video-title-show", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
> +    var_Create (mp, "video-title-position", VLC_VAR_INTEGER |
> VLC_VAR_DOINHERIT);
> +    var_Create (mp, "video-title-timeout",
> VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
> +

There is no need for VLC_VAR_DOINHERIT here. (I wonder why amen has them 
above, this may be a case of cargo cult.)

>      mp->p_md = NULL;
>      mp->state = libvlc_NothingSpecial;
>      mp->p_libvlc_instance = instance;
> @@ -1385,3 +1390,33 @@ void libvlc_media_player_next_frame(
> libvlc_media_player_t *p_mi ) vlc_object_release( p_input_thread );
>      }
>  }
> +
> +void libvlc_media_player_set_video_title_show( libvlc_media_player_t
> *p_mi, bool show ) +{
> +    var_SetBool( p_mi, "video-title-show", show );
> +}
> +
> +bool libvlc_media_player_get_video_title_show( libvlc_media_player_t *p_mi
> ) +{
> +    return var_GetBool( p_mi, "video-title-show" );
> +}
> +
> +void libvlc_media_player_set_video_title_position( libvlc_media_player_t
> *p_mi, libvlc_title_position_t pos ) +{
> +    var_SetInteger( p_mi, "video-title-position", pos );
> +}
> +
> +libvlc_title_position_t libvlc_media_player_get_video_title_position(
> libvlc_media_player_t *p_mi ) +{
> +    return var_GetInteger( p_mi, "video-title-position" );
> +}
> +
> +void libvlc_media_player_set_video_title_timeout( libvlc_media_player_t
> *p_mi, unsigned timeout ) +{
> +    var_SetInteger( p_mi, "video-title-timeout", timeout );
> +}
> +
> +unsigned libvlc_media_player_get_video_title_timeout(
> libvlc_media_player_t *p_mi ) +{
> +    return var_GetInteger( p_mi, "video-title-timeout" );
> +}

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list