Skip to main content

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    #[doc(alias = "gst_gl_display_egl_get_from_native")]
30    #[doc(alias = "get_from_native")]
31    pub unsafe fn from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {
32        unsafe { ffi::gst_gl_display_egl_get_from_native(display_type.into_glib(), display) }
33    }
34}