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
// 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::ControlPoint;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::mem::transmute;

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.
    ///
    /// # 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(),
    }
}

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

pub const NONE_TIMED_VALUE_CONTROL_SOURCE: Option<&TimedValueControlSource> = None;

/// Trait containing all [`struct@TimedValueControlSource`] methods.
///
/// # Implementors
///
/// [`InterpolationControlSource`][struct@crate::InterpolationControlSource], [`TimedValueControlSource`][struct@crate::TimedValueControlSource], [`TriggerControlSource`][struct@crate::TriggerControlSource]
pub trait TimedValueControlSourceExt: '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>;

    //#[doc(alias = "gst_timed_value_control_source_get_all")]
    //#[doc(alias = "get_all")]
    //fn all(&self) -> /*Ignored*/Vec<gst::TimedValue>;

    /// 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;

    /// 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;

    //#[doc(alias = "gst_timed_value_control_source_set_from_list")]
    //fn set_from_list(&self, timedvalues: /*Ignored*/&[&gst::TimedValue]) -> bool;

    /// 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;

    /// 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);

    /// 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;

    /// 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;

    /// 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;
}

impl<O: IsA<TimedValueControlSource>> TimedValueControlSourceExt for O {
    //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() }
    //}

    //fn all(&self) -> /*Ignored*/Vec<gst::TimedValue> {
    //    unsafe { TODO: call ffi:gst_timed_value_control_source_get_all() }
    //}

    fn count(&self) -> i32 {
        unsafe { ffi::gst_timed_value_control_source_get_count(self.as_ref().to_glib_none().0) }
    }

    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,
            ))
        }
    }

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

    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(),
            ))
        }
    }

    fn unset_all(&self) {
        unsafe {
            ffi::gst_timed_value_control_source_unset_all(self.as_ref().to_glib_none().0);
        }
    }

    #[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(transmute::<_, unsafe extern "C" fn()>(
                    value_added_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[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(transmute::<_, unsafe extern "C" fn()>(
                    value_changed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[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(transmute::<_, unsafe extern "C" fn()>(
                    value_removed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}