]> git.sesse.net Git - vlc/commitdiff
Add snapshot command to rc interface and make snapshot-width and snapshot-height...
authorJean-Paul Saman <jpsaman@videolan.org>
Fri, 26 Oct 2007 09:41:18 +0000 (09:41 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Fri, 26 Oct 2007 09:41:18 +0000 (09:41 +0000)
modules/control/rc.c
src/libvlc-module.c
src/video_output/vout_intf.c

index 230a8ab171332501ff914081e22b8329b3d14007..6f2f6813e56ceb02a4703079a4d266a67fa8a63e 100644 (file)
@@ -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" ) )
         {
index 0ac83a85cd05f6d742e8c9284eda6b3acbf278e4..70d283408002220ce566c32eb118f0db54c60969 100644 (file)
@@ -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 );
index 34452d44bafae2efc0c6272de74371d0d87d30fa..bf9481d3c109e49e5da78ec3569e613c57ac6993 100644 (file)
@@ -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;
 }
-