mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-29 04:51:09 +00:00
video: Add support for VideoDecoder::drain() vfunc
This commit is contained in:
parent
8160521574
commit
ea95d1e479
1 changed files with 38 additions and 0 deletions
|
@ -45,6 +45,10 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl + Send + Sync + 's
|
||||||
self.parent_finish(element)
|
self.parent_finish(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn drain(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
|
self.parent_drain(element)
|
||||||
|
}
|
||||||
|
|
||||||
fn set_format(
|
fn set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &VideoDecoder,
|
||||||
|
@ -127,6 +131,8 @@ pub trait VideoDecoderImplExt {
|
||||||
|
|
||||||
fn parent_finish(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError>;
|
fn parent_finish(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
|
fn parent_drain(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_set_format(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &VideoDecoder,
|
||||||
|
@ -276,6 +282,19 @@ impl<T: VideoDecoderImpl + ObjectImpl> VideoDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parent_drain(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
|
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(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &VideoDecoder,
|
||||||
|
@ -501,6 +520,7 @@ where
|
||||||
klass.start = Some(video_decoder_start::<T>);
|
klass.start = Some(video_decoder_start::<T>);
|
||||||
klass.stop = Some(video_decoder_stop::<T>);
|
klass.stop = Some(video_decoder_stop::<T>);
|
||||||
klass.finish = Some(video_decoder_finish::<T>);
|
klass.finish = Some(video_decoder_finish::<T>);
|
||||||
|
klass.drain = Some(video_decoder_drain::<T>);
|
||||||
klass.set_format = Some(video_decoder_set_format::<T>);
|
klass.set_format = Some(video_decoder_set_format::<T>);
|
||||||
klass.parse = Some(video_decoder_parse::<T>);
|
klass.parse = Some(video_decoder_parse::<T>);
|
||||||
klass.handle_frame = Some(video_decoder_handle_frame::<T>);
|
klass.handle_frame = Some(video_decoder_handle_frame::<T>);
|
||||||
|
@ -631,6 +651,24 @@ where
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn video_decoder_drain<T: ObjectSubclass>(
|
||||||
|
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<T: ObjectSubclass>(
|
unsafe extern "C" fn video_decoder_set_format<T: ObjectSubclass>(
|
||||||
ptr: *mut gst_video_sys::GstVideoDecoder,
|
ptr: *mut gst_video_sys::GstVideoDecoder,
|
||||||
state: *mut gst_video_sys::GstVideoCodecState,
|
state: *mut gst_video_sys::GstVideoCodecState,
|
||||||
|
|
Loading…
Reference in a new issue