gstreamer/auto/
control_binding.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, ClockTime, Object};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// A base class for value mapping objects that attaches control sources to [`glib::Object`][crate::glib::Object]
11    /// properties. Such an object is taking one or more [`ControlSource`][crate::ControlSource] instances,
12    /// combines them and maps the resulting value to the type and value range of the
13    /// bound property.
14    ///
15    /// This is an Abstract Base Class, you cannot instantiate it.
16    ///
17    /// ## Properties
18    ///
19    ///
20    /// #### `name`
21    ///  Readable | Writeable | Construct Only
22    ///
23    ///
24    /// #### `object`
25    ///  Readable | Writeable | Construct Only
26    /// <details><summary><h4>Object</h4></summary>
27    ///
28    ///
29    /// #### `name`
30    ///  Readable | Writeable | Construct
31    ///
32    ///
33    /// #### `parent`
34    ///  The parent of the object. Please note, that when changing the 'parent'
35    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::Object#deep-notify]
36    /// signals due to locking issues. In some cases one can use
37    /// [`element-added`][struct@crate::Bin#element-added] or [`element-removed`][struct@crate::Bin#element-removed] signals on the parent to
38    /// achieve a similar effect.
39    ///
40    /// Readable | Writeable
41    /// </details>
42    ///
43    /// # Implements
44    ///
45    /// [`ControlBindingExt`][trait@crate::prelude::ControlBindingExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`ControlBindingExtManual`][trait@crate::prelude::ControlBindingExtManual]
46    #[doc(alias = "GstControlBinding")]
47    pub struct ControlBinding(Object<ffi::GstControlBinding, ffi::GstControlBindingClass>) @extends Object;
48
49    match fn {
50        type_ => || ffi::gst_control_binding_get_type(),
51    }
52}
53
54impl ControlBinding {
55    pub const NONE: Option<&'static ControlBinding> = None;
56}
57
58unsafe impl Send for ControlBinding {}
59unsafe impl Sync for ControlBinding {}
60
61mod sealed {
62    pub trait Sealed {}
63    impl<T: super::IsA<super::ControlBinding>> Sealed for T {}
64}
65
66/// Trait containing all [`struct@ControlBinding`] methods.
67///
68/// # Implementors
69///
70/// [`ControlBinding`][struct@crate::ControlBinding]
71pub trait ControlBindingExt: IsA<ControlBinding> + sealed::Sealed + 'static {
72    /// Gets the value for the given controlled property at the requested time.
73    /// ## `timestamp`
74    /// the time the control-change should be read from
75    ///
76    /// # Returns
77    ///
78    /// the GValue of the property at the given time,
79    /// or [`None`] if the property isn't controlled.
80    #[doc(alias = "gst_control_binding_get_value")]
81    #[doc(alias = "get_value")]
82    fn value(&self, timestamp: ClockTime) -> Option<glib::Value> {
83        unsafe {
84            from_glib_full(ffi::gst_control_binding_get_value(
85                self.as_ref().to_glib_none().0,
86                timestamp.into_glib(),
87            ))
88        }
89    }
90
91    //#[doc(alias = "gst_control_binding_get_value_array")]
92    //#[doc(alias = "get_value_array")]
93    //fn is_value_array(&self, timestamp: impl Into<Option<ClockTime>>, interval: impl Into<Option<ClockTime>>, values: /*Unimplemented*/&[&Basic: Pointer]) -> bool {
94    //    unsafe { TODO: call ffi:gst_control_binding_get_value_array() }
95    //}
96
97    /// Checks if the control binding is disabled.
98    ///
99    /// # Returns
100    ///
101    /// [`true`] if the binding is inactive
102    #[doc(alias = "gst_control_binding_is_disabled")]
103    fn is_disabled(&self) -> bool {
104        unsafe {
105            from_glib(ffi::gst_control_binding_is_disabled(
106                self.as_ref().to_glib_none().0,
107            ))
108        }
109    }
110
111    /// This function is used to disable a control binding for some time, i.e.
112    /// [`GstObjectExt::sync_values()`][crate::prelude::GstObjectExt::sync_values()] will do nothing.
113    /// ## `disabled`
114    /// boolean that specifies whether to disable the controller
115    /// or not.
116    #[doc(alias = "gst_control_binding_set_disabled")]
117    fn set_disabled(&self, disabled: bool) {
118        unsafe {
119            ffi::gst_control_binding_set_disabled(
120                self.as_ref().to_glib_none().0,
121                disabled.into_glib(),
122            );
123        }
124    }
125
126    /// Sets the property of the `object`, according to the `GstControlSources` that
127    /// handles it and for the given timestamp.
128    ///
129    /// If this function fails, it is most likely the application developers fault.
130    /// Most probably the control sources are not setup correctly.
131    /// ## `object`
132    /// the object that has controlled properties
133    /// ## `timestamp`
134    /// the time that should be processed
135    /// ## `last_sync`
136    /// the last time this was called
137    ///
138    /// # Returns
139    ///
140    /// [`true`] if the controller value could be applied to the object
141    /// property, [`false`] otherwise
142    #[doc(alias = "gst_control_binding_sync_values")]
143    fn sync_values(
144        &self,
145        object: &impl IsA<Object>,
146        timestamp: ClockTime,
147        last_sync: impl Into<Option<ClockTime>>,
148    ) -> bool {
149        unsafe {
150            from_glib(ffi::gst_control_binding_sync_values(
151                self.as_ref().to_glib_none().0,
152                object.as_ref().to_glib_none().0,
153                timestamp.into_glib(),
154                last_sync.into().into_glib(),
155            ))
156        }
157    }
158
159    fn object(&self) -> Option<Object> {
160        ObjectExt::property(self.as_ref(), "object")
161    }
162}
163
164impl<O: IsA<ControlBinding>> ControlBindingExt for O {}