2020-01-24 23:31:01 +01:00
|
|
|
#ifndef SCREENCAST_COMMON_H
|
|
|
|
#define SCREENCAST_COMMON_H
|
|
|
|
|
2020-03-13 17:43:24 +01:00
|
|
|
#include <string.h>
|
2020-01-24 23:31:01 +01:00
|
|
|
#include <pipewire/pipewire.h>
|
|
|
|
#include <spa/param/video/format-utils.h>
|
|
|
|
#include <libdrm/drm_fourcc.h>
|
|
|
|
#include <wayland-client-protocol.h>
|
2020-02-20 20:59:46 +01:00
|
|
|
#include "logger.h"
|
2020-01-24 23:31:01 +01:00
|
|
|
|
|
|
|
struct damage {
|
|
|
|
uint32_t x;
|
|
|
|
uint32_t y;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct simple_frame {
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t size;
|
|
|
|
uint32_t stride;
|
|
|
|
bool y_invert;
|
|
|
|
uint64_t tv_sec;
|
|
|
|
uint32_t tv_nsec;
|
|
|
|
enum wl_shm_format format;
|
|
|
|
struct damage *damage;
|
|
|
|
struct wl_buffer *buffer;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct screencast_context {
|
|
|
|
// pipewire
|
2020-03-13 23:19:19 +01:00
|
|
|
struct pw_context *pwr_context;
|
2020-01-24 23:31:01 +01:00
|
|
|
struct pw_core *core;
|
2020-03-13 23:19:19 +01:00
|
|
|
struct spa_source *event;
|
2020-01-24 23:31:01 +01:00
|
|
|
struct pw_stream *stream;
|
|
|
|
struct spa_hook stream_listener;
|
|
|
|
struct spa_video_info_raw pwr_format;
|
|
|
|
uint32_t seq;
|
|
|
|
uint32_t node_id;
|
|
|
|
bool stream_state;
|
|
|
|
|
|
|
|
// wlroots
|
|
|
|
struct wl_display *display;
|
|
|
|
struct wl_list output_list;
|
|
|
|
struct wl_registry *registry;
|
|
|
|
struct zwlr_screencopy_manager_v1 *screencopy_manager;
|
2020-02-19 22:55:51 +01:00
|
|
|
struct zxdg_output_manager_v1* xdg_output_manager;
|
2020-01-24 23:31:01 +01:00
|
|
|
struct wl_shm *shm;
|
|
|
|
|
|
|
|
// main frame callback
|
|
|
|
struct zwlr_screencopy_frame_v1 *frame_callback;
|
|
|
|
|
|
|
|
// target output
|
|
|
|
struct wayland_output *target_output;
|
|
|
|
uint32_t framerate;
|
|
|
|
bool with_cursor;
|
|
|
|
|
|
|
|
// frame
|
|
|
|
struct zwlr_screencopy_frame_v1 *wlr_frame;
|
|
|
|
struct simple_frame simple_frame;
|
|
|
|
|
2020-02-19 17:48:36 +01:00
|
|
|
// cli options
|
2020-02-19 22:55:51 +01:00
|
|
|
const char *output_name;
|
2020-02-19 17:48:36 +01:00
|
|
|
const char *forced_pixelformat;
|
|
|
|
|
2020-01-24 23:31:01 +01:00
|
|
|
// if something happens during capture
|
|
|
|
int err;
|
|
|
|
bool quit;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wayland_output {
|
|
|
|
struct wl_list link;
|
|
|
|
uint32_t id;
|
|
|
|
struct wl_output *output;
|
2020-02-19 22:55:51 +01:00
|
|
|
struct zxdg_output_v1 *xdg_output;
|
2020-01-24 23:31:01 +01:00
|
|
|
char *make;
|
|
|
|
char *model;
|
2020-02-19 22:55:51 +01:00
|
|
|
char *name;
|
2020-01-24 23:31:01 +01:00
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
float framerate;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t pipewire_from_wl_shm(void *data);
|
|
|
|
|
|
|
|
#endif /* SCREENCAST_COMMON_H */
|