[vlc-devel] [PATCH 3/4] lib/video: provide API to set and get video filter options
Pierre Lamot
pierre at videolabs.io
Wed Sep 6 15:02:54 CEST 2017
---
include/vlc/libvlc_media_player.h | 91 +++++++++++++++++++++++++++++++++++++++
lib/libvlc.sym | 8 ++++
lib/video.c | 83 +++++++++++++++++++++++++++++++++--
3 files changed, 179 insertions(+), 3 deletions(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 579a6941ad..3118624219 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1628,6 +1628,97 @@ LIBVLC_API void libvlc_video_set_filters(libvlc_media_player_t *p_mi,
*/
LIBVLC_API const char *libvlc_video_get_filters( libvlc_media_player_t *p_mi );
+/**
+ * Get the value of a parameter
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \return the value of the parameter
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API const char *libvlc_video_get_filter_option_string( libvlc_media_player_t *p_mi,
+ const char *psz_option );
+
+/**
+ * Set the value of a parameter
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \param psz_value value to assign
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API void libvlc_video_set_filter_option_string( libvlc_media_player_t *p_mi,
+ const char *psz_option,
+ const char *psz_value );
+
+/**
+ * Get the value of a parameter
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \return the value of the parameter
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API int64_t libvlc_video_get_filter_option_int( libvlc_media_player_t *p_mi,
+ const char *psz_option );
+
+/**
+ * Set the value of a parameter
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \param i_value value to assign
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API void libvlc_video_set_filter_option_int( libvlc_media_player_t *p_mi,
+ const char *psz_option,
+ int64_t i_value );
+
+/**
+ * Get the value of a parameter
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \return the value of the parameter
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API float libvlc_video_get_filter_option_float( libvlc_media_player_t *p_mi,
+ const char *psz_option );
+
+/**
+ * Set the value of a parameter
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \param psz_value value to assign
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API void libvlc_video_set_filter_option_float( libvlc_media_player_t *p_mi,
+ const char *psz_option,
+ float f_value );
+
+/**
+ * Get the value of a parameter
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \return the value of the parameter
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API bool libvlc_video_get_filter_option_bool( libvlc_media_player_t *p_mi,
+ const char *psz_option );
+
+/**
+ * Set the value of a parameter
+ *
+ * \param p_mi libvlc media player instance
+ * \param psz_option option name
+ * \param b_value value to assign
+ * \version LibVLC 3.0.0 and later.
+ */
+LIBVLC_API void libvlc_video_set_filter_option_bool( libvlc_media_player_t *p_mi,
+ const char *psz_option,
+ bool b_value );
/** @} video */
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index cd5f433365..a228e21f0f 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -251,6 +251,10 @@ libvlc_video_get_size
libvlc_video_get_height
libvlc_video_get_cursor
libvlc_video_get_filters
+libvlc_video_get_filter_option_string
+libvlc_video_get_filter_option_int
+libvlc_video_get_filter_option_float
+libvlc_video_get_filter_option_bool
libvlc_video_get_logo_int
libvlc_video_get_marquee_int
libvlc_video_get_marquee_string
@@ -272,6 +276,10 @@ libvlc_video_set_callbacks
libvlc_video_set_crop_geometry
libvlc_video_set_deinterlace
libvlc_video_set_filters
+libvlc_video_set_filter_option_string
+libvlc_video_set_filter_option_int
+libvlc_video_set_filter_option_float
+libvlc_video_set_filter_option_bool
libvlc_video_set_format
libvlc_video_set_format_callbacks
libvlc_video_set_key_input
diff --git a/lib/video.c b/lib/video.c
index 7450e92fc4..20389e0192 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -804,8 +804,8 @@ static bool find_sub_source_by_name( libvlc_media_player_t *p_mi, const char *re
return (p != NULL);
}
-typedef const struct {
- const char name[20];
+typedef struct {
+ char name[20];
unsigned type;
} opt_t;
@@ -833,6 +833,7 @@ set_value( libvlc_media_player_t *p_mi, const char *restrict name,
case VLC_VAR_INTEGER:
case VLC_VAR_FLOAT:
case VLC_VAR_STRING:
+ case VLC_VAR_BOOL:
if( i_expected_type != opt->type )
{
libvlc_printerr( "Invalid argument to %s", name );
@@ -846,7 +847,11 @@ set_value( libvlc_media_player_t *p_mi, const char *restrict name,
/* Set the new value to the media player. Next vouts created from this
* media player will inherit this new value */
- var_SetChecked( p_mi, psz_opt_name, i_type, new_val );
+ if (var_SetChecked( p_mi, psz_opt_name, i_type, new_val ) == VLC_ENOVAR)
+ {
+ var_Create( p_mi, psz_opt_name, i_type | VLC_VAR_DOINHERIT);
+ var_SetChecked( p_mi, psz_opt_name, i_type, new_val );
+ }
/* Set the new value to every loaded vouts */
size_t i_vout_count;
@@ -1094,3 +1099,75 @@ const char *libvlc_video_get_filters( libvlc_media_player_t *p_mi)
static const opt_t opt = { "video-filter", VLC_VAR_STRING };
return get_string( p_mi, "video-filter", &opt );
}
+
+void libvlc_video_set_filter_option_string( libvlc_media_player_t *p_mi, const char *psz_option, const char * psz_value )
+{
+ opt_t opt = { .type = VLC_VAR_STRING };
+ strlcpy(opt.name, psz_option, sizeof(opt.name));
+ set_value( p_mi, psz_option, &opt, VLC_VAR_STRING,
+ &(vlc_value_t) { .psz_string = (char *)psz_value }, false );
+}
+
+const char * libvlc_video_get_filter_option_string( libvlc_media_player_t *p_mi, const char *psz_option )
+{
+ if ( ( var_Type( p_mi, psz_option ) & VLC_VAR_CLASS ) != VLC_VAR_STRING )
+ {
+ libvlc_printerr( "Invalid argument to %s", psz_option );
+ return NULL;
+ }
+ return var_GetString( p_mi, psz_option );
+}
+
+void libvlc_video_set_filter_option_int( libvlc_media_player_t *p_mi, const char *psz_option, int64_t i_value )
+{
+ opt_t opt = { .type = VLC_VAR_INTEGER };
+ strlcpy(opt.name, psz_option, sizeof(opt.name));
+ set_value( p_mi, psz_option, &opt, VLC_VAR_INTEGER,
+ &(vlc_value_t) { .i_int = i_value }, false );
+}
+
+int64_t libvlc_video_get_filter_option_int( libvlc_media_player_t *p_mi, const char *psz_option )
+{
+ if ( ( var_Type( p_mi, psz_option ) & VLC_VAR_CLASS ) != VLC_VAR_INTEGER )
+ {
+ libvlc_printerr( "Invalid argument to %s", psz_option );
+ return 0;
+ }
+ return var_GetInteger( p_mi, psz_option );
+}
+
+void libvlc_video_set_filter_option_float( libvlc_media_player_t *p_mi, const char *psz_option, float f_value )
+{
+ opt_t opt = { .type = VLC_VAR_FLOAT };
+ strlcpy(opt.name, psz_option, sizeof(opt.name));
+ set_value( p_mi, psz_option, &opt, VLC_VAR_FLOAT,
+ &(vlc_value_t) { .f_float = f_value }, false );
+}
+
+float libvlc_video_get_filter_option_float( libvlc_media_player_t *p_mi, const char *psz_option )
+{
+ if ( ( var_Type( p_mi, psz_option ) & VLC_VAR_CLASS ) != VLC_VAR_FLOAT )
+ {
+ libvlc_printerr( "Invalid argument to %s", psz_option );
+ return 0.0f;
+ }
+ return var_GetFloat( p_mi, psz_option );
+}
+
+void libvlc_video_set_filter_option_bool( libvlc_media_player_t *p_mi, const char *psz_option, bool b_value )
+{
+ opt_t opt = { .type = VLC_VAR_BOOL };
+ strlcpy(opt.name, psz_option, sizeof(opt.name));
+ set_value( p_mi, psz_option, &opt, VLC_VAR_BOOL,
+ &(vlc_value_t) { .b_bool = b_value }, false );
+}
+
+bool libvlc_video_get_filter_option_bool( libvlc_media_player_t *p_mi, const char *psz_option )
+{
+ if ( ( var_Type( p_mi, psz_option ) & VLC_VAR_CLASS ) != VLC_VAR_BOOL )
+ {
+ libvlc_printerr( "Invalid argument to %s", psz_option );
+ return false;
+ }
+ return var_GetBool( p_mi, psz_option );
+}
--
2.14.1
More information about the vlc-devel
mailing list