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
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
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
//! 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 "C" {
    /// Indicates the restrictions used by the movie when resolving references to external media data. The value of this key is an NSNumber wrapping an AVAssetReferenceRestrictions enum value or the logical combination of multiple such values. See AVAsset.h for the declaration of the AVAssetReferenceRestrictions enum.
    ///
    /// Some movies can contain references to media data stored outside the movie's container, for example in another file. This key can be used to specify a policy to use when these references are encountered. If a movie contains one or more references of a type that is forbidden by the reference restrictions, loading of movie properties will fail. In addition, such a movie cannot be used with other AVFoundation modules, such as AVPlayerItem or AVAssetExportSession.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmoviereferencerestrictionskey?language=objc)
    pub static AVMovieReferenceRestrictionsKey: &'static NSString;
}

extern "C" {
    /// Indicates whether alias data references in the movie should be parsed and resolved.
    ///
    /// Default is NO. Although the majority of QuickTime movie files contain all of the media data they require, some contain references to media stored in other files. While AVFoundation and CoreMedia typically employ a URL reference for this purpose, older implementations such as QuickTime 7 have commonly employed a Macintosh alias instead, as documented in the QuickTime File Format specification. If your application must work with legacy QuickTime movie files containing alias-based references to media data stored in other files, the use of this AVMovie initialization option is appropriate. AVMovie and AVMutableMovie do not create movies using alias data references to external media files.
    ///
    /// If you provide a value for AVMovieReferenceRestrictionsKey, restrictions will be observed for resolved alias references just as they are for URL references.
    ///
    /// For more details about alias resolution, consult documentation of the bookmark-related interfaces of NSURL.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmovieshouldsupportaliasdatareferenceskey?language=objc)
    pub static AVMovieShouldSupportAliasDataReferencesKey: &'static NSString;
}

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

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

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

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

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

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

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

