gstreamer-base/aggregator: Add subclassing support for new 1.18 virtual methods

This commit is contained in:
Sebastian Dröge 2020-05-02 22:33:52 +03:00
parent c449b34b37
commit 90a4918f92

View file

@ -56,6 +56,15 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
self.parent_sink_event(aggregator, aggregator_pad, event) self.parent_sink_event(aggregator, aggregator_pad, event)
} }
fn sink_event_pre_queue(
&self,
aggregator: &Aggregator,
aggregator_pad: &AggregatorPad,
event: gst::Event,
) -> Result<gst::FlowSuccess, gst::FlowError> {
self.parent_sink_event_pre_queue(aggregator, aggregator_pad, event)
}
fn sink_query( fn sink_query(
&self, &self,
aggregator: &Aggregator, aggregator: &Aggregator,
@ -65,6 +74,15 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
self.parent_sink_query(aggregator, aggregator_pad, query) 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 { fn src_event(&self, aggregator: &Aggregator, event: gst::Event) -> bool {
self.parent_src_event(aggregator, event) self.parent_src_event(aggregator, event)
} }
@ -129,6 +147,10 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_negotiated_src_caps(aggregator, caps) self.parent_negotiated_src_caps(aggregator, caps)
} }
fn negotiate(&self, aggregator: &Aggregator) -> bool {
self.parent_negotiate(aggregator)
}
} }
pub trait AggregatorImplExt { pub trait AggregatorImplExt {
@ -154,6 +176,13 @@ pub trait AggregatorImplExt {
event: gst::Event, event: gst::Event,
) -> bool; ) -> bool;
fn parent_sink_event_pre_queue(
&self,
aggregator: &Aggregator,
aggregator_pad: &AggregatorPad,
event: gst::Event,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_sink_query( fn parent_sink_query(
&self, &self,
aggregator: &Aggregator, aggregator: &Aggregator,
@ -161,6 +190,13 @@ pub trait AggregatorImplExt {
query: &mut gst::QueryRef, query: &mut gst::QueryRef,
) -> bool; ) -> 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_event(&self, aggregator: &Aggregator, event: gst::Event) -> bool;
fn parent_src_query(&self, aggregator: &Aggregator, query: &mut gst::QueryRef) -> bool; fn parent_src_query(&self, aggregator: &Aggregator, query: &mut gst::QueryRef) -> bool;
@ -205,6 +241,8 @@ pub trait AggregatorImplExt {
aggregator: &Aggregator, aggregator: &Aggregator,
caps: &gst::Caps, caps: &gst::Caps,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
fn parent_negotiate(&self, aggregator: &Aggregator) -> bool;
} }
impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T { impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
@ -280,6 +318,28 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
} }
} }
fn parent_sink_event_pre_queue(
&self,
aggregator: &Aggregator,
aggregator_pad: &AggregatorPad,
event: gst::Event,
) -> Result<gst::FlowSuccess, gst::FlowError> {
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( fn parent_sink_query(
&self, &self,
aggregator: &Aggregator, aggregator: &Aggregator,
@ -301,6 +361,27 @@ impl<T: AggregatorImpl + ObjectImpl> 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 { fn parent_src_event(&self, aggregator: &Aggregator, event: gst::Event) -> bool {
unsafe { unsafe {
let data = self.get_type_data(); let data = self.get_type_data();
@ -501,6 +582,18 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
.unwrap_or(Ok(())) .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<T: ObjectSubclass + AggregatorImpl> IsSubclassable<T> for AggregatorClass unsafe impl<T: ObjectSubclass + AggregatorImpl> IsSubclassable<T> for AggregatorClass
@ -515,7 +608,9 @@ where
klass.clip = Some(aggregator_clip::<T>); klass.clip = Some(aggregator_clip::<T>);
klass.finish_buffer = Some(aggregator_finish_buffer::<T>); klass.finish_buffer = Some(aggregator_finish_buffer::<T>);
klass.sink_event = Some(aggregator_sink_event::<T>); klass.sink_event = Some(aggregator_sink_event::<T>);
klass.sink_event_pre_queue = Some(aggregator_sink_event_pre_queue::<T>);
klass.sink_query = Some(aggregator_sink_query::<T>); klass.sink_query = Some(aggregator_sink_query::<T>);
klass.sink_query_pre_queue = Some(aggregator_sink_query_pre_queue::<T>);
klass.src_event = Some(aggregator_src_event::<T>); klass.src_event = Some(aggregator_src_event::<T>);
klass.src_query = Some(aggregator_src_query::<T>); klass.src_query = Some(aggregator_src_query::<T>);
klass.src_activate = Some(aggregator_src_activate::<T>); klass.src_activate = Some(aggregator_src_activate::<T>);
@ -527,6 +622,7 @@ where
klass.update_src_caps = Some(aggregator_update_src_caps::<T>); klass.update_src_caps = Some(aggregator_update_src_caps::<T>);
klass.fixate_src_caps = Some(aggregator_fixate_src_caps::<T>); klass.fixate_src_caps = Some(aggregator_fixate_src_caps::<T>);
klass.negotiated_src_caps = Some(aggregator_negotiated_src_caps::<T>); klass.negotiated_src_caps = Some(aggregator_negotiated_src_caps::<T>);
klass.negotiate = Some(aggregator_negotiate::<T>);
} }
} }
} }
@ -613,6 +709,30 @@ where
.to_glib() .to_glib()
} }
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,
) -> gst_sys::GstFlowReturn
where
T: AggregatorImpl,
T::Instance: PanicPoison,
{
let instance = &*(ptr as *mut T::Instance);
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = 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<T: ObjectSubclass>( unsafe extern "C" fn aggregator_sink_query<T: ObjectSubclass>(
ptr: *mut gst_base_sys::GstAggregator, ptr: *mut gst_base_sys::GstAggregator,
aggregator_pad: *mut gst_base_sys::GstAggregatorPad, aggregator_pad: *mut gst_base_sys::GstAggregatorPad,
@ -636,6 +756,29 @@ where
.to_glib() .to_glib()
} }
unsafe extern "C" fn aggregator_sink_query_pre_queue<T: ObjectSubclass>(
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<Aggregator> = 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<T: ObjectSubclass>( unsafe extern "C" fn aggregator_src_event<T: ObjectSubclass>(
ptr: *mut gst_base_sys::GstAggregator, ptr: *mut gst_base_sys::GstAggregator,
event: *mut gst_sys::GstEvent, event: *mut gst_sys::GstEvent,
@ -875,3 +1018,17 @@ where
}) })
.to_glib() .to_glib()
} }
unsafe extern "C" fn aggregator_negotiate<T: ObjectSubclass>(
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<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.negotiate(&wrap) }).to_glib()
}