Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore screencast session part 1 #179

Merged
merged 7 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions include/screencast_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

// this seems to be right based on
// https://github.com/flatpak/xdg-desktop-portal/blob/309a1fc0cf2fb32cceb91dbc666d20cf0a3202c2/src/screen-cast.c#L955
#define XDP_CAST_PROTO_VER 2
#define XDP_CAST_PROTO_VER 4
#define XDP_CAST_DATA_VER 1

enum cursor_modes {
HIDDEN = 1,
Expand All @@ -24,6 +25,12 @@ enum source_types {
WINDOW = 2,
};

enum persist_modes {
PERSIST_NONE = 0,
PERSIST_TRANSIENT = 1,
PERSIST_PERMANENT = 2,
};

enum buffer_type {
WL_SHM = 0,
DMABUF = 1,
Expand Down Expand Up @@ -129,6 +136,16 @@ struct xdpw_screencast_context {
struct wl_list screencast_instances;
};

struct xdpw_screencast_target {
struct xdpw_wlr_output *output;
bool with_cursor;
};

struct xdpw_screencast_restore_data {
uint32_t version;
const char *output_name;
};

struct xdpw_screencast_instance {
// list
struct wl_list link;
Expand All @@ -153,11 +170,10 @@ struct xdpw_screencast_instance {

// wlroots
struct zwlr_screencopy_frame_v1 *frame_callback;
struct xdpw_wlr_output *target_output;
struct xdpw_screencast_target *target;
uint32_t max_framerate;
struct zwlr_screencopy_frame_v1 *wlr_frame;
struct xdpw_screencopy_frame_info screencopy_frame_info[2];
bool with_cursor;
int err;
bool quit;
bool teardown;
Expand All @@ -167,6 +183,12 @@ struct xdpw_screencast_instance {
struct fps_limit_state fps_limit;
};

struct xdpw_screencast_session_data {
struct xdpw_screencast_instance *screencast_instance;
uint32_t cursor_mode;
uint32_t persist_mode;
};

struct xdpw_wlr_output {
struct wl_list link;
uint32_t id;
Expand Down
9 changes: 3 additions & 6 deletions include/wlr_screencast.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ struct xdpw_state;
int xdpw_wlr_screencopy_init(struct xdpw_state *state);
void xdpw_wlr_screencopy_finish(struct xdpw_screencast_context *ctx);

struct xdpw_wlr_output *xdpw_wlr_output_find_by_name(struct wl_list *output_list,
const char *name);
struct xdpw_wlr_output *xdpw_wlr_output_first(struct wl_list *output_list);
struct xdpw_wlr_output *xdpw_wlr_output_find(struct xdpw_screencast_context *ctx,
struct wl_output *out, uint32_t id);
struct xdpw_wlr_output *xdpw_wlr_output_chooser(struct xdpw_screencast_context *ctx);
bool xdpw_wlr_target_chooser(struct xdpw_screencast_context *ctx, struct xdpw_screencast_target *target);
bool xdpw_wlr_target_from_data(struct xdpw_screencast_context *ctx, struct xdpw_screencast_target *target,
struct xdpw_screencast_restore_data *data);

void xdpw_wlr_frame_finish(struct xdpw_screencast_instance *cast);
void xdpw_wlr_frame_start(struct xdpw_screencast_instance *cast);
Expand Down
2 changes: 1 addition & 1 deletion include/xdpw.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct xdpw_session {
struct wl_list link;
sd_bus_slot *slot;
char *session_handle;
struct xdpw_screencast_instance *screencast_instance;
struct xdpw_screencast_session_data screencast_data;
};

typedef void (*xdpw_event_loop_timer_func_t)(void *data);
Expand Down
2 changes: 1 addition & 1 deletion src/core/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void xdpw_session_destroy(struct xdpw_session *sess) {
if (!sess) {
return;
}
struct xdpw_screencast_instance *cast = sess->screencast_instance;
struct xdpw_screencast_instance *cast = sess->screencast_data.screencast_instance;
if (cast) {
assert(cast->refcount > 0);
--cast->refcount;
Expand Down
2 changes: 1 addition & 1 deletion src/screencast/pipewire_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ void xdpw_pwr_enqueue_buffer(struct xdpw_screencast_instance *cast) {

struct spa_meta_videotransform *vt;
if ((vt = spa_buffer_find_meta_data(spa_buf, SPA_META_VideoTransform, sizeof(*vt)))) {
vt->transform = cast->target_output->transformation;
vt->transform = cast->target->output->transformation;
logprint(TRACE, "pipewire: transformation %u", vt->transform);
}

Expand Down
Loading