mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
gl: Move EGL/Wayland/X11 manual impls to their own module
And use the new -sys crates.
This commit is contained in:
parent
75bcc8402d
commit
efec7d4e31
7 changed files with 85 additions and 34 deletions
|
@ -7,24 +7,19 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use crate::GLDisplayEGL;
|
use crate::GLDisplayEGL;
|
||||||
use crate::GLDisplayType;
|
|
||||||
use glib::ffi::gpointer;
|
use glib::ffi::gpointer;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
use gst_gl::GLDisplayType;
|
||||||
use libc::uintptr_t;
|
use libc::uintptr_t;
|
||||||
|
|
||||||
impl GLDisplayEGL {
|
impl GLDisplayEGL {
|
||||||
pub unsafe fn with_egl_display(
|
pub unsafe fn with_egl_display(
|
||||||
display: uintptr_t,
|
display: uintptr_t,
|
||||||
) -> Result<GLDisplayEGL, glib::error::BoolError> {
|
) -> 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,
|
display as gpointer,
|
||||||
));
|
))
|
||||||
match result {
|
.ok_or_else(|| glib::glib_bool_error!("Failed to create new EGL GL display"))
|
||||||
Some(d) => Ok(d),
|
|
||||||
None => Err(glib::glib_bool_error!(
|
|
||||||
"Failed to create new EGL GL display"
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn get_from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {
|
pub unsafe fn get_from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {
|
25
gstreamer-gl/egl/src/lib.rs
Normal file
25
gstreamer-gl/egl/src/lib.rs
Normal 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::*;
|
|
@ -37,15 +37,6 @@ mod gl_context;
|
||||||
pub use crate::gl_context::GLContextExtManual;
|
pub use crate::gl_context::GLContextExtManual;
|
||||||
mod gl_display;
|
mod gl_display;
|
||||||
pub use crate::gl_display::GL_DISPLAY_CONTEXT_TYPE;
|
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;
|
mod gl_video_frame;
|
||||||
pub use crate::gl_video_frame::VideoFrameGLExt;
|
pub use crate::gl_video_frame::VideoFrameGLExt;
|
||||||
mod gl_sync_meta;
|
mod gl_sync_meta;
|
||||||
|
|
|
@ -15,14 +15,9 @@ impl GLDisplayWayland {
|
||||||
pub unsafe fn with_display(
|
pub unsafe fn with_display(
|
||||||
display: uintptr_t,
|
display: uintptr_t,
|
||||||
) -> Result<GLDisplayWayland, glib::error::BoolError> {
|
) -> 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,
|
display as gpointer,
|
||||||
));
|
))
|
||||||
match result {
|
.ok_or_else(|| glib::glib_bool_error!("Failed to create new Wayland GL display"))
|
||||||
Some(d) => Ok(d),
|
|
||||||
None => Err(glib::glib_bool_error!(
|
|
||||||
"Failed to create new Wayland GL display"
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
25
gstreamer-gl/wayland/src/lib.rs
Normal file
25
gstreamer-gl/wayland/src/lib.rs
Normal 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::*;
|
|
@ -13,14 +13,9 @@ use libc::uintptr_t;
|
||||||
|
|
||||||
impl GLDisplayX11 {
|
impl GLDisplayX11 {
|
||||||
pub unsafe fn with_display(display: uintptr_t) -> Result<GLDisplayX11, glib::error::BoolError> {
|
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,
|
display as gpointer,
|
||||||
));
|
))
|
||||||
match result {
|
.ok_or_else(|| glib::glib_bool_error!("Failed to create new X11 GL display"))
|
||||||
Some(d) => Ok(d),
|
|
||||||
None => Err(glib::glib_bool_error!(
|
|
||||||
"Failed to create new X11 GL display"
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
25
gstreamer-gl/x11/src/lib.rs
Normal file
25
gstreamer-gl/x11/src/lib.rs
Normal 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::*;
|
Loading…
Reference in a new issue