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
// 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::MetaContainer;
use crate::Timeline;
use crate::TrackElement;
use crate::TrackType;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
use glib::ToValue;
use std::boxed::Box as Box_;
use std::mem::transmute;
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
use std::ptr;

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
    /// `property::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 `property::TimelineElement::start` is reached by outputting
    /// its data for its `property::TimelineElement::duration`. Similarly, a
    /// [`Operation`][crate::Operation] would be activated by applying its effect to the source
    /// data, starting from its `property::TimelineElement::start` time and lasting for
    /// its `property::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.
    ///
    /// # 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 `property::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 `property::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 `property::Track::restriction-caps` and call
    /// `ges_track_set_create_element_for_gap_func()` on the returned track.
    /// ## `type_`
    /// The `property::Track::track-type` for the track
    /// ## `caps`
    /// The `property::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.to_glib_full())) }
    }
}

/// Trait containing all [`struct@Track`] methods.
///
/// # Implementors
///
/// [`AudioTrack`][struct@crate::AudioTrack], [`Track`][struct@crate::Track], [`VideoTrack`][struct@crate::VideoTrack]
pub trait GESTrackExt: '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>;

    /// 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(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_track_add_element_full")]
    fn add_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::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
    /// `signal::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;

    /// Get the `property::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>;

    /// Gets the track elements contained in the track. The returned list is
    /// sorted by the element's `property::TimelineElement::priority` and
    /// `property::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>;

    /// Gets the `property::Track::mixing` of the track.
    ///
    /// # Returns
    ///
    /// Whether `self` is mixing.
    #[doc(alias = "ges_track_get_mixing")]
    #[doc(alias = "get_mixing")]
    fn is_mixing(&self) -> bool;

    /// Gets the `property::Track::restriction-caps` of the track.
    ///
    /// # Returns
    ///
    /// The restriction-caps of `self`.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_track_get_restriction_caps")]
    #[doc(alias = "get_restriction_caps")]
    fn restriction_caps(&self) -> Option<gst::Caps>;

    /// 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>;

    /// 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>;

    /// 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(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_track_remove_element_full")]
    fn remove_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error>;

    //#[doc(alias = "ges_track_set_create_element_for_gap_func")]
    //fn set_create_element_for_gap_func<P: Fn(&Track) -> gst::Element + 'static>(&self, func: P);

    /// Sets the `property::Track::mixing` for the track.
    /// ## `mixing`
    /// Whether `self` should be mixing
    #[doc(alias = "ges_track_set_mixing")]
    fn set_mixing(&self, mixing: bool);

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

    /// 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>);

    /// Updates the `property::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 `property::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 `property::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 `property::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);

    /// Current duration of the track
    ///
    /// Default value: O
    fn duration(&self) -> u64;

    /// The `nlecomposition:id` of the underlying `nlecomposition`.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn id(&self) -> Option<glib::GString>;

    /// The `nlecomposition:id` of the underlying `nlecomposition`.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn set_id(&self, id: Option<&str>);

    /// 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
    /// `property::Track::caps`.
    ///
    /// Default value: `GST_CAPS_ANY`.
    #[doc(alias = "restriction-caps")]
    fn get_property_restriction_caps(&self) -> Option<gst::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 `property::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;

    /// 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;

    /// 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;

    /// 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;

    #[doc(alias = "duration")]
    fn connect_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "id")]
    fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "mixing")]
    fn connect_mixing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "restriction-caps")]
    fn connect_restriction_caps_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<Track>> GESTrackExt for O {
    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"
            )
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn add_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
        unsafe {
            let mut error = 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,
            );
            assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    fn commit(&self) -> bool {
        unsafe { from_glib(ffi::ges_track_commit(self.as_ref().to_glib_none().0)) }
    }

    fn caps(&self) -> Option<gst::Caps> {
        unsafe { from_glib_none(ffi::ges_track_get_caps(self.as_ref().to_glib_none().0)) }
    }

    fn elements(&self) -> Vec<TrackElement> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::ges_track_get_elements(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_mixing(&self) -> bool {
        unsafe { from_glib(ffi::ges_track_get_mixing(self.as_ref().to_glib_none().0)) }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn restriction_caps(&self) -> Option<gst::Caps> {
        unsafe {
            from_glib_full(ffi::ges_track_get_restriction_caps(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn timeline(&self) -> Option<Timeline> {
        unsafe { from_glib_none(ffi::ges_track_get_timeline(self.as_ref().to_glib_none().0)) }
    }

    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"
            )
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn remove_element_full(&self, object: &impl IsA<TrackElement>) -> Result<(), glib::Error> {
        unsafe {
            let mut error = 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,
            );
            assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    //fn set_create_element_for_gap_func<P: Fn(&Track) -> gst::Element + 'static>(&self, func: P) {
    //    unsafe { TODO: call ffi:ges_track_set_create_element_for_gap_func() }
    //}

    fn set_mixing(&self, mixing: bool) {
        unsafe {
            ffi::ges_track_set_mixing(self.as_ref().to_glib_none().0, mixing.into_glib());
        }
    }

    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,
            );
        }
    }

    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,
            );
        }
    }

    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,
            );
        }
    }

    fn duration(&self) -> u64 {
        glib::ObjectExt::property(self.as_ref(), "duration")
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn id(&self) -> Option<glib::GString> {
        glib::ObjectExt::property(self.as_ref(), "id")
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn set_id(&self, id: Option<&str>) {
        glib::ObjectExt::set_property(self.as_ref(), "id", &id)
    }

    fn get_property_restriction_caps(&self) -> Option<gst::Caps> {
        glib::ObjectExt::property(self.as_ref(), "restriction-caps")
    }

    fn track_type(&self) -> TrackType {
        glib::ObjectExt::property(self.as_ref(), "track-type")
    }

    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(transmute::<_, unsafe extern "C" fn()>(
                    commited_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    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(transmute::<_, unsafe extern "C" fn()>(
                    track_element_added_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    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(transmute::<_, unsafe extern "C" fn()>(
                    track_element_removed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    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(transmute::<_, unsafe extern "C" fn()>(
                    notify_duration_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    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(transmute::<_, unsafe extern "C" fn()>(
                    notify_id_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    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(transmute::<_, unsafe extern "C" fn()>(
                    notify_mixing_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    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(transmute::<_, unsafe extern "C" fn()>(
                    notify_restriction_caps_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}