| 1 | // Take a look at the license at the top of the repository in the LICENSE file. |
| 2 | |
| 3 | use std::fmt; |
| 4 | |
| 5 | use glib::translate::*; |
| 6 | use gst::Caps; |
| 7 | |
| 8 | use crate::{ffi, AudioInfo, AudioRingBufferFormatType}; |
| 9 | |
| 10 | #[repr (transparent)] |
| 11 | #[doc (alias = "GstAudioRingBufferSpec" )] |
| 12 | pub struct AudioRingBufferSpec(pub(crate) ffi::GstAudioRingBufferSpec); |
| 13 | |
| 14 | impl AudioRingBufferSpec { |
| 15 | #[doc (alias = "get_type" )] |
| 16 | #[inline ] |
| 17 | pub fn type_(&self) -> AudioRingBufferFormatType { |
| 18 | unsafe { AudioRingBufferFormatType::from_glib(self.0.type_) } |
| 19 | } |
| 20 | |
| 21 | #[inline ] |
| 22 | pub fn set_type(&mut self, value: AudioRingBufferFormatType) { |
| 23 | self.0.type_ = value.into_glib(); |
| 24 | } |
| 25 | |
| 26 | #[doc (alias = "get_caps" )] |
| 27 | #[inline ] |
| 28 | pub fn caps(&self) -> Caps { |
| 29 | unsafe { Caps::from_glib_none(self.0.caps) } |
| 30 | } |
| 31 | |
| 32 | #[doc (alias = "get_audio_info" )] |
| 33 | #[inline ] |
| 34 | pub fn audio_info(&self) -> AudioInfo { |
| 35 | unsafe { AudioInfo::from_glib_none(&self.0.info as *const ffi::GstAudioInfo) } |
| 36 | } |
| 37 | |
| 38 | #[doc (alias = "get_latency_time" )] |
| 39 | #[inline ] |
| 40 | pub fn latency_time(&self) -> u64 { |
| 41 | self.0.latency_time |
| 42 | } |
| 43 | |
| 44 | #[inline ] |
| 45 | pub fn set_latency_time(&mut self, value: u64) { |
| 46 | self.0.latency_time = value; |
| 47 | } |
| 48 | |
| 49 | #[doc (alias = "get_buffer_time" )] |
| 50 | #[inline ] |
| 51 | pub fn buffer_time(&self) -> u64 { |
| 52 | self.0.buffer_time |
| 53 | } |
| 54 | |
| 55 | #[inline ] |
| 56 | pub fn set_buffer_time(&mut self, value: u64) { |
| 57 | self.0.buffer_time = value; |
| 58 | } |
| 59 | |
| 60 | #[doc (alias = "get_segsize" )] |
| 61 | #[inline ] |
| 62 | pub fn segsize(&self) -> i32 { |
| 63 | self.0.segsize |
| 64 | } |
| 65 | |
| 66 | #[inline ] |
| 67 | pub fn set_segsize(&mut self, value: i32) { |
| 68 | self.0.segsize = value; |
| 69 | } |
| 70 | |
| 71 | #[doc (alias = "get_segtotal" )] |
| 72 | #[inline ] |
| 73 | pub fn segtotal(&self) -> i32 { |
| 74 | self.0.segtotal |
| 75 | } |
| 76 | |
| 77 | #[inline ] |
| 78 | pub fn set_segtotal(&mut self, value: i32) { |
| 79 | self.0.segtotal = value; |
| 80 | } |
| 81 | |
| 82 | #[doc (alias = "get_seglatency" )] |
| 83 | #[inline ] |
| 84 | pub fn seglatency(&self) -> i32 { |
| 85 | self.0.seglatency |
| 86 | } |
| 87 | |
| 88 | #[inline ] |
| 89 | pub fn set_seglatency(&mut self, value: i32) { |
| 90 | self.0.seglatency = value; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | impl Clone for AudioRingBufferSpec { |
| 95 | #[inline ] |
| 96 | fn clone(&self) -> Self { |
| 97 | unsafe { |
| 98 | let spec: GstAudioRingBufferSpec = self.0; |
| 99 | gst::ffi::gst_mini_object_ref(mini_object:spec.caps as *mut gst::ffi::GstMiniObject); |
| 100 | |
| 101 | Self(spec) |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | impl Drop for AudioRingBufferSpec { |
| 107 | #[inline ] |
| 108 | fn drop(&mut self) { |
| 109 | unsafe { |
| 110 | gst::ffi::gst_mini_object_unref(self.0.caps as *mut gst::ffi::GstMiniObject); |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | unsafe impl Send for AudioRingBufferSpec {} |
| 116 | unsafe impl Sync for AudioRingBufferSpec {} |
| 117 | |
| 118 | impl fmt::Debug for AudioRingBufferSpec { |
| 119 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 120 | f&mut DebugStruct<'_, '_>.debug_struct("AudioRingBufferSpec" ) |
| 121 | .field("type" , &self.type_()) |
| 122 | .field("caps" , &self.caps()) |
| 123 | .field("audio_info" , &self.audio_info()) |
| 124 | .field("latency_time" , &self.latency_time()) |
| 125 | .field("buffer_time" , &self.buffer_time()) |
| 126 | .field("segsize" , &self.segsize()) |
| 127 | .field("segtotal" , &self.segtotal()) |
| 128 | .field(name:"seglatency" , &self.seglatency()) |
| 129 | .finish() |
| 130 | } |
| 131 | } |
| 132 | |