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
//! 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::*;
#[cfg(feature = "objc2-uniform-type-identifiers")]
use objc2_uniform_type_identifiers::*;

use crate::*;

extern_class!(
    /// An AVAsset is an abstract class that defines AVFoundation's model for timed audiovisual media.
    ///
    /// Each asset contains a collection of tracks that are intended to be presented or processed together, each of a uniform media type, including but not limited to audio, video, text, closed captions, and subtitles.
    ///
    /// AVAssets are often instantiated via its concrete subclass AVURLAsset with NSURLs that refer to audiovisual media resources, such as streams (including HTTP live streams), QuickTime movie files, MP3 files, and files of other types.
    ///
    /// They can also be instantiated using other concrete subclasses that extend the basic model for audiovisual media in useful ways, as AVComposition does for temporal editing.
    ///
    /// Properties of assets as a whole are defined by AVAsset. Additionally, references to instances of AVAssetTracks representing tracks of the collection can be obtained, so that each of these can be examined independently.
    ///
    /// Because of the nature of timed audiovisual media, upon successful initialization of an AVAsset some or all of the values for its keys may not be immediately available. The value of any key can be requested at any time, and AVAsset will always return its value synchronously, although it may have to block the calling thread in order to do so.
    ///
    /// In order to avoid blocking, clients can register their interest in particular keys and to become notified when their values become available. For further details, see AVAsynchronousKeyValueLoading.h. For clients who want to examine a subset of the tracks, metadata, and other parts of the asset, asynchronous methods like -loadTracksWithMediaType:completionHandler: can be used to load this information without blocking. When using these asynchronous methods, it is not necessary to load the associated property beforehand. Swift clients can also use the load(:) method to load properties in a type safe manner.
    ///
    /// On platforms other than macOS, it is particularly important to avoid blocking. To preserve responsiveness, a synchronous request that blocks for too long (eg, a property request on an asset on a slow HTTP server) may lead to media services being reset.
    ///
    /// To play an instance of AVAsset, initialize an instance of AVPlayerItem with it, use the AVPlayerItem to set up its presentation state (such as whether only a limited timeRange of the asset should be played, etc.), and provide the AVPlayerItem to an AVPlayer according to whether the items is to be played by itself or together with a collection of other items. Full details available in AVPlayerItem.h and AVPlayer.h.
    ///
    /// AVAssets can also be inserted into AVMutableCompositions in order to assemble audiovisual constructs from one or more source assets.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avasset?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVAsset;
);

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

extern_conformance!(
    unsafe impl NSCopying for AVAsset {}
);

unsafe impl CopyingHelper for AVAsset {
    type Result = Self;
}

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

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

        #[cfg(feature = "objc2-core-media")]
        /// Indicates the duration of the asset.
        ///
        /// If
        /// "
        /// providesPreciseDurationAndTiming" is NO, a best-available estimate of the duration is returned. The degree of precision preferred for timing-related properties can be set at initialization time for assets initialized with URLs
        ///
        /// - Seealso: AVURLAssetPreferPreciseDurationAndTimingKey for AVURLAsset below.
        #[unsafe(method(duration))]
        #[unsafe(method_family = none)]
        pub unsafe fn duration(&self) -> CMTime;

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

        /// Indicates the preferred volume at which the audible media of an asset is to be played; often but not always 1.0
        #[unsafe(method(preferredVolume))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredVolume(&self) -> c_float;

        #[cfg(feature = "objc2-core-foundation")]
        /// Indicates the preferred transform to apply to the visual content of the asset for presentation or processing; the value is often but not always the identity transform
        #[unsafe(method(preferredTransform))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredTransform(&self) -> CGAffineTransform;

        #[cfg(feature = "objc2-core-foundation")]
        /// The following property is deprecated. Instead, use the naturalSize and preferredTransform, as appropriate, of the receiver's video tracks. See -tracksWithMediaType: below.
        #[deprecated = "Use the naturalSize and preferredTransform, as appropriate, of the receiver's video tracks. See -tracksWithMediaType:"]
        #[unsafe(method(naturalSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn naturalSize(&self) -> CGSize;

        #[cfg(feature = "objc2-core-media")]
        /// Indicates how close to the latest content in a live stream playback can be sustained.
        ///
        /// For non-live assets this value is kCMTimeInvalid.
        #[unsafe(method(minimumTimeOffsetFromLive))]
        #[unsafe(method_family = none)]
        pub unsafe fn minimumTimeOffsetFromLive(&self) -> CMTime;
    );
}

/// Methods declared on superclass `NSObject`.
impl AVAsset {
    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>;
    );
}

/// AVAssetAsynchronousLoading.
impl AVAsset {
    extern_methods!(
        /// Indicates that the asset provides precise timing. See
        /// "
        /// duration" above and AVURLAssetPreferPreciseDurationAndTimingKey below.
        #[unsafe(method(providesPreciseDurationAndTiming))]
        #[unsafe(method_family = none)]
        pub unsafe fn providesPreciseDurationAndTiming(&self) -> bool;

        /// Cancels the loading of all values for all observers.
        ///
        /// Deallocation or finalization of an instance of AVAsset will implicitly cancel loading if any loading requests are still outstanding.
        #[unsafe(method(cancelLoading))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelLoading(&self);
    );
}

/// These constants can be passed in to AVURLAssetReferenceRestrictionsKey to control the resolution of references to external media data.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetreferencerestrictions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVAssetReferenceRestrictions(pub NSUInteger);
bitflags::bitflags! {
    impl AVAssetReferenceRestrictions: NSUInteger {
/// Indicates that all types of references should be followed.
        #[doc(alias = "AVAssetReferenceRestrictionForbidNone")]
        const ForbidNone = 0;
/// Indicates that references from a remote asset (e.g. referenced via http URL) to local media data (e.g. stored in a local file) should not be followed.
        #[doc(alias = "AVAssetReferenceRestrictionForbidRemoteReferenceToLocal")]
        const ForbidRemoteReferenceToLocal = 1<<0;
/// Indicates that references from a local asset to remote media data should not be followed.
        #[doc(alias = "AVAssetReferenceRestrictionForbidLocalReferenceToRemote")]
        const ForbidLocalReferenceToRemote = 1<<1;
/// Indicates that references from a remote asset to remote media data stored at a different site should not be followed.
        #[doc(alias = "AVAssetReferenceRestrictionForbidCrossSiteReference")]
        const ForbidCrossSiteReference = 1<<2;
/// Indicates that references from a local asset to local media data stored outside the asset's container file should not be followed.
        #[doc(alias = "AVAssetReferenceRestrictionForbidLocalReferenceToLocal")]
        const ForbidLocalReferenceToLocal = 1<<3;
/// Indicates that only references to media data stored within the asset's container file should be allowed.
        #[doc(alias = "AVAssetReferenceRestrictionForbidAll")]
        const ForbidAll = 0xFFFF;
/// Indicates that only references to media data stored within the asset's container file should be allowed.
        #[doc(alias = "AVAssetReferenceRestrictionDefaultPolicy")]
        const DefaultPolicy = AVAssetReferenceRestrictions::ForbidLocalReferenceToRemote.0;
    }
}

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

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

