| 1 | #[cfg (feature = "v1_18" )] |
| 2 | use std::mem::transmute; |
| 3 | |
| 4 | #[cfg (feature = "v1_18" )] |
| 5 | use glib::object::Cast; |
| 6 | #[cfg (feature = "v1_18" )] |
| 7 | use glib::signal::{connect_raw, SignalHandlerId}; |
| 8 | use glib::translate::*; |
| 9 | use gst::prelude::*; |
| 10 | |
| 11 | use crate::{ffi, AudioAggregator, AudioAggregatorPad}; |
| 12 | |
| 13 | mod sealed { |
| 14 | pub trait Sealed {} |
| 15 | impl<T: super::IsA<super::AudioAggregator>> Sealed for T {} |
| 16 | } |
| 17 | |
| 18 | pub trait AudioAggregatorExtManual: sealed::Sealed + IsA<AudioAggregator> + 'static { |
| 19 | #[doc (alias = "gst_audio_aggregator_set_sink_caps" )] |
| 20 | fn set_sink_caps(&self, pad: &impl IsA<AudioAggregatorPad>, caps: &gst::CapsRef) { |
| 21 | unsafe { |
| 22 | ffi::gst_audio_aggregator_set_sink_caps( |
| 23 | self.as_ref().to_glib_none().0, |
| 24 | pad.as_ref().to_glib_none().0, |
| 25 | caps.as_mut_ptr(), |
| 26 | ); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | #[cfg (feature = "v1_18" )] |
| 31 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_18" )))] |
| 32 | #[doc (alias = "output-buffer-duration-fraction" )] |
| 33 | fn output_buffer_duration_fraction(&self) -> gst::Fraction { |
| 34 | ObjectExt::property(self.as_ref(), "output-buffer-duration-fraction" ) |
| 35 | } |
| 36 | |
| 37 | #[cfg (feature = "v1_18" )] |
| 38 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_18" )))] |
| 39 | #[doc (alias = "output-buffer-duration-fraction" )] |
| 40 | fn set_output_buffer_duration_fraction(&self, output_buffer_duration_fraction: gst::Fraction) { |
| 41 | ObjectExt::set_property( |
| 42 | self.as_ref(), |
| 43 | "output-buffer-duration-fraction" , |
| 44 | output_buffer_duration_fraction, |
| 45 | ) |
| 46 | } |
| 47 | |
| 48 | #[cfg (feature = "v1_18" )] |
| 49 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_18" )))] |
| 50 | #[doc (alias = "output-buffer-duration-fraction" )] |
| 51 | fn connect_output_buffer_duration_fraction_notify<F: Fn(&Self) + Send + Sync + 'static>( |
| 52 | &self, |
| 53 | f: F, |
| 54 | ) -> SignalHandlerId { |
| 55 | unsafe extern "C" fn notify_output_buffer_duration_fraction_trampoline< |
| 56 | P: IsA<AudioAggregator>, |
| 57 | F: Fn(&P) + Send + Sync + 'static, |
| 58 | >( |
| 59 | this: *mut ffi::GstAudioAggregator, |
| 60 | _param_spec: glib::ffi::gpointer, |
| 61 | f: glib::ffi::gpointer, |
| 62 | ) { |
| 63 | let f: &F = &*(f as *const F); |
| 64 | f(AudioAggregator::from_glib_borrow(this).unsafe_cast_ref()) |
| 65 | } |
| 66 | unsafe { |
| 67 | let f: Box<F> = Box::new(f); |
| 68 | connect_raw( |
| 69 | self.as_ptr() as *mut _, |
| 70 | b"notify::output-buffer-duration-fraction \0" .as_ptr() as *const _, |
| 71 | Some(transmute::<*const (), unsafe extern "C" fn()>( |
| 72 | notify_output_buffer_duration_fraction_trampoline::<Self, F> as *const (), |
| 73 | )), |
| 74 | Box::into_raw(f), |
| 75 | ) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | fn current_caps(&self) -> Option<gst::Caps> { |
| 80 | unsafe { |
| 81 | let ptr = self.as_ptr() as *mut ffi::GstAudioAggregator; |
| 82 | let _guard = self.as_ref().object_lock(); |
| 83 | from_glib_none((*ptr).current_caps) |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | fn current_audio_info(&self) -> Option<crate::AudioInfo> { |
| 88 | self.current_caps() |
| 89 | .and_then(|caps| crate::AudioInfo::from_caps(&caps).ok()) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | impl<O: IsA<AudioAggregator>> AudioAggregatorExtManual for O {} |
| 94 | |