From 11be6b0d2fd8cb6ad95a1ca1b27772bf0418746a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 22 Nov 2024 14:07:17 +0200 Subject: [PATCH] meta: Add functions for working with meta API types directly When working with allocation queries one only has the `glib::Type`. Part-of: --- gstreamer/src/meta.rs | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index cc7726837..0b3779fd1 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -212,20 +212,13 @@ impl<'a, T> MetaRef<'a, T> { #[inline] pub fn has_tag_by_quark(&self, tag: glib::Quark) -> bool { - unsafe { - from_glib(ffi::gst_meta_api_type_has_tag( - self.api().into_glib(), - tag.into_glib(), - )) - } + meta_api_type_has_tag_by_quark(self.api(), tag) } #[inline] #[doc(alias = "gst_meta_api_type_get_tags")] pub fn tags<'b>(&self) -> &'b [glib::GStringPtr] { - unsafe { - glib::StrV::from_glib_borrow(ffi::gst_meta_api_type_get_tags(self.api().into_glib())) - } + meta_api_type_get_tags(self.api()) } #[inline] @@ -1116,6 +1109,32 @@ unsafe impl<'a> MetaTransform<'a> for MetaTransformCopy { } } +#[inline] +#[doc(alias = "gst_meta_api_type_has_tag")] +pub fn meta_api_type_has_tag(type_: glib::Type) -> bool { + skip_assert_initialized!(); + meta_api_type_has_tag_by_quark(type_, MT::quark()) +} + +#[inline] +#[doc(alias = "gst_meta_api_type_has_tag")] +pub fn meta_api_type_has_tag_by_quark(type_: glib::Type, tag: glib::Quark) -> bool { + skip_assert_initialized!(); + unsafe { + from_glib(ffi::gst_meta_api_type_has_tag( + type_.into_glib(), + tag.into_glib(), + )) + } +} + +#[inline] +#[doc(alias = "gst_meta_api_type_get_tags")] +pub fn meta_api_type_get_tags<'b>(type_: glib::Type) -> &'b [glib::GStringPtr] { + skip_assert_initialized!(); + unsafe { glib::StrV::from_glib_borrow(ffi::gst_meta_api_type_get_tags(type_.into_glib())) } +} + #[cfg(test)] mod tests { use super::*;