gstreamer_gl_egl/auto/gl_display_egl.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 /// the contents of a [`GLDisplayEGL`][crate::GLDisplayEGL] are private and should only be accessed
11 /// through the provided API
12 ///
13 /// # Implements
14 ///
15 /// [`GLDisplayEGLExt`][trait@crate::prelude::GLDisplayEGLExt], [`trait@gst_gl::prelude::GLDisplayExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
16 #[doc(alias = "GstGLDisplayEGL")]
17 pub struct GLDisplayEGL(Object<ffi::GstGLDisplayEGL, ffi::GstGLDisplayEGLClass>) @extends gst_gl::GLDisplay, gst::Object;
18
19 match fn {
20 type_ => || ffi::gst_gl_display_egl_get_type(),
21 }
22}
23
24impl GLDisplayEGL {
25 pub const NONE: Option<&'static GLDisplayEGL> = None;
26
27 /// Create a new [`GLDisplayEGL`][crate::GLDisplayEGL] using the default EGL_DEFAULT_DISPLAY.
28 ///
29 /// The returned [`GLDisplayEGL`][crate::GLDisplayEGL] will by default free all EGL resources when
30 /// finalized. See [`GLDisplayEGLExt::set_foreign()`][crate::prelude::GLDisplayEGLExt::set_foreign()] for details on if you need
31 /// the EGLDisplay to remain alive.
32 ///
33 /// # Returns
34 ///
35 /// a new [`GLDisplayEGL`][crate::GLDisplayEGL] or [`None`]
36 #[doc(alias = "gst_gl_display_egl_new")]
37 pub fn new() -> Result<GLDisplayEGL, glib::BoolError> {
38 assert_initialized_main_thread!();
39 unsafe {
40 Option::<_>::from_glib_full(ffi::gst_gl_display_egl_new())
41 .ok_or_else(|| glib::bool_error!("Failed to create EGL display"))
42 }
43 }
44
45 /// Create a new surfaceless [`GLDisplayEGL`][crate::GLDisplayEGL] using the Mesa3D
46 /// EGL_PLATFORM_SURFACELESS_MESA extension.
47 ///
48 /// # Returns
49 ///
50 /// a new [`GLDisplayEGL`][crate::GLDisplayEGL] or [`None`]
51 #[cfg(feature = "v1_24")]
52 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
53 #[doc(alias = "gst_gl_display_egl_new_surfaceless")]
54 pub fn new_surfaceless() -> Result<GLDisplayEGL, glib::BoolError> {
55 assert_initialized_main_thread!();
56 unsafe {
57 Option::<_>::from_glib_full(ffi::gst_gl_display_egl_new_surfaceless())
58 .ok_or_else(|| glib::bool_error!("Failed to create surfaceless EGL display"))
59 }
60 }
61
62 /// Creates a EGL display connection from a native Display.
63 ///
64 /// This function will return the same value for multiple calls with the same
65 /// `display`.
66 ///
67 /// The returned [`GLDisplayEGL`][crate::GLDisplayEGL] will *not* be marked as foreign and will free
68 /// some display global EGL resources on finalization. If an external API/user
69 /// will be also handling the lifetime of the `EGLDisplay`, you should mark the
70 /// returned [`GLDisplayEGL`][crate::GLDisplayEGL] as foreign by calling [`GLDisplayEGLExt::set_foreign()`][crate::prelude::GLDisplayEGLExt::set_foreign()].
71 /// ## `display`
72 /// an existing [`gst_gl::GLDisplay`][crate::gst_gl::GLDisplay]
73 ///
74 /// # Returns
75 ///
76 /// a new [`GLDisplayEGL`][crate::GLDisplayEGL]
77 #[doc(alias = "gst_gl_display_egl_from_gl_display")]
78 pub fn from_gl_display(display: &impl IsA<gst_gl::GLDisplay>) -> Option<GLDisplayEGL> {
79 assert_initialized_main_thread!();
80 unsafe {
81 from_glib_full(ffi::gst_gl_display_egl_from_gl_display(
82 display.as_ref().to_glib_none().0,
83 ))
84 }
85 }
86}
87
88unsafe impl Send for GLDisplayEGL {}
89unsafe impl Sync for GLDisplayEGL {}
90
91/// Trait containing all [`struct@GLDisplayEGL`] methods.
92///
93/// # Implementors
94///
95/// [`GLDisplayEGL`][struct@crate::GLDisplayEGL]
96pub trait GLDisplayEGLExt: IsA<GLDisplayEGL> + 'static {
97 /// Configure whether or not this EGL display is foreign and is managed by an
98 /// external application/library.
99 ///
100 /// A display marked as foreign will not have display global resources freed when
101 /// this display is finalized. As such, any external API using the same
102 /// `EGLDisplay` must keep the `EGLDisplay` alive while GStreamer is using any
103 /// EGL or GL resources associated with that `EGLDisplay`. The reverse is also
104 /// true and a foreign [`GLDisplayEGL`][crate::GLDisplayEGL] must not be used after the associated
105 /// `EGLDisplay` has been destroyed externally with `eglTerminate()`.
106 ///
107 /// A non-foreign [`GLDisplayEGL`][crate::GLDisplayEGL] will destroy the associated `EGLDisplay` on
108 /// finalization. This can also be useful when a user would like GStreamer to
109 /// assume ownership of the `EGLDisplay` after calling e.g.
110 /// [`GLDisplayEGL::with_egl_display()`][crate::GLDisplayEGL::with_egl_display()].
111 /// ## `foreign`
112 /// whether `self` should be marked as containing a foreign
113 /// `EGLDisplay`
114 #[cfg(feature = "v1_26")]
115 #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
116 #[doc(alias = "gst_gl_display_egl_set_foreign")]
117 fn set_foreign(&self, foreign: bool) {
118 unsafe {
119 ffi::gst_gl_display_egl_set_foreign(
120 self.as_ref().to_glib_none().0,
121 foreign.into_glib(),
122 );
123 }
124 }
125}
126
127impl<O: IsA<GLDisplayEGL>> GLDisplayEGLExt for O {}