/// AVAssetReferenceRestrictions.
impl AVAsset {
    extern_methods!(
        /// Indicates the reference restrictions being used by the receiver.
        ///
        /// For AVURLAsset, this property reflects the value passed in for AVURLAssetReferenceRestrictionsKey, if any. See AVURLAssetReferenceRestrictionsKey below for a full discussion of reference restrictions. The default value for this property is AVAssetReferenceRestrictionForbidLocalReferenceToRemote.
        #[unsafe(method(referenceRestrictions))]
        #[unsafe(method_family = none)]
        pub unsafe fn referenceRestrictions(&self) -> AVAssetReferenceRestrictions;
    );
}

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

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

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

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

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

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

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

        #[cfg(feature = "AVAssetTrackGroup")]
        /// All track groups in the receiver.
        ///
        /// The value of this property is an NSArray of AVAssetTrackGroups, each representing a different grouping of tracks in the receiver.
        #[unsafe(method(trackGroups))]
        #[unsafe(method_family = none)]
        pub unsafe fn trackGroups(&self) -> Retained<NSArray<AVAssetTrackGroup>>;
    );
}

/// AVAssetMetadataReading.
impl AVAsset {
    extern_methods!(
        #[cfg(feature = "AVMetadataItem")]
        /// Indicates the creation date of the asset as an AVMetadataItem. May be nil. If a creation date has been stored by the asset in a form that can be converted to an NSDate, the dateValue property of the AVMetadataItem will provide an instance of NSDate. Otherwise the creation date is available only as a string value, via -[AVMetadataItem stringValue].
        #[unsafe(method(creationDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn creationDate(&self) -> Option<Retained<AVMetadataItem>>;

        /// Provides access to the lyrics of the asset suitable for the current locale.
        #[unsafe(method(lyrics))]
        #[unsafe(method_family = none)]
        pub unsafe fn lyrics(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "AVMetadataItem")]
        /// Provides access to an array of AVMetadataItems for each common metadata key for which a value is available; items can be filtered according to language via +[AVMetadataItem metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages:] and according to identifier via +[AVMetadataItem metadataItemsFromArray:filteredByIdentifier:].
        #[unsafe(method(commonMetadata))]
        #[unsafe(method_family = none)]
        pub unsafe fn commonMetadata(&self) -> Retained<NSArray<AVMetadataItem>>;

        #[cfg(feature = "AVMetadataItem")]
        /// Provides access to an array of AVMetadataItems for all metadata identifiers for which a value is available; items can be filtered according to language via +[AVMetadataItem metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages:] and according to identifier via +[AVMetadataItem metadataItemsFromArray:filteredByIdentifier:].
        #[unsafe(method(metadata))]
        #[unsafe(method_family = none)]
        pub unsafe fn metadata(&self) -> Retained<NSArray<AVMetadataItem>>;

        #[cfg(feature = "AVMetadataFormat")]
        /// Provides an NSArray of NSStrings, each representing a metadata format that's available to the asset (e.g. ID3, iTunes metadata, etc.). Metadata formats are defined in AVMetadataFormat.h.
        #[unsafe(method(availableMetadataFormats))]
        #[unsafe(method_family = none)]
        pub unsafe fn availableMetadataFormats(&self) -> Retained<NSArray<AVMetadataFormat>>;

        #[cfg(all(feature = "AVMetadataFormat", feature = "AVMetadataItem"))]
        /// Provides an NSArray of AVMetadataItems, one for each metadata item in the container of the specified format; can subsequently be filtered according to language via +[AVMetadataItem metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages:], according to locale via +[AVMetadataItem metadataItemsFromArray:withLocale:], or according to key via +[AVMetadataItem metadataItemsFromArray:withKey:keySpace:].
        ///
        /// Becomes callable without blocking when the key
        /// "
        /// availableMetadataFormats" has been loaded
        ///
        /// - Parameter format: The metadata format for which items are requested.
        ///
        /// - Returns: An NSArray containing AVMetadataItems; may be empty if there is no metadata of the specified format.
        #[deprecated = "Use loadMetadataForFormat:completionHandler: instead"]
        #[unsafe(method(metadataForFormat:))]
        #[unsafe(method_family = none)]
        pub unsafe fn metadataForFormat(
            &self,
            format: &AVMetadataFormat,
        ) -> Retained<NSArray<AVMetadataItem>>;

        #[cfg(all(
            feature = "AVMetadataFormat",
            feature = "AVMetadataItem",
            feature = "block2"
        ))]
        /// Loads an NSArray of AVMetadataItems, one for each metadata item in the container of the specified format; can subsequently be filtered according to language via +[AVMetadataItem metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages:], according to locale via +[AVMetadataItem metadataItemsFromArray:withLocale:], or according to key via +[AVMetadataItem metadataItemsFromArray:withKey:keySpace:].
        ///
        /// - Parameter format: The metadata format for which items are requested.
        /// - Parameter completionHandler: A block that is invoked when loading is complete, vending the array of metadata items (which may be empty if there is no metadata of the specified format) or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadMetadataForFormat:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadMetadataForFormat_completionHandler(
            &self,
            format: &AVMetadataFormat,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut NSArray<AVMetadataItem>, *mut NSError),
            >,
        );
    );
}

/// AVAssetChapterInspection.
impl AVAsset {
    extern_methods!(
        /// array of NSLocale
        #[unsafe(method(availableChapterLocales))]
        #[unsafe(method_family = none)]
        pub unsafe fn availableChapterLocales(&self) -> Retained<NSArray<NSLocale>>;

        #[cfg(all(feature = "AVMetadataFormat", feature = "AVTimedMetadataGroup"))]
        /// Provides an array of chapters.
        ///
        /// This method returns an array of AVTimedMetadataGroup objects. Each object in the array always contains an AVMetadataItem representing the chapter title; the timeRange property of the AVTimedMetadataGroup object is equal to the time range of the chapter title item.
        ///
        /// An AVMetadataItem with the specified common key will be added to an existing AVTimedMetadataGroup object if the time range (timestamp and duration) of the metadata item and the metadata group overlaps. The locale of items not carrying chapter titles need not match the specified locale parameter.
        ///
        /// Further filtering of the metadata items in AVTimedMetadataGroups according to language can be accomplished using +[AVMetadataItem metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages:]; filtering of the metadata items according to locale can be accomplished using +[AVMetadataItem metadataItemsFromArray:withLocale:].
        ///
        /// - Parameter locale: Locale of the metadata items carrying chapter titles to be returned (supports the IETF BCP 47 specification).
        /// - Parameter commonKeys: Array of common keys of AVMetadataItem to be included; can be nil. AVMetadataCommonKeyArtwork is the only supported key for now.
        ///
        /// - Returns: An NSArray of AVTimedMetadataGroup.
        #[deprecated = "Use loadChapterMetadataGroupsWithTitleLocale:containingItemsWithCommonKeys:completionHandler: instead"]
        #[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(all(
            feature = "AVMetadataFormat",
            feature = "AVTimedMetadataGroup",
            feature = "block2"
        ))]
        /// Loads an array of chapters.
        ///
        /// This method vends an array of AVTimedMetadataGroup objects. Each object in the array always contains an AVMetadataItem representing the chapter title; the timeRange property of the AVTimedMetadataGroup object is equal to the time range of the chapter title item.
        ///
        /// An AVMetadataItem with the specified common key will be added to an existing AVTimedMetadataGroup object if the time range (timestamp and duration) of the metadata item and the metadata group overlaps. The locale of items not carrying chapter titles need not match the specified locale parameter.
        ///
        /// Further filtering of the metadata items in AVTimedMetadataGroups according to language can be accomplished using +[AVMetadataItem metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages:]; filtering of the metadata items according to locale can be accomplished using +[AVMetadataItem metadataItemsFromArray:withLocale:].
        ///
        /// - Parameter locale: Locale of the metadata items carrying chapter titles to be returned (supports the IETF BCP 47 specification).
        /// - Parameter commonKeys: Array of common keys of AVMetadataItem to be included; if no common keys are required, send an empty list. AVMetadataCommonKeyArtwork is the only supported key for now.
        /// - Parameter completionHandler: A block that is invoked when loading is complete, vending the array of timed metadata groups or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadChapterMetadataGroupsWithTitleLocale:containingItemsWithCommonKeys:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadChapterMetadataGroupsWithTitleLocale_containingItemsWithCommonKeys_completionHandler(
            &self,
            locale: &NSLocale,
            common_keys: &NSArray<AVMetadataKey>,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut NSArray<AVTimedMetadataGroup>, *mut NSError),
            >,
        );

        #[cfg(feature = "AVTimedMetadataGroup")]
        /// Tests, in order of preference, for a match between language identifiers in the specified array of preferred languages and the available chapter locales, and returns the array of chapters corresponding to the first match that's found.
        ///
        /// Safe to call without blocking when the AVAsset key availableChapterLocales has status AVKeyValueStatusLoaded.
        ///
        /// Returns an array of AVTimedMetadataGroup objects. Each object in the array always contains an AVMetadataItem representing the chapter title; the timeRange property of the AVTimedMetadataGroup object is equal to the time range of the chapter title item.
        ///
        /// All of the available chapter metadata is included in the metadata groups, including items with the common key AVMetadataCommonKeyArtwork, if such items are present. Items not carrying chapter titles will be added to an existing AVTimedMetadataGroup object if the time range (timestamp and duration) of the metadata item and that of the metadata group overlaps. The locale of such items need not match the locale of the chapter titles.
        ///
        /// Further filtering of the metadata items in AVTimedMetadataGroups according to language can be accomplished using +[AVMetadataItem metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages:]; filtering of the metadata items according to locale can be accomplished using +[AVMetadataItem metadataItemsFromArray:withLocale:].
        ///
        /// - Parameter preferredLanguages: An array of language identifiers in order of preference, each of which is an IETF BCP 47 (RFC 4646) language identifier. If your goal is to provide the best match for the end user's preferred languages without consideration of your app's available localizations, pass [NSLocale preferredLanguages] as the value of preferredLanguages. However, if you want to filter the available choices in order to obtain the best match among the localizations that are available for your app, pass [NSBundle preferredLocalizationsFromArray:[[NSBundle mainBundle] localizations] forPreferences:[NSLocale preferredLanguages]] instead. The latter choice is normally more appropriate for strings intended for display as part of the app's UI.
        ///
        /// - Returns: An NSArray of AVTimedMetadataGroup.
        #[deprecated = "Use loadChapterMetadataGroupsBestMatchingPreferredLanguages:completionHandler: instead"]
        #[unsafe(method(chapterMetadataGroupsBestMatchingPreferredLanguages:))]
        #[unsafe(method_family = none)]
        pub unsafe fn chapterMetadataGroupsBestMatchingPreferredLanguages(
            &self,
            preferred_languages: &NSArray<NSString>,
        ) -> Retained<NSArray<AVTimedMetadataGroup>>;

        #[cfg(all(feature = "AVTimedMetadataGroup", feature = "block2"))]
        /// Tests, in order of preference, for a match between language identifiers in the specified array of preferred languages and the available chapter locales, and loads the array of chapters corresponding to the first match that's found.
        ///
        /// Returns an array of AVTimedMetadataGroup objects. Each object in the array always contains an AVMetadataItem representing the chapter title; the timeRange property of the AVTimedMetadataGroup object is equal to the time range of the chapter title item.
        ///
        /// All of the available chapter metadata is included in the metadata groups, including items with the common key AVMetadataCommonKeyArtwork, if such items are present. Items not carrying chapter titles will be added to an existing AVTimedMetadataGroup object if the time range (timestamp and duration) of the metadata item and that of the metadata group overlaps. The locale of such items need not match the locale of the chapter titles.
        ///
        /// Further filtering of the metadata items in AVTimedMetadataGroups according to language can be accomplished using +[AVMetadataItem metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages:]; filtering of the metadata items according to locale can be accomplished using +[AVMetadataItem metadataItemsFromArray:withLocale:].
        ///
        /// - Parameter preferredLanguages: An array of language identifiers in order of preference, each of which is an IETF BCP 47 (RFC 4646) language identifier. If your goal is to provide the best match for the end user's preferred languages without consideration of your app's available localizations, pass [NSLocale preferredLanguages] as the value of preferredLanguages. However, if you want to filter the available choices in order to obtain the best match among the localizations that are available for your app, pass [NSBundle preferredLocalizationsFromArray:[[NSBundle mainBundle] localizations] forPreferences:[NSLocale preferredLanguages]] instead. The latter choice is normally more appropriate for strings intended for display as part of the app's UI.
        /// - Parameter completionHandler: A block that is invoked when loading is complete, vending the array of timed metadata groups or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadChapterMetadataGroupsBestMatchingPreferredLanguages:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadChapterMetadataGroupsBestMatchingPreferredLanguages_completionHandler(
            &self,
            preferred_languages: &NSArray<NSString>,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut NSArray<AVTimedMetadataGroup>, *mut NSError),
            >,
        );
    );
}

/// AVAssetMediaSelection.
impl AVAsset {
    extern_methods!(
        #[cfg(feature = "AVMediaFormat")]
        /// Provides an NSArray of NSStrings, each NSString indicating a media characteristic for which a media selection option is available.
        #[unsafe(method(availableMediaCharacteristicsWithMediaSelectionOptions))]
        #[unsafe(method_family = none)]
        pub unsafe fn availableMediaCharacteristicsWithMediaSelectionOptions(
            &self,
        ) -> Retained<NSArray<AVMediaCharacteristic>>;

        #[cfg(all(feature = "AVMediaFormat", feature = "AVMediaSelectionGroup"))]
        /// Provides an instance of AVMediaSelectionGroup that contains one or more options with the specified media characteristic.
        ///
        /// Becomes callable without blocking when the key
        /// "
        /// availableMediaCharacteristicsWithMediaSelectionOptions" has been loaded.
        ///
        /// If the asset has no AVMediaSelectionGroup containing options with the specified media characteristic, the return value will be nil.
        ///
        /// Filtering of the options in the returned AVMediaSelectionGroup according to playability, locale, and additional media characteristics can be accomplished using the category AVMediaSelectionOptionFiltering defined on AVMediaSelectionGroup.
        ///
        /// - Parameter mediaCharacteristic: A media characteristic for which you wish to obtain the available media selection options. AVMediaCharacteristicAudible, AVMediaCharacteristicLegible, and AVMediaCharacteristicVisual are currently supported.
        /// Pass AVMediaCharacteristicAudible to obtain the group of available options for audio media in various languages and for various purposes, such as descriptive audio.
        /// Pass AVMediaCharacteristicLegible to obtain the group of available options for subtitles in various languages and for various purposes.
        /// Pass AVMediaCharacteristicVisual to obtain the group of available options for video media.
        ///
        /// - Returns: An instance of AVMediaSelectionGroup. May be nil.
        #[deprecated = "Use loadMediaSelectionGroupForMediaCharacteristic:completionHandler: instead"]
        #[unsafe(method(mediaSelectionGroupForMediaCharacteristic:))]
        #[unsafe(method_family = none)]
        pub unsafe fn mediaSelectionGroupForMediaCharacteristic(
            &self,
            media_characteristic: &AVMediaCharacteristic,
        ) -> Option<Retained<AVMediaSelectionGroup>>;

        #[cfg(all(
            feature = "AVMediaFormat",
            feature = "AVMediaSelectionGroup",
            feature = "block2"
        ))]
        /// Loads an instance of AVMediaSelectionGroup that contains one or more options with the specified media characteristic.
        ///
        /// If the asset has no AVMediaSelectionGroup containing options with the specified media characteristic, the return value will be nil.
        ///
        /// Filtering of the options in the returned AVMediaSelectionGroup according to playability, locale, and additional media characteristics can be accomplished using the category AVMediaSelectionOptionFiltering defined on AVMediaSelectionGroup.
        ///
        /// - Parameter mediaCharacteristic: A media characteristic for which you wish to obtain the available media selection options. AVMediaCharacteristicAudible, AVMediaCharacteristicLegible, and AVMediaCharacteristicVisual are currently supported.
        /// Pass AVMediaCharacteristicAudible to obtain the group of available options for audio media in various languages and for various purposes, such as descriptive audio.
        /// Pass AVMediaCharacteristicLegible to obtain the group of available options for subtitles in various languages and for various purposes
        /// Pass AVMediaCharacteristicVisual to obtain the group of available options for video media.
        /// - Parameter completionHandler: A block that is invoked when loading is complete, vending an instance of AVMediaSelectionGroup (which may be nil) or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(loadMediaSelectionGroupForMediaCharacteristic:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadMediaSelectionGroupForMediaCharacteristic_completionHandler(
            &self,
            media_characteristic: &AVMediaCharacteristic,
            completion_handler: &block2::DynBlock<dyn Fn(*mut AVMediaSelectionGroup, *mut NSError)>,
        );

        #[cfg(feature = "AVMediaSelection")]
        /// Provides an instance of AVMediaSelection with default selections for each of the receiver's media selection groups.
        #[unsafe(method(preferredMediaSelection))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredMediaSelection(&self) -> Retained<AVMediaSelection>;

        #[cfg(feature = "AVMediaSelection")]
        /// Provides an array of all permutations of AVMediaSelection for this asset.
        #[unsafe(method(allMediaSelections))]
        #[unsafe(method_family = none)]
        pub unsafe fn allMediaSelections(&self) -> Retained<NSArray<AVMediaSelection>>;
    );
}

/// AVAssetProtectedContent.
impl AVAsset {
    extern_methods!(
        /// Indicates whether or not the asset has protected content.
        ///
        /// Assets containing protected content may not be playable without successful authorization, even if the value of the "playable" property is YES. See the properties in the AVAssetUsability category for details on how such an asset may be used. On macOS, clients can use the interfaces in AVPlayerItemProtectedContentAdditions.h to request authorization to play the asset.
        #[unsafe(method(hasProtectedContent))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasProtectedContent(&self) -> bool;
    );
}

/// AVAssetFragments.
impl AVAsset {
    extern_methods!(
        /// Indicates whether the asset is capable of being extended by fragments.
        ///
        /// For QuickTime movie files and MPEG-4 files, the value of canContainFragments is YES if an 'mvex' box is present in the 'moov' box. For those types, the 'mvex' box signals the possible presence of later 'moof' boxes.
        #[unsafe(method(canContainFragments))]
        #[unsafe(method_family = none)]
        pub unsafe fn canContainFragments(&self) -> bool;

        /// Indicates whether the asset is extended by at least one fragment.
        ///
        /// For QuickTime movie files and MPEG-4 files, the value of this property is YES if canContainFragments is YES and at least one 'moof' box is present after the 'moov' box.
        #[unsafe(method(containsFragments))]
        #[unsafe(method_family = none)]
        pub unsafe fn containsFragments(&self) -> bool;

        #[cfg(feature = "objc2-core-media")]
        /// Indicates the total duration of fragments that either exist now or may be appended in the future in order to extend the duration of the asset.
        ///
        /// For QuickTime movie files and MPEG-4 files, the value of this property is obtained from the 'mehd' box of the 'mvex' box, if present. If no total fragment duration hint is available, the value of this property is kCMTimeInvalid.
        #[unsafe(method(overallDurationHint))]
        #[unsafe(method_family = none)]
        pub unsafe fn overallDurationHint(&self) -> CMTime;
    );
}

/// AVAssetUsability.
impl AVAsset {
    extern_methods!(
        /// Indicates whether an AVPlayer can play the contents of the asset in a manner that meets user expectations.
        ///
        /// A client can attempt playback when playable is NO, this however may lead to a substandard playback experience.
        #[unsafe(method(isPlayable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPlayable(&self) -> bool;

        /// Indicates whether an AVAssetExportSession can be used with the receiver for export
        #[unsafe(method(isExportable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isExportable(&self) -> bool;

        /// Indicates whether an AVAssetReader can be used with the receiver for extracting media data
        #[unsafe(method(isReadable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isReadable(&self) -> bool;

        /// Indicates whether the receiver can be used to build an AVMutableComposition
        #[unsafe(method(isComposable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isComposable(&self) -> bool;

        /// Indicates whether the receiver can be written to the saved photos album
        #[unsafe(method(isCompatibleWithSavedPhotosAlbum))]
        #[unsafe(method_family = none)]
        pub unsafe fn isCompatibleWithSavedPhotosAlbum(&self) -> bool;

        /// Indicates whether the asset is compatible with AirPlay Video.
        ///
        /// YES if an AVPlayerItem initialized with the receiver can be played by an external device via AirPlay Video.
        #[unsafe(method(isCompatibleWithAirPlayVideo))]
        #[unsafe(method_family = none)]
        pub unsafe fn isCompatibleWithAirPlayVideo(&self) -> bool;
    );
}

