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::{ClockTime, ControlBinding};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::{boxed::Box as Box_, fmt, mem::transmute};
13
14glib::wrapper! {
15 #[doc(alias = "GstObject")]
16 pub struct Object(Object<ffi::GstObject, ffi::GstObjectClass>);
17
18 match fn {
19 type_ => || ffi::gst_object_get_type(),
20 }
21}
22
23impl Object {
24 pub const NONE: Option<&'static Object> = None;
25
26 #[doc(alias = "gst_object_check_uniqueness")]
27 pub fn check_uniqueness(list: &[Object], name: &str) -> bool {
28 assert_initialized_main_thread!();
29 unsafe {
30 from_glib(val:ffi::gst_object_check_uniqueness(
31 list:list.to_glib_none().0,
32 name:name.to_glib_none().0,
33 ))
34 }
35 }
36
37 //#[doc(alias = "gst_object_default_deep_notify")]
38 //pub fn default_deep_notify(object: &impl IsA<glib::Object>, orig: &impl IsA<Object>, pspec: /*Ignored*/&glib::ParamSpec, excluded_props: &[&str]) {
39 // unsafe { TODO: call ffi:gst_object_default_deep_notify() }
40 //}
41
42 //#[doc(alias = "gst_object_replace")]
43 //pub fn replace(oldobj: Option<impl IsA<Object>>, newobj: Option<&impl IsA<Object>>) -> bool {
44 // unsafe { TODO: call ffi:gst_object_replace() }
45 //}
46}
47
48impl fmt::Display for Object {
49 #[inline]
50 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
51 f.write_str(&GstObjectExt::name(self))
52 }
53}
54
55unsafe impl Send for Object {}
56unsafe impl Sync for Object {}
57
58mod sealed {
59 pub trait Sealed {}
60 impl<T: super::IsA<super::Object>> Sealed for T {}
61}
62
63pub trait GstObjectExt: IsA<Object> + sealed::Sealed + 'static {
64 #[doc(alias = "gst_object_add_control_binding")]
65 fn add_control_binding(
66 &self,
67 binding: &impl IsA<ControlBinding>,
68 ) -> Result<(), glib::error::BoolError> {
69 unsafe {
70 glib::result_from_gboolean!(
71 ffi::gst_object_add_control_binding(
72 self.as_ref().to_glib_none().0,
73 binding.as_ref().to_glib_none().0
74 ),
75 "Failed to add control binding"
76 )
77 }
78 }
79
80 #[doc(alias = "gst_object_default_error")]
81 fn default_error(&self, error: &glib::Error, debug: Option<&str>) {
82 unsafe {
83 ffi::gst_object_default_error(
84 self.as_ref().to_glib_none().0,
85 error.to_glib_none().0,
86 debug.to_glib_none().0,
87 );
88 }
89 }
90
91 #[doc(alias = "gst_object_get_control_binding")]
92 #[doc(alias = "get_control_binding")]
93 fn control_binding(&self, property_name: &str) -> Option<ControlBinding> {
94 unsafe {
95 from_glib_full(ffi::gst_object_get_control_binding(
96 self.as_ref().to_glib_none().0,
97 property_name.to_glib_none().0,
98 ))
99 }
100 }
101
102 #[doc(alias = "gst_object_get_control_rate")]
103 #[doc(alias = "get_control_rate")]
104 fn control_rate(&self) -> Option<ClockTime> {
105 unsafe {
106 from_glib(ffi::gst_object_get_control_rate(
107 self.as_ref().to_glib_none().0,
108 ))
109 }
110 }
111
112 #[doc(alias = "gst_object_get_name")]
113 #[doc(alias = "get_name")]
114 fn name(&self) -> glib::GString {
115 unsafe { from_glib_full(ffi::gst_object_get_name(self.as_ref().to_glib_none().0)) }
116 }
117
118 #[doc(alias = "gst_object_get_parent")]
119 #[doc(alias = "get_parent")]
120 #[must_use]
121 fn parent(&self) -> Option<Object> {
122 unsafe { from_glib_full(ffi::gst_object_get_parent(self.as_ref().to_glib_none().0)) }
123 }
124
125 #[doc(alias = "gst_object_get_path_string")]
126 #[doc(alias = "get_path_string")]
127 fn path_string(&self) -> glib::GString {
128 unsafe {
129 from_glib_full(ffi::gst_object_get_path_string(
130 self.as_ref().to_glib_none().0,
131 ))
132 }
133 }
134
135 #[doc(alias = "gst_object_get_value")]
136 #[doc(alias = "get_value")]
137 fn value(
138 &self,
139 property_name: &str,
140 timestamp: impl Into<Option<ClockTime>>,
141 ) -> Option<glib::Value> {
142 unsafe {
143 from_glib_full(ffi::gst_object_get_value(
144 self.as_ref().to_glib_none().0,
145 property_name.to_glib_none().0,
146 timestamp.into().into_glib(),
147 ))
148 }
149 }
150
151 //#[doc(alias = "gst_object_get_value_array")]
152 //#[doc(alias = "get_value_array")]
153 //fn is_value_array(&self, property_name: &str, timestamp: impl Into<Option<ClockTime>>, interval: impl Into<Option<ClockTime>>, values: /*Unimplemented*/&[&Basic: Pointer]) -> bool {
154 // unsafe { TODO: call ffi:gst_object_get_value_array() }
155 //}
156
157 #[doc(alias = "gst_object_has_active_control_bindings")]
158 fn has_active_control_bindings(&self) -> bool {
159 unsafe {
160 from_glib(ffi::gst_object_has_active_control_bindings(
161 self.as_ref().to_glib_none().0,
162 ))
163 }
164 }
165
166 #[doc(alias = "gst_object_has_ancestor")]
167 fn has_ancestor(&self, ancestor: &impl IsA<Object>) -> bool {
168 unsafe {
169 from_glib(ffi::gst_object_has_ancestor(
170 self.as_ref().to_glib_none().0,
171 ancestor.as_ref().to_glib_none().0,
172 ))
173 }
174 }
175
176 #[doc(alias = "gst_object_has_as_ancestor")]
177 fn has_as_ancestor(&self, ancestor: &impl IsA<Object>) -> bool {
178 unsafe {
179 from_glib(ffi::gst_object_has_as_ancestor(
180 self.as_ref().to_glib_none().0,
181 ancestor.as_ref().to_glib_none().0,
182 ))
183 }
184 }
185
186 #[doc(alias = "gst_object_has_as_parent")]
187 fn has_as_parent(&self, parent: &impl IsA<Object>) -> bool {
188 unsafe {
189 from_glib(ffi::gst_object_has_as_parent(
190 self.as_ref().to_glib_none().0,
191 parent.as_ref().to_glib_none().0,
192 ))
193 }
194 }
195
196 #[doc(alias = "gst_object_remove_control_binding")]
197 fn remove_control_binding(&self, binding: &impl IsA<ControlBinding>) -> bool {
198 unsafe {
199 from_glib(ffi::gst_object_remove_control_binding(
200 self.as_ref().to_glib_none().0,
201 binding.as_ref().to_glib_none().0,
202 ))
203 }
204 }
205
206 #[doc(alias = "gst_object_set_control_binding_disabled")]
207 fn set_control_binding_disabled(&self, property_name: &str, disabled: bool) {
208 unsafe {
209 ffi::gst_object_set_control_binding_disabled(
210 self.as_ref().to_glib_none().0,
211 property_name.to_glib_none().0,
212 disabled.into_glib(),
213 );
214 }
215 }
216
217 #[doc(alias = "gst_object_set_control_bindings_disabled")]
218 fn set_control_bindings_disabled(&self, disabled: bool) {
219 unsafe {
220 ffi::gst_object_set_control_bindings_disabled(
221 self.as_ref().to_glib_none().0,
222 disabled.into_glib(),
223 );
224 }
225 }
226
227 #[doc(alias = "gst_object_set_control_rate")]
228 fn set_control_rate(&self, control_rate: impl Into<Option<ClockTime>>) {
229 unsafe {
230 ffi::gst_object_set_control_rate(
231 self.as_ref().to_glib_none().0,
232 control_rate.into().into_glib(),
233 );
234 }
235 }
236
237 #[doc(alias = "gst_object_set_parent")]
238 fn set_parent(&self, parent: &impl IsA<Object>) -> Result<(), glib::error::BoolError> {
239 unsafe {
240 glib::result_from_gboolean!(
241 ffi::gst_object_set_parent(
242 self.as_ref().to_glib_none().0,
243 parent.as_ref().to_glib_none().0
244 ),
245 "Failed to set parent object"
246 )
247 }
248 }
249
250 #[doc(alias = "gst_object_suggest_next_sync")]
251 fn suggest_next_sync(&self) -> Option<ClockTime> {
252 unsafe {
253 from_glib(ffi::gst_object_suggest_next_sync(
254 self.as_ref().to_glib_none().0,
255 ))
256 }
257 }
258
259 #[doc(alias = "gst_object_sync_values")]
260 fn sync_values(&self, timestamp: ClockTime) -> Result<(), glib::error::BoolError> {
261 unsafe {
262 glib::result_from_gboolean!(
263 ffi::gst_object_sync_values(self.as_ref().to_glib_none().0, timestamp.into_glib()),
264 "Failed to sync values"
265 )
266 }
267 }
268
269 #[doc(alias = "gst_object_unparent")]
270 fn unparent(&self) {
271 unsafe {
272 ffi::gst_object_unparent(self.as_ref().to_glib_none().0);
273 }
274 }
275
276 //#[doc(alias = "deep-notify")]
277 //fn connect_deep_notify<Unsupported or ignored types>(&self, detail: Option<&str>, f: F) -> SignalHandlerId {
278 // Ignored prop: GObject.ParamSpec
279 //}
280
281 #[doc(alias = "parent")]
282 fn connect_parent_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
283 unsafe extern "C" fn notify_parent_trampoline<
284 P: IsA<Object>,
285 F: Fn(&P) + Send + Sync + 'static,
286 >(
287 this: *mut ffi::GstObject,
288 _param_spec: glib::ffi::gpointer,
289 f: glib::ffi::gpointer,
290 ) {
291 let f: &F = &*(f as *const F);
292 f(Object::from_glib_borrow(this).unsafe_cast_ref())
293 }
294 unsafe {
295 let f: Box_<F> = Box_::new(f);
296 connect_raw(
297 self.as_ptr() as *mut _,
298 b"notify::parent\0".as_ptr() as *const _,
299 Some(transmute::<_, unsafe extern "C" fn()>(
300 notify_parent_trampoline::<Self, F> as *const (),
301 )),
302 Box_::into_raw(f),
303 )
304 }
305 }
306}
307
308impl<O: IsA<Object>> GstObjectExt for O {}
309