forked from mirrors/gstreamer-rs
Add BinExtManual::get_children() that returns a Vec<Element>
This is sometimes more convenient than using the iterator.
This commit is contained in:
parent
20729497a2
commit
95317267ec
1 changed files with 11 additions and 1 deletions
|
@ -11,7 +11,7 @@ use Element;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::IsA;
|
use glib::IsA;
|
||||||
use glib::translate::{from_glib, from_glib_full, ToGlib, ToGlibPtr};
|
use glib::translate::{from_glib, from_glib_full, FromGlibPtrContainer, ToGlib, ToGlibPtr};
|
||||||
|
|
||||||
use ffi;
|
use ffi;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ pub trait BinExtManual {
|
||||||
fn iterate_sinks(&self) -> ::Iterator<Element>;
|
fn iterate_sinks(&self) -> ::Iterator<Element>;
|
||||||
fn iterate_sorted(&self) -> ::Iterator<Element>;
|
fn iterate_sorted(&self) -> ::Iterator<Element>;
|
||||||
fn iterate_sources(&self) -> ::Iterator<Element>;
|
fn iterate_sources(&self) -> ::Iterator<Element>;
|
||||||
|
fn get_children(&self) -> Vec<Element>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<O: IsA<Bin>> BinExtManual for O {
|
impl<O: IsA<Bin>> BinExtManual for O {
|
||||||
|
@ -86,4 +87,13 @@ impl<O: IsA<Bin>> BinExtManual for O {
|
||||||
fn iterate_sources(&self) -> ::Iterator<Element> {
|
fn iterate_sources(&self) -> ::Iterator<Element> {
|
||||||
unsafe { from_glib_full(ffi::gst_bin_iterate_sources(self.to_glib_none().0)) }
|
unsafe { from_glib_full(ffi::gst_bin_iterate_sources(self.to_glib_none().0)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_children(&self) -> Vec<Element> {
|
||||||
|
unsafe {
|
||||||
|
let stash = self.to_glib_none();
|
||||||
|
let bin: &ffi::GstBin = &*stash.0;
|
||||||
|
::utils::MutexGuard::lock(&bin.element.object.lock);
|
||||||
|
FromGlibPtrContainer::from_glib_none(bin.children)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue