From 12bed29738afac5924cb9ed718534664244627a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 30 Jun 2023 08:50:03 +0300 Subject: [PATCH] gstreamer: Move various `MetaAPI` methods to an extension trait These don't make sense to implement any different than the default. Part-of: --- gstreamer/src/lib.rs | 5 +++-- gstreamer/src/meta.rs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 842d19f68..d64f7ed49 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -104,7 +104,8 @@ pub mod meta; #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] pub use crate::meta::MetaSeqnum; pub use crate::meta::{ - Meta, MetaAPI, MetaRef, MetaRefMut, ParentBufferMeta, ProtectionMeta, ReferenceTimestampMeta, + Meta, MetaAPI, MetaAPIExt, MetaRef, MetaRefMut, ParentBufferMeta, ProtectionMeta, + ReferenceTimestampMeta, }; pub mod buffer; pub use crate::buffer::{ @@ -322,7 +323,7 @@ pub mod prelude { gobject::GObjectExtManualGst, memory::MemoryType, message::MessageErrorDomain, - meta::MetaAPI, + meta::{MetaAPI, MetaAPIExt}, miniobject::IsMiniObject, object::GstObjectExtManual, pad::PadExtManual, diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index f1631b5c4..460b88bf4 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -14,7 +14,23 @@ pub unsafe trait MetaAPI: Sync + Send + Sized { #[doc(alias = "get_meta_api")] fn meta_api() -> glib::Type; +} +pub trait MetaAPIExt: MetaAPI { + #[doc(alias = "gst_meta_api_type_has_tag")] + fn has_tag(&self, tag: glib::Quark) -> bool; + + #[doc(alias = "gst_meta_api_type_get_tags")] + fn tags(&self) -> &[glib::GStringPtr]; + + unsafe fn from_ptr(buffer: &BufferRef, ptr: *const Self::GstType) -> MetaRef; + unsafe fn from_mut_ptr( + buffer: &mut BufferRef, + ptr: *mut Self::GstType, + ) -> MetaRefMut; +} + +impl MetaAPIExt for A { fn has_tag(&self, tag: glib::Quark) -> bool { unsafe { from_glib(ffi::gst_meta_api_type_has_tag(