From f82b9cc197371e57d740e381e4bd0fcddfe664c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 9 Feb 2024 10:25:02 +0200 Subject: [PATCH] meta: Add support for 1.24 `Meta` clear function Part-of: --- gstreamer/src/meta.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index d1f697ff8..b469ad2f1 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -522,6 +522,24 @@ impl<'a, T, U> MetaRefMut<'a, T, U> { ) -> Result { self.as_meta_ref().serialize(writer) } + + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn clear(&mut self) -> Result<(), glib::BoolError> + where + T: MetaAPI, + { + unsafe { + let info = *(*self.upcast_ref().as_ptr()).info; + + if let Some(clear_func) = info.clear_func { + clear_func(self.buffer.as_mut_ptr(), self.upcast_mut().as_mut_ptr()); + Ok(()) + } else { + Err(glib::bool_error!("Failed to clear meta")) + } + } + } } impl<'a, T> MetaRefMut<'a, T, Standalone> {