[vlc-commits] lib/video: apply filters value to all vouts
Thomas Guillem
git at videolan.org
Mon Jun 5 18:39:23 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jun 5 17:04:05 2017 +0200| [738b0971d0e2ec86e06f36819f0d7cf0ea227fa4] | committer: Thomas Guillem
lib/video: apply filters value to all vouts
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=738b0971d0e2ec86e06f36819f0d7cf0ea227fa4
---
lib/video.c | 73 +++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 45 insertions(+), 28 deletions(-)
diff --git a/lib/video.c b/lib/video.c
index 5b5c70c6d2..3fcde1091c 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -699,8 +699,9 @@ void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi,
/* module helpers */
/* ************** */
-static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name,
- bool b_add )
+static int get_filter_str( vlc_object_t *p_parent, const char *psz_name,
+ bool b_add, const char **ppsz_filter_type,
+ char **ppsz_filter_value)
{
char *psz_parser;
char *psz_string;
@@ -710,7 +711,7 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name,
if( !p_obj )
{
msg_Err( p_parent, "Unable to find filter module \"%s\".", psz_name );
- return;
+ return VLC_EGENERIC;
}
if( module_provides( p_obj, "video filter" ) )
@@ -728,7 +729,7 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name,
else
{
msg_Err( p_parent, "Unknown video filter type." );
- return;
+ return VLC_EGENERIC;
}
psz_string = var_GetString( p_parent, psz_filter_type );
@@ -746,14 +747,14 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name,
psz_string, psz_name ) == -1 )
{
free( psz_parser );
- return;
+ return VLC_EGENERIC;
}
free( psz_parser );
}
else
{
free( psz_string );
- return;
+ return VLC_EGENERIC;
}
}
else
@@ -771,13 +772,13 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name,
else
{
free( psz_string );
- return;
+ return VLC_EGENERIC;
}
}
- var_SetString( p_parent, psz_filter_type, psz_string );
-
- free( psz_string );
+ *ppsz_filter_type = psz_filter_type;
+ *ppsz_filter_value = psz_string;
+ return VLC_SUCCESS;
}
static bool find_sub_source_by_name( libvlc_media_player_t *p_mi, const char *restrict name )
@@ -809,23 +810,22 @@ typedef const struct {
static void
set_value( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt, unsigned i_expected_type,
- const vlc_value_t *val )
+ const vlc_value_t *val, bool b_sub_source )
{
if( !opt ) return;
- switch( opt->type )
+ int i_type = opt->type;
+ vlc_value_t new_val = *val;
+ const char *psz_opt_name = opt->name;
+ switch( i_type )
{
case 0: /* the enabler */
{
- vout_thread_t *vout = GetVout( p_mi, 0 );
- vlc_object_t *p_parent = vout ? VLC_OBJECT( vout ) :
- VLC_OBJECT( p_mi );
- vout_EnableFilter( p_parent, opt->name, val->i_int );
- if (vout != NULL)
- { /* Fill sub-source */
- var_TriggerCallback( vout, "sub-source" );
- vlc_object_release( vout );
- }
+ int i_ret = get_filter_str( VLC_OBJECT( p_mi ), opt->name, val->i_int,
+ &psz_opt_name, &new_val.psz_string );
+ if( i_ret != VLC_SUCCESS )
+ return;
+ i_type = VLC_VAR_STRING;
break;
}
case VLC_VAR_INTEGER:
@@ -836,12 +836,29 @@ set_value( libvlc_media_player_t *p_mi, const char *restrict name,
libvlc_printerr( "Invalid argument to %s", name );
return;
}
- var_SetChecked( p_mi, opt->name, opt->type, *val );
break;
default:
libvlc_printerr( "Invalid argument to %s", name );
return;
}
+
+ /* 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 );
+
+ /* Set the new value to every loaded vouts */
+ size_t i_vout_count;
+ vout_thread_t **pp_vouts = GetVouts( p_mi, &i_vout_count );
+ for( size_t i = 0; i < i_vout_count; ++i )
+ {
+ var_SetChecked( pp_vouts[i], psz_opt_name, i_type, new_val );
+ if( b_sub_source )
+ var_TriggerCallback( pp_vouts[i], "sub-source" );
+ vlc_object_release( pp_vouts[i] );
+ }
+
+ if( opt->type == 0 )
+ free( new_val.psz_string );
}
static int
@@ -946,7 +963,7 @@ void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi,
unsigned option, int value )
{
set_value( p_mi, "marq", marq_option_bynumber(option), VLC_VAR_INTEGER,
- &(vlc_value_t) { .i_int = value } );
+ &(vlc_value_t) { .i_int = value }, true );
}
/*****************************************************************************
@@ -956,7 +973,7 @@ void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi,
unsigned option, const char * value )
{
set_value( p_mi, "marq", marq_option_bynumber(option), VLC_VAR_STRING,
- &(vlc_value_t){ .psz_string = (char *)value } );
+ &(vlc_value_t){ .psz_string = (char *)value }, true );
}
@@ -989,7 +1006,7 @@ void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
unsigned option, const char *psz_value )
{
set_value( p_mi,"logo",logo_option_bynumber(option), VLC_VAR_STRING,
- &(vlc_value_t){ .psz_string = (char *)psz_value } );
+ &(vlc_value_t){ .psz_string = (char *)psz_value }, true );
}
@@ -997,7 +1014,7 @@ void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi,
unsigned option, int value )
{
set_value( p_mi, "logo", logo_option_bynumber(option), VLC_VAR_INTEGER,
- &(vlc_value_t) { .i_int = value } );
+ &(vlc_value_t) { .i_int = value }, true );
}
@@ -1036,7 +1053,7 @@ void libvlc_video_set_adjust_int( libvlc_media_player_t *p_mi,
unsigned option, int value )
{
set_value( p_mi, "adjust", adjust_option_bynumber(option), VLC_VAR_INTEGER,
- &(vlc_value_t) { .i_int = value } );
+ &(vlc_value_t) { .i_int = value }, false );
}
@@ -1051,7 +1068,7 @@ void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
unsigned option, float value )
{
set_value( p_mi, "adjust", adjust_option_bynumber(option), VLC_VAR_FLOAT,
- &(vlc_value_t) { .f_float = value } );
+ &(vlc_value_t) { .f_float = value }, false );
}
More information about the vlc-commits
mailing list