#[cfg(feature = "AVAsset")]
impl AVMovie {
    extern_methods!(
        #[cfg(feature = "AVMediaFormat")]
        /// Provides the file types the AVMovie class understands.
        ///
        /// Returns: An NSArray of UTIs identifying the file types the AVMovie class understands.
        #[unsafe(method(movieTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieTypes() -> Retained<NSArray<AVFileType>>;

        /// Creates an AVMovie object from a movie header stored in a QuickTime movie file or ISO base media file.
        ///
        /// Parameter `URL`: An NSURL object that specifies a file containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from a file and then append sample buffers to any of its tracks, you must first set one of these properties
        /// to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(movieWithURL:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieWithURL_options(
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Creates an AVMovie object from a movie header stored in a QuickTime movie file or ISO base media file.
        ///
        /// Parameter `URL`: An NSURL object that specifies a file containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from a file and then append sample buffers to any of its tracks, you must first set one of these properties
        /// to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithURL:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL_options(
            this: Allocated<Self>,
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Creates an AVMovie object from a movie header stored in an NSData object.
        ///
        /// Parameter `data`: An NSData object containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// You can use this method to operate on movie headers that are not stored in files; this might include movie headers on the pasteboard (which do not contain media data). In general you should avoid loading an entire movie file with its media data into an instance of NSData! By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(movieWithData:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieWithData_options(
            data: &NSData,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Creates an AVMovie object from a movie header stored in an NSData object.
        ///
        /// Parameter `data`: An NSData object containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// You can use this method to operate on movie headers that are not stored in files. In general you should avoid loading an entire movie file with its media data into an instance of NSData!
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil. If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithData:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithData_options(
            this: Allocated<Self>,
            data: &NSData,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// The URL with which the instance of AVMovie was initialized; may be nil.
        #[unsafe(method(URL))]
        #[unsafe(method_family = none)]
        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;

        /// The data block with which the instance of AVMovie was initialized; may be nil.
        #[unsafe(method(data))]
        #[unsafe(method_family = none)]
        pub unsafe fn data(&self) -> Option<Retained<NSData>>;

        /// The default storage container for media data added to a movie.
        ///
        /// The value of this property is an AVMediaDataStorage object that indicates where sample data that is added to a movie should be written by default.
        #[unsafe(method(defaultMediaDataStorage))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultMediaDataStorage(&self) -> Option<Retained<AVMediaDataStorage>>;

        #[cfg(all(feature = "AVAssetTrack", feature = "AVMovieTrack"))]
        /// The tracks in a movie.
        ///
        /// The value of this property is an array of tracks the movie contains; the tracks are of type AVMovieTrack.
        #[unsafe(method(tracks))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracks(&self) -> Retained<NSArray<AVMovieTrack>>;

        /// Indicates whether the movie file is capable of being extended by fragments.
        ///
        /// The value of this property is YES if an 'mvex' box is present in the 'moov' box. The 'mvex' box is necessary in order to signal the possible presence of later 'moof' boxes.
        #[unsafe(method(canContainMovieFragments))]
        #[unsafe(method_family = none)]
        pub unsafe fn canContainMovieFragments(&self) -> bool;

        /// Indicates whether the movie file is extended by at least one movie fragment.
        ///
        /// The value of this property is YES if canContainMovieFragments is YES and at least one 'moof' box is present after the 'moov' box.
        #[unsafe(method(containsMovieFragments))]
        #[unsafe(method_family = none)]
        pub unsafe fn containsMovieFragments(&self) -> bool;
    );
}

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

/// These options can be passed into writeMovieHeaderToURL:fileType:options:error: to control the writing of a movie header to a destination URL.
///
/// Writing the movie header will remove any existing movie header in the destination file and add a new movie header, preserving any other data in the file. If the destination file was empty, a file type box will be written at the beginning of the file.
///
/// If set, writing the movie header will truncate all existing data in the destination file and write a new movie header, thereby creating a pure reference movie file. A file type box will be written at the beginning of the file.
///
/// You would not want to use the AVMovieWritingTruncateDestinationToMovieHeaderOnly option if you had written sample data to the destination file using (for example) -[AVMutableMovie insertTimeRange:ofAsset:atTime:copySampleData:error:] with copySampleData set to YES, since that data would be lost.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmoviewritingoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVMovieWritingOptions(pub NSUInteger);
bitflags::bitflags! {
    impl AVMovieWritingOptions: NSUInteger {
        #[doc(alias = "AVMovieWritingAddMovieHeaderToDestination")]
        const AddMovieHeaderToDestination = 0;
        #[doc(alias = "AVMovieWritingTruncateDestinationToMovieHeaderOnly")]
        const TruncateDestinationToMovieHeaderOnly = 1<<0;
    }
}

unsafe impl Encode for AVMovieWritingOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for AVMovieWritingOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// AVMovieMovieHeaderSupport.
#[cfg(feature = "AVAsset")]
impl AVMovie {
    extern_methods!(
        #[cfg(feature = "AVMediaFormat")]
        /// Creates an NSData object containing the movie header of the AVMovie object.
        ///
        /// Parameter `fileType`: A UTI indicating the specific file format of the movie header (e.g. AVFileTypeQuickTimeMovie for a QuickTime movie).
        ///
        /// Parameter `outError`: If an error occurs reading the movie header, describes the nature of the failure.
        ///
        /// Returns: An NSData object.
        ///
        /// The movie header will be a pure reference movie, with no base URL, suitable for use on the pasteboard.
        #[unsafe(method(movieHeaderWithFileType:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieHeaderWithFileType_error(
            &self,
            file_type: &AVFileType,
        ) -> Result<Retained<NSData>, Retained<NSError>>;

        #[cfg(feature = "AVMediaFormat")]
        /// Writes the movie header to a destination URL.
        ///
        /// Parameter `URL`: An NSURL object indicating where to write the movie header.
        ///
        /// Parameter `fileType`: A UTI indicating the specific file format (e.g. AVFileTypeQuickTimeMovie for a QuickTime movie).
        ///
        /// Parameter `options`: An NSUInteger whose bits specify options for the writing of the movie header. See AVMovieWritingOptions above.
        ///
        /// Parameter `outError`: If an error occurs writing the movie header, describes the nature of the failure.
        ///
        /// Note that modifications to instances of AVMutableMovie, to their constituent AVMutableMovieTracks, or to their collections of metadata are committed to storage when their movie headers are written.
        #[unsafe(method(writeMovieHeaderToURL:fileType:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn writeMovieHeaderToURL_fileType_options_error(
            &self,
            url: &NSURL,
            file_type: &AVFileType,
            options: AVMovieWritingOptions,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "AVMediaFormat")]
        /// Indicates whether a movie header for the AVMovie object can be created for the specified file type.
        ///
        /// Parameter `fileType`: A UTI indicating a movie file format (e.g. AVFileTypeQuickTimeMovie for a QuickTime movie).
        ///
        /// This method returns a BOOL that indicates whether a movie header of the specified type can be created for the receiver. For example, this method returns NO if the movie contains tracks whose media types or media subtypes are not allowed by the specified file type.
        #[unsafe(method(isCompatibleWithFileType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn isCompatibleWithFileType(&self, file_type: &AVFileType) -> bool;
    );
}

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

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMovieTrack",
            feature = "block2",
            feature = "objc2-core-media"
        ))]
        /// Loads an instance of AVMovieTrack that represents the track of the specified trackID.
        ///
        /// Parameter `trackID`: The trackID of the requested AVMovieTrack.
        ///
        /// 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 AVMovieTrack, *mut NSError)>,
        );

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

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMediaFormat",
            feature = "AVMovieTrack",
            feature = "block2"
        ))]
        /// Loads an array of AVMovieTracks of the asset that present media of the specified media type.
        ///
        /// Parameter `mediaType`: The media type according to which AVAsset filters its AVMovieTracks. (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<AVMovieTrack>, *mut NSError)>,
        );

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

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMediaFormat",
            feature = "AVMovieTrack",
            feature = "block2"
        ))]
        /// Loads an array of AVMovieTracks of the asset that present media with the specified characteristic.
        ///
        /// Parameter `mediaCharacteristic`: The media characteristic according to which AVAsset filters its AVMovieTracks. (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<AVMovieTrack>, *mut NSError)>,
        );
    );
}

extern_class!(
    /// AVMutableMovie adds to its immutable superclass, AVMovie, several categories of methods for editing QuickTime movie files, e.g. inserting and removing time ranges of media, adding and removing tracks, and modifying the metadata collections stored therein.
    ///
    ///
    /// By default, after creating an AVMutableMovie the defaultMediaDataStorage property will be nil and each associated AVMutableMovieTrack's mediaDataStorage property will be nil. If you want to create an AVMutableMovie from a file and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmutablemovie?language=objc)
    #[unsafe(super(AVMovie, AVAsset, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "AVAsset")]
    pub struct AVMutableMovie;
);

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

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

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

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

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

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

#[cfg(feature = "AVAsset")]
impl AVMutableMovie {
    extern_methods!(
        /// Creates an AVMutableMovie object from a movie header stored in a QuickTime movie file or ISO base media file.
        ///
        /// Parameter `URL`: An NSURL object that specifies a file containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMutableMovie object.
        ///
        /// Parameter `outError`: If an error occurs creating a movie, describes the nature of the failure.
        ///
        /// Returns: An AVMutableMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMutableMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from a file and then append sample buffers to any of its tracks, you must first set one of these properties
        /// to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(movieWithURL:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieWithURL_options_error(
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        /// Creates an AVMutableMovie object from a movie header stored in a QuickTime movie file or ISO base media file.
        ///
        /// Parameter `URL`: An NSURL object that specifies a file containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMutableMovie object.
        ///
        /// Parameter `outError`: If an error occurs creating a movie, describes the nature of the failure.
        ///
        /// Returns: An AVMutableMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMutableMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from a file and then append sample buffers to any of its tracks, you must first set one of these properties
        /// to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithURL:options:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL_options_error(
            this: Allocated<Self>,
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        /// Creates an AVMutableMovie object from a movie header stored in an NSData object.
        ///
        /// Parameter `data`: An NSData object containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMutableMovie object.
        ///
        /// Parameter `outError`: If an error occurs creating a movie, describes the nature of the failure.
        ///
        /// Returns: An AVMutableMovie object
        ///
        /// You can use this method to operate on movie headers that are not stored in files. In general you should avoid loading an entire movie file with its media data into an instance of NSData!
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMutableMovieTrack's mediaDataStorage property will be nil. If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(movieWithData:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieWithData_options_error(
            data: &NSData,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        /// Creates an AVMutableMovie object from a movie header stored in an NSData object.
        ///
        /// Parameter `data`: An NSData object containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMutableMovie object.
        ///
        /// Parameter `outError`: If an error occurs creating a movie, describes the nature of the failure.
        ///
        /// Returns: An AVMutableMovie object
        ///
        /// You can use this method to operate on movie headers that are not stored in files. In general you should avoid loading an entire movie file with its media data into an instance of NSData!
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMutableMovieTrack's mediaDataStorage property will be nil. If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithData:options:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithData_options_error(
            this: Allocated<Self>,
            data: &NSData,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        /// Creates an AVMutableMovie object without tracks (and therefore without media).
        ///
        /// Parameter `movie`: If you wish to transfer settings from an existing movie (including movie userdata and metadata, preferred rate, preferred volume, etc.), pass a reference to an AVMovie object representing that movie. Otherwise pass nil. The userdata and metadata from the source movie may need to be converted if the format of that movie differs from fileType; you may wish to inspect the userdata or metadata of the receiver to ensure that important data was copied.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMutableMovie object. Pass nil for default initialization behavior.
        ///
        /// Parameter `outError`: If an error occurs creating a movie, describes the nature of the failure.
        ///
        /// Returns: An AVMutableMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(movieWithSettingsFromMovie:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieWithSettingsFromMovie_options_error(
            movie: Option<&AVMovie>,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        /// Creates an AVMutableMovie object without tracks (and therefore without media).
        ///
        /// Parameter `movie`: If you wish to transfer settings from an existing movie (including movie userdata and metadata, preferred rate, preferred volume, etc.), pass a reference to an AVMovie object representing that movie. Otherwise pass nil. The userdata and metadata from the source movie may need to be converted if the format of that movie differs from fileType; you may wish to inspect the userdata or metadata of the receiver to ensure that important data was copied.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMutableMovie object. Pass nil for default initialization behavior.
        ///
        /// Parameter `outError`: If an error occurs creating a movie, describes the nature of the failure.
        ///
        /// Returns: An AVMutableMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithSettingsFromMovie:options:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSettingsFromMovie_options_error(
            this: Allocated<Self>,
            movie: Option<&AVMovie>,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        /// The natural rate at which the movie is to be played; often but not always 1.0.
        #[unsafe(method(preferredRate))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredRate(&self) -> c_float;

        /// Setter for [`preferredRate`][Self::preferredRate].
        #[unsafe(method(setPreferredRate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredRate(&self, preferred_rate: c_float);

        /// The preferred volume of the audible media data of the movie; 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);

        #[cfg(feature = "objc2-core-foundation")]
        /// A CGAffineTransform indicating the transform specified in the movie'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);

        #[cfg(feature = "objc2-core-media")]
        /// For file types that contain a 'moov' atom, such as QuickTime Movie files, specifies the time scale of the movie.
        ///
        /// The default movie time scale is 600. In certain cases, you may want to set this to a different value. For instance, a movie that
        /// contains a single audio track should typically have the movie time scale set to the media time scale of that track.
        ///
        /// This property should be set on a new empty movie before any edits are performed on the movie.
        #[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);

        #[cfg(all(feature = "AVAssetTrack", feature = "AVMovieTrack"))]
        /// The tracks in a mutable movie.
        ///
        /// The value of this property is an array of tracks the mutable movie contains; the tracks are of type AVMutableMovieTrack.
        #[unsafe(method(tracks))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracks(&self) -> Retained<NSArray<AVMutableMovieTrack>>;
    );
}

/// Methods declared on superclass `AVMovie`.
#[cfg(feature = "AVAsset")]
impl AVMutableMovie {
    extern_methods!(
        /// Creates an AVMovie object from a movie header stored in a QuickTime movie file or ISO base media file.
        ///
        /// Parameter `URL`: An NSURL object that specifies a file containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from a file and then append sample buffers to any of its tracks, you must first set one of these properties
        /// to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(movieWithURL:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieWithURL_options(
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Creates an AVMovie object from a movie header stored in a QuickTime movie file or ISO base media file.
        ///
        /// Parameter `URL`: An NSURL object that specifies a file containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from a file and then append sample buffers to any of its tracks, you must first set one of these properties
        /// to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithURL:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL_options(
            this: Allocated<Self>,
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Creates an AVMovie object from a movie header stored in an NSData object.
        ///
        /// Parameter `data`: An NSData object containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// You can use this method to operate on movie headers that are not stored in files; this might include movie headers on the pasteboard (which do not contain media data). In general you should avoid loading an entire movie file with its media data into an instance of NSData! By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(movieWithData:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieWithData_options(
            data: &NSData,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Creates an AVMovie object from a movie header stored in an NSData object.
        ///
        /// Parameter `data`: An NSData object containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// You can use this method to operate on movie headers that are not stored in files. In general you should avoid loading an entire movie file with its media data into an instance of NSData!
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil. If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithData:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithData_options(
            this: Allocated<Self>,
            data: &NSData,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;
    );
}

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

/// AVMutableMovieMovieLevelEditing.
#[cfg(feature = "AVAsset")]
impl AVMutableMovie {
    extern_methods!(
        /// Whether a movie has been modified.
        ///
        /// The value of this property is a BOOL that indicates whether the AVMutableMovie 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);

        /// The default storage container for media data added to a movie.
        ///
        /// The value of this property is an AVMediaDataStorage object that indicates where sample data that is added to a movie should be written, for any track for whose mediaDataStorage property is nil.
        #[unsafe(method(defaultMediaDataStorage))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultMediaDataStorage(&self) -> Option<Retained<AVMediaDataStorage>>;

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

        #[cfg(feature = "objc2-core-media")]
        /// A CMTime that indicates the duration for interleaving runs of samples of each track.
        ///
        /// The default interleaving period is 0.5 seconds.
        #[unsafe(method(interleavingPeriod))]
        #[unsafe(method_family = none)]
        pub unsafe fn interleavingPeriod(&self) -> CMTime;

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

        #[cfg(feature = "objc2-core-media")]
        /// Inserts all the tracks of a timeRange of an asset into a movie.
        ///
        /// Parameter `timeRange`: The time range of the asset to be inserted.
        ///
        /// Parameter `asset`: An AVAsset object indicating the source of the inserted media. Only instances of AVURLAsset and AVComposition are supported.
        /// Must not be nil.
        ///
        /// Parameter `startTime`: The time in the target movie 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 location 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 source AVAsset is not able to provide sample reference information for the original container.
        ///
        /// Parameter `outError`: If the insertion fails, an NSError object that describes the nature of the failure.
        ///
        /// Returns: A BOOL value that indicates the success of the insertion.
        ///
        /// This method may add new tracks to the target movie to ensure that all tracks of the asset are represented in the inserted timeRange.
        /// Existing content at the specified startTime will be pushed out by the duration of timeRange.
        /// Note that metadata will not be automatically copied.
        #[unsafe(method(insertTimeRange:ofAsset:atTime:copySampleData:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertTimeRange_ofAsset_atTime_copySampleData_error(
            &self,
            time_range: CMTimeRange,
            asset: &AVAsset,
            start_time: CMTime,
            copy_sample_data: bool,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "objc2-core-media")]
        /// Adds an empty time range to the target movie.
        ///
        /// Parameter `timeRange`: The time range to be made empty. Note that you cannot add empty time ranges to the end of a movie.
        #[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 movie.
        ///
        /// 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 movie.
        ///
        /// 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);
    );
}

/// AVMutableMovieTrackLevelEditing.
#[cfg(feature = "AVAsset")]
impl AVMutableMovie {
    extern_methods!(
        #[cfg(all(feature = "AVAssetTrack", feature = "AVMovieTrack"))]
        /// Provides a reference to a track of a mutable movie into which any time range of an AVAssetTrack
        /// can be inserted (via -[AVMutableMovieTrack insertTimeRange:ofTrack:atTime:copySampleData:error:]).
        ///
        /// Parameter `track`: A reference to the AVAssetTrack from which a time range may be inserted.
        ///
        /// Returns: An AVMutableMovieTrack that can accommodate the insertion.
        /// If no such track is available, the result is nil. A new track of the same media type
        /// as the AVAssetTrack can be created via -addMutableTrackWithMediaType:copySettingsFromTrack:options:,
        /// and this new track will be compatible.
        ///
        /// For best performance, the number of tracks in a movie 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.
        #[unsafe(method(mutableTrackCompatibleWithTrack:))]
        #[unsafe(method_family = none)]
        pub unsafe fn mutableTrackCompatibleWithTrack(
            &self,
            track: &AVAssetTrack,
        ) -> Option<Retained<AVMutableMovieTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMediaFormat",
            feature = "AVMovieTrack"
        ))]
        /// Adds an empty track to the target movie.
        ///
        /// Parameter `mediaType`: The media type of the new track (e.g. AVMediaTypeVideo for a video track).
        ///
        /// Parameter `track`: If you wish to transfer settings from an existing track, including width, height, preferred volume, etc., pass a reference to an AVAssetTrack representing that track. Otherwise pass nil.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the new AVMutableMovieTrack object. Pass nil for default initialization behavior.
        ///
        /// Returns: An AVMutableMovieTrack object
        ///
        /// The trackID of the newly added track is a property of the returned instance of AVMutableMovieTrack.
        /// This method throws an exception if media type is not equal to the track's media type, or if any option is invalid.
        /// Note that metadata will not be automatically copied.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(addMutableTrackWithMediaType:copySettingsFromTrack:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addMutableTrackWithMediaType_copySettingsFromTrack_options(
            &self,
            media_type: &AVMediaType,
            track: Option<&AVAssetTrack>,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Option<Retained<AVMutableMovieTrack>>;

        #[cfg(all(feature = "AVAssetTrack", feature = "AVMovieTrack"))]
        /// Adds one or more empty tracks to the target movie, copying track settings from the source tracks.
        ///
        /// Parameter `existingTracks`: An array of AVAssetTrack objects.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the new AVMutableMovieTrack objects. Pass nil for default initialization behavior.
        ///
        /// Returns: An array of AVMutableMovieTrack objects; the index of a track in this array is the same as the index of its source track in the existingTracks array.
        ///
        /// This method creates one or more empty tracks in the target movie and configures those tracks with settings (such as track userdata and metadata, width, height, and preferred volume) copied from the source tracks in the existingTracks array. Also, properties involving pairs of tracks (such as track references) are copied from the source tracks to the target tracks.
        /// This method throws an exception if any option is invalid.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(addMutableTracksCopyingSettingsFromTracks:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addMutableTracksCopyingSettingsFromTracks_options(
            &self,
            existing_tracks: &NSArray<AVAssetTrack>,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<NSArray<AVMutableMovieTrack>>;

        #[cfg(all(feature = "AVAssetTrack", feature = "AVMovieTrack"))]
        /// Removes a track from the target movie.
        ///
        /// Parameter `track`: The track to be removed.
        #[unsafe(method(removeTrack:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeTrack(&self, track: &AVMovieTrack);
    );
}

/// AVMutableMovieMetadataEditing.
#[cfg(feature = "AVAsset")]
impl AVMutableMovie {
    extern_methods!(
        #[cfg(feature = "AVMetadataItem")]
        /// A collection of metadata stored by the movie.
        ///
        /// The value of this property is an array of AVMetadataItem objects representing the collection of metadata stored by the movie.
        #[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>);
    );
}

/// AVMutableMovieTrackInspection.
#[cfg(feature = "AVAsset")]
impl AVMutableMovie {
    extern_methods!(
        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMovieTrack",
            feature = "objc2-core-media"
        ))]
        /// Provides an instance of AVMutableMovieTrack that represents the track of the specified trackID.
        ///
        /// Parameter `trackID`: The trackID of the requested AVMutableMovieTrack.
        ///
        /// Returns: An instance of AVMutableMovieTrack; 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<AVMutableMovieTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMovieTrack",
            feature = "block2",
            feature = "objc2-core-media"
        ))]
        /// Loads an instance of AVMutableMovieTrack that represents the track of the specified trackID.
        ///
        /// Parameter `trackID`: The trackID of the requested AVMutableMovieTrack.
        ///
        /// 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 AVMutableMovieTrack, *mut NSError)>,
        );

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMediaFormat",
            feature = "AVMovieTrack"
        ))]
        /// Provides an array of AVMutableMovieTracks of the asset that present media of the specified media type.
        ///
        /// Parameter `mediaType`: The media type according to which the receiver filters its AVMutableMovieTracks. (Media types are defined in AVMediaFormat.h)
        ///
        /// Returns: An NSArray of AVMutableMovieTracks; 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<AVMutableMovieTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMediaFormat",
            feature = "AVMovieTrack",
            feature = "block2"
        ))]
        /// Loads an array of AVMutableMovieTracks of the asset that present media of the specified media type.
        ///
        /// Parameter `mediaType`: The media type according to which AVAsset filters its AVMutableMovieTracks. (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<AVMutableMovieTrack>, *mut NSError),
            >,
        );

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMediaFormat",
            feature = "AVMovieTrack"
        ))]
        /// Provides an array of AVMutableMovieTracks of the asset that present media with the specified characteristic.
        ///
        /// Parameter `mediaCharacteristic`: The media characteristic according to which the receiver filters its AVMutableMovieTracks. (Media characteristics are defined in AVMediaFormat.h)
        ///
        /// Returns: An NSArray of AVMutableMovieTracks; 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<AVMutableMovieTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMediaFormat",
            feature = "AVMovieTrack",
            feature = "block2"
        ))]
        /// Loads an array of AVMutableMovieTracks of the asset that present media with the specified characteristic.
        ///
        /// Parameter `mediaCharacteristic`: The media characteristic according to which AVAsset filters its AVMutableMovieTracks. (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<AVMutableMovieTrack>, *mut NSError),
            >,
        );
    );
}

extern_class!(
    /// Media sample data storage file.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avmediadatastorage?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVMediaDataStorage;
);

unsafe impl Send for AVMediaDataStorage {}

unsafe impl Sync for AVMediaDataStorage {}

extern_conformance!(
    unsafe impl NSObjectProtocol for AVMediaDataStorage {}
);

impl AVMediaDataStorage {
    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>;

        /// Creates an AVMediaDataStorage object associated with a file URL.
        ///
        /// Parameter `URL`: An NSURL object that specifies a file where sample data that is added to a movie or track should be written.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMediaDataStorage object. Currently no keys are defined.
        ///
        /// Returns: An AVMediaDataStorage object
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithURL:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL_options(
            this: Allocated<Self>,
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// The URL from which the receiver was initialized; may be nil.
        #[unsafe(method(URL))]
        #[unsafe(method_family = none)]
        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
    );
}

extern "C" {
    /// Posted after the value of
    /// "
    /// containsMovieFragments" has already been loaded and the AVFragmentedMovie is added to an AVFragmentedMovieMinder, either when 1) movie fragments are detected in the movie file on disk after it had previously contained none or when 2) no movie fragments are detected in the movie file on disk after it had previously contained one or more.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avfragmentedmoviecontainsmoviefragmentsdidchangenotification?language=objc)
    pub static AVFragmentedMovieContainsMovieFragmentsDidChangeNotification: &'static NSString;
}

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

extern "C" {
    /// Posted when the movie file on disk is defragmented while an AVFragmentedMovie is being minded by an AVFragmentedMovieMinder, but only if the defragmentation occurs after the status of the value of
    /// "
    /// canContainMovieFragments" has reached AVKeyValueStatusLoaded.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avfragmentedmoviewasdefragmentednotification?language=objc)
    pub static AVFragmentedMovieWasDefragmentedNotification: &'static NSString;
}

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

#[cfg(feature = "AVAsset")]
unsafe impl Send for AVFragmentedMovie {}

#[cfg(feature = "AVAsset")]
unsafe impl Sync for AVFragmentedMovie {}

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

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

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

#[cfg(feature = "AVAsset")]
impl AVFragmentedMovie {
    extern_methods!(
        #[cfg(all(feature = "AVAssetTrack", feature = "AVMovieTrack"))]
        /// The tracks in a movie.
        ///
        /// The value of this property is an array of tracks the movie contains; the tracks are of type AVFragmentedMovieTrack.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(tracks))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracks(&self) -> Retained<NSArray<AVFragmentedMovieTrack>>;
    );
}

/// Methods declared on superclass `AVMovie`.
#[cfg(feature = "AVAsset")]
impl AVFragmentedMovie {
    extern_methods!(
        /// Creates an AVMovie object from a movie header stored in a QuickTime movie file or ISO base media file.
        ///
        /// Parameter `URL`: An NSURL object that specifies a file containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from a file and then append sample buffers to any of its tracks, you must first set one of these properties
        /// to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(movieWithURL:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieWithURL_options(
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Creates an AVMovie object from a movie header stored in a QuickTime movie file or ISO base media file.
        ///
        /// Parameter `URL`: An NSURL object that specifies a file containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from a file and then append sample buffers to any of its tracks, you must first set one of these properties
        /// to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithURL:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL_options(
            this: Allocated<Self>,
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Creates an AVMovie object from a movie header stored in an NSData object.
        ///
        /// Parameter `data`: An NSData object containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// You can use this method to operate on movie headers that are not stored in files; this might include movie headers on the pasteboard (which do not contain media data). In general you should avoid loading an entire movie file with its media data into an instance of NSData! By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil.
        /// If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(movieWithData:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn movieWithData_options(
            data: &NSData,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Creates an AVMovie object from a movie header stored in an NSData object.
        ///
        /// Parameter `data`: An NSData object containing a movie header.
        ///
        /// Parameter `options`: An NSDictionary object that contains keys for specifying options for the initialization of the AVMovie object.
        ///
        /// Returns: An AVMovie object
        ///
        /// You can use this method to operate on movie headers that are not stored in files. In general you should avoid loading an entire movie file with its media data into an instance of NSData!
        ///
        /// By default, the defaultMediaDataStorage property will be nil and each associated AVMovieTrack's mediaDataStorage property will be nil. If you want to create an AVMutableMovie from an NSData object and then append sample buffers to any of its tracks, you must first set one of these properties to indicate where the sample data should be written.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithData:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithData_options(
            this: Allocated<Self>,
            data: &NSData,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;
    );
}

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

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

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMovieTrack",
            feature = "block2",
            feature = "objc2-core-media"
        ))]
        /// Loads an instance of AVFragmentedMovieTrack that represents the track of the specified trackID.
        ///
        /// Parameter `trackID`: The trackID of the requested AVFragmentedMovieTrack.
        ///
        /// 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 AVFragmentedMovieTrack, *mut NSError),
            >,
        );

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

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMediaFormat",
            feature = "AVMovieTrack",
            feature = "block2"
        ))]
        /// Loads an array of AVFragmentedMovieTracks of the asset that present media of the specified media type.
        ///
        /// Parameter `mediaType`: The media type according to which AVAsset filters its AVFragmentedMovieTracks. (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<AVFragmentedMovieTrack>, *mut NSError),
            >,
        );

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

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVMediaFormat",
            feature = "AVMovieTrack",
            feature = "block2"
        ))]
        /// Loads an array of AVFragmentedMovieTracks of the asset that present media with the specified characteristic.
        ///
        /// Parameter `mediaCharacteristic`: The media characteristic according to which AVAsset filters its AVFragmentedMovieTracks. (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<AVFragmentedMovieTrack>, *mut NSError),
            >,
        );
    );
}

extern_class!(
    /// A class that periodically checks whether additional movie fragments have been appended to fragmented movie files.
    ///
    /// AVFragmentedMovieMinder is identical to AVFragmentedAssetMinder except that it's capable of minding only assets of class AVFragmentedMovie.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avfragmentedmovieminder?language=objc)
    #[unsafe(super(AVFragmentedAssetMinder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "AVAsset")]
    pub struct AVFragmentedMovieMinder;
);

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

#[cfg(feature = "AVAsset")]
impl AVFragmentedMovieMinder {
    extern_methods!(
        /// Creates an AVFragmentedMovieMinder, adds the specified movie to it, and sets the mindingInterval to the specified value.
        ///
        /// Parameter `movie`: An instance of AVFragmentedMovie to add to the AVFragmentedMovieMinder
        ///
        /// Parameter `mindingInterval`: The initial minding interval of the AVFragmentedMovieMinder.
        ///
        /// Returns: A new instance of AVFragmentedMovieMinder.
        #[unsafe(method(fragmentedMovieMinderWithMovie:mindingInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn fragmentedMovieMinderWithMovie_mindingInterval(
            movie: &AVFragmentedMovie,
            minding_interval: NSTimeInterval,
        ) -> Retained<Self>;

        /// Creates an AVFragmentedMovieMinder, adds the specified movie to it, and sets the mindingInterval to the specified value.
        ///
        /// Parameter `movie`: An instance of AVFragmentedMovie to add to the AVFragmentedMovieMinder
        ///
        /// Parameter `mindingInterval`: The initial minding interval of the AVFragmentedMovieMinder.
        ///
        /// Returns: A new instance of AVFragmentedMovieMinder.
        #[unsafe(method(initWithMovie:mindingInterval:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithMovie_mindingInterval(
            this: Allocated<Self>,
            movie: &AVFragmentedMovie,
            minding_interval: NSTimeInterval,
        ) -> Retained<Self>;

        /// An NSTimeInterval indicating how often a check for additional movie fragments should be performed. The default interval is 10.0.
        #[unsafe(method(mindingInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn mindingInterval(&self) -> NSTimeInterval;

        /// Setter for [`mindingInterval`][Self::mindingInterval].
        #[unsafe(method(setMindingInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMindingInterval(&self, minding_interval: NSTimeInterval);

        /// An NSArray of the AVFragmentedMovie objects being minded.
        #[unsafe(method(movies))]
        #[unsafe(method_family = none)]
        pub unsafe fn movies(&self) -> Retained<NSArray<AVFragmentedMovie>>;

        /// Adds a fragmented movie to the array of movies being minded.
        ///
        /// Parameter `movie`: The fragmented movie to add to the minder.
        #[unsafe(method(addFragmentedMovie:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addFragmentedMovie(&self, movie: &AVFragmentedMovie);

        /// Removes a fragmented movie from the array of movies being minded.
        ///
        /// Parameter `movie`: The fragmented movie to remove from the minder.
        #[unsafe(method(removeFragmentedMovie:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeFragmentedMovie(&self, movie: &AVFragmentedMovie);
    );
}

/// Methods declared on superclass `AVFragmentedAssetMinder`.
#[cfg(feature = "AVAsset")]
impl AVFragmentedMovieMinder {
    extern_methods!(
        /// Creates an AVFragmentedAssetMinder, adds the specified asset to it, and sets the mindingInterval to the specified value.
        ///
        /// - Parameter asset: An instance of AVFragmentedAsset to add to the AVFragmentedAssetMinder
        /// - Parameter mindingInterval: The initial minding interval of the AVFragmentedAssetMinder.
        ///
        /// - Returns: A new instance of AVFragmentedAssetMinder.
        ///
        /// # Safety
        ///
        /// `asset` must implement AVFragmentMinding.
        #[unsafe(method(fragmentedAssetMinderWithAsset:mindingInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn fragmentedAssetMinderWithAsset_mindingInterval(
            asset: &AVAsset,
            minding_interval: NSTimeInterval,
        ) -> Retained<Self>;

        /// Creates an AVFragmentedAssetMinder, adds the specified asset to it, and sets the mindingInterval to the specified value.
        ///
        /// - Parameter asset: An instance of AVFragmentedAsset to add to the AVFragmentedAssetMinder
        /// - Parameter mindingInterval: The initial minding interval of the AVFragmentedAssetMinder.
        ///
        /// - Returns: A new instance of AVFragmentedAssetMinder.
        ///
        /// # Safety
        ///
        /// `asset` must implement AVFragmentMinding.
        #[unsafe(method(initWithAsset:mindingInterval:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAsset_mindingInterval(
            this: Allocated<Self>,
            asset: &AVAsset,
            minding_interval: NSTimeInterval,
        ) -> Retained<Self>;
    );
}

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

/// 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 AVMutableMovie {
    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;
    );
}