rtp: Add bindings for new RTPBaseDepayload::extensions() property

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1401>
This commit is contained in:
Sebastian Dröge 2024-02-26 11:27:08 +02:00 committed by GStreamer Marge Bot
parent ab0a29b765
commit 4e6ddf6663
2 changed files with 54 additions and 3 deletions

View file

@ -21,7 +21,6 @@ generate = [
"GstRtp.RTCPSDESType", "GstRtp.RTCPSDESType",
"GstRtp.RTCPType", "GstRtp.RTCPType",
"GstRtp.RTCPXRType", "GstRtp.RTCPXRType",
"GstRtp.RTPBaseDepayload",
"GstRtp.RTPHeaderExtensionDirection", "GstRtp.RTPHeaderExtensionDirection",
"GstRtp.RTPHeaderExtensionFlags", "GstRtp.RTPHeaderExtensionFlags",
"GstRtp.RTPPayload", "GstRtp.RTPPayload",
@ -82,10 +81,20 @@ status = "generate"
name = "rtp_source_meta_api_get_type" name = "rtp_source_meta_api_get_type"
ignore = true ignore = true
[[object]]
name = "GstRtp.RTPBaseDepayload"
status = "generate"
manual_traits = ["RTPBaseDepayloadExtManual"]
[[object.property]]
name = "extensions"
# use proper type
ignore = true
[[object]] [[object]]
name = "GstRtp.RTPBasePayload" name = "GstRtp.RTPBasePayload"
status = "generate" status = "generate"
manual_traits = ["RTPHeaderExtensionExtManual"] manual_traits = ["RTPBasePayloadExtManual"]
[[object.function]] [[object.function]]
name = "set_outcaps" name = "set_outcaps"

View file

@ -1,4 +1,4 @@
use glib::object::IsA; use glib::{prelude::*, translate::*};
use crate::RTPBaseDepayload; use crate::RTPBaseDepayload;
@ -8,6 +8,48 @@ mod sealed {
} }
pub trait RTPBaseDepayloadExtManual: sealed::Sealed + IsA<RTPBaseDepayload> + 'static { pub trait RTPBaseDepayloadExtManual: sealed::Sealed + IsA<RTPBaseDepayload> + 'static {
#[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),
)
}
}
fn sink_pad(&self) -> &gst::Pad { fn sink_pad(&self) -> &gst::Pad {
unsafe { unsafe {
let elt = &*(self.as_ptr() as *const ffi::GstRTPBaseDepayload); let elt = &*(self.as_ptr() as *const ffi::GstRTPBaseDepayload);