2019-02-01 14:07:42 +00:00
|
|
|
// Copyright (C) 2017-2019 Sebastian Dröge <sebastian@centricular.com>
|
2018-11-20 21:40:39 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
use glib_sys;
|
|
|
|
use gst_base_sys;
|
|
|
|
use gst_sys;
|
2018-11-20 21:40:39 +00:00
|
|
|
|
|
|
|
use glib::translate::*;
|
|
|
|
use prelude::*;
|
|
|
|
|
|
|
|
use glib::subclass::prelude::*;
|
|
|
|
use gst;
|
|
|
|
use gst::subclass::prelude::*;
|
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
use std::mem;
|
|
|
|
|
2018-11-20 21:40:39 +00:00
|
|
|
use BaseTransform;
|
|
|
|
use BaseTransformClass;
|
|
|
|
|
2019-02-12 14:23:30 +00:00
|
|
|
pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl + Send + Sync + 'static {
|
2019-02-02 16:11:30 +00:00
|
|
|
fn start(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
|
|
|
|
self.parent_start(element)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
2019-02-02 16:11:30 +00:00
|
|
|
fn stop(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
|
|
|
|
self.parent_stop(element)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn transform_caps(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
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,
|
|
|
|
element: &BaseTransform,
|
|
|
|
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,
|
|
|
|
element: &BaseTransform,
|
|
|
|
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,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
) -> bool {
|
|
|
|
self.parent_accept_caps(element, direction, caps)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn query(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
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,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
size: usize,
|
|
|
|
othercaps: &gst::Caps,
|
|
|
|
) -> Option<usize> {
|
|
|
|
self.parent_transform_size(element, direction, caps, size, othercaps)
|
|
|
|
}
|
|
|
|
|
2019-02-02 16:11:30 +00:00
|
|
|
fn get_unit_size(&self, element: &BaseTransform, caps: &gst::Caps) -> Option<usize> {
|
|
|
|
self.parent_get_unit_size(element, caps)
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn sink_event(&self, element: &BaseTransform, event: gst::Event) -> bool {
|
|
|
|
self.parent_sink_event(element, event)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn src_event(&self, element: &BaseTransform, event: gst::Event) -> bool {
|
|
|
|
self.parent_src_event(element, event)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn transform(
|
|
|
|
&self,
|
2019-02-02 16:11:30 +00:00
|
|
|
element: &BaseTransform,
|
|
|
|
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,
|
2019-02-02 16:11:30 +00:00
|
|
|
element: &BaseTransform,
|
|
|
|
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,
|
2019-02-02 16:11:30 +00:00
|
|
|
element: &BaseTransform,
|
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)
|
|
|
|
}
|
2019-02-12 14:23:30 +00:00
|
|
|
}
|
2019-02-02 16:11:30 +00:00
|
|
|
|
2019-02-12 14:23:30 +00:00
|
|
|
pub trait BaseTransformImplExt {
|
|
|
|
fn parent_start(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage>;
|
|
|
|
|
|
|
|
fn parent_stop(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage>;
|
|
|
|
|
|
|
|
fn parent_transform_caps(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
filter: Option<&gst::Caps>,
|
|
|
|
) -> Option<gst::Caps>;
|
|
|
|
|
|
|
|
fn parent_fixate_caps(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
othercaps: gst::Caps,
|
|
|
|
) -> gst::Caps;
|
|
|
|
|
|
|
|
fn parent_set_caps(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
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,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
) -> bool;
|
|
|
|
|
|
|
|
fn parent_query(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
query: &mut gst::QueryRef,
|
|
|
|
) -> bool;
|
|
|
|
|
|
|
|
fn parent_transform_size(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
size: usize,
|
|
|
|
othercaps: &gst::Caps,
|
|
|
|
) -> Option<usize>;
|
|
|
|
|
|
|
|
fn parent_get_unit_size(&self, element: &BaseTransform, caps: &gst::Caps) -> Option<usize>;
|
|
|
|
|
|
|
|
fn parent_sink_event(&self, element: &BaseTransform, event: gst::Event) -> bool;
|
|
|
|
|
|
|
|
fn parent_src_event(&self, element: &BaseTransform, event: gst::Event) -> bool;
|
|
|
|
|
|
|
|
fn parent_transform(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
inbuf: &gst::Buffer,
|
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
|
|
|
|
|
|
|
fn parent_transform_ip(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
buf: &mut gst::BufferRef,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
|
|
|
|
|
|
|
fn parent_transform_ip_passthrough(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
2019-05-23 11:28:09 +00:00
|
|
|
buf: &gst::Buffer,
|
2019-02-12 14:23:30 +00:00
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: BaseTransformImpl + ObjectImpl> BaseTransformImplExt for T {
|
2019-02-02 16:11:30 +00:00
|
|
|
fn parent_start(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
(*parent_class)
|
|
|
|
.start
|
|
|
|
.map(|f| {
|
|
|
|
if from_glib(f(element.to_glib_none().0)) {
|
|
|
|
Ok(())
|
|
|
|
} else {
|
|
|
|
Err(gst_error_msg!(
|
|
|
|
gst::CoreError::StateChange,
|
|
|
|
["Parent function `start` failed"]
|
|
|
|
))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.unwrap_or(Ok(()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_stop(&self, element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
(*parent_class)
|
|
|
|
.stop
|
|
|
|
.map(|f| {
|
|
|
|
if from_glib(f(element.to_glib_none().0)) {
|
|
|
|
Ok(())
|
|
|
|
} else {
|
|
|
|
Err(gst_error_msg!(
|
|
|
|
gst::CoreError::StateChange,
|
|
|
|
["Parent function `stop` failed"]
|
|
|
|
))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.unwrap_or(Ok(()))
|
|
|
|
}
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_transform_caps(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
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 {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2019-02-01 14:07:42 +00:00
|
|
|
(*parent_class)
|
|
|
|
.transform_caps
|
|
|
|
.map(|f| {
|
|
|
|
from_glib_full(f(
|
|
|
|
element.to_glib_none().0,
|
|
|
|
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,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
othercaps: gst::Caps,
|
|
|
|
) -> gst::Caps {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
match (*parent_class).fixate_caps {
|
|
|
|
Some(f) => from_glib_full(f(
|
|
|
|
element.to_glib_none().0,
|
|
|
|
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,
|
|
|
|
element: &BaseTransform,
|
|
|
|
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 {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
(*parent_class)
|
|
|
|
.set_caps
|
|
|
|
.map(|f| {
|
2019-11-20 22:02:23 +00:00
|
|
|
gst_result_from_gboolean!(
|
|
|
|
f(
|
|
|
|
element.to_glib_none().0,
|
|
|
|
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,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
) -> bool {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
(*parent_class)
|
|
|
|
.accept_caps
|
|
|
|
.map(|f| {
|
|
|
|
from_glib(f(
|
|
|
|
element.to_glib_none().0,
|
|
|
|
direction.to_glib(),
|
|
|
|
caps.to_glib_none().0,
|
|
|
|
))
|
|
|
|
})
|
|
|
|
.unwrap_or(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_query(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
query: &mut gst::QueryRef,
|
|
|
|
) -> bool {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
(*parent_class)
|
|
|
|
.query
|
|
|
|
.map(|f| {
|
|
|
|
from_glib(f(
|
|
|
|
element.to_glib_none().0,
|
|
|
|
direction.to_glib(),
|
|
|
|
query.as_mut_ptr(),
|
|
|
|
))
|
|
|
|
})
|
|
|
|
.unwrap_or(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_transform_size(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
direction: gst::PadDirection,
|
|
|
|
caps: &gst::Caps,
|
|
|
|
size: usize,
|
|
|
|
othercaps: &gst::Caps,
|
|
|
|
) -> Option<usize> {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::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(
|
|
|
|
element.to_glib_none().0,
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-02 16:11:30 +00:00
|
|
|
fn parent_get_unit_size(&self, element: &BaseTransform, caps: &gst::Caps) -> Option<usize> {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
let f = (*parent_class).get_unit_size.unwrap_or_else(|| {
|
|
|
|
if !element.is_in_place() {
|
|
|
|
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(
|
|
|
|
element.to_glib_none().0,
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-20 21:40:39 +00:00
|
|
|
fn parent_sink_event(&self, element: &BaseTransform, event: gst::Event) -> bool {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
(*parent_class)
|
|
|
|
.sink_event
|
|
|
|
.map(|f| from_glib(f(element.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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_src_event(&self, element: &BaseTransform, event: gst::Event) -> bool {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2018-11-20 21:40:39 +00:00
|
|
|
(*parent_class)
|
|
|
|
.src_event
|
|
|
|
.map(|f| from_glib(f(element.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
|
|
|
|
|
|
|
fn parent_transform(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
inbuf: &gst::Buffer,
|
|
|
|
outbuf: &mut gst::BufferRef,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
(*parent_class)
|
|
|
|
.transform
|
|
|
|
.map(|f| {
|
|
|
|
from_glib(f(
|
|
|
|
element.to_glib_none().0,
|
|
|
|
inbuf.to_glib_none().0,
|
|
|
|
outbuf.as_mut_ptr(),
|
|
|
|
))
|
|
|
|
})
|
|
|
|
.unwrap_or_else(|| {
|
|
|
|
if !element.is_in_place() {
|
|
|
|
gst::FlowReturn::NotSupported
|
|
|
|
} else {
|
|
|
|
unreachable!(concat!(
|
|
|
|
"parent `transform` called ",
|
|
|
|
"while transform element operates in-place"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.into_result()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_transform_ip(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
|
|
|
buf: &mut gst::BufferRef,
|
|
|
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
|
|
|
unsafe {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
let f = (*parent_class).transform_ip.unwrap_or_else(|| {
|
|
|
|
if element.is_in_place() {
|
|
|
|
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"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-23 11:28:09 +00:00
|
|
|
gst::FlowReturn::from_glib(f(element.to_glib_none().0, buf.as_mut_ptr() as *mut _))
|
2019-02-02 16:11:30 +00:00
|
|
|
.into_result()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_transform_ip_passthrough(
|
|
|
|
&self,
|
|
|
|
element: &BaseTransform,
|
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 {
|
|
|
|
let data = self.get_type_data();
|
2019-03-19 07:58:20 +00:00
|
|
|
let parent_class =
|
|
|
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
|
2019-02-02 16:11:30 +00:00
|
|
|
let f = (*parent_class).transform_ip.unwrap_or_else(|| {
|
|
|
|
if element.is_in_place() {
|
|
|
|
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
|
|
|
|
let buf: *mut gst_sys::GstBuffer = buf.to_glib_none().0;
|
|
|
|
gst::FlowReturn::from_glib(f(element.to_glib_none().0, buf as *mut _)).into_result()
|
2019-02-02 16:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
|
|
|
pub enum BaseTransformMode {
|
|
|
|
AlwaysInPlace,
|
|
|
|
NeverInPlace,
|
|
|
|
Both,
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl<T: ObjectSubclass + BaseTransformImpl> IsSubclassable<T> for BaseTransformClass
|
|
|
|
where
|
|
|
|
<T as ObjectSubclass>::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
fn override_vfuncs(&mut self) {
|
|
|
|
<gst::ElementClass as IsSubclassable<T>>::override_vfuncs(self);
|
|
|
|
unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstBaseTransformClass);
|
2018-11-20 21:40:39 +00:00
|
|
|
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.sink_event = Some(base_transform_sink_event::<T>);
|
|
|
|
klass.src_event = Some(base_transform_src_event::<T>);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub unsafe trait BaseTransformClassSubclassExt: Sized + 'static {
|
|
|
|
fn configure<T: ObjectSubclass + BaseTransformImpl>(
|
|
|
|
&mut self,
|
|
|
|
mode: BaseTransformMode,
|
|
|
|
passthrough_on_same_caps: bool,
|
|
|
|
transform_ip_on_passthrough: bool,
|
|
|
|
) where
|
|
|
|
Self: ClassStruct<Type = T>,
|
|
|
|
<T as ObjectSubclass>::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstBaseTransformClass);
|
2018-11-20 21:40:39 +00:00
|
|
|
|
|
|
|
klass.passthrough_on_same_caps = passthrough_on_same_caps.to_glib();
|
|
|
|
klass.transform_ip_on_passthrough = transform_ip_on_passthrough.to_glib();
|
|
|
|
|
|
|
|
match mode {
|
|
|
|
BaseTransformMode::AlwaysInPlace => {
|
|
|
|
klass.transform_ip = Some(base_transform_transform_ip::<T>);
|
|
|
|
}
|
|
|
|
BaseTransformMode::NeverInPlace => {
|
|
|
|
klass.transform = Some(base_transform_transform::<T>);
|
|
|
|
}
|
|
|
|
BaseTransformMode::Both => {
|
|
|
|
klass.transform = Some(base_transform_transform::<T>);
|
|
|
|
klass.transform_ip = Some(base_transform_transform_ip::<T>);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl<T: ClassStruct> BaseTransformClassSubclassExt for T
|
|
|
|
where
|
|
|
|
T::Type: ObjectSubclass + BaseTransformImpl,
|
|
|
|
<T::Type as ObjectSubclass>::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_start<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
) -> glib_sys::gboolean
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
2019-01-26 14:22:06 +00:00
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
|
|
|
match imp.start(&wrap) {
|
|
|
|
Ok(()) => true,
|
|
|
|
Err(err) => {
|
|
|
|
wrap.post_error_message(&err);
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_stop<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
) -> glib_sys::gboolean
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
2019-01-26 14:22:06 +00:00
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
|
|
|
match imp.stop(&wrap) {
|
|
|
|
Ok(()) => true,
|
|
|
|
Err(err) => {
|
|
|
|
wrap.post_error_message(&err);
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
2018-11-20 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_transform_caps<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
direction: gst_sys::GstPadDirection,
|
|
|
|
caps: *mut gst_sys::GstCaps,
|
|
|
|
filter: *mut gst_sys::GstCaps,
|
|
|
|
) -> *mut gst_sys::GstCaps
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
2019-02-01 14:07:42 +00:00
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
|
2018-11-20 21:40:39 +00:00
|
|
|
let filter = if filter.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(from_glib_borrow(filter))
|
|
|
|
};
|
|
|
|
|
|
|
|
imp.transform_caps(
|
|
|
|
&wrap,
|
|
|
|
from_glib(direction),
|
|
|
|
&from_glib_borrow(caps),
|
|
|
|
filter.as_ref(),
|
|
|
|
)
|
|
|
|
})
|
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
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_fixate_caps<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
direction: gst_sys::GstPadDirection,
|
|
|
|
caps: *mut gst_sys::GstCaps,
|
|
|
|
othercaps: *mut gst_sys::GstCaps,
|
|
|
|
) -> *mut gst_sys::GstCaps
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
|
|
|
imp.fixate_caps(
|
|
|
|
&wrap,
|
|
|
|
from_glib(direction),
|
|
|
|
&from_glib_borrow(caps),
|
|
|
|
from_glib_full(othercaps),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.into_ptr()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_set_caps<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
incaps: *mut gst_sys::GstCaps,
|
|
|
|
outcaps: *mut gst_sys::GstCaps,
|
|
|
|
) -> glib_sys::gboolean
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
2019-11-20 22:02:23 +00:00
|
|
|
match imp.set_caps(&wrap, &from_glib_borrow(incaps), &from_glib_borrow(outcaps)) {
|
|
|
|
Ok(()) => true,
|
|
|
|
Err(err) => {
|
|
|
|
err.log_with_object(&wrap);
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
2018-11-20 21:40:39 +00:00
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_accept_caps<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
direction: gst_sys::GstPadDirection,
|
|
|
|
caps: *mut gst_sys::GstCaps,
|
|
|
|
) -> glib_sys::gboolean
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
|
|
|
imp.accept_caps(&wrap, from_glib(direction), &from_glib_borrow(caps))
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_query<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
direction: gst_sys::GstPadDirection,
|
|
|
|
query: *mut gst_sys::GstQuery,
|
|
|
|
) -> glib_sys::gboolean
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
|
|
|
BaseTransformImpl::query(
|
|
|
|
imp,
|
|
|
|
&wrap,
|
|
|
|
from_glib(direction),
|
|
|
|
gst::QueryRef::from_mut_ptr(query),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_transform_size<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
direction: gst_sys::GstPadDirection,
|
|
|
|
caps: *mut gst_sys::GstCaps,
|
2018-11-20 21:40:39 +00:00
|
|
|
size: usize,
|
2019-03-19 07:58:20 +00:00
|
|
|
othercaps: *mut gst_sys::GstCaps,
|
2018-11-20 21:40:39 +00:00
|
|
|
othersize: *mut usize,
|
2019-03-19 07:58:20 +00:00
|
|
|
) -> glib_sys::gboolean
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
|
|
|
match imp.transform_size(
|
|
|
|
&wrap,
|
|
|
|
from_glib(direction),
|
|
|
|
&from_glib_borrow(caps),
|
|
|
|
size,
|
|
|
|
&from_glib_borrow(othercaps),
|
|
|
|
) {
|
|
|
|
Some(s) => {
|
|
|
|
*othersize = s;
|
|
|
|
true
|
|
|
|
}
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_get_unit_size<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
caps: *mut gst_sys::GstCaps,
|
2018-11-20 21:40:39 +00:00
|
|
|
size: *mut usize,
|
2019-03-19 07:58:20 +00:00
|
|
|
) -> glib_sys::gboolean
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
|
|
|
match imp.get_unit_size(&wrap, &from_glib_borrow(caps)) {
|
|
|
|
Some(s) => {
|
|
|
|
*size = s;
|
|
|
|
true
|
|
|
|
}
|
|
|
|
None => false,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_sink_event<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
event: *mut gst_sys::GstEvent,
|
|
|
|
) -> glib_sys::gboolean
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
|
|
|
imp.sink_event(&wrap, from_glib_full(event))
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_src_event<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
event: *mut gst_sys::GstEvent,
|
|
|
|
) -> glib_sys::gboolean
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
|
|
|
imp.src_event(&wrap, from_glib_full(event))
|
|
|
|
})
|
|
|
|
.to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_transform<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
inbuf: *mut gst_sys::GstBuffer,
|
|
|
|
outbuf: *mut gst_sys::GstBuffer,
|
|
|
|
) -> gst_sys::GstFlowReturn
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
|
|
|
imp.transform(
|
|
|
|
&wrap,
|
|
|
|
&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()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn base_transform_transform_ip<T: ObjectSubclass>(
|
2019-03-19 07:58:20 +00:00
|
|
|
ptr: *mut gst_base_sys::GstBaseTransform,
|
|
|
|
buf: *mut *mut gst_sys::GstBuffer,
|
|
|
|
) -> gst_sys::GstFlowReturn
|
2018-11-20 21:40:39 +00:00
|
|
|
where
|
|
|
|
T: BaseTransformImpl,
|
|
|
|
T::Instance: PanicPoison,
|
|
|
|
{
|
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
|
|
|
let imp = instance.get_impl();
|
|
|
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
|
|
|
|
|
|
|
// FIXME: Wrong signature in FFI
|
2019-03-19 07:58:20 +00:00
|
|
|
let buf = buf as *mut gst_sys::GstBuffer;
|
2018-11-20 21:40:39 +00:00
|
|
|
|
|
|
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
2019-03-19 07:58:20 +00:00
|
|
|
if from_glib(gst_base_sys::gst_base_transform_is_passthrough(ptr)) {
|
2019-05-23 11:28:09 +00:00
|
|
|
imp.transform_ip_passthrough(&wrap, &from_glib_borrow(buf))
|
2019-01-08 16:13:37 +00:00
|
|
|
.into()
|
2018-11-20 21:40:39 +00:00
|
|
|
} else {
|
|
|
|
imp.transform_ip(&wrap, 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()
|
|
|
|
}
|