mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-09 16:55:27 +00:00
gstreamer-video: Make virtual methods take wrapper of type, not parent
This commit is contained in:
parent
29c9bcf667
commit
b861f724c4
3 changed files with 313 additions and 183 deletions
|
@ -11,9 +11,10 @@ use glib_sys;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
use gst_video_sys;
|
use gst_video_sys;
|
||||||
|
|
||||||
|
use glib::prelude::*;
|
||||||
|
use glib::subclass::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
use glib::subclass::prelude::*;
|
|
||||||
use gst;
|
use gst;
|
||||||
use gst::subclass::prelude::*;
|
use gst::subclass::prelude::*;
|
||||||
use gst_base;
|
use gst_base;
|
||||||
|
@ -24,33 +25,33 @@ use VideoCodecFrame;
|
||||||
use VideoDecoder;
|
use VideoDecoder;
|
||||||
|
|
||||||
pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
|
pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
|
||||||
fn open(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage> {
|
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_open(element)
|
self.parent_open(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage> {
|
fn close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_close(element)
|
self.parent_close(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage> {
|
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_start(element)
|
self.parent_start(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage> {
|
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_stop(element)
|
self.parent_stop(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
fn finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_finish(element)
|
self.parent_finish(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn drain(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
fn drain(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_drain(element)
|
self.parent_drain(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_format(
|
fn set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
state: &VideoCodecState<'static, Readable>,
|
state: &VideoCodecState<'static, Readable>,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
self.parent_set_format(element, state)
|
self.parent_set_format(element, state)
|
||||||
|
@ -58,7 +59,7 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn parse(
|
fn parse(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
frame: &VideoCodecFrame,
|
frame: &VideoCodecFrame,
|
||||||
adapter: &gst_base::Adapter,
|
adapter: &gst_base::Adapter,
|
||||||
at_eos: bool,
|
at_eos: bool,
|
||||||
|
@ -68,43 +69,43 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn handle_frame(
|
fn handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
frame: VideoCodecFrame,
|
frame: VideoCodecFrame,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_handle_frame(element, frame)
|
self.parent_handle_frame(element, frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&self, element: &VideoDecoder) -> bool {
|
fn flush(&self, element: &Self::Type) -> bool {
|
||||||
self.parent_flush(element)
|
self.parent_flush(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn negotiate(&self, element: &VideoDecoder) -> Result<(), gst::LoggableError> {
|
fn negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||||
self.parent_negotiate(element)
|
self.parent_negotiate(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_caps(&self, element: &VideoDecoder, filter: Option<&gst::Caps>) -> gst::Caps {
|
fn get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||||
self.parent_get_caps(element, filter)
|
self.parent_get_caps(element, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sink_event(&self, element: &VideoDecoder, event: gst::Event) -> bool {
|
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
self.parent_sink_event(element, event)
|
self.parent_sink_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sink_query(&self, element: &VideoDecoder, query: &mut gst::QueryRef) -> bool {
|
fn sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
self.parent_sink_query(element, query)
|
self.parent_sink_query(element, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn src_event(&self, element: &VideoDecoder, event: gst::Event) -> bool {
|
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
self.parent_src_event(element, event)
|
self.parent_src_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn src_query(&self, element: &VideoDecoder, query: &mut gst::QueryRef) -> bool {
|
fn src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
self.parent_src_query(element, query)
|
self.parent_src_query(element, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn propose_allocation(
|
fn propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_propose_allocation(element, query)
|
self.parent_propose_allocation(element, query)
|
||||||
|
@ -112,35 +113,35 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn decide_allocation(
|
fn decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_decide_allocation(element, query)
|
self.parent_decide_allocation(element, query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait VideoDecoderImplExt {
|
pub trait VideoDecoderImplExt: ObjectSubclass {
|
||||||
fn parent_open(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_close(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_start(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_stop(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_finish(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError>;
|
fn parent_finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_drain(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError>;
|
fn parent_drain(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_set_format(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
state: &VideoCodecState<'static, Readable>,
|
state: &VideoCodecState<'static, Readable>,
|
||||||
) -> Result<(), gst::LoggableError>;
|
) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_parse(
|
fn parent_parse(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
frame: &VideoCodecFrame,
|
frame: &VideoCodecFrame,
|
||||||
adapter: &gst_base::Adapter,
|
adapter: &gst_base::Adapter,
|
||||||
at_eos: bool,
|
at_eos: bool,
|
||||||
|
@ -148,39 +149,39 @@ pub trait VideoDecoderImplExt {
|
||||||
|
|
||||||
fn parent_handle_frame(
|
fn parent_handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
frame: VideoCodecFrame,
|
frame: VideoCodecFrame,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_flush(&self, element: &VideoDecoder) -> bool;
|
fn parent_flush(&self, element: &Self::Type) -> bool;
|
||||||
|
|
||||||
fn parent_negotiate(&self, element: &VideoDecoder) -> Result<(), gst::LoggableError>;
|
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_get_caps(&self, element: &VideoDecoder, filter: Option<&gst::Caps>) -> gst::Caps;
|
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||||
|
|
||||||
fn parent_sink_event(&self, element: &VideoDecoder, event: gst::Event) -> bool;
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_sink_query(&self, element: &VideoDecoder, query: &mut gst::QueryRef) -> bool;
|
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||||
|
|
||||||
fn parent_src_event(&self, element: &VideoDecoder, event: gst::Event) -> bool;
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_src_query(&self, element: &VideoDecoder, query: &mut gst::QueryRef) -> bool;
|
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||||
|
|
||||||
fn parent_propose_allocation(
|
fn parent_propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage>;
|
) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_decide_allocation(
|
fn parent_decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage>;
|
) -> Result<(), gst::ErrorMessage>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
fn parent_open(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -188,7 +189,11 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.open
|
.open
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -201,7 +206,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_close(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -209,7 +214,11 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.close
|
.close
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -222,7 +231,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_start(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -230,7 +239,11 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.start
|
.start
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -243,7 +256,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_stop(&self, element: &VideoDecoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -251,7 +264,11 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.stop
|
.stop
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -264,27 +281,37 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_finish(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
fn parent_finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoDecoderClass;
|
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoDecoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.finish
|
.finish
|
||||||
.map(|f| gst::FlowReturn::from_glib(f(element.to_glib_none().0)))
|
.map(|f| {
|
||||||
|
gst::FlowReturn::from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
})
|
||||||
.unwrap_or(gst::FlowReturn::Ok)
|
.unwrap_or(gst::FlowReturn::Ok)
|
||||||
.into_result()
|
.into_result()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_drain(&self, element: &VideoDecoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
fn parent_drain(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoDecoderClass;
|
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoDecoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.drain
|
.drain
|
||||||
.map(|f| gst::FlowReturn::from_glib(f(element.to_glib_none().0)))
|
.map(|f| {
|
||||||
|
gst::FlowReturn::from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
})
|
||||||
.unwrap_or(gst::FlowReturn::Ok)
|
.unwrap_or(gst::FlowReturn::Ok)
|
||||||
.into_result()
|
.into_result()
|
||||||
}
|
}
|
||||||
|
@ -292,7 +319,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
|
|
||||||
fn parent_set_format(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
state: &VideoCodecState<'static, Readable>,
|
state: &VideoCodecState<'static, Readable>,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -303,7 +330,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
.set_format
|
.set_format
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0, state.as_mut_ptr()),
|
f(
|
||||||
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
|
state.as_mut_ptr()
|
||||||
|
),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"parent function `set_format` failed"
|
"parent function `set_format` failed"
|
||||||
)
|
)
|
||||||
|
@ -314,7 +344,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
|
|
||||||
fn parent_parse(
|
fn parent_parse(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
frame: &VideoCodecFrame,
|
frame: &VideoCodecFrame,
|
||||||
adapter: &gst_base::Adapter,
|
adapter: &gst_base::Adapter,
|
||||||
at_eos: bool,
|
at_eos: bool,
|
||||||
|
@ -327,7 +357,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
.parse
|
.parse
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst::FlowReturn::from_glib(f(
|
gst::FlowReturn::from_glib(f(
|
||||||
element.to_glib_none().0,
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
frame.to_glib_none().0,
|
frame.to_glib_none().0,
|
||||||
adapter.to_glib_none().0,
|
adapter.to_glib_none().0,
|
||||||
at_eos.to_glib(),
|
at_eos.to_glib(),
|
||||||
|
@ -340,7 +370,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
|
|
||||||
fn parent_handle_frame(
|
fn parent_handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
frame: VideoCodecFrame,
|
frame: VideoCodecFrame,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -350,26 +380,34 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.handle_frame
|
.handle_frame
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst::FlowReturn::from_glib(f(element.to_glib_none().0, frame.to_glib_none().0))
|
gst::FlowReturn::from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
|
frame.to_glib_none().0,
|
||||||
|
))
|
||||||
})
|
})
|
||||||
.unwrap_or(gst::FlowReturn::Error)
|
.unwrap_or(gst::FlowReturn::Error)
|
||||||
.into_result()
|
.into_result()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_flush(&self, element: &VideoDecoder) -> bool {
|
fn parent_flush(&self, element: &Self::Type) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoDecoderClass;
|
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoDecoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.flush
|
.flush
|
||||||
.map(|f| from_glib(f(element.to_glib_none().0)))
|
.map(|f| {
|
||||||
|
from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
})
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_negotiate(&self, element: &VideoDecoder) -> Result<(), gst::LoggableError> {
|
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -378,7 +416,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
.negotiate
|
.negotiate
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0),
|
f(element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Parent function `negotiate` failed"
|
"Parent function `negotiate` failed"
|
||||||
)
|
)
|
||||||
|
@ -387,19 +425,28 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_get_caps(&self, element: &VideoDecoder, filter: Option<&gst::Caps>) -> gst::Caps {
|
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoDecoderClass;
|
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoDecoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.getcaps
|
.getcaps
|
||||||
.map(|f| from_glib_full(f(element.to_glib_none().0, filter.to_glib_none().0)))
|
.map(|f| {
|
||||||
.unwrap_or_else(|| element.proxy_getcaps(None, filter))
|
from_glib_full(f(
|
||||||
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
|
filter.to_glib_none().0,
|
||||||
|
))
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
element
|
||||||
|
.unsafe_cast_ref::<VideoDecoder>()
|
||||||
|
.proxy_getcaps(None, filter)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_sink_event(&self, element: &VideoDecoder, event: gst::Event) -> bool {
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -407,11 +454,14 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.sink_event
|
.sink_event
|
||||||
.expect("Missing parent function `sink_event`");
|
.expect("Missing parent function `sink_event`");
|
||||||
from_glib(f(element.to_glib_none().0, event.into_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
|
event.into_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_sink_query(&self, element: &VideoDecoder, query: &mut gst::QueryRef) -> bool {
|
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -419,11 +469,14 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.sink_query
|
.sink_query
|
||||||
.expect("Missing parent function `sink_query`");
|
.expect("Missing parent function `sink_query`");
|
||||||
from_glib(f(element.to_glib_none().0, query.as_mut_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_src_event(&self, element: &VideoDecoder, event: gst::Event) -> bool {
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -431,11 +484,14 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.src_event
|
.src_event
|
||||||
.expect("Missing parent function `src_event`");
|
.expect("Missing parent function `src_event`");
|
||||||
from_glib(f(element.to_glib_none().0, event.into_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
|
event.into_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_src_query(&self, element: &VideoDecoder, query: &mut gst::QueryRef) -> bool {
|
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -443,13 +499,16 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.src_query
|
.src_query
|
||||||
.expect("Missing parent function `src_query`");
|
.expect("Missing parent function `src_query`");
|
||||||
from_glib(f(element.to_glib_none().0, query.as_mut_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_propose_allocation(
|
fn parent_propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -459,7 +518,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.propose_allocation
|
.propose_allocation
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0, query.as_mut_ptr())) {
|
if from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
)) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -474,7 +536,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
|
|
||||||
fn parent_decide_allocation(
|
fn parent_decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -484,7 +546,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.decide_allocation
|
.decide_allocation
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0, query.as_mut_ptr())) {
|
if from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
)) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -537,7 +602,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.open(&wrap) {
|
match imp.open(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -559,7 +624,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.close(&wrap) {
|
match imp.close(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -581,7 +646,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.start(&wrap) {
|
match imp.start(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -603,7 +668,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.stop(&wrap) {
|
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -625,7 +690,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.finish(&wrap).into()
|
imp.finish(wrap.unsafe_cast_ref()).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -641,7 +706,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.drain(&wrap).into()
|
imp.drain(wrap.unsafe_cast_ref()).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -660,7 +725,7 @@ where
|
||||||
let wrap_state = VideoCodecState::<Readable>::new(state);
|
let wrap_state = VideoCodecState::<Readable>::new(state);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.set_format(&wrap, &wrap_state) {
|
match imp.set_format(wrap.unsafe_cast_ref(), &wrap_state) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -689,7 +754,8 @@ where
|
||||||
let at_eos: bool = from_glib(at_eos);
|
let at_eos: bool = from_glib(at_eos);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.parse(&wrap, &wrap_frame, &wrap_adapter, at_eos).into()
|
imp.parse(wrap.unsafe_cast_ref(), &wrap_frame, &wrap_adapter, at_eos)
|
||||||
|
.into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -707,7 +773,7 @@ where
|
||||||
let wrap_frame = VideoCodecFrame::new(frame, &*wrap);
|
let wrap_frame = VideoCodecFrame::new(frame, &*wrap);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.handle_frame(&wrap, wrap_frame).into()
|
imp.handle_frame(wrap.unsafe_cast_ref(), wrap_frame).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -723,7 +789,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
VideoDecoderImpl::flush(imp, &wrap)
|
VideoDecoderImpl::flush(imp, wrap.unsafe_cast_ref())
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -739,7 +805,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.negotiate(&wrap) {
|
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -764,7 +830,7 @@ where
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
||||||
VideoDecoderImpl::get_caps(
|
VideoDecoderImpl::get_caps(
|
||||||
imp,
|
imp,
|
||||||
&wrap,
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
|
@ -785,7 +851,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.sink_event(&wrap, from_glib_full(event))
|
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -802,7 +868,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.sink_query(&wrap, gst::QueryRef::from_mut_ptr(query))
|
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -819,7 +885,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.src_event(&wrap, from_glib_full(event))
|
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -836,7 +902,7 @@ where
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.src_query(&wrap, gst::QueryRef::from_mut_ptr(query))
|
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -854,7 +920,7 @@ where
|
||||||
let query = gst::QueryRef::from_mut_ptr(query);
|
let query = gst::QueryRef::from_mut_ptr(query);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.propose_allocation(&wrap, query) {
|
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -878,7 +944,7 @@ where
|
||||||
let query = gst::QueryRef::from_mut_ptr(query);
|
let query = gst::QueryRef::from_mut_ptr(query);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.decide_allocation(&wrap, query) {
|
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
|
|
@ -11,9 +11,10 @@ use glib_sys;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
use gst_video_sys;
|
use gst_video_sys;
|
||||||
|
|
||||||
|
use glib::prelude::*;
|
||||||
|
use glib::subclass::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
use glib::subclass::prelude::*;
|
|
||||||
use gst;
|
use gst;
|
||||||
use gst::subclass::prelude::*;
|
use gst::subclass::prelude::*;
|
||||||
|
|
||||||
|
@ -23,29 +24,29 @@ use VideoCodecFrame;
|
||||||
use VideoEncoder;
|
use VideoEncoder;
|
||||||
|
|
||||||
pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl {
|
pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl {
|
||||||
fn open(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage> {
|
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_open(element)
|
self.parent_open(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage> {
|
fn close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_close(element)
|
self.parent_close(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage> {
|
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_start(element)
|
self.parent_start(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage> {
|
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_stop(element)
|
self.parent_stop(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&self, element: &VideoEncoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
fn finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_finish(element)
|
self.parent_finish(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_format(
|
fn set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
state: &VideoCodecState<'static, Readable>,
|
state: &VideoCodecState<'static, Readable>,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
self.parent_set_format(element, state)
|
self.parent_set_format(element, state)
|
||||||
|
@ -53,43 +54,43 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn handle_frame(
|
fn handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
frame: VideoCodecFrame,
|
frame: VideoCodecFrame,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_handle_frame(element, frame)
|
self.parent_handle_frame(element, frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&self, element: &VideoEncoder) -> bool {
|
fn flush(&self, element: &Self::Type) -> bool {
|
||||||
self.parent_flush(element)
|
self.parent_flush(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn negotiate(&self, element: &VideoEncoder) -> Result<(), gst::LoggableError> {
|
fn negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||||
self.parent_negotiate(element)
|
self.parent_negotiate(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_caps(&self, element: &VideoEncoder, filter: Option<&gst::Caps>) -> gst::Caps {
|
fn get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||||
self.parent_get_caps(element, filter)
|
self.parent_get_caps(element, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sink_event(&self, element: &VideoEncoder, event: gst::Event) -> bool {
|
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
self.parent_sink_event(element, event)
|
self.parent_sink_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sink_query(&self, element: &VideoEncoder, query: &mut gst::QueryRef) -> bool {
|
fn sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
self.parent_sink_query(element, query)
|
self.parent_sink_query(element, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn src_event(&self, element: &VideoEncoder, event: gst::Event) -> bool {
|
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
self.parent_src_event(element, event)
|
self.parent_src_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn src_query(&self, element: &VideoEncoder, query: &mut gst::QueryRef) -> bool {
|
fn src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
self.parent_src_query(element, query)
|
self.parent_src_query(element, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn propose_allocation(
|
fn propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_propose_allocation(element, query)
|
self.parent_propose_allocation(element, query)
|
||||||
|
@ -97,65 +98,65 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn decide_allocation(
|
fn decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_decide_allocation(element, query)
|
self.parent_decide_allocation(element, query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait VideoEncoderImplExt {
|
pub trait VideoEncoderImplExt: ObjectSubclass {
|
||||||
fn parent_open(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_close(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_start(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_stop(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_finish(&self, element: &VideoEncoder) -> Result<gst::FlowSuccess, gst::FlowError>;
|
fn parent_finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_set_format(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
state: &VideoCodecState<'static, Readable>,
|
state: &VideoCodecState<'static, Readable>,
|
||||||
) -> Result<(), gst::LoggableError>;
|
) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_handle_frame(
|
fn parent_handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
frame: VideoCodecFrame,
|
frame: VideoCodecFrame,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_flush(&self, element: &VideoEncoder) -> bool;
|
fn parent_flush(&self, element: &Self::Type) -> bool;
|
||||||
|
|
||||||
fn parent_negotiate(&self, element: &VideoEncoder) -> Result<(), gst::LoggableError>;
|
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_get_caps(&self, element: &VideoEncoder, filter: Option<&gst::Caps>) -> gst::Caps;
|
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||||
|
|
||||||
fn parent_sink_event(&self, element: &VideoEncoder, event: gst::Event) -> bool;
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_sink_query(&self, element: &VideoEncoder, query: &mut gst::QueryRef) -> bool;
|
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||||
|
|
||||||
fn parent_src_event(&self, element: &VideoEncoder, event: gst::Event) -> bool;
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_src_query(&self, element: &VideoEncoder, query: &mut gst::QueryRef) -> bool;
|
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||||
|
|
||||||
fn parent_propose_allocation(
|
fn parent_propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage>;
|
) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_decide_allocation(
|
fn parent_decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage>;
|
) -> Result<(), gst::ErrorMessage>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
fn parent_open(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -163,7 +164,11 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.open
|
.open
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -176,7 +181,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_close(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -184,7 +189,11 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.close
|
.close
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -197,7 +206,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_start(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -205,7 +214,11 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.start
|
.start
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -218,7 +231,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_stop(&self, element: &VideoEncoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -226,7 +239,11 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.stop
|
.stop
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -239,14 +256,19 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_finish(&self, element: &VideoEncoder) -> Result<gst::FlowSuccess, gst::FlowError> {
|
fn parent_finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoEncoderClass;
|
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoEncoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.finish
|
.finish
|
||||||
.map(|f| gst::FlowReturn::from_glib(f(element.to_glib_none().0)))
|
.map(|f| {
|
||||||
|
gst::FlowReturn::from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
})
|
||||||
.unwrap_or(gst::FlowReturn::Ok)
|
.unwrap_or(gst::FlowReturn::Ok)
|
||||||
.into_result()
|
.into_result()
|
||||||
}
|
}
|
||||||
|
@ -254,7 +276,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
|
|
||||||
fn parent_set_format(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
state: &VideoCodecState<'static, Readable>,
|
state: &VideoCodecState<'static, Readable>,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -265,7 +287,10 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
.set_format
|
.set_format
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0, state.as_mut_ptr()),
|
f(
|
||||||
|
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||||
|
state.as_mut_ptr()
|
||||||
|
),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"parent function `set_format` failed"
|
"parent function `set_format` failed"
|
||||||
)
|
)
|
||||||
|
@ -276,7 +301,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
|
|
||||||
fn parent_handle_frame(
|
fn parent_handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
frame: VideoCodecFrame,
|
frame: VideoCodecFrame,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -286,26 +311,34 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.handle_frame
|
.handle_frame
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst::FlowReturn::from_glib(f(element.to_glib_none().0, frame.to_glib_none().0))
|
gst::FlowReturn::from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||||
|
frame.to_glib_none().0,
|
||||||
|
))
|
||||||
})
|
})
|
||||||
.unwrap_or(gst::FlowReturn::Error)
|
.unwrap_or(gst::FlowReturn::Error)
|
||||||
.into_result()
|
.into_result()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_flush(&self, element: &VideoEncoder) -> bool {
|
fn parent_flush(&self, element: &Self::Type) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoEncoderClass;
|
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoEncoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.flush
|
.flush
|
||||||
.map(|f| from_glib(f(element.to_glib_none().0)))
|
.map(|f| {
|
||||||
|
from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<VideoEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
})
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_negotiate(&self, element: &VideoEncoder) -> Result<(), gst::LoggableError> {
|
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -314,7 +347,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
.negotiate
|
.negotiate
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0),
|
f(element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Parent function `negotiate` failed"
|
"Parent function `negotiate` failed"
|
||||||
)
|
)
|
||||||
|
@ -323,19 +356,28 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_get_caps(&self, element: &VideoEncoder, filter: Option<&gst::Caps>) -> gst::Caps {
|
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoEncoderClass;
|
data.as_ref().get_parent_class() as *mut gst_video_sys::GstVideoEncoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.getcaps
|
.getcaps
|
||||||
.map(|f| from_glib_full(f(element.to_glib_none().0, filter.to_glib_none().0)))
|
.map(|f| {
|
||||||
.unwrap_or_else(|| element.proxy_getcaps(None, filter))
|
from_glib_full(f(
|
||||||
|
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||||
|
filter.to_glib_none().0,
|
||||||
|
))
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
element
|
||||||
|
.unsafe_cast_ref::<VideoEncoder>()
|
||||||
|
.proxy_getcaps(None, filter)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_sink_event(&self, element: &VideoEncoder, event: gst::Event) -> bool {
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -343,11 +385,14 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.sink_event
|
.sink_event
|
||||||
.expect("Missing parent function `sink_event`");
|
.expect("Missing parent function `sink_event`");
|
||||||
from_glib(f(element.to_glib_none().0, event.into_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||||
|
event.into_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_sink_query(&self, element: &VideoEncoder, query: &mut gst::QueryRef) -> bool {
|
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -355,11 +400,14 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.sink_query
|
.sink_query
|
||||||
.expect("Missing parent function `sink_query`");
|
.expect("Missing parent function `sink_query`");
|
||||||
from_glib(f(element.to_glib_none().0, query.as_mut_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_src_event(&self, element: &VideoEncoder, event: gst::Event) -> bool {
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -367,11 +415,14 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.src_event
|
.src_event
|
||||||
.expect("Missing parent function `src_event`");
|
.expect("Missing parent function `src_event`");
|
||||||
from_glib(f(element.to_glib_none().0, event.into_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||||
|
event.into_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_src_query(&self, element: &VideoEncoder, query: &mut gst::QueryRef) -> bool {
|
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -379,13 +430,16 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.src_query
|
.src_query
|
||||||
.expect("Missing parent function `src_query`");
|
.expect("Missing parent function `src_query`");
|
||||||
from_glib(f(element.to_glib_none().0, query.as_mut_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_propose_allocation(
|
fn parent_propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -395,7 +449,10 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.propose_allocation
|
.propose_allocation
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0, query.as_mut_ptr())) {
|
if from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
)) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -410,7 +467,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
|
|
||||||
fn parent_decide_allocation(
|
fn parent_decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -420,7 +477,10 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.decide_allocation
|
.decide_allocation
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0, query.as_mut_ptr())) {
|
if from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
)) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -471,7 +531,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.open(&wrap) {
|
match imp.open(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -493,7 +553,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.close(&wrap) {
|
match imp.close(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -515,7 +575,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.start(&wrap) {
|
match imp.start(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -537,7 +597,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.stop(&wrap) {
|
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -559,7 +619,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.finish(&wrap).into()
|
imp.finish(wrap.unsafe_cast_ref()).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -578,7 +638,7 @@ where
|
||||||
let wrap_state = VideoCodecState::<Readable>::new(state);
|
let wrap_state = VideoCodecState::<Readable>::new(state);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.set_format(&wrap, &wrap_state) {
|
match imp.set_format(wrap.unsafe_cast_ref(), &wrap_state) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -602,7 +662,7 @@ where
|
||||||
let wrap_frame = VideoCodecFrame::new(frame, &*wrap);
|
let wrap_frame = VideoCodecFrame::new(frame, &*wrap);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.handle_frame(&wrap, wrap_frame).into()
|
imp.handle_frame(wrap.unsafe_cast_ref(), wrap_frame).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -618,7 +678,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
VideoEncoderImpl::flush(imp, &wrap)
|
VideoEncoderImpl::flush(imp, wrap.unsafe_cast_ref())
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -634,7 +694,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.negotiate(&wrap) {
|
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -659,7 +719,7 @@ where
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
||||||
VideoEncoderImpl::get_caps(
|
VideoEncoderImpl::get_caps(
|
||||||
imp,
|
imp,
|
||||||
&wrap,
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
|
@ -680,7 +740,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.sink_event(&wrap, from_glib_full(event))
|
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -697,7 +757,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.sink_query(&wrap, gst::QueryRef::from_mut_ptr(query))
|
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -714,7 +774,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.src_event(&wrap, from_glib_full(event))
|
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -731,7 +791,7 @@ where
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.src_query(&wrap, gst::QueryRef::from_mut_ptr(query))
|
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -749,7 +809,7 @@ where
|
||||||
let query = gst::QueryRef::from_mut_ptr(query);
|
let query = gst::QueryRef::from_mut_ptr(query);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.propose_allocation(&wrap, query) {
|
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -773,7 +833,7 @@ where
|
||||||
let query = gst::QueryRef::from_mut_ptr(query);
|
let query = gst::QueryRef::from_mut_ptr(query);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.decide_allocation(&wrap, query) {
|
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
|
|
@ -9,9 +9,10 @@
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
use gst_video_sys;
|
use gst_video_sys;
|
||||||
|
|
||||||
|
use glib::prelude::*;
|
||||||
|
use glib::subclass::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
use glib::subclass::prelude::*;
|
|
||||||
use gst;
|
use gst;
|
||||||
use gst::subclass::prelude::*;
|
use gst::subclass::prelude::*;
|
||||||
use gst_base::subclass::prelude::*;
|
use gst_base::subclass::prelude::*;
|
||||||
|
@ -21,17 +22,17 @@ use VideoSink;
|
||||||
pub trait VideoSinkImpl: VideoSinkImplExt + BaseSinkImpl + ElementImpl {
|
pub trait VideoSinkImpl: VideoSinkImplExt + BaseSinkImpl + ElementImpl {
|
||||||
fn show_frame(
|
fn show_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoSink,
|
element: &Self::Type,
|
||||||
buffer: &gst::Buffer,
|
buffer: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_show_frame(element, buffer)
|
self.parent_show_frame(element, buffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait VideoSinkImplExt {
|
pub trait VideoSinkImplExt: ObjectSubclass {
|
||||||
fn parent_show_frame(
|
fn parent_show_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoSink,
|
element: &Self::Type,
|
||||||
buffer: &gst::Buffer,
|
buffer: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +40,7 @@ pub trait VideoSinkImplExt {
|
||||||
impl<T: VideoSinkImpl> VideoSinkImplExt for T {
|
impl<T: VideoSinkImpl> VideoSinkImplExt for T {
|
||||||
fn parent_show_frame(
|
fn parent_show_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &VideoSink,
|
element: &Self::Type,
|
||||||
buffer: &gst::Buffer,
|
buffer: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -49,7 +50,10 @@ impl<T: VideoSinkImpl> VideoSinkImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.show_frame
|
.show_frame
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst::FlowReturn::from_glib(f(element.to_glib_none().0, buffer.to_glib_none().0))
|
gst::FlowReturn::from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<VideoSink>().to_glib_none().0,
|
||||||
|
buffer.to_glib_none().0,
|
||||||
|
))
|
||||||
})
|
})
|
||||||
.unwrap_or(gst::FlowReturn::Error)
|
.unwrap_or(gst::FlowReturn::Error)
|
||||||
.into_result()
|
.into_result()
|
||||||
|
@ -81,7 +85,7 @@ where
|
||||||
let buffer = from_glib_borrow(buffer);
|
let buffer = from_glib_borrow(buffer);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.show_frame(&wrap, &buffer).into()
|
imp.show_frame(wrap.unsafe_cast_ref(), &buffer).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue