2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use std::fmt;
|
|
|
|
|
2019-12-13 13:09:30 +00:00
|
|
|
use glib::translate::*;
|
|
|
|
use gst::Caps;
|
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use crate::{ffi::GstAudioRingBufferSpec, AudioInfo, AudioRingBufferFormatType};
|
2019-12-18 13:35:24 +00:00
|
|
|
|
2020-10-24 17:06:59 +00:00
|
|
|
#[repr(transparent)]
|
2019-12-13 13:09:30 +00:00
|
|
|
pub struct AudioRingBufferSpec(pub(crate) GstAudioRingBufferSpec);
|
|
|
|
|
|
|
|
impl AudioRingBufferSpec {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_type")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn type_(&self) -> AudioRingBufferFormatType {
|
2020-12-08 14:07:12 +00:00
|
|
|
unsafe { AudioRingBufferFormatType::from_glib(self.0.type_) }
|
2019-12-13 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2019-12-13 13:09:30 +00:00
|
|
|
pub fn set_type(&mut self, value: AudioRingBufferFormatType) {
|
2021-04-27 15:15:46 +00:00
|
|
|
self.0.type_ = value.into_glib();
|
2019-12-13 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_caps")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn caps(&self) -> Caps {
|
2019-12-13 13:09:30 +00:00
|
|
|
unsafe { Caps::from_glib_none(self.0.caps) }
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_audio_info")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn audio_info(&self) -> AudioInfo {
|
2023-11-29 09:24:47 +00:00
|
|
|
unsafe { AudioInfo::from_glib_none(&self.0.info as *const ffi::GstAudioInfo) }
|
2019-12-13 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_latency_time")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn latency_time(&self) -> u64 {
|
2019-12-13 13:09:30 +00:00
|
|
|
self.0.latency_time
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2019-12-13 13:09:30 +00:00
|
|
|
pub fn set_latency_time(&mut self, value: u64) {
|
|
|
|
self.0.latency_time = value;
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_buffer_time")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn buffer_time(&self) -> u64 {
|
2019-12-13 13:09:30 +00:00
|
|
|
self.0.buffer_time
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2019-12-13 13:09:30 +00:00
|
|
|
pub fn set_buffer_time(&mut self, value: u64) {
|
|
|
|
self.0.buffer_time = value;
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_segsize")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn segsize(&self) -> i32 {
|
2019-12-13 13:09:30 +00:00
|
|
|
self.0.segsize
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2019-12-13 13:09:30 +00:00
|
|
|
pub fn set_segsize(&mut self, value: i32) {
|
|
|
|
self.0.segsize = value;
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_segtotal")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn segtotal(&self) -> i32 {
|
2019-12-13 13:09:30 +00:00
|
|
|
self.0.segtotal
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2019-12-13 13:09:30 +00:00
|
|
|
pub fn set_segtotal(&mut self, value: i32) {
|
|
|
|
self.0.segtotal = value;
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_seglatency")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn seglatency(&self) -> i32 {
|
2019-12-13 13:09:30 +00:00
|
|
|
self.0.seglatency
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2019-12-13 13:09:30 +00:00
|
|
|
pub fn set_seglatency(&mut self, value: i32) {
|
|
|
|
self.0.seglatency = value;
|
|
|
|
}
|
|
|
|
}
|
2019-12-18 13:35:24 +00:00
|
|
|
|
|
|
|
impl Clone for AudioRingBufferSpec {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2019-12-18 13:35:24 +00:00
|
|
|
fn clone(&self) -> Self {
|
|
|
|
unsafe {
|
|
|
|
let spec = self.0;
|
2020-11-21 18:17:20 +00:00
|
|
|
gst::ffi::gst_mini_object_ref(spec.caps as *mut gst::ffi::GstMiniObject);
|
2019-12-18 13:35:24 +00:00
|
|
|
|
2021-04-29 20:49:26 +00:00
|
|
|
Self(spec)
|
2019-12-18 13:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for AudioRingBufferSpec {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2019-12-18 13:35:24 +00:00
|
|
|
fn drop(&mut self) {
|
|
|
|
unsafe {
|
2020-11-21 18:17:20 +00:00
|
|
|
gst::ffi::gst_mini_object_unref(self.0.caps as *mut gst::ffi::GstMiniObject);
|
2019-12-18 13:35:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-18 15:04:42 +00:00
|
|
|
unsafe impl Send for AudioRingBufferSpec {}
|
|
|
|
unsafe impl Sync for AudioRingBufferSpec {}
|
|
|
|
|
2019-12-18 13:35:24 +00:00
|
|
|
impl fmt::Debug for AudioRingBufferSpec {
|
2020-11-28 11:33:46 +00:00
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
2019-12-18 13:35:24 +00:00
|
|
|
f.debug_struct("AudioRingBufferSpec")
|
2021-04-11 19:39:50 +00:00
|
|
|
.field("type", &self.type_())
|
|
|
|
.field("caps", &self.caps())
|
|
|
|
.field("audio_info", &self.audio_info())
|
|
|
|
.field("latency_time", &self.latency_time())
|
|
|
|
.field("buffer_time", &self.buffer_time())
|
|
|
|
.field("segsize", &self.segsize())
|
|
|
|
.field("segtotal", &self.segtotal())
|
|
|
|
.field("seglatency", &self.seglatency())
|
2019-12-18 13:35:24 +00:00
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|