diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index 2fbb84e94..959610cc9 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -45,6 +45,10 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl + Send + Sync + 's self.parent_finish(element) } + fn drain(&self, element: &VideoDecoder) -> Result { + self.parent_drain(element) + } + fn set_format( &self, element: &VideoDecoder, @@ -127,6 +131,8 @@ pub trait VideoDecoderImplExt { fn parent_finish(&self, element: &VideoDecoder) -> Result; + fn parent_drain(&self, element: &VideoDecoder) -> Result; + fn parent_set_format( &self, element: &VideoDecoder, @@ -276,6 +282,19 @@ impl VideoDecoderImplExt for T { } } + fn parent_drain(&self, element: &VideoDecoder) -> Result { + unsafe { + let data = self.get_type_data(); + let parent_class = + data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoDecoderClass; + (*parent_class) + .drain + .map(|f| gst::FlowReturn::from_glib(f(element.to_glib_none().0))) + .unwrap_or(gst::FlowReturn::Ok) + .into_result() + } + } + fn parent_set_format( &self, element: &VideoDecoder, @@ -501,6 +520,7 @@ where klass.start = Some(video_decoder_start::); klass.stop = Some(video_decoder_stop::); klass.finish = Some(video_decoder_finish::); + klass.drain = Some(video_decoder_drain::); klass.set_format = Some(video_decoder_set_format::); klass.parse = Some(video_decoder_parse::); klass.handle_frame = Some(video_decoder_handle_frame::); @@ -631,6 +651,24 @@ where .to_glib() } +unsafe extern "C" fn video_decoder_drain( + ptr: *mut gst_video_sys::GstVideoDecoder, +) -> gst_sys::GstFlowReturn +where + T: VideoDecoderImpl, + T::Instance: PanicPoison, +{ + glib_floating_reference_guard!(ptr); + let instance = &*(ptr as *mut T::Instance); + let imp = instance.get_impl(); + let wrap: VideoDecoder = from_glib_borrow(ptr); + + gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { + imp.drain(&wrap).into() + }) + .to_glib() +} + unsafe extern "C" fn video_decoder_set_format( ptr: *mut gst_video_sys::GstVideoDecoder, state: *mut gst_video_sys::GstVideoCodecState,