summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authornick <nick@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-02-17 10:21:00 +0000
committernick <nick@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-02-17 10:21:00 +0000
commitd14af0326d67ec5c924ba43ac85580aa0b509f8a (patch)
tree5d50bc063abc190ee13c7a23f5a5b9147bb1caa6 /libvo
parent340183b0e920023d1a24dc5ff95255b5ecbc2a9c (diff)
downloadmpv-d14af0326d67ec5c924ba43ac85580aa0b509f8a.tar.bz2
mpv-d14af0326d67ec5c924ba43ac85580aa0b509f8a.tar.xz
Screenshot on the fly
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4740 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_vesa.c73
-rw-r--r--libvo/vosub_vidix.c5
2 files changed, 78 insertions, 0 deletions
diff --git a/libvo/vo_vesa.c b/libvo/vo_vesa.c
index f659fc5b94..7bf552f66d 100644
--- a/libvo/vo_vesa.c
+++ b/libvo/vo_vesa.c
@@ -25,6 +25,11 @@
#include <string.h>
#include <stddef.h>
#include <limits.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
#include "video_out.h"
#include "video_out_internal.h"
@@ -42,6 +47,11 @@
#include "../postproc/swscale.h"
LIBVO_EXTERN(vesa)
+
+#ifdef HAVE_PNG
+extern vo_functions_t video_out_png;
+#endif
+
extern int verbose;
#define MAX_BUFFERS 3
@@ -936,11 +946,74 @@ static uint32_t preinit(const char *arg)
return pre_init_err;
}
+#ifdef HAVE_PNG
+static int vesa_screenshot(const char *fname)
+{
+ uint32_t i,n;
+ uint8_t *ptrs[video_mode_info.YResolution];
+ if(!video_out_png.control(VOCTRL_QUERY_FORMAT, &dstFourcc))
+ {
+ printf("\nvo_vesa: vo_png doesn't support: %s fourcc\n",vo_format_name(dstFourcc));
+ return 1;
+ }
+ if(video_out_png.preinit(NULL))
+ {
+ printf("\nvo_vesa: can't preinit vo_png\n");
+ return 1;
+ }
+ if(video_out_png.config(HAS_DGA()?video_mode_info.XResolution:dstW,
+ HAS_DGA()?video_mode_info.YResolution:dstH,
+ HAS_DGA()?video_mode_info.XResolution:dstW,
+ HAS_DGA()?video_mode_info.YResolution:dstH,
+ 0,NULL,dstFourcc,NULL))
+ {
+ printf("\nvo_vesa: can't configure vo_png\n");
+ return 1;
+ }
+ n = HAS_DGA()?video_mode_info.YResolution:dstH;
+ for(i=0;i<n;i++)
+ ptrs[i] = &dga_buffer[(HAS_DGA()?video_mode_info.XResolution:dstW)*i*PIXEL_SIZE()];
+ if(video_out_png.draw_frame(ptrs))
+ {
+ printf("\nvo_vesa: vo_png: error during dumping\n");
+ return 1;
+ }
+
+ video_out_png.uninit();
+ if(verbose) printf("\nvo_vesa: png output has been created\n");
+ return 0;
+}
+
+
+static char _home_name[FILENAME_MAX + 1];
+static char * __get_home_filename(const char *progname)
+{
+ char *p = getenv("HOME");
+
+ if (p == NULL || strlen(p) < 2) {
+ struct passwd *psw = getpwuid(getuid());
+ if (psw != NULL) p = psw->pw_dir;
+ }
+
+ if (p == NULL || strlen(p) > FILENAME_MAX - (strlen(progname) + 4))
+ p = "/tmp";
+
+ strcpy(_home_name, p);
+ strcat(_home_name, "/.");
+ return strcat(_home_name, progname);
+}
+#endif
+
static uint32_t control(uint32_t request, void *data, ...)
{
switch (request) {
case VOCTRL_QUERY_FORMAT:
return query_format(*((uint32_t*)data));
+#ifdef HAVE_PNG
+ case VOCTRL_SCREENSHOT:
+ return vesa_screenshot(__get_home_filename("mplayer_vesa_dump.png"));
+ break;
+#endif
}
return VO_NOTIMPL;
}
diff --git a/libvo/vosub_vidix.c b/libvo/vosub_vidix.c
index c5b10f2ff2..4cf9ad9be9 100644
--- a/libvo/vosub_vidix.c
+++ b/libvo/vosub_vidix.c
@@ -43,6 +43,8 @@ static vidix_capability_t vidix_cap;
static vidix_playback_t vidix_play;
static vidix_fourcc_t vidix_fourcc;
static vo_functions_t * vo_server;
+static uint32_t (*server_control)(uint32_t request, void *data, ...);
+
static int vidix_get_bes_da(bes_da_t *);
static int vidix_get_video_eq(vidix_video_eq_t *info);
@@ -635,6 +637,8 @@ uint32_t vidix_control(uint32_t request, void *data, ...)
return VO_TRUE;
case VOCTRL_QUERY_FORMAT:
return vidix_query_fourcc(*((uint32_t*)data));
+ case VOCTRL_SCREENSHOT:
+ return (*server_control)(request,data);
}
return VO_NOTIMPL;
}
@@ -668,6 +672,7 @@ int vidix_preinit(const char *drvname,void *server)
((vo_functions_t *)server)->draw_frame=vidix_draw_frame;
((vo_functions_t *)server)->flip_page=vidix_flip_page;
((vo_functions_t *)server)->draw_osd=vidix_draw_osd;
+ server_control = ((vo_functions_t *)server)->control;
((vo_functions_t *)server)->control=vidix_control;
vo_server = server;
return 0;