diff --git a/gstreamer-audio/src/audio_buffer.rs b/gstreamer-audio/src/audio_buffer.rs index 663246af8..20159489e 100644 --- a/gstreamer-audio/src/audio_buffer.rs +++ b/gstreamer-audio/src/audio_buffer.rs @@ -2,7 +2,7 @@ use std::{fmt, marker::PhantomData, mem, ops, ptr, slice}; -use glib::translate::{from_glib, Borrowed, ToGlibPtr}; +use glib::translate::*; use smallvec::SmallVec; @@ -200,6 +200,11 @@ impl AudioBuffer { } } } + + #[inline] + pub fn buffer_owned(&self) -> gst::Buffer { + unsafe { from_glib_none(self.audio_buffer.buffer) } + } } impl AudioBuffer { diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index ecdf3e664..1f6c692f7 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -1368,6 +1368,14 @@ impl MappedBuffer { } } +impl MappedBuffer { + #[doc(alias = "get_buffer")] + #[inline] + pub fn buffer_owned(&self) -> Buffer { + self.buffer.clone() + } +} + impl MappedBuffer { #[inline] pub fn as_mut_slice(&mut self) -> &mut [u8] { diff --git a/gstreamer/src/buffer_cursor.rs b/gstreamer/src/buffer_cursor.rs index 7ff7cdab1..727f9fe2c 100644 --- a/gstreamer/src/buffer_cursor.rs +++ b/gstreamer/src/buffer_cursor.rs @@ -287,6 +287,10 @@ impl BufferCursor { phantom: PhantomData, } } + + pub fn buffer_owned(&self) -> Buffer { + self.buffer.as_ref().unwrap().clone() + } } impl BufferCursor {