mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-19 23:55:42 +00:00
fallbackswitch: Update aggregator and aggregator bindings from gstreamer git master
This commit is contained in:
parent
577c980a6d
commit
ccdb704ca8
6 changed files with 67 additions and 28 deletions
|
@ -15,9 +15,12 @@ use glib::IsA;
|
|||
use glib::Value;
|
||||
use gst;
|
||||
use std::boxed::Box as Box_;
|
||||
use std::mem::transmute;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
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 get_property_min_upstream_latency(&self) -> gst::ClockTime;
|
||||
|
||||
|
@ -30,6 +33,19 @@ pub trait AggregatorExtManual: 'static {
|
|||
}
|
||||
|
||||
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> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(gst_base_sys::gst_aggregator_finish_buffer(
|
||||
|
@ -74,7 +90,7 @@ impl<O: IsA<Aggregator>> 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::<Self, F> as usize,
|
||||
)),
|
||||
Box_::into_raw(f),
|
||||
|
|
|
@ -30,6 +30,8 @@ unsafe impl Sync for Aggregator {}
|
|||
pub const NONE_AGGREGATOR: Option<&Aggregator> = None;
|
||||
|
||||
pub trait AggregatorExt: 'static {
|
||||
//fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams);
|
||||
|
||||
fn get_buffer_pool(&self) -> Option<gst::BufferPool>;
|
||||
|
||||
fn get_latency(&self) -> gst::ClockTime;
|
||||
|
|
|
@ -404,7 +404,7 @@ gst_aggregator_pad_queue_is_empty (GstAggregatorPad * pad)
|
|||
* if at least one of the pads has an event or query at the top of its queue.
|
||||
*
|
||||
* Only returns TRUE if all non-EOS pads have a buffer available at the top of
|
||||
* their queue
|
||||
* their queue or a clipped buffer already.
|
||||
*/
|
||||
static gboolean
|
||||
gst_aggregator_check_pads_ready (GstAggregator * self,
|
||||
|
@ -521,6 +521,9 @@ gst_aggregator_reset_flow_values (GstAggregator * self)
|
|||
self->priv->send_segment = TRUE;
|
||||
gst_segment_init (&GST_AGGREGATOR_PAD (self->srcpad)->segment,
|
||||
GST_FORMAT_TIME);
|
||||
/* Initialize to -1 so we set it to the start position once the first buffer
|
||||
* is handled in gst_aggregator_pad_chain_internal() */
|
||||
GST_AGGREGATOR_PAD (self->srcpad)->segment.position = -1;
|
||||
self->priv->first_buffer = TRUE;
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
}
|
||||
|
@ -774,7 +777,7 @@ gst_aggregator_wait_and_check (GstAggregator * self, gboolean * timeout)
|
|||
}
|
||||
}
|
||||
|
||||
res = gst_aggregator_check_pads_ready (self, &have_event_or_query);
|
||||
res = gst_aggregator_check_pads_ready (self, NULL);
|
||||
SRC_UNLOCK (self);
|
||||
|
||||
return res;
|
||||
|
@ -1631,7 +1634,7 @@ eat:
|
|||
* The queued events with be handled from the src-pad task in
|
||||
* gst_aggregator_do_events_and_queries().
|
||||
*/
|
||||
static gboolean
|
||||
static GstFlowReturn
|
||||
gst_aggregator_default_sink_event_pre_queue (GstAggregator * self,
|
||||
GstAggregatorPad * aggpad, GstEvent * event)
|
||||
{
|
||||
|
@ -3077,8 +3080,7 @@ gst_aggregator_pad_class_init (GstAggregatorPadClass * klass)
|
|||
*/
|
||||
gst_aggregator_pad_signals[PAD_SIGNAL_BUFFER_CONSUMED] =
|
||||
g_signal_new ("buffer-consumed", G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE, 1, GST_TYPE_BUFFER);
|
||||
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_BUFFER);
|
||||
|
||||
/**
|
||||
* GstAggregatorPad:emit-signals:
|
||||
|
@ -3463,3 +3465,27 @@ gst_aggregator_simple_get_next_time (GstAggregator * self)
|
|||
|
||||
return next_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_aggregator_update_segment:
|
||||
*
|
||||
* Subclasses should use this to update the segment on their
|
||||
* source pad, instead of directly pushing new segment events
|
||||
* downstream.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
void
|
||||
gst_aggregator_update_segment (GstAggregator * self, GstSegment * segment)
|
||||
{
|
||||
g_return_if_fail (GST_IS_AGGREGATOR (self));
|
||||
g_return_if_fail (segment != NULL);
|
||||
|
||||
GST_INFO_OBJECT (self, "Updating srcpad segment: %" GST_SEGMENT_FORMAT,
|
||||
segment);
|
||||
|
||||
GST_OBJECT_LOCK (self);
|
||||
GST_AGGREGATOR_PAD (self->srcpad)->segment = *segment;
|
||||
self->priv->send_segment = TRUE;
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
}
|
||||
|
|
|
@ -321,7 +321,7 @@ struct _GstAggregatorClass {
|
|||
|
||||
gboolean (*negotiate) (GstAggregator * self);
|
||||
|
||||
gboolean (*sink_event_pre_queue) (GstAggregator * aggregator,
|
||||
GstFlowReturn (*sink_event_pre_queue) (GstAggregator * aggregator,
|
||||
GstAggregatorPad * aggregator_pad,
|
||||
GstEvent * event);
|
||||
|
||||
|
@ -384,6 +384,9 @@ void gst_aggregator_get_allocator (GstAggregator
|
|||
GST_BASE_API
|
||||
GstClockTime gst_aggregator_simple_get_next_time (GstAggregator * self);
|
||||
|
||||
GST_BASE_API
|
||||
void gst_aggregator_update_segment (GstAggregator * self,
|
||||
GstSegment * segment);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
|
|||
aggregator: &Aggregator,
|
||||
aggregator_pad: &AggregatorPad,
|
||||
event: gst::Event,
|
||||
) -> bool {
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_sink_event_pre_queue(aggregator, aggregator_pad, event)
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ pub trait AggregatorImplExt {
|
|||
aggregator: &Aggregator,
|
||||
aggregator_pad: &AggregatorPad,
|
||||
event: gst::Event,
|
||||
) -> bool;
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_sink_query(
|
||||
&self,
|
||||
|
@ -323,7 +323,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
|
|||
aggregator: &Aggregator,
|
||||
aggregator_pad: &AggregatorPad,
|
||||
event: gst::Event,
|
||||
) -> bool {
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class =
|
||||
|
@ -331,11 +331,12 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
|
|||
let f = (*parent_class)
|
||||
.sink_event_pre_queue
|
||||
.expect("Missing parent function `sink_event_pre_queue`");
|
||||
from_glib(f(
|
||||
gst::FlowReturn::from_glib(f(
|
||||
aggregator.to_glib_none().0,
|
||||
aggregator_pad.to_glib_none().0,
|
||||
event.into_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -712,7 +713,7 @@ unsafe extern "C" fn aggregator_sink_event_pre_queue<T: ObjectSubclass>(
|
|||
ptr: *mut gst_base_sys::GstAggregator,
|
||||
aggregator_pad: *mut gst_base_sys::GstAggregatorPad,
|
||||
event: *mut gst_sys::GstEvent,
|
||||
) -> glib_sys::gboolean
|
||||
) -> gst_sys::GstFlowReturn
|
||||
where
|
||||
T: AggregatorImpl,
|
||||
T::Instance: PanicPoison,
|
||||
|
@ -721,12 +722,13 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
imp.sink_event_pre_queue(
|
||||
&wrap,
|
||||
&from_glib_borrow(aggregator_pad),
|
||||
from_glib_full(event),
|
||||
)
|
||||
.into()
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
@ -934,22 +936,12 @@ where
|
|||
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
|
||||
let req_name: Option<String> = from_glib_none(req_name);
|
||||
|
||||
// FIXME: Easier way to convert Option<String> to Option<&str>?
|
||||
let mut _tmp = String::new();
|
||||
let req_name = match req_name {
|
||||
Some(n) => {
|
||||
_tmp = n;
|
||||
Some(_tmp.as_str())
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
let req_name: Borrowed<Option<glib::GString>> = from_glib_borrow(req_name);
|
||||
|
||||
imp.create_new_pad(
|
||||
&wrap,
|
||||
&from_glib_borrow(templ),
|
||||
req_name,
|
||||
req_name.as_ref().as_ref().map(|s| s.as_str()),
|
||||
Option::<gst::Caps>::from_glib_borrow(caps)
|
||||
.as_ref()
|
||||
.as_ref(),
|
||||
|
|
|
@ -547,13 +547,13 @@ impl AggregatorImpl for FallbackSwitch {
|
|||
agg: &gst_base::Aggregator,
|
||||
agg_pad: &gst_base::AggregatorPad,
|
||||
event: gst::Event,
|
||||
) -> bool {
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
use gst::EventView;
|
||||
|
||||
match event.view() {
|
||||
EventView::Gap(_) => {
|
||||
gst_debug!(CAT, obj: agg_pad, "Dropping gap event");
|
||||
true
|
||||
Ok(gst::FlowSuccess::Ok)
|
||||
}
|
||||
_ => self.parent_sink_event_pre_queue(agg, agg_pad, event),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue