From 1d67f7b18284ba4268998880d2e40bd4ed933dee Mon Sep 17 00:00:00 2001 From: Jean-Paul Saman Date: Fri, 26 Oct 2007 09:41:18 +0000 Subject: [PATCH] Add snapshot command to rc interface and make snapshot-width and snapshot-height user modifiable. --- modules/control/rc.c | 25 +++++++++++++++++-------- src/libvlc-module.c | 14 ++++++++++++++ src/video_output/vout_intf.c | 10 +++++----- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/modules/control/rc.c b/modules/control/rc.c index 230a8ab171..6f2f6813e5 100644 --- a/modules/control/rc.c +++ b/modules/control/rc.c @@ -408,6 +408,7 @@ static void RegisterCallbacks( intf_thread_t *p_intf ) ADD( "vratio", STRING, VideoConfig ) ADD( "vcrop", STRING, VideoConfig ) ADD( "vzoom", STRING, VideoConfig ) + ADD( "snapshot", VOID, VideoConfig ) /* audio commands */ ADD( "volume", STRING, Volume ) @@ -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(_("| vcrop [X] . . . . . . . . . . . set/get video crop")); msg_rc(_("| vzoom [X] . . . . . . . . . . . set/get video zoom")); + msg_rc(_("| snapshot . . . . . . . . . . . . take video snapshot")); msg_rc(_("| strack [X] . . . . . . . . . set/get subtitles track")); msg_rc(_("| key [hotkey name] . . . . . . simulate hotkey press")); 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, input_thread_t *p_input = NULL; vout_thread_t * p_vout; const char * psz_variable; - vlc_value_t val_name; int i_error; 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, { psz_variable = "aspect-ratio"; } - else /* if( !strcmp( psz_cmd, "vzoom" ) ) */ + else if( !strcmp( psz_cmd, "vzoom" ) ) { psz_variable = "zoom"; } - - - /* 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); + else if( !strcmp( psz_cmd, "snapshot" ) ) + { + psz_variable = "video-snapshot"; + } if( newval.psz_string && *newval.psz_string ) { @@ -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 ); } } + else if( !strcmp( psz_cmd, "snapshot" ) ) + { + i_error = var_Set( p_vout, psz_variable, newval ); + } else { /* get */ + vlc_value_t val_name; vlc_value_t val, text; int i; float f_value = 0.; @@ -1708,6 +1712,11 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd, 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 ); if( !strcmp( psz_variable, "zoom" ) ) { diff --git a/src/libvlc-module.c b/src/libvlc-module.c index 0ac83a85cd..70d2834080 100644 --- a/src/libvlc-module.c +++ b/src/libvlc-module.c @@ -444,6 +444,16 @@ static const char *ppsz_pos_descriptions[] = #define SNAP_SEQUENTIAL_LONGTEXT N_( \ "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_LONGTEXT N_( \ "This forces the cropping of the source video. " \ @@ -1475,6 +1485,10 @@ vlc_module_begin(); SNAP_PREVIEW_LONGTEXT, VLC_FALSE ); add_bool( "snapshot-sequential", VLC_FALSE, NULL, SNAP_SEQUENTIAL_TEXT, 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 ); add_integer( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE ); diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c index 34452d44ba..bf9481d3c1 100644 --- a/src/video_output/vout_intf.c +++ b/src/video_output/vout_intf.c @@ -202,6 +202,8 @@ void vout_IntfInit( vout_thread_t *p_vout ) VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_vout, "snapshot-num", VLC_VAR_INTEGER ); 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, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); @@ -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; /* FIXME: should not be hardcoded. We should be able to specify the snapshot size (snapshot-width and snapshot-height). */ - fmt_out.i_width = 320; - fmt_out.i_height = 200; + fmt_out.i_width = var_GetInteger( p_vout, "snapshot-width" ); + fmt_out.i_height = var_GetInteger( p_vout, "snapshot-height" ); fmt_out.i_chroma = VLC_FOURCC( 'p','n','g',' ' ); + p_block = ( block_t* ) image_Write( p_image, p_pic, &fmt_in, &fmt_out ); if( !p_block ) { @@ -571,7 +574,6 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) return VLC_SUCCESS; } - #if defined(__APPLE__) || defined(SYS_BEOS) 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 ) * Did the user specify a directory? If not, path = NULL. */ path = utf8_opendir ( (const char *)val.psz_string ); - if ( path != NULL ) { 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, p_vout->i_title_position = newval.i_int; return VLC_SUCCESS; } - -- 2.39.2