2024-02-26 09:27:08 +00:00
|
|
|
use glib::{prelude::*, translate::*};
|
2023-01-03 18:58:25 +00:00
|
|
|
|
2022-04-13 13:38:59 +00:00
|
|
|
use crate::RTPBaseDepayload;
|
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
mod sealed {
|
|
|
|
pub trait Sealed {}
|
|
|
|
impl<T: super::IsA<super::RTPBaseDepayload>> Sealed for T {}
|
2022-04-13 13:38:59 +00:00
|
|
|
}
|
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
pub trait RTPBaseDepayloadExtManual: sealed::Sealed + IsA<RTPBaseDepayload> + 'static {
|
2024-02-26 09:27:08 +00:00
|
|
|
#[cfg(feature = "v1_24")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
|
|
|
fn extensions(&self) -> Vec<crate::RTPHeaderExtension> {
|
|
|
|
let extensions = self.as_ref().property::<gst::Array>("extensions");
|
|
|
|
|
|
|
|
extensions
|
|
|
|
.iter()
|
|
|
|
.map(|v| v.get::<crate::RTPHeaderExtension>().unwrap())
|
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "v1_24")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
|
|
|
#[doc(alias = "extensions")]
|
|
|
|
fn connect_extensions_notify<F: Fn(&Self) + Send + Sync + 'static>(
|
|
|
|
&self,
|
|
|
|
f: F,
|
|
|
|
) -> glib::SignalHandlerId {
|
|
|
|
unsafe extern "C" fn notify_extensions_trampoline<
|
|
|
|
P: IsA<RTPBaseDepayload>,
|
|
|
|
F: Fn(&P) + Send + Sync + 'static,
|
|
|
|
>(
|
|
|
|
this: *mut ffi::GstRTPBaseDepayload,
|
|
|
|
_param_spec: glib::ffi::gpointer,
|
|
|
|
f: glib::ffi::gpointer,
|
|
|
|
) {
|
|
|
|
let f: &F = &*(f as *const F);
|
|
|
|
f(RTPBaseDepayload::from_glib_borrow(this).unsafe_cast_ref())
|
|
|
|
}
|
|
|
|
unsafe {
|
|
|
|
let f: Box<F> = Box::new(f);
|
|
|
|
glib::signal::connect_raw(
|
|
|
|
self.as_ptr() as *mut _,
|
|
|
|
b"notify::extensions\0".as_ptr() as *const _,
|
|
|
|
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
|
|
|
|
notify_extensions_trampoline::<Self, F> as *const (),
|
|
|
|
)),
|
|
|
|
Box::into_raw(f),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-05 10:24:46 +00:00
|
|
|
fn sink_pad(&self) -> &gst::Pad {
|
2022-05-03 22:04:08 +00:00
|
|
|
unsafe {
|
2022-05-05 10:24:46 +00:00
|
|
|
let elt = &*(self.as_ptr() as *const ffi::GstRTPBaseDepayload);
|
|
|
|
&*(&elt.sinkpad as *const *mut gst::ffi::GstPad as *const gst::Pad)
|
2022-05-03 22:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-05 10:24:46 +00:00
|
|
|
fn src_pad(&self) -> &gst::Pad {
|
2022-05-03 22:04:08 +00:00
|
|
|
unsafe {
|
2022-05-05 10:24:46 +00:00
|
|
|
let elt = &*(self.as_ptr() as *const ffi::GstRTPBaseDepayload);
|
|
|
|
&*(&elt.srcpad as *const *mut gst::ffi::GstPad as *const gst::Pad)
|
2022-05-03 22:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-13 13:38:59 +00:00
|
|
|
}
|
2023-07-05 20:21:43 +00:00
|
|
|
|
|
|
|
impl<O: IsA<RTPBaseDepayload>> RTPBaseDepayloadExtManual for O {}
|