2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2020-11-21 17:59:22 +00:00
|
|
|
use crate::prelude::*;
|
2018-11-20 21:40:39 +00:00
|
|
|
|
|
|
|
use glib::subclass::prelude::*;
|
2020-11-14 16:01:13 +00:00
|
|
|
use glib::translate::*;
|
|
|
|
|
2020-12-20 15:09:22 +00:00
|
|
|
use gst::gst_warning;
|
2018-11-20 21:40:39 +00:00
|
|
|
use gst::subclass::prelude::*;
|
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
use std::mem;
|
2020-02-09 18:06:25 +00:00
|
|
|
use std::ptr;
|
2019-07-11 12:34:28 +00:00
|
|
|
|
2020-11-21 17:59:22 +00:00
|
|
|
use crate::BaseTransform;
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2020-10-20 20:55:20 +00:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
|
|
|
pub enum BaseTransformMode {
|
|
|
|
AlwaysInPlace,
|
|
|
|
NeverInPlace,
|
|
|
|
Both,
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl {
|
2020-10-20 20:55:20 +00:00
|
|
|
const MODE: BaseTransformMode;
|
|
|
|
const PASSTHROUGH_ON_SAME_CAPS: bool;
|
|
|
|
const TRANSFORM_IP_ON_PASSTHROUGH: bool;
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
2019-02-02 16:11:30 +00:00
|
|
|
self.parent_start(element)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
2019-02-02 16:11:30 +00:00
|
|
|
self.parent_stop(element)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn transform_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
filter: Option<&gst::Caps>,
|
2019-02-01 14:07:42 +00:00
|
|
|
) -> Option<gst::Caps> {
|
2018-11-20 21:40:39 +00:00
|
|
|
self.parent_transform_caps(element, direction, caps, filter)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fixate_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
othercaps: gst::Caps,
|
|
|
|
) -> gst::Caps {
|
|
|
|
self.parent_fixate_caps(element, direction, caps, othercaps)
|
|
|
|
}
|
|
|
|
|
2019-11-20 22:02:23 +00:00
|
|
|
fn set_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-11-20 22:02:23 +00:00
|
|
|
incaps: &gst::Caps,
|
|
|
|
outcaps: &gst::Caps,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
2019-02-02 16:11:30 +00:00
|
|
|
self.parent_set_caps(element, incaps, outcaps)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn accept_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
) -> bool {
|
|
|
|
self.parent_accept_caps(element, direction, caps)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn query(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
query: &mut gst::QueryRef,
|
|
|
|
) -> bool {
|
2019-02-12 14:23:30 +00:00
|
|
|
BaseTransformImplExt::parent_query(self, element, direction, query)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn transform_size(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
size: usize,
|
|
|
|
othercaps: &gst::Caps,
|
|
|
|
) -> Option<usize> {
|
|
|
|
self.parent_transform_size(element, direction, caps, size, othercaps)
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn get_unit_size(&self, element: &Self::Type, caps: &gst::Caps) -> Option<usize> {
|
2019-02-02 16:11:30 +00:00
|
|
|
self.parent_get_unit_size(element, caps)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
2018-11-20 21:40:39 +00:00
|
|
|
self.parent_sink_event(element, event)
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
2018-11-20 21:40:39 +00:00
|
|
|
self.parent_src_event(element, event)
|
|
|
|
}
|
|
|
|
|
2020-02-22 16:36:20 +00:00
|
|
|
fn prepare_output_buffer(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-22 16:36:20 +00:00
|
|
|
inbuf: &gst::BufferRef,
|
2020-04-02 16:57:04 +00:00
|
|
|
) -> Result<PrepareOutputBufferSuccess, gst::FlowError> {
|
2020-02-22 16:36:20 +00:00
|
|
|
self.parent_prepare_output_buffer(element, inbuf)
|
|
|
|
}
|
|
|
|
|
2018-11-20 21:40:39 +00:00
|
|
|
fn transform(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-02 16:11:30 +00:00
|
|
|
inbuf: &gst::Buffer,
|
|
|
|
outbuf: &mut gst::BufferRef,
|
2019-01-08 16:13:37 +00:00
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
2019-02-02 16:11:30 +00:00
|
|
|
self.parent_transform(element, inbuf, outbuf)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2019-01-08 16:13:37 +00:00
|
|
|
fn transform_ip(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-02 16:11:30 +00:00
|
|
|
buf: &mut gst::BufferRef,
|
2019-01-08 16:13:37 +00:00
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
2019-02-02 16:11:30 +00:00
|
|
|
self.parent_transform_ip(element, buf)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn transform_ip_passthrough(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-05-23 11:28:09 +00:00
|
|
|
buf: &gst::Buffer,
|
2019-01-08 16:13:37 +00:00
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
2019-02-02 16:11:30 +00:00
|
|
|
self.parent_transform_ip_passthrough(element, buf)
|
|
|
|
}
|
2020-02-09 18:06:25 +00:00
|
|
|
|
2020-02-09 18:45:29 +00:00
|
|
|
fn copy_metadata(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-09 18:45:29 +00:00
|
|
|
inbuf: &gst::BufferRef,
|
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
|
|
|
self.parent_copy_metadata(element, inbuf, outbuf)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn transform_meta<'a>(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-09 18:45:29 +00:00
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
meta: gst::MetaRef<'a, gst::Meta>,
|
|
|
|
inbuf: &'a gst::BufferRef,
|
|
|
|
) -> bool {
|
|
|
|
self.parent_transform_meta(element, outbuf, meta, inbuf)
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn before_transform(&self, element: &Self::Type, inbuf: &gst::BufferRef) {
|
2020-02-09 18:45:29 +00:00
|
|
|
self.parent_before_transform(element, inbuf);
|
|
|
|
}
|
|
|
|
|
2020-02-09 18:06:25 +00:00
|
|
|
fn submit_input_buffer(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-09 18:06:25 +00:00
|
|
|
is_discont: bool,
|
|
|
|
inbuf: gst::Buffer,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
|
|
|
self.parent_submit_input_buffer(element, is_discont, inbuf)
|
|
|
|
}
|
|
|
|
|
2020-04-02 16:57:04 +00:00
|
|
|
fn generate_output(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-04-02 16:57:04 +00:00
|
|
|
) -> Result<GenerateOutputSuccess, gst::FlowError> {
|
2020-02-09 18:06:25 +00:00
|
|
|
self.parent_generate_output(element)
|
|
|
|
}
|
2019-02-12 14:23:30 +00:00
|
|
|
}
|
2019-02-02 16:11:30 +00:00
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
pub trait BaseTransformImplExt: ObjectSubclass {
|
|
|
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
2019-02-12 14:23:30 +00:00
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
2019-02-12 14:23:30 +00:00
|
|
|
|
|
|
|
fn parent_transform_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-12 14:23:30 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
filter: Option<&gst::Caps>,
|
|
|
|
) -> Option<gst::Caps>;
|
|
|
|
|
|
|
|
fn parent_fixate_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-12 14:23:30 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
othercaps: gst::Caps,
|
|
|
|
) -> gst::Caps;
|
|
|
|
|
|
|
|
fn parent_set_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-12 14:23:30 +00:00
|
|
|
incaps: &gst::Caps,
|
|
|
|
outcaps: &gst::Caps,
|
2019-11-20 22:02:23 +00:00
|
|
|
) -> Result<(), gst::LoggableError>;
|
2019-02-12 14:23:30 +00:00
|
|
|
|
|
|
|
fn parent_accept_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-12 14:23:30 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
) -> bool;
|
|
|
|
|
|
|
|
fn parent_query(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-12 14:23:30 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
query: &mut gst::QueryRef,
|
|
|
|
) -> bool;
|
|
|
|
|
|
|
|
fn parent_transform_size(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-12 14:23:30 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
size: usize,
|
|
|
|
othercaps: &gst::Caps,
|
|
|
|
) -> Option<usize>;
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_get_unit_size(&self, element: &Self::Type, caps: &gst::Caps) -> Option<usize>;
|
2019-02-12 14:23:30 +00:00
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
2019-02-12 14:23:30 +00:00
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
2019-02-12 14:23:30 +00:00
|
|
|
|
2020-02-22 16:36:20 +00:00
|
|
|
fn parent_prepare_output_buffer(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-22 16:36:20 +00:00
|
|
|
inbuf: &gst::BufferRef,
|
2020-04-02 16:57:04 +00:00
|
|
|
) -> Result<PrepareOutputBufferSuccess, gst::FlowError>;
|
2020-02-22 16:36:20 +00:00
|
|
|
|
2019-02-12 14:23:30 +00:00
|
|
|
fn parent_transform(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-12 14:23:30 +00:00
|
|
|
inbuf: &gst::Buffer,
|
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
|
|
|
|
|
|
|
fn parent_transform_ip(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-12 14:23:30 +00:00
|
|
|
buf: &mut gst::BufferRef,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
|
|
|
|
|
|
|
fn parent_transform_ip_passthrough(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-05-23 11:28:09 +00:00
|
|
|
buf: &gst::Buffer,
|
2019-02-12 14:23:30 +00:00
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
2020-02-09 18:06:25 +00:00
|
|
|
|
2020-02-09 18:45:29 +00:00
|
|
|
fn parent_copy_metadata(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-09 18:45:29 +00:00
|
|
|
inbuf: &gst::BufferRef,
|
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
) -> Result<(), gst::LoggableError>;
|
|
|
|
|
|
|
|
fn parent_transform_meta<'a>(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-09 18:45:29 +00:00
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
meta: gst::MetaRef<'a, gst::Meta>,
|
|
|
|
inbuf: &'a gst::BufferRef,
|
|
|
|
) -> bool;
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_before_transform(&self, element: &Self::Type, inbuf: &gst::BufferRef);
|
2020-02-09 18:45:29 +00:00
|
|
|
|
2020-02-09 18:06:25 +00:00
|
|
|
fn parent_submit_input_buffer(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-09 18:06:25 +00:00
|
|
|
is_discont: bool,
|
|
|
|
inbuf: gst::Buffer,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
|
|
|
|
|
|
|
fn parent_generate_output(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-04-02 16:57:04 +00:00
|
|
|
) -> Result<GenerateOutputSuccess, gst::FlowError>;
|
2020-02-09 18:06:25 +00:00
|
|
|
|
|
|
|
fn take_queued_buffer(&self) -> Option<gst::Buffer>
|
|
|
|
where
|
|
|
|
Self: ObjectSubclass,
|
|
|
|
<Self as ObjectSubclass>::ParentType: IsA<BaseTransform>;
|
|
|
|
|
2021-04-11 19:39:50 +00:00
|
|
|
fn queued_buffer(&self) -> Option<gst::Buffer>
|
2020-02-09 18:06:25 +00:00
|
|
|
where
|
|
|
|
Self: ObjectSubclass,
|
|
|
|
<Self as ObjectSubclass>::ParentType: IsA<BaseTransform>;
|
2019-02-12 14:23:30 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
2019-02-02 16:11:30 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
(*parent_class)
|
|
|
|
.start
|
|
|
|
.map(|f| {
|
2020-11-14 16:01:13 +00:00
|
|
|
if from_glib(f(element
|
|
|
|
.unsafe_cast_ref::<BaseTransform>()
|
|
|
|
.to_glib_none()
|
|
|
|
.0))
|
|
|
|
{
|
2019-02-02 16:11:30 +00:00
|
|
|
Ok(())
|
|
|
|
} else {
|
2020-12-20 15:09:22 +00:00
|
|
|
Err(gst::error_msg!(
|
2019-02-02 16:11:30 +00:00
|
|
|
gst::CoreError::StateChange,
|
|
|
|
["Parent function `start` failed"]
|
|
|
|
))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.unwrap_or(Ok(()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
2019-02-02 16:11:30 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
(*parent_class)
|
|
|
|
.stop
|
|
|
|
.map(|f| {
|
2020-11-14 16:01:13 +00:00
|
|
|
if from_glib(f(element
|
|
|
|
.unsafe_cast_ref::<BaseTransform>()
|
|
|
|
.to_glib_none()
|
|
|
|
.0))
|
|
|
|
{
|
2019-02-02 16:11:30 +00:00
|
|
|
Ok(())
|
|
|
|
} else {
|
2020-12-20 15:09:22 +00:00
|
|
|
Err(gst::error_msg!(
|
2019-02-02 16:11:30 +00:00
|
|
|
gst::CoreError::StateChange,
|
|
|
|
["Parent function `stop` failed"]
|
|
|
|
))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.unwrap_or(Ok(()))
|
|
|
|
}
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_transform_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
filter: Option<&gst::Caps>,
|
2019-02-01 14:07:42 +00:00
|
|
|
) -> Option<gst::Caps> {
|
2018-11-20 21:40:39 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2019-02-01 14:07:42 +00:00
|
|
|
(*parent_class)
|
|
|
|
.transform_caps
|
|
|
|
.map(|f| {
|
|
|
|
from_glib_full(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2019-02-01 14:07:42 +00:00
|
|
|
direction.to_glib(),
|
|
|
|
caps.to_glib_none().0,
|
|
|
|
filter.to_glib_none().0,
|
|
|
|
))
|
|
|
|
})
|
|
|
|
.unwrap_or(None)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_fixate_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
othercaps: gst::Caps,
|
|
|
|
) -> gst::Caps {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
match (*parent_class).fixate_caps {
|
|
|
|
Some(f) => from_glib_full(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction.to_glib(),
|
|
|
|
caps.to_glib_none().0,
|
|
|
|
othercaps.into_ptr(),
|
|
|
|
)),
|
|
|
|
None => othercaps,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-02 16:11:30 +00:00
|
|
|
fn parent_set_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-02 16:11:30 +00:00
|
|
|
incaps: &gst::Caps,
|
|
|
|
outcaps: &gst::Caps,
|
2019-11-20 22:02:23 +00:00
|
|
|
) -> Result<(), gst::LoggableError> {
|
2019-02-02 16:11:30 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
(*parent_class)
|
|
|
|
.set_caps
|
|
|
|
.map(|f| {
|
2020-12-20 15:09:22 +00:00
|
|
|
gst::result_from_gboolean!(
|
2019-11-20 22:02:23 +00:00
|
|
|
f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2019-11-20 22:02:23 +00:00
|
|
|
incaps.to_glib_none().0,
|
|
|
|
outcaps.to_glib_none().0,
|
|
|
|
),
|
|
|
|
gst::CAT_RUST,
|
|
|
|
"Parent function `set_caps` failed"
|
|
|
|
)
|
2019-02-02 16:11:30 +00:00
|
|
|
})
|
2019-11-20 22:02:23 +00:00
|
|
|
.unwrap_or(Ok(()))
|
2019-02-02 16:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-20 21:40:39 +00:00
|
|
|
fn parent_accept_caps(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
) -> bool {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
(*parent_class)
|
|
|
|
.accept_caps
|
|
|
|
.map(|f| {
|
|
|
|
from_glib(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction.to_glib(),
|
|
|
|
caps.to_glib_none().0,
|
|
|
|
))
|
|
|
|
})
|
|
|
|
.unwrap_or(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_query(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
query: &mut gst::QueryRef,
|
|
|
|
) -> bool {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
(*parent_class)
|
|
|
|
.query
|
|
|
|
.map(|f| {
|
|
|
|
from_glib(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction.to_glib(),
|
|
|
|
query.as_mut_ptr(),
|
|
|
|
))
|
|
|
|
})
|
|
|
|
.unwrap_or(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_transform_size(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
size: usize,
|
|
|
|
othercaps: &gst::Caps,
|
|
|
|
) -> Option<usize> {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
(*parent_class)
|
|
|
|
.transform_size
|
|
|
|
.map(|f| {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut othersize = mem::MaybeUninit::uninit();
|
2018-11-20 21:40:39 +00:00
|
|
|
let res: bool = from_glib(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2018-11-20 21:40:39 +00:00
|
|
|
direction.to_glib(),
|
|
|
|
caps.to_glib_none().0,
|
|
|
|
size,
|
|
|
|
othercaps.to_glib_none().0,
|
2019-07-11 12:34:28 +00:00
|
|
|
othersize.as_mut_ptr(),
|
2018-11-20 21:40:39 +00:00
|
|
|
));
|
|
|
|
if res {
|
2019-07-11 12:34:28 +00:00
|
|
|
Some(othersize.assume_init())
|
2018-11-20 21:40:39 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.unwrap_or(None)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_get_unit_size(&self, element: &Self::Type, caps: &gst::Caps) -> Option<usize> {
|
2019-02-02 16:11:30 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
let f = (*parent_class).get_unit_size.unwrap_or_else(|| {
|
2020-11-14 16:01:13 +00:00
|
|
|
if !element.unsafe_cast_ref::<BaseTransform>().is_in_place() {
|
2019-02-02 16:11:30 +00:00
|
|
|
unimplemented!(concat!(
|
|
|
|
"Missing parent function `get_unit_size`. Required because ",
|
|
|
|
"transform element doesn't operate in-place"
|
|
|
|
))
|
|
|
|
} else {
|
|
|
|
unreachable!(concat!(
|
|
|
|
"parent `get_unit_size` called ",
|
|
|
|
"while transform element operates in-place"
|
|
|
|
))
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut size = mem::MaybeUninit::uninit();
|
2019-02-02 16:11:30 +00:00
|
|
|
if from_glib(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2019-02-02 16:11:30 +00:00
|
|
|
caps.to_glib_none().0,
|
2019-07-11 12:34:28 +00:00
|
|
|
size.as_mut_ptr(),
|
2019-02-02 16:11:30 +00:00
|
|
|
)) {
|
2019-07-11 12:34:28 +00:00
|
|
|
Some(size.assume_init())
|
2019-02-02 16:11:30 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
2018-11-20 21:40:39 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
(*parent_class)
|
|
|
|
.sink_event
|
2020-11-14 16:01:13 +00:00
|
|
|
.map(|f| {
|
|
|
|
from_glib(f(
|
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
|
|
|
event.into_ptr(),
|
|
|
|
))
|
|
|
|
})
|
2019-02-01 14:07:42 +00:00
|
|
|
.unwrap_or(true)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
2018-11-20 21:40:39 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
(*parent_class)
|
|
|
|
.src_event
|
2020-11-14 16:01:13 +00:00
|
|
|
.map(|f| {
|
|
|
|
from_glib(f(
|
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
|
|
|
event.into_ptr(),
|
|
|
|
))
|
|
|
|
})
|
2019-02-01 14:07:42 +00:00
|
|
|
.unwrap_or(true)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-02 16:11:30 +00:00
|
|
|
|
2020-02-22 16:36:20 +00:00
|
|
|
fn parent_prepare_output_buffer(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-22 16:36:20 +00:00
|
|
|
inbuf: &gst::BufferRef,
|
2020-04-02 16:57:04 +00:00
|
|
|
) -> Result<PrepareOutputBufferSuccess, gst::FlowError> {
|
2020-02-22 16:36:20 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2020-02-22 16:36:20 +00:00
|
|
|
(*parent_class)
|
|
|
|
.prepare_output_buffer
|
|
|
|
.map(|f| {
|
2020-11-21 17:59:22 +00:00
|
|
|
let mut outbuf: *mut gst::ffi::GstBuffer = ptr::null_mut();
|
2020-02-22 16:36:20 +00:00
|
|
|
// FIXME: Wrong signature in FFI
|
|
|
|
let res = from_glib(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2020-11-21 17:59:22 +00:00
|
|
|
inbuf.as_ptr() as *mut gst::ffi::GstBuffer,
|
|
|
|
(&mut outbuf) as *mut *mut gst::ffi::GstBuffer as *mut gst::ffi::GstBuffer,
|
2020-02-22 16:36:20 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
match gst::FlowReturn::into_result(res) {
|
|
|
|
Err(err) => Err(err),
|
|
|
|
Ok(_) => {
|
|
|
|
if outbuf == inbuf.as_ptr() as *mut _ {
|
2020-04-02 16:57:04 +00:00
|
|
|
Ok(PrepareOutputBufferSuccess::InputBuffer)
|
2020-02-22 16:36:20 +00:00
|
|
|
} else {
|
2020-04-02 16:57:04 +00:00
|
|
|
Ok(PrepareOutputBufferSuccess::Buffer(from_glib_full(outbuf)))
|
2020-02-22 16:36:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.unwrap_or(Err(gst::FlowError::NotSupported))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-02 16:11:30 +00:00
|
|
|
fn parent_transform(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-02 16:11:30 +00:00
|
|
|
inbuf: &gst::Buffer,
|
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
(*parent_class)
|
|
|
|
.transform
|
|
|
|
.map(|f| {
|
|
|
|
from_glib(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2019-02-02 16:11:30 +00:00
|
|
|
inbuf.to_glib_none().0,
|
|
|
|
outbuf.as_mut_ptr(),
|
|
|
|
))
|
|
|
|
})
|
|
|
|
.unwrap_or_else(|| {
|
2020-11-14 16:01:13 +00:00
|
|
|
if !element.unsafe_cast_ref::<BaseTransform>().is_in_place() {
|
2019-02-02 16:11:30 +00:00
|
|
|
gst::FlowReturn::NotSupported
|
|
|
|
} else {
|
|
|
|
unreachable!(concat!(
|
|
|
|
"parent `transform` called ",
|
|
|
|
"while transform element operates in-place"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.into_result()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_transform_ip(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-02-02 16:11:30 +00:00
|
|
|
buf: &mut gst::BufferRef,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
let f = (*parent_class).transform_ip.unwrap_or_else(|| {
|
2020-11-14 16:01:13 +00:00
|
|
|
if element.unsafe_cast_ref::<BaseTransform>().is_in_place() {
|
2019-02-02 16:11:30 +00:00
|
|
|
panic!(concat!(
|
|
|
|
"Missing parent function `transform_ip`. Required because ",
|
|
|
|
"transform element operates in-place"
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
unreachable!(concat!(
|
|
|
|
"parent `transform` called ",
|
|
|
|
"while transform element doesn't operate in-place"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
gst::FlowReturn::from_glib(f(
|
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
|
|
|
buf.as_mut_ptr() as *mut _,
|
|
|
|
))
|
|
|
|
.into_result()
|
2019-02-02 16:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_transform_ip_passthrough(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2019-05-23 11:28:09 +00:00
|
|
|
buf: &gst::Buffer,
|
2019-02-02 16:11:30 +00:00
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
let f = (*parent_class).transform_ip.unwrap_or_else(|| {
|
2020-11-14 16:01:13 +00:00
|
|
|
if element.unsafe_cast_ref::<BaseTransform>().is_in_place() {
|
2019-02-02 16:11:30 +00:00
|
|
|
panic!(concat!(
|
|
|
|
"Missing parent function `transform_ip`. Required because ",
|
|
|
|
"transform element operates in-place (passthrough mode)"
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
unreachable!(concat!(
|
|
|
|
"parent `transform_ip` called ",
|
|
|
|
"while transform element doesn't operate in-place (passthrough mode)"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-23 11:28:09 +00:00
|
|
|
// FIXME: Wrong signature in FFI
|
2020-11-21 17:59:22 +00:00
|
|
|
let buf: *mut gst::ffi::GstBuffer = buf.to_glib_none().0;
|
2020-11-14 16:01:13 +00:00
|
|
|
gst::FlowReturn::from_glib(f(
|
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
|
|
|
buf as *mut _,
|
|
|
|
))
|
|
|
|
.into_result()
|
2019-02-02 16:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-09 18:06:25 +00:00
|
|
|
|
2020-02-09 18:45:29 +00:00
|
|
|
fn parent_copy_metadata(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-09 18:45:29 +00:00
|
|
|
inbuf: &gst::BufferRef,
|
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2020-02-09 18:45:29 +00:00
|
|
|
if let Some(ref f) = (*parent_class).copy_metadata {
|
2020-12-20 15:09:22 +00:00
|
|
|
gst::result_from_gboolean!(
|
2020-02-09 18:45:29 +00:00
|
|
|
f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2020-02-09 18:45:29 +00:00
|
|
|
inbuf.as_ptr() as *mut _,
|
|
|
|
outbuf.as_mut_ptr()
|
|
|
|
),
|
|
|
|
gst::CAT_RUST,
|
|
|
|
"Parent function `copy_metadata` failed"
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_transform_meta<'a>(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-09 18:45:29 +00:00
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
meta: gst::MetaRef<'a, gst::Meta>,
|
|
|
|
inbuf: &'a gst::BufferRef,
|
|
|
|
) -> bool {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2020-02-09 18:45:29 +00:00
|
|
|
(*parent_class)
|
|
|
|
.transform_meta
|
|
|
|
.map(|f| {
|
|
|
|
from_glib(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2020-02-09 18:45:29 +00:00
|
|
|
outbuf.as_mut_ptr(),
|
|
|
|
meta.as_ptr() as *mut _,
|
|
|
|
inbuf.as_ptr() as *mut _,
|
|
|
|
))
|
|
|
|
})
|
|
|
|
.unwrap_or(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:01:13 +00:00
|
|
|
fn parent_before_transform(&self, element: &Self::Type, inbuf: &gst::BufferRef) {
|
2020-02-09 18:45:29 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2020-02-09 19:22:04 +00:00
|
|
|
if let Some(ref f) = (*parent_class).before_transform {
|
2020-11-14 16:01:13 +00:00
|
|
|
f(
|
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
|
|
|
inbuf.as_ptr() as *mut _,
|
|
|
|
);
|
2020-02-09 19:22:04 +00:00
|
|
|
}
|
2020-02-09 18:45:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-09 18:06:25 +00:00
|
|
|
fn parent_submit_input_buffer(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-02-09 18:06:25 +00:00
|
|
|
is_discont: bool,
|
|
|
|
inbuf: gst::Buffer,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2020-02-09 18:06:25 +00:00
|
|
|
let f = (*parent_class)
|
|
|
|
.submit_input_buffer
|
|
|
|
.expect("Missing parent function `submit_input_buffer`");
|
|
|
|
|
|
|
|
gst::FlowReturn::from_glib(f(
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
2020-02-09 18:06:25 +00:00
|
|
|
is_discont.to_glib(),
|
|
|
|
inbuf.into_ptr(),
|
|
|
|
))
|
|
|
|
.into_result()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_generate_output(
|
|
|
|
&self,
|
2020-11-14 16:01:13 +00:00
|
|
|
element: &Self::Type,
|
2020-04-02 16:57:04 +00:00
|
|
|
) -> Result<GenerateOutputSuccess, gst::FlowError> {
|
2020-02-09 18:06:25 +00:00
|
|
|
unsafe {
|
2020-07-25 08:02:04 +00:00
|
|
|
let data = T::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass;
|
2020-02-09 18:06:25 +00:00
|
|
|
let f = (*parent_class)
|
|
|
|
.generate_output
|
|
|
|
.expect("Missing parent function `generate_output`");
|
|
|
|
|
|
|
|
let mut outbuf = ptr::null_mut();
|
2020-11-14 16:01:13 +00:00
|
|
|
gst::FlowReturn::from_glib(f(
|
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
|
|
|
&mut outbuf,
|
|
|
|
))
|
|
|
|
.into_result()
|
|
|
|
.map(|res| {
|
2020-11-21 17:59:22 +00:00
|
|
|
if res == crate::BASE_TRANSFORM_FLOW_DROPPED {
|
2020-11-14 16:01:13 +00:00
|
|
|
GenerateOutputSuccess::Dropped
|
|
|
|
} else if res != gst::FlowSuccess::Ok || outbuf.is_null() {
|
|
|
|
GenerateOutputSuccess::NoOutput
|
|
|
|
} else {
|
|
|
|
GenerateOutputSuccess::Buffer(from_glib_full(outbuf))
|
|
|
|
}
|
|
|
|
})
|
2020-02-09 18:06:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn take_queued_buffer(&self) -> Option<gst::Buffer>
|
|
|
|
where
|
|
|
|
Self: ObjectSubclass,
|
|
|
|
<Self as ObjectSubclass>::ParentType: IsA<BaseTransform>,
|
|
|
|
{
|
|
|
|
unsafe {
|
2021-04-11 19:39:50 +00:00
|
|
|
let element = self.instance();
|
2020-11-21 17:59:22 +00:00
|
|
|
let ptr: *mut ffi::GstBaseTransform =
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0;
|
2020-04-05 14:52:56 +00:00
|
|
|
let sinkpad: Borrowed<gst::Pad> = from_glib_borrow((*ptr).sinkpad);
|
2020-02-09 18:06:25 +00:00
|
|
|
let _stream_lock = sinkpad.stream_lock();
|
|
|
|
let buffer = (*ptr).queued_buf;
|
|
|
|
(*ptr).queued_buf = ptr::null_mut();
|
|
|
|
from_glib_full(buffer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 19:39:50 +00:00
|
|
|
fn queued_buffer(&self) -> Option<gst::Buffer>
|
2020-02-09 18:06:25 +00:00
|
|
|
where
|
|
|
|
Self: ObjectSubclass,
|
|
|
|
<Self as ObjectSubclass>::ParentType: IsA<BaseTransform>,
|
|
|
|
{
|
|
|
|
unsafe {
|
2021-04-11 19:39:50 +00:00
|
|
|
let element = self.instance();
|
2020-11-21 17:59:22 +00:00
|
|
|
let ptr: *mut ffi::GstBaseTransform =
|
2020-11-14 16:01:13 +00:00
|
|
|
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0;
|
2020-04-05 14:52:56 +00:00
|
|
|
let sinkpad: Borrowed<gst::Pad> = from_glib_borrow((*ptr).sinkpad);
|
2020-02-09 18:06:25 +00:00
|
|
|
let _stream_lock = sinkpad.stream_lock();
|
|
|
|
let buffer = (*ptr).queued_buf;
|
|
|
|
from_glib_none(buffer)
|
|
|
|
}
|
|
|
|
}
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
unsafe impl<T: BaseTransformImpl> IsSubclassable<T> for BaseTransform {
|
2021-03-08 10:06:56 +00:00
|
|
|
fn class_init(klass: &mut glib::Class<Self>) {
|
|
|
|
<gst::Element as IsSubclassable<T>>::class_init(klass);
|
2020-11-05 17:07:31 +00:00
|
|
|
let klass = klass.as_mut();
|
|
|
|
klass.start = Some(base_transform_start::<T>);
|
|
|
|
klass.stop = Some(base_transform_stop::<T>);
|
|
|
|
klass.transform_caps = Some(base_transform_transform_caps::<T>);
|
|
|
|
klass.fixate_caps = Some(base_transform_fixate_caps::<T>);
|
|
|
|
klass.set_caps = Some(base_transform_set_caps::<T>);
|
|
|
|
klass.accept_caps = Some(base_transform_accept_caps::<T>);
|
|
|
|
klass.query = Some(base_transform_query::<T>);
|
|
|
|
klass.transform_size = Some(base_transform_transform_size::<T>);
|
|
|
|
klass.get_unit_size = Some(base_transform_get_unit_size::<T>);
|
|
|
|
klass.prepare_output_buffer = Some(base_transform_prepare_output_buffer::<T>);
|
|
|
|
klass.sink_event = Some(base_transform_sink_event::<T>);
|
|
|
|
klass.src_event = Some(base_transform_src_event::<T>);
|
|
|
|
klass.transform_meta = Some(base_transform_transform_meta::<T>);
|
|
|
|
klass.copy_metadata = Some(base_transform_copy_metadata::<T>);
|
|
|
|
klass.before_transform = Some(base_transform_before_transform::<T>);
|
|
|
|
klass.submit_input_buffer = Some(base_transform_submit_input_buffer::<T>);
|
|
|
|
klass.generate_output = Some(base_transform_generate_output::<T>);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2020-10-20 20:55:20 +00:00
|
|
|
klass.passthrough_on_same_caps = T::PASSTHROUGH_ON_SAME_CAPS.to_glib();
|
|
|
|
klass.transform_ip_on_passthrough = T::TRANSFORM_IP_ON_PASSTHROUGH.to_glib();
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2020-10-20 20:55:20 +00:00
|
|
|
match T::MODE {
|
|
|
|
BaseTransformMode::AlwaysInPlace => {
|
|
|
|
klass.transform = None;
|
|
|
|
klass.transform_ip = Some(base_transform_transform_ip::<T>);
|
|
|
|
}
|
|
|
|
BaseTransformMode::NeverInPlace => {
|
|
|
|
klass.transform = Some(base_transform_transform::<T>);
|
|
|
|
klass.transform_ip = None;
|
|
|
|
}
|
|
|
|
BaseTransformMode::Both => {
|
|
|
|
klass.transform = Some(base_transform_transform::<T>);
|
|
|
|
klass.transform_ip = Some(base_transform_transform_ip::<T>);
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-09 11:50:32 +00:00
|
|
|
|
|
|
|
fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
|
|
|
|
<gst::Element as IsSubclassable<T>>::instance_init(instance);
|
|
|
|
}
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2020-02-09 18:06:25 +00:00
|
|
|
#[derive(Debug)]
|
2020-04-02 16:57:04 +00:00
|
|
|
pub enum GenerateOutputSuccess {
|
2020-02-09 18:06:25 +00:00
|
|
|
Buffer(gst::Buffer),
|
|
|
|
NoOutput,
|
|
|
|
Dropped,
|
|
|
|
}
|
|
|
|
|
2020-02-22 16:36:20 +00:00
|
|
|
#[derive(Debug)]
|
2020-04-02 16:57:04 +00:00
|
|
|
pub enum PrepareOutputBufferSuccess {
|
2020-02-22 16:36:20 +00:00
|
|
|
Buffer(gst::Buffer),
|
|
|
|
InputBuffer,
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_start<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2020-11-14 16:01:13 +00:00
|
|
|
match imp.start(wrap.unsafe_cast_ref()) {
|
2019-01-26 14:22:06 +00:00
|
|
|
Ok(()) => true,
|
|
|
|
Err(err) => {
|
2020-06-30 20:51:15 +00:00
|
|
|
wrap.post_error_message(err);
|
2019-01-26 14:22:06 +00:00
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_stop<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2020-11-14 16:01:13 +00:00
|
|
|
match imp.stop(wrap.unsafe_cast_ref()) {
|
2019-01-26 14:22:06 +00:00
|
|
|
Ok(()) => true,
|
|
|
|
Err(err) => {
|
2020-06-30 20:51:15 +00:00
|
|
|
wrap.post_error_message(err);
|
2019-01-26 14:22:06 +00:00
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_transform_caps<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
direction: gst::ffi::GstPadDirection,
|
|
|
|
caps: *mut gst::ffi::GstCaps,
|
|
|
|
filter: *mut gst::ffi::GstCaps,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> *mut gst::ffi::GstCaps {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), None, {
|
2020-04-05 14:52:56 +00:00
|
|
|
let filter: Borrowed<Option<gst::Caps>> = from_glib_borrow(filter);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
|
|
|
imp.transform_caps(
|
2020-11-14 16:01:13 +00:00
|
|
|
wrap.unsafe_cast_ref(),
|
2018-11-20 21:40:39 +00:00
|
|
|
from_glib(direction),
|
|
|
|
&from_glib_borrow(caps),
|
2020-04-05 14:52:56 +00:00
|
|
|
filter.as_ref().as_ref(),
|
2018-11-20 21:40:39 +00:00
|
|
|
)
|
|
|
|
})
|
2019-02-01 14:07:42 +00:00
|
|
|
.map(|caps| caps.into_ptr())
|
|
|
|
.unwrap_or(std::ptr::null_mut())
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_fixate_caps<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
direction: gst::ffi::GstPadDirection,
|
|
|
|
caps: *mut gst::ffi::GstCaps,
|
|
|
|
othercaps: *mut gst::ffi::GstCaps,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> *mut gst::ffi::GstCaps {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), {
|
2018-11-20 21:40:39 +00:00
|
|
|
imp.fixate_caps(
|
2020-11-14 16:01:13 +00:00
|
|
|
wrap.unsafe_cast_ref(),
|
2018-11-20 21:40:39 +00:00
|
|
|
from_glib(direction),
|
|
|
|
&from_glib_borrow(caps),
|
|
|
|
from_glib_full(othercaps),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.into_ptr()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_set_caps<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
incaps: *mut gst::ffi::GstCaps,
|
|
|
|
outcaps: *mut gst::ffi::GstCaps,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2020-11-14 16:01:13 +00:00
|
|
|
match imp.set_caps(
|
|
|
|
wrap.unsafe_cast_ref(),
|
|
|
|
&from_glib_borrow(incaps),
|
|
|
|
&from_glib_borrow(outcaps),
|
|
|
|
) {
|
2019-11-20 22:02:23 +00:00
|
|
|
Ok(()) => true,
|
|
|
|
Err(err) => {
|
2020-04-05 14:52:56 +00:00
|
|
|
err.log_with_object(&*wrap);
|
2019-11-20 22:02:23 +00:00
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
2018-11-20 21:40:39 +00:00
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_accept_caps<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
direction: gst::ffi::GstPadDirection,
|
|
|
|
caps: *mut gst::ffi::GstCaps,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2020-11-14 16:01:13 +00:00
|
|
|
imp.accept_caps(
|
|
|
|
wrap.unsafe_cast_ref(),
|
|
|
|
from_glib(direction),
|
|
|
|
&from_glib_borrow(caps),
|
|
|
|
)
|
2018-11-20 21:40:39 +00:00
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_query<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
direction: gst::ffi::GstPadDirection,
|
|
|
|
query: *mut gst::ffi::GstQuery,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2018-11-20 21:40:39 +00:00
|
|
|
BaseTransformImpl::query(
|
|
|
|
imp,
|
2020-11-14 16:01:13 +00:00
|
|
|
wrap.unsafe_cast_ref(),
|
2018-11-20 21:40:39 +00:00
|
|
|
from_glib(direction),
|
|
|
|
gst::QueryRef::from_mut_ptr(query),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_transform_size<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
direction: gst::ffi::GstPadDirection,
|
|
|
|
caps: *mut gst::ffi::GstCaps,
|
2018-11-20 21:40:39 +00:00
|
|
|
size: usize,
|
2020-11-21 17:59:22 +00:00
|
|
|
othercaps: *mut gst::ffi::GstCaps,
|
2018-11-20 21:40:39 +00:00
|
|
|
othersize: *mut usize,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2018-11-20 21:40:39 +00:00
|
|
|
match imp.transform_size(
|
2020-11-14 16:01:13 +00:00
|
|
|
wrap.unsafe_cast_ref(),
|
2018-11-20 21:40:39 +00:00
|
|
|
from_glib(direction),
|
|
|
|
&from_glib_borrow(caps),
|
|
|
|
size,
|
|
|
|
&from_glib_borrow(othercaps),
|
|
|
|
) {
|
|
|
|
Some(s) => {
|
|
|
|
*othersize = s;
|
|
|
|
true
|
|
|
|
}
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_get_unit_size<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
caps: *mut gst::ffi::GstCaps,
|
2018-11-20 21:40:39 +00:00
|
|
|
size: *mut usize,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2020-11-14 16:01:13 +00:00
|
|
|
match imp.get_unit_size(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
|
2018-11-20 21:40:39 +00:00
|
|
|
Some(s) => {
|
|
|
|
*size = s;
|
|
|
|
true
|
|
|
|
}
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_prepare_output_buffer<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
inbuf: *mut gst::ffi::GstBuffer,
|
|
|
|
outbuf: *mut gst::ffi::GstBuffer,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> gst::ffi::GstFlowReturn {
|
2020-02-22 16:36:20 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2020-02-22 16:36:20 +00:00
|
|
|
|
|
|
|
// FIXME: Wrong signature in FFI
|
2020-11-21 17:59:22 +00:00
|
|
|
let outbuf = outbuf as *mut *mut gst::ffi::GstBuffer;
|
2020-02-22 16:36:20 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, {
|
2020-11-14 16:01:13 +00:00
|
|
|
match imp.prepare_output_buffer(wrap.unsafe_cast_ref(), gst::BufferRef::from_ptr(inbuf)) {
|
2020-04-02 16:57:04 +00:00
|
|
|
Ok(PrepareOutputBufferSuccess::InputBuffer) => {
|
2020-02-22 16:36:20 +00:00
|
|
|
*outbuf = inbuf;
|
|
|
|
gst::FlowReturn::Ok
|
|
|
|
}
|
2020-04-02 16:57:04 +00:00
|
|
|
Ok(PrepareOutputBufferSuccess::Buffer(buf)) => {
|
2020-02-22 16:36:20 +00:00
|
|
|
*outbuf = buf.into_ptr();
|
|
|
|
gst::FlowReturn::Ok
|
|
|
|
}
|
|
|
|
Err(err) => err.into(),
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_sink_event<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
event: *mut gst::ffi::GstEvent,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2020-11-14 16:01:13 +00:00
|
|
|
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
2018-11-20 21:40:39 +00:00
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_src_event<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
event: *mut gst::ffi::GstEvent,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2020-11-14 16:01:13 +00:00
|
|
|
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
2018-11-20 21:40:39 +00:00
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_transform<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
inbuf: *mut gst::ffi::GstBuffer,
|
|
|
|
outbuf: *mut gst::ffi::GstBuffer,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> gst::ffi::GstFlowReturn {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, {
|
2018-11-20 21:40:39 +00:00
|
|
|
imp.transform(
|
2020-11-14 16:01:13 +00:00
|
|
|
wrap.unsafe_cast_ref(),
|
2018-11-20 21:40:39 +00:00
|
|
|
&from_glib_borrow(inbuf),
|
|
|
|
gst::BufferRef::from_mut_ptr(outbuf),
|
|
|
|
)
|
2019-01-08 16:13:37 +00:00
|
|
|
.into()
|
2018-11-20 21:40:39 +00:00
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_transform_ip<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
buf: *mut *mut gst::ffi::GstBuffer,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> gst::ffi::GstFlowReturn {
|
2018-11-20 21:40:39 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
|
|
|
// FIXME: Wrong signature in FFI
|
2020-11-21 17:59:22 +00:00
|
|
|
let buf = buf as *mut gst::ffi::GstBuffer;
|
2018-11-20 21:40:39 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, {
|
2020-11-21 17:59:22 +00:00
|
|
|
if from_glib(ffi::gst_base_transform_is_passthrough(ptr)) {
|
2020-11-14 16:01:13 +00:00
|
|
|
imp.transform_ip_passthrough(wrap.unsafe_cast_ref(), &from_glib_borrow(buf))
|
2019-01-08 16:13:37 +00:00
|
|
|
.into()
|
2018-11-20 21:40:39 +00:00
|
|
|
} else {
|
2020-11-14 16:01:13 +00:00
|
|
|
imp.transform_ip(wrap.unsafe_cast_ref(), gst::BufferRef::from_mut_ptr(buf))
|
2019-01-08 16:13:37 +00:00
|
|
|
.into()
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
2020-02-09 18:06:25 +00:00
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_transform_meta<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
outbuf: *mut gst::ffi::GstBuffer,
|
|
|
|
meta: *mut gst::ffi::GstMeta,
|
|
|
|
inbuf: *mut gst::ffi::GstBuffer,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-09 18:45:29 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2020-02-09 18:45:29 +00:00
|
|
|
|
|
|
|
let inbuf = gst::BufferRef::from_ptr(inbuf);
|
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
2020-02-09 18:45:29 +00:00
|
|
|
imp.transform_meta(
|
2020-11-14 16:01:13 +00:00
|
|
|
wrap.unsafe_cast_ref(),
|
2020-02-09 18:45:29 +00:00
|
|
|
gst::BufferRef::from_mut_ptr(outbuf),
|
|
|
|
gst::Meta::from_ptr(inbuf, meta),
|
|
|
|
inbuf,
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_copy_metadata<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
inbuf: *mut gst::ffi::GstBuffer,
|
|
|
|
outbuf: *mut gst::ffi::GstBuffer,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-09 18:45:29 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2020-02-09 18:45:29 +00:00
|
|
|
|
2020-11-21 17:59:22 +00:00
|
|
|
if gst::ffi::gst_mini_object_is_writable(outbuf as *mut _) == glib::ffi::GFALSE {
|
2020-12-20 15:09:22 +00:00
|
|
|
gst_warning!(
|
2020-02-09 18:45:29 +00:00
|
|
|
gst::CAT_RUST,
|
2020-04-05 14:52:56 +00:00
|
|
|
obj: &*wrap,
|
2020-02-09 18:45:29 +00:00
|
|
|
"buffer {:?} not writable",
|
|
|
|
outbuf
|
|
|
|
);
|
2020-11-21 17:59:22 +00:00
|
|
|
return glib::ffi::GFALSE;
|
2020-02-09 18:45:29 +00:00
|
|
|
}
|
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), true, {
|
2020-02-09 18:45:29 +00:00
|
|
|
match imp.copy_metadata(
|
2020-11-14 16:01:13 +00:00
|
|
|
wrap.unsafe_cast_ref(),
|
2020-02-09 18:45:29 +00:00
|
|
|
gst::BufferRef::from_ptr(inbuf),
|
|
|
|
gst::BufferRef::from_mut_ptr(outbuf),
|
|
|
|
) {
|
|
|
|
Ok(_) => true,
|
|
|
|
Err(err) => {
|
2020-04-05 14:52:56 +00:00
|
|
|
err.log_with_object(&*wrap);
|
2020-02-09 18:45:29 +00:00
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_before_transform<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
inbuf: *mut gst::ffi::GstBuffer,
|
2021-03-09 13:37:05 +00:00
|
|
|
) {
|
2020-02-09 18:45:29 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2020-02-09 18:45:29 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), (), {
|
2020-11-14 16:01:13 +00:00
|
|
|
imp.before_transform(wrap.unsafe_cast_ref(), gst::BufferRef::from_ptr(inbuf));
|
2020-02-09 18:45:29 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_submit_input_buffer<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
is_discont: glib::ffi::gboolean,
|
|
|
|
buf: *mut gst::ffi::GstBuffer,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> gst::ffi::GstFlowReturn {
|
2020-02-09 18:06:25 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2020-02-09 18:06:25 +00:00
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, {
|
2020-11-14 16:01:13 +00:00
|
|
|
imp.submit_input_buffer(
|
|
|
|
wrap.unsafe_cast_ref(),
|
|
|
|
from_glib(is_discont),
|
|
|
|
from_glib_full(buf),
|
|
|
|
)
|
|
|
|
.into()
|
2020-02-09 18:06:25 +00:00
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn base_transform_generate_output<T: BaseTransformImpl>(
|
2020-11-21 17:59:22 +00:00
|
|
|
ptr: *mut ffi::GstBaseTransform,
|
|
|
|
buf: *mut *mut gst::ffi::GstBuffer,
|
2021-03-09 13:37:05 +00:00
|
|
|
) -> gst::ffi::GstFlowReturn {
|
2020-02-09 18:06:25 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
2020-02-09 18:06:25 +00:00
|
|
|
|
|
|
|
*buf = ptr::null_mut();
|
|
|
|
|
2021-03-09 13:37:05 +00:00
|
|
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::FlowReturn::Error, {
|
2020-11-14 16:01:13 +00:00
|
|
|
match imp.generate_output(wrap.unsafe_cast_ref()) {
|
2020-11-21 17:59:22 +00:00
|
|
|
Ok(GenerateOutputSuccess::Dropped) => crate::BASE_TRANSFORM_FLOW_DROPPED.into(),
|
2020-04-02 16:57:04 +00:00
|
|
|
Ok(GenerateOutputSuccess::NoOutput) => gst::FlowReturn::Ok,
|
|
|
|
Ok(GenerateOutputSuccess::Buffer(outbuf)) => {
|
2020-02-09 18:06:25 +00:00
|
|
|
*buf = outbuf.into_ptr();
|
|
|
|
gst::FlowReturn::Ok
|
|
|
|
}
|
|
|
|
Err(err) => err.into(),
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|