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