mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
video: Add finish() virtual function for video encoder/decoder
This commit is contained in:
parent
7a0bc76668
commit
be9434e029
2 changed files with 76 additions and 0 deletions
|
@ -41,6 +41,10 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl + Send + Sync + 's
|
|||
self.parent_stop(element)
|
||||
}
|
||||
|
||||
fn finish(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_finish(element)
|
||||
}
|
||||
|
||||
fn set_format(
|
||||
&self,
|
||||
element: &VideoDecoder,
|
||||
|
@ -97,6 +101,8 @@ pub trait VideoDecoderImplExt {
|
|||
|
||||
fn parent_stop(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_finish(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &VideoDecoder,
|
||||
|
@ -217,6 +223,19 @@ impl<T: VideoDecoderImpl + ObjectImpl> VideoDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_finish(&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)
|
||||
.finish
|
||||
.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,
|
||||
|
@ -359,6 +378,7 @@ where
|
|||
klass.close = Some(video_decoder_close::<T>);
|
||||
klass.start = Some(video_decoder_start::<T>);
|
||||
klass.stop = Some(video_decoder_stop::<T>);
|
||||
klass.finish = Some(video_decoder_finish::<T>);
|
||||
klass.set_format = Some(video_decoder_set_format::<T>);
|
||||
klass.parse = Some(video_decoder_parse::<T>);
|
||||
klass.handle_frame = Some(video_decoder_handle_frame::<T>);
|
||||
|
@ -465,6 +485,24 @@ where
|
|||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_decoder_finish<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.finish(&wrap).into()
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_decoder_set_format<T: ObjectSubclass>(
|
||||
ptr: *mut gst_video_sys::GstVideoDecoder,
|
||||
state: *mut gst_video_sys::GstVideoCodecState,
|
||||
|
|
|
@ -40,6 +40,10 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl + Send + Sync + 's
|
|||
self.parent_stop(element)
|
||||
}
|
||||
|
||||
fn finish(&self, element: &VideoEncoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_finish(element)
|
||||
}
|
||||
|
||||
fn set_format(
|
||||
&self,
|
||||
element: &VideoEncoder,
|
||||
|
@ -86,6 +90,8 @@ pub trait VideoEncoderImplExt {
|
|||
|
||||
fn parent_stop(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_finish(&self, element: &VideoEncoder) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &VideoEncoder,
|
||||
|
@ -198,6 +204,19 @@ impl<T: VideoEncoderImpl + ObjectImpl> VideoEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_finish(&self, element: &VideoEncoder) -> 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::GstVideoEncoderClass;
|
||||
(*parent_class)
|
||||
.finish
|
||||
.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: &VideoEncoder,
|
||||
|
@ -314,6 +333,7 @@ where
|
|||
klass.close = Some(video_encoder_close::<T>);
|
||||
klass.start = Some(video_encoder_start::<T>);
|
||||
klass.stop = Some(video_encoder_stop::<T>);
|
||||
klass.finish = Some(video_encoder_finish::<T>);
|
||||
klass.set_format = Some(video_encoder_set_format::<T>);
|
||||
klass.handle_frame = Some(video_encoder_handle_frame::<T>);
|
||||
klass.flush = Some(video_encoder_flush::<T>);
|
||||
|
@ -419,6 +439,24 @@ where
|
|||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_encoder_finish<T: ObjectSubclass>(
|
||||
ptr: *mut gst_video_sys::GstVideoEncoder,
|
||||
) -> gst_sys::GstFlowReturn
|
||||
where
|
||||
T: VideoEncoderImpl,
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
glib_floating_reference_guard!(ptr);
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.get_impl();
|
||||
let wrap: VideoEncoder = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
imp.finish(&wrap).into()
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_encoder_set_format<T: ObjectSubclass>(
|
||||
ptr: *mut gst_video_sys::GstVideoEncoder,
|
||||
state: *mut gst_video_sys::GstVideoCodecState,
|
||||
|
|
Loading…
Reference in a new issue