1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::{ffi, ControlPoint};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// Base class for [`gst::ControlSource`][crate::gst::ControlSource] that use time-stamped values.
    ///
    /// When overriding bind, chain up first to give this bind implementation a
    /// chance to setup things.
    ///
    /// All functions are MT-safe.
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// ## Signals
    ///
    ///
    /// #### `value-added`
    ///  Emitted right after the new value has been added to `self_`
    ///
    ///
    ///
    ///
    /// #### `value-changed`
    ///  Emitted right after the new value has been set on `timed_signals`
    ///
    ///
    ///
    ///
    /// #### `value-removed`
    ///  Emitted when `timed_value` is removed from `self_`
    ///
    ///
    /// <details><summary><h4>Object</h4></summary>
    ///
    ///
    /// #### `deep-notify`
    ///  The deep notify signal is used to be notified of property changes. It is
    /// typically attached to the toplevel bin to receive notifications from all
    /// the elements contained in that bin.
    ///
    /// Detailed
    /// </details>
    ///
    /// # Implements
    ///
    /// [`TimedValueControlSourceExt`][trait@crate::prelude::TimedValueControlSourceExt], [`trait@gst::prelude::ControlSourceExt`], [`trait@gst::prelude::ObjectExt`]
    #[doc(alias = "GstTimedValueControlSource")]
    pub struct TimedValueControlSource(Object<ffi::GstTimedValueControlSource, ffi::GstTimedValueControlSourceClass>) @extends gst::ControlSource, gst::Object;

    match fn {
        type_ => || ffi::gst_timed_value_control_source_get_type(),
    }
}

impl TimedValueControlSource {
    pub const NONE: Option<&'static TimedValueControlSource> = None;
}

unsafe impl Send for TimedValueControlSource {}
unsafe impl Sync for TimedValueControlSource {}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::TimedValueControlSource>> Sealed for T {}
}

/// Trait containing all [`struct@TimedValueControlSource`] methods.
///
/// # Implementors
///
/// [`InterpolationControlSource`][struct@crate::InterpolationControlSource], [`TimedValueControlSource`][struct@crate::TimedValueControlSource], [`TriggerControlSource`][struct@crate::TriggerControlSource]
pub trait TimedValueControlSourceExt:
    IsA<TimedValueControlSource> + sealed::Sealed + 'static
{
    //#[doc(alias = "gst_timed_value_control_source_find_control_point_iter")]
    //fn find_control_point_iter(&self, timestamp: impl Into<Option<gst::ClockTime>>) -> /*Ignored*/Option<glib::SequenceIter> {
    //    unsafe { TODO: call ffi:gst_timed_value_control_source_find_control_point_iter() }
    //}

    //#[doc(alias = "gst_timed_value_control_source_get_all")]
    //#[doc(alias = "get_all")]
    //fn all(&self) -> /*Ignored*/Vec<gst::TimedValue> {
    //    unsafe { TODO: call ffi:gst_timed_value_control_source_get_all() }
    //}

    /// Get the number of control points that are set.
    ///
    /// # Returns
    ///
    /// the number of control points that are set.
    #[doc(alias = "gst_timed_value_control_source_get_count")]
    #[doc(alias = "get_count")]
    fn count(&self) -> i32 {
        unsafe { ffi::gst_timed_value_control_source_get_count(self.as_ref().to_glib_none().0) }
    }

    /// Set the value of given controller-handled property at a certain time.
    /// ## `timestamp`
    /// the time the control-change is scheduled for
    /// ## `value`
    /// the control-value
    ///
    /// # Returns
    ///
    /// FALSE if the values couldn't be set, TRUE otherwise.
    #[doc(alias = "gst_timed_value_control_source_set")]
    fn set(&self, timestamp: gst::ClockTime, value: f64) -> bool {
        unsafe {
            from_glib(ffi::gst_timed_value_control_source_set(
                self.as_ref().to_glib_none().0,
                timestamp.into_glib(),
                value,
            ))
        }
    }

    //#[doc(alias = "gst_timed_value_control_source_set_from_list")]
    //fn set_from_list(&self, timedvalues: /*Ignored*/&[gst::TimedValue]) -> bool {
    //    unsafe { TODO: call ffi:gst_timed_value_control_source_set_from_list() }
    //}

    /// Used to remove the value of given controller-handled property at a certain
    /// time.
    /// ## `timestamp`
    /// the time the control-change should be removed from
    ///
    /// # Returns
    ///
    /// FALSE if the value couldn't be unset (i.e. not found, TRUE otherwise.
    #[doc(alias = "gst_timed_value_control_source_unset")]
    fn unset(&self, timestamp: gst::ClockTime) -> bool {
        unsafe {
            from_glib(ffi::gst_timed_value_control_source_unset(
                self.as_ref().to_glib_none().0,
                timestamp.into_glib(),
            ))
        }
    }

    /// Used to remove all time-stamped values of given controller-handled property
    #[doc(alias = "gst_timed_value_control_source_unset_all")]
    fn unset_all(&self) {
        unsafe {
            ffi::gst_timed_value_control_source_unset_all(self.as_ref().to_glib_none().0);
        }
    }

    /// Emitted right after the new value has been added to `self_`
    /// ## `timed_value`
    /// The newly added `GstTimedValue`
    #[doc(alias = "value-added")]
    fn connect_value_added<F: Fn(&Self, &ControlPoint) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn value_added_trampoline<
            P: IsA<TimedValueControlSource>,
            F: Fn(&P, &ControlPoint) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstTimedValueControlSource,
            timed_value: *mut ffi::GstControlPoint,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                TimedValueControlSource::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(timed_value),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"value-added\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    value_added_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// Emitted right after the new value has been set on `timed_signals`
    /// ## `timed_value`
    /// The `GstTimedValue` where the value changed
    #[doc(alias = "value-changed")]
    fn connect_value_changed<F: Fn(&Self, &ControlPoint) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn value_changed_trampoline<
            P: IsA<TimedValueControlSource>,
            F: Fn(&P, &ControlPoint) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstTimedValueControlSource,
            timed_value: *mut ffi::GstControlPoint,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                TimedValueControlSource::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(timed_value),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"value-changed\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    value_changed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// Emitted when `timed_value` is removed from `self_`
    /// ## `timed_value`
    /// The removed `GstTimedValue`
    #[doc(alias = "value-removed")]
    fn connect_value_removed<F: Fn(&Self, &ControlPoint) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn value_removed_trampoline<
            P: IsA<TimedValueControlSource>,
            F: Fn(&P, &ControlPoint) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstTimedValueControlSource,
            timed_value: *mut ffi::GstControlPoint,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                TimedValueControlSource::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(timed_value),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"value-removed\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    value_removed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<TimedValueControlSource>> TimedValueControlSourceExt for O {}