]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_intf.c
For consistency, remove references to vlc from libvlc
[vlc] / src / video_output / vout_intf.c
index 1fe8ffd7922c8a2e8d8181313c97ca65d504b35b..8f0944f96f14d81cd1c75b3dec597353854e36da 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                                /* free() */
 
 #include <vlc/vlc.h>
+
+#include <stdio.h>
+#include <stdlib.h>                                                /* free() */
+#include <sys/types.h>                                          /* opendir() */
+#include <dirent.h>                                             /* opendir() */
+
 #include <vlc/intf.h>
 #include <vlc_block.h>
 
@@ -87,7 +92,7 @@ void *vout_RequestWindow( vout_thread_t *p_vout,
     *pi_height_hint = p_vout->i_window_height;
 
     /* Check whether someone provided us with a window ID */
-    var_Get( p_vout->p_vlc, "drawable", &val );
+    var_Get( p_vout->p_libvlc, "drawable", &val );
     if( val.i_int ) return (void *)val.i_int;
 
     /* Find if the main interface supports embedding */
@@ -185,8 +190,14 @@ void vout_IntfInit( vout_thread_t *p_vout )
 
     /* Create a few object variables we'll need later on */
     var_Create( p_vout, "snapshot-path", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "snapshot-prefix", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "snapshot-format", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "snapshot-preview", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "snapshot-sequential",
+                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, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
@@ -432,10 +443,12 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
 {
     image_handler_t *p_image = image_HandlerCreate( p_vout );
     video_format_t fmt_in = {0}, fmt_out = {0};
-    char *psz_filename;
+    char *psz_filename = NULL;
     subpicture_t *p_subpic;
     picture_t *p_pif;
     vlc_value_t val, format;
+    DIR *path;
+
     int i_ret;
 
     var_Get( p_vout, "snapshot-path", &val );
@@ -537,14 +550,14 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
 
 
 #if defined(__APPLE__) || defined(SYS_BEOS)
-    if( !val.psz_string && p_vout->p_vlc->psz_homedir )
+    if( !val.psz_string && p_vout->p_libvlc->psz_homedir )
     {
         asprintf( &val.psz_string, "%s/Desktop",
-                  p_vout->p_vlc->psz_homedir );
+                  p_vout->p_libvlc->psz_homedir );
     }
 
 #elif defined(WIN32) && !defined(UNDER_CE)
-    if( !val.psz_string && p_vout->p_vlc->psz_homedir )
+    if( !val.psz_string && p_vout->p_libvlc->psz_homedir )
     {
         /* Get the My Pictures folder path */
 
@@ -591,7 +604,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
         if( p_mypicturesdir == NULL )
         {
             asprintf( &val.psz_string, "%s/" CONFIG_DIR,
-                      p_vout->p_vlc->psz_homedir );
+                      p_vout->p_libvlc->psz_homedir );
         }
         else
         {
@@ -601,16 +614,16 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
     }
 
 #else
-    if( !val.psz_string && p_vout->p_vlc->psz_homedir )
+    if( !val.psz_string && p_vout->p_libvlc->psz_homedir )
     {
         asprintf( &val.psz_string, "%s/" CONFIG_DIR,
-                  p_vout->p_vlc->psz_homedir );
+                  p_vout->p_libvlc->psz_homedir );
     }
 #endif
 
     if( !val.psz_string )
     {
-        msg_Err( p_vout, "no directory specified for snapshots" );
+        msg_Err( p_vout, "no path specified for snapshots" );
         return VLC_EGENERIC;
     }
     var_Get( p_vout, "snapshot-format", &format );
@@ -620,9 +633,44 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
         format.psz_string = strdup( "png" );
     }
 
