1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::{mem, ptr};
4
5use glib::{prelude::*, translate::*};
6use gst::prelude::*;
7
8use crate::BaseTransform;
9
10mod sealed {
11 pub trait Sealed {}
12 impl<T: super::IsA<super::BaseTransform>> Sealed for T {}
13}
14
15pub trait BaseTransformExtManual: sealed::Sealed + IsA<BaseTransform> + 'static {
16 #[doc(alias = "get_allocator")]
17 #[doc(alias = "gst_base_transform_get_allocator")]
18 fn allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams) {
19 unsafe {
20 let mut allocator = ptr::null_mut();
21 let mut params = mem::MaybeUninit::uninit();
22 ffi::gst_base_transform_get_allocator(
23 self.as_ref().to_glib_none().0,
24 &mut allocator,
25 params.as_mut_ptr(),
26 );
27 (from_glib_full(allocator), params.assume_init().into())
28 }
29 }
30
31 #[doc(alias = "get_segment")]
32 fn segment(&self) -> gst::Segment {
33 unsafe {
34 let trans: &ffi::GstBaseTransform = &*(self.as_ptr() as *const _);
35 let _guard = self.as_ref().object_lock();
36 from_glib_none(&trans.segment as *const _)
37 }
38 }
39
40 fn sink_pad(&self) -> &gst::Pad {
41 unsafe {
42 let elt = &*(self.as_ptr() as *const ffi::GstBaseTransform);
43 &*(&elt.sinkpad as *const *mut gst::ffi::GstPad as *const gst::Pad)
44 }
45 }
46
47 fn src_pad(&self) -> &gst::Pad {
48 unsafe {
49 let elt = &*(self.as_ptr() as *const ffi::GstBaseTransform);
50 &*(&elt.srcpad as *const *mut gst::ffi::GstPad as *const gst::Pad)
51 }
52 }
53}
54
55impl<O: IsA<BaseTransform>> BaseTransformExtManual for O {}
56