From 90a4918f92b6ef4f12838c2e3d6943d7cd473a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 2 May 2020 22:33:52 +0300 Subject: [PATCH] gstreamer-base/aggregator: Add subclassing support for new 1.18 virtual methods --- gstreamer-base/src/subclass/aggregator.rs | 157 ++++++++++++++++++++++ 1 file changed, 157 insertions(+) diff --git a/gstreamer-base/src/subclass/aggregator.rs b/gstreamer-base/src/subclass/aggregator.rs index fbb889478..f6f38f9fa 100644 --- a/gstreamer-base/src/subclass/aggregator.rs +++ b/gstreamer-base/src/subclass/aggregator.rs @@ -56,6 +56,15 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati self.parent_sink_event(aggregator, aggregator_pad, event) } + fn sink_event_pre_queue( + &self, + aggregator: &Aggregator, + aggregator_pad: &AggregatorPad, + event: gst::Event, + ) -> Result { + self.parent_sink_event_pre_queue(aggregator, aggregator_pad, event) + } + fn sink_query( &self, aggregator: &Aggregator, @@ -65,6 +74,15 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati self.parent_sink_query(aggregator, aggregator_pad, query) } + fn sink_query_pre_queue( + &self, + aggregator: &Aggregator, + aggregator_pad: &AggregatorPad, + query: &mut gst::QueryRef, + ) -> bool { + self.parent_sink_query_pre_queue(aggregator, aggregator_pad, query) + } + fn src_event(&self, aggregator: &Aggregator, event: gst::Event) -> bool { self.parent_src_event(aggregator, event) } @@ -129,6 +147,10 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati ) -> Result<(), gst::LoggableError> { self.parent_negotiated_src_caps(aggregator, caps) } + + fn negotiate(&self, aggregator: &Aggregator) -> bool { + self.parent_negotiate(aggregator) + } } pub trait AggregatorImplExt { @@ -154,6 +176,13 @@ pub trait AggregatorImplExt { event: gst::Event, ) -> bool; + fn parent_sink_event_pre_queue( + &self, + aggregator: &Aggregator, + aggregator_pad: &AggregatorPad, + event: gst::Event, + ) -> Result; + fn parent_sink_query( &self, aggregator: &Aggregator, @@ -161,6 +190,13 @@ pub trait AggregatorImplExt { query: &mut gst::QueryRef, ) -> bool; + fn parent_sink_query_pre_queue( + &self, + aggregator: &Aggregator, + aggregator_pad: &AggregatorPad, + query: &mut gst::QueryRef, + ) -> bool; + fn parent_src_event(&self, aggregator: &Aggregator, event: gst::Event) -> bool; fn parent_src_query(&self, aggregator: &Aggregator, query: &mut gst::QueryRef) -> bool; @@ -205,6 +241,8 @@ pub trait AggregatorImplExt { aggregator: &Aggregator, caps: &gst::Caps, ) -> Result<(), gst::LoggableError>; + + fn parent_negotiate(&self, aggregator: &Aggregator) -> bool; } impl AggregatorImplExt for T { @@ -280,6 +318,28 @@ impl AggregatorImplExt for T { } } + fn parent_sink_event_pre_queue( + &self, + aggregator: &Aggregator, + aggregator_pad: &AggregatorPad, + event: gst::Event, + ) -> Result { + unsafe { + let data = self.get_type_data(); + let parent_class = + data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass; + let f = (*parent_class) + .sink_event_pre_queue + .expect("Missing parent function `sink_event_pre_queue`"); + gst::FlowReturn::from_glib(f( + aggregator.to_glib_none().0, + aggregator_pad.to_glib_none().0, + event.into_ptr(), + )) + .into_result() + } + } + fn parent_sink_query( &self, aggregator: &Aggregator, @@ -301,6 +361,27 @@ impl AggregatorImplExt for T { } } + fn parent_sink_query_pre_queue( + &self, + aggregator: &Aggregator, + aggregator_pad: &AggregatorPad, + query: &mut gst::QueryRef, + ) -> bool { + unsafe { + let data = self.get_type_data(); + let parent_class = + data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass; + let f = (*parent_class) + .sink_query_pre_queue + .expect("Missing parent function `sink_query`"); + from_glib(f( + aggregator.to_glib_none().0, + aggregator_pad.to_glib_none().0, + query.as_mut_ptr(), + )) + } + } + fn parent_src_event(&self, aggregator: &Aggregator, event: gst::Event) -> bool { unsafe { let data = self.get_type_data(); @@ -501,6 +582,18 @@ impl AggregatorImplExt for T { .unwrap_or(Ok(())) } } + + fn parent_negotiate(&self, aggregator: &Aggregator) -> bool { + unsafe { + let data = self.get_type_data(); + let parent_class = + data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass; + (*parent_class) + .negotiate + .map(|f| from_glib(f(aggregator.to_glib_none().0))) + .unwrap_or(true) + } + } } unsafe impl IsSubclassable for AggregatorClass @@ -515,7 +608,9 @@ where klass.clip = Some(aggregator_clip::); klass.finish_buffer = Some(aggregator_finish_buffer::); klass.sink_event = Some(aggregator_sink_event::); + klass.sink_event_pre_queue = Some(aggregator_sink_event_pre_queue::); klass.sink_query = Some(aggregator_sink_query::); + klass.sink_query_pre_queue = Some(aggregator_sink_query_pre_queue::); klass.src_event = Some(aggregator_src_event::); klass.src_query = Some(aggregator_src_query::); klass.src_activate = Some(aggregator_src_activate::); @@ -527,6 +622,7 @@ where klass.update_src_caps = Some(aggregator_update_src_caps::); klass.fixate_src_caps = Some(aggregator_fixate_src_caps::); klass.negotiated_src_caps = Some(aggregator_negotiated_src_caps::); + klass.negotiate = Some(aggregator_negotiate::); } } } @@ -613,6 +709,30 @@ where .to_glib() } +unsafe extern "C" fn aggregator_sink_event_pre_queue( + ptr: *mut gst_base_sys::GstAggregator, + aggregator_pad: *mut gst_base_sys::GstAggregatorPad, + event: *mut gst_sys::GstEvent, +) -> gst_sys::GstFlowReturn +where + T: AggregatorImpl, + T::Instance: PanicPoison, +{ + let instance = &*(ptr as *mut T::Instance); + let imp = instance.get_impl(); + let wrap: Borrowed = from_glib_borrow(ptr); + + 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() +} + unsafe extern "C" fn aggregator_sink_query( ptr: *mut gst_base_sys::GstAggregator, aggregator_pad: *mut gst_base_sys::GstAggregatorPad, @@ -636,6 +756,29 @@ where .to_glib() } +unsafe extern "C" fn aggregator_sink_query_pre_queue( + ptr: *mut gst_base_sys::GstAggregator, + aggregator_pad: *mut gst_base_sys::GstAggregatorPad, + query: *mut gst_sys::GstQuery, +) -> glib_sys::gboolean +where + T: AggregatorImpl, + T::Instance: PanicPoison, +{ + let instance = &*(ptr as *mut T::Instance); + let imp = instance.get_impl(); + let wrap: Borrowed = from_glib_borrow(ptr); + + gst_panic_to_error!(&wrap, &instance.panicked(), false, { + imp.sink_query_pre_queue( + &wrap, + &from_glib_borrow(aggregator_pad), + gst::QueryRef::from_mut_ptr(query), + ) + }) + .to_glib() +} + unsafe extern "C" fn aggregator_src_event( ptr: *mut gst_base_sys::GstAggregator, event: *mut gst_sys::GstEvent, @@ -875,3 +1018,17 @@ where }) .to_glib() } + +unsafe extern "C" fn aggregator_negotiate( + ptr: *mut gst_base_sys::GstAggregator, +) -> glib_sys::gboolean +where + T: AggregatorImpl, + T::Instance: PanicPoison, +{ + let instance = &*(ptr as *mut T::Instance); + let imp = instance.get_impl(); + let wrap: Borrowed = from_glib_borrow(ptr); + + gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.negotiate(&wrap) }).to_glib() +}