gstreamer_video/auto/color_balance.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, ColorBalanceChannel, ColorBalanceType};
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{connect_raw, SignalHandlerId},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 /// This interface is implemented by elements which can perform some color
17 /// balance operation on video frames they process. For example, modifying
18 /// the brightness, contrast, hue or saturation.
19 ///
20 /// Example elements are 'xvimagesink' and 'colorbalance'
21 ///
22 /// ## Signals
23 ///
24 ///
25 /// #### `value-changed`
26 /// Fired when the value of the indicated channel has changed.
27 ///
28 ///
29 ///
30 /// # Implements
31 ///
32 /// [`ColorBalanceExt`][trait@crate::prelude::ColorBalanceExt]
33 #[doc(alias = "GstColorBalance")]
34 pub struct ColorBalance(Interface<ffi::GstColorBalance, ffi::GstColorBalanceInterface>);
35
36 match fn {
37 type_ => || ffi::gst_color_balance_get_type(),
38 }
39}
40
41impl ColorBalance {
42 pub const NONE: Option<&'static ColorBalance> = None;
43}
44
45unsafe impl Send for ColorBalance {}
46unsafe impl Sync for ColorBalance {}
47
48/// Trait containing all [`struct@ColorBalance`] methods.
49///
50/// # Implementors
51///
52/// [`ColorBalance`][struct@crate::ColorBalance]
53pub trait ColorBalanceExt: IsA<ColorBalance> + 'static {
54 /// Get the [`ColorBalanceType`][crate::ColorBalanceType] of this implementation.
55 ///
56 /// # Returns
57 ///
58 /// A the [`ColorBalanceType`][crate::ColorBalanceType].
59 #[doc(alias = "gst_color_balance_get_balance_type")]
60 #[doc(alias = "get_balance_type")]
61 fn balance_type(&self) -> ColorBalanceType {
62 unsafe {
63 from_glib(ffi::gst_color_balance_get_balance_type(
64 self.as_ref().to_glib_none().0,
65 ))
66 }
67 }
68
69 /// Retrieve the current value of the indicated channel, between min_value
70 /// and max_value.
71 ///
72 /// See Also: The `GstColorBalanceChannel.min_value` and
73 /// `GstColorBalanceChannel.max_value` members of the
74 /// [`ColorBalanceChannel`][crate::ColorBalanceChannel] object.
75 /// ## `channel`
76 /// A [`ColorBalanceChannel`][crate::ColorBalanceChannel] instance
77 ///
78 /// # Returns
79 ///
80 /// The current value of the channel.
81 #[doc(alias = "gst_color_balance_get_value")]
82 #[doc(alias = "get_value")]
83 fn value(&self, channel: &impl IsA<ColorBalanceChannel>) -> i32 {
84 unsafe {
85 ffi::gst_color_balance_get_value(
86 self.as_ref().to_glib_none().0,
87 channel.as_ref().to_glib_none().0,
88 )
89 }
90 }
91
92 /// Retrieve a list of the available channels.
93 ///
94 /// # Returns
95 ///
96 /// A
97 /// GList containing pointers to [`ColorBalanceChannel`][crate::ColorBalanceChannel]
98 /// objects. The list is owned by the [`ColorBalance`][crate::ColorBalance]
99 /// instance and must not be freed.
100 #[doc(alias = "gst_color_balance_list_channels")]
101 fn list_channels(&self) -> Vec<ColorBalanceChannel> {
102 unsafe {
103 FromGlibPtrContainer::from_glib_none(ffi::gst_color_balance_list_channels(
104 self.as_ref().to_glib_none().0,
105 ))
106 }
107 }
108
109 /// Sets the current value of the channel to the passed value, which must
110 /// be between min_value and max_value.
111 ///
112 /// See Also: The `GstColorBalanceChannel.min_value` and
113 /// `GstColorBalanceChannel.max_value` members of the
114 /// [`ColorBalanceChannel`][crate::ColorBalanceChannel] object.
115 /// ## `channel`
116 /// A [`ColorBalanceChannel`][crate::ColorBalanceChannel] instance
117 /// ## `value`
118 /// The new value for the channel.
119 #[doc(alias = "gst_color_balance_set_value")]
120 fn set_value(&self, channel: &impl IsA<ColorBalanceChannel>, value: i32) {
121 unsafe {
122 ffi::gst_color_balance_set_value(
123 self.as_ref().to_glib_none().0,
124 channel.as_ref().to_glib_none().0,
125 value,
126 );
127 }
128 }
129
130 /// A helper function called by implementations of the GstColorBalance
131 /// interface. It fires the [`value-changed`][struct@crate::ColorBalance#value-changed] signal on the
132 /// instance, and the [`value-changed`][struct@crate::ColorBalanceChannel#value-changed] signal on the
133 /// channel object.
134 /// ## `channel`
135 /// A [`ColorBalanceChannel`][crate::ColorBalanceChannel] whose value has changed
136 /// ## `value`
137 /// The new value of the channel
138 #[doc(alias = "gst_color_balance_value_changed")]
139 fn value_changed(&self, channel: &impl IsA<ColorBalanceChannel>, value: i32) {
140 unsafe {
141 ffi::gst_color_balance_value_changed(
142 self.as_ref().to_glib_none().0,
143 channel.as_ref().to_glib_none().0,
144 value,
145 );
146 }
147 }
148
149 /// Fired when the value of the indicated channel has changed.
150 /// ## `channel`
151 /// The [`ColorBalanceChannel`][crate::ColorBalanceChannel]
152 /// ## `value`
153 /// The new value
154 #[doc(alias = "value-changed")]
155 fn connect_value_changed<F: Fn(&Self, &ColorBalanceChannel, i32) + Send + Sync + 'static>(
156 &self,
157 f: F,
158 ) -> SignalHandlerId {
159 unsafe extern "C" fn value_changed_trampoline<
160 P: IsA<ColorBalance>,
161 F: Fn(&P, &ColorBalanceChannel, i32) + Send + Sync + 'static,
162 >(
163 this: *mut ffi::GstColorBalance,
164 channel: *mut ffi::GstColorBalanceChannel,
165 value: std::ffi::c_int,
166 f: glib::ffi::gpointer,
167 ) {
168 let f: &F = &*(f as *const F);
169 f(
170 ColorBalance::from_glib_borrow(this).unsafe_cast_ref(),
171 &from_glib_borrow(channel),
172 value,
173 )
174 }
175 unsafe {
176 let f: Box_<F> = Box_::new(f);
177 connect_raw(
178 self.as_ptr() as *mut _,
179 c"value-changed".as_ptr() as *const _,
180 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
181 value_changed_trampoline::<Self, F> as *const (),
182 )),
183 Box_::into_raw(f),
184 )
185 }
186 }
187}
188
189impl<O: IsA<ColorBalance>> ColorBalanceExt for O {}