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::{GLDisplayEGL, ffi};
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 unsafe {
22 from_glib_full::<_, Option<GLDisplayEGL>>(ffi::gst_gl_display_egl_new_with_egl_display(
23 display as gpointer,
24 ))
25 .ok_or_else(|| glib::bool_error!("Failed to create new EGL GL display"))
26 }
27 }
28
29 /// Attempts to create a new `EGLDisplay` from `display`. If `type_` is
30 /// `GST_GL_DISPLAY_TYPE_ANY` or `GST_GL_DISPLAY_TYPE_EGL_SURFACELESS`, then
31 /// `display` must be 0. `type_` must not be `GST_GL_DISPLAY_TYPE_NONE`.
32 /// ## `type_`
33 /// a `GstGLDisplayType`
34 /// ## `display`
35 /// pointer to a display (or 0)
36 ///
37 /// # Returns
38 ///
39 /// A `EGLDisplay` or `EGL_NO_DISPLAY`
40 #[doc(alias = "gst_gl_display_egl_get_from_native")]
41 #[doc(alias = "get_from_native")]
42 pub unsafe fn from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {
43 unsafe { ffi::gst_gl_display_egl_get_from_native(display_type.into_glib(), display) }
44 }
45}