diff --git a/gstreamer-rtp/Gir.toml b/gstreamer-rtp/Gir.toml index 4b53d7b33..473307113 100644 --- a/gstreamer-rtp/Gir.toml +++ b/gstreamer-rtp/Gir.toml @@ -97,6 +97,11 @@ manual_traits = ["RTPHeaderExtensionExtManual"] manual = true rename = "set_outcaps" + [[object.property]] + name = "extensions" + # use proper type + ignore = true + [[object]] name = "GstRtp.RTPBuffer" status = "manual" diff --git a/gstreamer-rtp/src/rtp_base_payload.rs b/gstreamer-rtp/src/rtp_base_payload.rs index ed9e93fff..962cedc35 100644 --- a/gstreamer-rtp/src/rtp_base_payload.rs +++ b/gstreamer-rtp/src/rtp_base_payload.rs @@ -1,6 +1,6 @@ use std::ptr; -use glib::{object::IsA, translate::*}; +use glib::{prelude::*, translate::*}; use crate::RTPBasePayload; @@ -28,6 +28,48 @@ pub trait RTPBasePayloadExtManual: sealed::Sealed + IsA + 'stati } } + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + fn extensions(&self) -> Vec { + let extensions = self.as_ref().property::("extensions"); + + extensions + .iter() + .map(|v| v.get::().unwrap()) + .collect() + } + + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + #[doc(alias = "extensions")] + fn connect_extensions_notify( + &self, + f: F, + ) -> glib::SignalHandlerId { + unsafe extern "C" fn notify_extensions_trampoline< + P: IsA, + F: Fn(&P) + Send + Sync + 'static, + >( + this: *mut ffi::GstRTPBasePayload, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(RTPBasePayload::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box = 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:: as *const (), + )), + Box::into_raw(f), + ) + } + } + fn sink_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstRTPBasePayload);