1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use crate::ClockTime;
use crate::ControlBinding;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;

glib::wrapper! {
    /// [`crate::Object`] provides a root for the object hierarchy tree filed in by the
    /// GStreamer library. It is currently a thin wrapper on top of
    /// [`crate::glib::object::InitiallyUnowned`]. It is an abstract class that is not very usable on its own.
    ///
    /// [`crate::Object`] gives us basic refcounting, parenting functionality and locking.
    /// Most of the functions are just extended for special GStreamer needs and can be
    /// found under the same name in the base class of [`crate::Object`] which is [`crate::glib::object::Object`]
    /// (e.g. [`crate::glib::object::ObjectExt::ref()`] becomes [`crate::prelude::GstObjectExt::ref()`]).
    ///
    /// Since [`crate::Object`] derives from [`crate::glib::object::InitiallyUnowned`], it also inherits the
    /// floating reference. Be aware that functions such as [`crate::prelude::GstBinExt::add()`] and
    /// [`crate::prelude::ElementExt::add_pad()`] take ownership of the floating reference.
    ///
    /// In contrast to [`crate::glib::object::Object`] instances, [`crate::Object`] adds a name property. The functions
    /// [`Self::set_name()`] and [`crate::prelude::GstObjectExt::get_name()`] are used to set/get the name
    /// of the object.
    ///
    /// ## controlled properties
    ///
    /// Controlled properties offers a lightweight way to adjust gobject properties
    /// over stream-time. It works by using time-stamped value pairs that are queued
    /// for element-properties. At run-time the elements continuously pull value
    /// changes for the current stream-time.
    ///
    /// What needs to be changed in a [`crate::Element`]?
    /// Very little - it is just two steps to make a plugin controllable!
    ///
    ///  * mark gobject-properties paramspecs that make sense to be controlled,
    ///  by GST_PARAM_CONTROLLABLE.
    ///
    ///  * when processing data (get, chain, loop function) at the beginning call
    ///  gst_object_sync_values(element,timestamp).
    ///  This will make the controller update all GObject properties that are
    ///  under its control with the current values based on the timestamp.
    ///
    /// What needs to be done in applications? Again it's not a lot to change.
    ///
    ///  * create a [`crate::ControlSource`].
    ///  csource = gst_interpolation_control_source_new ();
    ///  g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
    ///
    ///  * Attach the [`crate::ControlSource`] on the controller to a property.
    ///  gst_object_add_control_binding (object, gst_direct_control_binding_new (object, "prop1", csource));
    ///
    ///  * Set the control values
    ///  gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,0 * GST_SECOND, value1);
    ///  gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,1 * GST_SECOND, value2);
    ///
    ///  * start your pipeline
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// # Implements
    ///
    /// [`trait@crate::prelude::GstObjectExt`], [`trait@glib::object::ObjectExt`]
    pub struct Object(Object<ffi::GstObject, ffi::GstObjectClass>);

    match fn {
        type_ => || ffi::gst_object_get_type(),
    }
}

impl Object {
    /// Checks to see if there is any object named `name` in `list`. This function
    /// does not do any locking of any kind. You might want to protect the
    /// provided list with the lock of the owner of the list. This function
    /// will lock each [`crate::Object`] in the list to compare the name, so be
    /// careful when passing a list with a locked object.
    /// ## `list`
    /// a list of [`crate::Object`] to
    ///  check through
    /// ## `name`
    /// the name to search for
    ///
    /// # Returns
    ///
    /// [`true`] if a [`crate::Object`] named `name` does not appear in `list`,
    /// [`false`] if it does.
    ///
    /// MT safe. Grabs and releases the LOCK of each object in the list.
    #[doc(alias = "gst_object_check_uniqueness")]
    pub fn check_uniqueness(list: &[Object], name: &str) -> bool {
        assert_initialized_main_thread!();
        unsafe {
            from_glib(ffi::gst_object_check_uniqueness(
                list.to_glib_none().0,
                name.to_glib_none().0,
            ))
        }
    }

    //#[doc(alias = "gst_object_default_deep_notify")]
    //pub fn default_deep_notify<P: IsA<glib::Object>, Q: IsA<Object>>(object: &P, orig: &Q, pspec: /*Ignored*/&glib::ParamSpec, excluded_props: &[&str]) {
    //    unsafe { TODO: call ffi:gst_object_default_deep_notify() }
    //}

