From 07e786b44f3eb302b79938d37a9db64d7b08282f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 23 Jun 2020 00:19:37 +0300 Subject: [PATCH] gstreamer/pad: Add support for setting proxy pad functions on a ghost pad during construction --- gstreamer/src/pad.rs | 237 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index e1d7fa0f2..7ebebf571 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -1856,6 +1856,243 @@ impl + IsA> PadBuilder { } impl + IsA> PadBuilder { + pub fn proxy_pad_activate_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>) -> Result<(), LoggableError> + Send + Sync + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_activate_function(func); + } + + self + } + + pub fn proxy_pad_activatemode_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>, ::PadMode, bool) -> Result<(), LoggableError> + + Send + + Sync + + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_activatemode_function(func); + } + + self + } + + pub fn proxy_pad_chain_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>, ::Buffer) -> Result + + Send + + Sync + + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_chain_function(func); + } + + self + } + + pub fn proxy_pad_chain_list_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>, ::BufferList) -> Result + + Send + + Sync + + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_chain_list_function(func); + } + + self + } + + pub fn proxy_pad_event_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>, ::Event) -> bool + Send + Sync + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_event_function(func); + } + + self + } + + pub fn proxy_pad_event_full_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>, ::Event) -> Result + + Send + + Sync + + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_event_full_function(func); + } + + self + } + + pub fn proxy_pad_getrange_function(self, func: F) -> Self + where + F: Fn( + &::ProxyPad, + Option<&::Object>, + u64, + Option<&mut ::BufferRef>, + u32, + ) -> Result + + Send + + Sync + + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_getrange_function(func); + } + + self + } + + pub fn proxy_pad_iterate_internal_links_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>) -> ::Iterator + Send + Sync + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_iterate_internal_links_function(func); + } + + self + } + + pub fn proxy_pad_link_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>, &Pad) -> Result<::PadLinkSuccess, ::PadLinkError> + + Send + + Sync + + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_link_function(func); + } + + self + } + + pub fn proxy_pad_query_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_query_function(func); + } + + self + } + + pub fn proxy_pad_unlink_function(self, func: F) -> Self + where + F: Fn(&::ProxyPad, Option<&::Object>) + Send + Sync + 'static, + { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_unlink_function(func); + } + + self + } + + pub fn proxy_pad_flags(self, flags: PadFlags) -> Self { + use ProxyPadExt; + + unsafe { + let proxy = self + .0 + .unsafe_cast_ref::<::ProxyPad>() + .get_internal() + .unwrap(); + proxy.set_pad_flags(flags); + } + + self + } + pub fn build_with_target>(self, target: &P) -> Result { use GhostPadExt; use PadExt;