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
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
//! 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/avmovietrack?language=objc)
    #[unsafe(super(AVAssetTrack, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "AVAssetTrack")]
    pub struct AVMovieTrack;
);

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

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

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

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

#[cfg(feature = "AVAssetTrack")]
impl AVMovieTrack {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// A CMTimeRange indicating the range of presentation times for the track's media.
        #[unsafe(method(mediaPresentationTimeRange))]
        #[unsafe(method_family = none)]
        pub unsafe fn mediaPresentationTimeRange(&self) -> CMTimeRange;

        #[cfg(feature = "objc2-core-media")]
        /// A CMTimeRange indicating the range of decode times for the track's media.
        #[unsafe(method(mediaDecodeTimeRange))]
        #[unsafe(method_family = none)]
        pub unsafe fn mediaDecodeTimeRange(&self) -> CMTimeRange;

        #[unsafe(method(alternateGroupID))]
        #[unsafe(method_family = none)]
        pub unsafe fn alternateGroupID(&self) -> NSInteger;
    );
}

/// Methods declared on superclass `AVAssetTrack`.
#[cfg(feature = "AVAssetTrack")]
impl AVMovieTrack {
    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>;
    );
}

/// AVMovieTrackMediaDataStorage.
#[cfg(feature = "AVAssetTrack")]
impl AVMovieTrack {
    extern_methods!(
        #[cfg(feature = "AVMovie")]
        /// The storage container for media data added to a track.
        ///
        /// The value of this property is an AVMediaDataStorage object that indicates the location at which media data inserted or appended to the track will be written.
        #[unsafe(method(mediaDataStorage))]
        #[unsafe(method_family = none)]
        pub unsafe fn mediaDataStorage(&self) -> Option<Retained<AVMediaDataStorage>>;
    );
}

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

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

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

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

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

#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        #[cfg(feature = "AVMovie")]
        /// The storage container for media data added to a track.
        ///
        /// The value of this property is an AVMediaDataStorage object that indicates the location at which media data inserted or appended to the track will be written.
        #[unsafe(method(mediaDataStorage))]
        #[unsafe(method_family = none)]
        pub unsafe fn mediaDataStorage(&self) -> Option<Retained<AVMediaDataStorage>>;

        #[cfg(feature = "AVMovie")]
        /// Setter for [`mediaDataStorage`][Self::mediaDataStorage].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setMediaDataStorage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMediaDataStorage(&self, media_data_storage: Option<&AVMediaDataStorage>);

        /// For file types that support writing sample references, such as QuickTime Movie files, specifies the base URL that sample references are relative to; may be nil.
        ///
        /// If the value of this property can be resolved as an absolute URL, the sample locations written to the file when appending sample references to this track will be relative to this URL. The URL must point to a location contained by any common parent directory of the locations that will be referenced. For example, setting the sampleReferenceBaseURL property to "file:///Users/johnappleseed/Movies/" and appending sample buffers that refer to "file:///Users/johnappleseed/Movies/data/movie1.mov" will cause the sample reference "data/movie1.mov" to be written to the movie file.
        ///
        /// If the value of the property cannot be resolved as an absolute URL or if it points to a location that is not contained by any common parent directory of the locations that will be referenced, the location will be written unmodified.
        ///
        /// The default value is nil, which means that the location will be written unmodified.
        #[unsafe(method(sampleReferenceBaseURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn sampleReferenceBaseURL(&self) -> Option<Retained<NSURL>>;

        /// Setter for [`sampleReferenceBaseURL`][Self::sampleReferenceBaseURL].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSampleReferenceBaseURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSampleReferenceBaseURL(&self, sample_reference_base_url: Option<&NSURL>);

        /// A BOOL value indicating whether the track is enabled by default for presentation.
        #[unsafe(method(isEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isEnabled(&self) -> bool;

        /// Setter for [`isEnabled`][Self::isEnabled].
        #[unsafe(method(setEnabled:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setEnabled(&self, enabled: bool);

        /// An integer indicating the track as a member of a particular alternate group.
        #[unsafe(method(alternateGroupID))]
        #[unsafe(method_family = none)]
        pub unsafe fn alternateGroupID(&self) -> NSInteger;

        /// Setter for [`alternateGroupID`][Self::alternateGroupID].
        #[unsafe(method(setAlternateGroupID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAlternateGroupID(&self, alternate_group_id: NSInteger);

        /// Whether a track has been modified.
        ///
        /// The value of this property is a BOOL that indicates whether the AVMutableMovieTrack object has been modified since it was created, was last written, or had its modified state cleared via a call to setModified:NO.
        #[unsafe(method(isModified))]
        #[unsafe(method_family = none)]
        pub unsafe fn isModified(&self) -> bool;

        /// Setter for [`isModified`][Self::isModified].
        #[unsafe(method(setModified:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setModified(&self, modified: bool);

        /// Whether a track contains protected content.
        ///
        /// The value of this property is a BOOL that indicates whether the track contains protected content.
        #[unsafe(method(hasProtectedContent))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasProtectedContent(&self) -> bool;

        #[cfg(feature = "objc2-core-media")]
        /// For file types that contain a 'moov' atom, such as QuickTime Movie files, specifies the time scale of the track's media.
        ///
        /// The default media time scale is 0.
        ///
        /// This property should be set on a new empty track before any edits are performed on the track.
        #[unsafe(method(timescale))]
        #[unsafe(method_family = none)]
        pub unsafe fn timescale(&self) -> CMTimeScale;

        #[cfg(feature = "objc2-core-media")]
        /// Setter for [`timescale`][Self::timescale].
        #[unsafe(method(setTimescale:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTimescale(&self, timescale: CMTimeScale);
    );
}

