| 1 | use std::ptr; |
| 2 | |
| 3 | use glib::{object::IsA, translate::*}; |
| 4 | |
| 5 | pub use crate::auto::functions::*; |
| 6 | use crate::{ffi, GLContext, GLDisplay}; |
| 7 | |
| 8 | #[doc (alias = "gst_gl_handle_context_query" )] |
| 9 | pub fn gl_handle_context_query( |
| 10 | element: &impl IsA<gst::Element>, |
| 11 | query: &mut gst::query::Context, |
| 12 | display: Option<&impl IsA<GLDisplay>>, |
| 13 | context: Option<&impl IsA<GLContext>>, |
| 14 | other_context: Option<&impl IsA<GLContext>>, |
| 15 | ) -> bool { |
| 16 | skip_assert_initialized!(); |
| 17 | unsafe { |
| 18 | from_glib(val:ffi::gst_gl_handle_context_query( |
| 19 | element.as_ref().to_glib_none().0, |
| 20 | query.as_mut_ptr(), |
| 21 | display.map(|p: &impl IsA| p.as_ref()).to_glib_none().0, |
| 22 | context.map(|p: &impl IsA| p.as_ref()).to_glib_none().0, |
| 23 | other_context.map(|p: &impl IsA| p.as_ref()).to_glib_none().0, |
| 24 | )) |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | #[doc (alias = "gst_gl_handle_set_context" )] |
| 29 | pub fn gl_handle_set_context( |
| 30 | element: &impl IsA<gst::Element>, |
| 31 | context: &gst::Context, |
| 32 | ) -> (Option<GLDisplay>, Option<GLContext>) { |
| 33 | skip_assert_initialized!(); |
| 34 | unsafe { |
| 35 | let mut display: *mut GstGLDisplay = ptr::null_mut(); |
| 36 | let mut other_context: *mut GstGLContext = ptr::null_mut(); |
| 37 | let ret: bool = from_glib(val:ffi::gst_gl_handle_set_context( |
| 38 | element.as_ref().to_glib_none().0, |
| 39 | context.to_glib_none().0, |
| 40 | &mut display, |
| 41 | &mut other_context, |
| 42 | )); |
| 43 | if ret { |
| 44 | (from_glib_full(ptr:display), from_glib_full(ptr:other_context)) |
| 45 | } else { |
| 46 | (None, None) |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | #[cfg (feature = "v1_24" )] |
| 52 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_24" )))] |
| 53 | #[doc (alias = "gst_gl_swizzle_invert" )] |
| 54 | pub fn gl_swizzle_invert(swizzle: [i32; 4]) -> [i32; 4] { |
| 55 | unsafe { |
| 56 | use std::mem; |
| 57 | |
| 58 | let mut inversion = mem::MaybeUninit::uninit(); |
| 59 | ffi::gst_gl_swizzle_invert( |
| 60 | mut_override(swizzle.as_ptr() as *const _), |
| 61 | inversion.as_mut_ptr(), |
| 62 | ); |
| 63 | inversion.assume_init() |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | #[cfg (feature = "v1_24" )] |
| 68 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_24" )))] |
| 69 | #[doc (alias = "gst_gl_video_format_swizzle" )] |
| 70 | pub fn gl_video_format_swizzle(video_format: gst_video::VideoFormat) -> Option<[i32; 4]> { |
| 71 | unsafe { |
| 72 | use std::mem; |
| 73 | |
| 74 | let mut swizzle = mem::MaybeUninit::uninit(); |
| 75 | let res = from_glib(ffi::gst_gl_video_format_swizzle( |
| 76 | video_format.into_glib(), |
| 77 | swizzle.as_mut_ptr(), |
| 78 | )); |
| 79 | if res { |
| 80 | Some(swizzle.assume_init()) |
| 81 | } else { |
| 82 | None |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |