diff --git a/video/gtk4/Cargo.toml b/video/gtk4/Cargo.toml index b413539f..94b8d54a 100644 --- a/video/gtk4/Cargo.toml +++ b/video/gtk4/Cargo.toml @@ -45,11 +45,13 @@ gst-plugin-version-helper.workspace = true [features] default = [] static = [] -wayland = ["gdk-wayland", "gst-gl-wayland"] +# Deprecated +wayland = ["waylandegl"] +waylandegl = ["gdk-wayland", "gst-gl-wayland"] x11glx = ["gdk-x11", "gst-gl-x11"] x11egl = ["gdk-x11", "gst-gl-egl"] winegl = ["gdk-win32/egl", "gst-gl-egl"] -dmabuf = ["gst-allocators", "wayland", "gtk_v4_14", "gst-video/v1_24"] +dmabuf = ["gst-allocators", "gtk_v4_14", "gst-video/v1_24"] capi = [] doc = ["gst/v1_18"] gtk_v4_10 = ["gtk/v4_10"] diff --git a/video/gtk4/README.md b/video/gtk4/README.md index 404340b6..db6d54dc 100644 --- a/video/gtk4/README.md +++ b/video/gtk4/README.md @@ -4,7 +4,7 @@ GTK 4 provides `gtk::Video` & `gtk::Picture` for rendering media such as videos. offer the possibility to use a custom `gst::Pipeline`. The plugin provides a `gst_video::VideoSink` along with a `gdk::Paintable` that's capable of rendering the sink's frames. The sink can generate GL Textures if the system is capable of it, but it needs -to be compiled with either `wayland`, `x11glx` or `x11egl` cargo features. On +to be compiled with either `waylandegl`, `x11glx` or `x11egl` cargo features. On Windows and macOS this is enabled by default. Additionally, the sink can render DMABufs directly on Linux if GTK 4.14 or @@ -52,7 +52,7 @@ To build and include the plugin in a Flatpak manifest, you can add the following } }, "build-commands": [ - "cargo cinstall --offline --release --features=wayland,x11glx,x11egl,dmabuf --library-type=cdylib --prefix=/app" + "cargo cinstall --offline --release --features=waylandegl,x11glx,x11egl,dmabuf --library-type=cdylib --prefix=/app" ] } ] diff --git a/video/gtk4/build.rs b/video/gtk4/build.rs index cda12e57..a7a2c873 100644 --- a/video/gtk4/build.rs +++ b/video/gtk4/build.rs @@ -1,3 +1,7 @@ fn main() { + #[cfg(feature = "wayland")] + { + println!("cargo:warning=\"wayland\" feature is deprecated, use \"waylandegl\" instead"); + } gst_plugin_version_helper::info() } diff --git a/video/gtk4/src/sink/imp.rs b/video/gtk4/src/sink/imp.rs index ed2c111d..188d52a6 100644 --- a/video/gtk4/src/sink/imp.rs +++ b/video/gtk4/src/sink/imp.rs @@ -36,6 +36,7 @@ use crate::utils; enum GLContext { Uninitialized, Unsupported, + #[allow(unused)] Initialized { display: gst_gl::GLDisplay, wrapped_context: gst_gl::GLContext, @@ -261,10 +262,24 @@ impl ElementImpl for PaintableSink { } for features in [ + #[cfg(any( + feature = "x11egl", + feature = "x11glx", + feature = "waylandegl", + target_os = "macos", + target_os = "windows" + ))] Some(gst::CapsFeatures::new([ gst_gl::CAPS_FEATURE_MEMORY_GL_MEMORY, gst_video::CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, ])), + #[cfg(any( + feature = "x11egl", + feature = "x11glx", + feature = "waylandegl", + target_os = "macos", + target_os = "windows" + ))] Some(gst::CapsFeatures::new([ gst_gl::CAPS_FEATURE_MEMORY_GL_MEMORY, ])), @@ -818,9 +833,27 @@ impl PaintableSink { } fn create_paintable(&self, paintable_storage: &mut Option>) { + #[cfg(any( + feature = "x11egl", + feature = "x11glx", + feature = "waylandegl", + target_os = "macos", + target_os = "windows" + ))] { self.initialize_gl_context(); } + #[cfg(not(any( + feature = "x11egl", + feature = "x11glx", + feature = "waylandegl", + target_os = "macos", + target_os = "windows" + )))] + { + gst::debug!(CAT, imp = self, "No GL platform enabled"); + *GL_CONTEXT.lock().unwrap() = GLContext::Unsupported; + } self.configure_caps(); self.initialize_paintable(paintable_storage); @@ -862,6 +895,13 @@ impl PaintableSink { *self.sender.lock().unwrap() = Some(sender); } + #[cfg(any( + feature = "x11egl", + feature = "x11glx", + feature = "waylandegl", + target_os = "macos", + target_os = "windows" + ))] fn initialize_gl_context(&self) { gst::debug!(CAT, imp = self, "Realizing GDK GL Context"); @@ -871,6 +911,13 @@ impl PaintableSink { }); } + #[cfg(any( + feature = "x11egl", + feature = "x11glx", + feature = "waylandegl", + target_os = "macos", + target_os = "windows" + ))] fn initialize_gl_context_main(&self) { gst::debug!(CAT, imp = self, "Realizing GDK GL Context from main thread"); @@ -965,6 +1012,13 @@ impl PaintableSink { }; } + #[cfg(any( + feature = "x11egl", + feature = "x11glx", + feature = "waylandegl", + target_os = "macos", + target_os = "windows" + ))] fn initialize_gst_gl( &self, gdk_display: &gdk::Display, @@ -975,7 +1029,7 @@ impl PaintableSink { "GdkX11GLContextEGL" => self.initialize_x11egl(gdk_display), #[cfg(feature = "x11glx")] "GdkX11GLContextGLX" => self.initialize_x11glx(gdk_display), - #[cfg(feature = "wayland")] + #[cfg(feature = "waylandegl")] "GdkWaylandGLContext" => self.initialize_waylandegl(gdk_display), #[cfg(target_os = "macos")] "GdkMacosGLContext" => self.initialize_macosgl(gdk_display), @@ -1094,7 +1148,7 @@ impl PaintableSink { } } - #[cfg(feature = "wayland")] + #[cfg(feature = "waylandegl")] fn initialize_waylandegl( &self, display: &gdk::Display,