// Copyright (C) 2017 Sebastian Dröge // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use glib::prelude::*; use glib::translate::*; use gst_sys; use FlowError; use FlowSuccess; use GhostPad; use LoggableError; use Object; use Pad; use PadBuilder; use PadExtManual; use PadFlags; use PadGetRangeSuccess; use PadMode; use StaticPadTemplate; impl GhostPad { pub fn activate_mode_default, Q: IsA>( pad: &P, parent: Option<&Q>, mode: PadMode, active: bool, ) -> Result<(), glib::BoolError> { skip_assert_initialized!(); unsafe { glib_result_from_gboolean!( gst_sys::gst_ghost_pad_activate_mode_default( pad.to_glib_none().0 as *mut gst_sys::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, mode.to_glib(), active.to_glib(), ), "Failed to invoke the default activate mode function of the ghost pad" ) } } pub fn internal_activate_mode_default, Q: IsA>( pad: &P, parent: Option<&Q>, mode: PadMode, active: bool, ) -> Result<(), glib::BoolError> { skip_assert_initialized!(); unsafe { glib_result_from_gboolean!( gst_sys::gst_ghost_pad_internal_activate_mode_default( pad.to_glib_none().0 as *mut gst_sys::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, mode.to_glib(), active.to_glib(), ), concat!( "Failed to invoke the default activate mode function of a proxy pad ", "that is owned by the ghost pad" ) ) } } pub fn new(name: Option<&str>, direction: ::PadDirection) -> Self { skip_assert_initialized!(); Self::builder(name, direction).build() } pub fn builder(name: Option<&str>, direction: ::PadDirection) -> PadBuilder { 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 { skip_assert_initialized!(); PadBuilder::from_static_template(templ, name) } pub fn from_template(templ: &::PadTemplate, name: Option<&str>) -> Self { skip_assert_initialized!(); Self::builder_with_template(templ, name).build() } pub fn builder_with_template(templ: &::PadTemplate, name: Option<&str>) -> PadBuilder { skip_assert_initialized!(); PadBuilder::from_template(templ, name) } } 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; assert_eq!(self.0.get_direction(), target.get_direction()); self.0.set_target(Some(target))?; Ok(self.0) } }