diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index adec2f798..f82d7a854 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -103,6 +103,17 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl { ) -> Result<(), gst::ErrorMessage> { self.parent_decide_allocation(element, query) } + + #[cfg(any(feature = "v1_20", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] + fn handle_missing_data( + &self, + element: &Self::Type, + timestamp: gst::ClockTime, + duration: Option, + ) -> bool { + self.parent_handle_missing_data(element, timestamp, duration) + } } pub trait VideoDecoderImplExt: ObjectSubclass { @@ -163,6 +174,15 @@ pub trait VideoDecoderImplExt: ObjectSubclass { element: &Self::Type, query: &mut gst::QueryRef, ) -> Result<(), gst::ErrorMessage>; + + #[cfg(any(feature = "v1_20", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] + fn parent_handle_missing_data( + &self, + element: &Self::Type, + timestamp: gst::ClockTime, + duration: Option, + ) -> bool; } impl VideoDecoderImplExt for T { @@ -524,6 +544,30 @@ impl VideoDecoderImplExt for T { .unwrap_or(Ok(())) } } + + #[cfg(any(feature = "v1_20", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] + fn parent_handle_missing_data( + &self, + element: &Self::Type, + timestamp: gst::ClockTime, + duration: Option, + ) -> bool { + unsafe { + let data = Self::type_data(); + let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass; + (*parent_class) + .handle_missing_data + .map(|f| { + from_glib(f( + element.unsafe_cast_ref::().to_glib_none().0, + timestamp.into_glib(), + duration.into_glib(), + )) + }) + .unwrap_or(true) + } + } } unsafe impl IsSubclassable for VideoDecoder { @@ -548,6 +592,10 @@ unsafe impl IsSubclassable for VideoDecoder { klass.src_query = Some(video_decoder_src_query::); klass.propose_allocation = Some(video_decoder_propose_allocation::); klass.decide_allocation = Some(video_decoder_decide_allocation::); + #[cfg(any(feature = "v1_20", feature = "dox"))] + { + klass.handle_missing_data = Some(video_decoder_handle_missing_data::); + } } fn instance_init(instance: &mut glib::subclass::InitializingObject) { @@ -864,3 +912,23 @@ unsafe extern "C" fn video_decoder_decide_allocation( }) .into_glib() } + +#[cfg(any(feature = "v1_20", feature = "dox"))] +unsafe extern "C" fn video_decoder_handle_missing_data( + ptr: *mut ffi::GstVideoDecoder, + timestamp: gst::ffi::GstClockTime, + duration: gst::ffi::GstClockTime, +) -> glib::ffi::gboolean { + let instance = &*(ptr as *mut T::Instance); + let imp = instance.impl_(); + let wrap: Borrowed = from_glib_borrow(ptr); + + gst::panic_to_error!(&wrap, imp.panicked(), true, { + imp.handle_missing_data( + wrap.unsafe_cast_ref(), + Option::::from_glib(timestamp).unwrap(), + from_glib(duration), + ) + }) + .into_glib() +}