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
107mod sealed {
108    pub trait Sealed {}
109    impl<T: super::IsA<super::AudioBaseSrc>> Sealed for T {}
110}
111
112/// Trait containing all [`struct@AudioBaseSrc`] methods.
113///
114/// # Implementors
115///
116/// [`AudioBaseSrc`][struct@crate::AudioBaseSrc], [`AudioSrc`][struct@crate::AudioSrc]
117pub trait AudioBaseSrcExt: IsA<AudioBaseSrc> + sealed::Sealed + 'static {
118    //#[doc(alias = "gst_audio_base_src_create_ringbuffer")]
119    //fn create_ringbuffer(&self) -> /*Ignored*/Option<AudioRingBuffer> {
120    //    unsafe { TODO: call ffi:gst_audio_base_src_create_ringbuffer() }
121    //}
122
123    /// Queries whether `self` will provide a clock or not. See also
124    /// gst_audio_base_src_set_provide_clock.
125    ///
126    /// # Returns
127    ///
128    /// [`true`] if `self` will provide a clock.
129    #[doc(alias = "gst_audio_base_src_get_provide_clock")]
130    #[doc(alias = "get_provide_clock")]
131    #[doc(alias = "provide-clock")]
132    fn is_provide_clock(&self) -> bool {
133        unsafe {
134            from_glib(ffi::gst_audio_base_src_get_provide_clock(
135                self.as_ref().to_glib_none().0,
136            ))
137        }
138    }
139
140    //#[doc(alias = "gst_audio_base_src_get_slave_method")]
141    //#[doc(alias = "get_slave_method")]
142    //#[doc(alias = "slave-method")]
143    //fn slave_method(&self) -> /*Ignored*/AudioBaseSrcSlaveMethod {
144    //    unsafe { TODO: call ffi:gst_audio_base_src_get_slave_method() }
145    //}
146
147    /// Controls whether `self` will provide a clock or not. If `provide` is [`true`],
148    /// [`ElementExtManual::provide_clock()`][crate::gst::prelude::ElementExtManual::provide_clock()] will return a clock that reflects the datarate
149    /// of `self`. If `provide` is [`false`], [`ElementExtManual::provide_clock()`][crate::gst::prelude::ElementExtManual::provide_clock()] will return NULL.
150    /// ## `provide`
151    /// new state
152    #[doc(alias = "gst_audio_base_src_set_provide_clock")]
153    #[doc(alias = "provide-clock")]
154    fn set_provide_clock(&self, provide: bool) {
155        unsafe {
156            ffi::gst_audio_base_src_set_provide_clock(
157                self.as_ref().to_glib_none().0,
158                provide.into_glib(),
159            );
160        }
161    }
162
163    //#[doc(alias = "gst_audio_base_src_set_slave_method")]
164    //#[doc(alias = "slave-method")]
165    //fn set_slave_method(&self, method: /*Ignored*/AudioBaseSrcSlaveMethod) {
166    //    unsafe { TODO: call ffi:gst_audio_base_src_set_slave_method() }
167    //}
168
169    /// Actual configured size of audio buffer in microseconds.
170    #[doc(alias = "actual-buffer-time")]
171    fn actual_buffer_time(&self) -> i64 {
172        ObjectExt::property(self.as_ref(), "actual-buffer-time")
173    }
174
175    /// Actual configured audio latency in microseconds.
176    #[doc(alias = "actual-latency-time")]
177    fn actual_latency_time(&self) -> i64 {
178        ObjectExt::property(self.as_ref(), "actual-latency-time")
179    }
180
181    #[doc(alias = "buffer-time")]
182    fn buffer_time(&self) -> i64 {
183        ObjectExt::property(self.as_ref(), "buffer-time")
184    }
185
186    #[doc(alias = "buffer-time")]
187    fn set_buffer_time(&self, buffer_time: i64) {
188        ObjectExt::set_property(self.as_ref(), "buffer-time", buffer_time)
189    }
190
191    #[doc(alias = "latency-time")]
192    fn latency_time(&self) -> i64 {
193        ObjectExt::property(self.as_ref(), "latency-time")
194    }
195
196    #[doc(alias = "latency-time")]
197    fn set_latency_time(&self, latency_time: i64) {
198        ObjectExt::set_property(self.as_ref(), "latency-time", latency_time)
199    }
200
201    #[doc(alias = "actual-buffer-time")]
202    fn connect_actual_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
203        &self,
204        f: F,
205    ) -> SignalHandlerId {
206        unsafe extern "C" fn notify_actual_buffer_time_trampoline<
207            P: IsA<AudioBaseSrc>,
208            F: Fn(&P) + Send + Sync + 'static,
209        >(
210            this: *mut ffi::GstAudioBaseSrc,
211            _param_spec: glib::ffi::gpointer,
212            f: glib::ffi::gpointer,
213        ) {
214            let f: &F = &*(f as *const F);
215            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
216        }
217        unsafe {
218            let f: Box_<F> = Box_::new(f);
219            connect_raw(
220                self.as_ptr() as *mut _,
221                b"notify::actual-buffer-time\0".as_ptr() as *const _,
222                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
223                    notify_actual_buffer_time_trampoline::<Self, F> as *const (),
224                )),
225                Box_::into_raw(f),
226            )
227        }
228    }
229
230    #[doc(alias = "actual-latency-time")]
231    fn connect_actual_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
232        &self,
233        f: F,
234    ) -> SignalHandlerId {
235        unsafe extern "C" fn notify_actual_latency_time_trampoline<
236            P: IsA<AudioBaseSrc>,
237            F: Fn(&P) + Send + Sync + 'static,
238        >(
239            this: *mut ffi::GstAudioBaseSrc,
240            _param_spec: glib::ffi::gpointer,
241            f: glib::ffi::gpointer,
242        ) {
243            let f: &F = &*(f as *const F);
244            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
245        }
246        unsafe {
247            let f: Box_<F> = Box_::new(f);
248            connect_raw(
249                self.as_ptr() as *mut _,
250                b"notify::actual-latency-time\0".as_ptr() as *const _,
251                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
252                    notify_actual_latency_time_trampoline::<Self, F> as *const (),
253                )),
254                Box_::into_raw(f),
255            )
256        }
257    }
258
259    #[doc(alias = "buffer-time")]
260    fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
261        &self,
262        f: F,
263    ) -> SignalHandlerId {
264        unsafe extern "C" fn notify_buffer_time_trampoline<
265            P: IsA<AudioBaseSrc>,
266            F: Fn(&P) + Send + Sync + 'static,
267        >(
268            this: *mut ffi::GstAudioBaseSrc,
269            _param_spec: glib::ffi::gpointer,
270            f: glib::ffi::gpointer,
271        ) {
272            let f: &F = &*(f as *const F);
273            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
274        }
275        unsafe {
276            let f: Box_<F> = Box_::new(f);
277            connect_raw(
278                self.as_ptr() as *mut _,
279                b"notify::buffer-time\0".as_ptr() as *const _,
280                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
281                    notify_buffer_time_trampoline::<Self, F> as *const (),
282                )),
283                Box_::into_raw(f),
284            )
285        }
286    }
287
288    #[doc(alias = "latency-time")]
289    fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
290        &self,
291        f: F,
292    ) -> SignalHandlerId {
293        unsafe extern "C" fn notify_latency_time_trampoline<
294            P: IsA<AudioBaseSrc>,
295            F: Fn(&P) + Send + Sync + 'static,
296        >(
297            this: *mut ffi::GstAudioBaseSrc,
298            _param_spec: glib::ffi::gpointer,
299            f: glib::ffi::gpointer,
300        ) {
301            let f: &F = &*(f as *const F);
302            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
303        }
304        unsafe {
305            let f: Box_<F> = Box_::new(f);
306            connect_raw(
307                self.as_ptr() as *mut _,
308                b"notify::latency-time\0".as_ptr() as *const _,
309                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
310                    notify_latency_time_trampoline::<Self, F> as *const (),
311                )),
312                Box_::into_raw(f),
313            )
314        }
315    }
316
317    #[doc(alias = "provide-clock")]
318    fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
319        &self,
320        f: F,
321    ) -> SignalHandlerId {
322        unsafe extern "C" fn notify_provide_clock_trampoline<
323            P: IsA<AudioBaseSrc>,
324            F: Fn(&P) + Send + Sync + 'static,
325        >(
326            this: *mut ffi::GstAudioBaseSrc,
327            _param_spec: glib::ffi::gpointer,
328            f: glib::ffi::gpointer,
329        ) {
330            let f: &F = &*(f as *const F);
331            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
332        }
333        unsafe {
334            let f: Box_<F> = Box_::new(f);
335            connect_raw(
336                self.as_ptr() as *mut _,
337                b"notify::provide-clock\0".as_ptr() as *const _,
338                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
339                    notify_provide_clock_trampoline::<Self, F> as *const (),
340                )),
341                Box_::into_raw(f),
342            )
343        }
344    }
345
346    #[doc(alias = "slave-method")]
347    fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
348        &self,
349        f: F,
350    ) -> SignalHandlerId {
351        unsafe extern "C" fn notify_slave_method_trampoline<
352            P: IsA<AudioBaseSrc>,
353            F: Fn(&P) + Send + Sync + 'static,
354        >(
355            this: *mut ffi::GstAudioBaseSrc,
356            _param_spec: glib::ffi::gpointer,
357            f: glib::ffi::gpointer,
358        ) {
359            let f: &F = &*(f as *const F);
360            f(AudioBaseSrc::from_glib_borrow(this).unsafe_cast_ref())
361        }
362        unsafe {
363            let f: Box_<F> = Box_::new(f);
364            connect_raw(
365                self.as_ptr() as *mut _,
366                b"notify::slave-method\0".as_ptr() as *const _,
367                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
368                    notify_slave_method_trampoline::<Self, F> as *const (),
369                )),
370                Box_::into_raw(f),
371            )
372        }
373    }
374}
375
376impl<O: IsA<AudioBaseSrc>> AudioBaseSrcExt for O {}