gstreamer_controller/auto/
lfo_control_source.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, LFOWaveform};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// [`LFOControlSource`][crate::LFOControlSource] is a [`gst::ControlSource`][crate::gst::ControlSource], that provides several periodic
16    /// waveforms as control values.
17    ///
18    /// To use [`LFOControlSource`][crate::LFOControlSource] get a new instance by calling
19    /// [`new()`][Self::new()], bind it to a `GParamSpec` and set the relevant
20    /// properties.
21    ///
22    /// All functions are MT-safe.
23    ///
24    /// ## Properties
25    ///
26    ///
27    /// #### `amplitude`
28    ///  Specifies the amplitude for the waveform of this [`LFOControlSource`][crate::LFOControlSource].
29    ///
30    /// Readable | Writeable
31    ///
32    ///
33    /// #### `frequency`
34    ///  Specifies the frequency that should be used for the waveform
35    /// of this [`LFOControlSource`][crate::LFOControlSource]. It should be large enough
36    /// so that the period is longer than one nanosecond.
37    ///
38    /// Readable | Writeable
39    ///
40    ///
41    /// #### `offset`
42    ///  Specifies the value offset for the waveform of this [`LFOControlSource`][crate::LFOControlSource].
43    ///
44    /// Readable | Writeable
45    ///
46    ///
47    /// #### `timeshift`
48    ///  Specifies the timeshift to the right that should be used for the waveform
49    /// of this [`LFOControlSource`][crate::LFOControlSource] in nanoseconds.
50    ///
51    /// To get a n nanosecond shift to the left use
52    /// "(GST_SECOND / frequency) - n".
53    ///
54    /// Readable | Writeable
55    ///
56    ///
57    /// #### `waveform`
58    ///  Specifies the waveform that should be used for this [`LFOControlSource`][crate::LFOControlSource].
59    ///
60    /// Readable | Writeable
61    /// <details><summary><h4>Object</h4></summary>
62    ///
63    ///
64    /// #### `name`
65    ///  Readable | Writeable | Construct
66    ///
67    ///
68    /// #### `parent`
69    ///  The parent of the object. Please note, that when changing the 'parent'
70    /// property, we don't emit `GObject::notify` and [`deep-notify`][struct@crate::gst::Object#deep-notify]
71    /// signals due to locking issues. In some cases one can use
72    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
73    /// achieve a similar effect.
74    ///
75    /// Readable | Writeable
76    /// </details>
77    ///
78    /// # Implements
79    ///
80    /// [`LFOControlSourceExt`][trait@crate::prelude::LFOControlSourceExt], [`trait@gst::prelude::ControlSourceExt`], [`trait@gst::prelude::ObjectExt`]
81    #[doc(alias = "GstLFOControlSource")]
82    pub struct LFOControlSource(Object<ffi::GstLFOControlSource, ffi::GstLFOControlSourceClass>) @extends gst::ControlSource, gst::Object;
83
84    match fn {
85        type_ => || ffi::gst_lfo_control_source_get_type(),
86    }
87}
88
89impl LFOControlSource {
90    pub const NONE: Option<&'static LFOControlSource> = None;
91
92    /// This returns a new, unbound [`LFOControlSource`][crate::LFOControlSource].
93    ///
94    /// # Returns
95    ///
96    /// a new, unbound [`LFOControlSource`][crate::LFOControlSource].
97    #[doc(alias = "gst_lfo_control_source_new")]
98    pub fn new() -> LFOControlSource {
99        assert_initialized_main_thread!();
100        unsafe {
101            gst::ControlSource::from_glib_full(ffi::gst_lfo_control_source_new()).unsafe_cast()
102        }
103    }
104}
105
106impl Default for LFOControlSource {
107    fn default() -> Self {
108        Self::new()
109    }
110}
111
112unsafe impl Send for LFOControlSource {}
113unsafe impl Sync for LFOControlSource {}
114
115mod sealed {
116    pub trait Sealed {}
117    impl<T: super::IsA<super::LFOControlSource>> Sealed for T {}
118}
119
120/// Trait containing all [`struct@LFOControlSource`] methods.
121///
122/// # Implementors
123///
124/// [`LFOControlSource`][struct@crate::LFOControlSource]
125pub trait LFOControlSourceExt: IsA<LFOControlSource> + sealed::Sealed + 'static {
126    /// Specifies the amplitude for the waveform of this [`LFOControlSource`][crate::LFOControlSource].
127    fn amplitude(&self) -> f64 {
128        ObjectExt::property(self.as_ref(), "amplitude")
129    }
130
131    /// Specifies the amplitude for the waveform of this [`LFOControlSource`][crate::LFOControlSource].
132    fn set_amplitude(&self, amplitude: f64) {
133        ObjectExt::set_property(self.as_ref(), "amplitude", amplitude)
134    }
135
136    /// Specifies the frequency that should be used for the waveform
137    /// of this [`LFOControlSource`][crate::LFOControlSource]. It should be large enough
138    /// so that the period is longer than one nanosecond.
139    fn frequency(&self) -> f64 {
140        ObjectExt::property(self.as_ref(), "frequency")
141    }
142
143    /// Specifies the frequency that should be used for the waveform
144    /// of this [`LFOControlSource`][crate::LFOControlSource]. It should be large enough
145    /// so that the period is longer than one nanosecond.
146    fn set_frequency(&self, frequency: f64) {
147        ObjectExt::set_property(self.as_ref(), "frequency", frequency)
148    }
149
150    /// Specifies the value offset for the waveform of this [`LFOControlSource`][crate::LFOControlSource].
151    fn offset(&self) -> f64 {
152        ObjectExt::property(self.as_ref(), "offset")
153    }
154
155    /// Specifies the value offset for the waveform of this [`LFOControlSource`][crate::LFOControlSource].
156    fn set_offset(&self, offset: f64) {
157        ObjectExt::set_property(self.as_ref(), "offset", offset)
158    }
159
160    /// Specifies the timeshift to the right that should be used for the waveform
161    /// of this [`LFOControlSource`][crate::LFOControlSource] in nanoseconds.
162    ///
163    /// To get a n nanosecond shift to the left use
164    /// "(GST_SECOND / frequency) - n".
165    fn timeshift(&self) -> u64 {
166        ObjectExt::property(self.as_ref(), "timeshift")
167    }
168
169    /// Specifies the timeshift to the right that should be used for the waveform
170    /// of this [`LFOControlSource`][crate::LFOControlSource] in nanoseconds.
171    ///
172    /// To get a n nanosecond shift to the left use
173    /// "(GST_SECOND / frequency) - n".
174    fn set_timeshift(&self, timeshift: u64) {
175        ObjectExt::set_property(self.as_ref(), "timeshift", timeshift)
176    }
177
178    /// Specifies the waveform that should be used for this [`LFOControlSource`][crate::LFOControlSource].
179    fn waveform(&self) -> LFOWaveform {
180        ObjectExt::property(self.as_ref(), "waveform")
181    }
182
183    /// Specifies the waveform that should be used for this [`LFOControlSource`][crate::LFOControlSource].
184    fn set_waveform(&self, waveform: LFOWaveform) {
185        ObjectExt::set_property(self.as_ref(), "waveform", waveform)
186    }
187
188    #[doc(alias = "amplitude")]
189    fn connect_amplitude_notify<F: Fn(&Self) + Send + Sync + 'static>(
190        &self,
191        f: F,
192    ) -> SignalHandlerId {
193        unsafe extern "C" fn notify_amplitude_trampoline<
194            P: IsA<LFOControlSource>,
195            F: Fn(&P) + Send + Sync + 'static,
196        >(
197            this: *mut ffi::GstLFOControlSource,
198            _param_spec: glib::ffi::gpointer,
199            f: glib::ffi::gpointer,
200        ) {
201            let f: &F = &*(f as *const F);
202            f(LFOControlSource::from_glib_borrow(this).unsafe_cast_ref())
203        }
204        unsafe {
205            let f: Box_<F> = Box_::new(f);
206            connect_raw(
207                self.as_ptr() as *mut _,
208                b"notify::amplitude\0".as_ptr() as *const _,
209                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
210                    notify_amplitude_trampoline::<Self, F> as *const (),
211                )),
212                Box_::into_raw(f),
213            )
214        }
215    }
216
217    #[doc(alias = "frequency")]
218    fn connect_frequency_notify<F: Fn(&Self) + Send + Sync + 'static>(
219        &self,
220        f: F,
221    ) -> SignalHandlerId {
222        unsafe extern "C" fn notify_frequency_trampoline<
223            P: IsA<LFOControlSource>,
224            F: Fn(&P) + Send + Sync + 'static,
225        >(
226            this: *mut ffi::GstLFOControlSource,
227            _param_spec: glib::ffi::gpointer,
228            f: glib::ffi::gpointer,
229        ) {
230            let f: &F = &*(f as *const F);
231            f(LFOControlSource::from_glib_borrow(this).unsafe_cast_ref())
232        }
233        unsafe {
234            let f: Box_<F> = Box_::new(f);
235            connect_raw(
236                self.as_ptr() as *mut _,
237                b"notify::frequency\0".as_ptr() as *const _,
238                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
239                    notify_frequency_trampoline::<Self, F> as *const (),
240                )),
241                Box_::into_raw(f),
242            )
243        }
244    }
245
246    #[doc(alias = "offset")]
247    fn connect_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
248        unsafe extern "C" fn notify_offset_trampoline<
249            P: IsA<LFOControlSource>,
250            F: Fn(&P) + Send + Sync + 'static,
251        >(
252            this: *mut ffi::GstLFOControlSource,
253            _param_spec: glib::ffi::gpointer,
254            f: glib::ffi::gpointer,
255        ) {
256            let f: &F = &*(f as *const F);
257            f(LFOControlSource::from_glib_borrow(this).unsafe_cast_ref())
258        }
259        unsafe {
260            let f: Box_<F> = Box_::new(f);
261            connect_raw(
262                self.as_ptr() as *mut _,
263                b"notify::offset\0".as_ptr() as *const _,
264                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
265                    notify_offset_trampoline::<Self, F> as *const (),
266                )),
267                Box_::into_raw(f),
268            )
269        }
270    }
271
272    #[doc(alias = "timeshift")]
273    fn connect_timeshift_notify<F: Fn(&Self) + Send + Sync + 'static>(
274        &self,
275        f: F,
276    ) -> SignalHandlerId {
277        unsafe extern "C" fn notify_timeshift_trampoline<
278            P: IsA<LFOControlSource>,
279            F: Fn(&P) + Send + Sync + 'static,
280        >(
281            this: *mut ffi::GstLFOControlSource,
282            _param_spec: glib::ffi::gpointer,
283            f: glib::ffi::gpointer,
284        ) {
285            let f: &F = &*(f as *const F);
286            f(LFOControlSource::from_glib_borrow(this).unsafe_cast_ref())
287        }
288        unsafe {
289            let f: Box_<F> = Box_::new(f);
290            connect_raw(
291                self.as_ptr() as *mut _,
292                b"notify::timeshift\0".as_ptr() as *const _,
293                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
294                    notify_timeshift_trampoline::<Self, F> as *const (),
295                )),
296                Box_::into_raw(f),
297            )
298        }
299    }
300
301    #[doc(alias = "waveform")]
302    fn connect_waveform_notify<F: Fn(&Self) + Send + Sync + 'static>(
303        &self,
304        f: F,
305    ) -> SignalHandlerId {
306        unsafe extern "C" fn notify_waveform_trampoline<
307            P: IsA<LFOControlSource>,
308            F: Fn(&P) + Send + Sync + 'static,
309        >(
310            this: *mut ffi::GstLFOControlSource,
311            _param_spec: glib::ffi::gpointer,
312            f: glib::ffi::gpointer,
313        ) {
314            let f: &F = &*(f as *const F);
315            f(LFOControlSource::from_glib_borrow(this).unsafe_cast_ref())
316        }
317        unsafe {
318            let f: Box_<F> = Box_::new(f);
319            connect_raw(
320                self.as_ptr() as *mut _,
321                b"notify::waveform\0".as_ptr() as *const _,
322                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
323                    notify_waveform_trampoline::<Self, F> as *const (),
324                )),
325                Box_::into_raw(f),
326            )
327        }
328    }
329}
330
331impl<O: IsA<LFOControlSource>> LFOControlSourceExt for O {}