objc2-av-foundation 0.3.2

Bindings to the AVFoundation framework
Documentation
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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcomposition?language=objc)
    #[unsafe(super(AVAsset, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "AVAsset")]
    pub struct AVComposition;
);

#[cfg(all(feature = "AVAsset", feature = "AVAsynchronousKeyValueLoading"))]
extern_conformance!(
    unsafe impl AVAsynchronousKeyValueLoading for AVComposition {}
);

#[cfg(feature = "AVAsset")]
extern_conformance!(
    unsafe impl NSCopying for AVComposition {}
);

#[cfg(feature = "AVAsset")]
unsafe impl CopyingHelper for AVComposition {
    type Result = Self;
}

#[cfg(feature = "AVAsset")]
extern_conformance!(
    unsafe impl NSMutableCopying for AVComposition {}
);

#[cfg(feature = "AVAsset")]
unsafe impl MutableCopyingHelper for AVComposition {
    type Result = AVMutableComposition;
}

#[cfg(feature = "AVAsset")]
extern_conformance!(
    unsafe impl NSObjectProtocol for AVComposition {}
);

#[cfg(feature = "AVAsset")]
impl AVComposition {
    extern_methods!(
        #[cfg(all(feature = "AVAssetTrack", feature = "AVCompositionTrack"))]
        /// Provides the array of AVCompositionTracks contained by the composition.
        #[unsafe(method(tracks))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracks(&self) -> Retained<NSArray<AVCompositionTrack>>;

        #[cfg(feature = "objc2-core-foundation")]
        /// Indicates the authored size of the visual portion of the composition.
        #[unsafe(method(naturalSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn naturalSize(&self) -> CGSize;

        /// Specifies the initialization options for the creation of AVURLAssets by the receiver, e.g. AVURLAssetPreferPreciseDurationAndTimingKey. The default behavior for creation of AVURLAssets by an AVComposition is equivalent to the behavior of +[AVURLAsset URLAssetWithURL:options:] when specifying no initialization options.
        ///
        /// AVCompositions create AVURLAssets internally for URLs specified by AVCompositionTrackSegments of AVCompositionTracks, as needed, whenever AVCompositionTrackSegments were originally added to a track via -[AVMutableCompositionTrack setSegments:] rather than by inserting timeranges of already existing AVAssets or AVAssetTracks.
        /// The value of URLAssetInitializationOptions can be specified at the time an AVMutableComposition is created via +compositionWithURLAssetInitializationOptions:.
        #[unsafe(method(URLAssetInitializationOptions))]
        #[unsafe(method_family = none)]
        pub unsafe fn URLAssetInitializationOptions(
            &self,
        ) -> Retained<NSDictionary<NSString, AnyObject>>;
    );
}

/// Methods declared on superclass `AVAsset`.
#[cfg(feature = "AVAsset")]
impl AVComposition {
    extern_methods!(
        /// Returns an instance of AVAsset for inspection of a media resource.
        ///
        /// Returns a newly allocated instance of a subclass of AVAsset initialized with the specified URL.
        ///
        /// - Parameter URL: An instance of NSURL that references a media resource.
        ///
        /// - Returns: An instance of AVAsset.
        #[unsafe(method(assetWithURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn assetWithURL(url: &NSURL) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "AVAsset")]
impl AVComposition {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// AVCompositionTrackInspection.
#[cfg(feature = "AVAsset")]
impl AVComposition {
    extern_methods!(
        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "objc2-core-media"
        ))]
        /// Provides an instance of AVCompositionTrack that represents the track of the specified trackID.
        ///
        /// Parameter `trackID`: The trackID of the requested AVCompositionTrack.
        ///
        /// Returns: An instance of AVCompositionTrack; may be nil if no track of the specified trackID is available.
        ///
        /// Becomes callable without blocking when the key
        /// "
        /// tracks" has been loaded
        #[unsafe(method(trackWithTrackID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn trackWithTrackID(
            &self,
            track_id: CMPersistentTrackID,
        ) -> Option<Retained<AVCompositionTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "block2",
            feature = "objc2-core-media"
        ))]
        /// Loads an instance of AVCompositionTrack that represents the track of the specified trackID.
        ///
        /// Parameter `trackID`: The trackID of the requested AVCompositionTrack.
        ///
        /// Parameter `completionHandler`: A block that is called when the loading is finished, with either the loaded track (which may be nil if no track of the specified trackID is available) or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadTrackWithTrackID:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadTrackWithTrackID_completionHandler(
            &self,
            track_id: CMPersistentTrackID,
            completion_handler: &block2::DynBlock<dyn Fn(*mut AVCompositionTrack, *mut NSError)>,
        );

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "AVMediaFormat"
        ))]
        /// Provides an array of AVCompositionTracks of the asset that present media of the specified media type.
        ///
        /// Parameter `mediaType`: The media type according to which the receiver filters its AVCompositionTracks. (Media types are defined in AVMediaFormat.h)
        ///
        /// Returns: An NSArray of AVCompositionTracks; may be empty if no tracks of the specified media type are available.
        ///
        /// Becomes callable without blocking when the key
        /// "
        /// tracks" has been loaded
        #[unsafe(method(tracksWithMediaType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracksWithMediaType(
            &self,
            media_type: &AVMediaType,
        ) -> Retained<NSArray<AVCompositionTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "AVMediaFormat",
            feature = "block2"
        ))]
        /// Loads an array of AVCompositionTracks of the asset that present media of the specified media type.
        ///
        /// Parameter `mediaType`: The media type according to which AVAsset filters its AVCompositionTracks. (Media types are defined in AVMediaFormat.h.)
        ///
        /// Parameter `completionHandler`: A block that is called when the loading is finished, with either the loaded tracks (which may be empty if no tracks of the specified media type are available) or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadTracksWithMediaType:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadTracksWithMediaType_completionHandler(
            &self,
            media_type: &AVMediaType,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut NSArray<AVCompositionTrack>, *mut NSError),
            >,
        );

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "AVMediaFormat"
        ))]
        /// Provides an array of AVCompositionTracks of the asset that present media with the specified characteristic.
        ///
        /// Parameter `mediaCharacteristic`: The media characteristic according to which the receiver filters its AVCompositionTracks. (Media characteristics are defined in AVMediaFormat.h)
        ///
        /// Returns: An NSArray of AVCompositionTracks; may be empty if no tracks with the specified characteristic are available.
        ///
        /// Becomes callable without blocking when the key
        /// "
        /// tracks" has been loaded
        #[unsafe(method(tracksWithMediaCharacteristic:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracksWithMediaCharacteristic(
            &self,
            media_characteristic: &AVMediaCharacteristic,
        ) -> Retained<NSArray<AVCompositionTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "AVMediaFormat",
            feature = "block2"
        ))]
        /// Loads an array of AVCompositionTracks of the asset that present media with the specified characteristic.
        ///
        /// Parameter `mediaCharacteristic`: The media characteristic according to which AVAsset filters its AVCompositionTracks. (Media characteristics are defined in AVMediaFormat.h.)
        ///
        /// Parameter `completionHandler`: A block that is called when the loading is finished, with either the loaded tracks (which may be empty if no tracks with the specified characteristic are available) or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadTracksWithMediaCharacteristic:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadTracksWithMediaCharacteristic_completionHandler(
            &self,
            media_characteristic: &AVMediaCharacteristic,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut NSArray<AVCompositionTrack>, *mut NSError),
            >,
        );
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmutablecomposition?language=objc)
    #[unsafe(super(AVComposition, AVAsset, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "AVAsset")]
    pub struct AVMutableComposition;
);

#[cfg(all(feature = "AVAsset", feature = "AVAsynchronousKeyValueLoading"))]
extern_conformance!(
    unsafe impl AVAsynchronousKeyValueLoading for AVMutableComposition {}
);

#[cfg(feature = "AVAsset")]
extern_conformance!(
    unsafe impl NSCopying for AVMutableComposition {}
);

#[cfg(feature = "AVAsset")]
unsafe impl CopyingHelper for AVMutableComposition {
    type Result = AVComposition;
}

#[cfg(feature = "AVAsset")]
extern_conformance!(
    unsafe impl NSMutableCopying for AVMutableComposition {}
);

#[cfg(feature = "AVAsset")]
unsafe impl MutableCopyingHelper for AVMutableComposition {
    type Result = Self;
}

#[cfg(feature = "AVAsset")]
extern_conformance!(
    unsafe impl NSObjectProtocol for AVMutableComposition {}
);

