gstreamer-base: subclassing: move parent fn in dedicated trait (!231)

This commit is contained in:
François Laignel 2019-02-12 15:23:30 +01:00 committed by Sebastian Dröge
parent fb99f1abad
commit e24efa7259
6 changed files with 296 additions and 14 deletions

View file

@ -25,7 +25,7 @@ use Aggregator;
use AggregatorClass;
use AggregatorPad;
pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'static {
fn flush(&self, aggregator: &Aggregator) -> Result<gst::FlowSuccess, gst::FlowError> {
self.parent_flush(aggregator)
}
@ -129,7 +129,85 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
) -> Result<(), gst::LoggableError> {
self.parent_negotiated_src_caps(aggregator, caps)
}
}
pub trait AggregatorImplExt {
fn parent_flush(&self, aggregator: &Aggregator) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_clip(
&self,
aggregator: &Aggregator,
aggregator_pad: &AggregatorPad,
buffer: gst::Buffer,
) -> Option<gst::Buffer>;
fn parent_finish_buffer(
&self,
aggregator: &Aggregator,
buffer: gst::Buffer,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_sink_event(
&self,
aggregator: &Aggregator,
aggregator_pad: &AggregatorPad,
event: gst::Event,
) -> bool;
fn parent_sink_query(
&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;
fn parent_src_activate(
&self,
aggregator: &Aggregator,
mode: gst::PadMode,
active: bool,
) -> Result<(), gst::LoggableError>;
fn parent_aggregate(
&self,
aggregator: &Aggregator,
timeout: bool,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_start(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage>;
fn parent_stop(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage>;
fn parent_get_next_time(&self, aggregator: &Aggregator) -> gst::ClockTime;
fn parent_create_new_pad(
&self,
aggregator: &Aggregator,
templ: &gst::PadTemplate,
req_name: Option<&str>,
caps: Option<&gst::CapsRef>,
) -> Option<AggregatorPad>;
fn parent_update_src_caps(
&self,
aggregator: &Aggregator,
caps: &gst::CapsRef,
) -> Result<gst::Caps, gst::FlowError>;
fn parent_fixate_src_caps(&self, aggregator: &Aggregator, caps: gst::Caps) -> gst::Caps;
fn parent_negotiated_src_caps(
&self,
aggregator: &Aggregator,
caps: &gst::CapsRef,
) -> Result<(), gst::LoggableError>;
}
impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
fn parent_flush(&self, aggregator: &Aggregator) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
let data = self.get_type_data();

View file

@ -21,7 +21,7 @@ use Aggregator;
use AggregatorPad;
use AggregatorPadClass;
pub trait AggregatorPadImpl: PadImpl + Send + Sync + 'static {
pub trait AggregatorPadImpl: AggregatorPadImplExt + PadImpl + Send + Sync + 'static {
fn flush(
&self,
aggregator_pad: &AggregatorPad,
@ -38,7 +38,24 @@ pub trait AggregatorPadImpl: PadImpl + Send + Sync + 'static {
) -> bool {
self.parent_skip_buffer(aggregator_pad, aggregator, buffer)
}
}
pub trait AggregatorPadImplExt {
fn parent_flush(
&self,
aggregator_pad: &AggregatorPad,
aggregator: &Aggregator,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_skip_buffer(
&self,
aggregator_pad: &AggregatorPad,
aggregator: &Aggregator,
buffer: &gst::BufferRef,
) -> bool;
}
impl<T: AggregatorPadImpl + ObjectImpl> AggregatorPadImplExt for T {
fn parent_flush(
&self,
aggregator_pad: &AggregatorPad,
@ -82,7 +99,6 @@ pub trait AggregatorPadImpl: PadImpl + Send + Sync + 'static {
}
}
}
unsafe impl<T: ObjectSubclass + AggregatorPadImpl> IsSubclassable<T> for AggregatorPadClass {
fn override_vfuncs(&mut self) {
<gst::PadClass as IsSubclassable<T>>::override_vfuncs(self);

View file

@ -22,7 +22,7 @@ use std::ptr;
use BaseSink;
use BaseSinkClass;
pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl + Send + Sync + 'static {
fn start(&self, element: &BaseSink) -> Result<(), gst::ErrorMessage> {
self.parent_start(element)
}
@ -62,7 +62,7 @@ pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
}
fn query(&self, element: &BaseSink, query: &mut gst::QueryRef) -> bool {
BaseSinkImpl::parent_query(self, element, query)
BaseSinkImplExt::parent_query(self, element, query)
}
fn event(&self, element: &BaseSink, event: gst::Event) -> bool {
@ -88,7 +88,61 @@ pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
fn unlock_stop(&self, element: &BaseSink) -> Result<(), gst::ErrorMessage> {
self.parent_unlock_stop(element)
}
}
pub trait BaseSinkImplExt {
fn parent_start(&self, element: &BaseSink) -> Result<(), gst::ErrorMessage>;
fn parent_stop(&self, element: &BaseSink) -> Result<(), gst::ErrorMessage>;
fn parent_render(
&self,
element: &BaseSink,
buffer: &gst::BufferRef,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_prepare(
&self,
element: &BaseSink,
buffer: &gst::BufferRef,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_render_list(
&self,
element: &BaseSink,
list: &gst::BufferListRef,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_prepare_list(
&self,
element: &BaseSink,
list: &gst::BufferListRef,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_query(&self, element: &BaseSink, query: &mut gst::QueryRef) -> bool;
fn parent_event(&self, element: &BaseSink, event: gst::Event) -> bool;
fn parent_get_caps(
&self,
element: &BaseSink,
filter: Option<&gst::CapsRef>,
) -> Option<gst::Caps>;
fn parent_set_caps(
&self,
element: &BaseSink,
caps: &gst::CapsRef,
) -> Result<(), gst::LoggableError>;
fn parent_fixate(&self, element: &BaseSink, caps: gst::Caps) -> gst::Caps;
fn parent_unlock(&self, element: &BaseSink) -> Result<(), gst::ErrorMessage>;
fn parent_unlock_stop(&self, element: &BaseSink) -> Result<(), gst::ErrorMessage>;
}
impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
fn parent_start(&self, element: &BaseSink) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = self.get_type_data();

View file

@ -22,7 +22,7 @@ use std::ptr;
use BaseSrc;
use BaseSrcClass;
pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl + Send + Sync + 'static {
fn start(&self, element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
self.parent_start(element)
}
@ -63,7 +63,7 @@ pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
}
fn query(&self, element: &BaseSrc, query: &mut gst::QueryRef) -> bool {
BaseSrcImpl::parent_query(self, element, query)
BaseSrcImplExt::parent_query(self, element, query)
}
fn event(&self, element: &BaseSrc, event: &gst::Event) -> bool {
@ -93,7 +93,60 @@ pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
fn unlock_stop(&self, element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
self.parent_unlock_stop(element)
}
}
pub trait BaseSrcImplExt {
fn parent_start(&self, element: &BaseSrc) -> Result<(), gst::ErrorMessage>;
fn parent_stop(&self, element: &BaseSrc) -> Result<(), gst::ErrorMessage>;
fn parent_is_seekable(&self, element: &BaseSrc) -> bool;
fn parent_get_size(&self, element: &BaseSrc) -> Option<u64>;
fn parent_fill(
&self,
element: &BaseSrc,
offset: u64,
length: u32,
buffer: &mut gst::BufferRef,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_create(
&self,
element: &BaseSrc,
offset: u64,
length: u32,
) -> Result<gst::Buffer, gst::FlowError>;
fn parent_do_seek(&self, element: &BaseSrc, segment: &mut gst::Segment) -> bool;
fn parent_query(&self, element: &BaseSrc, query: &mut gst::QueryRef) -> bool;
fn parent_event(&self, element: &BaseSrc, event: &gst::Event) -> bool;
fn parent_get_caps(
&self,
element: &BaseSrc,
filter: Option<&gst::CapsRef>,
) -> Option<gst::Caps>;
fn parent_negotiate(&self, element: &BaseSrc) -> Result<(), gst::LoggableError>;
fn parent_set_caps(
&self,
element: &BaseSrc,
caps: &gst::CapsRef,
) -> Result<(), gst::LoggableError>;
fn parent_fixate(&self, element: &BaseSrc, caps: gst::Caps) -> gst::Caps;
fn parent_unlock(&self, element: &BaseSrc) -> Result<(), gst::ErrorMessage>;
fn parent_unlock_stop(&self, element: &BaseSrc) -> Result<(), gst::ErrorMessage>;
}
impl<T: BaseSrcImpl + ObjectImpl> BaseSrcImplExt for T {
fn parent_start(&self, element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = self.get_type_data();

View file

@ -20,7 +20,7 @@ use gst::subclass::prelude::*;
use BaseTransform;
use BaseTransformClass;
pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl + Send + Sync + 'static {
fn start(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
self.parent_start(element)
}
@ -68,7 +68,7 @@ pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
direction: gst::PadDirection,
query: &mut gst::QueryRef,
) -> bool {
BaseTransformImpl::parent_query(self, element, direction, query)
BaseTransformImplExt::parent_query(self, element, direction, query)
}
fn transform_size(
@ -118,7 +118,86 @@ pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
) -> Result<gst::FlowSuccess, gst::FlowError> {
self.parent_transform_ip_passthrough(element, buf)
}
}
pub trait BaseTransformImplExt {
fn parent_start(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage>;
fn parent_stop(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage>;
fn parent_transform_caps(
&self,
element: &BaseTransform,
direction: gst::PadDirection,
caps: &gst::Caps,
filter: Option<&gst::Caps>,
) -> Option<gst::Caps>;
fn parent_fixate_caps(
&self,
element: &BaseTransform,
direction: gst::PadDirection,
caps: &gst::Caps,
othercaps: gst::Caps,
) -> gst::Caps;
fn parent_set_caps(
&self,
element: &BaseTransform,
incaps: &gst::Caps,
outcaps: &gst::Caps,
) -> bool;
fn parent_accept_caps(
&self,
element: &BaseTransform,
direction: gst::PadDirection,
caps: &gst::Caps,
) -> bool;
fn parent_query(
&self,
element: &BaseTransform,
direction: gst::PadDirection,
query: &mut gst::QueryRef,
) -> bool;
fn parent_transform_size(
&self,
element: &BaseTransform,
direction: gst::PadDirection,
caps: &gst::Caps,
size: usize,
othercaps: &gst::Caps,
) -> Option<usize>;
fn parent_get_unit_size(&self, element: &BaseTransform, caps: &gst::Caps) -> Option<usize>;
fn parent_sink_event(&self, element: &BaseTransform, event: gst::Event) -> bool;
fn parent_src_event(&self, element: &BaseTransform, event: gst::Event) -> bool;
fn parent_transform(
&self,
element: &BaseTransform,
inbuf: &gst::Buffer,
outbuf: &mut gst::BufferRef,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_transform_ip(
&self,
element: &BaseTransform,
buf: &mut gst::BufferRef,
) -> Result<gst::FlowSuccess, gst::FlowError>;
fn parent_transform_ip_passthrough(
&self,
element: &BaseTransform,
buf: &gst::BufferRef,
) -> Result<gst::FlowSuccess, gst::FlowError>;
}
impl<T: BaseTransformImpl + ObjectImpl> BaseTransformImplExt for T {
fn parent_start(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = self.get_type_data();

View file

@ -21,10 +21,12 @@ pub mod aggregator_pad;
pub mod prelude {
#[cfg(any(feature = "v1_14", feature = "dox"))]
pub use super::aggregator::AggregatorImpl;
pub use super::aggregator::{AggregatorImpl, AggregatorImplExt};
#[cfg(any(feature = "v1_14", feature = "dox"))]
pub use super::aggregator_pad::AggregatorPadImpl;
pub use super::base_sink::BaseSinkImpl;
pub use super::base_src::BaseSrcImpl;
pub use super::base_transform::{BaseTransformClassSubclassExt, BaseTransformImpl};
pub use super::aggregator_pad::{AggregatorPadImpl, AggregatorPadImplExt};
pub use super::base_sink::{BaseSinkImpl, BaseSinkImplExt};
pub use super::base_src::{BaseSrcImpl, BaseSrcImplExt};
pub use super::base_transform::{
BaseTransformClassSubclassExt, BaseTransformImpl, BaseTransformImplExt,
};
}