/// Methods declared on superclass `AVAssetTrack`.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    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>;
    );
}

/// AVMutableMovieTrackLanguageProperties.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        /// The language associated with the track.
        ///
        /// The value of this property is an ISO 639-2/T language code indicating the language associated with the track; may be nil if no language is indicated.
        #[unsafe(method(languageCode))]
        #[unsafe(method_family = none)]
        pub unsafe fn languageCode(&self) -> Option<Retained<NSString>>;

        /// Setter for [`languageCode`][Self::languageCode].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setLanguageCode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLanguageCode(&self, language_code: Option<&NSString>);

        /// The language tag associated with the track.
        ///
        /// The value of this property is an IETF BCP 47 (RFC 4646) language identifier indicating the language tag associated with the track; may be nil if no language tag is indicated.
        #[unsafe(method(extendedLanguageTag))]
        #[unsafe(method_family = none)]
        pub unsafe fn extendedLanguageTag(&self) -> Option<Retained<NSString>>;

        /// Setter for [`extendedLanguageTag`][Self::extendedLanguageTag].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setExtendedLanguageTag:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setExtendedLanguageTag(&self, extended_language_tag: Option<&NSString>);
    );
}

/// AVMutableMovieTrackVisualProperties.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        /// A CGSize indicating the dimensions at which the visual media data of the track should be displayed.
        #[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);

        #[cfg(feature = "objc2-core-foundation")]
        /// A CGAffineTransform indicating the transform specified in the track's storage container as the preferred transformation of the visual media data for display purposes; the value is often but not always CGAffineTransformIdentity.
        #[unsafe(method(preferredTransform))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredTransform(&self) -> CGAffineTransform;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`preferredTransform`][Self::preferredTransform].
        #[unsafe(method(setPreferredTransform:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredTransform(&self, preferred_transform: CGAffineTransform);

        /// The layer level of the visual media data of the track.
        #[unsafe(method(layer))]
        #[unsafe(method_family = none)]
        pub unsafe fn layer(&self) -> NSInteger;

        /// Setter for [`layer`][Self::layer].
        #[unsafe(method(setLayer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLayer(&self, layer: NSInteger);

        #[cfg(feature = "objc2-core-foundation")]
        /// A CGSize indicating the clean aperture dimensions of the track.
        #[unsafe(method(cleanApertureDimensions))]
        #[unsafe(method_family = none)]
        pub unsafe fn cleanApertureDimensions(&self) -> CGSize;

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

        #[cfg(feature = "objc2-core-foundation")]
        /// A CGSize indicating the production aperture dimensions of the track.
        #[unsafe(method(productionApertureDimensions))]
        #[unsafe(method_family = none)]
        pub unsafe fn productionApertureDimensions(&self) -> CGSize;

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

        #[cfg(feature = "objc2-core-foundation")]
        /// A CGSize indicating the dimensions encoded pixels dimensions of the track.
        #[unsafe(method(encodedPixelsDimensions))]
        #[unsafe(method_family = none)]
        pub unsafe fn encodedPixelsDimensions(&self) -> CGSize;

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

/// AVMutableMovieTrackAudibleProperties.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        /// The preferred volume of the audible media data of the track; often but not always 1.0.
        #[unsafe(method(preferredVolume))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredVolume(&self) -> c_float;

        /// Setter for [`preferredVolume`][Self::preferredVolume].
        #[unsafe(method(setPreferredVolume:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredVolume(&self, preferred_volume: c_float);
    );
}

/// AVMutableMovieTrackChunkProperties.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        /// For file types that support media chunk sizes, the maximum size (in bytes) to be used for each chunk of sample data written to the file.
        ///
        /// The total size of the samples in a chunk will be no larger than this preferred chunk size, or the size of a single sample if the sample is larger than this preferred chunk size.
        ///
        /// The default media chunk size is 1024 * 1024 bytes. It is an error to set a negative chunk size.
        #[unsafe(method(preferredMediaChunkSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredMediaChunkSize(&self) -> NSInteger;

        /// Setter for [`preferredMediaChunkSize`][Self::preferredMediaChunkSize].
        #[unsafe(method(setPreferredMediaChunkSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredMediaChunkSize(&self, preferred_media_chunk_size: NSInteger);

        #[cfg(feature = "objc2-core-media")]
        /// For file types that support media chunk durations, the maximum duration to be used for each chunk of sample data written to the file.
        ///
        ///
        /// The total duration of the samples in a chunk will be no greater than this preferred chunk duration, or the duration of a single sample if the sample's duration is greater than this preferred chunk duration.
        ///
        /// The default media chunk duration is 1.0 second. It is an error to set a chunk duration that is negative or non-numeric.
        #[unsafe(method(preferredMediaChunkDuration))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredMediaChunkDuration(&self) -> CMTime;

        #[cfg(feature = "objc2-core-media")]
        /// Setter for [`preferredMediaChunkDuration`][Self::preferredMediaChunkDuration].
        #[unsafe(method(setPreferredMediaChunkDuration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredMediaChunkDuration(&self, preferred_media_chunk_duration: CMTime);

        /// For file types that support media chunk alignment, the boundary for media chunk alignment (in bytes).
        ///
        ///
        /// The default value is 0, which means that no padding should be used to achieve chunk alignment. It is an error to set a negative value for chunk alignment.
        #[unsafe(method(preferredMediaChunkAlignment))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredMediaChunkAlignment(&self) -> NSInteger;

        /// Setter for [`preferredMediaChunkAlignment`][Self::preferredMediaChunkAlignment].
        #[unsafe(method(setPreferredMediaChunkAlignment:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredMediaChunkAlignment(
            &self,
            preferred_media_chunk_alignment: NSInteger,
        );
    );
}

/// AVMutableMovieTrackTrackLevelEditing.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// Inserts a portion of an AVAssetTrack object into the target movie.
        ///
        /// Parameter `timeRange`: The time range from the track from which media is to be inserted.
        ///
        /// Parameter `track`: An AVAssetTrack object indicating the source of the inserted media. Only AVAssetTracks of AVURLAssets and AVCompositions are supported.
        /// Must not be nil.
        ///
        /// Parameter `startTime`: The time in the target track at which the media is to be inserted.
        ///
        /// Parameter `copySampleData`: A BOOL value that indicates whether sample data is to be copied from the source to the destination during edits.
        /// If YES, the sample data is written to the file specified by the track property mediaDataStorage if non-nil,
        /// or else by the movie property defaultMediaDataStorage if non-nil; if both are nil, the method will fail and return NO.
        /// If NO, sample data will not be written and sample references to the samples in their original container will be added
        /// as necessary. Note that in this case, this method will fail if the original samples are fragmented.
        ///
        /// Parameter `outError`: If the insertion fails, describes the nature of the failure.
        ///
        /// Returns: A BOOL value that indicates the success of the insertion.
        #[unsafe(method(insertTimeRange:ofTrack:atTime:copySampleData:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertTimeRange_ofTrack_atTime_copySampleData_error(
            &self,
            time_range: CMTimeRange,
            track: &AVAssetTrack,
            start_time: CMTime,
            copy_sample_data: bool,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "objc2-core-media")]
        /// Adds an empty time range to the target track.
        ///
        /// Parameter `timeRange`: The time range to be made empty. Note that you cannot add empty time ranges to the end of a track.
        #[unsafe(method(insertEmptyTimeRange:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertEmptyTimeRange(&self, time_range: CMTimeRange);

        #[cfg(feature = "objc2-core-media")]
        /// Removes a specified time range from a track.
        ///
        /// Parameter `timeRange`: The time range to be removed.
        #[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 time range of a track.
        ///
        /// Parameter `timeRange`: The time range to be scaled.
        ///
        /// Parameter `duration`: The new duration of the time range.
        #[unsafe(method(scaleTimeRange:toDuration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn scaleTimeRange_toDuration(&self, time_range: CMTimeRange, duration: CMTime);
    );
}

/// AVMutableMovieTrackMetadataEditing.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        #[cfg(feature = "AVMetadataItem")]
        /// A collection of metadata stored by the track.
        ///
        /// The value of this property is an array of AVMetadataItem objects representing the collection of metadata stored by the track.
        #[unsafe(method(metadata))]
        #[unsafe(method_family = none)]
        pub unsafe fn metadata(&self) -> Retained<NSArray<AVMetadataItem>>;

        #[cfg(feature = "AVMetadataItem")]
        /// Setter for [`metadata`][Self::metadata].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setMetadata:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMetadata(&self, metadata: &NSArray<AVMetadataItem>);
    );
}

/// AVMutableMovieTrackTrackAssociations.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        /// Establishes a track association of a specific type between two tracks.
        ///
        /// Parameter `movieTrack`: An AVMovieTrack object that is to be associated with the receiver.
        ///
        /// Parameter `trackAssociationType`: The type of track association to add between the receiver and the specified movieTrack (for instance, AVTrackAssociationTypeChapterList).
        ///
        /// This method throws an exception if the movie track belongs to a different movie.
        #[unsafe(method(addTrackAssociationToTrack:type:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addTrackAssociationToTrack_type(
            &self,
            movie_track: &AVMovieTrack,
            track_association_type: &AVTrackAssociationType,
        );

        /// Removes a track association of a specific type between two tracks.
        ///
        /// Parameter `movieTrack`: An AVMovieTrack object that is associated with the receiver.
        ///
        /// Parameter `trackAssociationType`: The type of track association to remove between the receiver and the specified movieTrack (for instance, AVTrackAssociationTypeChapterList).
        ///
        /// This method throws an exception if the movie track belongs to a different movie.
        #[unsafe(method(removeTrackAssociationToTrack:type:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeTrackAssociationToTrack_type(
            &self,
            movie_track: &AVMovieTrack,
            track_association_type: &AVTrackAssociationType,
        );
    );
}

/// AVMutableMovieTrackFormatDescriptions.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// Replaces one of the receiver's format descriptions with another format description
        ///
        /// Parameter `formatDescription`: A CMFormatDescription occurring in the array returned by the -formatDescriptions method.
        ///
        /// Parameter `newFormatDescription`: A CMFormatDescription to replace the specified format description.
        ///
        /// You can use this method to make surgical changes to a track's format descriptions, such as adding format description extensions to a format description or changing the audio channel layout of an audio track. You should note that a format description can have extensions of type kCMFormatDescriptionExtension_VerbatimSampleDescription and kCMFormatDescriptionExtension_VerbatimISOSampleEntry; if you modify a copy of a format description, you should delete those extensions from the copy or your changes might be ignored.
        ///
        /// This method throws an exception if the media type of the new format description does not match the media type of the receiver.
        #[unsafe(method(replaceFormatDescription:withFormatDescription:))]
        #[unsafe(method_family = none)]
        pub unsafe fn replaceFormatDescription_withFormatDescription(
            &self,
            format_description: &CMFormatDescription,
            new_format_description: &CMFormatDescription,
        );
    );
}

/// AVMutableMovieTrackSampleLevelEditing.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// Appends sample data to a media file and adds sample references for the added data to a track's media sample tables.
        ///
        /// Parameter `sampleBuffer`: The CMSampleBuffer to be appended; this may be obtained from an instance of AVAssetReader.
        ///
        /// Parameter `outDecodeTime`: A pointer to a CMTime structure to receive the decode time in the media of the first sample appended from the sample buffer. Pass NULL if you do not need this information.
        ///
        /// Parameter `outPresentationTime`: A pointer to a CMTime structure to receive the presentation time in the media of the first sample appended from the sample buffer. Pass NULL if you do not need this information.
        ///
        /// Parameter `outError`: If the appending fails, describes the nature of the failure. For example, if the device containing the track's media data storage is full, AVErrorDiskFull is returned.
        ///
        /// Returns: A BOOL value indicating the success of the operation.
        ///
        /// If the sample buffer carries sample data, the sample data is written to the container specified by the track property mediaDataStorage if non-nil,
        /// or else by the movie property defaultMediaDataStorage if non-nil, and sample references will be appended to the track's media.
        /// If both media data storage properties are nil, the method will fail and return NO.
        /// If the sample buffer carries sample references only, sample data will not be written and sample references to the samples in their
        /// original container will be appended to the track's media as necessary.
        ///
        /// Note regarding sample timing: in a track's media, the first sample's decode timestamp must always be zero.
        /// For an audio track, each sample buffer's duration is used as the sample decode duration.
        /// For other track types, difference between a sample's decode timestamp and the following
        /// sample's decode timestamp is used as the first sample's decode duration, so as to preserve the relative timing.
        ///
        /// Note that this method does not modify the track's sourceTimeMappings but only appends sample references and sample data to the track's media.
        /// To make the new samples appear in the track's timeline, invoke -insertMediaTimeRange:intoTimeRange:.
        /// You can retrieve the mediaPresentationTimeRange property before and after appending a sequence of samples,
        /// using CMTimeRangeGetEnd on each to calculate the media TimeRange for -insertMediaTimeRange:intoTimeRange:.
        ///
        /// It's safe for multiple threads to call this method on different tracks at once.
        ///
        /// This method throws an exception for any of the following reasons:
        /// - the sample buffer's media type does not match the track's media type
        /// - the sample buffer contains image buffers (must contain encoded video)
        /// - the sample buffer contains caption groups (must contain encoded media data)
        ///
        /// # Safety
        ///
        /// - `out_decode_time` must be a valid pointer or null.
        /// - `out_presentation_time` must be a valid pointer or null.
        #[unsafe(method(appendSampleBuffer:decodeTime:presentationTime:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn appendSampleBuffer_decodeTime_presentationTime_error(
            &self,
            sample_buffer: &CMSampleBuffer,
            out_decode_time: *mut CMTime,
            out_presentation_time: *mut CMTime,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "objc2-core-media")]
        /// Inserts a reference to a media time range into a track.
        ///
        /// Parameter `mediaTimeRange`: The presentation time range of the media to be inserted.
        ///
        /// Parameter `trackTimeRange`: The time range of the track into which the media is to be inserted.
        ///
        /// Returns: A BOOL value indicating the success of the operation.
        ///
        /// Use this method after you have appended samples or sample references to a track's media.
        ///
        /// To specify that the media time range be played at its natural rate, pass mediaTimeRange.duration == trackTimeRange.duration;
        /// otherwise, the ratio between these is used to determine the playback rate.
        ///
        /// Pass kCMTimeInvalid for trackTimeRange.start to indicate that the segment should be appended to the end of the track.
        #[unsafe(method(insertMediaTimeRange:intoTimeRange:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertMediaTimeRange_intoTimeRange(
            &self,
            media_time_range: CMTimeRange,
            track_time_range: CMTimeRange,
        ) -> bool;
    );
}

extern "C" {
    /// Posted when the timeRange of an AVFragmentedMovieTrack changes while the associated instance of AVFragmentedMovie is being minded by an AVFragmentedMovieMinder, but only for changes that occur after the status of the value of
    /// "
    /// timeRange" has reached AVKeyValueStatusLoaded.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avfragmentedmovietracktimerangedidchangenotification?language=objc)
    pub static AVFragmentedMovieTrackTimeRangeDidChangeNotification: &'static NSString;
}

extern "C" {
    /// Posted when the array of segments of an AVFragmentedMovieTrack changes while the associated instance of AVFragmentedMovie is being minded by an AVFragmentedMovieMinder, but only for changes that occur after the status of the value of
    /// "
    /// segments" has reached AVKeyValueStatusLoaded.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avfragmentedmovietracksegmentsdidchangenotification?language=objc)
    pub static AVFragmentedMovieTrackSegmentsDidChangeNotification: &'static NSString;
}

extern "C" {
    /// This notification name has been deprecated. Use either AVFragmentedMovieTrackTimeRangeDidChangeNotification or AVFragmentedMovieTrackSegmentsDidChangeNotification instead; in either case, you can assume that timing changes to fragmented tracks result in changes to the total length of the sample data used by the track.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avfragmentedmovietracktotalsampledatalengthdidchangenotification?language=objc)
    #[deprecated = "Upon receipt of either AVFragmentedMovieTrackTimeRangeDidChangeNotification or AVFragmentedMovieTrackSegmentsDidChangeNotification, you can assume that the sender's totalSampleDataLength has changed."]
    pub static AVFragmentedMovieTrackTotalSampleDataLengthDidChangeNotification: &'static NSString;
}

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

#[cfg(feature = "AVAssetTrack")]
unsafe impl Send for AVFragmentedMovieTrack {}

#[cfg(feature = "AVAssetTrack")]
unsafe impl Sync for AVFragmentedMovieTrack {}

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

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

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

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

#[cfg(feature = "AVAssetTrack")]
impl AVFragmentedMovieTrack {
    extern_methods!();
}

/// Methods declared on superclass `AVAssetTrack`.
#[cfg(feature = "AVAssetTrack")]
impl AVFragmentedMovieTrack {
    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>;
    );
}

/// SynchronousTrackInterface.
///
/// Redeclarations of async-only AVAssetTrack interfaces to allow synchronous usage in the synchronous subclass.
///
/// See AVAssetTrack's interface for more information about these interfaces.
#[cfg(feature = "AVAssetTrack")]
impl AVMutableMovieTrack {
    extern_methods!(
        #[cfg(feature = "AVMediaFormat")]
        #[unsafe(method(hasMediaCharacteristic:))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasMediaCharacteristic(
            &self,
            media_characteristic: &AVMediaCharacteristic,
        ) -> bool;

        #[cfg(all(feature = "AVAssetTrackSegment", feature = "objc2-core-media"))]
        #[unsafe(method(segmentForTrackTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn segmentForTrackTime(
            &self,
            track_time: CMTime,
        ) -> Option<Retained<AVAssetTrackSegment>>;

        #[cfg(feature = "objc2-core-media")]
        #[unsafe(method(samplePresentationTimeForTrackTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn samplePresentationTimeForTrackTime(&self, track_time: CMTime) -> CMTime;

        #[cfg(all(feature = "AVMetadataFormat", feature = "AVMetadataItem"))]
        #[unsafe(method(metadataForFormat:))]
        #[unsafe(method_family = none)]
        pub unsafe fn metadataForFormat(
            &self,
            format: &AVMetadataFormat,
        ) -> Retained<NSArray<AVMetadataItem>>;

        #[unsafe(method(associatedTracksOfType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn associatedTracksOfType(
            &self,
            track_association_type: &AVTrackAssociationType,
        ) -> Retained<NSArray<AVAssetTrack>>;
    );
}