From c0e233955568fbea4e859336f6d3d14d51294d7c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 25 Apr 2023 17:16:21 +0100 Subject: [PATCH] screencast: send transform to pw --- include/screencast_common.h | 1 + meson.build | 8 +------ src/screencast/pipewire_screencast.c | 32 +++++++++++++++++++--------- src/screencast/wlr_screencast.c | 1 + 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/include/screencast_common.h b/include/screencast_common.h index b8667ca..23a67ef 100644 --- a/include/screencast_common.h +++ b/include/screencast_common.h @@ -149,6 +149,7 @@ struct xdpw_wlr_output { int width; int height; float framerate; + enum wl_output_transform transform; }; struct xdpw_share { diff --git a/meson.build b/meson.build index bca1ac8..8d8f2a9 100644 --- a/meson.build +++ b/meson.build @@ -24,7 +24,7 @@ add_project_arguments('-DSYSCONFDIR="@0@"'.format(join_paths(prefix, sysconfdir) inc = include_directories('include') rt = cc.find_library('rt') -pipewire = dependency('libpipewire-0.3', version: '>= 0.3.41') +pipewire = dependency('libpipewire-0.3', version: '>= 0.3.62') hyprland_protos = dependency('hyprland-protocols', version: '>=0.2', fallback: 'hyprland-protocols') wayland_client = dependency('wayland-client') wayland_protos = dependency('wayland-protocols', version: '>=1.24') @@ -39,12 +39,6 @@ if (not cc.has_function('timerfd_create', prefix: '#include ') or epoll = dependency('epoll-shim') endif -if pipewire.version() == '0.3.49' - add_project_arguments(cc.get_supported_arguments([ - '-D_GNU_SOURCE', - ]), language: 'c') -endif - if get_option('sd-bus-provider') == 'auto' assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto') sdbus = dependency('libsystemd', diff --git a/src/screencast/pipewire_screencast.c b/src/screencast/pipewire_screencast.c index e71aef5..ed1ce9d 100644 --- a/src/screencast/pipewire_screencast.c +++ b/src/screencast/pipewire_screencast.c @@ -1,19 +1,20 @@ #include "pipewire_screencast.h" -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "logger.h" #include "wlr_screencast.h" #include "xdpw.h" -#include "logger.h" static struct spa_pod *build_buffer(struct spa_pod_builder *b, uint32_t blocks, uint32_t size, uint32_t stride, uint32_t datatype) { @@ -316,7 +317,12 @@ fixate_format: SPA_PARAM_META_type, SPA_POD_Id(SPA_META_Header), SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_header))); - params[2] = spa_pod_builder_add_object(&b[2].b, + params[2] = spa_pod_builder_add_object(&b[1].b, + SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, + SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoTransform), + SPA_PARAM_META_size, SPA_POD_Int(sizeof(struct spa_meta_videotransform))); + + params[3] = spa_pod_builder_add_object(&b[2].b, SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta, SPA_PARAM_META_type, SPA_POD_Id(SPA_META_VideoDamage), SPA_PARAM_META_size, SPA_POD_CHOICE_RANGE_Int( @@ -449,6 +455,12 @@ void xdpw_pwr_enqueue_buffer(struct xdpw_screencast_instance *cast) { logprint(TRACE, "pipewire: timestamp %"PRId64, h->pts); } + struct spa_meta_videotransform *vt; + if ((vt = spa_buffer_find_meta_data(spa_buf, SPA_META_VideoTransform, sizeof(*vt)))) { + vt->transform = cast->target.output->transform; + logprint(TRACE, "pipewire: transform %u", vt->transform); + } + struct spa_meta *damage; if ((damage = spa_buffer_find_meta(spa_buf, SPA_META_VideoDamage))) { struct spa_region *d_region = spa_meta_first(damage); diff --git a/src/screencast/wlr_screencast.c b/src/screencast/wlr_screencast.c index cb4634d..c86ce1d 100644 --- a/src/screencast/wlr_screencast.c +++ b/src/screencast/wlr_screencast.c @@ -551,6 +551,7 @@ static void wlr_output_handle_geometry(void *data, struct wl_output *wl_output, struct xdpw_wlr_output *output = data; output->make = strdup(make); output->model = strdup(model); + output->transform = transform; } static void wlr_output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, int32_t width, int32_t height, int32_t refresh) {