Skip to main content

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::{SignalHandlerId, connect_raw},
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            unsafe {
210                let f: &F = &*(f as *const F);
211                f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
212            }
213        }
214        unsafe {
215            let f: Box_<F> = Box_::new(f);
216            connect_raw(
217                self.as_ptr() as *mut _,
218                c"notify::actual-buffer-time".as_ptr(),
219                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
220                    notify_actual_buffer_time_trampoline::<Self, F> as *const (),
221                )),
222                Box_::into_raw(f),
223            )
224        }
225    }
226
227    #[doc(alias = "actual-latency-time")]
228    fn connect_actual_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
229        &self,
230        f: F,
231    ) -> SignalHandlerId {
232        unsafe extern "C" fn notify_actual_latency_time_trampoline<
233            P: IsA<AudioBaseSrc>,
234            F: Fn(&P) + Send + Sync + 'static,
235        >(
236            this: *mut ffi::GstAudioBaseSrc,
237            _param_spec: glib::ffi::gpointer,
238            f: glib::ffi::gpointer,
239        ) {
240            unsafe {
241                let f: &F = &*(f as *const F);
242                f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
243            }
244        }
245        unsafe {
246            let f: Box_<F> = Box_::new(f);
247            connect_raw(
248                self.as_ptr() as *mut _,
249                c"notify::actual-latency-time".as_ptr(),
250                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
251                    notify_actual_latency_time_trampoline::<Self, F> as *const (),
252                )),
253                Box_::into_raw(f),
254            )
255        }
256    }
257
258    #[doc(alias = "buffer-time")]
259    fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
260        &self,
261        f: F,
262    ) -> SignalHandlerId {
263        unsafe extern "C" fn notify_buffer_time_trampoline<
264            P: IsA<AudioBaseSrc>,
265            F: Fn(&P) + Send + Sync + 'static,
266        >(
267            this: *mut ffi::GstAudioBaseSrc,
268            _param_spec: glib::ffi::gpointer,
269            f: glib::ffi::gpointer,
270        ) {
271            unsafe {
272                let f: &F = &*(f as *const F);
273                f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
274            }
275        }
276        unsafe {
277            let f: Box_<F> = Box_::new(f);
278            connect_raw(
279                self.as_ptr() as *mut _,
280                c"notify::buffer-time".as_ptr(),
281                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
282                    notify_buffer_time_trampoline::<Self, F> as *const (),
283                )),
284                Box_::into_raw(f),
285            )
286        }
287    }
288
289    #[doc(alias = "latency-time")]
290    fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
291        &self,
292        f: F,
293    ) -> SignalHandlerId {
294        unsafe extern "C" fn notify_latency_time_trampoline<
295            P: IsA<AudioBaseSrc>,
296            F: Fn(&P) + Send + Sync + 'static,
297        >(
298            this: *mut ffi::GstAudioBaseSrc,
299            _param_spec: glib::ffi::gpointer,
300            f: glib::ffi::gpointer,
301        ) {
302            unsafe {
303                let f: &F = &*(f as *const F);
304                f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
305            }
306        }
307        unsafe {
308            let f: Box_<F> = Box_::new(f);
309            connect_raw(
310                self.as_ptr() as *mut _,
311                c"notify::latency-time".as_ptr(),
312                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
313                    notify_latency_time_trampoline::<Self, F> as *const (),
314                )),
315                Box_::into_raw(f),
316            )
317        }
318    }
319
320    #[doc(alias = "provide-clock")]
321    fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
322        &self,
323        f: F,
324    ) -> SignalHandlerId {
325        unsafe extern "C" fn notify_provide_clock_trampoline<
326            P: IsA<AudioBaseSrc>,
327            F: Fn(&P) + Send + Sync + 'static,
328        >(
329            this: *mut ffi::GstAudioBaseSrc,
330            _param_spec: glib::ffi::gpointer,
331            f: glib::ffi::gpointer,
332        ) {
333            unsafe {
334                let f: &F = &*(f as *const F);
335                f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
336            }
337        }
338        unsafe {
339            let f: Box_<F> = Box_::new(f);
340            connect_raw(
341                self.as_ptr() as *mut _,
342                c"notify::provide-clock".as_ptr(),
343                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
344                    notify_provide_clock_trampoline::<Self, F> as *const (),
345                )),
346                Box_::into_raw(f),
347            )
348        }
349    }
350
351    #[doc(alias = "slave-method")]
352    fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
353        &self,
354        f: F,
355    ) -> SignalHandlerId {
356        unsafe extern "C" fn notify_slave_method_trampoline<
357            P: IsA<AudioBaseSrc>,
358            F: Fn(&P) + Send + Sync + 'static,
359        >(
360            this: *mut ffi::GstAudioBaseSrc,
361            _param_spec: glib::ffi::gpointer,
362            f: glib::ffi::gpointer,
363        ) {
364            unsafe {
365                let f: &F = &*(f as *const F);
366                f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
367            }
368        }
369        unsafe {
370            let f: Box_<F> = Box_::new(f);
371            connect_raw(
372                self.as_ptr() as *mut _,
373                c"notify::slave-method".as_ptr(),
374                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
375                    notify_slave_method_trampoline::<Self, F> as *const (),
376                )),
377                Box_::into_raw(f),
378            )
379        }
380    }
381}
382
383impl<O: IsA<AudioBaseSrc>> AudioBaseSrcExt for O {}