diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index b5ed29ed6..ff55da78e 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -119,7 +119,7 @@ mod tags_serde; pub mod meta; #[cfg(any(feature = "v1_14", feature = "dox"))] pub use meta::ReferenceTimestampMeta; -pub use meta::{Meta, MetaAPI, MetaRef, MetaRefMut, ParentBufferMeta}; +pub use meta::{Meta, MetaAPI, MetaRef, MetaRefMut, ParentBufferMeta, ProtectionMeta}; pub mod buffer; pub use buffer::{ Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_ALL, BUFFER_COPY_METADATA, diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index 97faf6102..f5920250f 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -295,6 +295,48 @@ impl fmt::Debug for ParentBufferMeta { } } +#[repr(C)] +pub struct ProtectionMeta(gst_sys::GstProtectionMeta); + +unsafe impl Send for ProtectionMeta {} +unsafe impl Sync for ProtectionMeta {} + +impl ProtectionMeta { + pub fn add(buffer: &mut BufferRef, info: ::Structure) -> MetaRefMut { + skip_assert_initialized!(); + unsafe { + let meta = + gst_sys::gst_buffer_add_protection_meta(buffer.as_mut_ptr(), info.into_ptr()); + + Self::from_mut_ptr(buffer, meta) + } + } + + pub fn get_info(&self) -> &::StructureRef { + unsafe { ::StructureRef::from_glib_borrow(self.0.info) } + } + + pub fn get_info_mut(&mut self) -> &mut ::StructureRef { + unsafe { ::StructureRef::from_glib_borrow_mut(self.0.info) } + } +} + +unsafe impl MetaAPI for ProtectionMeta { + type GstType = gst_sys::GstProtectionMeta; + + fn get_meta_api() -> glib::Type { + unsafe { from_glib(gst_sys::gst_protection_meta_api_get_type()) } + } +} + +impl fmt::Debug for ProtectionMeta { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("ProtectionMeta") + .field("info", &self.get_info()) + .finish() + } +} + #[cfg(any(feature = "v1_14", feature = "dox"))] #[repr(C)] pub struct ReferenceTimestampMeta(gst_sys::GstReferenceTimestampMeta);