mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 11:31:06 +00:00
gstreamer/ghost_pad: Add convenience constructors with target pad
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/275
This commit is contained in:
parent
af15dafc14
commit
7517a50834
1 changed files with 25 additions and 1 deletions
|
@ -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<P: IsA<Pad>>(
|
||||
name: Option<&str>,
|
||||
target: &P,
|
||||
) -> Result<Self, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
Self::builder(name, target.get_direction()).build_with_target(target)
|
||||
}
|
||||
|
||||
pub fn from_template_with_target<P: IsA<Pad>>(
|
||||
templ: &::PadTemplate,
|
||||
name: Option<&str>,
|
||||
target: &P,
|
||||
) -> Result<Self, glib::BoolError> {
|
||||
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<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
|
||||
|
@ -340,7 +365,6 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
|
|||
|
||||
pub fn build_with_target<P: IsA<Pad>>(self, target: &P) -> Result<T, glib::BoolError> {
|
||||
use GhostPadExt;
|
||||
use PadExt;
|
||||
|
||||
assert_eq!(self.0.get_direction(), target.get_direction());
|
||||
|
||||
|
|
Loading…
Reference in a new issue