diff --git a/gstreamer/src/allocator.rs b/gstreamer/src/allocator.rs index 1a935bb22..d8f7af1e3 100644 --- a/gstreamer/src/allocator.rs +++ b/gstreamer/src/allocator.rs @@ -10,7 +10,7 @@ use std::ptr; use gst_sys; -use glib::translate::{from_glib_full, ToGlibPtr}; +use glib::translate::from_glib_full; use glib::IsA; use AllocationParams; @@ -28,7 +28,7 @@ impl> AllocatorExtManual for O { self.as_ptr() as *mut _, size, match params { - Some(val) => val.to_glib_none().0 as *mut _, + Some(val) => val.as_ptr() as *mut _, None => ptr::null_mut(), }, ); diff --git a/gstreamer/src/buffer_pool.rs b/gstreamer/src/buffer_pool.rs index b3fa9515a..7b88dd2dc 100644 --- a/gstreamer/src/buffer_pool.rs +++ b/gstreamer/src/buffer_pool.rs @@ -6,6 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use AllocationParams; +use Allocator; use BufferPool; use Structure; @@ -144,7 +146,36 @@ impl BufferPoolConfig { } } - // TODO: get_allocator / set_allocator + pub fn get_allocator(&self) -> Option<(Option, AllocationParams)> { + unsafe { + let mut allocator = ptr::null_mut(); + let mut params = mem::zeroed(); + let ret = from_glib(gst_sys::gst_buffer_pool_config_get_allocator( + self.0.to_glib_none().0, + &mut allocator, + &mut params, + )); + if ret { + Some((from_glib_none(allocator), params.into())) + } else { + None + } + } + } + + pub fn set_allocator(&self, allocator: Option<&Allocator>, params: Option<&AllocationParams>) { + assert!(allocator.is_some() || params.is_some()); + unsafe { + gst_sys::gst_buffer_pool_config_set_allocator( + self.0.to_glib_none().0, + allocator.to_glib_none().0, + match params { + Some(val) => val.as_ptr(), + None => ptr::null(), + }, + ) + } + } // TODO: options iterator } diff --git a/gstreamer/src/memory.rs b/gstreamer/src/memory.rs index fd2c50abb..c10411024 100644 --- a/gstreamer/src/memory.rs +++ b/gstreamer/src/memory.rs @@ -21,6 +21,7 @@ use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlibPtr}; use miniobject::MiniObject; use AllocationParams; +use Allocator; use MemoryFlags; gst_define_mini_object_wrapper!(Memory, MemoryRef, gst_sys::GstMemory, [Debug,], || { @@ -43,7 +44,7 @@ impl fmt::Debug for MemoryRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Memory") .field("ptr", unsafe { &self.as_ptr() }) - //.field("allocator", &self.get_allocator()) + .field("allocator", &self.get_allocator()) .field("parent", &self.get_parent()) .field("maxsize", &self.get_maxsize()) .field("align", &self.get_align()) @@ -168,6 +169,10 @@ impl Memory { } impl MemoryRef { + pub fn get_allocator(&self) -> Option { + unsafe { from_glib_none(self.0.allocator) } + } + pub fn get_parent(&self) -> Option<&MemoryRef> { unsafe { if self.0.parent.is_null() {