mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
gstreamer: meta Add API to list/check tags
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1284>
This commit is contained in:
parent
1bc197db79
commit
af57f6f17b
1 changed files with 20 additions and 0 deletions
|
@ -15,6 +15,23 @@ pub unsafe trait MetaAPI: Sync + Send + Sized {
|
||||||
#[doc(alias = "get_meta_api")]
|
#[doc(alias = "get_meta_api")]
|
||||||
fn meta_api() -> glib::Type;
|
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]
|
#[inline]
|
||||||
unsafe fn from_ptr(buffer: &BufferRef, ptr: *const Self::GstType) -> MetaRef<Self> {
|
unsafe fn from_ptr(buffer: &BufferRef, ptr: *const Self::GstType) -> MetaRef<Self> {
|
||||||
debug_assert!(!ptr.is_null());
|
debug_assert!(!ptr.is_null());
|
||||||
|
@ -758,6 +775,9 @@ mod tests {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
assert_eq!(metas.len(), 1);
|
assert_eq!(metas.len(), 1);
|
||||||
assert_eq!(metas[0].parent().as_ptr(), parent.as_ptr());
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue