forked from mirrors/gstreamer-rs
examples/glupload: Remove Wayland display integration
`GstGLDisplayWayland` calls GstGLDisplayEGL::from_gl_display()` under the hood (which calls `GstGLDisplayEGL::from_native()`, which calls `eglGetPlatformDisplay()`) to retrieve the underlying `EGLDisplay` handle, which thus far seems to be the same value as `glutin`. However, newer `glutin 0.31` passes attributes to this function resulting in a different handle, causing all kinds of trouble further down the line when sharing resources between `glutin` and `gstreamer-rs` that both operate on a distinct `EGLDisplay`. Furthermore `GstGLDisplayEGL` thinks that it uniquely owns the handle returned by `eglGetPlatformDisplay()` and _does not_ set `.foreign_display = TRUE` (which `GstGLDisplayEGL::with_egl_display()` would), causing it to call `eglTerminate()` as soon as the `GstGLDisplay` is destroyed, leaving `glutin` dysfunctional. To solve all of this, simply remove this wrongly-behaving class from the example as it is not suitable for sharing an `EGLDisplay` with `glutin`. It might however be interesting to create a different example that showcases how to use raw window handles instead of EGL/GLX handles, however only Wayland and any platform on EGL like Android, via `GstGLDisplayEGL::from_native()`, support this. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1336>
This commit is contained in:
parent
0f3d2d6d09
commit
5fdd56747f
4 changed files with 12 additions and 42 deletions
|
@ -23,7 +23,7 @@ done
|
||||||
if [ -n "$EXAMPLES_TUTORIALS" ]; then
|
if [ -n "$EXAMPLES_TUTORIALS" ]; then
|
||||||
# Keep in sync with examples/Cargo.toml
|
# Keep in sync with examples/Cargo.toml
|
||||||
# List all features except windows/win32
|
# List all features except windows/win32
|
||||||
EXAMPLES_FEATURES="--features=rtsp-server,rtsp-server-record,pango-cairo,overlay-composition,gl,gst-gl-x11,gst-gl-wayland,gst-gl-egl,allocators,gst-play,gst-player,ges,image,cairo-rs,gst-video/v1_18"
|
EXAMPLES_FEATURES="--features=rtsp-server,rtsp-server-record,pango-cairo,overlay-composition,gl,gst-gl-x11,gst-gl-egl,allocators,gst-play,gst-player,ges,image,cairo-rs,gst-video/v1_18"
|
||||||
|
|
||||||
cargo build --locked --color=always --manifest-path examples/Cargo.toml --bins --examples "$EXAMPLES_FEATURES"
|
cargo build --locked --color=always --manifest-path examples/Cargo.toml --bins --examples "$EXAMPLES_FEATURES"
|
||||||
cargo build --locked --color=always --manifest-path tutorials/Cargo.toml --bins --examples --all-features
|
cargo build --locked --color=always --manifest-path tutorials/Cargo.toml --bins --examples --all-features
|
||||||
|
|
|
@ -34,7 +34,7 @@ done
|
||||||
|
|
||||||
# Keep in sync with examples/Cargo.toml
|
# Keep in sync with examples/Cargo.toml
|
||||||
# List all features except windows/win32
|
# List all features except windows/win32
|
||||||
EXAMPLES_FEATURES="--features=rtsp-server,rtsp-server-record,pango-cairo,overlay-composition,gl,gst-gl-x11,gst-gl-wayland,gst-gl-egl,allocators,gst-play,gst-player,ges,image,cairo-rs,gst-video/v1_18"
|
EXAMPLES_FEATURES="--features=rtsp-server,rtsp-server-record,pango-cairo,overlay-composition,gl,gst-gl-x11,gst-gl-egl,allocators,gst-play,gst-player,ges,image,cairo-rs,gst-video/v1_18"
|
||||||
|
|
||||||
# And also run over all the examples/tutorials
|
# And also run over all the examples/tutorials
|
||||||
cargo clippy --locked --color=always --manifest-path examples/Cargo.toml --all-targets "$EXAMPLES_FEATURES" -- $CLIPPY_LINTS
|
cargo clippy --locked --color=always --manifest-path examples/Cargo.toml --all-targets "$EXAMPLES_FEATURES" -- $CLIPPY_LINTS
|
||||||
|
|
|
@ -11,7 +11,6 @@ glib = { git = "https://github.com/gtk-rs/gtk-rs-core" }
|
||||||
gst = { package = "gstreamer", path = "../gstreamer" }
|
gst = { package = "gstreamer", path = "../gstreamer" }
|
||||||
gst-gl = { package = "gstreamer-gl", path = "../gstreamer-gl", optional = true }
|
gst-gl = { package = "gstreamer-gl", path = "../gstreamer-gl", optional = true }
|
||||||
gst-gl-egl = { package = "gstreamer-gl-egl", path = "../gstreamer-gl/egl", optional = true }
|
gst-gl-egl = { package = "gstreamer-gl-egl", path = "../gstreamer-gl/egl", optional = true }
|
||||||
gst-gl-wayland = { package = "gstreamer-gl-wayland", path = "../gstreamer-gl/wayland", optional = true }
|
|
||||||
gst-gl-x11 = { package = "gstreamer-gl-x11", path = "../gstreamer-gl/x11", optional = true }
|
gst-gl-x11 = { package = "gstreamer-gl-x11", path = "../gstreamer-gl/x11", optional = true }
|
||||||
gst-app = { package = "gstreamer-app", path = "../gstreamer-app" }
|
gst-app = { package = "gstreamer-app", path = "../gstreamer-app" }
|
||||||
gst-audio = { package = "gstreamer-audio", path = "../gstreamer-audio" }
|
gst-audio = { package = "gstreamer-audio", path = "../gstreamer-audio" }
|
||||||
|
@ -61,7 +60,6 @@ overlay-composition = ["pango", "pangocairo", "cairo-rs"]
|
||||||
gl = ["gst-gl", "gl_generator", "glutin"]
|
gl = ["gst-gl", "gl_generator", "glutin"]
|
||||||
gst-gl-x11 = ["dep:gst-gl-x11"]
|
gst-gl-x11 = ["dep:gst-gl-x11"]
|
||||||
gst-gl-egl = ["dep:gst-gl-egl"]
|
gst-gl-egl = ["dep:gst-gl-egl"]
|
||||||
gst-gl-wayland = ["dep:gst-gl-wayland"]
|
|
||||||
allocators = ["gst-allocators", "memmap2", "memfd", "uds"]
|
allocators = ["gst-allocators", "memmap2", "memfd", "uds"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -332,12 +332,12 @@ impl App {
|
||||||
|
|
||||||
let windowed_context = unsafe { windowed_context.make_current().map_err(|(_, err)| err)? };
|
let windowed_context = unsafe { windowed_context.make_current().map_err(|(_, err)| err)? };
|
||||||
|
|
||||||
#[cfg(any(feature = "gst-gl-x11", feature = "gst-gl-wayland"))]
|
#[cfg(any(feature = "gst-gl-x11"))]
|
||||||
let inner_window = windowed_context.window();
|
let inner_window = windowed_context.window();
|
||||||
|
|
||||||
let shared_context: gst_gl::GLContext;
|
let shared_context: gst_gl::GLContext;
|
||||||
if cfg!(target_os = "linux") {
|
if cfg!(target_os = "linux") {
|
||||||
#[cfg(any(feature = "gst-gl-x11", feature = "gst-gl-wayland"))]
|
#[cfg(any(feature = "gst-gl-x11"))]
|
||||||
use glutin::platform::unix::WindowExtUnix;
|
use glutin::platform::unix::WindowExtUnix;
|
||||||
use glutin::platform::{unix::RawHandle, ContextTraitExt};
|
use glutin::platform::{unix::RawHandle, ContextTraitExt};
|
||||||
|
|
||||||
|
@ -345,47 +345,19 @@ impl App {
|
||||||
|
|
||||||
let (gl_context, gl_display, platform) = match unsafe { windowed_context.raw_handle() }
|
let (gl_context, gl_display, platform) = match unsafe { windowed_context.raw_handle() }
|
||||||
{
|
{
|
||||||
#[cfg(any(feature = "gst-gl-egl", feature = "gst-gl-wayland"))]
|
#[cfg(any(feature = "gst-gl-egl"))]
|
||||||
RawHandle::Egl(egl_context) => {
|
RawHandle::Egl(egl_context) => {
|
||||||
let mut gl_display = None;
|
let gl_display =
|
||||||
|
if let Some(display) = unsafe { windowed_context.get_egl_display() } {
|
||||||
#[cfg(feature = "gst-gl-egl")]
|
|
||||||
if let Some(display) = unsafe { windowed_context.get_egl_display() } {
|
|
||||||
gl_display = Some(
|
|
||||||
unsafe { gst_gl_egl::GLDisplayEGL::with_egl_display(display as usize) }
|
unsafe { gst_gl_egl::GLDisplayEGL::with_egl_display(display as usize) }
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.upcast::<gst_gl::GLDisplay>(),
|
} else {
|
||||||
)
|
panic!("EGL window without EGL Display")
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "gst-gl-wayland")]
|
|
||||||
if let Some(display) = inner_window.wayland_display() {
|
|
||||||
let gl_display = gl_display.insert(
|
|
||||||
unsafe {
|
|
||||||
gst_gl_wayland::GLDisplayWayland::with_display(display as usize)
|
|
||||||
}
|
|
||||||
.unwrap()
|
|
||||||
.upcast::<gst_gl::GLDisplay>(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// If using a Wayland display, resolving that to an EGL display _should_
|
|
||||||
// result in the same handle that glutin found (both via eglGetPlatformDisplay(EXT)()).
|
|
||||||
#[cfg(feature = "gst-gl-egl")]
|
|
||||||
{
|
|
||||||
let gl_display =
|
|
||||||
gst_gl_egl::GLDisplayEGL::from_gl_display(gl_display).unwrap();
|
|
||||||
assert_eq!(
|
|
||||||
unsafe { windowed_context.get_egl_display() }
|
|
||||||
.expect("Wayland clients use EGL"),
|
|
||||||
gl_display.handle() as *const std::ffi::c_void,
|
|
||||||
"GLDisplayWayland must use the same EGLDisplay as glutin!"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(
|
(
|
||||||
egl_context as usize,
|
egl_context as usize,
|
||||||
gl_display.expect("Could not retrieve GLDisplay through EGL context and/or Wayland display"),
|
gl_display.upcast::<gst_gl::GLDisplay>(),
|
||||||
gst_gl::GLPlatform::EGL,
|
gst_gl::GLPlatform::EGL,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -394,7 +366,7 @@ impl App {
|
||||||
let gl_display = if let Some(display) = inner_window.xlib_display() {
|
let gl_display = if let Some(display) = inner_window.xlib_display() {
|
||||||
unsafe { gst_gl_x11::GLDisplayX11::with_display(display as usize) }.unwrap()
|
unsafe { gst_gl_x11::GLDisplayX11::with_display(display as usize) }.unwrap()
|
||||||
} else {
|
} else {
|
||||||
panic!("X11 window without X Display");
|
panic!("X11 window without X Display")
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
Loading…
Reference in a new issue