Commit 9ff83fc5 authored by JP Dinger's avatar JP Dinger

Add libvlc interface to video_filter/logo module, like the

marquee filter. Also change logo parameter transparency to
opacity for consistency with marquee.
parent cdce6740
...@@ -875,6 +875,53 @@ VLC_PUBLIC_API void libvlc_video_set_marquee_option_as_string( libvlc_media_play ...@@ -875,6 +875,53 @@ VLC_PUBLIC_API void libvlc_video_set_marquee_option_as_string( libvlc_media_play
const char *, const char *,
libvlc_exception_t * ); libvlc_exception_t * );
enum libvlc_video_logo_option_t {
libvlc_logo_enable,
libvlc_logo_file, /**< string argument, "file,d,t;file,d,t;..." */
libvlc_logo_x,
libvlc_logo_y,
libvlc_logo_delay,
libvlc_logo_repeat,
libvlc_logo_opacity,
libvlc_logo_position,
};
/**
* Get integer logo option.
*
* \param p_mi libvlc media player instance
* \param option logo option to get, values of libvlc_video_logo_option_t
* \param p_e an pointer to an initialized exception object
*/
VLC_PUBLIC_API int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi,
unsigned option, libvlc_exception_t *p_e );
/**
* Set logo option as integer. Options that take a different type value
* cause an invalid argument exception.
* Passing libvlc_logo_enable as option value has the side effect of
* starting (arg !0) or stopping (arg 0) the logo filter.
*
* \param p_mi libvlc media player instance
* \param option logo option to set, values of libvlc_video_logo_option_t
* \param value logo option value
* \param p_e an pointer to an initialized exception object
*/
VLC_PUBLIC_API void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi,
unsigned option, int value, libvlc_exception_t *p_e );
/**
* Set logo option as string. Options that take a different type value
* cause an invalid argument exception.
*
* \param p_mi libvlc media player instance
* \param option logo option to set, values of libvlc_video_logo_option_t
* \param psz_value logo option value
* \param p_e an pointer to an initialized exception object
*/
VLC_PUBLIC_API void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
unsigned option, const char *psz_value, libvlc_exception_t *p_e );
/** @} video */ /** @} video */
/** \defgroup libvlc_audio libvlc_audio /** \defgroup libvlc_audio libvlc_audio
......
...@@ -61,8 +61,8 @@ ...@@ -61,8 +61,8 @@
#define POSY_TEXT N_("Y coordinate") #define POSY_TEXT N_("Y coordinate")
#define POSY_LONGTEXT N_("Y coordinate of the logo. You can move the logo " \ #define POSY_LONGTEXT N_("Y coordinate of the logo. You can move the logo " \
"by left-clicking it." ) "by left-clicking it." )
#define TRANS_TEXT N_("Transparency of the logo") #define OPACITY_TEXT N_("Opacity of the logo")
#define TRANS_LONGTEXT N_("Logo transparency value " \ #define OPACITY_LONGTEXT N_("Logo opacity value " \
"(from 0 for full transparency to 255 for full opacity)." ) "(from 0 for full transparency to 255 for full opacity)." )
#define POS_TEXT N_("Logo position") #define POS_TEXT N_("Logo position")
#define POS_LONGTEXT N_( \ #define POS_LONGTEXT N_( \
...@@ -99,8 +99,8 @@ vlc_module_begin () ...@@ -99,8 +99,8 @@ vlc_module_begin ()
/* default to 1000 ms per image, continuously cycle through them */ /* default to 1000 ms per image, continuously cycle through them */
add_integer( CFG_PREFIX "delay", 1000, NULL, DELAY_TEXT, DELAY_LONGTEXT, true ) add_integer( CFG_PREFIX "delay", 1000, NULL, DELAY_TEXT, DELAY_LONGTEXT, true )
add_integer( CFG_PREFIX "repeat", -1, NULL, REPEAT_TEXT, REPEAT_LONGTEXT, true ) add_integer( CFG_PREFIX "repeat", -1, NULL, REPEAT_TEXT, REPEAT_LONGTEXT, true )
add_integer_with_range( CFG_PREFIX "transparency", 255, 0, 255, NULL, add_integer_with_range( CFG_PREFIX "opacity", 255, 0, 255, NULL,
TRANS_TEXT, TRANS_LONGTEXT, false ) OPACITY_TEXT, OPACITY_LONGTEXT, false )
add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, false ) add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, false )
change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL ) change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL )
...@@ -171,7 +171,7 @@ struct filter_sys_t ...@@ -171,7 +171,7 @@ struct filter_sys_t
}; };
static const char *const ppsz_filter_options[] = { static const char *const ppsz_filter_options[] = {
"file", "x", "y", "delay", "repeat", "transparency", "position", NULL "file", "x", "y", "delay", "repeat", "opacity", "position", NULL
}; };
static const char *const ppsz_filter_callbacks[] = { static const char *const ppsz_filter_callbacks[] = {
...@@ -179,7 +179,7 @@ static const char *const ppsz_filter_callbacks[] = { ...@@ -179,7 +179,7 @@ static const char *const ppsz_filter_callbacks[] = {
"logo-x", "logo-x",
"logo-y", "logo-y",
"logo-position", "logo-position",
"logo-transparency", "logo-opacity",
"logo-repeat", "logo-repeat",
NULL NULL
}; };
...@@ -269,13 +269,10 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub ) ...@@ -269,13 +269,10 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
if( *psz_filename == '\0' ) if( *psz_filename == '\0' )
msg_Warn( p_this, "no logo file specified" ); msg_Warn( p_this, "no logo file specified" );
p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity");
"logo-transparency");
p_list->i_alpha = __MAX( __MIN( p_list->i_alpha, 255 ), 0 ); p_list->i_alpha = __MAX( __MIN( p_list->i_alpha, 255 ), 0 );
p_list->i_delay = p_list->i_delay = var_CreateGetIntegerCommand( p_filter, "logo-delay" );
var_CreateGetIntegerCommand( p_filter, "logo-delay" ); p_list->i_repeat = var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
p_list->i_repeat =
var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "logo-position" ); p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "logo-position" );
p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "logo-x" ); p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "logo-x" );
...@@ -579,7 +576,7 @@ static int LogoCallback( vlc_object_t *p_this, char const *psz_var, ...@@ -579,7 +576,7 @@ static int LogoCallback( vlc_object_t *p_this, char const *psz_var,
{ {
p_sys->i_pos = newval.i_int; p_sys->i_pos = newval.i_int;
} }
else if ( !strcmp( psz_var, "logo-transparency" ) ) else if ( !strcmp( psz_var, "logo-opacity" ) )
{ {
p_list->i_alpha = __MAX( __MIN( newval.i_int, 255 ), 0 ); p_list->i_alpha = __MAX( __MIN( newval.i_int, 255 ), 0 );
} }
...@@ -620,10 +617,10 @@ static picture_t *LoadImage( vlc_object_t *p_this, const char *psz_filename ) ...@@ -620,10 +617,10 @@ static picture_t *LoadImage( vlc_object_t *p_this, const char *psz_filename )
/** /**
* It loads the logo images into memory. * It loads the logo images into memory.
* *
* Read the logo-file input switch, obtaining a list of images and associated * Read the logo-file input switch, obtaining a list of images and
* durations and transparencies. Store the image(s), and times. An image * associated durations and transparencies. Store the image(s), and
* without a stated time or transparency will use the logo-delay and * times. An image without a stated time or opacity will use the
* logo-transparency values. * logo-delay and logo-opacity values.
*/ */
static void LogoListLoad( vlc_object_t *p_this, logo_list_t *p_logo_list, static void LogoListLoad( vlc_object_t *p_this, logo_list_t *p_logo_list,
const char *psz_filename ) const char *psz_filename )
......
/***************************************************************************** /*****************************************************************************
* video.c: libvlc new API video functions * video.c: libvlc new API video functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2005 the VideoLAN team * Copyright (C) 2005-2010 the VideoLAN team
* *
* $Id$ * $Id$
* *
...@@ -709,8 +709,8 @@ static vlc_object_t *get_marquee_object( libvlc_media_player_t * p_mi ) ...@@ -709,8 +709,8 @@ static vlc_object_t *get_marquee_object( libvlc_media_player_t * p_mi )
* libvlc_video_get_marquee_option_as_int : get a marq option value * libvlc_video_get_marquee_option_as_int : get a marq option value
*****************************************************************************/ *****************************************************************************/
int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi, int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi,
libvlc_video_marquee_int_option_t option, libvlc_video_marquee_int_option_t option,
libvlc_exception_t *p_e ) libvlc_exception_t *p_e )
{ {
const char * identifier = get_marquee_int_option_identifier(option); const char * identifier = get_marquee_int_option_identifier(option);
if(!identifier) if(!identifier)
...@@ -746,7 +746,7 @@ int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi, ...@@ -746,7 +746,7 @@ int libvlc_video_get_marquee_option_as_int( libvlc_media_player_t *p_mi,
* libvlc_video_get_marquee_option_as_string : get a marq option value * libvlc_video_get_marquee_option_as_string : get a marq option value
*****************************************************************************/ *****************************************************************************/
char * libvlc_video_get_marquee_option_as_string( libvlc_media_player_t *p_mi, char * libvlc_video_get_marquee_option_as_string( libvlc_media_player_t *p_mi,
libvlc_video_marquee_string_option_t option, libvlc_video_marquee_string_option_t option,
libvlc_exception_t *p_e ) libvlc_exception_t *p_e )
{ {
const char * identifier = get_marquee_string_option_identifier(option); const char * identifier = get_marquee_string_option_identifier(option);
...@@ -773,8 +773,8 @@ char * libvlc_video_get_marquee_option_as_string( libvlc_media_player_t *p_mi, ...@@ -773,8 +773,8 @@ char * libvlc_video_get_marquee_option_as_string( libvlc_media_player_t *p_mi,
* libvlc_video_set_marquee_option_as_int: enable, disable or set an int option * libvlc_video_set_marquee_option_as_int: enable, disable or set an int option
*****************************************************************************/ *****************************************************************************/
void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi, void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi,
libvlc_video_marquee_int_option_t option, libvlc_video_marquee_int_option_t option,
int value, libvlc_exception_t *p_e ) int value, libvlc_exception_t *p_e )
{ {
const char * identifier = get_marquee_int_option_identifier(option); const char * identifier = get_marquee_int_option_identifier(option);
if(!identifier) if(!identifier)
...@@ -814,9 +814,8 @@ void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi, ...@@ -814,9 +814,8 @@ void libvlc_video_set_marquee_option_as_int( libvlc_media_player_t *p_mi,
* libvlc_video_set_marquee_option_as_string: set a string option * libvlc_video_set_marquee_option_as_string: set a string option
*****************************************************************************/ *****************************************************************************/
void libvlc_video_set_marquee_option_as_string( libvlc_media_player_t *p_mi, void libvlc_video_set_marquee_option_as_string( libvlc_media_player_t *p_mi,
libvlc_video_marquee_string_option_t option, libvlc_video_marquee_string_option_t option,
const char * value, const char * value, libvlc_exception_t *p_e )
libvlc_exception_t *p_e )
{ {
const char * identifier = get_marquee_string_option_identifier(option); const char * identifier = get_marquee_string_option_identifier(option);
if(!identifier) if(!identifier)
...@@ -835,3 +834,152 @@ void libvlc_video_set_marquee_option_as_string( libvlc_media_player_t *p_mi, ...@@ -835,3 +834,152 @@ void libvlc_video_set_marquee_option_as_string( libvlc_media_player_t *p_mi,
var_SetString(marquee, identifier, value); var_SetString(marquee, identifier, value);
vlc_object_release(marquee); vlc_object_release(marquee);
} }
/* logo module support */
static vlc_object_t *get_logo_object( libvlc_media_player_t * p_mi,
libvlc_exception_t *p_e )
{
vlc_object_t *object = NULL;
vout_thread_t *vout = GetVout( p_mi, p_e );
libvlc_exception_clear( p_e );
if( vout )
{
object = vlc_object_find_name( vout, "logo", FIND_CHILD );
vlc_object_release(vout);
}
if( !object )
{
libvlc_exception_raise( p_e );
libvlc_printerr( "Logo not enabled" );
}
return object;
}
typedef const struct vlogo_opt {
const char name[16];
unsigned type;
} vlogo_opt_t;
static vlogo_opt_t *
logo_option_bynumber( unsigned option, libvlc_exception_t *p_e )
{
# define CFG_PREFIX "logo-"
vlogo_opt_t vlogo_optlist[] = /* depends on libvlc_video_logo_option_t */
{
{ "logo", 0 },
{ "logo-file", VLC_VAR_STRING },
{ "logo-x", VLC_VAR_INTEGER },
{ "logo-y", VLC_VAR_INTEGER },
{ "logo-delay", VLC_VAR_INTEGER },
{ "logo-repeat", VLC_VAR_INTEGER },
{ "logo-opacity", VLC_VAR_INTEGER },
{ "logo-position", VLC_VAR_INTEGER },
};
# undef CFG_PREFIX
enum { num_vlogo_opts = sizeof(vlogo_optlist) / sizeof(*vlogo_optlist) };
vlogo_opt_t *r = option < num_vlogo_opts ? vlogo_optlist+option : NULL;
if( !r )
{
libvlc_exception_raise( p_e );
libvlc_printerr( "Unknown marquee option" );
}
return r;
}
void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
unsigned option, const char *psz_value,
libvlc_exception_t *p_e )
{
vlogo_opt_t *opt = logo_option_bynumber( option, p_e );
printf("logo set string (%u)%s = %s.\n", option,
(opt?(opt->name):"<unkn>"),(psz_value?psz_value:"<null>"));
if( !opt ) return;
vlc_object_t *logo = get_logo_object( p_mi, p_e );
if( !logo ) return;
switch( opt->type )
{
case VLC_VAR_STRING:
var_SetString( logo, opt->name, psz_value );
break;
default:
libvlc_exception_raise( p_e );
libvlc_printerr( "Invalid argument" );
break;
}
vlc_object_release(logo);
}
void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi,
unsigned option, int value,
libvlc_exception_t *p_e )
{
vlogo_opt_t *opt = logo_option_bynumber( option, p_e );
printf("logo set integer (%u)%s = %i.\n",
option, (opt?(opt->name):"<unkn>"),value);
if( !opt ) return;
if( !opt->type ) /* libvlc_logo_enable */
{
vout_thread_t *vout = GetVout( p_mi, p_e );
libvlc_exception_clear( p_e );
if (vout)
{
vout_EnableFilter(vout, opt->name, value, false);
vlc_object_release(vout);
}
return;
}
vlc_object_t *logo = get_logo_object( p_mi, p_e );
if( !logo ) return;
switch( opt->type )
{
case VLC_VAR_INTEGER:
var_SetInteger(logo, opt->name, value);
break;
default:
libvlc_exception_raise( p_e );
libvlc_printerr( "Invalid argument" );
break;
}
vlc_object_release(logo);
}
int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi,
unsigned option, libvlc_exception_t *p_e )
{
vlogo_opt_t *opt = logo_option_bynumber( option, p_e );
printf("logo get integer (%u)%s.\n", option, opt?opt->name:"<unkn>");
if( !opt ) return 0;
vlc_object_t *logo = get_logo_object( p_mi, p_e );
if( !logo ) return 0;
int ret;
switch( opt->type )
{
case 0: /* libvlc_logo_enable */
ret = NULL != logo;
break;
case VLC_VAR_INTEGER:
ret = var_GetInteger(logo, opt->name);
break;
default:
libvlc_exception_raise( p_e );
libvlc_printerr( "Invalid argument" );
ret = 0;
break;
}
vlc_object_release(logo);
return ret;
}
...@@ -186,6 +186,7 @@ libvlc_video_get_aspect_ratio ...@@ -186,6 +186,7 @@ libvlc_video_get_aspect_ratio
libvlc_video_get_chapter_description libvlc_video_get_chapter_description
libvlc_video_get_crop_geometry libvlc_video_get_crop_geometry
libvlc_video_get_height libvlc_video_get_height
libvlc_video_get_logo_int
libvlc_video_get_marquee_option_as_int libvlc_video_get_marquee_option_as_int
libvlc_video_get_marquee_option_as_string libvlc_video_get_marquee_option_as_string
libvlc_video_get_scale libvlc_video_get_scale
...@@ -201,9 +202,11 @@ libvlc_video_get_width ...@@ -201,9 +202,11 @@ libvlc_video_get_width
libvlc_video_set_aspect_ratio libvlc_video_set_aspect_ratio
libvlc_video_set_crop_geometry libvlc_video_set_crop_geometry
libvlc_video_set_deinterlace libvlc_video_set_deinterlace
libvlc_video_set_key_input
libvlc_video_set_logo_int
libvlc_video_set_logo_string
libvlc_video_set_marquee_option_as_int libvlc_video_set_marquee_option_as_int
libvlc_video_set_marquee_option_as_string libvlc_video_set_marquee_option_as_string
libvlc_video_set_key_input
libvlc_video_set_mouse_input libvlc_video_set_mouse_input
libvlc_video_set_scale libvlc_video_set_scale
libvlc_video_set_spu libvlc_video_set_spu
......
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