Commit 738b0971 authored by Thomas Guillem's avatar Thomas Guillem

lib/video: apply filters value to all vouts

parent 9a516806
...@@ -699,8 +699,9 @@ void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, ...@@ -699,8 +699,9 @@ void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi,
/* module helpers */ /* module helpers */
/* ************** */ /* ************** */
static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name, static int get_filter_str( vlc_object_t *p_parent, const char *psz_name,
bool b_add ) bool b_add, const char **ppsz_filter_type,
char **ppsz_filter_value)
{ {
char *psz_parser; char *psz_parser;
char *psz_string; char *psz_string;
...@@ -710,7 +711,7 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name, ...@@ -710,7 +711,7 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name,
if( !p_obj ) if( !p_obj )
{ {
msg_Err( p_parent, "Unable to find filter module \"%s\".", psz_name ); msg_Err( p_parent, "Unable to find filter module \"%s\".", psz_name );
return; return VLC_EGENERIC;
} }
if( module_provides( p_obj, "video filter" ) ) if( module_provides( p_obj, "video filter" ) )
...@@ -728,7 +729,7 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name, ...@@ -728,7 +729,7 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name,
else else
{ {
msg_Err( p_parent, "Unknown video filter type." ); msg_Err( p_parent, "Unknown video filter type." );
return; return VLC_EGENERIC;
} }
psz_string = var_GetString( p_parent, psz_filter_type ); 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, ...@@ -746,14 +747,14 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name,
psz_string, psz_name ) == -1 ) psz_string, psz_name ) == -1 )
{ {
free( psz_parser ); free( psz_parser );
return; return VLC_EGENERIC;
} }
free( psz_parser ); free( psz_parser );
} }
else else
{ {
free( psz_string ); free( psz_string );
return; return VLC_EGENERIC;
} }
} }
else else
...@@ -771,13 +772,13 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name, ...@@ -771,13 +772,13 @@ static void vout_EnableFilter( vlc_object_t *p_parent, const char *psz_name,
else else
{ {
free( psz_string ); free( psz_string );
return; return VLC_EGENERIC;
} }
} }
var_SetString( p_parent, psz_filter_type, psz_string ); *ppsz_filter_type = psz_filter_type;
*ppsz_filter_value = psz_string;
free( psz_string ); return VLC_SUCCESS;
} }
static bool find_sub_source_by_name( libvlc_media_player_t *p_mi, const char *restrict name ) static bool find_sub_source_by_name( libvlc_media_player_t *p_mi, const char *restrict name )
...@@ -809,23 +810,22 @@ typedef const struct { ...@@ -809,23 +810,22 @@ typedef const struct {
static void static void
set_value( libvlc_media_player_t *p_mi, const char *restrict name, set_value( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt, unsigned i_expected_type, 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; 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 */ case 0: /* the enabler */
{ {
vout_thread_t *vout = GetVout( p_mi, 0 ); int i_ret = get_filter_str( VLC_OBJECT( p_mi ), opt->name, val->i_int,
vlc_object_t *p_parent = vout ? VLC_OBJECT( vout ) : &psz_opt_name, &new_val.psz_string );
VLC_OBJECT( p_mi ); if( i_ret != VLC_SUCCESS )
vout_EnableFilter( p_parent, opt->name, val->i_int ); return;
if (vout != NULL) i_type = VLC_VAR_STRING;
{ /* Fill sub-source */
var_TriggerCallback( vout, "sub-source" );
vlc_object_release( vout );
}
break; break;
} }
case VLC_VAR_INTEGER: case VLC_VAR_INTEGER:
...@@ -836,12 +836,29 @@ set_value( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -836,12 +836,29 @@ set_value( libvlc_media_player_t *p_mi, const char *restrict name,
libvlc_printerr( "Invalid argument to %s", name ); libvlc_printerr( "Invalid argument to %s", name );
return; return;
} }
var_SetChecked( p_mi, opt->name, opt->type, *val );
break; break;
default: default:
libvlc_printerr( "Invalid argument to %s", name ); libvlc_printerr( "Invalid argument to %s", name );
return; 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 static int
...@@ -946,7 +963,7 @@ void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi, ...@@ -946,7 +963,7 @@ void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi,
unsigned option, int value ) unsigned option, int value )
{ {
set_value( p_mi, "marq", marq_option_bynumber(option), VLC_VAR_INTEGER, 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, ...@@ -956,7 +973,7 @@ void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi,
unsigned option, const char * value ) unsigned option, const char * value )
{ {
set_value( p_mi, "marq", marq_option_bynumber(option), VLC_VAR_STRING, 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, ...@@ -989,7 +1006,7 @@ void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
unsigned option, const char *psz_value ) unsigned option, const char *psz_value )
{ {
set_value( p_mi,"logo",logo_option_bynumber(option), VLC_VAR_STRING, 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, ...@@ -997,7 +1014,7 @@ void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi,
unsigned option, int value ) unsigned option, int value )
{ {
set_value( p_mi, "logo", logo_option_bynumber(option), VLC_VAR_INTEGER, 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, ...@@ -1036,7 +1053,7 @@ void libvlc_video_set_adjust_int( libvlc_media_player_t *p_mi,
unsigned option, int value ) unsigned option, int value )
{ {
set_value( p_mi, "adjust", adjust_option_bynumber(option), VLC_VAR_INTEGER, 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, ...@@ -1051,7 +1068,7 @@ void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
unsigned option, float value ) unsigned option, float value )
{ {
set_value( p_mi, "adjust", adjust_option_bynumber(option), VLC_VAR_FLOAT, 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 );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment