meta: Add functions for working with meta API types directly

When working with allocation queries one only has the `glib::Type`.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1600>
This commit is contained in:
Sebastian Dröge 2024-11-22 14:07:17 +02:00
parent 486b5178e9
commit 11be6b0d2f

View file

@ -212,20 +212,13 @@ impl<'a, T> MetaRef<'a, T> {
#[inline] #[inline]
pub fn has_tag_by_quark(&self, tag: glib::Quark) -> bool { pub fn has_tag_by_quark(&self, tag: glib::Quark) -> bool {
unsafe { meta_api_type_has_tag_by_quark(self.api(), tag)
from_glib(ffi::gst_meta_api_type_has_tag(
self.api().into_glib(),
tag.into_glib(),
))
}
} }
#[inline] #[inline]
#[doc(alias = "gst_meta_api_type_get_tags")] #[doc(alias = "gst_meta_api_type_get_tags")]
pub fn tags<'b>(&self) -> &'b [glib::GStringPtr] { pub fn tags<'b>(&self) -> &'b [glib::GStringPtr] {
unsafe { meta_api_type_get_tags(self.api())
glib::StrV::from_glib_borrow(ffi::gst_meta_api_type_get_tags(self.api().into_glib()))
}
} }
#[inline] #[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<MT: MetaTag>(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)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;