# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_interface.h>
#include <vlc_input.h>
#define CACHE_LONGTEXT N_( "Snapshot cache size (number of images to keep)." )
-vlc_module_begin( );
- set_description( _( "Snapshot module" ) );
- set_shortname( _("Snapshot") );
+vlc_module_begin ()
+ set_description( N_( "Snapshot output" ) )
+ set_shortname( N_("Snapshot") )
- set_category( CAT_VIDEO );
- set_subcategory( SUBCAT_VIDEO_VOUT );
- set_capability( "video output", 1 );
+ set_category( CAT_VIDEO )
+ set_subcategory( SUBCAT_VIDEO_VOUT )
+ set_capability( "video output", 1 )
- add_integer( "snapshot-width", 320, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, false );
- add_integer( "snapshot-height", 200, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, false );
- add_string( "snapshot-chroma", "RV32", NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true );
- add_integer( "snapshot-cache-size", 50, NULL, CACHE_TEXT, CACHE_LONGTEXT, true );
+ add_integer( "snapshot-width", 320, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, false )
+ add_integer( "snapshot-height", 200, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, false )
+ add_string( "snapshot-chroma", "RV32", NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true )
+ add_integer( "snapshot-cache-size", 50, NULL, CACHE_TEXT, CACHE_LONGTEXT, true )
- set_callbacks( Create, Destroy );
-vlc_module_end();
+ set_callbacks( Create, Destroy )
+vlc_module_end ()
/*****************************************************************************
* vout_sys_t: video output descriptor
*****************************************************************************/
+typedef struct snapshot_t
+{
+ uint8_t *p_data; /* Data area */
+
+ int i_width; /* In pixels */
+ int i_height; /* In pixels */
+ int i_datasize; /* In bytes */
+ mtime_t date; /* Presentation time */
+} snapshot_t;
+
struct vout_sys_t
{
snapshot_t **p_list; /* List of available snapshots */
msg_Err( p_vout, "snapshot-chroma should be 4 characters long" );
return VLC_EGENERIC;
}
- i_chroma = VLC_FOURCC( psz_chroma[0], psz_chroma[1],
- psz_chroma[2], psz_chroma[3] );
+ i_chroma = vlc_fourcc_GetCodec( VIDEO_ES,
+ VLC_FOURCC( psz_chroma[0], psz_chroma[1],
+ psz_chroma[2], psz_chroma[3] ) );
free( psz_chroma );
}
else
/* Define the bitmasks */
switch( i_chroma )
{
- case VLC_FOURCC( 'R','V','1','5' ):
+ case VLC_CODEC_RGB15;
p_vout->output.i_rmask = 0x001f;
p_vout->output.i_gmask = 0x03e0;
p_vout->output.i_bmask = 0x7c00;
break;
- case VLC_FOURCC( 'R','V','1','6' ):
+ case VLC_CODEC_RGB16;
p_vout->output.i_rmask = 0x001f;
p_vout->output.i_gmask = 0x07e0;
p_vout->output.i_bmask = 0xf800;
break;
- case VLC_FOURCC( 'R','V','2','4' ):
+ case VLC_CODEC_RGB24;
p_vout->output.i_rmask = 0xff0000;
p_vout->output.i_gmask = 0x00ff00;
p_vout->output.i_bmask = 0x0000ff;
break;
- case VLC_FOURCC( 'R','V','3','2' ):
+ case VLC_CODEC_RGB32:
p_vout->output.i_rmask = 0xff0000;
p_vout->output.i_gmask = 0x00ff00;
p_vout->output.i_bmask = 0x0000ff;
p_snapshot->i_height = i_height;
p_snapshot->i_datasize = i_datasize;
p_snapshot->date = 0;
- p_snapshot->p_data = ( char* ) malloc( i_datasize );
+ p_snapshot->p_data = malloc( i_datasize );
if( p_snapshot->p_data == NULL )
+ {
+ free( p_snapshot );
return VLC_ENOMEM;
+ }
p_vout->p_sys->p_list[i_index] = p_snapshot;
}
if( var_Create( p_vout->p_sys->p_input, "snapshot-id", VLC_VAR_INTEGER ) )
{
- msg_Err( p_vout, "Cannot create snapshot-id variable in p_input (%d).",
- p_vout->p_sys->p_input->i_object_id );
+ msg_Err( p_vout, "Cannot create snapshot-id variable in p_input(%p).",
+ p_vout->p_sys->p_input );
return VLC_EGENERIC;
}
/* Register the snapshot vout module at the input level */
- val.i_int = p_vout->i_object_id;
+ val.p_address = p_vout;
if( var_Set( p_vout->p_sys->p_input, "snapshot-id", val ) )
{
- msg_Err( p_vout, "Cannot register snapshot-id in p_input (%d).",
- p_vout->p_sys->p_input->i_object_id );
+ msg_Err( p_vout, "Cannot register snapshot-id in p_input(%p).",
+ p_vout->p_sys->p_input );
return VLC_EGENERIC;
}
/* Return the position in ms from the start of the movie */
static mtime_t snapshot_GetMovietime( vout_thread_t *p_vout )
{
- input_thread_t* p_input;
- vlc_value_t val;
- mtime_t i_result;
-
- p_input = p_vout->p_sys->p_input;
+ input_thread_t *p_input = p_vout->p_sys->p_input;
if( !p_input )
return 0;
- var_Get( p_input, "time", &val );
-
- i_result = val.i_time - p_input->i_pts_delay;
-
- return( i_result / 1000 );
+ return var_GetTime( p_input, "time" ) / 1000;
}
/*****************************************************************************
i_index = p_vout->p_sys->i_index;
- p_vout->p_libvlc->pf_memcpy( p_vout->p_sys->p_list[i_index]->p_data,
- p_pic->p->p_pixels,
- p_vout->p_sys->i_datasize );
+ vlc_memcpy( p_vout->p_sys->p_list[i_index]->p_data, p_pic->p->p_pixels,
+ p_vout->p_sys->i_datasize );
i_date = snapshot_GetMovietime( p_vout );