gl: Move EGL/Wayland/X11 manual impls to their own module

And use the new -sys crates.
This commit is contained in:
Marijn Suijten 2020-11-25 20:48:20 +01:00
parent 75bcc8402d
commit efec7d4e31
7 changed files with 85 additions and 34 deletions

View file

@ -7,24 +7,19 @@
// except according to those terms.
use crate::GLDisplayEGL;
use crate::GLDisplayType;
use glib::ffi::gpointer;
use glib::translate::*;
use gst_gl::GLDisplayType;
use libc::uintptr_t;
impl GLDisplayEGL {
pub unsafe fn with_egl_display(
display: uintptr_t,
) -> Result<GLDisplayEGL, glib::error::BoolError> {
let result = from_glib_full(ffi::gst_gl_display_egl_new_with_egl_display(
from_glib_full::<_, Option<GLDisplayEGL>>(ffi::gst_gl_display_egl_new_with_egl_display(
display as gpointer,
));
match result {
Some(d) => Ok(d),
None => Err(glib::glib_bool_error!(
"Failed to create new EGL GL display"
)),
}
))
.ok_or_else(|| glib::glib_bool_error!("Failed to create new EGL GL display"))
}
pub unsafe fn get_from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {

View file

@ -0,0 +1,25 @@
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![cfg_attr(all(not(doctest), doc), feature(doc_cfg))]
pub use ffi;
macro_rules! assert_initialized_main_thread {
() => {
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
};
}
mod auto;
pub use auto::*;
mod gl_display_egl;
pub use gl_display_egl::*;

View file

@ -37,15 +37,6 @@ mod gl_context;
pub use crate::gl_context::GLContextExtManual;
mod gl_display;
pub use crate::gl_display::GL_DISPLAY_CONTEXT_TYPE;
#[cfg(any(feature = "egl", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "egl")))]
mod gl_display_egl;
#[cfg(any(feature = "wayland", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "wayland")))]
mod gl_display_wayland;
#[cfg(any(feature = "x11", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "x11")))]
mod gl_display_x11;
mod gl_video_frame;
pub use crate::gl_video_frame::VideoFrameGLExt;
mod gl_sync_meta;

View file

@ -15,14 +15,9 @@ impl GLDisplayWayland {
pub unsafe fn with_display(
display: uintptr_t,
) -> Result<GLDisplayWayland, glib::error::BoolError> {
let result = from_glib_full(ffi::gst_gl_display_wayland_new_with_display(
from_glib_full::<_, Option<GLDisplayWayland>>(ffi::gst_gl_display_wayland_new_with_display(
display as gpointer,
));
match result {
Some(d) => Ok(d),
None => Err(glib::glib_bool_error!(
"Failed to create new Wayland GL display"
)),
}
))
.ok_or_else(|| glib::glib_bool_error!("Failed to create new Wayland GL display"))
}
}

View file

@ -0,0 +1,25 @@
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![cfg_attr(all(not(doctest), doc), feature(doc_cfg))]
pub use ffi;
macro_rules! assert_initialized_main_thread {
() => {
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
};
}
mod auto;
pub use auto::*;
mod gl_display_wayland;
pub use gl_display_wayland::*;

View file

@ -13,14 +13,9 @@ use libc::uintptr_t;
impl GLDisplayX11 {
pub unsafe fn with_display(display: uintptr_t) -> Result<GLDisplayX11, glib::error::BoolError> {
let result = from_glib_full(ffi::gst_gl_display_x11_new_with_display(
from_glib_full::<_, Option<GLDisplayX11>>(ffi::gst_gl_display_x11_new_with_display(
display as gpointer,
));
match result {
Some(d) => Ok(d),
None => Err(glib::glib_bool_error!(
"Failed to create new X11 GL display"
)),
}
))
.ok_or_else(|| glib::glib_bool_error!("Failed to create new X11 GL display"))
}
}

View file

@ -0,0 +1,25 @@
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![cfg_attr(all(not(doctest), doc), feature(doc_cfg))]
pub use ffi;
macro_rules! assert_initialized_main_thread {
() => {
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
};
}
mod auto;
pub use auto::*;
mod gl_display_x11;
pub use gl_display_x11::*;