#[cfg(feature = "AVAsset")]
impl AVMutableComposition {
    extern_methods!(
        #[cfg(all(feature = "AVAssetTrack", feature = "AVCompositionTrack"))]
        /// Provides the array of AVMutableCompositionTracks contained by the composition.
        #[unsafe(method(tracks))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracks(&self) -> Retained<NSArray<AVMutableCompositionTrack>>;

        #[cfg(feature = "objc2-core-foundation")]
        /// Indicates the authored size of the visual portion of the asset.
        ///
        /// If not set, the value is the size of the composition's first video track. Set to CGSizeZero to revert to default behavior.
        #[unsafe(method(naturalSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn naturalSize(&self) -> CGSize;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`naturalSize`][Self::naturalSize].
        #[unsafe(method(setNaturalSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setNaturalSize(&self, natural_size: CGSize);

        /// Returns an empty AVMutableComposition.
        #[unsafe(method(composition))]
        #[unsafe(method_family = none)]
        pub unsafe fn composition() -> Retained<Self>;

        /// Returns an empty AVMutableComposition.
        ///
        /// Parameter `URLAssetInitializationOptions`: Specifies the initialization options that the receiver should use when creating AVURLAssets internally, e.g. AVURLAssetPreferPreciseDurationAndTimingKey. The default behavior for creation of AVURLAssets by an AVMutableComposition is equivalent to the behavior of +[AVURLAsset URLAssetWithURL:options:] when specifying no initialization options.
        ///
        /// AVMutableCompositions create AVURLAssets internally for URLs specified by AVCompositionTrackSegments of AVMutableCompositionTracks, as needed, whenever AVCompositionTrackSegments are added to tracks via -[AVMutableCompositionTrack setSegments:] rather than by inserting timeranges of already existing AVAssets or AVAssetTracks.
        ///
        /// # Safety
        ///
        /// `url_asset_initialization_options` generic should be of the correct type.
        #[unsafe(method(compositionWithURLAssetInitializationOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn compositionWithURLAssetInitializationOptions(
            url_asset_initialization_options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `AVAsset`.
#[cfg(feature = "AVAsset")]
impl AVMutableComposition {
    extern_methods!(
        /// Returns an instance of AVAsset for inspection of a media resource.
        ///
        /// Returns a newly allocated instance of a subclass of AVAsset initialized with the specified URL.
        ///
        /// - Parameter URL: An instance of NSURL that references a media resource.
        ///
        /// - Returns: An instance of AVAsset.
        #[unsafe(method(assetWithURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn assetWithURL(url: &NSURL) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "AVAsset")]
impl AVMutableComposition {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// AVMutableCompositionCompositionLevelEditing.
#[cfg(feature = "AVAsset")]
impl AVMutableComposition {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// Inserts all the tracks of a timeRange of an asset into a composition.
        ///
        /// Parameter `timeRange`: Specifies the timeRange of the asset to be inserted.
        ///
        /// Parameter `asset`: Specifies the asset that contains the tracks that are to be inserted. Only instances of AVURLAsset and AVComposition are supported (AVComposition starting in macOS 10.10 and iOS 8.0). The asset should have its tracks loaded, and the tracks should have their formatDescriptions loaded before invoking this method to avoid blocking.
        ///
        /// Parameter `startTime`: Specifies the time at which the inserted tracks are to be presented by the composition.
        ///
        /// Parameter `outError`: Describes failures that may be reported to the user, e.g. the asset that was selected for insertion in the composition is restricted by copy-protection.
        ///
        /// Returns: A BOOL value indicating the success of the insertion.
        ///
        /// You provide a reference to an AVAsset and the timeRange within it that you want to insert. You specify the start time in the destination composition at which the timeRange should be inserted.
        /// This method may add new tracks to ensure that all tracks of the asset are represented in the inserted timeRange.
        /// Note that the media data for the inserted timeRange will be presented at its natural duration and rate. It can be scaled to a different duration and presented at a different rate via -scaleTimeRange:toDuration:.
        /// Existing content at the specified startTime will be pushed out by the duration of timeRange.
        /// Note that this operation only inserts one or more track segments into affected AVMutableCompositionTracks; it does not affect the values of other track properties, either to match the corresponding values of tracks in the source asset or for any other purpose.
        #[deprecated]
        #[unsafe(method(insertTimeRange:ofAsset:atTime:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertTimeRange_ofAsset_atTime_error(
            &self,
            time_range: CMTimeRange,
            asset: &AVAsset,
            start_time: CMTime,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
        /// Inserts all the tracks of a timeRange of an asset into a composition.
        ///
        /// Parameter `timeRange`: Specifies the timeRange of the asset to be inserted.
        ///
        /// Parameter `asset`: Specifies the asset that contains the tracks that are to be inserted. Only instances of AVURLAsset and AVComposition are supported (AVComposition starting in macOS 10.10 and iOS 8.0).
        ///
        /// Parameter `startTime`: Specifies the time at which the inserted tracks are to be presented by the composition.
        ///
        /// Parameter `completionHandler`: A block that is invoked when the insertion is complete.  If the error parameter is non-nil, it describes a failure that may be reported to the user, e.g. the asset that was selected for insertion in the composition is restricted by copy-protection.
        ///
        /// You provide a reference to an AVAsset and the timeRange within it that you want to insert. You specify the start time in the destination composition at which the timeRange should be inserted.
        /// This method may add new tracks to ensure that all tracks of the asset are represented in the inserted timeRange.
        /// Note that the media data for the inserted timeRange will be presented at its natural duration and rate. It can be scaled to a different duration and presented at a different rate via -scaleTimeRange:toDuration:.
        /// Existing content at the specified startTime will be pushed out by the duration of timeRange.
        /// Note that this operation only inserts one or more track segments into affected AVMutableCompositionTracks; it does not affect the values of other track properties, either to match the corresponding values of tracks in the source asset or for any other purpose.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(insertTimeRange:ofAsset:atTime:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertTimeRange_ofAsset_atTime_completionHandler(
            &self,
            time_range: CMTimeRange,
            asset: &AVAsset,
            start_time: CMTime,
            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "objc2-core-media")]
        /// Adds or extends an empty timeRange within all tracks of the composition.
        ///
        /// Parameter `timeRange`: Specifies the empty timeRange to be inserted.
        ///
        /// If you insert an empty timeRange into the composition, any media that was presented during that interval prior to the insertion will be presented instead immediately afterward. You can use this method to reserve an interval in which you want a subsequently created track to present its media.
        /// Note that you cannot add empty time ranges to the end of a composition.
        #[unsafe(method(insertEmptyTimeRange:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertEmptyTimeRange(&self, time_range: CMTimeRange);

        #[cfg(feature = "objc2-core-media")]
        /// Removes a specified timeRange from all tracks of the composition.
        ///
        /// Parameter `timeRange`: Specifies the timeRange to be removed.
        ///
        /// Removal of a time range does not cause any existing tracks to be removed from the composition, even if removing timeRange results in an empty track. Instead, it removes or truncates track segments that intersect with the timeRange.
        ///
        /// After removing, existing content after timeRange will be pulled in.
        #[unsafe(method(removeTimeRange:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeTimeRange(&self, time_range: CMTimeRange);

        #[cfg(feature = "objc2-core-media")]
        /// Changes the duration of a timeRange of all tracks.
        ///
        /// Parameter `timeRange`: Specifies the timeRange of the composition to be scaled.
        ///
        /// Parameter `duration`: Specifies the new duration of the timeRange.
        ///
        /// Each trackSegment affected by the scaling operation will be presented at a rate equal to source.duration / target.duration of its resulting timeMapping.
        #[unsafe(method(scaleTimeRange:toDuration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn scaleTimeRange_toDuration(&self, time_range: CMTimeRange, duration: CMTime);
    );
}

/// AVMutableCompositionTrackLevelEditing.
#[cfg(feature = "AVAsset")]
impl AVMutableComposition {
    extern_methods!(
        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "AVMediaFormat",
            feature = "objc2-core-media"
        ))]
        /// Adds an empty track to a mutable composition.
        ///
        /// Parameter `mediaType`: The media type of the new track.
        ///
        /// Parameter `preferredTrackID`: Specifies the preferred track ID for the new track. If you do not need to specify a preferred track ID, pass kCMPersistentTrackID_Invalid. Otherwise the preferred track ID will be used for the new track, provided that it is not currently in use and has not previously been used.
        ///
        /// Returns: An instance of AVMutableCompositionTrack representing the new track. Its actual trackID is available via its
        /// "
        /// trackID" key.
        ///
        /// If the specified preferred track ID is not available, or kCMPersistentTrackID_Invalid was passed in, a unique track ID will be generated.
        #[unsafe(method(addMutableTrackWithMediaType:preferredTrackID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addMutableTrackWithMediaType_preferredTrackID(
            &self,
            media_type: &AVMediaType,
            preferred_track_id: CMPersistentTrackID,
        ) -> Option<Retained<AVMutableCompositionTrack>>;

        #[cfg(all(feature = "AVAssetTrack", feature = "AVCompositionTrack"))]
        /// Removes a track of a mutable composition.
        ///
        /// Parameter `track`: A reference to the AVCompositionTrack to be removed.
        ///
        /// If you retain a reference to the removed track, note that its
        /// "
        /// composition" key will have the value nil, and the values of its other properties are undefined.
        #[unsafe(method(removeTrack:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeTrack(&self, track: &AVCompositionTrack);

        #[cfg(all(feature = "AVAssetTrack", feature = "AVCompositionTrack"))]
        /// Provides a reference to a track of a mutable composition into which any timeRange of an AVAssetTrack can be inserted (via -[AVMutableCompositionTrack insertTimeRange:ofTrack:atTime:error:]).
        ///
        /// Parameter `track`: A reference to the AVAssetTrack from which a timeRange may be inserted.
        ///
        /// Returns: An AVMutableCompositionTrack that can accommodate the insertion, or, if no such track is available, nil.
        ///
        /// If a compatible track is desired but the result of this method is nil, a new track of the same mediaType as the AVAssetTrack can be created via -addMutableTrackWithMediaType:preferredTrackID:, and this new track will be compatible.
        ///
        /// For best performance, the number of tracks of a composition should be kept to a minimum, corresponding to the number for which media data must be presented in parallel. If media data of the same type is to be presented serially, even from multiple assets, a single track of that media type should be used. This method, -mutableTrackCompatibleWithTrack:, can help the client to identify an existing target track for an insertion.
        ///
        /// Similar to -[AVAsset compatibleTrackForCompositionTrack:].
        #[unsafe(method(mutableTrackCompatibleWithTrack:))]
        #[unsafe(method_family = none)]
        pub unsafe fn mutableTrackCompatibleWithTrack(
            &self,
            track: &AVAssetTrack,
        ) -> Option<Retained<AVMutableCompositionTrack>>;
    );
}

