From af57f6f17bbf1d19d822c84f8d4af32a476aa337 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 29 Jun 2023 10:58:51 -0400 Subject: [PATCH] gstreamer: meta Add API to list/check tags Part-of: --- gstreamer/src/meta.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index c791eb832..f1631b5c4 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -15,6 +15,23 @@ pub unsafe trait MetaAPI: Sync + Send + Sized { #[doc(alias = "get_meta_api")] fn meta_api() -> glib::Type; + fn has_tag(&self, tag: glib::Quark) -> bool { + unsafe { + from_glib(ffi::gst_meta_api_type_has_tag( + Self::meta_api().into_glib(), + tag.into_glib(), + )) + } + } + + fn tags(&self) -> &[glib::GStringPtr] { + unsafe { + glib::StrV::from_glib_borrow(ffi::gst_meta_api_type_get_tags( + Self::meta_api().into_glib(), + )) + } + } + #[inline] unsafe fn from_ptr(buffer: &BufferRef, ptr: *const Self::GstType) -> MetaRef { debug_assert!(!ptr.is_null()); @@ -758,6 +775,9 @@ mod tests { .collect::>(); assert_eq!(metas.len(), 1); assert_eq!(metas[0].parent().as_ptr(), parent.as_ptr()); + assert!(!metas[0].has_tag(glib::Quark::from_str("video"))); + assert!(metas[0].has_tag(glib::Quark::from_str("memory-reference"))); + assert_eq!(metas[0].tags().len(), 1); } {