2022-08-30 14:13:45 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
|
|
|
|
|
|
|
use gst::prelude::*;
|
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use crate::{auto::AudioVisualizer, subclass::AudioVisualizerSetupToken};
|
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
mod sealed {
|
|
|
|
pub trait Sealed {}
|
|
|
|
impl<T: super::IsA<super::AudioVisualizer>> Sealed for T {}
|
2022-08-30 14:13:45 +00:00
|
|
|
}
|
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
pub trait AudioVisualizerExtManual:
|
|
|
|
sealed::Sealed + IsA<AudioVisualizer> + IsA<gst::Element> + 'static
|
|
|
|
{
|
|
|
|
// rustdoc-stripper-ignore-next
|
|
|
|
/// Returns the number of samples per frame required before calling the render method
|
2022-08-30 14:13:45 +00:00
|
|
|
fn req_spf(&self) -> u32 {
|
|
|
|
let sinkpad = self.static_pad("sink").expect("sink pad presence");
|
|
|
|
let _stream_lock = sinkpad.stream_lock();
|
|
|
|
|
|
|
|
let ptr = self.as_ptr() as *mut ffi::GstAudioVisualizer;
|
|
|
|
unsafe { (*ptr).req_spf }
|
|
|
|
}
|
|
|
|
|
2023-07-05 20:21:43 +00:00
|
|
|
// rustdoc-stripper-ignore-next
|
|
|
|
/// Modify the request of samples per frame required to be present in buffer before calling
|
|
|
|
/// the render method
|
2022-08-30 14:13:45 +00:00
|
|
|
fn set_req_spf(&self, spf: u32, token: &AudioVisualizerSetupToken) {
|
|
|
|
assert_eq!(
|
|
|
|
self.as_ptr() as *mut ffi::GstAudioVisualizer,
|
2023-08-22 07:00:35 +00:00
|
|
|
token.0.as_ptr()
|
2022-08-30 14:13:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
let sinkpad = self.static_pad("sink").expect("sink pad presence");
|
|
|
|
let _stream_lock = sinkpad.stream_lock();
|
|
|
|
|
2023-07-11 07:05:32 +00:00
|
|
|
let ptr = self.as_ptr() as *mut ffi::GstAudioVisualizer;
|
2022-08-30 14:13:45 +00:00
|
|
|
unsafe {
|
|
|
|
(*ptr).req_spf = spf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn audio_info(&self) -> gst_audio::AudioInfo {
|
|
|
|
let sinkpad = self.static_pad("sink").expect("sink pad presence");
|
|
|
|
let _stream_lock = sinkpad.stream_lock();
|
|
|
|
|
|
|
|
let ptr = self.as_ptr() as *mut ffi::GstAudioVisualizer;
|
|
|
|
unsafe {
|
|
|
|
let info = &(*ptr).ainfo;
|
|
|
|
glib::translate::from_glib_none(glib::translate::mut_override(
|
|
|
|
info as *const gst_audio::ffi::GstAudioInfo,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn video_info(&self) -> gst_video::VideoInfo {
|
|
|
|
let srcpad = self.static_pad("src").expect("src pad presence");
|
|
|
|
let _stream_lock = srcpad.stream_lock();
|
|
|
|
|
|
|
|
let ptr = self.as_ptr() as *mut ffi::GstAudioVisualizer;
|
|
|
|
unsafe {
|
|
|
|
let info = &(*ptr).vinfo;
|
|
|
|
glib::translate::from_glib_none(glib::translate::mut_override(
|
|
|
|
info as *const gst_video::ffi::GstVideoInfo,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-05 20:21:43 +00:00
|
|
|
|
|
|
|
impl<O: IsA<AudioVisualizer> + IsA<gst::Element>> AudioVisualizerExtManual for O {}
|