/// AVMutableCompositionTrackInspection.
#[cfg(feature = "AVAsset")]
impl AVMutableComposition {
    extern_methods!(
        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "objc2-core-media"
        ))]
        /// Provides an instance of AVMutableCompositionTrack that represents the track of the specified trackID.
        ///
        /// Parameter `trackID`: The trackID of the requested AVMutableCompositionTrack.
        ///
        /// Returns: An instance of AVMutableCompositionTrack; may be nil if no track of the specified trackID is available.
        ///
        /// Becomes callable without blocking when the key
        /// "
        /// tracks" has been loaded
        #[unsafe(method(trackWithTrackID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn trackWithTrackID(
            &self,
            track_id: CMPersistentTrackID,
        ) -> Option<Retained<AVMutableCompositionTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "block2",
            feature = "objc2-core-media"
        ))]
        /// Loads an instance of AVMutableCompositionTrack that represents the track of the specified trackID.
        ///
        /// Parameter `trackID`: The trackID of the requested AVMutableCompositionTrack.
        ///
        /// Parameter `completionHandler`: A block that is called when the loading is finished, with either the loaded track (which may be nil if no track of the specified trackID is available) or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadTrackWithTrackID:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadTrackWithTrackID_completionHandler(
            &self,
            track_id: CMPersistentTrackID,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut AVMutableCompositionTrack, *mut NSError),
            >,
        );

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "AVMediaFormat"
        ))]
        /// Provides an array of AVMutableCompositionTracks of the asset that present media of the specified media type.
        ///
        /// Parameter `mediaType`: The media type according to which the receiver filters its AVMutableCompositionTracks. (Media types are defined in AVMediaFormat.h)
        ///
        /// Returns: An NSArray of AVMutableCompositionTracks; may be empty if no tracks of the specified media type are available.
        ///
        /// Becomes callable without blocking when the key
        /// "
        /// tracks" has been loaded
        #[unsafe(method(tracksWithMediaType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracksWithMediaType(
            &self,
            media_type: &AVMediaType,
        ) -> Retained<NSArray<AVMutableCompositionTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "AVMediaFormat",
            feature = "block2"
        ))]
        /// Loads an array of AVMutableCompositionTracks of the asset that present media of the specified media type.
        ///
        /// Parameter `mediaType`: The media type according to which AVAsset filters its AVMutableCompositionTracks. (Media types are defined in AVMediaFormat.h.)
        ///
        /// Parameter `completionHandler`: A block that is called when the loading is finished, with either the loaded tracks (which may be empty if no tracks of the specified media type are available) or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadTracksWithMediaType:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadTracksWithMediaType_completionHandler(
            &self,
            media_type: &AVMediaType,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut NSArray<AVMutableCompositionTrack>, *mut NSError),
            >,
        );

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "AVMediaFormat"
        ))]
        /// Provides an array of AVMutableCompositionTracks of the asset that present media with the specified characteristic.
        ///
        /// Parameter `mediaCharacteristic`: The media characteristic according to which the receiver filters its AVMutableCompositionTracks. (Media characteristics are defined in AVMediaFormat.h)
        ///
        /// Returns: An NSArray of AVMutableCompositionTracks; may be empty if no tracks with the specified characteristic are available.
        ///
        /// Becomes callable without blocking when the key
        /// "
        /// tracks" has been loaded
        #[unsafe(method(tracksWithMediaCharacteristic:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracksWithMediaCharacteristic(
            &self,
            media_characteristic: &AVMediaCharacteristic,
        ) -> Retained<NSArray<AVMutableCompositionTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "AVMediaFormat",
            feature = "block2"
        ))]
        /// Loads an array of AVMutableCompositionTracks of the asset that present media with the specified characteristic.
        ///
        /// Parameter `mediaCharacteristic`: The media characteristic according to which AVAsset filters its AVMutableCompositionTracks. (Media characteristics are defined in AVMediaFormat.h.)
        ///
        /// Parameter `completionHandler`: A block that is called when the loading is finished, with either the loaded tracks (which may be empty if no tracks with the specified characteristic are available) or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadTracksWithMediaCharacteristic:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadTracksWithMediaCharacteristic_completionHandler(
            &self,
            media_characteristic: &AVMediaCharacteristic,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut NSArray<AVMutableCompositionTrack>, *mut NSError),
            >,
        );
    );
}

