gstreamer_base/
base_transform.rs

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::{ffi, BaseTransform};
9
10pub trait BaseTransformExtManual: IsA<BaseTransform> + 'static {
11    #[doc(alias = "get_allocator")]
12    #[doc(alias = "gst_base_transform_get_allocator")]
13    fn allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams) {
14        unsafe {
15            let mut allocator = ptr::null_mut();
16            let mut params = mem::MaybeUninit::uninit();
17            ffi::gst_base_transform_get_allocator(
18                self.as_ref().to_glib_none().0,
19                &mut allocator,
20                params.as_mut_ptr(),
21            );
22            (from_glib_full(allocator), params.assume_init().into())
23        }
24    }
25
26    #[doc(alias = "get_segment")]
27    fn segment(&self) -> gst::Segment {
28        unsafe {
29            let trans: &ffi::GstBaseTransform = &*(self.as_ptr() as *const _);
30            let sinkpad = self.sink_pad();
31            let _guard = sinkpad.stream_lock();
32            from_glib_none(&trans.segment as *const _)
33        }
34    }
35
36    fn sink_pad(&self) -> &gst::Pad {
37        unsafe {
38            let elt = &*(self.as_ptr() as *const ffi::GstBaseTransform);
39            &*(&elt.sinkpad as *const *mut gst::ffi::GstPad as *const gst::Pad)
40        }
41    }
42
43    fn src_pad(&self) -> &gst::Pad {
44        unsafe {
45            let elt = &*(self.as_ptr() as *const ffi::GstBaseTransform);
46            &*(&elt.srcpad as *const *mut gst::ffi::GstPad as *const gst::Pad)
47        }
48    }
49}
50
51impl<O: IsA<BaseTransform>> BaseTransformExtManual for O {}