From 4e6ddf666325d9055ccb1c152159071070e86524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 26 Feb 2024 11:27:08 +0200 Subject: [PATCH] rtp: Add bindings for new `RTPBaseDepayload::extensions()` property Part-of: --- gstreamer-rtp/Gir.toml | 13 ++++++-- gstreamer-rtp/src/rtp_base_depayload.rs | 44 ++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/gstreamer-rtp/Gir.toml b/gstreamer-rtp/Gir.toml index 0155a13a1..bc1deec10 100644 --- a/gstreamer-rtp/Gir.toml +++ b/gstreamer-rtp/Gir.toml @@ -21,7 +21,6 @@ generate = [ "GstRtp.RTCPSDESType", "GstRtp.RTCPType", "GstRtp.RTCPXRType", - "GstRtp.RTPBaseDepayload", "GstRtp.RTPHeaderExtensionDirection", "GstRtp.RTPHeaderExtensionFlags", "GstRtp.RTPPayload", @@ -82,10 +81,20 @@ status = "generate" name = "rtp_source_meta_api_get_type" ignore = true +[[object]] +name = "GstRtp.RTPBaseDepayload" +status = "generate" +manual_traits = ["RTPBaseDepayloadExtManual"] + + [[object.property]] + name = "extensions" + # use proper type + ignore = true + [[object]] name = "GstRtp.RTPBasePayload" status = "generate" -manual_traits = ["RTPHeaderExtensionExtManual"] +manual_traits = ["RTPBasePayloadExtManual"] [[object.function]] name = "set_outcaps" diff --git a/gstreamer-rtp/src/rtp_base_depayload.rs b/gstreamer-rtp/src/rtp_base_depayload.rs index f30d7f341..01b9f8f98 100644 --- a/gstreamer-rtp/src/rtp_base_depayload.rs +++ b/gstreamer-rtp/src/rtp_base_depayload.rs @@ -1,4 +1,4 @@ -use glib::object::IsA; +use glib::{prelude::*, translate::*}; use crate::RTPBaseDepayload; @@ -8,6 +8,48 @@ mod sealed { } pub trait RTPBaseDepayloadExtManual: sealed::Sealed + IsA + 'static { + #[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::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 = 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::GstRTPBaseDepayload);