diff --git a/gstreamer-gl/src/gl_display_egl.rs b/gstreamer-gl/egl/src/gl_display_egl.rs similarity index 73% rename from gstreamer-gl/src/gl_display_egl.rs rename to gstreamer-gl/egl/src/gl_display_egl.rs index ecf72aa1a..59b53bd22 100644 --- a/gstreamer-gl/src/gl_display_egl.rs +++ b/gstreamer-gl/egl/src/gl_display_egl.rs @@ -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 { - let result = from_glib_full(ffi::gst_gl_display_egl_new_with_egl_display( + from_glib_full::<_, Option>(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 { diff --git a/gstreamer-gl/egl/src/lib.rs b/gstreamer-gl/egl/src/lib.rs new file mode 100644 index 000000000..51beac6b2 --- /dev/null +++ b/gstreamer-gl/egl/src/lib.rs @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Sebastian Dröge +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , 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::*; diff --git a/gstreamer-gl/src/lib.rs b/gstreamer-gl/src/lib.rs index 9fd9f2a93..9294c0e7e 100644 --- a/gstreamer-gl/src/lib.rs +++ b/gstreamer-gl/src/lib.rs @@ -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; diff --git a/gstreamer-gl/src/gl_display_wayland.rs b/gstreamer-gl/wayland/src/gl_display_wayland.rs similarity index 69% rename from gstreamer-gl/src/gl_display_wayland.rs rename to gstreamer-gl/wayland/src/gl_display_wayland.rs index bcf5c052b..f5c993470 100644 --- a/gstreamer-gl/src/gl_display_wayland.rs +++ b/gstreamer-gl/wayland/src/gl_display_wayland.rs @@ -15,14 +15,9 @@ impl GLDisplayWayland { pub unsafe fn with_display( display: uintptr_t, ) -> Result { - let result = from_glib_full(ffi::gst_gl_display_wayland_new_with_display( + from_glib_full::<_, Option>(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")) } } diff --git a/gstreamer-gl/wayland/src/lib.rs b/gstreamer-gl/wayland/src/lib.rs new file mode 100644 index 000000000..5b1a03452 --- /dev/null +++ b/gstreamer-gl/wayland/src/lib.rs @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Sebastian Dröge +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , 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::*; diff --git a/gstreamer-gl/src/gl_display_x11.rs b/gstreamer-gl/x11/src/gl_display_x11.rs similarity index 69% rename from gstreamer-gl/src/gl_display_x11.rs rename to gstreamer-gl/x11/src/gl_display_x11.rs index c136b6585..e5719f07b 100644 --- a/gstreamer-gl/src/gl_display_x11.rs +++ b/gstreamer-gl/x11/src/gl_display_x11.rs @@ -13,14 +13,9 @@ use libc::uintptr_t; impl GLDisplayX11 { pub unsafe fn with_display(display: uintptr_t) -> Result { - let result = from_glib_full(ffi::gst_gl_display_x11_new_with_display( + from_glib_full::<_, Option>(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")) } } diff --git a/gstreamer-gl/x11/src/lib.rs b/gstreamer-gl/x11/src/lib.rs new file mode 100644 index 000000000..9670f7e07 --- /dev/null +++ b/gstreamer-gl/x11/src/lib.rs @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Sebastian Dröge +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , 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::*;