From 9d2e8b2f3caaf85783420ea9aff5a8e551de4d60 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 3 Jun 2022 17:37:02 +0200 Subject: [PATCH 1/2] wayland: add support for content-type-v1 Allows the compositor to forward the correct information to the output device (e.g. via HDMI infoframes), and to implement rules based on the content type hint. See: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/150 --- generated/wayland/meson.build | 1 + video/out/wayland_common.c | 16 ++++++++++++++++ video/out/wayland_common.h | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/generated/wayland/meson.build b/generated/wayland/meson.build index 79247409b1dd5..9ca53e7170689 100644 --- a/generated/wayland/meson.build +++ b/generated/wayland/meson.build @@ -2,6 +2,7 @@ wl_protocol_dir = wayland['deps'][2].get_variable(pkgconfig: 'pkgdatadir') protocols = [[wl_protocol_dir, 'stable/presentation-time/presentation-time.xml'], [wl_protocol_dir, 'stable/viewporter/viewporter.xml'], [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], + [wl_protocol_dir, 'staging/content-type/content-type-v1.xml'], [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'], [wl_protocol_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml'], [wl_protocol_dir, 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml']] diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 1c8d2097c8582..320fa8453bb90 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -34,6 +34,7 @@ #include "win_state.h" // Generated from wayland-protocols +#include "generated/wayland/content-type-v1.h" #include "generated/wayland/idle-inhibit-unstable-v1.h" #include "generated/wayland/linux-dmabuf-unstable-v1.h" #include "generated/wayland/presentation-time.h" @@ -1145,6 +1146,10 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id wl->idle_inhibit_manager = wl_registry_bind(reg, id, &zwp_idle_inhibit_manager_v1_interface, 1); } + if (!strcmp(interface, wp_content_type_manager_v1_interface.name) && found++) { + wl->content_type_manager = wl_registry_bind(reg, id, &wp_content_type_manager_v1_interface, 1); + } + if (found > 1) MP_VERBOSE(wl, "Registered for protocol %s\n", interface); } @@ -1898,6 +1903,11 @@ int vo_wayland_init(struct vo *vo) zxdg_decoration_manager_v1_interface.name); } + if (wl->content_type_manager) { + wl->content_type = wp_content_type_manager_v1_get_surface_content_type(wl->content_type_manager, wl->surface); + wp_content_type_v1_set_content_type(wl->content_type, WP_CONTENT_TYPE_V1_CONTENT_TYPE_VIDEO); + } + if (!wl->idle_inhibit_manager) MP_VERBOSE(wl, "Compositor doesn't support the %s protocol!\n", zwp_idle_inhibit_manager_v1_interface.name); @@ -2109,6 +2119,12 @@ void vo_wayland_uninit(struct vo *vo) if (wl->xdg_decoration_manager) zxdg_decoration_manager_v1_destroy(wl->xdg_decoration_manager); + if (wl->content_type_manager) + wp_content_type_manager_v1_destroy(wl->content_type_manager); + + if (wl->content_type) + wp_content_type_v1_destroy(wl->content_type); + if (wl->xdg_toplevel) xdg_toplevel_destroy(wl->xdg_toplevel); diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h index 90bd1ca7e11d9..ec1bc845380e4 100644 --- a/video/out/wayland_common.h +++ b/video/out/wayland_common.h @@ -111,6 +111,10 @@ struct vo_wayland_state { struct wp_viewport *viewport; struct wp_viewport *video_viewport; + /* content-type */ + struct wp_content_type_manager_v1 *content_type_manager; + struct wp_content_type_v1 *content_type; + /* Input */ struct wl_keyboard *keyboard; struct wl_pointer *pointer; From 1d46cd794b22c0163acc086e6f1c8a7746518c09 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 3 Jun 2022 17:39:50 +0200 Subject: [PATCH 2/2] meson: add internal arg to wayland-protocols' get_variable() This allows developers to build mpv with a wayland-protocols subproject. --- generated/wayland/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generated/wayland/meson.build b/generated/wayland/meson.build index 9ca53e7170689..93a13f764e24e 100644 --- a/generated/wayland/meson.build +++ b/generated/wayland/meson.build @@ -1,4 +1,4 @@ -wl_protocol_dir = wayland['deps'][2].get_variable(pkgconfig: 'pkgdatadir') +wl_protocol_dir = wayland['deps'][2].get_variable(pkgconfig: 'pkgdatadir', internal: 'pkgdatadir') protocols = [[wl_protocol_dir, 'stable/presentation-time/presentation-time.xml'], [wl_protocol_dir, 'stable/viewporter/viewporter.xml'], [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],