#include <vlc_common.h>
#include <vlc_plugin.h>
-#include "vlc_filter.h"
+#include <vlc_filter.h>
+#include <vlc_url.h>
#include <vlc_image.h>
-#include <vlc_osd.h>
#ifdef LoadImage
# undef LoadImage
#define POSY_TEXT N_("Y coordinate")
#define POSY_LONGTEXT N_("Y coordinate of the logo. You can move the logo " \
"by left-clicking it." )
-#define TRANS_TEXT N_("Transparency of the logo")
-#define TRANS_LONGTEXT N_("Logo transparency value " \
+#define OPACITY_TEXT N_("Opacity of the logo")
+#define OPACITY_LONGTEXT N_("Logo opacity value " \
"(from 0 for full transparency to 255 for full opacity)." )
#define POS_TEXT N_("Logo position")
#define POS_LONGTEXT N_( \
"(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \
"also use combinations of these values, eg 6 = top-right).")
+#define LOGO_HELP N_("Use a local picture as logo on the video")
+
#define CFG_PREFIX "logo-"
static const int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
vlc_module_begin ()
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_SUBPIC )
-
+ set_help(LOGO_HELP)
set_capability( "sub filter", 0 )
set_callbacks( OpenSub, Close )
set_description( N_("Logo sub filter") )
add_shortcut( "logo" )
add_file( CFG_PREFIX "file", NULL, NULL, FILE_TEXT, FILE_LONGTEXT, false )
- add_integer( CFG_PREFIX "x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, true )
- add_integer( CFG_PREFIX "y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, true )
+ add_integer( CFG_PREFIX "x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, true )
+ add_integer( CFG_PREFIX "y", -1, NULL, POSY_TEXT, POSY_LONGTEXT, true )
/* 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 "repeat", -1, NULL, REPEAT_TEXT, REPEAT_LONGTEXT, true )
- add_integer_with_range( CFG_PREFIX "transparency", 255, 0, 255, NULL,
- TRANS_TEXT, TRANS_LONGTEXT, false )
+ add_integer_with_range( CFG_PREFIX "opacity", 255, 0, 255, NULL,
+ OPACITY_TEXT, OPACITY_LONGTEXT, false )
add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, false )
change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL )
*/
typedef struct
{
- char *psz_file; /* candidate for deletion -- not needed */
int i_delay; /* -1 means use default delay */
int i_alpha; /* -1 means use default alpha */
picture_t *p_pic;
int i_delay; /* default delay (0 - 60000 ms) */
int i_alpha; /* default alpha */
- char *psz_filename; /* --logo-file string ( is it really useful
- * to store it ? ) */
} logo_list_t;
/**
};
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[] = {
"logo-x",
"logo-y",
"logo-position",
- "logo-transparency",
+ "logo-opacity",
"logo-repeat",
NULL
};
static int LogoCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
-static void LogoListLoad( vlc_object_t *, logo_list_t * );
+static void LogoListLoad( vlc_object_t *, logo_list_t *, const char * );
static void LogoListUnload( logo_list_t * );
static logo_t *LogoListNext( logo_list_t *p_list, mtime_t i_date );
static logo_t *LogoListCurrent( logo_list_t *p_list );
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
+ char *psz_filename;
/* */
if( !b_sub && !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) )
return VLC_EGENERIC;
}
-
/* */
p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) );
if( !p_sys )
{
p_sys->p_blend = filter_NewBlend( VLC_OBJECT(p_filter),
- p_filter->fmt_in.i_codec );
+ &p_filter->fmt_in.video );
if( !p_sys->p_blend )
{
free( p_sys );
/* */
logo_list_t *p_list = &p_sys->list;
- p_list->psz_filename =
- var_CreateGetStringCommand( p_filter, "logo-file" );
- if( !p_list->psz_filename || *p_list->psz_filename == '\0' )
+ psz_filename = var_CreateGetStringCommand( p_filter, "logo-file" );
+ if( !psz_filename )
{
- msg_Err( p_this, "logo file not specified" );
-
if( p_sys->p_blend )
filter_DeleteBlend( p_sys->p_blend );
- free( p_list->psz_filename );
free( p_sys );
- return VLC_EGENERIC;
+ return VLC_ENOMEM;
}
- p_list->i_alpha = var_CreateGetIntegerCommand( p_filter,
- "logo-transparency");
+ if( *psz_filename == '\0' )
+ msg_Warn( p_this, "no logo file specified" );
+
+ p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity");
p_list->i_alpha = __MAX( __MIN( p_list->i_alpha, 255 ), 0 );
- p_list->i_delay =
- var_CreateGetIntegerCommand( p_filter, "logo-delay" );
- p_list->i_repeat =
- var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
+ p_list->i_delay = var_CreateGetIntegerCommand( p_filter, "logo-delay" );
+ p_list->i_repeat = var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
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 = 0;
vlc_mutex_init( &p_sys->lock );
- LogoListLoad( p_this, p_list );
+ LogoListLoad( p_this, p_list, psz_filename );
p_sys->b_spu_update = true;
p_sys->b_mouse_grab = false;
else
{
p_filter->pf_video_filter = FilterVideo;
- p_filter->pf_mouse = Mouse;
+ p_filter->pf_video_mouse = Mouse;
}
+ free( psz_filename );
return VLC_SUCCESS;
}
/* Create new SPU region */
memset( &fmt, 0, sizeof(video_format_t) );
fmt.i_chroma = VLC_CODEC_YUVA;
- fmt.i_aspect = VOUT_ASPECT_FACTOR;
fmt.i_sar_num = fmt.i_sar_den = 1;
fmt.i_width = fmt.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
fmt.i_height = fmt.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines;
/* where to locate the logo: */
if( p_sys->i_pos < 0 )
{ /* set to an absolute xy */
- p_region->i_align = OSD_ALIGN_RIGHT | OSD_ALIGN_TOP;
+ p_region->i_align = SUBPICTURE_ALIGN_RIGHT | SUBPICTURE_ALIGN_TOP;
p_spu->b_absolute = true;
}
else
else if( vlc_mouse_HasReleased( p_old, p_new, MOUSE_BUTTON_LEFT ) )
p_sys->b_mouse_grab = false;
- msg_Err( p_filter, "Mouse: %d G: %d", b_over, p_sys->b_mouse_grab );
-
if( p_sys->b_mouse_grab )
{
int i_dx, i_dy;
vlc_mouse_GetMotion( &i_dx, &i_dy, p_old, p_new );
- msg_Err( p_filter, "Mouse: d=%d:%d", i_dx, i_dy );
p_sys->i_pos_x = __MIN( __MAX( p_sys->i_pos_x + i_dx, 0 ),
p_filter->fmt_in.video.i_width - i_logo_w );
p_sys->i_pos_y = __MIN( __MAX( p_sys->i_pos_y + i_dy, 0 ),
p_filter->fmt_in.video.i_height - i_logo_h );
+
+ /* object under mouse has moved */
+ var_SetBool( p_filter->p_parent, "mouse-object", true );
+ }
+ else if( b_over )
+ {
+ /* object under mouse stoped moving */
+ var_SetBool( p_filter->p_parent, "mouse-object", false );
}
if( p_sys->b_mouse_grab || b_over )
return VLC_SUCCESS;
}
-
-#if 0
-/*****************************************************************************
- * MouseEvent: callback for mouse events
- *****************************************************************************/
-static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
- vlc_value_t oldval, vlc_value_t newval, void *p_data )
-{
- vout_thread_t *p_vout = p_data;
- assert( p_this == VLC_OBJECT(p_vout->p_sys->p_vout) );
- VLC_UNUSED(oldval);
-
- vout_sys_t *p_sys = p_vout->p_sys;
- const int i_delta = newval.i_int - oldval.i_int;
- const int i_bdown = var_GetInteger( p_sys->p_vout, "mouse-button-down" );
-
- if( (i_bdown & 0x1) == 0 )
- goto forward;
-
- int i_x, i_y;
- int i_dx = 0;
- int i_dy = 0;
- if( psz_var[6] == 'x' )
- {
- i_y = var_GetInteger( p_sys->p_vout, "mouse-y" );
- i_x = newval.i_int;
- i_dx = i_delta;
- }
- else if( psz_var[6] == 'y' )
- {
- i_y = newval.i_int;
- i_x = var_GetInteger( p_sys->p_vout, "mouse-x" );
- i_dy = i_delta;
- }
- else
- {
- goto forward;
- }
-
- /* FIXME missing lock */
- if( i_x < (int)p_sys->i_pos_x ||
- i_y < (int)p_sys->i_pos_y ||
- i_x > (int)(p_sys->i_pos_x + p_sys->i_width) ||
- i_y > (int)(p_sys->i_pos_y + p_sys->i_height) )
- goto forward;
-
- p_sys->i_pos_x = __MIN( __MAX( p_sys->i_pos_x + i_dx, 0 ),
- p_vout->output.i_width - p_sys->i_width );
- p_sys->i_pos_y = __MIN( __MAX( p_sys->i_pos_y + i_dy, 0 ),
- p_vout->output.i_height - p_sys->i_height );
- return VLC_SUCCESS;
-
-forward:
- return var_Set( p_vout, psz_var, newval );
-}
-#endif
-
/*****************************************************************************
* Callback to update params on the fly
*****************************************************************************/
if( !strcmp( psz_var, "logo-file" ) )
{
LogoListUnload( p_list );
- p_list->psz_filename = strdup( newval.psz_string );
- LogoListLoad( p_this, p_list );
+ LogoListLoad( p_this, p_list, newval.psz_string );
}
else if ( !strcmp( psz_var, "logo-x" ) )
{
{
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 );
}
/**
* It loads the logo image into memory.
*/
-static picture_t *LoadImage( vlc_object_t *p_this, char *psz_filename )
+static picture_t *LoadImage( vlc_object_t *p_this, const char *psz_filename )
{
+ if( !psz_filename )
+ return NULL;
+
video_format_t fmt_in;
video_format_Init( &fmt_in, 0 );
if( !p_image )
return NULL;
- picture_t *p_pic = image_ReadUrl( p_image, psz_filename, &fmt_in, &fmt_out );
+ char *psz_url = make_URI( psz_filename, NULL );
+ picture_t *p_pic = image_ReadUrl( p_image, psz_url, &fmt_in, &fmt_out );
+ free( psz_url );
image_HandlerDelete( p_image );
return p_pic;
/**
* It loads the logo images into memory.
*
- * Read the logo-file input switch, obtaining a list of images and associated
- * durations and transparencies. Store the image(s), and times. An image
- * without a stated time or transparency will use the logo-delay and
- * logo-transparency values.
+ * Read the logo-file input switch, obtaining a list of images and
+ * associated durations and transparencies. Store the image(s), and
+ * times. An image without a stated time or opacity will use the
+ * 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 )
{
char *psz_list; /* the list: <logo>[,[<delay>[,[<alpha>]]]][;...] */
+ char *psz_original;
unsigned int i;
logo_t *p_logo; /* the parsing's result */
p_logo_list->i_counter = 0;
p_logo_list->i_next_pic = 0;
- psz_list = strdup( p_logo_list->psz_filename );
+ psz_original = psz_list = strdup( psz_filename );
+ if( !psz_list )
+ abort();
/* Count the number logos == number of ';' + 1 */
p_logo_list->i_count = 1;
p_logo_list->p_logo =
p_logo = calloc( p_logo_list->i_count, sizeof(*p_logo) );
+ if( !p_logo )
+ abort();
/* Fill the data */
for( i = 0; i < p_logo_list->i_count; i++ )
*p_c = '\0';
}
- p_logo[i].psz_file = strdup( psz_list );
- p_logo[i].p_pic = LoadImage( p_this, p_logo[i].psz_file );
-
+ msg_Dbg( p_this, "logo file name %s, delay %d, alpha %d",
+ psz_list, p_logo[i].i_delay, p_logo[i].i_alpha );
+ p_logo[i].p_pic = LoadImage( p_this, psz_list );
if( !p_logo[i].p_pic )
{
msg_Warn( p_this, "error while loading logo %s, will be skipped",
- p_logo[i].psz_file );
+ psz_list );
}
if( p_c )
psz_list = &p_c[1];
}
- for( i = 0; i < p_logo_list->i_count; i++ )
- {
- msg_Dbg( p_this, "logo file name %s, delay %d, alpha %d",
- p_logo[i].psz_file, p_logo[i].i_delay, p_logo[i].i_alpha );
- }
-
/* initialize so that on the first update it will wrap back to 0 */
p_logo_list->i_counter = p_logo_list->i_count - 1;
+
+ free( psz_original );
}
/**
*/
static void LogoListUnload( logo_list_t *p_list )
{
- free( p_list->psz_filename );
-
for( unsigned i = 0; i < p_list->i_count; i++ )
{
logo_t *p_logo = &p_list->p_logo[i];
- free( p_logo->psz_file );
if( p_logo->p_pic )
- {
picture_Release( p_logo->p_pic );
- p_logo->p_pic = NULL;
- }
}
+ free( p_list->p_logo );
}
/**