/// SynchronousAssetInterface.
///
/// Redeclarations of async-only AVAsset interfaces to allow synchronous usage in the synchronous subclass.
///
/// See AVAsset's interface for more information about these interfaces.
#[cfg(feature = "AVAsset")]
impl AVComposition {
    extern_methods!(
        #[cfg(all(feature = "AVMetadataFormat", feature = "AVMetadataItem"))]
        #[unsafe(method(metadataForFormat:))]
        #[unsafe(method_family = none)]
        pub unsafe fn metadataForFormat(
            &self,
            format: &AVMetadataFormat,
        ) -> Retained<NSArray<AVMetadataItem>>;

        #[cfg(all(feature = "AVMetadataFormat", feature = "AVTimedMetadataGroup"))]
        #[unsafe(method(chapterMetadataGroupsWithTitleLocale:containingItemsWithCommonKeys:))]
        #[unsafe(method_family = none)]
        pub unsafe fn chapterMetadataGroupsWithTitleLocale_containingItemsWithCommonKeys(
            &self,
            locale: &NSLocale,
            common_keys: Option<&NSArray<AVMetadataKey>>,
        ) -> Retained<NSArray<AVTimedMetadataGroup>>;

        #[cfg(feature = "AVTimedMetadataGroup")]
        #[unsafe(method(chapterMetadataGroupsBestMatchingPreferredLanguages:))]
        #[unsafe(method_family = none)]
        pub unsafe fn chapterMetadataGroupsBestMatchingPreferredLanguages(
            &self,
            preferred_languages: &NSArray<NSString>,
        ) -> Retained<NSArray<AVTimedMetadataGroup>>;

        #[cfg(all(feature = "AVMediaFormat", feature = "AVMediaSelectionGroup"))]
        #[unsafe(method(mediaSelectionGroupForMediaCharacteristic:))]
        #[unsafe(method_family = none)]
        pub unsafe fn mediaSelectionGroupForMediaCharacteristic(
            &self,
            media_characteristic: &AVMediaCharacteristic,
        ) -> Option<Retained<AVMediaSelectionGroup>>;

        #[cfg(feature = "objc2-core-media")]
        #[unsafe(method(unusedTrackID))]
        #[unsafe(method_family = none)]
        pub unsafe fn unusedTrackID(&self) -> CMPersistentTrackID;
    );
}