Commit 9786ac41 authored by Antoine Cellerier's avatar Antoine Cellerier

use config chain for the --sub-filter option.
Example:
  --sub-filter "marq{marquee=pouet}:marq{marquee=\$N,y=50,x=50}"
Sub filters other than marq still need to be changed
rc interface marq callbacks need to be fixed too
parent 62fffadf
...@@ -130,6 +130,8 @@ static char *ppsz_pos_descriptions[] = ...@@ -130,6 +130,8 @@ static char *ppsz_pos_descriptions[] =
{ N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"), { N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") }; N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
#define CFG_PREFIX "marq-"
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
...@@ -139,26 +141,27 @@ vlc_module_begin(); ...@@ -139,26 +141,27 @@ vlc_module_begin();
set_callbacks( CreateFilter, DestroyFilter ); set_callbacks( CreateFilter, DestroyFilter );
set_category( CAT_VIDEO ); set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_SUBPIC ); set_subcategory( SUBCAT_VIDEO_SUBPIC );
add_string( "marq-marquee", "VLC", NULL, MSG_TEXT, MSG_LONGTEXT, add_string( CFG_PREFIX "marquee", "VLC", NULL, MSG_TEXT, MSG_LONGTEXT,
VLC_FALSE ); VLC_FALSE );
set_section( N_("Position"), NULL ); set_section( N_("Position"), NULL );
add_integer( "marq-x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_TRUE ); add_integer( CFG_PREFIX "x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_TRUE );
add_integer( "marq-y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_TRUE ); add_integer( CFG_PREFIX "y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_TRUE );
add_integer( "marq-position", 5, NULL, POS_TEXT, POS_LONGTEXT, VLC_FALSE ); add_integer( CFG_PREFIX "position", 5, NULL, POS_TEXT, POS_LONGTEXT, VLC_FALSE );
set_section( N_("Font"), NULL ); set_section( N_("Font"), NULL );
/* 5 sets the default to top [1] left [4] */ /* 5 sets the default to top [1] left [4] */
change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 ); change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );
add_integer_with_range( "marq-opacity", 255, 0, 255, NULL, add_integer_with_range( CFG_PREFIX "opacity", 255, 0, 255, NULL,
OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE ); OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE );
add_integer( "marq-color", 0xFFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT, add_integer( CFG_PREFIX "color", 0xFFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT,
VLC_FALSE ); VLC_FALSE );
change_integer_list( pi_color_values, ppsz_color_descriptions, 0 ); change_integer_list( pi_color_values, ppsz_color_descriptions, 0 );
add_integer( "marq-size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, VLC_FALSE ); add_integer( CFG_PREFIX "size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT,
VLC_FALSE );
set_section( N_("Misc"), NULL ); set_section( N_("Misc"), NULL );
add_integer( "marq-timeout", 0, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT, add_integer( CFG_PREFIX "timeout", 0, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT,
VLC_FALSE ); VLC_FALSE );
set_description( _("Marquee display") ); set_description( _("Marquee display") );
...@@ -166,6 +169,10 @@ vlc_module_begin(); ...@@ -166,6 +169,10 @@ vlc_module_begin();
add_shortcut( "time" ); add_shortcut( "time" );
vlc_module_end(); vlc_module_end();
static const char *ppsz_filter_options[] = {
"marquee", "x", "y", "position", "color", "size", "timeout", NULL
};
/***************************************************************************** /*****************************************************************************
* CreateFilter: allocates marquee video filter * CreateFilter: allocates marquee video filter
*****************************************************************************/ *****************************************************************************/
...@@ -185,9 +192,12 @@ static int CreateFilter( vlc_object_t *p_this ) ...@@ -185,9 +192,12 @@ static int CreateFilter( vlc_object_t *p_this )
p_sys->p_style = malloc( sizeof( text_style_t ) ); p_sys->p_style = malloc( sizeof( text_style_t ) );
memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ) ); memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ) );
config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
p_filter->p_cfg );
#define CREATE_VAR( stor, type, var ) \ #define CREATE_VAR( stor, type, var ) \
p_sys->stor = var_CreateGet##type( p_filter->p_libvlc, var ); \ p_sys->stor = var_CreateGet##type( p_filter, var ); \
var_AddCallback( p_filter->p_libvlc, var, MarqueeCallback, p_sys ); var_AddCallback( p_filter, var, MarqueeCallback, p_sys );
CREATE_VAR( i_xoff, Integer, "marq-x" ); CREATE_VAR( i_xoff, Integer, "marq-x" );
CREATE_VAR( i_yoff, Integer, "marq-y" ); CREATE_VAR( i_yoff, Integer, "marq-y" );
...@@ -221,8 +231,8 @@ static void DestroyFilter( vlc_object_t *p_this ) ...@@ -221,8 +231,8 @@ static void DestroyFilter( vlc_object_t *p_this )
/* Delete the marquee variables */ /* Delete the marquee variables */
#define DEL_VAR(var) \ #define DEL_VAR(var) \
var_DelCallback( p_filter->p_libvlc, var, MarqueeCallback, p_sys ); \ var_DelCallback( p_filter, var, MarqueeCallback, p_sys ); \
var_Destroy( p_filter->p_libvlc, var ); var_Destroy( p_filter, var );
DEL_VAR( "marq-x" ); DEL_VAR( "marq-x" );
DEL_VAR( "marq-y" ); DEL_VAR( "marq-y" );
DEL_VAR( "marq-marquee" ); DEL_VAR( "marq-marquee" );
......
...@@ -1555,7 +1555,7 @@ static int ParseVideoFilter2Chain( vout_thread_t *p_vout, char *psz_vfilters ) ...@@ -1555,7 +1555,7 @@ static int ParseVideoFilter2Chain( vout_thread_t *p_vout, char *psz_vfilters )
&p_vout->psz_vfilters[p_vout->i_vfilters_cfg], &p_vout->psz_vfilters[p_vout->i_vfilters_cfg],
&p_vout->p_vfilters_cfg[p_vout->i_vfilters_cfg], &p_vout->p_vfilters_cfg[p_vout->i_vfilters_cfg],
psz_parser ); psz_parser );
msg_Dbg( p_vout, "adding vfilter: %s\n", msg_Dbg( p_vout, "adding vfilter: %s",
p_vout->psz_vfilters[p_vout->i_vfilters_cfg] ); p_vout->psz_vfilters[p_vout->i_vfilters_cfg] );
p_vout->i_vfilters_cfg++; p_vout->i_vfilters_cfg++;
if( psz_parser && psz_parser ) if( psz_parser && psz_parser )
......
...@@ -98,7 +98,8 @@ spu_t *__spu_Create( vlc_object_t *p_this ) ...@@ -98,7 +98,8 @@ spu_t *__spu_Create( vlc_object_t *p_this )
*/ */
int spu_Init( spu_t *p_spu ) int spu_Init( spu_t *p_spu )
{ {
char *psz_filter, *psz_filter_orig; char *psz_filter;
char *psz_parser;
vlc_value_t val; vlc_value_t val;
/* If the user requested a sub margin, we force the position. */ /* If the user requested a sub margin, we force the position. */
...@@ -108,21 +109,28 @@ int spu_Init( spu_t *p_spu ) ...@@ -108,21 +109,28 @@ int spu_Init( spu_t *p_spu )
var_Create( p_spu, "sub-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_spu, "sub-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_spu, "sub-filter", &val ); var_Get( p_spu, "sub-filter", &val );
psz_filter = psz_filter_orig = val.psz_string;
while( psz_filter && *psz_filter ) psz_filter = val.psz_string;
psz_parser = psz_filter;
while( psz_parser && *psz_parser )
{ {
char *psz_parser = strchr( psz_filter, ':' ); config_chain_t *p_cfg; /* Do we ever need to free this ? */
char *psz_name;
psz_parser = config_ChainCreate( &psz_name, &p_cfg, psz_parser );
if( psz_parser ) *psz_parser++ = 0; msg_Dbg( p_spu, "adding sub-filter: %s", psz_name );
p_spu->pp_filter[p_spu->i_filter] = p_spu->pp_filter[p_spu->i_filter] =
vlc_object_create( p_spu, VLC_OBJECT_FILTER ); vlc_object_create( p_spu, VLC_OBJECT_FILTER );
vlc_object_attach( p_spu->pp_filter[p_spu->i_filter], p_spu ); vlc_object_attach( p_spu->pp_filter[p_spu->i_filter], p_spu );
p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_new = sub_new_buffer; p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_new = sub_new_buffer;
p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_del = sub_del_buffer; p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_del = sub_del_buffer;
p_spu->pp_filter[p_spu->i_filter]->p_cfg = p_cfg;;
p_spu->pp_filter[p_spu->i_filter]->p_module = p_spu->pp_filter[p_spu->i_filter]->p_module =
module_Need( p_spu->pp_filter[p_spu->i_filter], module_Need( p_spu->pp_filter[p_spu->i_filter],
"sub filter", psz_filter, 0 ); "sub filter", psz_name, 0 );
if( p_spu->pp_filter[p_spu->i_filter]->p_module ) if( p_spu->pp_filter[p_spu->i_filter]->p_module )
{ {
filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) ); filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) );
...@@ -143,9 +151,8 @@ int spu_Init( spu_t *p_spu ) ...@@ -143,9 +151,8 @@ int spu_Init( spu_t *p_spu )
msg_Dbg( p_spu, "can't add anymore filters" ); msg_Dbg( p_spu, "can't add anymore filters" );
} }
psz_filter = psz_parser; free( psz_name );
} }
if( psz_filter_orig ) free( psz_filter_orig );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
......
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