2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2017-07-29 13:19:15 +00:00
|
|
|
|
2021-04-25 18:40:13 +00:00
|
|
|
use crate::prelude::*;
|
2020-11-21 13:46:48 +00:00
|
|
|
use crate::FlowError;
|
|
|
|
use crate::FlowSuccess;
|
|
|
|
use crate::GhostPad;
|
|
|
|
use crate::LoggableError;
|
|
|
|
use crate::Object;
|
|
|
|
use crate::Pad;
|
|
|
|
use crate::PadBuilder;
|
|
|
|
use crate::PadFlags;
|
|
|
|
use crate::PadGetRangeSuccess;
|
|
|
|
use crate::PadMode;
|
|
|
|
use crate::StaticPadTemplate;
|
2018-04-25 08:10:06 +00:00
|
|
|
use glib::translate::*;
|
2017-07-29 13:19:15 +00:00
|
|
|
|
|
|
|
impl GhostPad {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_ghost_pad_activate_mode_default")]
|
2019-05-23 18:19:24 +00:00
|
|
|
pub fn activate_mode_default<P: IsA<GhostPad>, Q: IsA<Object>>(
|
2017-12-17 09:24:03 +00:00
|
|
|
pad: &P,
|
2019-05-23 18:19:24 +00:00
|
|
|
parent: Option<&Q>,
|
2017-12-17 09:24:03 +00:00
|
|
|
mode: PadMode,
|
|
|
|
active: bool,
|
2019-01-16 20:23:56 +00:00
|
|
|
) -> Result<(), glib::BoolError> {
|
2017-12-17 09:24:03 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
unsafe {
|
2020-12-17 22:38:06 +00:00
|
|
|
glib::result_from_gboolean!(
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_ghost_pad_activate_mode_default(
|
|
|
|
pad.to_glib_none().0 as *mut ffi::GstPad,
|
2019-01-16 20:23:56 +00:00
|
|
|
parent.map(|p| p.as_ref()).to_glib_none().0,
|
2021-04-27 15:15:46 +00:00
|
|
|
mode.into_glib(),
|
|
|
|
active.into_glib(),
|
2019-01-16 20:23:56 +00:00
|
|
|
),
|
|
|
|
"Failed to invoke the default activate mode function of the ghost pad"
|
|
|
|
)
|
2017-12-17 09:24:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_ghost_pad_internal_activate_mode_default")]
|
2019-05-23 18:19:24 +00:00
|
|
|
pub fn internal_activate_mode_default<P: IsA<GhostPad>, Q: IsA<Object>>(
|
2017-12-17 09:24:03 +00:00
|
|
|
pad: &P,
|
2019-05-23 18:19:24 +00:00
|
|
|
parent: Option<&Q>,
|
2017-12-17 09:24:03 +00:00
|
|
|
mode: PadMode,
|
|
|
|
active: bool,
|
2019-01-16 20:23:56 +00:00
|
|
|
) -> Result<(), glib::BoolError> {
|
2017-12-17 09:24:03 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
unsafe {
|
2020-12-17 22:38:06 +00:00
|
|
|
glib::result_from_gboolean!(
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_ghost_pad_internal_activate_mode_default(
|
|
|
|
pad.to_glib_none().0 as *mut ffi::GstPad,
|
2019-01-16 20:23:56 +00:00
|
|
|
parent.map(|p| p.as_ref()).to_glib_none().0,
|
2021-04-27 15:15:46 +00:00
|
|
|
mode.into_glib(),
|
|
|
|
active.into_glib(),
|
2019-01-16 20:23:56 +00:00
|
|
|
),
|
|
|
|
concat!(
|
|
|
|
"Failed to invoke the default activate mode function of a proxy pad ",
|
|
|
|
"that is owned by the ghost pad"
|
|
|
|
)
|
|
|
|
)
|
2017-12-17 09:24:03 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-10 12:04:23 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(name: Option<&str>, direction: crate::PadDirection) -> Self {
|
2020-07-10 12:04:23 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(name, direction).build()
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn builder(name: Option<&str>, direction: crate::PadDirection) -> PadBuilder<Self> {
|
2020-07-10 12:04:23 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
PadBuilder::new(name, direction)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_static_template(templ: &StaticPadTemplate, name: Option<&str>) -> Self {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder_with_static_template(templ, name).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder_with_static_template(
|
|
|
|
templ: &StaticPadTemplate,
|
|
|
|
name: Option<&str>,
|
|
|
|
) -> PadBuilder<Self> {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
PadBuilder::from_static_template(templ, name)
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn from_template(templ: &crate::PadTemplate, name: Option<&str>) -> Self {
|
2020-07-10 12:04:23 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder_with_template(templ, name).build()
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn builder_with_template(
|
|
|
|
templ: &crate::PadTemplate,
|
|
|
|
name: Option<&str>,
|
|
|
|
) -> PadBuilder<Self> {
|
2020-07-10 12:04:23 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
PadBuilder::from_template(templ, name)
|
|
|
|
}
|
2020-07-10 12:10:42 +00:00
|
|
|
|
|
|
|
pub fn with_target<P: IsA<Pad>>(
|
|
|
|
name: Option<&str>,
|
|
|
|
target: &P,
|
|
|
|
) -> Result<Self, glib::BoolError> {
|
|
|
|
skip_assert_initialized!();
|
2021-04-11 19:39:50 +00:00
|
|
|
Self::builder(name, target.direction()).build_with_target(target)
|
2020-07-10 12:10:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_template_with_target<P: IsA<Pad>>(
|
2020-11-21 13:46:48 +00:00
|
|
|
templ: &crate::PadTemplate,
|
2020-07-10 12:10:42 +00:00
|
|
|
name: Option<&str>,
|
|
|
|
target: &P,
|
|
|
|
) -> Result<Self, glib::BoolError> {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
|
2021-04-12 10:01:22 +00:00
|
|
|
if target.direction() != templ.direction() {
|
2020-12-17 22:38:06 +00:00
|
|
|
return Err(glib::bool_error!(
|
2020-07-10 12:10:42 +00:00
|
|
|
"Template and target have different directions"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
Self::builder_with_template(templ, name).build_with_target(target)
|
|
|
|
}
|
2020-07-10 12:04:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
|
|
|
|
pub fn proxy_pad_activate_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(&crate::ProxyPad, Option<&crate::Object>) -> Result<(), LoggableError>
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
2020-07-10 12:04:23 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_activate_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_activatemode_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(
|
|
|
|
&crate::ProxyPad,
|
|
|
|
Option<&crate::Object>,
|
|
|
|
crate::PadMode,
|
|
|
|
bool,
|
|
|
|
) -> Result<(), LoggableError>
|
2020-07-10 12:04:23 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_activatemode_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_chain_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(
|
|
|
|
&crate::ProxyPad,
|
|
|
|
Option<&crate::Object>,
|
|
|
|
crate::Buffer,
|
|
|
|
) -> Result<FlowSuccess, FlowError>
|
2020-07-10 12:04:23 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_chain_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_chain_list_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(
|
|
|
|
&crate::ProxyPad,
|
|
|
|
Option<&crate::Object>,
|
|
|
|
crate::BufferList,
|
|
|
|
) -> Result<FlowSuccess, FlowError>
|
2020-07-10 12:04:23 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_chain_list_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_event_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(&crate::ProxyPad, Option<&crate::Object>, crate::Event) -> bool
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
2020-07-10 12:04:23 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_event_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_event_full_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(
|
|
|
|
&crate::ProxyPad,
|
|
|
|
Option<&crate::Object>,
|
|
|
|
crate::Event,
|
|
|
|
) -> Result<FlowSuccess, FlowError>
|
2020-07-10 12:04:23 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_event_full_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_getrange_function<F>(self, func: F) -> Self
|
|
|
|
where
|
|
|
|
F: Fn(
|
2020-11-21 13:46:48 +00:00
|
|
|
&crate::ProxyPad,
|
|
|
|
Option<&crate::Object>,
|
2020-07-10 12:04:23 +00:00
|
|
|
u64,
|
2020-11-21 13:46:48 +00:00
|
|
|
Option<&mut crate::BufferRef>,
|
2020-07-10 12:04:23 +00:00
|
|
|
u32,
|
2020-11-21 13:46:48 +00:00
|
|
|
) -> Result<PadGetRangeSuccess, crate::FlowError>
|
2020-07-10 12:04:23 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_getrange_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_iterate_internal_links_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(&crate::ProxyPad, Option<&crate::Object>) -> crate::Iterator<Pad>
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
2020-07-10 12:04:23 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_iterate_internal_links_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_link_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(
|
|
|
|
&crate::ProxyPad,
|
|
|
|
Option<&crate::Object>,
|
|
|
|
&Pad,
|
|
|
|
) -> Result<crate::PadLinkSuccess, crate::PadLinkError>
|
2020-07-10 12:04:23 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_link_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_query_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(&crate::ProxyPad, Option<&crate::Object>, &mut crate::QueryRef) -> bool
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
2020-07-10 12:04:23 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_query_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_unlink_function<F>(self, func: F) -> Self
|
|
|
|
where
|
2020-11-21 13:46:48 +00:00
|
|
|
F: Fn(&crate::ProxyPad, Option<&crate::Object>) + Send + Sync + 'static,
|
2020-07-10 12:04:23 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_unlink_function(func);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn proxy_pad_flags(self, flags: PadFlags) -> Self {
|
|
|
|
unsafe {
|
|
|
|
let proxy = self
|
|
|
|
.0
|
2020-11-21 13:46:48 +00:00
|
|
|
.unsafe_cast_ref::<crate::ProxyPad>()
|
2021-04-11 19:39:50 +00:00
|
|
|
.internal()
|
2020-07-10 12:04:23 +00:00
|
|
|
.unwrap();
|
|
|
|
proxy.set_pad_flags(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn build_with_target<P: IsA<Pad>>(self, target: &P) -> Result<T, glib::BoolError> {
|
2021-04-11 19:39:50 +00:00
|
|
|
assert_eq!(self.0.direction(), target.direction());
|
2020-07-10 12:04:23 +00:00
|
|
|
|
|
|
|
self.0.set_target(Some(target))?;
|
|
|
|
|
|
|
|
Ok(self.0)
|
|
|
|
}
|
2017-07-29 13:19:15 +00:00
|
|
|
}
|