Commit cfe5b8d5 authored by Laurent Aimar's avatar Laurent Aimar

Moved vout_GetSnapshot() to video_output.c

parent 41d4b8bd
......@@ -44,6 +44,7 @@
#include <vlc_filter.h>
#include <vlc_vout_osd.h>
#include <vlc_image.h>
#include <libvlc.h>
#include "vout_internal.h"
......@@ -440,6 +441,40 @@ void vout_HoldPicture(vout_thread_t *vout, picture_t *picture)
vlc_mutex_unlock(&vout->p->picture_lock);
}
/* */
int vout_GetSnapshot(vout_thread_t *vout,
block_t **image_dst, picture_t **picture_dst,
video_format_t *fmt,
const char *type, mtime_t timeout)
{
picture_t *picture = vout_snapshot_Get(&vout->p->snapshot, timeout);
if (!picture) {
msg_Err(vout, "Failed to grab a snapshot");
return VLC_EGENERIC;
}
if (image_dst) {
vlc_fourcc_t codec = VLC_CODEC_PNG;
if (type && image_Type2Fourcc(type))
codec = image_Type2Fourcc(type);
const int override_width = var_GetInteger(vout, "snapshot-width");
const int override_height = var_GetInteger(vout, "snapshot-height");
if (picture_Export(VLC_OBJECT(vout), image_dst, fmt,
picture, codec, override_width, override_height)) {
msg_Err(vout, "Failed to convert image for snapshot");
picture_Release(picture);
return VLC_EGENERIC;
}
}
if (picture_dst)
*picture_dst = picture;
else
picture_Release(picture);
return VLC_SUCCESS;
}
/* vout_Control* are usable by anyone at anytime */
void vout_ControlChangeFullscreen(vout_thread_t *vout, bool fullscreen)
{
......
......@@ -32,18 +32,12 @@
#include <stdio.h>
#include <stdlib.h> /* free() */
#include <sys/types.h> /* opendir() */
#include <dirent.h> /* opendir() */
#include <assert.h>
#include <time.h> /* strftime */
#include <vlc_interface.h>
#include <vlc_block.h>
#include <vlc_playlist.h>
#include <vlc_modules.h>
#include <vlc_vout.h>
#include <vlc_image.h>
#include <vlc_vout_osd.h>
#include <vlc_strings.h>
#include <vlc_charset.h>
......@@ -396,43 +390,6 @@ static void VoutOsdSnapshot( vout_thread_t *p_vout, picture_t *p_pic, const char
}
}
/* */
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 )
{
picture_t *p_picture = vout_snapshot_Get( &p_vout->p->snapshot, i_timeout );
if( !p_picture )
{
msg_Err( p_vout, "Failed to grab a snapshot" );
return VLC_EGENERIC;
}
if( pp_image )
{
vlc_fourcc_t i_format = VLC_CODEC_PNG;
if( psz_format && image_Type2Fourcc( psz_format ) )
i_format = image_Type2Fourcc( psz_format );
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( pp_picture )
*pp_picture = p_picture;
else
picture_Release( p_picture );
return VLC_SUCCESS;
}
/**
* This function will handle a snapshot request
*/
......
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