diff --git a/gstreamer/src/subclass/bin.rs b/gstreamer/src/subclass/bin.rs index e539c3f33..d3b596f48 100644 --- a/gstreamer/src/subclass/bin.rs +++ b/gstreamer/src/subclass/bin.rs @@ -20,6 +20,10 @@ pub trait BinImpl: BinImplExt + ElementImpl { self.parent_remove_element(bin, element) } + fn do_latency(&self, bin: &Self::Type) -> Result<(), LoggableError> { + self.parent_do_latency(bin) + } + fn handle_message(&self, bin: &Self::Type, message: Message) { self.parent_handle_message(bin, message) } @@ -34,6 +38,8 @@ pub trait BinImplExt: ObjectSubclass { element: &Element, ) -> Result<(), LoggableError>; + fn parent_do_latency(&self, bin: &Self::Type) -> Result<(), LoggableError>; + fn parent_handle_message(&self, bin: &Self::Type, message: Message); } @@ -84,6 +90,24 @@ impl BinImplExt for T { } } + fn parent_do_latency(&self, bin: &Self::Type) -> Result<(), LoggableError> { + unsafe { + let data = Self::type_data(); + let parent_class = data.as_ref().parent_class() as *mut ffi::GstBinClass; + let f = (*parent_class).do_latency.ok_or_else(|| { + loggable_error!( + crate::CAT_RUST, + "Parent function `do_latency` is not defined" + ) + })?; + result_from_gboolean!( + f(bin.unsafe_cast_ref::().to_glib_none().0,), + crate::CAT_RUST, + "Failed to update latency using the parent function" + ) + } + } + fn parent_handle_message(&self, bin: &Self::Type, message: Message) { unsafe { let data = Self::type_data(); @@ -104,6 +128,7 @@ unsafe impl IsSubclassable for Bin { let klass = klass.as_mut(); klass.add_element = Some(bin_add_element::); klass.remove_element = Some(bin_remove_element::); + klass.do_latency = Some(bin_do_latency::); klass.handle_message = Some(bin_handle_message::); } } @@ -157,6 +182,23 @@ unsafe extern "C" fn bin_remove_element( .into_glib() } +unsafe extern "C" fn bin_do_latency(ptr: *mut ffi::GstBin) -> glib::ffi::gboolean { + let instance = &*(ptr as *mut T::Instance); + let imp = instance.imp(); + let wrap: Borrowed = from_glib_borrow(ptr); + + panic_to_error!(&wrap, imp.panicked(), false, { + match imp.do_latency(wrap.unsafe_cast_ref()) { + Ok(()) => true, + Err(err) => { + err.log_with_object(&*wrap); + false + } + } + }) + .into_glib() +} + unsafe extern "C" fn bin_handle_message( ptr: *mut ffi::GstBin, message: *mut ffi::GstMessage,