| 1 | // Take a look at the license at the top of the repository in the LICENSE file. |
| 2 | |
| 3 | use glib::{prelude::*, translate::*}; |
| 4 | use gst::prelude::*; |
| 5 | use gst_base::prelude::*; |
| 6 | |
| 7 | use crate::{ffi, VideoFilter}; |
| 8 | |
| 9 | mod sealed { |
| 10 | pub trait Sealed {} |
| 11 | impl<T: super::IsA<super::VideoFilter>> Sealed for T {} |
| 12 | } |
| 13 | |
| 14 | pub trait VideoFilterExtManual: sealed::Sealed + IsA<VideoFilter> + 'static { |
| 15 | fn input_video_info(&self) -> Option<crate::VideoInfo> { |
| 16 | unsafe { |
| 17 | let ptr = self.as_ptr() as *mut ffi::GstVideoFilter; |
| 18 | let sinkpad = self.as_ref().sink_pad(); |
| 19 | let _guard = sinkpad.stream_lock(); |
| 20 | |
| 21 | let info = &(*ptr).in_info; |
| 22 | |
| 23 | if info.finfo.is_null() || info.width <= 0 || info.height <= 0 { |
| 24 | return None; |
| 25 | } |
| 26 | |
| 27 | Some(from_glib_none(mut_override( |
| 28 | info as *const ffi::GstVideoInfo, |
| 29 | ))) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | fn output_video_info(&self) -> Option<crate::VideoInfo> { |
| 34 | unsafe { |
| 35 | let ptr = self.as_ptr() as *mut ffi::GstVideoFilter; |
| 36 | let sinkpad = self.as_ref().sink_pad(); |
| 37 | let _guard = sinkpad.stream_lock(); |
| 38 | |
| 39 | let info = &(*ptr).out_info; |
| 40 | |
| 41 | if info.finfo.is_null() || info.width <= 0 || info.height <= 0 { |
| 42 | return None; |
| 43 | } |
| 44 | |
| 45 | Some(from_glib_none(mut_override( |
| 46 | info as *const ffi::GstVideoInfo, |
| 47 | ))) |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | impl<O: IsA<VideoFilter>> VideoFilterExtManual for O {} |
| 53 | |