From 5e05bbbbcbd45298c48af2b56a33da93d15b8f44 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 9 Mar 2024 15:28:17 +0100 Subject: Refactor xcomposite Move common code between cuda/vaapi implementations into xcomposite file. This also fixes limited/full range colors on nvidia. --- include/capture/xcomposite.h | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 include/capture/xcomposite.h (limited to 'include/capture/xcomposite.h') diff --git a/include/capture/xcomposite.h b/include/capture/xcomposite.h new file mode 100644 index 0000000..222ff5b --- /dev/null +++ b/include/capture/xcomposite.h @@ -0,0 +1,46 @@ +#ifndef GSR_CAPTURE_XCOMPOSITE_H +#define GSR_CAPTURE_XCOMPOSITE_H + +#include "capture.h" +#include "../egl.h" +#include "../vec2.h" +#include "../color_conversion.h" +#include "../window_texture.h" + +typedef struct { + gsr_egl *egl; + Window window; + bool follow_focused; /* If this is set then |window| is ignored */ + vec2i region_size; /* This is currently only used with |follow_focused| */ + gsr_color_range color_range; +} gsr_capture_xcomposite_params; + +typedef struct { + gsr_capture_base base; + gsr_capture_xcomposite_params params; + XEvent xev; + + bool should_stop; + bool stop_is_error; + bool window_resized; + bool follow_focused_initialized; + + Window window; + vec2i window_size; + vec2i texture_size; + double window_resize_timer; + + WindowTexture window_texture; + + Atom net_active_window_atom; +} gsr_capture_xcomposite; + +void gsr_capture_xcomposite_init(gsr_capture_xcomposite *self, const gsr_capture_xcomposite_params *params); + +int gsr_capture_xcomposite_start(gsr_capture_xcomposite *self, AVCodecContext *video_codec_context, AVFrame *frame); +void gsr_capture_xcomposite_stop(gsr_capture_xcomposite *self, AVCodecContext *video_codec_context); +void gsr_capture_xcomposite_tick(gsr_capture_xcomposite *self, AVCodecContext *video_codec_context); +bool gsr_capture_xcomposite_should_stop(gsr_capture_xcomposite *self, bool *err); +int gsr_capture_xcomposite_capture(gsr_capture_xcomposite *self, AVFrame *frame); + +#endif /* GSR_CAPTURE_XCOMPOSITE_H */ -- cgit v1.2.3