Commit 599b0d51 authored by Filippo Carone's avatar Filippo Carone

New snapshot behaviour.

if the user specifies a directory in the snapshot-path variable, then vlc
behaves as before; 

if the user specifies a complete path (folder/filename) then the snapshot 
is named and saved after it.
parent 71148dd9
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> /* free() */ #include <stdlib.h> /* free() */
#include <sys/types.h> /* opendir() */
#include <dirent.h> /* opendir() */
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/intf.h> #include <vlc/intf.h>
...@@ -436,6 +438,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -436,6 +438,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
subpicture_t *p_subpic; subpicture_t *p_subpic;
picture_t *p_pif; picture_t *p_pif;
vlc_value_t val, format; vlc_value_t val, format;
DIR *path;
int i_ret; int i_ret;
var_Get( p_vout, "snapshot-path", &val ); var_Get( p_vout, "snapshot-path", &val );
...@@ -610,7 +614,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -610,7 +614,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
if( !val.psz_string ) 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; return VLC_EGENERIC;
} }
var_Get( p_vout, "snapshot-format", &format ); var_Get( p_vout, "snapshot-format", &format );
...@@ -620,9 +624,24 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -620,9 +624,24 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
format.psz_string = strdup( "png" ); format.psz_string = strdup( "png" );
} }
/*
* Did the user specify a directory? If not, path = NULL.
*/
path = opendir ( (const char *)val.psz_string );
if ( path != NULL )
{
asprintf( &psz_filename, "%s/vlcsnap-%u.%s", val.psz_string, asprintf( &psz_filename, "%s/vlcsnap-%u.%s", val.psz_string,
(unsigned int)(p_pic->date / 100000) & 0xFFFFFF, (unsigned int)(p_pic->date / 100000) & 0xFFFFFF,
format.psz_string ); format.psz_string );
closedir( path );
}
else // The user specified a full path name (including file name)
{
asprintf ( &psz_filename, "%s", val.psz_string );
}
free( val.psz_string ); free( val.psz_string );
free( format.psz_string ); free( format.psz_string );
......
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