1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::ffi;
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// the contents of a [`GLDisplayEGL`][crate::GLDisplayEGL] are private and should only be accessed
    /// through the provided API
    ///
    /// # Implements
    ///
    /// [`trait@gst_gl::prelude::GLDisplayExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
    #[doc(alias = "GstGLDisplayEGL")]
    pub struct GLDisplayEGL(Object<ffi::GstGLDisplayEGL, ffi::GstGLDisplayEGLClass>) @extends gst_gl::GLDisplay, gst::Object;

    match fn {
        type_ => || ffi::gst_gl_display_egl_get_type(),
    }
}

impl GLDisplayEGL {
    pub const NONE: Option<&'static GLDisplayEGL> = None;

    /// Create a new [`GLDisplayEGL`][crate::GLDisplayEGL] using the default EGL_DEFAULT_DISPLAY.
    ///
    /// # Returns
    ///
    /// a new [`GLDisplayEGL`][crate::GLDisplayEGL] or [`None`]
    #[doc(alias = "gst_gl_display_egl_new")]
    pub fn new() -> Result<GLDisplayEGL, glib::BoolError> {
        assert_initialized_main_thread!();
        unsafe {
            Option::<_>::from_glib_full(ffi::gst_gl_display_egl_new())
                .ok_or_else(|| glib::bool_error!("Failed to create EGL display"))
        }
    }

    /// Create a new surfaceless [`GLDisplayEGL`][crate::GLDisplayEGL] using the Mesa3D
    /// EGL_PLATFORM_SURFACELESS_MESA extension.
    ///
    /// # Returns
    ///
    /// a new [`GLDisplayEGL`][crate::GLDisplayEGL] or [`None`]
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    #[doc(alias = "gst_gl_display_egl_new_surfaceless")]
    pub fn new_surfaceless() -> Result<GLDisplayEGL, glib::BoolError> {
        assert_initialized_main_thread!();
        unsafe {
            Option::<_>::from_glib_full(ffi::gst_gl_display_egl_new_surfaceless())
                .ok_or_else(|| glib::bool_error!("Failed to create surfaceless EGL display"))
        }
    }

    /// Creates a EGL display connection from a native Display.
    ///
    /// This function will return the same value for multiple calls with the same
    /// `display`.
    /// ## `display`
    /// an existing [`gst_gl::GLDisplay`][crate::gst_gl::GLDisplay]
    ///
    /// # Returns
    ///
    /// a new [`GLDisplayEGL`][crate::GLDisplayEGL]
    #[doc(alias = "gst_gl_display_egl_from_gl_display")]
    pub fn from_gl_display(display: &impl IsA<gst_gl::GLDisplay>) -> Option<GLDisplayEGL> {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_gl_display_egl_from_gl_display(
                display.as_ref().to_glib_none().0,
            ))
        }
    }
}

unsafe impl Send for GLDisplayEGL {}
unsafe impl Sync for GLDisplayEGL {}