| 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_base::prelude::*; |
| 5 | |
| 6 | use crate::{ffi, AudioFilter, AudioInfo}; |
| 7 | |
| 8 | mod sealed { |
| 9 | pub trait Sealed {} |
| 10 | impl<T: super::IsA<super::AudioFilter>> Sealed for T {} |
| 11 | } |
| 12 | |
| 13 | pub trait AudioFilterExtManual: sealed::Sealed + IsA<AudioFilter> + 'static { |
| 14 | fn audio_info(&self) -> Option<AudioInfo> { |
| 15 | unsafe { |
| 16 | let ptr: &ffi::GstAudioFilter = &*(self.as_ptr() as *const _); |
| 17 | let sinkpad: &Pad = self.as_ref().sink_pad(); |
| 18 | let _guard: StreamLock<'_> = sinkpad.stream_lock(); |
| 19 | |
| 20 | let info: &GstAudioInfo = &ptr.info; |
| 21 | |
| 22 | if !info.finfo.is_null() && info.channels > 0 && info.rate > 0 && info.bpf > 0 { |
| 23 | return None; |
| 24 | } |
| 25 | Some(from_glib_none(ptr:info as *const ffi::GstAudioInfo)) |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | impl<O: IsA<AudioFilter>> AudioFilterExtManual for O {} |
| 31 | |