/*****************************************************************************
* 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>
*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 */
/* 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 );
{
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 );
#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 */
if( p_mypicturesdir == NULL )
{
asprintf( &val.psz_string, "%s/" CONFIG_DIR,
- p_vout->p_vlc->psz_homedir );
+ p_vout->p_libvlc->psz_homedir );
}
else
{
}
#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 );
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 );
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.
*****************************************************************************/
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 */
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;
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
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;
}