mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 11:31:06 +00:00
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.
This commit is contained in:
parent
6d5bded7b3
commit
35353445de
1 changed files with 21 additions and 8 deletions
|
@ -185,18 +185,31 @@ impl fmt::Debug for VideoOverlayCompositionRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VideoOverlayComposition {
|
impl VideoOverlayComposition {
|
||||||
pub fn new(rect: &VideoOverlayRectangle) -> Self {
|
pub fn new<'a, T: IntoIterator<Item = &'a VideoOverlayRectangle>>(rects: T) -> Option<Self> {
|
||||||
unsafe { from_glib_full(ffi::gst_video_overlay_composition_new(rect.as_mut_ptr())) }
|
unsafe {
|
||||||
|
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 {
|
impl VideoOverlayCompositionRef {
|
||||||
pub fn add_rectangle(&mut self, rect: &VideoOverlayRectangle) {
|
|
||||||
unsafe {
|
|
||||||
ffi::gst_video_overlay_composition_add_rectangle(self.as_mut_ptr(), rect.as_mut_ptr());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn n_rectangles(&self) -> u32 {
|
pub fn n_rectangles(&self) -> u32 {
|
||||||
unsafe { ffi::gst_video_overlay_composition_n_rectangles(self.as_mut_ptr()) }
|
unsafe { ffi::gst_video_overlay_composition_n_rectangles(self.as_mut_ptr()) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue