+/**
+ * This function will inject a subpicture into the vout with the provided
+ * picture
+ */
+static int VoutSnapshotPip( vout_thread_t *p_vout, image_handler_t *p_image, picture_t *p_pic, const video_format_t *p_fmt_in )
+{
+ video_format_t fmt_in = *p_fmt_in;
+ video_format_t fmt_out;
+ picture_t *p_pip;
+ subpicture_t *p_subpic;
+
+ /* */
+ memset( &fmt_out, 0, sizeof(fmt_out) );
+ fmt_out = fmt_in;
+ fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
+
+ /* */
+ p_pip = image_Convert( p_image, p_pic, &fmt_in, &fmt_out );
+ if( !p_pip )
+ return VLC_EGENERIC;
+
+ p_subpic = subpicture_New();
+ if( p_subpic == NULL )
+ {
+ picture_Release( p_pip );
+ return VLC_EGENERIC;
+ }
+
+ p_subpic->i_channel = 0;
+ p_subpic->i_start = mdate();
+ p_subpic->i_stop = mdate() + 4000000;
+ p_subpic->b_ephemer = true;
+ p_subpic->b_fade = true;
+ p_subpic->i_original_picture_width = fmt_out.i_width * 4;
+ p_subpic->i_original_picture_height = fmt_out.i_height * 4;
+ fmt_out.i_aspect = 0;
+ fmt_out.i_sar_num =
+ fmt_out.i_sar_den = 0;
+
+ p_subpic->p_region = subpicture_region_New( &fmt_out );
+ if( p_subpic->p_region )
+ {
+ picture_Release( p_subpic->p_region->p_picture );
+ p_subpic->p_region->p_picture = p_pip;
+ }
+ else
+ {
+ picture_Release( p_pip );
+ }
+
+ spu_DisplaySubpicture( p_vout->p_spu, p_subpic );
+ return VLC_SUCCESS;
+}
+/**
+ * This function will return the default directory used for snapshots
+ */
+static char *VoutSnapshotGetDefaultDirectory( void )
+{
+ char *psz_path = NULL;
+#if defined(__APPLE__) || defined(SYS_BEOS)
+
+ if( asprintf( &psz_path, "%s/Desktop",
+ config_GetHomeDir() ) == -1 )
+ psz_path = NULL;
+
+#elif defined(WIN32) && !defined(UNDER_CE)
+
+ /* Get the My Pictures folder path */
+ char *p_mypicturesdir = NULL;
+ typedef HRESULT (WINAPI *SHGETFOLDERPATH)( HWND, int, HANDLE, DWORD,
+ LPWSTR );
+ #ifndef CSIDL_FLAG_CREATE
+ # define CSIDL_FLAG_CREATE 0x8000
+ #endif
+ #ifndef CSIDL_MYPICTURES
+ # define CSIDL_MYPICTURES 0x27
+ #endif
+ #ifndef SHGFP_TYPE_CURRENT
+ # define SHGFP_TYPE_CURRENT 0
+ #endif
+
+ HINSTANCE shfolder_dll;
+ SHGETFOLDERPATH SHGetFolderPath ;
+
+ /* load the shfolder dll to retrieve SHGetFolderPath */
+ if( ( shfolder_dll = LoadLibrary( _T("SHFolder.dll") ) ) != NULL )
+ {
+ wchar_t wdir[PATH_MAX];
+ SHGetFolderPath = (void *)GetProcAddress( shfolder_dll,
+ _T("SHGetFolderPathW") );
+ if ((SHGetFolderPath != NULL )
+ && SUCCEEDED (SHGetFolderPath (NULL,
+ CSIDL_MYPICTURES | CSIDL_FLAG_CREATE,
+ NULL, SHGFP_TYPE_CURRENT,
+ wdir)))
+ p_mypicturesdir = FromWide (wdir);
+
+ FreeLibrary( shfolder_dll );
+ }
+
+ if( p_mypicturesdir == NULL )
+ psz_path = strdup( config_GetHomeDir() );
+ else
+ psz_path = p_mypicturesdir;
+
+#else
+
+ /* XXX: This saves in the data directory. Shouldn't we try saving
+ * to psz_homedir/Desktop or something nicer ? */
+ char *psz_datadir = config_GetUserDataDir();
+ if( psz_datadir )
+ {
+ if( asprintf( &psz_path, "%s", psz_datadir ) == -1 )
+ psz_path = NULL;
+ free( psz_datadir );
+ }
+
+#endif
+
+ return psz_path;
+}
+