Commit 1d67f7b1 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Add snapshot command to rc interface and make snapshot-width and snapshot-height user modifiable.

parent a8de7281
...@@ -408,6 +408,7 @@ static void RegisterCallbacks( intf_thread_t *p_intf ) ...@@ -408,6 +408,7 @@ static void RegisterCallbacks( intf_thread_t *p_intf )
ADD( "vratio", STRING, VideoConfig ) ADD( "vratio", STRING, VideoConfig )
ADD( "vcrop", STRING, VideoConfig ) ADD( "vcrop", STRING, VideoConfig )
ADD( "vzoom", STRING, VideoConfig ) ADD( "vzoom", STRING, VideoConfig )
ADD( "snapshot", VOID, VideoConfig )
/* audio commands */ /* audio commands */
ADD( "volume", STRING, Volume ) ADD( "volume", STRING, Volume )
...@@ -883,6 +884,7 @@ static void Help( intf_thread_t *p_intf, vlc_bool_t b_longhelp) ...@@ -883,6 +884,7 @@ static void Help( intf_thread_t *p_intf, vlc_bool_t b_longhelp)
msg_rc(_("| vratio [X] . . . . . . . set/get video aspect ratio")); msg_rc(_("| vratio [X] . . . . . . . set/get video aspect ratio"));
msg_rc(_("| vcrop [X] . . . . . . . . . . . set/get video crop")); msg_rc(_("| vcrop [X] . . . . . . . . . . . set/get video crop"));
msg_rc(_("| vzoom [X] . . . . . . . . . . . set/get video zoom")); msg_rc(_("| vzoom [X] . . . . . . . . . . . set/get video zoom"));
msg_rc(_("| snapshot . . . . . . . . . . . . take video snapshot"));
msg_rc(_("| strack [X] . . . . . . . . . set/get subtitles track")); msg_rc(_("| strack [X] . . . . . . . . . set/get subtitles track"));
msg_rc(_("| key [hotkey name] . . . . . . simulate hotkey press")); msg_rc(_("| key [hotkey name] . . . . . . simulate hotkey press"));
msg_rc(_("| menu . . [on|off|up|down|left|right|select] use menu")); msg_rc(_("| menu . . [on|off|up|down|left|right|select] use menu"));
...@@ -1634,7 +1636,6 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1634,7 +1636,6 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
input_thread_t *p_input = NULL; input_thread_t *p_input = NULL;
vout_thread_t * p_vout; vout_thread_t * p_vout;
const char * psz_variable; const char * psz_variable;
vlc_value_t val_name;
int i_error; int i_error;
p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE ); p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );
...@@ -1654,16 +1655,14 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1654,16 +1655,14 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
{ {
psz_variable = "aspect-ratio"; psz_variable = "aspect-ratio";
} }
else /* if( !strcmp( psz_cmd, "vzoom" ) ) */ else if( !strcmp( psz_cmd, "vzoom" ) )
{ {
psz_variable = "zoom"; psz_variable = "zoom";
} }
else if( !strcmp( psz_cmd, "snapshot" ) )
{
/* Get the descriptive name of the variable */ psz_variable = "video-snapshot";
var_Change( p_vout, psz_variable, VLC_VAR_GETTEXT, }
&val_name, NULL );
if( !val_name.psz_string ) val_name.psz_string = strdup(psz_variable);
if( newval.psz_string && *newval.psz_string ) if( newval.psz_string && *newval.psz_string )
{ {
...@@ -1679,9 +1678,14 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1679,9 +1678,14 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
i_error = var_Set( p_vout, psz_variable, newval ); i_error = var_Set( p_vout, psz_variable, newval );
} }
} }
else if( !strcmp( psz_cmd, "snapshot" ) )
{
i_error = var_Set( p_vout, psz_variable, newval );
}
else else
{ {
/* get */ /* get */
vlc_value_t val_name;
vlc_value_t val, text; vlc_value_t val, text;
int i; int i;
float f_value = 0.; float f_value = 0.;
...@@ -1708,6 +1712,11 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1708,6 +1712,11 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Get the descriptive name of the variable */
var_Change( p_vout, psz_variable, VLC_VAR_GETTEXT,
&val_name, NULL );
if( !val_name.psz_string ) val_name.psz_string = strdup(psz_variable);
msg_rc( "+----[ %s ]", val_name.psz_string ); msg_rc( "+----[ %s ]", val_name.psz_string );
if( !strcmp( psz_variable, "zoom" ) ) if( !strcmp( psz_variable, "zoom" ) )
{ {
......
...@@ -444,6 +444,16 @@ static const char *ppsz_pos_descriptions[] = ...@@ -444,6 +444,16 @@ static const char *ppsz_pos_descriptions[] =
#define SNAP_SEQUENTIAL_LONGTEXT N_( \ #define SNAP_SEQUENTIAL_LONGTEXT N_( \
"Use sequential numbers instead of timestamps for snapshot numbering") "Use sequential numbers instead of timestamps for snapshot numbering")
#define SNAP_WIDTH_TEXT N_("Video snapshot width")
#define SNAP_WIDTH_LONGTEXT N_( \
"You can enforce the width of the video snapshot. By default " \
"it will be 320 pixels." )
#define SNAP_HEIGHT_TEXT N_("Video snapshot height")
#define SNAP_HEIGHT_LONGTEXT N_( \
"You can enforce the height of the video snapshot. By default " \
"it will be 200 pixels." )
#define CROP_TEXT N_("Video cropping") #define CROP_TEXT N_("Video cropping")
#define CROP_LONGTEXT N_( \ #define CROP_LONGTEXT N_( \
"This forces the cropping of the source video. " \ "This forces the cropping of the source video. " \
...@@ -1475,6 +1485,10 @@ vlc_module_begin(); ...@@ -1475,6 +1485,10 @@ vlc_module_begin();
SNAP_PREVIEW_LONGTEXT, VLC_FALSE ); SNAP_PREVIEW_LONGTEXT, VLC_FALSE );
add_bool( "snapshot-sequential", VLC_FALSE, NULL, SNAP_SEQUENTIAL_TEXT, add_bool( "snapshot-sequential", VLC_FALSE, NULL, SNAP_SEQUENTIAL_TEXT,
SNAP_SEQUENTIAL_LONGTEXT, VLC_FALSE ); SNAP_SEQUENTIAL_LONGTEXT, VLC_FALSE );
add_integer( "snapshot-width", 320, NULL, SNAP_WIDTH_TEXT,
SNAP_WIDTH_LONGTEXT, VLC_TRUE );
add_integer( "snapshot-height", 200, NULL, SNAP_HEIGHT_TEXT,
SNAP_HEIGHT_LONGTEXT, VLC_TRUE );
set_section( N_("Window properties" ), NULL ); set_section( N_("Window properties" ), NULL );
add_integer( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE ); add_integer( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE );
......
...@@ -202,6 +202,8 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -202,6 +202,8 @@ void vout_IntfInit( vout_thread_t *p_vout )
VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_vout, "snapshot-num", VLC_VAR_INTEGER ); var_Create( p_vout, "snapshot-num", VLC_VAR_INTEGER );
var_SetInteger( p_vout, "snapshot-num", 1 ); var_SetInteger( p_vout, "snapshot-num", 1 );
var_Create( p_vout, "snapshot-width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "snapshot-height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
...@@ -516,9 +518,10 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -516,9 +518,10 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
fmt_out.i_sar_num = fmt_out.i_sar_den = 1; fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
/* FIXME: should not be hardcoded. We should be able to /* FIXME: should not be hardcoded. We should be able to
specify the snapshot size (snapshot-width and snapshot-height). */ specify the snapshot size (snapshot-width and snapshot-height). */
fmt_out.i_width = 320; fmt_out.i_width = var_GetInteger( p_vout, "snapshot-width" );
fmt_out.i_height = 200; fmt_out.i_height = var_GetInteger( p_vout, "snapshot-height" );
fmt_out.i_chroma = VLC_FOURCC( 'p','n','g',' ' ); fmt_out.i_chroma = VLC_FOURCC( 'p','n','g',' ' );
p_block = ( block_t* ) image_Write( p_image, p_pic, &fmt_in, &fmt_out ); p_block = ( block_t* ) image_Write( p_image, p_pic, &fmt_in, &fmt_out );
if( !p_block ) if( !p_block )
{ {
...@@ -571,7 +574,6 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -571,7 +574,6 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
#if defined(__APPLE__) || defined(SYS_BEOS) #if defined(__APPLE__) || defined(SYS_BEOS)
if( !val.psz_string && p_vout->p_libvlc->psz_homedir ) if( !val.psz_string && p_vout->p_libvlc->psz_homedir )
{ {
...@@ -658,7 +660,6 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -658,7 +660,6 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
* Did the user specify a directory? If not, path = NULL. * Did the user specify a directory? If not, path = NULL.
*/ */
path = utf8_opendir ( (const char *)val.psz_string ); path = utf8_opendir ( (const char *)val.psz_string );
if ( path != NULL ) if ( path != NULL )
{ {
char *psz_prefix = var_GetNonEmptyString( p_vout, "snapshot-prefix" ); char *psz_prefix = var_GetNonEmptyString( p_vout, "snapshot-prefix" );
...@@ -1193,4 +1194,3 @@ static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1193,4 +1194,3 @@ static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
p_vout->i_title_position = newval.i_int; p_vout->i_title_position = newval.i_int;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
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