gstreamer_gl_egl/gl_display_egl.rs
1// Copyright (C) 2018 Víctor Jáquez <vjaquez@igalia.com>
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use glib::{ffi::gpointer, translate::*};
10use gst_gl::GLDisplayType;
11use libc::uintptr_t;
12
13use crate::{ffi, GLDisplayEGL};
14
15impl GLDisplayEGL {
16 #[doc(alias = "gst_gl_display_egl_new_with_egl_display")]
17 #[doc(alias = "new_with_egl_display")]
18 pub unsafe fn with_egl_display(
19 display: uintptr_t,
20 ) -> Result<GLDisplayEGL, glib::error::BoolError> {
21 from_glib_full::<_, Option<GLDisplayEGL>>(ffi::gst_gl_display_egl_new_with_egl_display(
22 display as gpointer,
23 ))
24 .ok_or_else(|| glib::bool_error!("Failed to create new EGL GL display"))
25 }
26
27 /// Attempts to create a new `EGLDisplay` from `display`. If `type_` is
28 /// `GST_GL_DISPLAY_TYPE_ANY` or `GST_GL_DISPLAY_TYPE_EGL_SURFACELESS`, then
29 /// `display` must be 0. `type_` must not be `GST_GL_DISPLAY_TYPE_NONE`.
30 /// ## `type_`
31 /// a `GstGLDisplayType`
32 /// ## `display`
33 /// pointer to a display (or 0)
34 ///
35 /// # Returns
36 ///
37 /// A `EGLDisplay` or `EGL_NO_DISPLAY`
38 #[doc(alias = "gst_gl_display_egl_get_from_native")]
39 #[doc(alias = "get_from_native")]
40 pub unsafe fn from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {
41 ffi::gst_gl_display_egl_get_from_native(display_type.into_glib(), display)
42 }
43}