forked from mirrors/gstreamer-rs
gstreamer: meta: Move has_tag()
and tags()
getters to MetaRef
On `MetaAPI` only the static meta API type is known and based on that it's not possible to work with the tags of a specific meta instance's API. As the methods take a `&self` anyway they would be expected to check the value at hand instead. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1331>
This commit is contained in:
parent
a26fcaf0ad
commit
bd9b1d6e38
1 changed files with 40 additions and 21 deletions
|
@ -17,27 +17,6 @@ pub unsafe trait MetaAPI: Sync + Send + Sized {
|
|||
}
|
||||
|
||||
pub trait MetaAPIExt: MetaAPI {
|
||||
#[inline]
|
||||
#[doc(alias = "gst_meta_api_type_has_tag")]
|
||||
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(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(alias = "gst_meta_api_type_get_tags")]
|
||||
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<Self> {
|
||||
debug_assert!(!ptr.is_null());
|
||||
|
@ -212,6 +191,25 @@ impl<'a, T> MetaRef<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(alias = "gst_meta_api_type_has_tag")]
|
||||
pub fn has_tag(&self, tag: glib::Quark) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_meta_api_type_has_tag(
|
||||
self.api().into_glib(),
|
||||
tag.into_glib(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(alias = "gst_meta_api_type_get_tags")]
|
||||
pub fn tags(&self) -> &[glib::GStringPtr] {
|
||||
unsafe {
|
||||
glib::StrV::from_glib_borrow(ffi::gst_meta_api_type_get_tags(self.api().into_glib()))
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast_ref(&self) -> &MetaRef<'a, Meta> {
|
||||
unsafe { &*(self as *const MetaRef<'a, T> as *const MetaRef<'a, Meta>) }
|
||||
|
@ -293,6 +291,25 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(alias = "gst_meta_api_type_has_tag")]
|
||||
pub fn has_tag(&self, tag: glib::Quark) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_meta_api_type_has_tag(
|
||||
self.api().into_glib(),
|
||||
tag.into_glib(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(alias = "gst_meta_api_type_get_tags")]
|
||||
pub fn tags(&self) -> &[glib::GStringPtr] {
|
||||
unsafe {
|
||||
glib::StrV::from_glib_borrow(ffi::gst_meta_api_type_get_tags(self.api().into_glib()))
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast_ref(&self) -> &MetaRef<'a, Meta> {
|
||||
unsafe { &*(self as *const MetaRefMut<'a, T, U> as *const MetaRef<'a, Meta>) }
|
||||
|
@ -824,6 +841,8 @@ mod tests {
|
|||
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);
|
||||
|
||||
assert_eq!(metas[0].tags(), metas[0].upcast_ref().tags());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue