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
// 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::{ClockTime, Object};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// A base class for value mapping objects that attaches control sources to [`glib::Object`][crate::glib::Object]
    /// properties. Such an object is taking one or more [`ControlSource`][crate::ControlSource] instances,
    /// combines them and maps the resulting value to the type and value range of the
    /// bound property.
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// ## Properties
    ///
    ///
    /// #### `name`
    ///  Readable | Writeable | Construct Only
    ///
    ///
    /// #### `object`
    ///  Readable | Writeable | Construct Only
    /// <details><summary><h4>Object</h4></summary>
    ///
    ///
    /// #### `name`
    ///  Readable | Writeable | Construct
    ///
    ///
    /// #### `parent`
    ///  The parent of the object. Please note, that when changing the 'parent'
    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::Object#deep-notify]
    /// signals due to locking issues. In some cases one can use
    /// [`element-added`][struct@crate::Bin#element-added] or [`element-removed`][struct@crate::Bin#element-removed] signals on the parent to
    /// achieve a similar effect.
    ///
    /// Readable | Writeable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`ControlBindingExt`][trait@crate::prelude::ControlBindingExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`ControlBindingExtManual`][trait@crate::prelude::ControlBindingExtManual]
    #[doc(alias = "GstControlBinding")]
    pub struct ControlBinding(Object<ffi::GstControlBinding, ffi::GstControlBindingClass>) @extends Object;

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

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

unsafe impl Send for ControlBinding {}
unsafe impl Sync for ControlBinding {}

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

/// Trait containing all [`struct@ControlBinding`] methods.
///
/// # Implementors
///
/// [`ControlBinding`][struct@crate::ControlBinding]
pub trait ControlBindingExt: IsA<ControlBinding> + sealed::Sealed + 'static {
    /// Gets the value for the given controlled property at the requested time.
    /// ## `timestamp`
    /// the time the control-change should be read from
    ///
    /// # Returns
    ///
    /// the GValue of the property at the given time,
    /// or [`None`] if the property isn't controlled.
    #[doc(alias = "gst_control_binding_get_value")]
    #[doc(alias = "get_value")]
    fn value(&self, timestamp: ClockTime) -> Option<glib::Value> {
        unsafe {
            from_glib_full(ffi::gst_control_binding_get_value(
                self.as_ref().to_glib_none().0,
                timestamp.into_glib(),
            ))
        }
    }

    //#[doc(alias = "gst_control_binding_get_value_array")]
    //#[doc(alias = "get_value_array")]
    //fn is_value_array(&self, timestamp: impl Into<Option<ClockTime>>, interval: impl Into<Option<ClockTime>>, values: /*Unimplemented*/&[&Basic: Pointer]) -> bool {
    //    unsafe { TODO: call ffi:gst_control_binding_get_value_array() }
    //}

    /// Checks if the control binding is disabled.
    ///
    /// # Returns
    ///
    /// [`true`] if the binding is inactive
    #[doc(alias = "gst_control_binding_is_disabled")]
    fn is_disabled(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_control_binding_is_disabled(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// This function is used to disable a control binding for some time, i.e.
    /// [`GstObjectExt::sync_values()`][crate::prelude::GstObjectExt::sync_values()] will do nothing.
    /// ## `disabled`
    /// boolean that specifies whether to disable the controller
    /// or not.
    #[doc(alias = "gst_control_binding_set_disabled")]
    fn set_disabled(&self, disabled: bool) {
        unsafe {
            ffi::gst_control_binding_set_disabled(
                self.as_ref().to_glib_none().0,
                disabled.into_glib(),
            );
        }
    }

    /// Sets the property of the `object`, according to the `GstControlSources` that
    /// handles it and for the given timestamp.
    ///
    /// If this function fails, it is most likely the application developers fault.
    /// Most probably the control sources are not setup correctly.
    /// ## `object`
    /// the object that has controlled properties
    /// ## `timestamp`
    /// the time that should be processed
    /// ## `last_sync`
    /// the last time this was called
    ///
    /// # Returns
    ///
    /// [`true`] if the controller value could be applied to the object
    /// property, [`false`] otherwise
    #[doc(alias = "gst_control_binding_sync_values")]
    fn sync_values(
        &self,
        object: &impl IsA<Object>,
        timestamp: ClockTime,
        last_sync: impl Into<Option<ClockTime>>,
    ) -> bool {
        unsafe {
            from_glib(ffi::gst_control_binding_sync_values(
                self.as_ref().to_glib_none().0,
                object.as_ref().to_glib_none().0,
                timestamp.into_glib(),
                last_sync.into().into_glib(),
            ))
        }
    }

    fn object(&self) -> Option<Object> {
        ObjectExt::property(self.as_ref(), "object")
    }
}

impl<O: IsA<ControlBinding>> ControlBindingExt for O {}