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
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
// 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::{ffi, MetaContainer, Timeline, TrackElement, TrackType};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// A [`Track`][crate::Track] acts an output source for a [`Timeline`][crate::Timeline]. Each one
    /// essentially provides an additional [`gst::Pad`][crate::gst::Pad] for the timeline, with
    /// [`restriction-caps`][struct@crate::Track#restriction-caps] capabilities. Internally, a track
    /// wraps an `nlecomposition` filtered by a `capsfilter`.
    ///
    /// A track will contain a number of [`TrackElement`][crate::TrackElement]-s, and its role is
    /// to select and activate these elements according to their timings when
    /// the timeline in played. For example, a track would activate a
    /// [`Source`][crate::Source] when its [`start`][struct@crate::TimelineElement#start] is reached by outputting
    /// its data for its [`duration`][struct@crate::TimelineElement#duration]. Similarly, a
    /// [`Operation`][crate::Operation] would be activated by applying its effect to the source
    /// data, starting from its [`start`][struct@crate::TimelineElement#start] time and lasting for
    /// its [`duration`][struct@crate::TimelineElement#duration].
    ///
    /// For most users, it will usually be sufficient to add newly created
    /// tracks to a timeline, but never directly add an element to a track.
    /// Whenever a [`Clip`][crate::Clip] is added to a timeline, the clip adds its
    /// elements to the timeline's tracks and assumes responsibility for
    /// updating them.
    ///
    /// ## Properties
    ///
    ///
    /// #### `caps`
    ///  The capabilities used to choose the output of the [`Track`][crate::Track]'s
    /// elements. Internally, this is used to select output streams when
    /// several may be available, by determining whether its [`gst::Pad`][crate::gst::Pad] is
    /// compatible (see `NleObject:caps` for `nlecomposition`). As such,
    /// this is used as a weaker indication of the desired output type of the
    /// track, **before** the [`restriction-caps`][struct@crate::Track#restriction-caps] is applied.
    /// Therefore, this should be set to a *generic* superset of the
    /// [`restriction-caps`][struct@crate::Track#restriction-caps], such as "video/x-raw(ANY)". In addition,
    /// it should match with the track's [`track-type`][struct@crate::Track#track-type].
    ///
    /// Note that when you set this property, the `GstCapsFeatures` of all its
    /// [`gst::Structure`][crate::gst::Structure]-s will be automatically set to `GST_CAPS_FEATURES_ANY`.
    ///
    /// Once a track has been added to a [`Timeline`][crate::Timeline], you should not change
    /// this.
    ///
    /// Default value: `GST_CAPS_ANY`.
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `duration`
    ///  Current duration of the track
    ///
    /// Default value: O
    ///
    /// Readable
    ///
    ///
    /// #### `id`
    ///  The `nlecomposition:id` of the underlying `nlecomposition`.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `mixing`
    ///  Whether the track should support the mixing of [`Layer`][crate::Layer] data, such
    /// as composing the video data of each layer (when part of the video
    /// data is transparent, the next layer will become visible) or adding
    /// together the audio data. As such, for audio and video tracks, you'll
    /// likely want to keep this set to [`true`].
    ///
    /// Readable | Writeable | Construct
    ///
    ///
    /// #### `restriction-caps`
    ///  The capabilities that specifies the final output format of the
    /// [`Track`][crate::Track]. For example, for a video track, it would specify the
    /// height, width, framerate and other properties of the stream.
    ///
    /// You may change this property after the track has been added to a
    /// [`Timeline`][crate::Timeline], but it must remain compatible with the track's
    /// [`caps`][struct@crate::Track#caps].
    ///
    /// Default value: `GST_CAPS_ANY`.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `track-type`
    ///  The track type of the track. This controls the type of
    /// [`TrackElement`][crate::TrackElement]-s that can be added to the track. This should
    /// match with the track's [`caps`][struct@crate::Track#caps].
    ///
    /// Once a track has been added to a [`Timeline`][crate::Timeline], you should not change
    /// this.
    ///
    /// Readable | Writeable | Construct Only
    /// <details><summary><h4>Bin</h4></summary>
    ///
    ///
    /// #### `async-handling`
    ///  If set to [`true`], the bin will handle asynchronous state changes.
    /// This should be used only if the bin subclass is modifying the state
    /// of its children on its own.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `message-forward`
    ///  Forward all children messages, even those that would normally be filtered by
    /// the bin. This can be interesting when one wants to be notified of the EOS
    /// state of individual elements, for example.
    ///
    /// The messages are converted to an ELEMENT message with the bin as the
    /// source. The structure of the message is named `GstBinForwarded` and contains
    /// a field named `message` that contains the original forwarded `GstMessage`.
    ///
    /// Readable | Writeable
    /// </details>
    /// <details><summary><h4>Object</h4></summary>
    ///
    ///
    /// #### `name`
    ///  Readable | Writeable | Construct
    ///
    ///
    /// #### `parent`
    ///  The parent of the object. Please note, that when changing the 'parent'
    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
    /// signals due to locking issues. In some cases one can use
    /// [`element-added`][struct@crate::gst::Bin#element-added] or [`element-removed`][struct@crate::gst::Bin#element-removed] signals on the parent to
    /// achieve a similar effect.
    ///
    /// Readable | Writeable
    /// </details>
    ///
    /// ## Signals
    ///
    ///
    /// #### `commited`
    ///  This signal will be emitted once the changes initiated by
    /// [`GESTrackExt::commit()`][crate::prelude::GESTrackExt::commit()] have been executed in the backend. In particular,
    /// this will be emitted whenever the underlying `nlecomposition` has been
    /// committed (see `nlecomposition::commited`).
    ///
    ///
    ///
    ///
    /// #### `track-element-added`
    ///  Will be emitted after a track element is added to the track.
    ///
    ///
    ///
    ///
    /// #### `track-element-removed`
    ///  Will be emitted after a track element is removed from the track.
    ///
    ///
    /// <details><summary><h4>Bin</h4></summary>
    ///
    ///
    /// #### `deep-element-added`
    ///  Will be emitted after the element was added to `sub_bin`.
    ///
    ///
    ///
    ///
    /// #### `deep-element-removed`
    ///  Will be emitted after the element was removed from `sub_bin`.
    ///
    ///
    ///
    ///
    /// #### `do-latency`
    ///  Will be emitted when the bin needs to perform latency calculations. This
    /// signal is only emitted for toplevel bins or when [`async-handling`][struct@crate::gst::Bin#async-handling] is
    /// enabled.
    ///
    /// Only one signal handler is invoked. If no signals are connected, the
    /// default handler is invoked, which will query and distribute the lowest
    /// possible latency to all sinks.
    ///
    /// Connect to this signal if the default latency calculations are not
    /// sufficient, like when you need different latencies for different sinks in
    /// the same pipeline.
    ///
    ///
    ///
    ///
    /// #### `element-added`
    ///  Will be emitted after the element was added to the bin.
    ///
    ///
    ///
    ///
    /// #### `element-removed`
    ///  Will be emitted after the element was removed from the bin.
    ///
    ///
    /// </details>
    /// <details><summary><h4>Element</h4></summary>
    ///
    ///
    /// #### `no-more-pads`
    ///  This signals that the element will not generate more dynamic pads.
    /// Note that this signal will usually be emitted from the context of
    /// the streaming thread.
    ///
    ///
    ///
    ///
    /// #### `pad-added`
    ///  a new [`gst::Pad`][crate::gst::Pad] has been added to the element. Note that this signal will
    /// usually be emitted from the context of the streaming thread. Also keep in
    /// mind that if you add new elements to the pipeline in the signal handler
    /// you will need to set them to the desired target state with
    /// [`ElementExtManual::set_state()`][crate::gst::prelude::ElementExtManual::set_state()] or [`ElementExtManual::sync_state_with_parent()`][crate::gst::prelude::ElementExtManual::sync_state_with_parent()].
    ///
    ///
    ///
    ///
    /// #### `pad-removed`
    ///  a [`gst::Pad`][crate::gst::Pad] has been removed from the element
    ///
    ///
    /// </details>
    /// <details><summary><h4>Object</h4></summary>
    ///
    ///
    /// #### `deep-notify`
    ///  The deep notify signal is used to be notified of property changes. It is
    /// typically attached to the toplevel bin to receive notifications from all
    /// the elements contained in that bin.
    ///
    /// Detailed
    /// </details>
    /// <details><summary><h4>ChildProxy</h4></summary>
    ///
    ///
    /// #### `child-added`
    ///  Will be emitted after the `object` was added to the `child_proxy`.
    ///
    ///
    ///
    ///
    /// #### `child-removed`
    ///  Will be emitted after the `object` was removed from the `child_proxy`.
    ///
    ///
    /// </details>
    /// <details><summary><h4>MetaContainer</h4></summary>
    ///
    ///
    /// #### `notify-meta`
    ///  This is emitted for a meta container whenever the metadata under one
    /// of its fields changes, is set for the first time, or is removed. In
    /// the latter case, `value` will be [`None`].
    ///
    /// Detailed
    /// </details>
    ///
    /// # Implements
    ///
    /// [`GESTrackExt`][trait@crate::prelude::GESTrackExt], [`trait@gst::prelude::BinExt`], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::GstObjectExt`], [`trait@glib::ObjectExt`], [`trait@gst::prelude::ChildProxyExt`], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt]
    #[doc(alias = "GESTrack")]
    pub struct Track(Object<ffi::GESTrack, ffi::GESTrackClass>) @extends gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy, MetaContainer;

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

impl Track {
    pub const NONE: Option<&'static Track> = None;

    /// Creates a new track with the given track-type and caps.
    ///
    /// If `type_` is [`TrackType::VIDEO`][crate::TrackType::VIDEO], and `caps` is a subset of
    /// "video/x-raw(ANY)", then a [`VideoTrack`][crate::VideoTrack] is created. This will
    /// automatically choose a gap creation method suitable for video data. You
    /// will likely want to set [`restriction-caps`][struct@crate::Track#restriction-caps] separately. You may
    /// prefer to use the [`VideoTrack::new()`][crate::VideoTrack::new()] method instead.
    ///
    /// If `type_` is [`TrackType::AUDIO`][crate::TrackType::AUDIO], and `caps` is a subset of
    /// "audio/x-raw(ANY)", then a [`AudioTrack`][crate::AudioTrack] is created. This will
    /// automatically choose a gap creation method suitable for audio data, and
    /// will set the [`restriction-caps`][struct@crate::Track#restriction-caps] to the default for
    /// [`AudioTrack`][crate::AudioTrack]. You may prefer to use the [`AudioTrack::new()`][crate::AudioTrack::new()] method
    /// instead.
    ///
    /// Otherwise, a plain [`Track`][crate::Track] is returned. You will likely want to set
    /// the [`restriction-caps`][struct@crate::Track#restriction-caps] and call
    /// `ges_track_set_create_element_for_gap_func()` on the returned track.
    /// ## `type_`
    /// The [`track-type`][struct@crate::Track#track-type] for the track
    /// ## `caps`
    /// The [`caps`][struct@crate::Track#caps] for the track
    ///
    /// # Returns
    ///
    /// A new track.
    #[doc(alias = "ges_track_new")]
    pub fn new(type_: TrackType, caps: gst::Caps) -> Track {
        assert_initialized_main_thread!();
        unsafe { from_glib_none(ffi::ges_track_new(type_.into_glib(), caps.into_glib_ptr())) }
    }
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::Track>> Sealed for T {}
}

/// Trait containing all [`struct@Track`] methods.
///
/// # Implementors
///
/// [`AudioTrack`][struct@crate::AudioTrack], [`Track`][struct@crate::Track], [`VideoTrack`][struct@crate::VideoTrack]
pub trait GESTrackExt: IsA<Track> + sealed::Sealed + 'static {
    /// See [`add_element()`][Self::add_element()], which also gives an error.
    /// ## `object`
    /// The element to add
    ///
    /// # Returns
    ///
    /// [`true`] if `object` was successfully added to `self`.
    #[doc(alias = "ges_track_add_element")]
    fn add_element(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_track_add_element(
                    self.as_ref().to_glib_none().0,
                    object.as_ref().to_glib_none().0
                ),
                "Failed to add element"
            )
        }
    }

    /// Adds the given track element to the track, which takes ownership of the
    /// element.
    ///
    /// Note that this can fail if it would break a configuration rule of the
    /// track's [`Timeline`][crate::Timeline].
    ///
    /// Note that a [`TrackElement`][crate::TrackElement] can only be added to one track.
    /// ## `object`
    /// The element to add
    ///
    /// # Returns
    ///
    /// [`true`] if `object` was successfully added to `self`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_track_add_element_full")]
    fn add_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::ges_track_add_element_full(
                self.as_ref().to_glib_none().0,
                object.as_ref().to_glib_none().0,
                &mut error,
            );
            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Commits all the pending changes for the elements contained in the
    /// track.
    ///
    /// When changes are made to the timing or priority of elements within a
    /// track, they are not directly executed for the underlying
    /// `nlecomposition` and its children. This method will finally execute
    /// these changes so they are reflected in the data output of the track.
    ///
    /// Any pending changes will be executed in the backend. The
    /// [`commited`][struct@crate::Timeline#commited] signal will be emitted once this has completed.
    ///
    /// Note that [`TimelineExt::commit()`][crate::prelude::TimelineExt::commit()] will call this method on all of its
    /// tracks, so you are unlikely to need to use this directly.
    ///
    /// # Returns
    ///
    /// [`true`] if pending changes were committed, or [`false`] if nothing
    /// needed to be committed.
    #[doc(alias = "ges_track_commit")]
    fn commit(&self) -> bool {
        unsafe { from_glib(ffi::ges_track_commit(self.as_ref().to_glib_none().0)) }
    }

    /// Get the [`caps`][struct@crate::Track#caps] of the track.
    ///
    /// # Returns
    ///
    /// The caps of `self`.
    #[doc(alias = "ges_track_get_caps")]
    #[doc(alias = "get_caps")]
    fn caps(&self) -> Option<gst::Caps> {
        unsafe { from_glib_none(ffi::ges_track_get_caps(self.as_ref().to_glib_none().0)) }
    }

    /// Gets the track elements contained in the track. The returned list is
    /// sorted by the element's [`priority`][struct@crate::TimelineElement#priority] and
    /// [`start`][struct@crate::TimelineElement#start].
    ///
    /// # Returns
    ///
    /// A list of
    /// all the [`TrackElement`][crate::TrackElement]-s in `self`.
    #[doc(alias = "ges_track_get_elements")]
    #[doc(alias = "get_elements")]
    fn elements(&self) -> Vec<TrackElement> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::ges_track_get_elements(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the [`mixing`][struct@crate::Track#mixing] of the track.
    ///
    /// # Returns
    ///
    /// Whether `self` is mixing.
    #[doc(alias = "ges_track_get_mixing")]
    #[doc(alias = "get_mixing")]
    #[doc(alias = "mixing")]
    fn is_mixing(&self) -> bool {
        unsafe { from_glib(ffi::ges_track_get_mixing(self.as_ref().to_glib_none().0)) }
    }

    /// Gets the [`restriction-caps`][struct@crate::Track#restriction-caps] of the track.
    ///
    /// # Returns
    ///
    /// The restriction-caps of `self`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_track_get_restriction_caps")]
    #[doc(alias = "get_restriction_caps")]
    #[doc(alias = "restriction-caps")]
    fn restriction_caps(&self) -> Option<gst::Caps> {
        unsafe {
            from_glib_full(ffi::ges_track_get_restriction_caps(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the timeline this track belongs to.
    ///
    /// # Returns
    ///
    /// The timeline that `self` belongs to, or [`None`] if
    /// it does not belong to a timeline.
    #[doc(alias = "ges_track_get_timeline")]
    #[doc(alias = "get_timeline")]
    fn timeline(&self) -> Option<Timeline> {
        unsafe { from_glib_none(ffi::ges_track_get_timeline(self.as_ref().to_glib_none().0)) }
    }

    /// See [`remove_element_full()`][Self::remove_element_full()], which also returns an error.
    /// ## `object`
    /// The element to remove
    ///
    /// # Returns
    ///
    /// [`true`] if `object` was successfully removed from `self`.
    #[doc(alias = "ges_track_remove_element")]
    fn remove_element(
        &self,
        object: &impl IsA<TrackElement>,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_track_remove_element(
                    self.as_ref().to_glib_none().0,
                    object.as_ref().to_glib_none().0
                ),
                "Failed to remove element"
            )
        }
    }

    /// Removes the given track element from the track, which revokes
    /// ownership of the element.
    /// ## `object`
    /// The element to remove
    ///
    /// # Returns
    ///
    /// [`true`] if `object` was successfully removed from `self`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_track_remove_element_full")]
    fn remove_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::ges_track_remove_element_full(
                self.as_ref().to_glib_none().0,
                object.as_ref().to_glib_none().0,
                &mut error,
            );
            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    //#[doc(alias = "ges_track_set_create_element_for_gap_func")]
    //fn set_create_element_for_gap_func<P: Fn() -> gst::Element + 'static>(&self, func: P) {
    //    unsafe { TODO: call ffi:ges_track_set_create_element_for_gap_func() }
    //}

    /// Sets the [`mixing`][struct@crate::Track#mixing] for the track.
    /// ## `mixing`
    /// Whether `self` should be mixing
    #[doc(alias = "ges_track_set_mixing")]
    #[doc(alias = "mixing")]
    fn set_mixing(&self, mixing: bool) {
        unsafe {
            ffi::ges_track_set_mixing(self.as_ref().to_glib_none().0, mixing.into_glib());
        }
    }

    /// Sets the [`restriction-caps`][struct@crate::Track#restriction-caps] for the track.
    ///
    /// > **NOTE**: Restriction caps are **not** taken into account when
    /// > using [`mode`][struct@crate::Pipeline#mode]=[`PipelineFlags::SMART_RENDER`][crate::PipelineFlags::SMART_RENDER].
    /// ## `caps`
    /// The new restriction-caps for `self`
    #[doc(alias = "ges_track_set_restriction_caps")]
    #[doc(alias = "restriction-caps")]
    fn set_restriction_caps(&self, caps: &gst::Caps) {
        unsafe {
            ffi::ges_track_set_restriction_caps(
                self.as_ref().to_glib_none().0,
                caps.to_glib_none().0,
            );
        }
    }

    /// Informs the track that it belongs to the given timeline. Calling this
    /// does not actually add the track to the timeline. For that, you should
    /// use [`TimelineExt::add_track()`][crate::prelude::TimelineExt::add_track()], which will also take care of informing
    /// the track that it belongs to the timeline. As such, there is no need
    /// for you to call this method.
    #[doc(alias = "ges_track_set_timeline")]
    fn set_timeline(&self, timeline: &impl IsA<Timeline>) {
        unsafe {
            ffi::ges_track_set_timeline(
                self.as_ref().to_glib_none().0,
                timeline.as_ref().to_glib_none().0,
            );
        }
    }

    /// Updates the [`restriction-caps`][struct@crate::Track#restriction-caps] of the track using the fields
    /// found in the given caps. Each of the [`gst::Structure`][crate::gst::Structure]-s in `caps` is
    /// compared against the existing structure with the same index in the
    /// current [`restriction-caps`][struct@crate::Track#restriction-caps]. If there is no corresponding
    /// existing structure at that index, then the new structure is simply
    /// copied to that index. Otherwise, any fields in the new structure are
    /// copied into the existing structure. This will replace existing values,
    /// and may introduce new ones, but any fields 'missing' in the new
    /// structure are left unchanged in the existing structure.
    ///
    /// For example, if the existing [`restriction-caps`][struct@crate::Track#restriction-caps] are
    /// "video/x-raw, width=480, height=360", and the updating caps is
    /// "video/x-raw, format=I420, width=500; video/x-bayer, width=400", then
    /// the new [`restriction-caps`][struct@crate::Track#restriction-caps] after calling this will be
    /// "video/x-raw, width=500, height=360, format=I420; video/x-bayer,
    /// width=400".
    /// ## `caps`
    /// The caps to update the restriction-caps with
    #[doc(alias = "ges_track_update_restriction_caps")]
    fn update_restriction_caps(&self, caps: &gst::Caps) {
        unsafe {
            ffi::ges_track_update_restriction_caps(
                self.as_ref().to_glib_none().0,
                caps.to_glib_none().0,
            );
        }
    }

    /// Current duration of the track
    ///
    /// Default value: O
    fn duration(&self) -> u64 {
        ObjectExt::property(self.as_ref(), "duration")
    }

    /// The `nlecomposition:id` of the underlying `nlecomposition`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    fn id(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "id")
    }

    /// The `nlecomposition:id` of the underlying `nlecomposition`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    fn set_id(&self, id: Option<&str>) {
        ObjectExt::set_property(self.as_ref(), "id", id)
    }

    #[cfg(not(feature = "v1_18"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_18"))))]
    #[doc(alias = "restriction-caps")]
    fn restriction_caps(&self) -> Option<gst::Caps> {
        ObjectExt::property(self.as_ref(), "restriction-caps")
    }

    /// The track type of the track. This controls the type of
    /// [`TrackElement`][crate::TrackElement]-s that can be added to the track. This should
    /// match with the track's [`caps`][struct@crate::Track#caps].
    ///
    /// Once a track has been added to a [`Timeline`][crate::Timeline], you should not change
    /// this.
    #[doc(alias = "track-type")]
    fn track_type(&self) -> TrackType {
        ObjectExt::property(self.as_ref(), "track-type")
    }

    /// This signal will be emitted once the changes initiated by
    /// [`commit()`][Self::commit()] have been executed in the backend. In particular,
    /// this will be emitted whenever the underlying `nlecomposition` has been
    /// committed (see `nlecomposition::commited`).
    #[doc(alias = "commited")]
    fn connect_commited<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn commited_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
            this: *mut ffi::GESTrack,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Track::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"commited\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    commited_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// Will be emitted after a track element is added to the track.
    /// ## `effect`
    /// The element that was added
    #[doc(alias = "track-element-added")]
    fn connect_track_element_added<F: Fn(&Self, &TrackElement) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn track_element_added_trampoline<
            P: IsA<Track>,
            F: Fn(&P, &TrackElement) + 'static,
        >(
            this: *mut ffi::GESTrack,
            effect: *mut ffi::GESTrackElement,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                Track::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(effect),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"track-element-added\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    track_element_added_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// Will be emitted after a track element is removed from the track.
    /// ## `effect`
    /// The element that was removed
    #[doc(alias = "track-element-removed")]
    fn connect_track_element_removed<F: Fn(&Self, &TrackElement) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn track_element_removed_trampoline<
            P: IsA<Track>,
            F: Fn(&P, &TrackElement) + 'static,
        >(
            this: *mut ffi::GESTrack,
            effect: *mut ffi::GESTrackElement,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                Track::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(effect),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"track-element-removed\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    track_element_removed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "duration")]
    fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_duration_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
            this: *mut ffi::GESTrack,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Track::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::duration\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_duration_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "id")]
    fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_id_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
            this: *mut ffi::GESTrack,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Track::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::id\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_id_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "mixing")]
    fn connect_mixing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_mixing_trampoline<P: IsA<Track>, F: Fn(&P) + 'static>(
            this: *mut ffi::GESTrack,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Track::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::mixing\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_mixing_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "restriction-caps")]
    fn connect_restriction_caps_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_restriction_caps_trampoline<
            P: IsA<Track>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GESTrack,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Track::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::restriction-caps\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_restriction_caps_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<Track>> GESTrackExt for O {}