mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-25 13:01:07 +00:00
gtk4paintablesink: Don't initialize a GL context unless a GL platform is enabled
And also don't suggest in the template caps that GL might be supported. For clarification, the wayland feature is also renamed to waylandegl and using wayland gives a deprecation warning. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1837>
This commit is contained in:
parent
d1254fc4ef
commit
36304a7d36
4 changed files with 66 additions and 6 deletions
|
@ -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"]
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
fn main() {
|
||||
#[cfg(feature = "wayland")]
|
||||
{
|
||||
println!("cargo:warning=\"wayland\" feature is deprecated, use \"waylandegl\" instead");
|
||||
}
|
||||
gst_plugin_version_helper::info()
|
||||
}
|
||||
|
|
|
@ -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<ThreadGuard<Paintable>>) {
|
||||
#[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,
|
||||
|
|
Loading…
Reference in a new issue