-    asprintf( &psz_filename, "%s/vlcsnap-%u.%s", val.psz_string,
-              (unsigned int)(p_pic->date / 100000) & 0xFFFFFF,
-              format.psz_string );
+    /*
+     * Did the user specify a directory? If not, path = NULL.
+     */
+    path = opendir ( (const char *)val.psz_string  );
+
+    if ( path != NULL )
+    {
+        char *psz_prefix = var_GetString( p_vout, "snapshot-prefix" );
+        if( !psz_prefix ) psz_prefix = strdup( "vlcsnap-" );
+
+        closedir( path );
+        if( var_GetBool( p_vout, "snapshot-sequential" ) == VLC_TRUE )
+        {
+            int i_num = var_GetInteger( p_vout, "snapshot-num" );
+            FILE *p_file;
+            do
+            {
+                asprintf( &psz_filename, "%s/%s%05d.%s", val.psz_string,
+                          psz_prefix, i_num++, format.psz_string );
+            }
+            while( ( p_file = fopen( psz_filename, "r" ) ) && !fclose( p_file ) );
+            var_SetInteger( p_vout, "snapshot-num", i_num );
+        }
+        else
+        {
+            asprintf( &psz_filename, "%s/%s%u.%s", val.psz_string,
+                      psz_prefix,
+                      (unsigned int)(p_pic->date / 100000) & 0xFFFFFF,
+                      format.psz_string );
+        }
+
+        free( psz_prefix );
+    }
+    else // The user specified a full path name (including file name)
+    {
+        asprintf ( &psz_filename, "%s", val.psz_string );
+    }
+
     free( val.psz_string );
     free( format.psz_string );
 
@@ -682,6 +730,59 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
     return VLC_SUCCESS;
 }
 
+/*****************************************************************************
+ * Handle filters
+ *****************************************************************************/
+
+void vout_EnableFilter( vout_thread_t *p_vout, char *psz_name,
+                        vlc_bool_t b_add, vlc_bool_t b_setconfig )
+{
+    char *psz_parser;
+    char *psz_string = config_GetPsz( p_vout, "vout-filter" );
+
+    /* Todo : Use some generic chain manipulation functions */
+    if( !psz_string ) psz_string = strdup("");
+
+    psz_parser = strstr( psz_string, psz_name );
+    if( b_add )
+    {
+        if( !psz_parser )
+        {
+            psz_parser = psz_string;
+            asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
+                            psz_string, psz_name );
+            free( psz_parser );
+        }
+        else
+            return;
+    }
+    else
+    {
+        if( psz_parser )
+        {
+            memmove( psz_parser, psz_parser + strlen(psz_name) +
+                            (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
+                            strlen(psz_parser + strlen(psz_name)) + 1 );
+
+            /* Remove trailing : : */
+            if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
+            {
+                *(psz_string+strlen(psz_string ) -1 ) = '\0';
+            }
+         }
+         else
+         {
+             free( psz_string );
+             return;
+         }
+    }
+    if( b_setconfig )
+        config_PutPsz( p_vout, "vout-filter", psz_string );
+
+    var_SetString( p_vout, "vout-filter", psz_string );
+    free( psz_string );
+}
+
 /*****************************************************************************
  * vout_ControlDefault: default methods for video output control.
  *****************************************************************************/
@@ -806,7 +907,7 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd,
 
     if( !strcmp( psz_cmd, "crop" ) )
     {
-        char *psz_end, *psz_parser = strchr( newval.psz_string, ':' );
+        char *psz_end = NULL, *psz_parser = strchr( newval.psz_string, ':' );
         if( psz_parser )
         {
             /* We're using the 3:4 syntax */
@@ -853,7 +954,8 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd,
                 i_crop_left = strtol( psz_end, &psz_end, 10 );
                 if( psz_end != psz_parser ) goto crop_end;
 
-                i_crop_top = strtol( ++psz_end, &psz_end, 10 );
+                psz_end++;
+                i_crop_top = strtol( psz_end, &psz_end, 10 );
                 if( *psz_end != '\0' ) goto crop_end;
 
                 i_width = i_crop_width;
@@ -882,7 +984,8 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd,
                 i_crop_right = strtol( psz_end, &psz_end, 10 );
                 if( psz_end != psz_parser ) goto crop_end;
 
-                i_crop_bottom = strtol( ++psz_end, &psz_end, 10 );
+                psz_end++;
+                i_crop_bottom = strtol( psz_end, &psz_end, 10 );
                 if( *psz_end != '\0' ) goto crop_end;
 
                 i_width = p_vout->fmt_render.i_visible_width
@@ -987,7 +1090,7 @@ static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd,
              p_vout->fmt_in.i_sar_num, p_vout->fmt_in.i_sar_den );
 
     var_Get( p_vout, "crop", &val );
-    return CropCallback( p_this, 0, val, val, 0 );
+    return CropCallback( p_this, "crop", val, val, 0 );
 
     return VLC_SUCCESS;
 }