extern "C" {
    /// Indicates whether the asset should be prepared to indicate a precise duration and provide precise random access by time.
    ///
    /// The value for this key is a boolean NSNumber.
    ///
    /// If nil is passed as the value of the options parameter to -[AVURLAsset initWithURL:options:], or if a dictionary that lacks a value for the key AVURLAssetPreferPreciseDurationAndTimingKey is passed instead, a default value of NO is assumed. If the asset is intended to be played only, because AVPlayer will support approximate random access by time when full precision isn't available, the default value of NO will suffice.
    /// Pass YES if longer loading times are acceptable in cases in which precise timing is required. If the asset is intended to be inserted into an AVMutableComposition, precise random access is typically desirable and the value of YES is recommended.
    /// Note that such precision may require additional parsing of the resource in advance of operations that make use of any portion of it, depending on the specifics of its container format. Many container formats provide sufficient summary information for precise timing and do not require additional parsing to prepare for it; QuickTime movie files and MPEG-4 files are examples of such formats. Other formats do not provide sufficient summary information, and precise random access for them is possible only after a preliminary examination of a file's contents.
    /// If you pass YES for an asset that you intend to play via an instance of AVPlayerItem and you are prepared for playback to commence before the value of -[AVPlayerItem duration] becomes available, you can omit the key
    /// "
    /// duration" from the array of AVAsset keys you pass to -[AVPlayerItem initWithAsset:automaticallyLoadedAssetKeys:] in order to prevent AVPlayerItem from automatically loading the value of duration while the item becomes ready to play.
    /// If precise duration and timing is not possible for the timed media resource referenced by the asset's URL, AVAsset.providesPreciseDurationAndTiming will be NO even if precise timing is requested via the use of this key.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassetpreferprecisedurationandtimingkey?language=objc)
    pub static AVURLAssetPreferPreciseDurationAndTimingKey: &'static NSString;
}

extern "C" {
    /// Indicates the MIME type that should be used to identify the format of the media resource.
    ///
    /// When a value for this key is provided, only the specified MIME type is considered in determining how to handle or parse the media resource. Any other information that may be available, such as the URL path extension or a server-provided MIME type, is ignored.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassetoverridemimetypekey?language=objc)
    pub static AVURLAssetOverrideMIMETypeKey: &'static NSString;
}

extern "C" {
    /// Indicates the restrictions used by the asset 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.
    ///
    /// Some assets can contain references to media data stored outside the asset's container file, for example in another file. This key can be used to specify a policy to use when these references are encountered. If an asset contains one or more references of a type that is forbidden by the reference restrictions, loading of asset properties will fail. In addition, such an asset cannot be used with other AVFoundation modules, such as AVPlayerItem or AVAssetExportSession.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassetreferencerestrictionskey?language=objc)
    pub static AVURLAssetReferenceRestrictionsKey: &'static NSString;
}

extern "C" {
    /// HTTP cookies that the AVURLAsset may send with HTTP requests
    ///
    /// Standard cross-site policy still applies: cookies will only be sent to domains to which they apply.
    ///
    /// By default, an AVURLAsset will only have access to cookies in the client's default cookie storage
    /// that apply to the AVURLAsset's URL. You can supplement the cookies available to the asset
    /// via use of this initialization option
    ///
    /// HTTP cookies do not apply to non-HTTP(S) URLS.
    /// In HLS, many HTTP requests (e.g., media, crypt key, variant index) might be issued to different paths or hosts.
    /// In both of these cases, HTTP requests will be missing any cookies that do not apply to the AVURLAsset's URL.
    /// This init option allows the AVURLAsset to use additional HTTP cookies for those HTTP(S) requests.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassethttpcookieskey?language=objc)
    pub static AVURLAssetHTTPCookiesKey: &'static NSString;
}

extern "C" {
    /// Indicates whether network requests on behalf of this asset are allowed to use the cellular interface.
    ///
    /// Default is YES.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassetallowscellularaccesskey?language=objc)
    pub static AVURLAssetAllowsCellularAccessKey: &'static NSString;
}

extern "C" {
    /// Indicates whether network requests on behalf of this asset are allowed to use the expensive interface (e.g. cellular, tethered, constrained).
    ///
    /// Default is YES.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassetallowsexpensivenetworkaccesskey?language=objc)
    pub static AVURLAssetAllowsExpensiveNetworkAccessKey: &'static NSString;
}

extern "C" {
    /// Indicates whether network requests on behalf of this asset are allowed to use the constrained interface (e.g. interfaces marked as being in data saver mode).
    ///
    /// Default is YES.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassetallowsconstrainednetworkaccesskey?language=objc)
    pub static AVURLAssetAllowsConstrainedNetworkAccessKey: &'static NSString;
}

extern "C" {
    /// Indicates whether alias data references in the asset 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 AVURLAsset initialization option is appropriate.
    ///
    /// If you provide a value for AVURLAssetReferenceRestrictionsKey, 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/avurlassetshouldsupportaliasdatareferenceskey?language=objc)
    pub static AVURLAssetShouldSupportAliasDataReferencesKey: &'static NSString;
}

extern "C" {
    /// Specifies the attribution of the URLs requested by this asset.
    ///
    /// Value is an NSNumber whose value is an NSURLRequestAttribution (see NSURLRequest.h).
    /// Default value is NSURLRequestAttributionDeveloper.
    /// All NSURLRequests issed on behalf of this AVURLAsset will be attributed with this value and follow the App Privacy Policy accordingly.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlasseturlrequestattributionkey?language=objc)
    pub static AVURLAssetURLRequestAttributionKey: &'static NSString;
}

extern "C" {
    /// Specifies the value of the User-Agent header to add to HTTP requests made by this asset.
    ///
    /// Value is an NSString
    /// Default value is the systems's default User-Agent.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassethttpuseragentkey?language=objc)
    pub static AVURLAssetHTTPUserAgentKey: &'static NSString;
}

extern "C" {
    /// Specifies a UUID to append as the value of the query parameter "_HLS_primary_id" to selected HTTP requests issued on behalf of the asset. Supported for HLS assets only.
    ///
    /// Value is an NSUUID. Its UUID string value will be used as the query parameter.
    /// If you create AVURLAssets for the templateItems of AVPlayerInterstitialEvents and you want the instances of AVURLAsset that you create to be used during interstitial playback rather than equivalent AVURLAssets with the same URL, you must provide a value for this key that's equal to the httpSessionIdentifier of the primary AVPlayerItem's asset. See AVPlayerInterstitialEventController.h. This is especially useful if you require the use of a custom AVAssetResourceLoader delegate for interstitial assets.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassetprimarysessionidentifierkey?language=objc)
    pub static AVURLAssetPrimarySessionIdentifierKey: &'static NSString;
}

extern "C" {
    /// Indicates whether additional projected media signaling in the asset should be parsed and resolved as format description extensions.
    ///
    /// Default is NO.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avurlassetshouldparseexternalsphericaltagskey?language=objc)
    pub static AVURLAssetShouldParseExternalSphericalTagsKey: &'static NSString;
}

extern_class!(
    /// AVURLAsset provides access to the AVAsset model for timed audiovisual media referenced by URL.
    ///
    /// Note that although instances of AVURLAsset are immutable, values for its keys may not be immediately available without blocking. See the discussion of the class AVAsset above regarding the availability of values for keys and the use of AVAsynchronousKeyValueLoading.
    ///
    /// Once an AVURLAsset's value for a key is available, it will not change. AVPlayerItem provides access to information that can change dynamically during playback; see AVPlayerItem.duration and AVPlayerItem.tracks.
    ///
    /// AVURLAssets can be initialized with NSURLs that refer to audiovisual media resources, such as streams (including HTTP live streams), QuickTime movie files, MP3 files, and files of other types.
    ///
    /// 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/avurlasset?language=objc)
    #[unsafe(super(AVAsset, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVURLAsset;
);

unsafe impl Send for AVURLAsset {}

unsafe impl Sync for AVURLAsset {}

#[cfg(feature = "AVAsynchronousKeyValueLoading")]
extern_conformance!(
    unsafe impl AVAsynchronousKeyValueLoading for AVURLAsset {}
);

extern_conformance!(
    unsafe impl NSCopying for AVURLAsset {}
);

unsafe impl CopyingHelper for AVURLAsset {
    type Result = Self;
}

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

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

        #[cfg(feature = "AVMediaFormat")]
        /// Provides the file types the AVURLAsset class understands.
        ///
        /// - Returns: An NSArray of UTIs identifying the file types the AVURLAsset class understands.
        #[deprecated = "Use audiovisualContentTypes instead"]
        #[unsafe(method(audiovisualTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn audiovisualTypes() -> Retained<NSArray<AVFileType>>;

        /// Provides the MIME types the AVURLAsset class understands.
        ///
        /// - Returns: An NSArray of NSStrings containing MIME types the AVURLAsset class understands.
        #[unsafe(method(audiovisualMIMETypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn audiovisualMIMETypes() -> Retained<NSArray<NSString>>;

        #[cfg(feature = "objc2-uniform-type-identifiers")]
        /// Provides the content types the AVURLAsset class understands.
        ///
        /// - Returns: An NSArray of UTTypes identifying the content types the AVURLAsset class understands.
        #[unsafe(method(audiovisualContentTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn audiovisualContentTypes() -> Retained<NSArray<UTType>>;

        /// Returns YES if asset is playable with the codec(s) and container type specified in extendedMIMEType. Returns NO otherwise.
        ///
        /// On releases prior to macOS 14, iOS 17, tvOS 17, and watchOS 10, regardless of the specified MIME type this method interprets all codecs parameters according to the ISO family syntax defined by RFC 6381 and evaluates playability according to whether the indicated codecs are supported when carried in container formats that conform to the ISO BMFF specification, such as the MPEG-4 file format.
        /// On releases starting with macOS 14, iOS 17, tvOS 17, and watchOS 10, this method interprets codecs parameters according to the syntax and namespace determined by the specified MIME type and evaluates playability according to whether the indicated codecs are supported when carried in the container format indicated by that MIME type. Codecs parameters for each of the following MIME types are supported: video/mp4 (per RFC 6381, ISO/IEC 14496-15 Annex E, et al), video/quicktime (RFC 6381 et al), video/mp2t (ISO/IEC 13818-1), audio/vnd.wave (RFC 2361), audio/aiff (using the CoreAudio AudioFormatID namespace), audio/x-caf (also using the CoreAudio AudioFormatID namespace), and audio/mpeg (e.g. codecs="mp3"). MIME types supported as alternatives for the same container formats, e.g audio/mp4, are equivalently treated. If the indicated MIME type defines no supported syntax and namespace for codecs parameters, when any codecs parameter is present this method returns NO.
        ///
        /// - Parameter extendedMIMEType:
        ///
        /// - Returns: YES or NO.
        #[unsafe(method(isPlayableExtendedMIMEType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPlayableExtendedMIMEType(extended_mime_type: &NSString) -> bool;

        /// Returns an instance of AVURLAsset for inspection of a media resource.
        ///
        /// - Parameter URL: An instance of NSURL that references a media resource.
        /// - Parameter options: An instance of NSDictionary that contains keys for specifying options for the initialization of the AVURLAsset. See AVURLAssetPreferPreciseDurationAndTimingKey and AVURLAssetReferenceRestrictionsKey above.
        ///
        /// - Returns: An instance of AVURLAsset.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(URLAssetWithURL:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn URLAssetWithURL_options(
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Initializes an instance of AVURLAsset for inspection of a media resource.
        ///
        /// - Parameter URL: An instance of NSURL that references a media resource.
        /// - Parameter options: An instance of NSDictionary that contains keys for specifying options for the initialization of the AVURLAsset. See AVURLAssetPreferPreciseDurationAndTimingKey and AVURLAssetReferenceRestrictionsKey above.
        ///
        /// - Returns: An instance of AVURLAsset.
        ///
        /// # 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>;

        /// Indicates the URL with which the instance of AVURLAsset was initialized.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(URL))]
        #[unsafe(method_family = none)]
        pub unsafe fn URL(&self) -> Retained<NSURL>;

        /// Provides the identifier that's automatically included in any HTTP request issued on behalf of this asset in the HTTP header field "X-Playback-Session-Id".
        ///
        /// The value is an NSUUID from which the UUID string can be obtained.
        /// Note that copies of an AVURLAsset vend an equivalent httpSessionIdentifier.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(httpSessionIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn httpSessionIdentifier(&self) -> Retained<NSUUID>;
    );
}

/// Methods declared on superclass `AVAsset`.
impl AVURLAsset {
    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>;
    );
}

/// AVURLAssetURLHandling.
impl AVURLAsset {
    extern_methods!(
        #[cfg(feature = "AVAssetResourceLoader")]
        /// Provides access to an instance of AVAssetResourceLoader, which offers limited control over the handling of URLs that may be loaded in the course of performing operations on the asset, such as playback.
        ///
        /// The loading of file URLs cannot be mediated via use of AVAssetResourceLoader.
        ///
        /// Note that copies of an AVAsset will vend the same instance of AVAssetResourceLoader.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(resourceLoader))]
        #[unsafe(method_family = none)]
        pub unsafe fn resourceLoader(&self) -> Retained<AVAssetResourceLoader>;
    );
}

/// AVURLAssetCache.
impl AVURLAsset {
    extern_methods!(
        #[cfg(feature = "AVAssetCache")]
        /// Provides access to an instance of AVAssetCache to use for inspection of locally cached media data. Will be nil if an asset has not been configured to store or access media data from disk.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(assetCache))]
        #[unsafe(method_family = none)]
        pub unsafe fn assetCache(&self) -> Option<Retained<AVAssetCache>>;
    );
}

/// AVAssetCompositionUtility.
impl AVURLAsset {
    extern_methods!(
        #[cfg(all(feature = "AVAssetTrack", feature = "AVCompositionTrack"))]
        /// Provides a reference to an AVAssetTrack of the target from which any timeRange can be inserted into a mutable composition track (via -[AVMutableCompositionTrack insertTimeRange:ofTrack:atTime:error:]).
        ///
        /// Finds a track of the target with content that can be accommodated by the specified composition track.
        /// The logical complement of -[AVMutableComposition mutableTrackCompatibleWithTrack:].
        ///
        /// - Parameter compositionTrack: The composition track for which a compatible AVAssetTrack is requested.
        ///
        /// - Returns: an instance of AVAssetTrack
        #[deprecated = "Use findCompatibleTrackForCompositionTrack:completionHandler: instead"]
        #[unsafe(method(compatibleTrackForCompositionTrack:))]
        #[unsafe(method_family = none)]
        pub unsafe fn compatibleTrackForCompositionTrack(
            &self,
            composition_track: &AVCompositionTrack,
        ) -> Option<Retained<AVAssetTrack>>;

        #[cfg(all(
            feature = "AVAssetTrack",
            feature = "AVCompositionTrack",
            feature = "block2"
        ))]
        /// Loads a reference to an AVAssetTrack of the target from which any timeRange can be inserted into a mutable composition track (via -[AVMutableCompositionTrack insertTimeRange:ofTrack:atTime:error:]).
        ///
        /// Finds a track of the target with content that can be accommodated by the specified composition track.
        /// The logical complement of -[AVMutableComposition mutableTrackCompatibleWithTrack:].
        ///
        /// - Parameter compositionTrack: The composition track for which a compatible AVAssetTrack is requested.
        /// - Parameter completionHandler: A block that is invoked when loading is complete, vending an instance of AVAssetTrack or an error.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(findCompatibleTrackForCompositionTrack:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn findCompatibleTrackForCompositionTrack_completionHandler(
            &self,
            composition_track: &AVCompositionTrack,
            completion_handler: &block2::DynBlock<dyn Fn(*mut AVAssetTrack, *mut NSError)>,
        );
    );
}

/// AVAssetVariantInspection.
impl AVURLAsset {
    extern_methods!(
        #[cfg(feature = "AVAssetVariant")]
        /// Provides an array of AVAssetVariants contained in the asset
        ///
        /// Some variants may not be playable according to the current device configuration.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(variants))]
        #[unsafe(method_family = none)]
        pub unsafe fn variants(&self) -> Retained<NSArray<AVAssetVariant>>;
    );
}

/// AVURLAssetNSItemProvider.
///
/// AVURLAssets can be shared through any interface that supports passing NSItemProviders. Note that only AVURLAssets with file URLs can be added to NSItemProviders. Attempting to share assets with non file URLs will result in an error.
///
/// AVURLAssets can be retrieved from NSItemProviders by directly requesting an AVURLAsset through -[NSItemProvider loadObjectOfClass:completionHandler:]. Requesting data representations of AVURLAssets is not supported. File representations of AVURLAssets will be sent without copying the underlying media and the receiver will be extended readonly sandbox access to the sender's original URL until the AVURLAsset is deallocated. Use of NSFileCoordinator and NSFilePresenter is recommended for both the sender and receive to coordinate possible changes in the file's state once sharing has been completed.
impl AVURLAsset {
    extern_methods!();
}

extern_conformance!(
    unsafe impl NSItemProviderReading for AVURLAsset {}
);

extern_conformance!(
    unsafe impl NSItemProviderWriting for AVURLAsset {}
);

extern_class!(
    /// A class incorporating properties for a MediaExtension
    ///
    /// AVMediaExtensionProperties objects are returned from property queries on AVAsset, AVPlayerItemTrack, AVSampleBufferDisplayLayer, or AVSampleBufferVideoRenderer.
    /// 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/avmediaextensionproperties?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVMediaExtensionProperties;
);

unsafe impl Send for AVMediaExtensionProperties {}

unsafe impl Sync for AVMediaExtensionProperties {}

extern_conformance!(
    unsafe impl NSCopying for AVMediaExtensionProperties {}
);

unsafe impl CopyingHelper for AVMediaExtensionProperties {
    type Result = Self;
}

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

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

        /// The identifier of the Media Extension.
        ///
        /// The extension identifier string, corresponding to the ClassImplementationID value from the EXAppExtensionAttributes dictionary in the Info.plist file.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(extensionIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn extensionIdentifier(&self) -> Retained<NSString>;

        /// The name of the MediaExtension.
        ///
        /// The localized name of the MediaExtension format reader or video decoder, corresponding to the CFBundleDisplayName.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(extensionName))]
        #[unsafe(method_family = none)]
        pub unsafe fn extensionName(&self) -> Retained<NSString>;

        /// The name of the containing application bundle.
        ///
        /// The localized name of the application that hosts the MediaExtension.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(containingBundleName))]
        #[unsafe(method_family = none)]
        pub unsafe fn containingBundleName(&self) -> Retained<NSString>;

        /// The file URL of the MediaExtension bundle.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(extensionURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn extensionURL(&self) -> Retained<NSURL>;

        /// The file URL of the host application for the MediaExtension.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(containingBundleURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn containingBundleURL(&self) -> Retained<NSURL>;
    );
}

/// AVMediaExtension.
impl AVURLAsset {
    extern_methods!(
        /// The properties of the MediaExtension format reader for the asset.
        ///
        /// If the asset is being decoded using a MediaExtension format reader, this property will return a AVMediaExtensionProperties object describing the extension. If the asset is not being decoded with a MediaExtension format reader, this property will return nil.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(mediaExtensionProperties))]
        #[unsafe(method_family = none)]
        pub unsafe fn mediaExtensionProperties(
            &self,
        ) -> Option<Retained<AVMediaExtensionProperties>>;

        /// The sidecar URL used by the MediaExtension.
        ///
        /// The sidecar URL is returned only if the MediaExtension format reader supports sidecar files, and implements this property [MEFileInfo setSidecarFilename:]. Will return nil otherwise.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(sidecarURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn sidecarURL(&self) -> Option<Retained<NSURL>>;
    );
}

extern "C" {
    /// Posted when the duration of an AVFragmentedAsset changes while it's being minded by an AVFragmentedAssetMinder, 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/avassetdurationdidchangenotification?language=objc)
    pub static AVAssetDurationDidChangeNotification: &'static NSString;
}

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

extern "C" {
    /// Posted when the asset on disk is defragmented while an AVFragmentedAsset is being minded by an AVFragmentedAssetMinder, but only if the defragmentation occurs after the status of the value of
    /// "
    /// canContainFragments" has reached AVKeyValueStatusLoaded.
    ///
    /// After this notification is posted, the value of the asset properties canContainFragments and containsFragments will both be NO.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetwasdefragmentednotification?language=objc)
    pub static AVAssetWasDefragmentedNotification: &'static NSString;
}

extern "C" {
    /// Posted when the collection of arrays of timed metadata groups representing chapters of an AVAsset change and when any of the contents of the timed metadata groups change, but only for changes that occur after the status of the value of
    /// "
    /// availableChapterLocales" has reached AVKeyValueStatusLoaded.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetchaptermetadatagroupsdidchangenotification?language=objc)
    pub static AVAssetChapterMetadataGroupsDidChangeNotification: &'static NSString;
}

extern "C" {
    /// Posted when the collection of media selection groups provided by an AVAsset changes and when any of the contents of its media selection groups change, but only for changes that occur after the status of the value of
    /// "
    /// availableMediaCharacteristicsWithMediaSelectionOptions" has reached AVKeyValueStatusLoaded.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetmediaselectiongroupsdidchangenotification?language=objc)
    pub static AVAssetMediaSelectionGroupsDidChangeNotification: &'static NSString;
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avfragmentminding?language=objc)
    pub unsafe trait AVFragmentMinding {
        /// Indicates whether an AVAsset that supports fragment minding is currently associated with a fragment minder, e.g. an instance of AVFragmentedAssetMinder.
        ///
        /// AVAssets that support fragment minding post change notifications only while associated with a fragment minder.
        #[unsafe(method(isAssociatedWithFragmentMinder))]
        #[unsafe(method_family = none)]
        unsafe fn isAssociatedWithFragmentMinder(&self) -> bool;
    }
);

extern_class!(
    /// A subclass of AVURLAsset that represents media resources that can be extended in total duration without modifying previously existing data structures.
    ///
    /// Such media resources include QuickTime movie files and MPEG-4 files that indicate, via an 'mvex' box in their 'moov' box, that they accommodate additional fragments. Media resources of other types may also be supported. To check whether a given instance of AVFragmentedAsset can be used to monitor the addition of fragments, check the value of the AVURLAsset property canContainFragments.
    ///
    /// An AVFragmentedAsset is capable of changing the values of certain of its properties and those of its tracks, while an operation that appends fragments to the underlying media resource in in progress, if the AVFragmentedAsset is associated with an instance of AVFragmentedAssetMinder.
    ///
    /// While associated with an AVFragmentedAssetMinder, AVFragmentedAsset posts AVAssetDurationDidChangeNotification whenever new fragments are detected, as appropriate. It may also post AVAssetContainsFragmentsDidChangeNotification and AVAssetWasDefragmentedNotification, as discussed in documentation of those notifications.
    /// 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/avfragmentedasset?language=objc)
    #[unsafe(super(AVURLAsset, AVAsset, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVFragmentedAsset;
);

unsafe impl Send for AVFragmentedAsset {}

unsafe impl Sync for AVFragmentedAsset {}

#[cfg(feature = "AVAsynchronousKeyValueLoading")]
extern_conformance!(
    unsafe impl AVAsynchronousKeyValueLoading for AVFragmentedAsset {}
);

extern_conformance!(
    unsafe impl AVFragmentMinding for AVFragmentedAsset {}
);

extern_conformance!(
    unsafe impl NSCopying for AVFragmentedAsset {}
);

unsafe impl CopyingHelper for AVFragmentedAsset {
    type Result = Self;
}

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

impl AVFragmentedAsset {
    extern_methods!(
        /// Returns an instance of AVFragmentedAsset for inspection of a fragmented media resource.
        ///
        /// - Parameter URL: An instance of NSURL that references a media resource.
        /// - Parameter options: An instance of NSDictionary that contains keys for specifying options for the initialization of the AVFragmentedAsset. See AVURLAssetPreferPreciseDurationAndTimingKey and AVURLAssetReferenceRestrictionsKey above.
        ///
        /// - Returns: An instance of AVFragmentedAsset.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(fragmentedAssetWithURL:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn fragmentedAssetWithURL_options(
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        #[cfg(feature = "AVAssetTrack")]
        /// The tracks in an asset.
        ///
        /// The value of this property is an array of tracks the asset contains; the tracks are of type AVFragmentedAssetTrack.
        ///
        /// 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<AVFragmentedAssetTrack>>;
    );
}

/// Methods declared on superclass `AVURLAsset`.
impl AVFragmentedAsset {
    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>;

        /// Returns an instance of AVURLAsset for inspection of a media resource.
        ///
        /// - Parameter URL: An instance of NSURL that references a media resource.
        /// - Parameter options: An instance of NSDictionary that contains keys for specifying options for the initialization of the AVURLAsset. See AVURLAssetPreferPreciseDurationAndTimingKey and AVURLAssetReferenceRestrictionsKey above.
        ///
        /// - Returns: An instance of AVURLAsset.
        ///
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(URLAssetWithURL:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn URLAssetWithURL_options(
            url: &NSURL,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Initializes an instance of AVURLAsset for inspection of a media resource.
        ///
        /// - Parameter URL: An instance of NSURL that references a media resource.
        /// - Parameter options: An instance of NSDictionary that contains keys for specifying options for the initialization of the AVURLAsset. See AVURLAssetPreferPreciseDurationAndTimingKey and AVURLAssetReferenceRestrictionsKey above.
        ///
        /// - Returns: An instance of AVURLAsset.
        ///
        /// # 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>;
    );
}

/// Methods declared on superclass `AVAsset`.
impl AVFragmentedAsset {
    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>;
    );
}

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

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

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

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

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

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

extern_class!(
    /// A class that periodically checks whether additional fragments have been appended to fragmented assets.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avfragmentedassetminder?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVFragmentedAssetMinder;
);

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

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

        /// An NSTimeInterval indicating how often a check for additional fragments should be performed. The default interval is 10.0.
        ///
        /// This property throws an excepion if a value is set less than one millisecond (0.001) in duration.
        #[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 AVFragmentedAsset objects being minded.
        #[unsafe(method(assets))]
        #[unsafe(method_family = none)]
        pub unsafe fn assets(&self) -> Retained<NSArray<AVAsset>>;

        /// Adds a fragmented asset to the array of assets being minded.
        ///
        /// This method throws an exception if the asset is not a supported type (AVFragmentedAsset, AVFragmentedMovie), or if the asset is already being minded by another fragment minder.
        ///
        /// - Parameter asset: The fragmented asset to add to the minder.
        ///
        /// # Safety
        ///
        /// `asset` must implement AVFragmentMinding.
        #[unsafe(method(addFragmentedAsset:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addFragmentedAsset(&self, asset: &AVAsset);

        /// Removes a fragmented asset from the array of assets being minded.
        ///
        /// This method throws an exception if the asset is not a supported type (AVFragmentedAsset, AVFragmentedMovie).
        ///
        /// - Parameter asset: The fragmented asset to remove from the minder.
        ///
        /// # Safety
        ///
        /// `asset` must implement AVFragmentMinding.
        #[unsafe(method(removeFragmentedAsset:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeFragmentedAsset(&self, asset: &AVAsset);
    );
}

/// Methods declared on superclass `NSObject`.
impl AVFragmentedAssetMinder {
    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>;
    );
}

/// AVURLAssetContentKeyEligibility.
impl AVURLAsset {
    extern_methods!(
        /// Allows AVURLAsset to be added as a content key recipient to an AVContentKeySession.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(mayRequireContentKeysForMediaDataProcessing))]
        #[unsafe(method_family = none)]
        pub unsafe fn mayRequireContentKeysForMediaDataProcessing(&self) -> bool;
    );
}

#[cfg(feature = "AVContentKeySession")]
extern_conformance!(
    unsafe impl AVContentKeyRecipient for AVURLAsset {}
);