From 68332e854e43e09ca51b50925d3fde5a8e3ba4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 29 Mar 2020 22:37:56 +0300 Subject: [PATCH] gstreamer-base: Add get_allocator() functions to aggregator, basesrc and basetransform base classes --- gstreamer-base/src/aggregator.rs | 21 ++++++++++++++++++--- gstreamer-base/src/base_src.rs | 17 +++++++++++++++++ gstreamer-base/src/base_transform.rs | 17 +++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/gstreamer-base/src/aggregator.rs b/gstreamer-base/src/aggregator.rs index a64fa7678..70764ed0c 100644 --- a/gstreamer-base/src/aggregator.rs +++ b/gstreamer-base/src/aggregator.rs @@ -18,11 +18,13 @@ use gst; use gst_base_sys; #[cfg(any(feature = "v1_16", feature = "dox"))] use std::boxed::Box as Box_; -#[cfg(any(feature = "v1_16", feature = "dox"))] -use std::mem::transmute; +use std::mem; +use std::ptr; use Aggregator; pub trait AggregatorExtManual: 'static { + fn get_allocator(&self) -> (Option, gst::AllocationParams); + fn finish_buffer(&self, buffer: gst::Buffer) -> Result; #[cfg(any(feature = "v1_16", feature = "dox"))] fn get_property_min_upstream_latency(&self) -> gst::ClockTime; @@ -38,6 +40,19 @@ pub trait AggregatorExtManual: 'static { } impl> AggregatorExtManual for O { + fn get_allocator(&self) -> (Option, gst::AllocationParams) { + unsafe { + let mut allocator = ptr::null_mut(); + let mut params = mem::zeroed(); + gst_base_sys::gst_aggregator_get_allocator( + self.as_ref().to_glib_none().0, + &mut allocator, + &mut params, + ); + (from_glib_full(allocator), params.into()) + } + } + fn finish_buffer(&self, buffer: gst::Buffer) -> Result { let ret: gst::FlowReturn = unsafe { from_glib(gst_base_sys::gst_aggregator_finish_buffer( @@ -85,7 +100,7 @@ impl> AggregatorExtManual for O { connect_raw( self.as_ptr() as *mut _, b"notify::min-upstream-latency\0".as_ptr() as *const _, - Some(transmute( + Some(mem::transmute( notify_min_upstream_latency_trampoline:: as usize, )), Box_::into_raw(f), diff --git a/gstreamer-base/src/base_src.rs b/gstreamer-base/src/base_src.rs index 2b1225569..791daba43 100644 --- a/gstreamer-base/src/base_src.rs +++ b/gstreamer-base/src/base_src.rs @@ -11,9 +11,13 @@ use glib::translate::*; use gst; use gst_base_sys; use std::mem; +use std::ptr; + use BaseSrc; pub trait BaseSrcExtManual: 'static { + fn get_allocator(&self) -> (Option, gst::AllocationParams); + fn get_segment(&self) -> gst::Segment; fn start_complete(&self, ret: Result); @@ -26,6 +30,19 @@ pub trait BaseSrcExtManual: 'static { } impl> BaseSrcExtManual for O { + fn get_allocator(&self) -> (Option, gst::AllocationParams) { + unsafe { + let mut allocator = ptr::null_mut(); + let mut params = mem::zeroed(); + gst_base_sys::gst_base_src_get_allocator( + self.as_ref().to_glib_none().0, + &mut allocator, + &mut params, + ); + (from_glib_full(allocator), params.into()) + } + } + fn get_segment(&self) -> gst::Segment { unsafe { let src: &gst_base_sys::GstBaseSrc = &*(self.as_ptr() as *const _); diff --git a/gstreamer-base/src/base_transform.rs b/gstreamer-base/src/base_transform.rs index f783814a7..cd17611ac 100644 --- a/gstreamer-base/src/base_transform.rs +++ b/gstreamer-base/src/base_transform.rs @@ -10,13 +10,30 @@ use glib::object::IsA; use glib::translate::*; use gst; use gst_base_sys; +use std::mem; +use std::ptr; use BaseTransform; pub trait BaseTransformExtManual: 'static { + fn get_allocator(&self) -> (Option, gst::AllocationParams); + fn get_segment(&self) -> gst::Segment; } impl> BaseTransformExtManual for O { + fn get_allocator(&self) -> (Option, gst::AllocationParams) { + unsafe { + let mut allocator = ptr::null_mut(); + let mut params = mem::zeroed(); + gst_base_sys::gst_base_transform_get_allocator( + self.as_ref().to_glib_none().0, + &mut allocator, + &mut params, + ); + (from_glib_full(allocator), params.into()) + } + } + fn get_segment(&self) -> gst::Segment { unsafe { let trans: &gst_base_sys::GstBaseTransform = &*(self.as_ptr() as *const _);