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
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
// 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

#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
use crate::FrameNumber;
use crate::{
    ffi, Asset, BaseEffect, Container, Extractable, Layer, MetaContainer, TimelineElement, Track,
    TrackElement, TrackType,
};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// [`Clip`][crate::Clip]-s are the core objects of a [`Layer`][crate::Layer]. Each clip may exist in
    /// a single layer but may control several [`TrackElement`][crate::TrackElement]-s that span
    /// several [`Track`][crate::Track]-s. A clip will ensure that all its children share the
    /// same [`start`][struct@crate::TimelineElement#start] and [`duration`][struct@crate::TimelineElement#duration] in
    /// their tracks, which will match the [`start`][struct@crate::TimelineElement#start] and
    /// [`duration`][struct@crate::TimelineElement#duration] of the clip itself. Therefore, changing
    /// the timing of the clip will change the timing of the children, and a
    /// change in the timing of a child will change the timing of the clip and
    /// subsequently all its siblings. As such, a clip can be treated as a
    /// singular object in its layer.
    ///
    /// For most uses of a [`Timeline`][crate::Timeline], it is often sufficient to only
    /// interact with [`Clip`][crate::Clip]-s directly, which will take care of creating and
    /// organising the elements of the timeline's tracks.
    ///
    /// ## Core Children
    ///
    /// In more detail, clips will usually have some *core* [`TrackElement`][crate::TrackElement]
    /// children, which are created by the clip when it is added to a layer in
    /// a timeline. The type and form of these core children will depend on the
    /// clip's subclass. You can use [`TrackElementExt::is_core()`][crate::prelude::TrackElementExt::is_core()] to determine
    /// whether a track element is considered such a core track element. Note,
    /// if a core track element is part of a clip, it will always be treated as
    /// a core *child* of the clip. You can connect to the
    /// [`child-added`][struct@crate::Container#child-added] signal to be notified of their creation.
    ///
    /// When a child is added to a clip, the timeline will select its tracks
    /// using [`select-tracks-for-object`][struct@crate::Timeline#select-tracks-for-object]. Note that it may be the
    /// case that the child will still have no set [`track`][struct@crate::TrackElement#track]
    /// after this process. For example, if the timeline does not have a track
    /// of the corresponding [`track-type`][struct@crate::Track#track-type]. A clip can safely contain
    /// such children, which may have their track set later, although they will
    /// play no functioning role in the timeline in the meantime.
    ///
    /// If a clip may create track elements with various
    /// [`track-type`][struct@crate::TrackElement#track-type](s), such as a [`UriClip`][crate::UriClip], but you only
    /// want it to create a subset of these types, you should set the
    /// [`supported-formats`][struct@crate::Clip#supported-formats] of the clip to the subset of types. This
    /// should be done *before* adding the clip to a layer.
    ///
    /// If a clip will produce several core elements of the same
    /// [`track-type`][struct@crate::TrackElement#track-type], you should connect to the timeline's
    /// [`select-tracks-for-object`][struct@crate::Timeline#select-tracks-for-object] signal to coordinate which
    /// tracks each element should land in. Note, no two core children within a
    /// clip can share the same [`Track`][crate::Track], so you should not select the same
    /// track for two separate core children. Provided you stick to this rule,
    /// it is still safe to select several tracks for the same core child, the
    /// core child will be copied into the additional tracks. You can manually
    /// add the child to more tracks later using [`ClipExt::add_child_to_track()`][crate::prelude::ClipExt::add_child_to_track()].
    /// If you do not wish to use a core child, you can always select no track.
    ///
    /// The [`in-point`][struct@crate::TimelineElement#in-point] of the clip will control the
    /// [`in-point`][struct@crate::TimelineElement#in-point] of its core children to be the same
    /// value if their [`has-internal-source`][struct@crate::TrackElement#has-internal-source] is set to [`true`].
    ///
    /// The [`max-duration`][struct@crate::TimelineElement#max-duration] of the clip is the minimum
    /// [`max-duration`][struct@crate::TimelineElement#max-duration] of its core children. If you set its
    /// value to anything other than its current value, this will also set the
    /// [`max-duration`][struct@crate::TimelineElement#max-duration] of all its core children to the same
    /// value if their [`has-internal-source`][struct@crate::TrackElement#has-internal-source] is set to [`true`].
    /// As a special case, whilst a clip does not yet have any core children,
    /// its [`max-duration`][struct@crate::TimelineElement#max-duration] may be set to indicate what its
    /// value will be once they are created.
    ///
    /// ## Effects
    ///
    /// Some subclasses ([`SourceClip`][crate::SourceClip] and [`BaseEffectClip`][crate::BaseEffectClip]) may also allow
    /// their objects to have additional non-core [`BaseEffect`][crate::BaseEffect]-s elements as
    /// children. These are additional effects that are applied to the output
    /// data of the core elements. They can be added to the clip using
    /// [`ClipExt::add_top_effect()`][crate::prelude::ClipExt::add_top_effect()], which will take care of adding the effect to
    /// the timeline's tracks. The new effect will be placed between the clip's
    /// core track elements and its other effects. As such, the newly added
    /// effect will be applied to any source data **before** the other existing
    /// effects. You can change the ordering of effects using
    /// [`ClipExt::set_top_effect_index()`][crate::prelude::ClipExt::set_top_effect_index()].
    ///
    /// Tracks are selected for top effects in the same way as core children.
    /// If you add a top effect to a clip before it is part of a timeline, and
    /// later add the clip to a timeline, the track selection for the top
    /// effects will occur just after the track selection for the core
    /// children. If you add a top effect to a clip that is already part of a
    /// timeline, the track selection will occur immediately. Since a top
    /// effect must be applied on top of a core child, if you use
    /// [`select-tracks-for-object`][struct@crate::Timeline#select-tracks-for-object], you should ensure that the
    /// added effects are destined for a [`Track`][crate::Track] that already contains a core
    /// child.
    ///
    /// In addition, if the core child in the track is not
    /// [`active`][struct@crate::TrackElement#active], then neither can any of its effects be
    /// [`active`][struct@crate::TrackElement#active]. Therefore, if a core child is made in-active,
    /// all of the additional effects in the same track will also become
    /// in-active. Similarly, if an effect is set to be active, then the core
    /// child will also become active, but other effects will be left alone.
    /// Finally, if an active effect is added to the track of an in-active core
    /// child, it will become in-active as well. Note, in contrast, setting a
    /// core child to be active, or an effect to be in-active will *not* change
    /// the other children in the same track.
    ///
    /// ### Time Effects
    ///
    /// Some effects also change the timing of their data (see [`BaseEffect`][crate::BaseEffect]
    /// for what counts as a time effect). Note that a [`BaseEffectClip`][crate::BaseEffectClip] will
    /// refuse time effects, but a [`Source`][crate::Source] will allow them.
    ///
    /// When added to a clip, time effects may adjust the timing of other
    /// children in the same track. Similarly, when changing the order of
    /// effects, making them (in)-active, setting their time property values
    /// or removing time effects. These can cause the [`duration-limit`][struct@crate::Clip#duration-limit]
    /// to change in value. However, if such an operation would ever cause the
    /// [`duration`][struct@crate::TimelineElement#duration] to shrink such that a clip's [`Source`][crate::Source] is
    /// totally overlapped in the timeline, the operation would be prevented.
    /// Note that the same can happen when adding non-time effects with a
    /// finite [`max-duration`][struct@crate::TimelineElement#max-duration].
    ///
    /// Therefore, when working with time effects, you should -- more so than
    /// usual -- not assume that setting the properties of the clip's children
    /// will succeed. In particular, you should use
    /// [`TimelineElementExt::set_child_property_full()`][crate::prelude::TimelineElementExt::set_child_property_full()] when setting the time
    /// properties.
    ///
    /// If you wish to preserve the *internal* duration of a source in a clip
    /// during these time effect operations, you can do something like the
    /// following.
    ///
    /// **⚠️ The following code is in c ⚠️**
    ///
    /// ```c
    /// void
    /// do_time_effect_change (GESClip * clip)
    /// {
    ///   GList *tmp, *children;
    ///   GESTrackElement *source;
    ///   GstClockTime source_outpoint;
    ///   GstClockTime new_end;
    ///   GError *error = NULL;
    ///
    ///   // choose some active source in a track to preserve the internal
    ///   // duration of
    ///   source = ges_clip_get_track_element (clip, NULL, GES_TYPE_SOURCE);
    ///
    ///   // note its current internal end time
    ///   source_outpoint = ges_clip_get_internal_time_from_timeline_time (
    ///         clip, source, GES_TIMELINE_ELEMENT_END (clip), NULL);
    ///
    ///   // handle invalid out-point
    ///
    ///   // stop the children's control sources from clamping when their
    ///   // out-point changes with a change in the time effects
    ///   children = ges_container_get_children (GES_CONTAINER (clip), FALSE);
    ///
    ///   for (tmp = children; tmp; tmp = tmp->next)
    ///     ges_track_element_set_auto_clamp_control_sources (tmp->data, FALSE);
    ///
    ///   // add time effect, or set their children properties, or move them around
    ///   ...
    ///   // user can make sure that if a time effect changes one source, we should
    ///   // also change the time effect for another source. E.g. if
    ///   // "GstVideorate::rate" is set to 2.0, we also set "GstPitch::rate" to
    ///   // 2.0
    ///
    ///   // Note the duration of the clip may have already changed if the
    ///   // duration-limit of the clip dropped below its current value
    ///
    ///   new_end = ges_clip_get_timeline_time_from_internal_time (
    ///         clip, source, source_outpoint, &error);
    ///   // handle error
    ///
    ///   if (!ges_timeline_elemnet_edit_full (GES_TIMELINE_ELEMENT (clip),
    ///         -1, GES_EDIT_MODE_TRIM, GES_EDGE_END, new_end, &error))
    ///     // handle error
    ///
    ///   for (tmp = children; tmp; tmp = tmp->next)
    ///     ges_track_element_set_auto_clamp_control_sources (tmp->data, TRUE);
    ///
    ///   g_list_free_full (children, gst_object_unref);
    ///   gst_object_unref (source);
    /// }
    /// ```
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// ## Properties
    ///
    ///
    /// #### `duration-limit`
    ///  The maximum [`duration`][struct@crate::TimelineElement#duration] that can be *currently* set
    /// for the clip, taking into account the [`in-point`][struct@crate::TimelineElement#in-point],
    /// [`max-duration`][struct@crate::TimelineElement#max-duration], [`active`][struct@crate::TrackElement#active], and
    /// [`track`][struct@crate::TrackElement#track] properties of its children, as well as any
    /// time effects. If there is no limit, this will be set to
    /// `GST_CLOCK_TIME_NONE`.
    ///
    /// Note that whilst a clip has no children in any tracks, the limit will
    /// be unknown, and similarly set to `GST_CLOCK_TIME_NONE`.
    ///
    /// If the duration-limit would ever go below the current
    /// [`duration`][struct@crate::TimelineElement#duration] of the clip due to a change in the above
    /// variables, its [`duration`][struct@crate::TimelineElement#duration] will be set to the new
    /// limit.
    ///
    /// Readable
    ///
    ///
    /// #### `layer`
    ///  The layer this clip lies in.
    ///
    /// If you want to connect to this property's [`notify`][struct@crate::glib::Object#notify] signal,
    /// you should connect to it with `g_signal_connect_after()` since the
    /// signal emission may be stopped internally.
    ///
    /// Readable
    ///
    ///
    /// #### `supported-formats`
    ///  The [`TrackType`][crate::TrackType]-s that the clip supports, which it can create
    /// [`TrackElement`][crate::TrackElement]-s for. Note that this can be a combination of
    /// [`TrackType`][crate::TrackType] flags to indicate support for several
    /// [`track-type`][struct@crate::TrackElement#track-type] elements.
    ///
    /// Readable | Writeable | Construct
    /// <details><summary><h4>Container</h4></summary>
    ///
    ///
    /// #### `height`
    ///  The span of the container's children's [`priority`][struct@crate::TimelineElement#priority]
    /// values, which is the number of integers that lie between (inclusive)
    /// the minimum and maximum priorities found amongst the container's
    /// children (maximum - minimum + 1).
    ///
    /// Readable
    /// </details>
    /// <details><summary><h4>TimelineElement</h4></summary>
    ///
    ///
    /// #### `duration`
    ///  The duration that the element is in effect for in the timeline (a
    /// time difference in nanoseconds using the time coordinates of the
    /// timeline). For example, for a source element, this would determine
    /// for how long it should output its internal content for. For an
    /// operation element, this would determine for how long its effect
    /// should be applied to any source content.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `in-point`
    ///  The initial offset to use internally when outputting content (in
    /// nanoseconds, but in the time coordinates of the internal content).
    ///
    /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
    /// file, the "internal content" is the media file data, and the
    /// in-point would correspond to some timestamp in the media file.
    /// When playing the timeline, and when the element is first reached at
    /// timeline-time [`start`][struct@crate::TimelineElement#start], it will begin outputting the
    /// data from the timestamp in-point **onwards**, until it reaches the
    /// end of its [`duration`][struct@crate::TimelineElement#duration] in the timeline.
    ///
    /// For elements that have no internal content, this should be kept
    /// as 0.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `max-duration`
    ///  The full duration of internal content that is available (a time
    /// difference in nanoseconds using the time coordinates of the internal
    /// content).
    ///
    /// This will act as a cap on the [`in-point`][struct@crate::TimelineElement#in-point] of the
    /// element (which is in the same time coordinates), and will sometimes
    /// be used to limit the [`duration`][struct@crate::TimelineElement#duration] of the element in
    /// the timeline.
    ///
    /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
    /// file, this would be the length of the media file.
    ///
    /// For elements that have no internal content, or whose content is
    /// indefinite, this should be kept as `GST_CLOCK_TIME_NONE`.
    ///
    /// Readable | Writeable | Construct
    ///
    ///
    /// #### `name`
    ///  The name of the element. This should be unique within its timeline.
    ///
    /// Readable | Writeable | Construct
    ///
    ///
    /// #### `parent`
    ///  The parent container of the element.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `priority`
    ///  The priority of the element.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `serialize`
    ///  Whether the element should be serialized.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `start`
    ///  The starting position of the element in the timeline (in nanoseconds
    /// and in the time coordinates of the timeline). For example, for a
    /// source element, this would determine the time at which it should
    /// start outputting its internal content. For an operation element, this
    /// would determine the time at which it should start applying its effect
    /// to any source content.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `timeline`
    ///  The timeline that the element lies within.
    ///
    /// Readable | Writeable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`ClipExt`][trait@crate::prelude::ClipExt], [`GESContainerExt`][trait@crate::prelude::GESContainerExt], [`TimelineElementExt`][trait@crate::prelude::TimelineElementExt], [`trait@glib::ObjectExt`], [`ExtractableExt`][trait@crate::prelude::ExtractableExt], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt], [`TimelineElementExtManual`][trait@crate::prelude::TimelineElementExtManual]
    #[doc(alias = "GESClip")]
    pub struct Clip(Object<ffi::GESClip, ffi::GESClipClass>) @extends Container, TimelineElement, @implements Extractable, MetaContainer;

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

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

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

/// Trait containing all [`struct@Clip`] methods.
///
/// # Implementors
///
/// [`Clip`][struct@crate::Clip], [`OperationClip`][struct@crate::OperationClip], [`SourceClip`][struct@crate::SourceClip]
pub trait ClipExt: IsA<Clip> + sealed::Sealed + 'static {
    /// Extracts a [`TrackElement`][crate::TrackElement] from an asset and adds it to the clip.
    /// This can be used to add effects that derive from the asset to the
    /// clip, but this method is not intended to be used to create the core
    /// elements of the clip.
    /// ## `asset`
    /// An asset with `GES_TYPE_TRACK_ELEMENT` as its
    /// [`extractable-type`][struct@crate::Asset#extractable-type]
    ///
    /// # Returns
    ///
    /// The newly created element, or
    /// [`None`] if an error occurred.
    #[doc(alias = "ges_clip_add_asset")]
    fn add_asset(&self, asset: &impl IsA<Asset>) -> Result<TrackElement, glib::BoolError> {
        unsafe {
            Option::<_>::from_glib_none(ffi::ges_clip_add_asset(
                self.as_ref().to_glib_none().0,
                asset.as_ref().to_glib_none().0,
            ))
            .ok_or_else(|| glib::bool_error!("Failed to add asset"))
        }
    }

    /// Adds the track element child of the clip to a specific track.
    ///
    /// If the given child is already in another track, this will create a copy
    /// of the child, add it to the clip, and add this copy to the track.
    ///
    /// You should only call this whilst a clip is part of a [`Timeline`][crate::Timeline], and
    /// for tracks that are in the same timeline.
    ///
    /// This method is an alternative to using the
    /// [`select-tracks-for-object`][struct@crate::Timeline#select-tracks-for-object] signal, but can be used to
    /// complement it when, say, you wish to copy a clip's children from one
    /// track into a new one.
    ///
    /// When the child is a core child, it must be added to a track that does
    /// not already contain another core child of the same clip. If it is not a
    /// core child (an additional effect), then it must be added to a track
    /// that already contains one of the core children of the same clip.
    ///
    /// This method can also fail if the adding the track element to the track
    /// would break a configuration rule of the corresponding [`Timeline`][crate::Timeline],
    /// such as causing three sources to overlap at a single time, or causing
    /// a source to completely overlap another in the same track.
    /// ## `child`
    /// A child of `self`
    /// ## `track`
    /// The track to add `child` to
    ///
    /// # Returns
    ///
    /// The element that was added to `track`, either
    /// `child` or a copy of child, or [`None`] if the element could not be added.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_add_child_to_track")]
    fn add_child_to_track(
        &self,
        child: &impl IsA<TrackElement>,
        track: &impl IsA<Track>,
    ) -> Result<TrackElement, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::ges_clip_add_child_to_track(
                self.as_ref().to_glib_none().0,
                child.as_ref().to_glib_none().0,
                track.as_ref().to_glib_none().0,
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib_none(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Add a top effect to a clip at the given index.
    ///
    /// Unlike using [`GESContainerExt::add()`][crate::prelude::GESContainerExt::add()], this allows you to set the index
    /// in advance. It will also check that no error occurred during the track
    /// selection for the effect.
    ///
    /// Note, only subclasses of `GESClipClass` that have
    /// `GES_CLIP_CLASS_CAN_ADD_EFFECTS` set to [`true`] (such as [`SourceClip`][crate::SourceClip]
    /// and [`BaseEffectClip`][crate::BaseEffectClip]) can have additional top effects added.
    ///
    /// Note, if the effect is a time effect, this may be refused if the clip
    /// would not be able to adapt itself once the effect is added.
    /// ## `effect`
    /// A top effect to add
    /// ## `index`
    /// The index to add `effect` at, or -1 to add at the highest,
    ///  see `ges_clip_get_top_effect_index` for more information
    ///
    /// # Returns
    ///
    /// [`true`] if `effect` was successfully added to `self` at `index`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_add_top_effect")]
    fn add_top_effect(&self, effect: &impl IsA<BaseEffect>, index: i32) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::ges_clip_add_top_effect(
                self.as_ref().to_glib_none().0,
                effect.as_ref().to_glib_none().0,
                index,
                &mut error,
            );
            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Finds an element controlled by the clip. If `track` is given,
    /// then only the track elements in `track` are searched for. If `type_` is
    /// given, then this function searches for a track element of the given
    /// `type_`.
    ///
    /// Note, if multiple track elements in the clip match the given criteria,
    /// this will return the element amongst them with the highest
    /// [`priority`][struct@crate::TimelineElement#priority] (numerically, the smallest). See
    /// [`find_track_elements()`][Self::find_track_elements()] if you wish to find all such elements.
    /// ## `track`
    /// The track to search in, or [`None`] to search in
    /// all tracks
    /// ## `type_`
    /// The type of track element to search for, or `G_TYPE_NONE` to
    /// match any type
    ///
    /// # Returns
    ///
    /// The element controlled by
    /// `self`, in `track`, and of the given `type_`, or [`None`] if no such element
    /// could be found.
    #[doc(alias = "ges_clip_find_track_element")]
    fn find_track_element(
        &self,
        track: Option<&impl IsA<Track>>,
        type_: glib::types::Type,
    ) -> Option<TrackElement> {
        unsafe {
            from_glib_full(ffi::ges_clip_find_track_element(
                self.as_ref().to_glib_none().0,
                track.map(|p| p.as_ref()).to_glib_none().0,
                type_.into_glib(),
            ))
        }
    }

    /// Finds the [`TrackElement`][crate::TrackElement]-s controlled by the clip that match the
    /// given criteria. If `track` is given as [`None`] and `track_type` is given as
    /// [`TrackType::UNKNOWN`][crate::TrackType::UNKNOWN], then the search will match all elements in any
    /// track, including those with no track, and of any
    /// [`track-type`][struct@crate::TrackElement#track-type]. Otherwise, if `track` is not [`None`], but
    /// `track_type` is [`TrackType::UNKNOWN`][crate::TrackType::UNKNOWN], then only the track elements in
    /// `track` are searched for. Otherwise, if `track_type` is not
    /// [`TrackType::UNKNOWN`][crate::TrackType::UNKNOWN], but `track` is [`None`], then only the track
    /// elements whose [`track-type`][struct@crate::TrackElement#track-type] matches `track_type` are
    /// searched for. Otherwise, when both are given, the track elements that
    /// match **either** criteria are searched for. Therefore, if you wish to
    /// only find elements in a specific track, you should give the track as
    /// `track`, but you should not give the track's [`track-type`][struct@crate::Track#track-type] as
    /// `track_type` because this would also select elements from other tracks
    /// of the same type.
    ///
    /// You may also give `type_` to _further_ restrict the search to track
    /// elements of the given `type_`.
    /// ## `track`
    /// The track to search in, or [`None`] to search in
    /// all tracks
    /// ## `track_type`
    /// The track-type of the track element to search for, or
    /// [`TrackType::UNKNOWN`][crate::TrackType::UNKNOWN] to match any track type
    /// ## `type_`
    /// The type of track element to search for, or `G_TYPE_NONE` to
    /// match any type
    ///
    /// # Returns
    ///
    /// A list of all
    /// the [`TrackElement`][crate::TrackElement]-s controlled by `self`, in `track` or of the given
    /// `track_type`, and of the given `type_`.
    #[doc(alias = "ges_clip_find_track_elements")]
    fn find_track_elements(
        &self,
        track: Option<&impl IsA<Track>>,
        track_type: TrackType,
        type_: glib::types::Type,
    ) -> Vec<TrackElement> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::ges_clip_find_track_elements(
                self.as_ref().to_glib_none().0,
                track.map(|p| p.as_ref()).to_glib_none().0,
                track_type.into_glib(),
                type_.into_glib(),
            ))
        }
    }

    /// Gets the [`duration-limit`][struct@crate::Clip#duration-limit] of the clip.
    ///
    /// # Returns
    ///
    /// The duration-limit of `self`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_get_duration_limit")]
    #[doc(alias = "get_duration_limit")]
    #[doc(alias = "duration-limit")]
    fn duration_limit(&self) -> gst::ClockTime {
        unsafe {
            try_from_glib(ffi::ges_clip_get_duration_limit(
                self.as_ref().to_glib_none().0,
            ))
            .expect("mandatory glib value is None")
        }
    }

    /// Convert the timeline time to an internal source time of the child.
    /// This will take any time effects placed on the clip into account (see
    /// [`BaseEffect`][crate::BaseEffect] for what time effects are supported, and how to
    /// declare them in GES).
    ///
    /// When `timeline_time` is above the [`start`][struct@crate::TimelineElement#start] of `self`,
    /// this will return the internal time at which the content that appears at
    /// `timeline_time` in the output of the timeline is created in `child`. For
    /// example, if `timeline_time` corresponds to the current seek position,
    /// this would let you know which part of a media file is being read.
    ///
    /// This will be done assuming the clip has an indefinite end, so the
    /// internal time may be beyond the current out-point of the child, or even
    /// its [`max-duration`][struct@crate::TimelineElement#max-duration].
    ///
    /// If, instead, `timeline_time` is below the current
    /// [`start`][struct@crate::TimelineElement#start] of `self`, this will return what you would
    /// need to set the [`in-point`][struct@crate::TimelineElement#in-point] of `child` to if you set
    /// the [`start`][struct@crate::TimelineElement#start] of `self` to `timeline_time` and wanted
    /// to keep the content of `child` currently found at the current
    /// [`start`][struct@crate::TimelineElement#start] of `self` at the same timeline position. If
    /// this would be negative, the conversion fails. This is useful for
    /// determining what [`in-point`][struct@crate::TimelineElement#in-point] would result from a
    /// [`EditMode::Trim`][crate::EditMode::Trim] to `timeline_time`.
    ///
    /// Note that whilst a clip has no time effects, this second return is
    /// equivalent to finding the internal time at which the content that
    /// appears at `timeline_time` in the timeline can be found in `child` if it
    /// had indefinite extent in both directions. However, with non-linear time
    /// effects this second return will be more distinct.
    ///
    /// In either case, the returned time would be appropriate to use for the
    /// [`in-point`][struct@crate::TimelineElement#in-point] or [`max-duration`][struct@crate::TimelineElement#max-duration] of the
    /// child.
    ///
    /// See [`timeline_time_from_internal_time()`][Self::timeline_time_from_internal_time()], which performs the
    /// reverse.
    /// ## `child`
    /// An [`active`][struct@crate::TrackElement#active] child of `self` with a
    /// [`track`][struct@crate::TrackElement#track]
    /// ## `timeline_time`
    /// A time in the timeline time coordinates
    ///
    /// # Returns
    ///
    /// The time in the internal coordinates of `child` corresponding
    /// to `timeline_time`, or `GST_CLOCK_TIME_NONE` if the conversion could not
    /// be performed.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_get_internal_time_from_timeline_time")]
    #[doc(alias = "get_internal_time_from_timeline_time")]
    fn internal_time_from_timeline_time(
        &self,
        child: &impl IsA<TrackElement>,
        timeline_time: impl Into<Option<gst::ClockTime>>,
    ) -> Result<Option<gst::ClockTime>, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::ges_clip_get_internal_time_from_timeline_time(
                self.as_ref().to_glib_none().0,
                child.as_ref().to_glib_none().0,
                timeline_time.into().into_glib(),
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Gets the [`layer`][struct@crate::Clip#layer] of the clip.
    ///
    /// # Returns
    ///
    /// The layer `self` is in, or [`None`] if
    /// `self` is not in any layer.
    #[doc(alias = "ges_clip_get_layer")]
    #[doc(alias = "get_layer")]
    fn layer(&self) -> Option<Layer> {
        unsafe { from_glib_full(ffi::ges_clip_get_layer(self.as_ref().to_glib_none().0)) }
    }

    /// Gets the [`supported-formats`][struct@crate::Clip#supported-formats] of the clip.
    ///
    /// # Returns
    ///
    /// The [`TrackType`][crate::TrackType]-s supported by `self`.
    #[doc(alias = "ges_clip_get_supported_formats")]
    #[doc(alias = "get_supported_formats")]
    #[doc(alias = "supported-formats")]
    fn supported_formats(&self) -> TrackType {
        unsafe {
            from_glib(ffi::ges_clip_get_supported_formats(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Convert the internal source time from the child to a timeline time.
    /// This will take any time effects placed on the clip into account (see
    /// [`BaseEffect`][crate::BaseEffect] for what time effects are supported, and how to
    /// declare them in GES).
    ///
    /// When `internal_time` is above the [`in-point`][struct@crate::TimelineElement#in-point] of
    /// `child`, this will return the timeline time at which the internal
    /// content found at `internal_time` appears in the output of the timeline's
    /// track. For example, this would let you know where in the timeline a
    /// particular scene in a media file would appear.
    ///
    /// This will be done assuming the clip has an indefinite end, so the
    /// timeline time may be beyond the end of the clip, or even breaking its
    /// [`duration-limit`][struct@crate::Clip#duration-limit].
    ///
    /// If, instead, `internal_time` is below the current
    /// [`in-point`][struct@crate::TimelineElement#in-point] of `child`, this will return what you would
    /// need to set the [`start`][struct@crate::TimelineElement#start] of `self` to if you set the
    /// [`in-point`][struct@crate::TimelineElement#in-point] of `child` to `internal_time` and wanted to
    /// keep the content of `child` currently found at the current
    /// [`start`][struct@crate::TimelineElement#start] of `self` at the same timeline position. If
    /// this would be negative, the conversion fails. This is useful for
    /// determining what position to use in a [`EditMode::Trim`][crate::EditMode::Trim] if you wish
    /// to trim to a specific point in the internal content, such as a
    /// particular scene in a media file.
    ///
    /// Note that whilst a clip has no time effects, this second return is
    /// equivalent to finding the timeline time at which the content of `child`
    /// at `internal_time` would be found in the timeline if it had indefinite
    /// extent in both directions. However, with non-linear time effects this
    /// second return will be more distinct.
    ///
    /// In either case, the returned time would be appropriate to use in
    /// [`TimelineElementExt::edit()`][crate::prelude::TimelineElementExt::edit()] for [`EditMode::Trim`][crate::EditMode::Trim], and similar, if
    /// you wish to use a particular internal point as a reference. For
    /// example, you could choose to end a clip at a certain internal
    /// 'out-point', similar to the [`in-point`][struct@crate::TimelineElement#in-point], by
    /// translating the desired end time into the timeline coordinates, and
    /// using this position to trim the end of a clip.
    ///
    /// See [`internal_time_from_timeline_time()`][Self::internal_time_from_timeline_time()], which performs the
    /// reverse, or [`timeline_time_from_source_frame()`][Self::timeline_time_from_source_frame()] which does
    /// the same conversion, but using frame numbers.
    /// ## `child`
    /// An [`active`][struct@crate::TrackElement#active] child of `self` with a
    /// [`track`][struct@crate::TrackElement#track]
    /// ## `internal_time`
    /// A time in the internal time coordinates of `child`
    ///
    /// # Returns
    ///
    /// The time in the timeline coordinates corresponding to
    /// `internal_time`, or `GST_CLOCK_TIME_NONE` if the conversion could not be
    /// performed.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_get_timeline_time_from_internal_time")]
    #[doc(alias = "get_timeline_time_from_internal_time")]
    fn timeline_time_from_internal_time(
        &self,
        child: &impl IsA<TrackElement>,
        internal_time: impl Into<Option<gst::ClockTime>>,
    ) -> Result<Option<gst::ClockTime>, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::ges_clip_get_timeline_time_from_internal_time(
                self.as_ref().to_glib_none().0,
                child.as_ref().to_glib_none().0,
                internal_time.into().into_glib(),
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Convert the source frame number to a timeline time. This acts the same
    /// as [`timeline_time_from_internal_time()`][Self::timeline_time_from_internal_time()] using the core
    /// children of the clip and using the frame number to specify the internal
    /// position, rather than a timestamp.
    ///
    /// The returned timeline time can be used to seek or edit to a specific
    /// frame.
    ///
    /// Note that you can get the frame timestamp of a particular clip asset
    /// with [`ClipAssetExt::frame_time()`][crate::prelude::ClipAssetExt::frame_time()].
    /// ## `frame_number`
    /// The frame number to get the corresponding timestamp of
    /// in the timeline coordinates
    ///
    /// # Returns
    ///
    /// The timestamp corresponding to `frame_number` in the core
    /// children of `self`, in the timeline coordinates, or `GST_CLOCK_TIME_NONE`
    /// if the conversion could not be performed.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_get_timeline_time_from_source_frame")]
    #[doc(alias = "get_timeline_time_from_source_frame")]
    fn timeline_time_from_source_frame(
        &self,
        frame_number: FrameNumber,
    ) -> Result<Option<gst::ClockTime>, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::ges_clip_get_timeline_time_from_source_frame(
                self.as_ref().to_glib_none().0,
                frame_number,
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Gets the internal index of an effect in the clip. The index of effects
    /// in a clip will run from 0 to n-1, where n is the total number of
    /// effects. If two effects share the same [`track`][struct@crate::TrackElement#track], the
    /// effect with the numerically lower index will be applied to the source
    /// data **after** the other effect, i.e. output data will always flow from
    /// a higher index effect to a lower index effect.
    /// ## `effect`
    /// The effect we want to get the index of
    ///
    /// # Returns
    ///
    /// The index of `effect` in `self`, or -1 if something went wrong.
    #[doc(alias = "ges_clip_get_top_effect_index")]
    #[doc(alias = "get_top_effect_index")]
    fn top_effect_index(&self, effect: &impl IsA<BaseEffect>) -> i32 {
        unsafe {
            ffi::ges_clip_get_top_effect_index(
                self.as_ref().to_glib_none().0,
                effect.as_ref().to_glib_none().0,
            )
        }
    }

    #[doc(alias = "ges_clip_get_top_effect_position")]
    #[doc(alias = "get_top_effect_position")]
    fn top_effect_position(&self, effect: &impl IsA<BaseEffect>) -> i32 {
        unsafe {
            ffi::ges_clip_get_top_effect_position(
                self.as_ref().to_glib_none().0,
                effect.as_ref().to_glib_none().0,
            )
        }
    }

    /// Gets the [`BaseEffect`][crate::BaseEffect]-s that have been added to the clip. The
    /// returned list is ordered by their internal index in the clip. See
    /// [`top_effect_index()`][Self::top_effect_index()].
    ///
    /// # Returns
    ///
    /// A list of all
    /// [`BaseEffect`][crate::BaseEffect]-s that have been added to `self`.
    #[doc(alias = "ges_clip_get_top_effects")]
    #[doc(alias = "get_top_effects")]
    fn top_effects(&self) -> Vec<TrackElement> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::ges_clip_get_top_effects(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// See [`move_to_layer_full()`][Self::move_to_layer_full()], which also gives an error.
    /// ## `layer`
    /// The new layer
    ///
    /// # Returns
    ///
    /// [`true`] if `self` was successfully moved to `layer`.
    #[doc(alias = "ges_clip_move_to_layer")]
    fn move_to_layer(&self, layer: &impl IsA<Layer>) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_clip_move_to_layer(
                    self.as_ref().to_glib_none().0,
                    layer.as_ref().to_glib_none().0
                ),
                "Failed to move clip to specified layer"
            )
        }
    }

    /// Moves a clip to a new layer. If the clip already exists in a layer, it
    /// is first removed from its current layer before being added to the new
    /// layer.
    /// ## `layer`
    /// The new layer
    ///
    /// # Returns
    ///
    /// [`true`] if `self` was successfully moved to `layer`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_move_to_layer_full")]
    fn move_to_layer_full(&self, layer: &impl IsA<Layer>) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::ges_clip_move_to_layer_full(
                self.as_ref().to_glib_none().0,
                layer.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))
            }
        }
    }

    /// Remove a top effect from the clip.
    ///
    /// Note, if the effect is a time effect, this may be refused if the clip
    /// would not be able to adapt itself once the effect is removed.
    /// ## `effect`
    /// The top effect to remove
    ///
    /// # Returns
    ///
    /// [`true`] if `effect` was successfully added to `self` at `index`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_remove_top_effect")]
    fn remove_top_effect(&self, effect: &impl IsA<BaseEffect>) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::ges_clip_remove_top_effect(
                self.as_ref().to_glib_none().0,
                effect.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))
            }
        }
    }

    /// Sets the [`supported-formats`][struct@crate::Clip#supported-formats] of the clip. This should normally
    /// only be called by subclasses, which should be responsible for updating
    /// its value, rather than the user.
    /// ## `supportedformats`
    /// The [`TrackType`][crate::TrackType]-s supported by `self`
    #[doc(alias = "ges_clip_set_supported_formats")]
    #[doc(alias = "supported-formats")]
    fn set_supported_formats(&self, supportedformats: TrackType) {
        unsafe {
            ffi::ges_clip_set_supported_formats(
                self.as_ref().to_glib_none().0,
                supportedformats.into_glib(),
            );
        }
    }

    /// See [`set_top_effect_index_full()`][Self::set_top_effect_index_full()], which also gives an error.
    /// ## `effect`
    /// An effect within `self` to move
    /// ## `newindex`
    /// The index for `effect` in `self`
    ///
    /// # Returns
    ///
    /// [`true`] if `effect` was successfully moved to `newindex`.
    #[doc(alias = "ges_clip_set_top_effect_index")]
    fn set_top_effect_index(
        &self,
        effect: &impl IsA<BaseEffect>,
        newindex: u32,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_clip_set_top_effect_index(
                    self.as_ref().to_glib_none().0,
                    effect.as_ref().to_glib_none().0,
                    newindex
                ),
                "Failed to move effect"
            )
        }
    }

    /// Set the index of an effect within the clip. See
    /// [`top_effect_index()`][Self::top_effect_index()]. The new index must be an existing
    /// index of the clip. The effect is moved to the new index, and the other
    /// effects may be shifted in index accordingly to otherwise maintain the
    /// ordering.
    /// ## `effect`
    /// An effect within `self` to move
    /// ## `newindex`
    /// The index for `effect` in `self`
    ///
    /// # Returns
    ///
    /// [`true`] if `effect` was successfully moved to `newindex`.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_set_top_effect_index_full")]
    fn set_top_effect_index_full(
        &self,
        effect: &impl IsA<BaseEffect>,
        newindex: u32,
    ) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::ges_clip_set_top_effect_index_full(
                self.as_ref().to_glib_none().0,
                effect.as_ref().to_glib_none().0,
                newindex,
                &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_clip_set_top_effect_priority")]
    fn set_top_effect_priority(
        &self,
        effect: &impl IsA<BaseEffect>,
        newpriority: u32,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_clip_set_top_effect_priority(
                    self.as_ref().to_glib_none().0,
                    effect.as_ref().to_glib_none().0,
                    newpriority
                ),
                "Failed to the set top effect priority"
            )
        }
    }

    /// See [`split_full()`][Self::split_full()], which also gives an error.
    /// ## `position`
    /// The timeline position at which to perform the split
    ///
    /// # Returns
    ///
    /// The newly created clip resulting
    /// from the splitting `self`, or [`None`] if `self` can't be split.
    #[doc(alias = "ges_clip_split")]
    fn split(&self, position: u64) -> Result<Clip, glib::BoolError> {
        unsafe {
            Option::<_>::from_glib_none(ffi::ges_clip_split(
                self.as_ref().to_glib_none().0,
                position,
            ))
            .ok_or_else(|| glib::bool_error!("Failed to split clip"))
        }
    }

    /// Splits a clip at the given timeline position into two clips. The clip
    /// must already have a [`layer`][struct@crate::Clip#layer].
    ///
    /// The original clip's [`duration`][struct@crate::TimelineElement#duration] is reduced such that
    /// its end point matches the split position. Then a new clip is created in
    /// the same layer, whose [`start`][struct@crate::TimelineElement#start] matches the split
    /// position and [`duration`][struct@crate::TimelineElement#duration] will be set such that its end
    /// point matches the old end point of the original clip. Thus, the two
    /// clips together will occupy the same positions in the timeline as the
    /// original clip did.
    ///
    /// The children of the new clip will be new copies of the original clip's
    /// children, so it will share the same sources and use the same
    /// operations.
    ///
    /// The new clip will also have its [`in-point`][struct@crate::TimelineElement#in-point] set so
    /// that any internal data will appear in the timeline at the same time.
    /// Thus, when the timeline is played, the playback of data should
    /// appear the same. This may be complicated by any additional
    /// [`Effect`][crate::Effect]-s that have been placed on the original clip that depend on
    /// the playback time or change the data consumption rate of sources. This
    /// method will attempt to translate these effects such that the playback
    /// appears the same. In such complex situations, you may get a better
    /// result if you place the clip in a separate sub [`Project`][crate::Project], which only
    /// contains this clip (and its effects), and in the original layer
    /// create two neighbouring [`UriClip`][crate::UriClip]-s that reference this sub-project,
    /// but at a different [`in-point`][struct@crate::TimelineElement#in-point].
    /// ## `position`
    /// The timeline position at which to perform the split, between
    /// the start and end of the clip
    ///
    /// # Returns
    ///
    /// The newly created clip resulting
    /// from the splitting `self`, or [`None`] if `self` can't be split.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_clip_split_full")]
    fn split_full(&self, position: u64) -> Result<Option<Clip>, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret =
                ffi::ges_clip_split_full(self.as_ref().to_glib_none().0, position, &mut error);
            if error.is_null() {
                Ok(from_glib_none(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "duration-limit")]
    fn connect_duration_limit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_duration_limit_trampoline<P: IsA<Clip>, F: Fn(&P) + 'static>(
            this: *mut ffi::GESClip,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Clip::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-limit\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_duration_limit_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

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

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

impl<O: IsA<Clip>> ClipExt for O {}