mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-15 22:11:01 +00:00
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
|
use Bin;
|
||
|
use Element;
|
||
|
|
||
|
use glib;
|
||
|
use glib::IsA;
|
||
|
use glib::translate::{ToGlibPtr, from_glib};
|
||
|
|
||
|
use ffi;
|
||
|
|
||
|
pub trait BinExtManual {
|
||
|
fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError>;
|
||
|
fn remove_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError>;
|
||
|
}
|
||
|
|
||
|
impl<O: IsA<Bin>> BinExtManual for O {
|
||
|
fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
|
||
|
for e in elements {
|
||
|
unsafe {
|
||
|
let ret: bool = from_glib(ffi::gst_bin_add(self.to_glib_none().0, e.to_glib_none().0));
|
||
|
if !ret {
|
||
|
return Err(glib::BoolError("Failed to add elements"));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return Ok(());
|
||
|
}
|
||
|
|
||
|
fn remove_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
|
||
|
for e in elements {
|
||
|
unsafe {
|
||
|
let ret: bool = from_glib(ffi::gst_bin_remove(self.to_glib_none().0, e.to_glib_none().0));
|
||
|
if !ret {
|
||
|
return Err(glib::BoolError("Failed to add elements"));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return Ok(());
|
||
|
}
|
||
|
}
|