gstreamer_rtp/
rtp_base_depayload.rs

1use glib::prelude::*;
2#[cfg(feature = "v1_24")]
3#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
4use glib::translate::*;
5
6use crate::{ffi, RTPBaseDepayload};
7
8pub trait RTPBaseDepayloadExtManual: IsA<RTPBaseDepayload> + 'static {
9    #[cfg(feature = "v1_24")]
10    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
11    fn extensions(&self) -> Vec<crate::RTPHeaderExtension> {
12        let extensions = self.as_ref().property::<gst::Array>("extensions");
13
14        extensions
15            .iter()
16            .map(|v| v.get::<crate::RTPHeaderExtension>().unwrap())
17            .collect()
18    }
19
20    #[cfg(feature = "v1_24")]
21    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
22    #[doc(alias = "extensions")]
23    fn connect_extensions_notify<F: Fn(&Self) + Send + Sync + 'static>(
24        &self,
25        f: F,
26    ) -> glib::SignalHandlerId {
27        unsafe extern "C" fn notify_extensions_trampoline<
28            P: IsA<RTPBaseDepayload>,
29            F: Fn(&P) + Send + Sync + 'static,
30        >(
31            this: *mut ffi::GstRTPBaseDepayload,
32            _param_spec: glib::ffi::gpointer,
33            f: glib::ffi::gpointer,
34        ) {
35            let f: &F = &*(f as *const F);
36            f(RTPBaseDepayload::from_glib_borrow(this).unsafe_cast_ref())
37        }
38        unsafe {
39            let f: Box<F> = Box::new(f);
40            glib::signal::connect_raw(
41                self.as_ptr() as *mut _,
42                b"notify::extensions\0".as_ptr() as *const _,
43                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
44                    notify_extensions_trampoline::<Self, F> as *const (),
45                )),
46                Box::into_raw(f),
47            )
48        }
49    }
50
51    fn sink_pad(&self) -> &gst::Pad {
52        unsafe {
53            let elt = &*(self.as_ptr() as *const ffi::GstRTPBaseDepayload);
54            &*(&elt.sinkpad as *const *mut gst::ffi::GstPad as *const gst::Pad)
55        }
56    }
57
58    fn src_pad(&self) -> &gst::Pad {
59        unsafe {
60            let elt = &*(self.as_ptr() as *const ffi::GstRTPBaseDepayload);
61            &*(&elt.srcpad as *const *mut gst::ffi::GstPad as *const gst::Pad)
62        }
63    }
64}
65
66impl<O: IsA<RTPBaseDepayload>> RTPBaseDepayloadExtManual for O {}