gstreamer_audio/auto/audio_stream_align.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::translate::*;
8
9glib::wrapper! {
10 /// [`AudioStreamAlign`][crate::AudioStreamAlign] provides a helper object that helps tracking audio
11 /// stream alignment and discontinuities, and detects discontinuities if
12 /// possible.
13 ///
14 /// See [`new()`][Self::new()] for a description of its parameters and
15 /// [`process()`][Self::process()] for the details of the processing.
16 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
17 pub struct AudioStreamAlign(Boxed<ffi::GstAudioStreamAlign>);
18
19 match fn {
20 copy => |ptr| ffi::gst_audio_stream_align_copy(ptr),
21 free => |ptr| ffi::gst_audio_stream_align_free(ptr),
22 type_ => || ffi::gst_audio_stream_align_get_type(),
23 }
24}
25
26impl AudioStreamAlign {
27 /// Allocate a new [`AudioStreamAlign`][crate::AudioStreamAlign] with the given configuration. All
28 /// processing happens according to sample rate `rate`, until
29 /// [`set_rate()`][Self::set_rate()] is called with a new `rate`.
30 /// A negative rate can be used for reverse playback.
31 ///
32 /// `alignment_threshold` gives the tolerance in nanoseconds after which a
33 /// timestamp difference is considered a discontinuity. Once detected,
34 /// `discont_wait` nanoseconds have to pass without going below the threshold
35 /// again until the output buffer is marked as a discontinuity. These can later
36 /// be re-configured with [`set_alignment_threshold()`][Self::set_alignment_threshold()] and
37 /// [`set_discont_wait()`][Self::set_discont_wait()].
38 /// ## `rate`
39 /// a sample rate
40 /// ## `alignment_threshold`
41 /// a alignment threshold in nanoseconds
42 /// ## `discont_wait`
43 /// discont wait in nanoseconds
44 ///
45 /// # Returns
46 ///
47 /// a new [`AudioStreamAlign`][crate::AudioStreamAlign]. free with `gst_audio_stream_align_free()`.
48 #[doc(alias = "gst_audio_stream_align_new")]
49 pub fn new(
50 rate: i32,
51 alignment_threshold: gst::ClockTime,
52 discont_wait: gst::ClockTime,
53 ) -> AudioStreamAlign {
54 assert_initialized_main_thread!();
55 unsafe {
56 from_glib_full(ffi::gst_audio_stream_align_new(
57 rate,
58 alignment_threshold.into_glib(),
59 discont_wait.into_glib(),
60 ))
61 }
62 }
63
64 /// Gets the currently configured alignment threshold.
65 ///
66 /// # Returns
67 ///
68 /// The currently configured alignment threshold
69 #[doc(alias = "gst_audio_stream_align_get_alignment_threshold")]
70 #[doc(alias = "get_alignment_threshold")]
71 pub fn alignment_threshold(&self) -> gst::ClockTime {
72 unsafe {
73 try_from_glib(ffi::gst_audio_stream_align_get_alignment_threshold(
74 self.to_glib_none().0,
75 ))
76 .expect("mandatory glib value is None")
77 }
78 }
79
80 /// Gets the currently configured discont wait.
81 ///
82 /// # Returns
83 ///
84 /// The currently configured discont wait
85 #[doc(alias = "gst_audio_stream_align_get_discont_wait")]
86 #[doc(alias = "get_discont_wait")]
87 pub fn discont_wait(&self) -> gst::ClockTime {
88 unsafe {
89 try_from_glib(ffi::gst_audio_stream_align_get_discont_wait(
90 self.to_glib_none().0,
91 ))
92 .expect("mandatory glib value is None")
93 }
94 }
95
96 /// Gets the currently configured sample rate.
97 ///
98 /// # Returns
99 ///
100 /// The currently configured sample rate
101 #[doc(alias = "gst_audio_stream_align_get_rate")]
102 #[doc(alias = "get_rate")]
103 pub fn rate(&self) -> i32 {
104 unsafe { ffi::gst_audio_stream_align_get_rate(self.to_glib_none().0) }
105 }
106
107 /// Returns the number of samples that were processed since the last
108 /// discontinuity was detected.
109 ///
110 /// # Returns
111 ///
112 /// The number of samples processed since the last discontinuity.
113 #[doc(alias = "gst_audio_stream_align_get_samples_since_discont")]
114 #[doc(alias = "get_samples_since_discont")]
115 pub fn samples_since_discont(&self) -> u64 {
116 unsafe { ffi::gst_audio_stream_align_get_samples_since_discont(self.to_glib_none().0) }
117 }
118
119 /// Timestamp that was passed when a discontinuity was detected, i.e. the first
120 /// timestamp after the discontinuity.
121 ///
122 /// # Returns
123 ///
124 /// The last timestamp at when a discontinuity was detected
125 #[doc(alias = "gst_audio_stream_align_get_timestamp_at_discont")]
126 #[doc(alias = "get_timestamp_at_discont")]
127 pub fn timestamp_at_discont(&self) -> Option<gst::ClockTime> {
128 unsafe {
129 from_glib(ffi::gst_audio_stream_align_get_timestamp_at_discont(
130 self.to_glib_none().0,
131 ))
132 }
133 }
134
135 /// Marks the next buffer as discontinuous and resets timestamp tracking.
136 #[doc(alias = "gst_audio_stream_align_mark_discont")]
137 pub fn mark_discont(&mut self) {
138 unsafe {
139 ffi::gst_audio_stream_align_mark_discont(self.to_glib_none_mut().0);
140 }
141 }
142
143 /// Sets `alignment_treshold` as new alignment threshold for the following processing.
144 /// ## `alignment_threshold`
145 /// a new alignment threshold
146 #[doc(alias = "gst_audio_stream_align_set_alignment_threshold")]
147 pub fn set_alignment_threshold(&mut self, alignment_threshold: gst::ClockTime) {
148 unsafe {
149 ffi::gst_audio_stream_align_set_alignment_threshold(
150 self.to_glib_none_mut().0,
151 alignment_threshold.into_glib(),
152 );
153 }
154 }
155
156 /// Sets `alignment_treshold` as new discont wait for the following processing.
157 /// ## `discont_wait`
158 /// a new discont wait
159 #[doc(alias = "gst_audio_stream_align_set_discont_wait")]
160 pub fn set_discont_wait(&mut self, discont_wait: gst::ClockTime) {
161 unsafe {
162 ffi::gst_audio_stream_align_set_discont_wait(
163 self.to_glib_none_mut().0,
164 discont_wait.into_glib(),
165 );
166 }
167 }
168
169 /// Sets `rate` as new sample rate for the following processing. If the sample
170 /// rate differs this implicitly marks the next data as discontinuous.
171 /// ## `rate`
172 /// a new sample rate
173 #[doc(alias = "gst_audio_stream_align_set_rate")]
174 pub fn set_rate(&mut self, rate: i32) {
175 unsafe {
176 ffi::gst_audio_stream_align_set_rate(self.to_glib_none_mut().0, rate);
177 }
178 }
179}
180
181unsafe impl Send for AudioStreamAlign {}
182unsafe impl Sync for AudioStreamAlign {}