gstreamer_audio/auto/
audio_base_src.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::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// This is the base class for audio sources. Subclasses need to implement the
16    /// ::create_ringbuffer vmethod. This base class will then take care of
17    /// reading samples from the ringbuffer, synchronisation and flushing.
18    ///
19    /// ## Properties
20    ///
21    ///
22    /// #### `actual-buffer-time`
23    ///  Actual configured size of audio buffer in microseconds.
24    ///
25    /// Readable
26    ///
27    ///
28    /// #### `actual-latency-time`
29    ///  Actual configured audio latency in microseconds.
30    ///
31    /// Readable
32    ///
33    ///
34    /// #### `buffer-time`
35    ///  Readable | Writeable
36    ///
37    ///
38    /// #### `latency-time`
39    ///  Readable | Writeable
40    ///
41    ///
42    /// #### `provide-clock`
43    ///  Readable | Writeable
44    ///
45    ///
46    /// #### `slave-method`
47    ///  Readable | Writeable
48    /// <details><summary><h4>BaseSrc</h4></summary>
49    ///
50    ///
51    /// #### `automatic-eos`
52    ///  See [`BaseSrcExtManual::set_automatic_eos()`][crate::gst_base::prelude::BaseSrcExtManual::set_automatic_eos()]
53    ///
54    /// Readable | Writeable
55    ///
56    ///
57    /// #### `blocksize`
58    ///  Readable | Writeable
59    ///
60    ///
61    /// #### `do-timestamp`
62    ///  Readable | Writeable
63    ///
64    ///
65    /// #### `num-buffers`
66    ///  Readable | Writeable
67    ///
68    ///
69    /// #### `typefind`
70    ///  Readable | Writeable
71    /// </details>
72    /// <details><summary><h4>Object</h4></summary>
73    ///
74    ///
75    /// #### `name`
76    ///  Readable | Writeable | Construct
77    ///
78    ///
79    /// #### `parent`
80    ///  The parent of the object. Please note, that when changing the 'parent'
81    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
82    /// signals due to locking issues. In some cases one can use
83    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
84    /// achieve a similar effect.
85    ///
86    /// Readable | Writeable
87    /// </details>
88    ///
89    /// # Implements
90    ///
91    /// [`AudioBaseSrcExt`][trait@crate::prelude::AudioBaseSrcExt], [`trait@gst_base::prelude::BaseSrcExt`], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::GstObjectExt`], [`trait@glib::ObjectExt`]
92    #[doc(alias = "GstAudioBaseSrc")]
93    pub struct AudioBaseSrc(Object<ffi::GstAudioBaseSrc, ffi::GstAudioBaseSrcClass>) @extends gst_base::BaseSrc, gst::Element, gst::Object;
94
95    match fn {
96        type_ => || ffi::gst_audio_base_src_get_type(),
97    }
98}
99
100impl AudioBaseSrc {
101    pub const NONE: Option<&'static AudioBaseSrc> = None;
102}
103
104unsafe impl Send for AudioBaseSrc {}
105unsafe impl Sync for AudioBaseSrc {}
106
107/// Trait containing all [`struct@AudioBaseSrc`] methods.
108///
109/// # Implementors
110///
111/// [`AudioBaseSrc`][struct@crate::AudioBaseSrc], [`AudioSrc`][struct@crate::AudioSrc]
112pub trait AudioBaseSrcExt: IsA<AudioBaseSrc> + 'static {
113    //#[doc(alias = "gst_audio_base_src_create_ringbuffer")]
114    //fn create_ringbuffer(&self) -> /*Ignored*/Option<AudioRingBuffer> {
115    //    unsafe { TODO: call ffi:gst_audio_base_src_create_ringbuffer() }
116    //}
117
118    /// Queries whether `self` will provide a clock or not. See also
119    /// gst_audio_base_src_set_provide_clock.
120    ///
121    /// # Returns
122    ///
123    /// [`true`] if `self` will provide a clock.
124    #[doc(alias = "gst_audio_base_src_get_provide_clock")]
125    #[doc(alias = "get_provide_clock")]
126    #[doc(alias = "provide-clock")]
127    fn is_provide_clock(&self) -> bool {
128        unsafe {
129            from_glib(ffi::gst_audio_base_src_get_provide_clock(
130                self.as_ref().to_glib_none().0,
131            ))
132        }
133    }
134
135    //#[doc(alias = "gst_audio_base_src_get_slave_method")]
136    //#[doc(alias = "get_slave_method")]
137    //#[doc(alias = "slave-method")]
138    //fn slave_method(&self) -> /*Ignored*/AudioBaseSrcSlaveMethod {
139    //    unsafe { TODO: call ffi:gst_audio_base_src_get_slave_method() }
140    //}
141
142    /// Controls whether `self` will provide a clock or not. If `provide` is [`true`],
143    /// [`ElementExtManual::provide_clock()`][crate::gst::prelude::ElementExtManual::provide_clock()] will return a clock that reflects the datarate
144    /// of `self`. If `provide` is [`false`], [`ElementExtManual::provide_clock()`][crate::gst::prelude::ElementExtManual::provide_clock()] will return NULL.
145    /// ## `provide`
146    /// new state
147    #[doc(alias = "gst_audio_base_src_set_provide_clock")]
148    #[doc(alias = "provide-clock")]
149    fn set_provide_clock(&self, provide: bool) {
150        unsafe {
151            ffi::gst_audio_base_src_set_provide_clock(
152                self.as_ref().to_glib_none().0,
153                provide.into_glib(),
154            );
155        }
156    }
157
158    //#[doc(alias = "gst_audio_base_src_set_slave_method")]
159    //#[doc(alias = "slave-method")]
160    //fn set_slave_method(&self, method: /*Ignored*/AudioBaseSrcSlaveMethod) {
161    //    unsafe { TODO: call ffi:gst_audio_base_src_set_slave_method() }
162    //}
163
164    /// Actual configured size of audio buffer in microseconds.
165    #[doc(alias = "actual-buffer-time")]
166    fn actual_buffer_time(&self) -> i64 {
167        ObjectExt::property(self.as_ref(), "actual-buffer-time")
168    }
169
170    /// Actual configured audio latency in microseconds.
171    #[doc(alias = "actual-latency-time")]
172    fn actual_latency_time(&self) -> i64 {
173        ObjectExt::property(self.as_ref(), "actual-latency-time")
174    }
175
176    #[doc(alias = "buffer-time")]
177    fn buffer_time(&self) -> i64 {
178        ObjectExt::property(self.as_ref(), "buffer-time")
179    }
180
181    #[doc(alias = "buffer-time")]
182    fn set_buffer_time(&self, buffer_time: i64) {
183        ObjectExt::set_property(self.as_ref(), "buffer-time", buffer_time)
184    }
185
186    #[doc(alias = "latency-time")]
187    fn latency_time(&self) -> i64 {
188        ObjectExt::property(self.as_ref(), "latency-time")
189    }
190
191    #[doc(alias = "latency-time")]
192    fn set_latency_time(&self, latency_time: i64) {
193        ObjectExt::set_property(self.as_ref(), "latency-time", latency_time)
194    }
195
196    #[doc(alias = "actual-buffer-time")]
197    fn connect_actual_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
198        &self,
199        f: F,
200    ) -> SignalHandlerId {
201        unsafe extern "C" fn notify_actual_buffer_time_trampoline<
202            P: IsA<AudioBaseSrc>,
203            F: Fn(&P) + Send + Sync + 'static,
204        >(
205            this: *mut ffi::GstAudioBaseSrc,
206            _param_spec: glib::ffi::gpointer,
207            f: glib::ffi::gpointer,
208        ) {
209            let f: &F = &*(f as *const F);
210            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
211        }
212        unsafe {
213            let f: Box_<F> = Box_::new(f);
214            connect_raw(
215                self.as_ptr() as *mut _,
216                c"notify::actual-buffer-time".as_ptr() as *const _,
217                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
218                    notify_actual_buffer_time_trampoline::<Self, F> as *const (),
219                )),
220                Box_::into_raw(f),
221            )
222        }
223    }
224
225    #[doc(alias = "actual-latency-time")]
226    fn connect_actual_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
227        &self,
228        f: F,
229    ) -> SignalHandlerId {
230        unsafe extern "C" fn notify_actual_latency_time_trampoline<
231            P: IsA<AudioBaseSrc>,
232            F: Fn(&P) + Send + Sync + 'static,
233        >(
234            this: *mut ffi::GstAudioBaseSrc,
235            _param_spec: glib::ffi::gpointer,
236            f: glib::ffi::gpointer,
237        ) {
238            let f: &F = &*(f as *const F);
239            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
240        }
241        unsafe {
242            let f: Box_<F> = Box_::new(f);
243            connect_raw(
244                self.as_ptr() as *mut _,
245                c"notify::actual-latency-time".as_ptr() as *const _,
246                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
247                    notify_actual_latency_time_trampoline::<Self, F> as *const (),
248                )),
249                Box_::into_raw(f),
250            )
251        }
252    }
253
254    #[doc(alias = "buffer-time")]
255    fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
256        &self,
257        f: F,
258    ) -> SignalHandlerId {
259        unsafe extern "C" fn notify_buffer_time_trampoline<
260            P: IsA<AudioBaseSrc>,
261            F: Fn(&P) + Send + Sync + 'static,
262        >(
263            this: *mut ffi::GstAudioBaseSrc,
264            _param_spec: glib::ffi::gpointer,
265            f: glib::ffi::gpointer,
266        ) {
267            let f: &F = &*(f as *const F);
268            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
269        }
270        unsafe {
271            let f: Box_<F> = Box_::new(f);
272            connect_raw(
273                self.as_ptr() as *mut _,
274                c"notify::buffer-time".as_ptr() as *const _,
275                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
276                    notify_buffer_time_trampoline::<Self, F> as *const (),
277                )),
278                Box_::into_raw(f),
279            )
280        }
281    }
282
283    #[doc(alias = "latency-time")]
284    fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
285        &self,
286        f: F,
287    ) -> SignalHandlerId {
288        unsafe extern "C" fn notify_latency_time_trampoline<
289            P: IsA<AudioBaseSrc>,
290            F: Fn(&P) + Send + Sync + 'static,
291        >(
292            this: *mut ffi::GstAudioBaseSrc,
293            _param_spec: glib::ffi::gpointer,
294            f: glib::ffi::gpointer,
295        ) {
296            let f: &F = &*(f as *const F);
297            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
298        }
299        unsafe {
300            let f: Box_<F> = Box_::new(f);
301            connect_raw(
302                self.as_ptr() as *mut _,
303                c"notify::latency-time".as_ptr() as *const _,
304                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
305                    notify_latency_time_trampoline::<Self, F> as *const (),
306                )),
307                Box_::into_raw(f),
308            )
309        }
310    }
311
312    #[doc(alias = "provide-clock")]
313    fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
314        &self,
315        f: F,
316    ) -> SignalHandlerId {
317        unsafe extern "C" fn notify_provide_clock_trampoline<
318            P: IsA<AudioBaseSrc>,
319            F: Fn(&P) + Send + Sync + 'static,
320        >(
321            this: *mut ffi::GstAudioBaseSrc,
322            _param_spec: glib::ffi::gpointer,
323            f: glib::ffi::gpointer,
324        ) {
325            let f: &F = &*(f as *const F);
326            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
327        }
328        unsafe {
329            let f: Box_<F> = Box_::new(f);
330            connect_raw(
331                self.as_ptr() as *mut _,
332                c"notify::provide-clock".as_ptr() as *const _,
333                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
334                    notify_provide_clock_trampoline::<Self, F> as *const (),
335                )),
336                Box_::into_raw(f),
337            )
338        }
339    }
340
341    #[doc(alias = "slave-method")]
342    fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
343        &self,
344        f: F,
345    ) -> SignalHandlerId {
346        unsafe extern "C" fn notify_slave_method_trampoline<
347            P: IsA<AudioBaseSrc>,
348            F: Fn(&P) + Send + Sync + 'static,
349        >(
350            this: *mut ffi::GstAudioBaseSrc,
351            _param_spec: glib::ffi::gpointer,
352            f: glib::ffi::gpointer,
353        ) {
354            let f: &F = &*(f as *const F);
355            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
356        }
357        unsafe {
358            let f: Box_<F> = Box_::new(f);
359            connect_raw(
360                self.as_ptr() as *mut _,
361                c"notify::slave-method".as_ptr() as *const _,
362                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
363                    notify_slave_method_trampoline::<Self, F> as *const (),
364                )),
365                Box_::into_raw(f),
366            )
367        }
368    }
369}
370
371impl<O: IsA<AudioBaseSrc>> AudioBaseSrcExt for O {}