wcap: Add a file format magic number and add the pixel format to the header

dev
Kristian Høgsberg 13 years ago
parent ee85ae9c13
commit 3b969608cb
  1. 19
      src/screenshooter.c
  2. 9
      src/wcap-decode.c

@ -318,12 +318,18 @@ weston_recorder_frame_notify(struct wl_listener *listener, void *data)
pixman_region32_fini(&damage); pixman_region32_fini(&damage);
} }
#define WCAP_HEADER_MAGIC 0x57434150
#define WCAP_FORMAT_XRGB8888 0x34325258
#define WCAP_FORMAT_XBGR8888 0x34324258
#define WCAP_FORMAT_RGBX8888 0x34325852
#define WCAP_FORMAT_BGRX8888 0x34325842
static void static void
weston_recorder_create(struct weston_output *output, const char *filename) weston_recorder_create(struct weston_output *output, const char *filename)
{ {
struct weston_recorder *recorder; struct weston_recorder *recorder;
int stride, size; int stride, size;
struct { uint32_t width, height; } header; struct { uint32_t magic, format, width, height; } header;
recorder = malloc(sizeof *recorder); recorder = malloc(sizeof *recorder);
recorder->output = output; recorder->output = output;
@ -338,6 +344,17 @@ weston_recorder_create(struct weston_output *output, const char *filename)
recorder->fd = open(filename, recorder->fd = open(filename,
O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
header.magic = WCAP_HEADER_MAGIC;
switch (output->compositor->read_format) {
case GL_BGRA_EXT:
header.format = WCAP_FORMAT_XRGB8888;
break;
case GL_RGBA:
header.format = WCAP_FORMAT_XBGR8888;
break;
}
header.width = output->current->width; header.width = output->current->width;
header.height = output->current->height; header.height = output->current->height;
recorder->total += write(recorder->fd, &header, sizeof header); recorder->total += write(recorder->fd, &header, sizeof header);

@ -33,7 +33,16 @@
#include <cairo.h> #include <cairo.h>
#define WCAP_HEADER_MAGIC 0x57434150
#define WCAP_FORMAT_XRGB8888 0x34325258
#define WCAP_FORMAT_XBGR8888 0x34324258
#define WCAP_FORMAT_RGBX8888 0x34325852
#define WCAP_FORMAT_BGRX8888 0x34325842
struct wcap_header { struct wcap_header {
uint32_t magic;
uint32_t format;
uint32_t width, height; uint32_t width, height;
}; };

Loading…
Cancel
Save