gstreamer-base: Add get_allocator() functions to aggregator, basesrc and basetransform base classes

This commit is contained in:
Sebastian Dröge 2020-03-29 22:37:56 +03:00
parent 0651bfb51b
commit 68332e854e
3 changed files with 52 additions and 3 deletions

View file

@ -18,11 +18,13 @@ use gst;
use gst_base_sys; use gst_base_sys;
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
use std::boxed::Box as Box_; use std::boxed::Box as Box_;
#[cfg(any(feature = "v1_16", feature = "dox"))] use std::mem;
use std::mem::transmute; use std::ptr;
use Aggregator; use Aggregator;
pub trait AggregatorExtManual: 'static { pub trait AggregatorExtManual: 'static {
fn get_allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams);
fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>; fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>;
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
fn get_property_min_upstream_latency(&self) -> gst::ClockTime; fn get_property_min_upstream_latency(&self) -> gst::ClockTime;
@ -38,6 +40,19 @@ pub trait AggregatorExtManual: 'static {
} }
impl<O: IsA<Aggregator>> AggregatorExtManual for O { impl<O: IsA<Aggregator>> AggregatorExtManual for O {
fn get_allocator(&self) -> (Option<gst::Allocator>, 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<gst::FlowSuccess, gst::FlowError> { fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe { let ret: gst::FlowReturn = unsafe {
from_glib(gst_base_sys::gst_aggregator_finish_buffer( from_glib(gst_base_sys::gst_aggregator_finish_buffer(
@ -85,7 +100,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"notify::min-upstream-latency\0".as_ptr() as *const _, b"notify::min-upstream-latency\0".as_ptr() as *const _,
Some(transmute( Some(mem::transmute(
notify_min_upstream_latency_trampoline::<Self, F> as usize, notify_min_upstream_latency_trampoline::<Self, F> as usize,
)), )),
Box_::into_raw(f), Box_::into_raw(f),

View file

@ -11,9 +11,13 @@ use glib::translate::*;
use gst; use gst;
use gst_base_sys; use gst_base_sys;
use std::mem; use std::mem;
use std::ptr;
use BaseSrc; use BaseSrc;
pub trait BaseSrcExtManual: 'static { pub trait BaseSrcExtManual: 'static {
fn get_allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams);
fn get_segment(&self) -> gst::Segment; fn get_segment(&self) -> gst::Segment;
fn start_complete(&self, ret: Result<gst::FlowSuccess, gst::FlowError>); fn start_complete(&self, ret: Result<gst::FlowSuccess, gst::FlowError>);
@ -26,6 +30,19 @@ pub trait BaseSrcExtManual: 'static {
} }
impl<O: IsA<BaseSrc>> BaseSrcExtManual for O { impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
fn get_allocator(&self) -> (Option<gst::Allocator>, 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 { fn get_segment(&self) -> gst::Segment {
unsafe { unsafe {
let src: &gst_base_sys::GstBaseSrc = &*(self.as_ptr() as *const _); let src: &gst_base_sys::GstBaseSrc = &*(self.as_ptr() as *const _);

View file

@ -10,13 +10,30 @@ use glib::object::IsA;
use glib::translate::*; use glib::translate::*;
use gst; use gst;
use gst_base_sys; use gst_base_sys;
use std::mem;
use std::ptr;
use BaseTransform; use BaseTransform;
pub trait BaseTransformExtManual: 'static { pub trait BaseTransformExtManual: 'static {
fn get_allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams);
fn get_segment(&self) -> gst::Segment; fn get_segment(&self) -> gst::Segment;
} }
impl<O: IsA<BaseTransform>> BaseTransformExtManual for O { impl<O: IsA<BaseTransform>> BaseTransformExtManual for O {
fn get_allocator(&self) -> (Option<gst::Allocator>, 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 { fn get_segment(&self) -> gst::Segment {
unsafe { unsafe {
let trans: &gst_base_sys::GstBaseTransform = &*(self.as_ptr() as *const _); let trans: &gst_base_sys::GstBaseTransform = &*(self.as_ptr() as *const _);