diff --git a/gstreamer/src/subclass/bin.rs b/gstreamer/src/subclass/bin.rs index ef831de17..478c7e197 100644 --- a/gstreamer/src/subclass/bin.rs +++ b/gstreamer/src/subclass/bin.rs @@ -20,7 +20,7 @@ use Element; use LoggableError; use Message; -pub trait BinImpl: ElementImpl + Send + Sync + 'static { +pub trait BinImpl: BinImplExt + ElementImpl + Send + Sync + 'static { fn add_element(&self, bin: &Bin, element: &Element) -> Result<(), LoggableError> { self.parent_add_element(bin, element) } @@ -32,7 +32,17 @@ pub trait BinImpl: ElementImpl + Send + Sync + 'static { fn handle_message(&self, bin: &Bin, message: Message) { self.parent_handle_message(bin, message) } +} +pub trait BinImplExt { + fn parent_add_element(&self, bin: &Bin, element: &Element) -> Result<(), LoggableError>; + + fn parent_remove_element(&self, bin: &Bin, element: &Element) -> Result<(), LoggableError>; + + fn parent_handle_message(&self, bin: &Bin, message: Message); +} + +impl BinImplExt for T { fn parent_add_element(&self, bin: &Bin, element: &Element) -> Result<(), LoggableError> { unsafe { let data = self.get_type_data(); diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index 965448674..3cf85e94d 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -28,7 +28,7 @@ use StateChangeError; use StateChangeReturn; use StateChangeSuccess; -pub trait ElementImpl: ObjectImpl + Send + Sync + 'static { +pub trait ElementImpl: ElementImplExt + ObjectImpl + Send + Sync + 'static { fn change_state( &self, element: &::Element, @@ -62,7 +62,54 @@ pub trait ElementImpl: ObjectImpl + Send + Sync + 'static { fn set_context(&self, element: &::Element, context: &::Context) { self.parent_set_context(element, context) } +} +pub trait ElementImplExt { + fn parent_change_state( + &self, + element: &::Element, + transition: StateChange, + ) -> Result; + + fn parent_request_new_pad( + &self, + element: &::Element, + templ: &::PadTemplate, + name: Option, + caps: Option<&::CapsRef>, + ) -> Option<::Pad>; + + fn parent_release_pad(&self, element: &::Element, pad: &::Pad); + + fn parent_send_event(&self, element: &::Element, event: Event) -> bool; + + fn parent_query(&self, element: &::Element, query: &mut QueryRef) -> bool; + + fn parent_set_context(&self, element: &::Element, context: &::Context); + + fn catch_panic< + R, + F: FnOnce(&Self) -> R, + G: FnOnce() -> R, + P: IsA<::Element> + IsA + glib::value::SetValue, + >( + &self, + element: &P, + fallback: G, + f: F, + ) -> R; + + fn catch_panic_pad_function R, G: FnOnce() -> R>( + parent: &Option<::Object>, + fallback: G, + f: F, + ) -> R; +} + +impl ElementImplExt for T +where + T::Instance: PanicPoison, +{ fn parent_change_state( &self, element: &::Element, @@ -152,32 +199,7 @@ pub trait ElementImpl: ObjectImpl + Send + Sync + 'static { .unwrap_or(()) } } -} -pub trait ElementImplExt { - fn catch_panic< - R, - F: FnOnce(&Self) -> R, - G: FnOnce() -> R, - P: IsA<::Element> + IsA + glib::value::SetValue, - >( - &self, - element: &P, - fallback: G, - f: F, - ) -> R; - - fn catch_panic_pad_function R, G: FnOnce() -> R>( - parent: &Option<::Object>, - fallback: G, - f: F, - ) -> R; -} - -impl ElementImplExt for T -where - T::Instance: PanicPoison, -{ fn catch_panic< R, F: FnOnce(&Self) -> R, diff --git a/gstreamer/src/subclass/mod.rs b/gstreamer/src/subclass/mod.rs index 19277fdf5..088ceb7cf 100644 --- a/gstreamer/src/subclass/mod.rs +++ b/gstreamer/src/subclass/mod.rs @@ -22,11 +22,11 @@ pub mod pipeline; pub mod uri_handler; pub mod prelude { - pub use super::bin::BinImpl; + pub use super::bin::{BinImpl, BinImplExt}; pub use super::child_proxy::ChildProxyImpl; pub use super::element::{ElementClassSubclassExt, ElementImpl, ElementImplExt}; pub use super::ghost_pad::GhostPadImpl; - pub use super::pad::PadImpl; + pub use super::pad::{PadImpl, PadImplExt}; pub use super::pipeline::PipelineImpl; pub use super::uri_handler::URIHandlerImpl; pub use super::PanicPoison; diff --git a/gstreamer/src/subclass/pad.rs b/gstreamer/src/subclass/pad.rs index 605b1a1db..262f892f4 100644 --- a/gstreamer/src/subclass/pad.rs +++ b/gstreamer/src/subclass/pad.rs @@ -16,7 +16,7 @@ use glib::subclass::prelude::*; use Pad; use PadClass; -pub trait PadImpl: ObjectImpl + Send + Sync + 'static { +pub trait PadImpl: PadImplExt + ObjectImpl + Send + Sync + 'static { fn linked(&self, pad: &Pad, peer: &Pad) { self.parent_linked(pad, peer) } @@ -24,7 +24,15 @@ pub trait PadImpl: ObjectImpl + Send + Sync + 'static { fn unlinked(&self, pad: &Pad, peer: &Pad) { self.parent_unlinked(pad, peer) } +} +pub trait PadImplExt { + fn parent_linked(&self, pad: &Pad, peer: &Pad); + + fn parent_unlinked(&self, pad: &Pad, peer: &Pad); +} + +impl PadImplExt for T { fn parent_linked(&self, pad: &Pad, peer: &Pad) { unsafe { let data = self.get_type_data();