Skip to content

Commit

Permalink
screencast: pipewire add import_shm_buffer function
Browse files Browse the repository at this point in the history
  • Loading branch information
columbarius committed Jun 14, 2021
1 parent 5c33970 commit 1967fd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/screencast_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ struct xdpw_wlr_output {

void randname(char *buf);
int anonymous_shm_open(void);
struct wl_buffer *import_shm_buffer(struct xdpw_screencast_instance *cast, int fd,
enum wl_shm_format fmt, int width, int height, int stride);
enum spa_video_format xdpw_format_pw_from_wl_shm(
struct xdpw_screencast_instance *cast);
enum spa_video_format xdpw_format_pw_strip_alpha(enum spa_video_format format);
Expand Down
17 changes: 17 additions & 0 deletions src/screencast/screencast_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ int anonymous_shm_open(void) {
return -1;
}

struct wl_buffer *import_shm_buffer(struct xdpw_screencast_instance *cast, int fd,
enum wl_shm_format fmt, int width, int height, int stride) {
struct xdpw_screencast_context *ctx = cast->ctx;
int size = stride * height;

if (fd < 0) {
return NULL;
}

struct wl_shm_pool *pool = wl_shm_create_pool(ctx->shm, fd, size);
struct wl_buffer *buffer =
wl_shm_pool_create_buffer(pool, 0, width, height, stride, fmt);
wl_shm_pool_destroy(pool);

return buffer;
}

enum spa_video_format xdpw_format_pw_from_wl_shm(
struct xdpw_screencast_instance *cast) {
switch (cast->simple_frame.format) {
Expand Down

0 comments on commit 1967fd3

Please sign in to comment.