Commit 35353445 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

VideoOverlayComposition is supposed to be immutable

So remove the add() function and instead require an
IntoIterator<Item=&VideoOverlayRetangle> in the constructor, and require
at least one item in the iterator or return None.
parent 6d5bded7
......@@ -185,18 +185,31 @@ impl fmt::Debug for VideoOverlayCompositionRef {
}
impl VideoOverlayComposition {
pub fn new(rect: &VideoOverlayRectangle) -> Self {
unsafe { from_glib_full(ffi::gst_video_overlay_composition_new(rect.as_mut_ptr())) }
}
}
impl VideoOverlayCompositionRef {
pub fn add_rectangle(&mut self, rect: &VideoOverlayRectangle) {
pub fn new<'a, T: IntoIterator<Item = &'a VideoOverlayRectangle>>(rects: T) -> Option<Self> {
unsafe {
ffi::gst_video_overlay_composition_add_rectangle(self.as_mut_ptr(), rect.as_mut_ptr());
let mut iter = rects.into_iter();
let first = match iter.next() {
None => return None,
Some(first) => first,
};
let composition =
Self::from_glib_full(ffi::gst_video_overlay_composition_new(first.as_mut_ptr()));
for rect in iter {
ffi::gst_video_overlay_composition_add_rectangle(
composition.as_mut_ptr(),
rect.as_mut_ptr(),
);
}
Some(composition)
}
}
}
impl VideoOverlayCompositionRef {
pub fn n_rectangles(&self) -> u32 {
unsafe { ffi::gst_video_overlay_composition_n_rectangles(self.as_mut_ptr()) }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment