1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use glib::translate::*;
use gst::prelude::*;

use crate::{ffi, VideoAggregator};

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::VideoAggregator>> Sealed for T {}
}

pub trait VideoAggregatorExtManual: sealed::Sealed + IsA<VideoAggregator> + 'static {
    fn video_info(&self) -> Option<crate::VideoInfo> {
        unsafe {
            let ptr = self.as_ptr() as *mut ffi::GstVideoAggregator;
            let _guard = self.as_ref().object_lock();

            let info = &(*ptr).info;

            if info.finfo.is_null() || info.width <= 0 || info.height <= 0 {
                return None;
            }

            Some(from_glib_none(mut_override(
                info as *const ffi::GstVideoInfo,
            )))
        }
    }
}

impl<O: IsA<VideoAggregator>> VideoAggregatorExtManual for O {}