diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index 6606d8c97..0eef0c216 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -204,6 +204,21 @@ impl std::iter::FromIterator<(Structure, Option)> for Caps { } } +impl std::iter::FromIterator for Caps { + fn from_iter>(iter: T) -> Self { + assert_initialized_main_thread!(); + let mut caps = Caps::new_empty(); + + { + let caps = caps.get_mut().unwrap(); + iter.into_iter() + .for_each(|other_caps| caps.append(other_caps)); + } + + caps + } +} + impl std::iter::Extend for CapsRef { fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|s| self.append_structure(s)); @@ -224,6 +239,12 @@ impl std::iter::Extend<(Structure, Option)> for CapsRef { } } +impl std::iter::Extend for CapsRef { + fn extend>(&mut self, iter: T) { + iter.into_iter().for_each(|caps| self.append(caps)); + } +} + impl CapsRef { #[doc(alias = "gst_caps_set_simple")] pub fn set_simple(&mut self, values: &[(&str, &(dyn ToSendValue + Sync))]) {