gstreamer_gl/
context.rs
1use std::ptr;
4
5use glib::{prelude::*, translate::*};
6use gst::ContextRef;
7
8use crate::{ffi, GLDisplay};
9
10pub trait ContextGLExt {
11 #[doc(alias = "get_gl_display")]
12 #[doc(alias = "gst_context_get_gl_display")]
13 fn gl_display(&self) -> Option<GLDisplay>;
14 #[doc(alias = "gst_context_set_gl_display")]
15 fn set_gl_display<'a, T: IsA<GLDisplay>>(&self, display: impl Into<Option<&'a T>>);
16}
17
18impl ContextGLExt for ContextRef {
19 fn gl_display(&self) -> Option<GLDisplay> {
20 unsafe {
21 let mut display = ptr::null_mut();
22 if from_glib(ffi::gst_context_get_gl_display(
23 self.as_mut_ptr(),
24 &mut display,
25 )) {
26 Some(from_glib_full(display))
27 } else {
28 None
29 }
30 }
31 }
32
33 fn set_gl_display<'a, T: IsA<GLDisplay>>(&self, display: impl Into<Option<&'a T>>) {
34 unsafe {
35 ffi::gst_context_set_gl_display(
36 self.as_mut_ptr(),
37 display.into().map(|d| d.as_ref()).to_glib_none().0,
38 );
39 }
40 }
41}