gstreamer/auto/
object.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, ControlBinding};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
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(ffi::gst_object_check_uniqueness(
31                list.to_glib_none().0,
32                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 std::fmt::Display for Object {
49    #[inline]
50    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::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    #[doc(alias = "parent")]
239    fn set_parent(&self, parent: &impl IsA<Object>) -> Result<(), glib::error::BoolError> {
240        unsafe {
241            glib::result_from_gboolean!(
242                ffi::gst_object_set_parent(
243                    self.as_ref().to_glib_none().0,
244                    parent.as_ref().to_glib_none().0
245                ),
246                "Failed to set parent object"
247            )
248        }
249    }
250
251    #[doc(alias = "gst_object_suggest_next_sync")]
252    fn suggest_next_sync(&self) -> Option<ClockTime> {
253        unsafe {
254            from_glib(ffi::gst_object_suggest_next_sync(
255                self.as_ref().to_glib_none().0,
256            ))
257        }
258    }
259
260    #[doc(alias = "gst_object_sync_values")]
261    fn sync_values(&self, timestamp: ClockTime) -> Result<(), glib::error::BoolError> {
262        unsafe {
263            glib::result_from_gboolean!(
264                ffi::gst_object_sync_values(self.as_ref().to_glib_none().0, timestamp.into_glib()),
265                "Failed to sync values"
266            )
267        }
268    }
269
270    #[doc(alias = "gst_object_unparent")]
271    fn unparent(&self) {
272        unsafe {
273            ffi::gst_object_unparent(self.as_ref().to_glib_none().0);
274        }
275    }
276
277    //#[doc(alias = "deep-notify")]
278    //fn connect_deep_notify<Unsupported or ignored types>(&self, detail: Option<&str>, f: F) -> SignalHandlerId {
279    //    Ignored prop: GObject.ParamSpec
280    //}
281
282    #[doc(alias = "parent")]
283    fn connect_parent_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
284        unsafe extern "C" fn notify_parent_trampoline<
285            P: IsA<Object>,
286            F: Fn(&P) + Send + Sync + 'static,
287        >(
288            this: *mut ffi::GstObject,
289            _param_spec: glib::ffi::gpointer,
290            f: glib::ffi::gpointer,
291        ) {
292            let f: &F = &*(f as *const F);
293            f(Object::from_glib_borrow(this).unsafe_cast_ref())
294        }
295        unsafe {
296            let f: Box_<F> = Box_::new(f);
297            connect_raw(
298                self.as_ptr() as *mut _,
299                b"notify::parent\0".as_ptr() as *const _,
300                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
301                    notify_parent_trampoline::<Self, F> as *const (),
302                )),
303                Box_::into_raw(f),
304            )
305        }
306    }
307}
308
309impl<O: IsA<Object>> GstObjectExt for O {}