examples: glupload: Fix iterating over elements inside glsinkbin

Some elements might not have a factory so handle this gracefully instead
of erroring out.
This commit is contained in:
Sebastian Dröge 2022-10-24 16:47:52 +03:00
parent f440534c6d
commit b67887c8dd

View file

@ -566,11 +566,11 @@ impl App {
src.link(&sink)?; src.link(&sink)?;
// get the glupload element to extract later the used context in it // get the glupload element to extract later the used context in it
let mut iter = sink.dynamic_cast::<gst::Bin>().unwrap().iterate_elements(); let mut iter = sink.downcast_ref::<gst::Bin>().unwrap().iterate_elements();
let glupload = loop { let glupload = loop {
match iter.next() { match iter.next() {
Ok(Some(element)) => { Ok(Some(element)) => {
if "glupload" == element.factory().unwrap().name() { if element.factory().map_or(false, |f| f.name() == "glupload") {
break Some(element); break Some(element);
} }
} }