]> git.sesse.net Git - vlc/commitdiff
Added a vout_GetSnapshot to retreive snapshot from vout.
authorLaurent Aimar <fenrir@videolan.org>
Sun, 8 Mar 2009 12:36:29 +0000 (13:36 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 8 Mar 2009 13:17:37 +0000 (14:17 +0100)
It will allows to remove libvlc hack.

include/vlc_vout.h
src/libvlccore.sym
src/video_output/vout_intf.c

index 71fae395f1b33ceebf97dc7d13fc840e65084f02..46369460ecbeca83f459a441ced8807ca77b52de 100644 (file)
@@ -683,6 +683,23 @@ static inline void vout_CloseAndRelease( vout_thread_t *p_vout )
     vlc_object_release( p_vout );
 }
 
+/**
+ * This function will handle a snapshot request.
+ *
+ * pp_image, pp_picture and p_fmt can be NULL otherwise they will be
+ * set with returned value in case of success.
+ *
+ * pp_image will hold an encoded picture in psz_format format.
+ *
+ * i_timeout specifies the time the function will wait for a snapshot to be
+ * available.
+ *
+ */
+VLC_EXPORT( int, vout_GetSnapshot, ( vout_thread_t *p_vout,
+                                     block_t **pp_image, picture_t **pp_picture,
+                                     video_format_t *p_fmt,
+                                     const char *psz_format, mtime_t i_timeout ) );
+
 /* */
 VLC_EXPORT( int,             vout_ChromaCmp,      ( uint32_t, uint32_t ) );
 
index ef489e36ff204021032003fc17621cca92db84c7..0a61bbde317e0cc727340a2029d68635083fd597 100644 (file)
@@ -513,6 +513,7 @@ vout_CreatePicture
 vout_DestroyPicture
 vout_DisplayPicture
 vout_EnableFilter
+vout_GetSnapshot
 vout_InitFormat
 __vout_InitPicture
 vout_LinkPicture
index 2ca11b63d5d42ca2d6bc5d327a9fde95de054de6..b764532f8a3b5646bf6c0e6d02191ce319f9e5e5 100644 (file)
@@ -745,13 +745,12 @@ static void VoutOsdSnapshot( vout_thread_t *p_vout, picture_t *p_pic, const char
             msg_Warn( p_vout, "Failed to display snapshot" );
     }
 }
-/**
- * This function will retreive a snapshot from vout
- */
-static int VoutGetSnapshot( vout_thread_t *p_vout,
-                            block_t **pp_image, picture_t **pp_picture,
-                            video_format_t *p_fmt,
-                            const char *psz_format, mtime_t i_timeout )
+
+/* */
+int vout_GetSnapshot( vout_thread_t *p_vout,
+                      block_t **pp_image, picture_t **pp_picture,
+                      video_format_t *p_fmt,
+                      const char *psz_format, mtime_t i_timeout )
 {
     vout_thread_sys_t *p_sys = p_vout->p;
 
@@ -779,22 +778,27 @@ static int VoutGetSnapshot( vout_thread_t *p_vout,
         return VLC_EGENERIC;
     }
 
-    vlc_fourcc_t i_format = VLC_FOURCC('p','n','g',' ');
-    if( psz_format && image_Ext2Fourcc( psz_format ) )
-        i_format = image_Ext2Fourcc( psz_format );
+    if( pp_image )
+    {
+        vlc_fourcc_t i_format = VLC_FOURCC('p','n','g',' ');
+        if( psz_format && image_Ext2Fourcc( psz_format ) )
+            i_format = image_Ext2Fourcc( psz_format );
 
-    const int i_override_width  = var_GetInteger( p_vout, "snapshot-width" );
-    const int i_override_height = var_GetInteger( p_vout, "snapshot-height" );
+        const int i_override_width  = var_GetInteger( p_vout, "snapshot-width" );
+        const int i_override_height = var_GetInteger( p_vout, "snapshot-height" );
 
-    if( picture_Export( VLC_OBJECT(p_vout), pp_image, p_fmt,
-                        p_picture, i_format, i_override_width, i_override_height ) )
-    {
-        msg_Err( p_vout, "Failed to convert image for snapshot" );
-        picture_Release( p_picture );
-        return VLC_EGENERIC;
+        if( picture_Export( VLC_OBJECT(p_vout), pp_image, p_fmt,
+                            p_picture, i_format, i_override_width, i_override_height ) )
+        {
+            msg_Err( p_vout, "Failed to convert image for snapshot" );
+            picture_Release( p_picture );
+            return VLC_EGENERIC;
+        }
     }
-
-    *pp_picture = p_picture;
+    if( pp_picture )
+        *pp_picture = p_picture;
+    else
+        picture_Release( p_picture );
     return VLC_SUCCESS;
 }
 
@@ -817,7 +821,7 @@ static void VoutSaveSnapshot( vout_thread_t *p_vout )
 
     /* 500ms timeout
      * XXX it will cause trouble with low fps video (< 2fps) */
-    if( VoutGetSnapshot( p_vout, &p_image, &p_picture, &fmt, psz_format, 500*1000 ) )
+    if( vout_GetSnapshot( p_vout, &p_image, &p_picture, &fmt, psz_format, 500*1000 ) )
     {
         if( b_embedded )
             VoutMemorySnapshot( p_vout, p_obj, NULL, NULL );