gstreamer_controller/auto/
timed_value_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#![allow(deprecated)]
6
7use crate::{ffi, ControlPoint};
8use glib::{
9    object::ObjectType as _,
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// Base class for [`gst::ControlSource`][crate::gst::ControlSource] that use time-stamped values.
18    ///
19    /// When overriding bind, chain up first to give this bind implementation a
20    /// chance to setup things.
21    ///
22    /// All functions are MT-safe.
23    ///
24    /// This is an Abstract Base Class, you cannot instantiate it.
25    ///
26    /// ## Signals
27    ///
28    ///
29    /// #### `value-added`
30    ///  Emitted right after the new value has been added to `self_`
31    ///
32    ///
33    ///
34    ///
35    /// #### `value-changed`
36    ///  Emitted right after the new value has been set on `timed_signals`
37    ///
38    ///
39    ///
40    ///
41    /// #### `value-removed`
42    ///  Emitted when `timed_value` is removed from `self_`
43    ///
44    ///
45    /// <details><summary><h4>Object</h4></summary>
46    ///
47    ///
48    /// #### `deep-notify`
49    ///  The deep notify signal is used to be notified of property changes. It is
50    /// typically attached to the toplevel bin to receive notifications from all
51    /// the elements contained in that bin.
52    ///
53    /// Detailed
54    /// </details>
55    ///
56    /// # Implements
57    ///
58    /// [`TimedValueControlSourceExt`][trait@crate::prelude::TimedValueControlSourceExt], [`trait@gst::prelude::ControlSourceExt`], [`trait@gst::prelude::ObjectExt`]
59    #[doc(alias = "GstTimedValueControlSource")]
60    pub struct TimedValueControlSource(Object<ffi::GstTimedValueControlSource, ffi::GstTimedValueControlSourceClass>) @extends gst::ControlSource, gst::Object;
61
62    match fn {
63        type_ => || ffi::gst_timed_value_control_source_get_type(),
64    }
65}
66
67impl TimedValueControlSource {
68    pub const NONE: Option<&'static TimedValueControlSource> = None;
69}
70
71unsafe impl Send for TimedValueControlSource {}
72unsafe impl Sync for TimedValueControlSource {}
73
74/// Trait containing all [`struct@TimedValueControlSource`] methods.
75///
76/// # Implementors
77///
78/// [`InterpolationControlSource`][struct@crate::InterpolationControlSource], [`TimedValueControlSource`][struct@crate::TimedValueControlSource], [`TriggerControlSource`][struct@crate::TriggerControlSource]
79pub trait TimedValueControlSourceExt: IsA<TimedValueControlSource> + 'static {
80    //#[doc(alias = "gst_timed_value_control_source_find_control_point_iter")]
81    //fn find_control_point_iter(&self, timestamp: impl Into<Option<gst::ClockTime>>) -> /*Ignored*/Option<glib::SequenceIter> {
82    //    unsafe { TODO: call ffi:gst_timed_value_control_source_find_control_point_iter() }
83    //}
84
85    /// Get the number of control points that are set.
86    ///
87    /// # Returns
88    ///
89    /// the number of control points that are set.
90    #[doc(alias = "gst_timed_value_control_source_get_count")]
91    #[doc(alias = "get_count")]
92    fn count(&self) -> i32 {
93        unsafe { ffi::gst_timed_value_control_source_get_count(self.as_ref().to_glib_none().0) }
94    }
95
96    /// Set the value of given controller-handled property at a certain time.
97    /// ## `timestamp`
98    /// the time the control-change is scheduled for
99    /// ## `value`
100    /// the control-value
101    ///
102    /// # Returns
103    ///
104    /// FALSE if the values couldn't be set, TRUE otherwise.
105    #[doc(alias = "gst_timed_value_control_source_set")]
106    fn set(&self, timestamp: gst::ClockTime, value: f64) -> bool {
107        unsafe {
108            from_glib(ffi::gst_timed_value_control_source_set(
109                self.as_ref().to_glib_none().0,
110                timestamp.into_glib(),
111                value,
112            ))
113        }
114    }
115
116    //#[doc(alias = "gst_timed_value_control_source_set_from_list")]
117    //fn set_from_list(&self, timedvalues: /*Ignored*/&[gst::TimedValue]) -> bool {
118    //    unsafe { TODO: call ffi:gst_timed_value_control_source_set_from_list() }
119    //}
120
121    /// Used to remove the value of given controller-handled property at a certain
122    /// time.
123    /// ## `timestamp`
124    /// the time the control-change should be removed from
125    ///
126    /// # Returns
127    ///
128    /// FALSE if the value couldn't be unset (i.e. not found, TRUE otherwise.
129    #[doc(alias = "gst_timed_value_control_source_unset")]
130    fn unset(&self, timestamp: gst::ClockTime) -> bool {
131        unsafe {
132            from_glib(ffi::gst_timed_value_control_source_unset(
133                self.as_ref().to_glib_none().0,
134                timestamp.into_glib(),
135            ))
136        }
137    }
138
139    /// Used to remove all time-stamped values of given controller-handled property
140    #[doc(alias = "gst_timed_value_control_source_unset_all")]
141    fn unset_all(&self) {
142        unsafe {
143            ffi::gst_timed_value_control_source_unset_all(self.as_ref().to_glib_none().0);
144        }
145    }
146
147    /// Emitted right after the new value has been added to `self_`
148    /// ## `timed_value`
149    /// The newly added `GstTimedValue`
150    #[doc(alias = "value-added")]
151    fn connect_value_added<F: Fn(&Self, &ControlPoint) + Send + Sync + 'static>(
152        &self,
153        f: F,
154    ) -> SignalHandlerId {
155        unsafe extern "C" fn value_added_trampoline<
156            P: IsA<TimedValueControlSource>,
157            F: Fn(&P, &ControlPoint) + Send + Sync + 'static,
158        >(
159            this: *mut ffi::GstTimedValueControlSource,
160            timed_value: *mut ffi::GstControlPoint,
161            f: glib::ffi::gpointer,
162        ) {
163            let f: &F = &*(f as *const F);
164            f(
165                TimedValueControlSource::from_glib_borrow(this).unsafe_cast_ref(),
166                &from_glib_borrow(timed_value),
167            )
168        }
169        unsafe {
170            let f: Box_<F> = Box_::new(f);
171            connect_raw(
172                self.as_ptr() as *mut _,
173                c"value-added".as_ptr() as *const _,
174                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
175                    value_added_trampoline::<Self, F> as *const (),
176                )),
177                Box_::into_raw(f),
178            )
179        }
180    }
181
182    /// Emitted right after the new value has been set on `timed_signals`
183    /// ## `timed_value`
184    /// The `GstTimedValue` where the value changed
185    #[doc(alias = "value-changed")]
186    fn connect_value_changed<F: Fn(&Self, &ControlPoint) + Send + Sync + 'static>(
187        &self,
188        f: F,
189    ) -> SignalHandlerId {
190        unsafe extern "C" fn value_changed_trampoline<
191            P: IsA<TimedValueControlSource>,
192            F: Fn(&P, &ControlPoint) + Send + Sync + 'static,
193        >(
194            this: *mut ffi::GstTimedValueControlSource,
195            timed_value: *mut ffi::GstControlPoint,
196            f: glib::ffi::gpointer,
197        ) {
198            let f: &F = &*(f as *const F);
199            f(
200                TimedValueControlSource::from_glib_borrow(this).unsafe_cast_ref(),
201                &from_glib_borrow(timed_value),
202            )
203        }
204        unsafe {
205            let f: Box_<F> = Box_::new(f);
206            connect_raw(
207                self.as_ptr() as *mut _,
208                c"value-changed".as_ptr() as *const _,
209                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
210                    value_changed_trampoline::<Self, F> as *const (),
211                )),
212                Box_::into_raw(f),
213            )
214        }
215    }
216
217    /// Emitted when `timed_value` is removed from `self_`
218    /// ## `timed_value`
219    /// The removed `GstTimedValue`
220    #[doc(alias = "value-removed")]
221    fn connect_value_removed<F: Fn(&Self, &ControlPoint) + Send + Sync + 'static>(
222        &self,
223        f: F,
224    ) -> SignalHandlerId {
225        unsafe extern "C" fn value_removed_trampoline<
226            P: IsA<TimedValueControlSource>,
227            F: Fn(&P, &ControlPoint) + Send + Sync + 'static,
228        >(
229            this: *mut ffi::GstTimedValueControlSource,
230            timed_value: *mut ffi::GstControlPoint,
231            f: glib::ffi::gpointer,
232        ) {
233            let f: &F = &*(f as *const F);
234            f(
235                TimedValueControlSource::from_glib_borrow(this).unsafe_cast_ref(),
236                &from_glib_borrow(timed_value),
237            )
238        }
239        unsafe {
240            let f: Box_<F> = Box_::new(f);
241            connect_raw(
242                self.as_ptr() as *mut _,
243                c"value-removed".as_ptr() as *const _,
244                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
245                    value_removed_trampoline::<Self, F> as *const (),
246                )),
247                Box_::into_raw(f),
248            )
249        }
250    }
251}
252
253impl<O: IsA<TimedValueControlSource>> TimedValueControlSourceExt for O {}