diff --git a/gstreamer/src/ghost_pad.rs b/gstreamer/src/ghost_pad.rs index a4bd78c68..22ef16170 100644 --- a/gstreamer/src/ghost_pad.rs +++ b/gstreamer/src/ghost_pad.rs @@ -16,6 +16,7 @@ use LoggableError; use Object; use Pad; use PadBuilder; +use PadExt; use PadExtManual; use PadFlags; use PadGetRangeSuccess; @@ -98,6 +99,30 @@ impl GhostPad { skip_assert_initialized!(); PadBuilder::from_template(templ, name) } + + pub fn with_target>( + name: Option<&str>, + target: &P, + ) -> Result { + skip_assert_initialized!(); + Self::builder(name, target.get_direction()).build_with_target(target) + } + + pub fn from_template_with_target>( + templ: &::PadTemplate, + name: Option<&str>, + target: &P, + ) -> Result { + skip_assert_initialized!(); + + if target.get_direction() != templ.get_property_direction() { + return Err(glib_bool_error!( + "Template and target have different directions" + )); + } + + Self::builder_with_template(templ, name).build_with_target(target) + } } impl + IsA> PadBuilder { @@ -340,7 +365,6 @@ impl + IsA> PadBuilder { pub fn build_with_target>(self, target: &P) -> Result { use GhostPadExt; - use PadExt; assert_eq!(self.0.get_direction(), target.get_direction());