gstreamer_controller/auto/
direct_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;
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// A value mapping object that attaches control sources to gobject properties. It
16    /// will map the control values directly to the target property range. If a
17    /// non-absolute direct control binding is used, the value range [0.0 ... 1.0]
18    /// is mapped to full target property range, and all values outside the range
19    /// will be clipped. An absolute control binding will not do any value
20    /// transformations.
21    ///
22    /// ## Properties
23    ///
24    ///
25    /// #### `absolute`
26    ///  Readable | Writeable | Construct Only
27    ///
28    ///
29    /// #### `control-source`
30    ///  Readable | Writeable | Construct
31    /// <details><summary><h4>ControlBinding</h4></summary>
32    ///
33    ///
34    /// #### `name`
35    ///  Readable | Writeable | Construct Only
36    ///
37    ///
38    /// #### `object`
39    ///  Readable | Writeable | Construct Only
40    /// </details>
41    /// <details><summary><h4>Object</h4></summary>
42    ///
43    ///
44    /// #### `name`
45    ///  Readable | Writeable | Construct
46    ///
47    ///
48    /// #### `parent`
49    ///  The parent of the object. Please note, that when changing the 'parent'
50    /// property, we don't emit `GObject::notify` and [`deep-notify`][struct@crate::gst::Object#deep-notify]
51    /// signals due to locking issues. In some cases one can use
52    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
53    /// achieve a similar effect.
54    ///
55    /// Readable | Writeable
56    /// </details>
57    ///
58    /// # Implements
59    ///
60    /// [`DirectControlBindingExt`][trait@crate::prelude::DirectControlBindingExt], [`trait@gst::prelude::ControlBindingExt`], [`trait@gst::prelude::ObjectExt`]
61    #[doc(alias = "GstDirectControlBinding")]
62    pub struct DirectControlBinding(Object<ffi::GstDirectControlBinding, ffi::GstDirectControlBindingClass>) @extends gst::ControlBinding, gst::Object;
63
64    match fn {
65        type_ => || ffi::gst_direct_control_binding_get_type(),
66    }
67}
68
69impl DirectControlBinding {
70    pub const NONE: Option<&'static DirectControlBinding> = None;
71
72    /// Create a new control-binding that attaches the [`gst::ControlSource`][crate::gst::ControlSource] to the
73    /// `GObject` property. It will map the control source range [0.0 ... 1.0] to
74    /// the full target property range, and clip all values outside this range.
75    /// ## `object`
76    /// the object of the property
77    /// ## `property_name`
78    /// the property-name to attach the control source
79    /// ## `cs`
80    /// the control source
81    ///
82    /// # Returns
83    ///
84    /// the new [`DirectControlBinding`][crate::DirectControlBinding]
85    #[doc(alias = "gst_direct_control_binding_new")]
86    pub fn new(
87        object: &impl IsA<gst::Object>,
88        property_name: &str,
89        cs: &impl IsA<gst::ControlSource>,
90    ) -> DirectControlBinding {
91        assert_initialized_main_thread!();
92        unsafe {
93            gst::ControlBinding::from_glib_none(ffi::gst_direct_control_binding_new(
94                object.as_ref().to_glib_none().0,
95                property_name.to_glib_none().0,
96                cs.as_ref().to_glib_none().0,
97            ))
98            .unsafe_cast()
99        }
100    }
101
102    /// Create a new control-binding that attaches the [`gst::ControlSource`][crate::gst::ControlSource] to the
103    /// `GObject` property. It will directly map the control source values to the
104    /// target property range without any transformations.
105    /// ## `object`
106    /// the object of the property
107    /// ## `property_name`
108    /// the property-name to attach the control source
109    /// ## `cs`
110    /// the control source
111    ///
112    /// # Returns
113    ///
114    /// the new [`DirectControlBinding`][crate::DirectControlBinding]
115    #[doc(alias = "gst_direct_control_binding_new_absolute")]
116    pub fn new_absolute(
117        object: &impl IsA<gst::Object>,
118        property_name: &str,
119        cs: &impl IsA<gst::ControlSource>,
120    ) -> DirectControlBinding {
121        assert_initialized_main_thread!();
122        unsafe {
123            gst::ControlBinding::from_glib_none(ffi::gst_direct_control_binding_new_absolute(
124                object.as_ref().to_glib_none().0,
125                property_name.to_glib_none().0,
126                cs.as_ref().to_glib_none().0,
127            ))
128            .unsafe_cast()
129        }
130    }
131}
132
133unsafe impl Send for DirectControlBinding {}
134unsafe impl Sync for DirectControlBinding {}
135
136/// Trait containing all [`struct@DirectControlBinding`] methods.
137///
138/// # Implementors
139///
140/// [`DirectControlBinding`][struct@crate::DirectControlBinding]
141pub trait DirectControlBindingExt: IsA<DirectControlBinding> + 'static {
142    fn is_absolute(&self) -> bool {
143        ObjectExt::property(self.as_ref(), "absolute")
144    }
145
146    #[doc(alias = "control-source")]
147    fn control_source(&self) -> Option<gst::ControlSource> {
148        ObjectExt::property(self.as_ref(), "control-source")
149    }
150
151    #[doc(alias = "control-source")]
152    fn set_control_source<P: IsA<gst::ControlSource>>(&self, control_source: Option<&P>) {
153        ObjectExt::set_property(self.as_ref(), "control-source", control_source)
154    }
155
156    #[doc(alias = "control-source")]
157    fn connect_control_source_notify<F: Fn(&Self) + Send + Sync + 'static>(
158        &self,
159        f: F,
160    ) -> SignalHandlerId {
161        unsafe extern "C" fn notify_control_source_trampoline<
162            P: IsA<DirectControlBinding>,
163            F: Fn(&P) + Send + Sync + 'static,
164        >(
165            this: *mut ffi::GstDirectControlBinding,
166            _param_spec: glib::ffi::gpointer,
167            f: glib::ffi::gpointer,
168        ) {
169            let f: &F = &*(f as *const F);
170            f(DirectControlBinding::from_glib_borrow(this).unsafe_cast_ref())
171        }
172        unsafe {
173            let f: Box_<F> = Box_::new(f);
174            connect_raw(
175                self.as_ptr() as *mut _,
176                c"notify::control-source".as_ptr() as *const _,
177                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
178                    notify_control_source_trampoline::<Self, F> as *const (),
179                )),
180                Box_::into_raw(f),
181            )
182        }
183    }
184}
185
186impl<O: IsA<DirectControlBinding>> DirectControlBindingExt for O {}