2018-07-30 08:54:06 +00:00
|
|
|
// Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2019-04-23 15:47:13 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
use glib::prelude::*;
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
use glib::signal::{connect_raw, SignalHandlerId};
|
2018-07-30 08:54:06 +00:00
|
|
|
use glib::translate::*;
|
2019-01-16 13:23:53 +00:00
|
|
|
use glib::IsA;
|
2019-04-23 15:47:13 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
use glib::Value;
|
2018-07-30 08:54:06 +00:00
|
|
|
use gst;
|
2019-03-19 07:58:20 +00:00
|
|
|
use gst_base_sys;
|
2019-04-23 15:47:13 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
use std::boxed::Box as Box_;
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
use std::mem::transmute;
|
2018-07-30 08:54:06 +00:00
|
|
|
use Aggregator;
|
|
|
|
|
2018-12-08 09:22:42 +00:00
|
|
|
pub trait AggregatorExtManual: 'static {
|
2019-01-08 16:13:37 +00:00
|
|
|
fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>;
|
2019-04-23 15:47:13 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
fn get_property_min_upstream_latency(&self) -> gst::ClockTime;
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
fn set_property_min_upstream_latency(&self, min_upstream_latency: gst::ClockTime);
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
fn connect_property_min_upstream_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
|
|
|
|
&self,
|
|
|
|
f: F,
|
|
|
|
) -> SignalHandlerId;
|
2018-07-30 08:54:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<O: IsA<Aggregator>> AggregatorExtManual for O {
|
2019-01-08 16:13:37 +00:00
|
|
|
fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
|
|
|
let ret: gst::FlowReturn = unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
from_glib(gst_base_sys::gst_aggregator_finish_buffer(
|
2019-01-16 11:32:58 +00:00
|
|
|
self.as_ref().to_glib_none().0,
|
2018-07-30 08:54:06 +00:00
|
|
|
buffer.into_ptr(),
|
|
|
|
))
|
2019-01-08 16:13:37 +00:00
|
|
|
};
|
|
|
|
ret.into_result()
|
2018-07-30 08:54:06 +00:00
|
|
|
}
|
2019-04-23 15:47:13 +00:00
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
fn get_property_min_upstream_latency(&self) -> gst::ClockTime {
|
|
|
|
unsafe {
|
|
|
|
let mut value = Value::from_type(<gst::ClockTime as StaticType>::static_type());
|
|
|
|
gobject_sys::g_object_get_property(
|
|
|
|
self.to_glib_none().0 as *mut gobject_sys::GObject,
|
|
|
|
b"min-upstream-latency\0".as_ptr() as *const _,
|
|
|
|
value.to_glib_none_mut().0,
|
|
|
|
);
|
2019-08-11 07:33:34 +00:00
|
|
|
value
|
|
|
|
.get()
|
|
|
|
.expect("AggregatorExtManual::get_property_min_upstream_latency")
|
|
|
|
.unwrap()
|
2019-04-23 15:47:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
fn set_property_min_upstream_latency(&self, min_upstream_latency: gst::ClockTime) {
|
|
|
|
unsafe {
|
|
|
|
gobject_sys::g_object_set_property(
|
|
|
|
self.to_glib_none().0 as *mut gobject_sys::GObject,
|
|
|
|
b"min-upstream-latency\0".as_ptr() as *const _,
|
|
|
|
Value::from(&min_upstream_latency).to_glib_none().0,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
fn connect_property_min_upstream_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
|
|
|
|
&self,
|
|
|
|
f: F,
|
|
|
|
) -> SignalHandlerId {
|
|
|
|
unsafe {
|
|
|
|
let f: Box_<F> = Box_::new(f);
|
|
|
|
connect_raw(
|
|
|
|
self.as_ptr() as *mut _,
|
|
|
|
b"notify::min-upstream-latency\0".as_ptr() as *const _,
|
|
|
|
Some(transmute(
|
|
|
|
notify_min_upstream_latency_trampoline::<Self, F> as usize,
|
|
|
|
)),
|
|
|
|
Box_::into_raw(f),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
unsafe extern "C" fn notify_min_upstream_latency_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
|
|
|
|
this: *mut gst_base_sys::GstAggregator,
|
|
|
|
_param_spec: glib_sys::gpointer,
|
|
|
|
f: glib_sys::gpointer,
|
|
|
|
) where
|
|
|
|
P: IsA<Aggregator>,
|
|
|
|
{
|
|
|
|
let f: &F = &*(f as *const F);
|
|
|
|
f(&Aggregator::from_glib_borrow(this).unsafe_cast())
|
2018-07-30 08:54:06 +00:00
|
|
|
}
|