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