# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <math.h>
static void End ( vout_thread_t * );
static void Render ( vout_thread_t *, picture_t * );
-static int SendEvents ( vlc_object_t *, char const *,
- vlc_value_t, vlc_value_t, void * );
static int MouseEvent ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
#define CFG_PREFIX "puzzle-"
-vlc_module_begin();
- set_description( _("Puzzle interactive game video filter") );
- set_shortname( _( "Puzzle" ));
- set_capability( "video filter", 0 );
- set_category( CAT_VIDEO );
- set_subcategory( SUBCAT_VIDEO_VFILTER );
+vlc_module_begin ()
+ set_description( N_("Puzzle interactive game video filter") )
+ set_shortname( N_( "Puzzle" ))
+ set_capability( "video filter", 0 )
+ set_category( CAT_VIDEO )
+ set_subcategory( SUBCAT_VIDEO_VFILTER )
add_integer_with_range( CFG_PREFIX "rows", 4, 1, 128, NULL,
- ROWS_TEXT, ROWS_LONGTEXT, false );
+ ROWS_TEXT, ROWS_LONGTEXT, false )
add_integer_with_range( CFG_PREFIX "cols", 4, 1, 128, NULL,
- COLS_TEXT, COLS_LONGTEXT, false );
+ COLS_TEXT, COLS_LONGTEXT, false )
add_bool( CFG_PREFIX "black-slot", 0, NULL,
- BLACKSLOT_TEXT, BLACKSLOT_LONGTEXT, false );
+ BLACKSLOT_TEXT, BLACKSLOT_LONGTEXT, false )
- set_callbacks( Create, Destroy );
-vlc_module_end();
+ set_callbacks( Create, Destroy )
+vlc_module_end ()
-static const char *ppsz_filter_options[] = {
+static const char *const ppsz_filter_options[] = {
"rows", "cols", "black-slot", NULL
};
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
- {
- msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
- }
p_vout->p_sys->p_image = image_HandlerCreate( p_vout );
*****************************************************************************/
static int Init( vout_thread_t *p_vout )
{
- int i_index;
- picture_t *p_pic;
video_format_t fmt;
memset( &fmt, 0, sizeof( video_format_t ) );
return VLC_EGENERIC;
}
- var_AddCallback( p_vout->p_sys->p_vout, "mouse-x", MouseEvent, p_vout );
- var_AddCallback( p_vout->p_sys->p_vout, "mouse-y", MouseEvent, p_vout );
- var_AddCallback( p_vout->p_sys->p_vout, "mouse-clicked",
- MouseEvent, p_vout);
+ vout_filter_AllocateDirectBuffers( p_vout, VOUT_MAX_PICTURES );
- ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
- ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
- ADD_PARENT_CALLBACKS( SendEventsToChild );
+ vout_filter_AddChild( p_vout, p_vout->p_sys->p_vout, MouseEvent );
return VLC_SUCCESS;
}
*****************************************************************************/
static void End( vout_thread_t *p_vout )
{
- int i_index;
+ vout_sys_t *p_sys = p_vout->p_sys;
- /* Free the fake output buffers we allocated */
- for( i_index = I_OUTPUTPICTURES ; i_index ; )
- {
- i_index--;
- free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
- }
+ vout_filter_DelChild( p_vout, p_sys->p_vout, MouseEvent );
+ vout_CloseAndRelease( p_sys->p_vout );
- var_DelCallback( p_vout->p_sys->p_vout, "mouse-x", MouseEvent, p_vout);
- var_DelCallback( p_vout->p_sys->p_vout, "mouse-y", MouseEvent, p_vout);
- var_DelCallback( p_vout->p_sys->p_vout, "mouse-clicked", MouseEvent, p_vout);
+ vout_filter_ReleaseDirectBuffers( p_vout );
}
#define SHUFFLE_WIDTH 81
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
- if( p_vout->p_sys->p_vout )
- {
- DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
- vlc_object_detach( p_vout->p_sys->p_vout );
- vout_Destroy( p_vout->p_sys->p_vout );
- }
-
image_HandlerDelete( p_vout->p_sys->p_image );
free( p_vout->p_sys->pi_order );
- DEL_PARENT_CALLBACKS( SendEventsToChild );
-
free( p_vout->p_sys );
}
while( ( p_outpic = vout_CreatePicture( p_vout->p_sys->p_vout, 0, 0, 0 ) )
== NULL )
{
- if( p_vout->b_die || p_vout->b_error )
+ if( !vlc_object_alive (p_vout) || p_vout->b_error )
{
return;
}
msleep( VOUT_OUTMEM_SLEEP );
}
- vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );
+ p_outpic->date = p_pic->date;
for( i_plane = 0; i_plane < p_outpic->i_planes; i_plane++ )
{
uint8_t color = ( i_plane == Y_PLANE ? 0x0 : 0x80 );
for( ; i_row < i_last_row; i_row++, i_orow++ )
{
- p_vout->p_libvlc->
- pf_memset( p_out->p_pixels + i_row * i_pitch
+ vlc_memset( p_out->p_pixels + i_row * i_pitch
+ i_col * i_pitch / i_cols,
color, i_pitch / i_cols );
}
{
for( ; i_row < i_last_row; i_row++, i_orow++ )
{
- p_vout->p_libvlc->
- pf_memcpy( p_out->p_pixels + i_row * i_pitch
+ vlc_memcpy( p_out->p_pixels + i_row * i_pitch
+ i_col * i_pitch / i_cols,
p_in->p_pixels + i_orow * i_pitch
+ i_ocol * i_pitch / i_cols,
int i_last_row = i_row + 1;
i_row *= p_in->i_lines / i_rows;
i_last_row *= p_in->i_lines / i_rows;
- p_vout->p_libvlc->
- pf_memset( p_out->p_pixels + i_row * i_pitch
+ vlc_memset( p_out->p_pixels + i_row * i_pitch
+ i_col * i_pitch / i_cols,
0xff, i_pitch / i_cols );
for( ; i_row < i_last_row; i_row++ )
+ (i_col+1) * i_pitch / i_cols - 1 ] = 0xff;
}
i_row--;
- p_vout->p_libvlc->
- pf_memset( p_out->p_pixels + i_row * i_pitch
+ vlc_memset( p_out->p_pixels + i_row * i_pitch
+ i_col * i_pitch / i_cols,
0xff, i_pitch / i_cols );
}
vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );
}
-/*****************************************************************************
- * SendEvents: forward mouse and keyboard events to the parent p_vout
- *****************************************************************************/
-static int SendEvents( vlc_object_t *p_this, char const *psz_var,
- vlc_value_t oldval, vlc_value_t newval, void *p_data )
-{
- VLC_UNUSED(p_this); VLC_UNUSED(oldval);
-
- var_Set( (vlc_object_t *)p_data, psz_var, newval );
-
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * SendEventsToChild: forward events to the child/children vout
- *****************************************************************************/
-static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
- vlc_value_t oldval, vlc_value_t newval, void *p_data )
-{
- VLC_UNUSED(p_data); VLC_UNUSED(oldval);
- vout_thread_t *p_vout = (vout_thread_t *)p_this;
- var_Set( p_vout->p_sys->p_vout, psz_var, newval );
- return VLC_SUCCESS;
-}
-
/*****************************************************************************
* 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 )
{
- VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(newval);
- vout_thread_t *p_vout = (vout_thread_t*)p_data;
+ vout_thread_t *p_vout = p_data;
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
int i_x, i_y;
int i_v;
+ /* FIXME missing lock */
#define MOUSE_DOWN 1
#define MOUSE_CLICKED 2
#define MOUSE_MOVE_X 4
p_vout->p_sys->b_finished = finished( p_vout->p_sys );
}
}
+ /* FIXME do we want to forward it or not ? */
+ var_Set( p_vout, psz_var, newval );
return VLC_SUCCESS;
}