    //#[doc(alias = "gst_object_ref_sink")]
    //pub fn ref_sink(object: /*Unimplemented*/Option<Fundamental: Pointer>) -> /*Unimplemented*/Option<Fundamental: Pointer> {
    //    unsafe { TODO: call ffi:gst_object_ref_sink() }
    //}

    //#[doc(alias = "gst_object_replace")]
    //pub fn replace<P: IsA<Object>, Q: IsA<Object>>(oldobj: Option<P>, newobj: Option<&Q>) -> bool {
    //    unsafe { TODO: call ffi:gst_object_replace() }
    //}
}

impl fmt::Display for Object {
    #[inline]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str(&GstObjectExt::name(self))
    }
}

unsafe impl Send for Object {}
unsafe impl Sync for Object {}

pub const NONE_OBJECT: Option<&Object> = None;

/// Trait containing all `Object` methods.
///
/// # Implementors
///
/// [`struct@crate::Allocator`], [`struct@crate::BufferPool`], [`struct@crate::Bus`], [`struct@crate::Clock`], [`struct@crate::ControlBinding`], [`struct@crate::ControlSource`], [`struct@crate::DeviceMonitor`], [`struct@crate::DeviceProvider`], [`struct@crate::Device`], [`struct@crate::Element`], [`struct@crate::Object`], [`struct@crate::PadTemplate`], [`struct@crate::Pad`], [`struct@crate::PluginFeature`], [`struct@crate::Plugin`], [`struct@crate::Registry`], [`struct@crate::StreamCollection`], [`struct@crate::Stream`]
pub trait GstObjectExt: 'static {
    /// Attach the [`crate::ControlBinding`] to the object. If there already was a
    /// [`crate::ControlBinding`] for this property it will be replaced.
    ///
    /// The object's reference count will be incremented, and any floating
    /// reference will be removed (see [`crate::Object::ref_sink()`])
    /// ## `binding`
    /// the [`crate::ControlBinding`] that should be used
    ///
    /// # Returns
    ///
    /// [`false`] if the given `binding` has not been setup for this object or
    /// has been setup for a non suitable property, [`true`] otherwise.
    #[doc(alias = "gst_object_add_control_binding")]
    fn add_control_binding<P: IsA<ControlBinding>>(
        &self,
        binding: &P,
    ) -> Result<(), glib::error::BoolError>;

    /// A default error function that uses `g_printerr()` to display the error message
    /// and the optional debug string..
    ///
    /// The default handler will simply print the error string using g_print.
    /// ## `error`
    /// the GError.
    /// ## `debug`
    /// an additional debug information string, or [`None`]
    #[doc(alias = "gst_object_default_error")]
    fn default_error(&self, error: &glib::Error, debug: Option<&str>);

    /// Gets the corresponding [`crate::ControlBinding`] for the property. This should be
    /// unreferenced again after use.
    /// ## `property_name`
    /// name of the property
    ///
    /// # Returns
    ///
    /// the [`crate::ControlBinding`] for
    /// `property_name` or [`None`] if the property is not controlled.
    #[doc(alias = "gst_object_get_control_binding")]
    #[doc(alias = "get_control_binding")]
    fn control_binding(&self, property_name: &str) -> Option<ControlBinding>;

    /// Obtain the control-rate for this `self`. Audio processing [`crate::Element`]
    /// objects will use this rate to sub-divide their processing loop and call
    /// [`Self::sync_values()`] in between. The length of the processing segment
    /// should be up to `control`-rate nanoseconds.
    ///
    /// If the `self` is not under property control, this will return
    /// `GST_CLOCK_TIME_NONE`. This allows the element to avoid the sub-dividing.
    ///
    /// The control-rate is not expected to change if the element is in
    /// [`crate::State::Paused`] or [`crate::State::Playing`].
    ///
    /// # Returns
    ///
    /// the control rate in nanoseconds
    #[doc(alias = "gst_object_get_control_rate")]
    #[doc(alias = "get_control_rate")]
    fn control_rate(&self) -> ClockTime;

    /// Returns a copy of the name of `self`.
    /// Caller should `g_free()` the return value after usage.
    /// For a nameless object, this returns [`None`], which you can safely `g_free()`
    /// as well.
    ///
    /// Free-function: g_free
    ///
    /// # Returns
    ///
    /// the name of `self`. `g_free()`
    /// after usage.
    ///
    /// MT safe. This function grabs and releases `self`'s LOCK.
    #[doc(alias = "gst_object_get_name")]
    #[doc(alias = "get_name")]
    fn name(&self) -> glib::GString;

    /// Returns the parent of `self`. This function increases the refcount
    /// of the parent object so you should [`Self::unref()`] it after usage.
    ///
    /// # Returns
    ///
    /// parent of `self`, this can be
    ///  [`None`] if `self` has no parent. unref after usage.
    ///
    /// MT safe. Grabs and releases `self`'s LOCK.
    #[doc(alias = "gst_object_get_parent")]
    #[doc(alias = "get_parent")]
    fn parent(&self) -> Option<Object>;

    /// Generates a string describing the path of `self` in
    /// the object hierarchy. Only useful (or used) for debugging.
    ///
    /// Free-function: g_free
    ///
    /// # Returns
    ///
    /// a string describing the path of `self`. You must
    ///  `g_free()` the string after usage.
    ///
    /// MT safe. Grabs and releases the [`crate::Object`]'s LOCK for all objects
    ///  in the hierarchy.
    #[doc(alias = "gst_object_get_path_string")]
    #[doc(alias = "get_path_string")]
    fn path_string(&self) -> glib::GString;

    /// Gets the value for the given controlled property at the requested time.
    /// ## `property_name`
    /// the name of the property to get
    /// ## `timestamp`
    /// the time the control-change should be read from
    ///
    /// # Returns
    ///
    /// the GValue of the property at the given time,
    /// or [`None`] if the property isn't controlled.
    #[doc(alias = "gst_object_get_value")]
    #[doc(alias = "get_value")]
    fn value(&self, property_name: &str, timestamp: ClockTime) -> Option<glib::Value>;

    //#[doc(alias = "gst_object_get_value_array")]
    //#[doc(alias = "get_value_array")]
    //fn is_value_array(&self, property_name: &str, timestamp: ClockTime, interval: ClockTime, n_values: u32, values: /*Unimplemented*/Option<Fundamental: Pointer>) -> bool;

    /// Check if the `self` has active controlled properties.
    ///
    /// # Returns
    ///
    /// [`true`] if the object has active controlled properties
    #[doc(alias = "gst_object_has_active_control_bindings")]
    fn has_active_control_bindings(&self) -> bool;

    /// Check if `self` has an ancestor `ancestor` somewhere up in
    /// the hierarchy. One can e.g. check if a [`crate::Element`] is inside a [`crate::Pipeline`].
    ///
    /// # Deprecated
    ///
    /// Use [`Self::has_as_ancestor()`] instead.
    ///
    /// MT safe. Grabs and releases `self`'s locks.
    /// ## `ancestor`
    /// a [`crate::Object`] to check as ancestor
    ///
    /// # Returns
    ///
    /// [`true`] if `ancestor` is an ancestor of `self`.
    #[doc(alias = "gst_object_has_ancestor")]
    fn has_ancestor<P: IsA<Object>>(&self, ancestor: &P) -> bool;

    /// Check if `self` has an ancestor `ancestor` somewhere up in
    /// the hierarchy. One can e.g. check if a [`crate::Element`] is inside a [`crate::Pipeline`].
    /// ## `ancestor`
    /// a [`crate::Object`] to check as ancestor
    ///
    /// # Returns
    ///
    /// [`true`] if `ancestor` is an ancestor of `self`.
    ///
    /// MT safe. Grabs and releases `self`'s locks.
    #[doc(alias = "gst_object_has_as_ancestor")]
    fn has_as_ancestor<P: IsA<Object>>(&self, ancestor: &P) -> bool;

    /// Check if `parent` is the parent of `self`.
    /// E.g. a [`crate::Element`] can check if it owns a given [`crate::Pad`].
    /// ## `parent`
    /// a [`crate::Object`] to check as parent
    ///
    /// # Returns
    ///
    /// [`false`] if either `self` or `parent` is [`None`]. [`true`] if `parent` is
    ///  the parent of `self`. Otherwise [`false`].
    ///
    /// MT safe. Grabs and releases `self`'s locks.
    #[doc(alias = "gst_object_has_as_parent")]
    fn has_as_parent<P: IsA<Object>>(&self, parent: &P) -> bool;

    /// Removes the corresponding [`crate::ControlBinding`]. If it was the
    /// last ref of the binding, it will be disposed.
    /// ## `binding`
    /// the binding
    ///
    /// # Returns
    ///
    /// [`true`] if the binding could be removed.
    #[doc(alias = "gst_object_remove_control_binding")]
    fn remove_control_binding<P: IsA<ControlBinding>>(&self, binding: &P) -> bool;

    /// This function is used to disable the control bindings on a property for
    /// some time, i.e. [`Self::sync_values()`] will do nothing for the
    /// property.
    /// ## `property_name`
    /// property to disable
    /// ## `disabled`
    /// boolean that specifies whether to disable the controller
    /// or not.
    #[doc(alias = "gst_object_set_control_binding_disabled")]
    fn set_control_binding_disabled(&self, property_name: &str, disabled: bool);

    /// This function is used to disable all controlled properties of the `self` for
    /// some time, i.e. [`Self::sync_values()`] will do nothing.
    /// ## `disabled`
    /// boolean that specifies whether to disable the controller
    /// or not.
    #[doc(alias = "gst_object_set_control_bindings_disabled")]
    fn set_control_bindings_disabled(&self, disabled: bool);

    /// Change the control-rate for this `self`. Audio processing [`crate::Element`]
    /// objects will use this rate to sub-divide their processing loop and call
    /// [`Self::sync_values()`] in between. The length of the processing segment
    /// should be up to `control`-rate nanoseconds.
    ///
    /// The control-rate should not change if the element is in [`crate::State::Paused`] or
    /// [`crate::State::Playing`].
    /// ## `control_rate`
    /// the new control-rate in nanoseconds.
    #[doc(alias = "gst_object_set_control_rate")]
    fn set_control_rate(&self, control_rate: ClockTime);

    /// Sets the parent of `self` to `parent`. The object's reference count will
    /// be incremented, and any floating reference will be removed (see [`crate::Object::ref_sink()`]).
    /// ## `parent`
    /// new parent of object
    ///
    /// # Returns
    ///
    /// [`true`] if `parent` could be set or [`false`] when `self`
    /// already had a parent or `self` and `parent` are the same.
    ///
    /// MT safe. Grabs and releases `self`'s LOCK.
    #[doc(alias = "gst_object_set_parent")]
    fn set_parent<P: IsA<Object>>(&self, parent: &P) -> Result<(), glib::error::BoolError>;

    /// Returns a suggestion for timestamps where buffers should be split
    /// to get best controller results.
    ///
    /// # Returns
    ///
    /// Returns the suggested timestamp or `GST_CLOCK_TIME_NONE`
    /// if no control-rate was set.
    #[doc(alias = "gst_object_suggest_next_sync")]
    fn suggest_next_sync(&self) -> ClockTime;

    /// Sets the properties of the object, according to the `GstControlSources` that
    /// (maybe) handle them and for the given timestamp.
    ///
    /// If this function fails, it is most likely the application developers fault.
    /// Most probably the control sources are not setup correctly.
    /// ## `timestamp`
    /// the time that should be processed
    ///
    /// # Returns
    ///
    /// [`true`] if the controller values could be applied to the object
    /// properties, [`false`] otherwise
    #[doc(alias = "gst_object_sync_values")]
    fn sync_values(&self, timestamp: ClockTime) -> Result<(), glib::error::BoolError>;

    /// Clear the parent of `self`, removing the associated reference.
    /// This function decreases the refcount of `self`.
    ///
    /// MT safe. Grabs and releases `self`'s lock.
    #[doc(alias = "gst_object_unparent")]
    fn unparent(&self);

    //#[doc(alias = "deep-notify")]
    //fn connect_deep_notify<Unsupported or ignored types>(&self, detail: Option<&str>, f: F) -> SignalHandlerId;

    #[doc(alias = "parent")]
    fn connect_parent_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<Object>> GstObjectExt for O {
    fn add_control_binding<P: IsA<ControlBinding>>(
        &self,
        binding: &P,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_object_add_control_binding(
                    self.as_ref().to_glib_none().0,
                    binding.as_ref().to_glib_none().0
                ),
                "Failed to add control binding"
            )
        }
    }

    fn default_error(&self, error: &glib::Error, debug: Option<&str>) {
        unsafe {
            ffi::gst_object_default_error(
                self.as_ref().to_glib_none().0,
                error.to_glib_none().0,
                debug.to_glib_none().0,
            );
        }
    }

    fn control_binding(&self, property_name: &str) -> Option<ControlBinding> {
        unsafe {
            from_glib_full(ffi::gst_object_get_control_binding(
                self.as_ref().to_glib_none().0,
                property_name.to_glib_none().0,
            ))
        }
    }

    fn control_rate(&self) -> ClockTime {
        unsafe {
            from_glib(ffi::gst_object_get_control_rate(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn name(&self) -> glib::GString {
        unsafe { from_glib_full(ffi::gst_object_get_name(self.as_ref().to_glib_none().0)) }
    }

    fn parent(&self) -> Option<Object> {
        unsafe { from_glib_full(ffi::gst_object_get_parent(self.as_ref().to_glib_none().0)) }
    }

    fn path_string(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gst_object_get_path_string(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn value(&self, property_name: &str, timestamp: ClockTime) -> Option<glib::Value> {
        unsafe {
            from_glib_full(ffi::gst_object_get_value(
                self.as_ref().to_glib_none().0,
                property_name.to_glib_none().0,
                timestamp.into_glib(),
            ))
        }
    }

    //fn is_value_array(&self, property_name: &str, timestamp: ClockTime, interval: ClockTime, n_values: u32, values: /*Unimplemented*/Option<Fundamental: Pointer>) -> bool {
    //    unsafe { TODO: call ffi:gst_object_get_value_array() }
    //}

    fn has_active_control_bindings(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_object_has_active_control_bindings(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn has_ancestor<P: IsA<Object>>(&self, ancestor: &P) -> bool {
        unsafe {
            from_glib(ffi::gst_object_has_ancestor(
                self.as_ref().to_glib_none().0,
                ancestor.as_ref().to_glib_none().0,
            ))
        }
    }

    fn has_as_ancestor<P: IsA<Object>>(&self, ancestor: &P) -> bool {
        unsafe {
            from_glib(ffi::gst_object_has_as_ancestor(
                self.as_ref().to_glib_none().0,
                ancestor.as_ref().to_glib_none().0,
            ))
        }
    }

    fn has_as_parent<P: IsA<Object>>(&self, parent: &P) -> bool {
        unsafe {
            from_glib(ffi::gst_object_has_as_parent(
                self.as_ref().to_glib_none().0,
                parent.as_ref().to_glib_none().0,
            ))
        }
    }

    fn remove_control_binding<P: IsA<ControlBinding>>(&self, binding: &P) -> bool {
        unsafe {
            from_glib(ffi::gst_object_remove_control_binding(
                self.as_ref().to_glib_none().0,
                binding.as_ref().to_glib_none().0,
            ))
        }
    }

    fn set_control_binding_disabled(&self, property_name: &str, disabled: bool) {
        unsafe {
            ffi::gst_object_set_control_binding_disabled(
                self.as_ref().to_glib_none().0,
                property_name.to_glib_none().0,
                disabled.into_glib(),
            );
        }
    }

    fn set_control_bindings_disabled(&self, disabled: bool) {
        unsafe {
            ffi::gst_object_set_control_bindings_disabled(
                self.as_ref().to_glib_none().0,
                disabled.into_glib(),
            );
        }
    }

    fn set_control_rate(&self, control_rate: ClockTime) {
        unsafe {
            ffi::gst_object_set_control_rate(
                self.as_ref().to_glib_none().0,
                control_rate.into_glib(),
            );
        }
    }

    fn set_parent<P: IsA<Object>>(&self, parent: &P) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_object_set_parent(
                    self.as_ref().to_glib_none().0,
                    parent.as_ref().to_glib_none().0
                ),
                "Failed to set parent object"
            )
        }
    }

    fn suggest_next_sync(&self) -> ClockTime {
        unsafe {
            from_glib(ffi::gst_object_suggest_next_sync(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn sync_values(&self, timestamp: ClockTime) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_object_sync_values(self.as_ref().to_glib_none().0, timestamp.into_glib()),
                "Failed to sync values"
            )
        }
    }

    fn unparent(&self) {
        unsafe {
            ffi::gst_object_unparent(self.as_ref().to_glib_none().0);
        }
    }

    //#[doc(alias = "deep-notify")]
    //fn connect_deep_notify<Unsupported or ignored types>(&self, detail: Option<&str>, f: F) -> SignalHandlerId {
    //    Ignored prop: GObject.ParamSpec
    //}

    #[doc(alias = "parent")]
    fn connect_parent_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_parent_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
            this: *mut ffi::GstObject,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<Object>,
        {
            let f: &F = &*(f as *const F);
            f(&Object::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::parent\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_parent_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}