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
//! 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-media")]
use objc2_core_media::*;
use objc2_foundation::*;
use crate::*;
extern "C" {
/// The lowest media bitrate greater than or equal to this value will be selected. Value should be a NSNumber in bps. If no suitable media bitrate is found, the highest media bitrate will be selected.
/// The value for this key should be a NSNumber.
///
/// By default, the highest media bitrate will be selected for download.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskminimumrequiredmediabitratekey?language=objc)
#[deprecated = "Use AVAssetDownloadConfiguration:variantQualifiers with assetVariantQualifierWithPredicate using desired comparison value against averageBitRate/peakBitRate instead"]
pub static AVAssetDownloadTaskMinimumRequiredMediaBitrateKey: &'static NSString;
}
extern "C" {
/// The lowest media presentation size greater than or equal to this value will be selected. If no suitable media presentation size is found, the highest media presentation size will be selected.
/// The value for this key should be a NSValue of CGSize.
///
/// By default, the highest media presentation size will be selected for download.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskminimumrequiredpresentationsizekey?language=objc)
#[deprecated = "Use AVAssetDownloadConfiguration:variantQualifiers with predicateForPresentationWidth and predicateForPresentationHeight instead"]
pub static AVAssetDownloadTaskMinimumRequiredPresentationSizeKey: &'static NSString;
}
extern "C" {
/// The media selection for this download.
/// The value for this key should be an AVMediaSelection.
///
/// By default, media selections for AVAssetDownloadTask will be automatically selected.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskmediaselectionkey?language=objc)
#[deprecated = "Use AVAssetDownloadConfiguration:mediaSelections instead"]
pub static AVAssetDownloadTaskMediaSelectionKey: &'static NSString;
}
extern "C" {
/// Download the specified media selections with or without support for multichannel playback.
/// The value for this key should be an NSNumber representing a BOOL.
///
/// By default AVAssetDownloadTask will prefer multichannel by downloading the most capable multichannel rendition available in additon to stereo.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskmediaselectionprefersmultichannelkey?language=objc)
#[deprecated = "Use AVAssetDownloadConfiguration:variantQualifiers with predicateForChannelCount instead"]
pub static AVAssetDownloadTaskMediaSelectionPrefersMultichannelKey: &'static NSString;
}
extern "C" {
/// Download the specified media selections in lossless audio representation.
/// The value for this key should be an NSNumber representing a BOOL.
///
/// By default AVAssetDownloadTask will prefer lossy audio representation.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskpreferslosslessaudiokey?language=objc)
#[deprecated = "Use AVAssetDownloadConfiguration:variantQualifiers with assetVariantQualifierWithPredicate using [NSPredicate predicateWithFormat:@'%d in audioAttributes.formatIDs', kAudioFormatAppleLossless]"]
pub static AVAssetDownloadTaskPrefersLosslessAudioKey: &'static NSString;
}
extern "C" {
/// Download the specified media selections with or without HDR content.
/// The value for this key should be an NSNumber representing a BOOL.
///
/// By default AVAssetDownloadTask will prefer HDR content.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskprefershdrkey?language=objc)
#[deprecated = "Use AVAssetDownloadConfiguration:variantQualifiers with assetVariantQualifierWithPredicate using [NSPredicate predicateWithFormat:@'videoAttributes.videoRange == %@', AVVideoRangePQ]"]
pub static AVAssetDownloadTaskPrefersHDRKey: &'static NSString;
}
extern_class!(
/// A NSURLSessionTask that accepts remote AVURLAssets to download locally.
///
/// Should be created with -[AVAssetDownloadURLSession assetDownloadTaskWithURLAsset:assetTitle:assetArtworkData:options:]. To utilize local data for playback for downloads that are in-progress, re-use the URLAsset supplied in initialization. An AVAssetDownloadTask may be instantiated with a destinationURL pointing to an existing asset on disk, for the purpose of completing or augmenting a downloaded asset.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtask?language=objc)
#[unsafe(super(NSURLSessionTask, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVAssetDownloadTask;
);
extern_conformance!(
unsafe impl NSCopying for AVAssetDownloadTask {}
);
unsafe impl CopyingHelper for AVAssetDownloadTask {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for AVAssetDownloadTask {}
);
extern_conformance!(
unsafe impl NSProgressReporting for AVAssetDownloadTask {}
);
impl AVAssetDownloadTask {
extern_methods!(
#[cfg(feature = "AVAsset")]
/// The asset supplied to the download task upon initialization.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(URLAsset))]
#[unsafe(method_family = none)]
pub unsafe fn URLAsset(&self) -> Retained<AVURLAsset>;
/// The file URL supplied to the download task upon initialization.
///
/// This URL may have been appended with the appropriate extension for the asset.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[deprecated = "Use the URL property of URLAsset instead"]
#[unsafe(method(destinationURL))]
#[unsafe(method_family = none)]
pub unsafe fn destinationURL(&self) -> Retained<NSURL>;
/// The options supplied to the download task upon initialization.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[deprecated = "Use AVAssetDownloadConfiguration instead"]
#[unsafe(method(options))]
#[unsafe(method_family = none)]
pub unsafe fn options(&self) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
/// This property provides a collection of time ranges for which the download task has media data already downloaded and playable. The ranges provided might be discontinuous.
///
/// Returns an NSArray of NSValues containing CMTimeRanges.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[deprecated = "Use NSURLSessionTask.progress instead"]
#[unsafe(method(loadedTimeRanges))]
#[unsafe(method_family = none)]
pub unsafe fn loadedTimeRanges(&self) -> Retained<NSArray<NSValue>>;
#[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>;
#[unsafe(method(originalRequest))]
#[unsafe(method_family = none)]
pub unsafe fn originalRequest(&self) -> Retained<NSURLRequest>;
#[unsafe(method(currentRequest))]
#[unsafe(method_family = none)]
pub unsafe fn currentRequest(&self) -> Retained<NSURLRequest>;
#[unsafe(method(response))]
#[unsafe(method_family = none)]
pub unsafe fn response(&self) -> Retained<NSURLResponse>;
);
}
extern_class!(
/// Configuration parameters for the download task.
///
/// Download configuration consists of primary and auxiliary content configurations. Primary content configuration represents the primary set of renditions essential for offline playback. Auxiliary content configurations represent additional configurations to complement the primary.
/// For example, the primary content configuration may represent stereo audio renditions and auxiliary configuration may represent complementing multichannel audio renditions.
///
/// It is important to configure your download configuration object appropriately before using it to create a download task. Download task makes a copy of the configuration settings you provide and use those settings to configure the task. Once configured, the task object ignores any changes you make to the NSURLSessionConfiguration object. If you need to modify your settings, you must update the download configuration object and use it to create a new download task object.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadconfiguration?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVAssetDownloadConfiguration;
);
extern_conformance!(
unsafe impl NSObjectProtocol for AVAssetDownloadConfiguration {}
);
impl AVAssetDownloadConfiguration {
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 = "AVAsset")]
/// Creates and initializes a download configuration object.
///
/// This method will throw an exception if AVURLAsset has been invalidated.
///
/// - Parameter asset: The asset to create the download configuration for.
/// - Parameter title: A human readable title for this asset, expected to be as suitable as possible for the user's preferred languages. Will show up in the usage pane of the settings app.
#[unsafe(method(downloadConfigurationWithAsset:title:))]
#[unsafe(method_family = none)]
pub unsafe fn downloadConfigurationWithAsset_title(
asset: &AVURLAsset,
title: &NSString,
) -> Retained<Self>;
/// NSData representing artwork data for this asset. Optional. May be displayed, for example, by the usage pane of the Settings app. Must work with +[UIImage imageWithData:].
#[unsafe(method(artworkData))]
#[unsafe(method_family = none)]
pub unsafe fn artworkData(&self) -> Option<Retained<NSData>>;
/// Setter for [`artworkData`][Self::artworkData].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setArtworkData:))]
#[unsafe(method_family = none)]
pub unsafe fn setArtworkData(&self, artwork_data: Option<&NSData>);
/// The primary content for the download.
#[unsafe(method(primaryContentConfiguration))]
#[unsafe(method_family = none)]
pub unsafe fn primaryContentConfiguration(
&self,
) -> Retained<AVAssetDownloadContentConfiguration>;
/// The auxiliary content for the download. Optional.
///
/// By default, auxiliaryContentConfigurations will have one or more default auxiliary content configurations. These content configurations can be augmented with additional content configurations or removed entirely if no auxiliary content is desired.
#[unsafe(method(auxiliaryContentConfigurations))]
#[unsafe(method_family = none)]
pub unsafe fn auxiliaryContentConfigurations(
&self,
) -> Retained<NSArray<AVAssetDownloadContentConfiguration>>;
/// Setter for [`auxiliaryContentConfigurations`][Self::auxiliaryContentConfigurations].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setAuxiliaryContentConfigurations:))]
#[unsafe(method_family = none)]
pub unsafe fn setAuxiliaryContentConfigurations(
&self,
auxiliary_content_configurations: &NSArray<AVAssetDownloadContentConfiguration>,
);
/// Optimizes auxiliary content selection depending on the primary to minimize total number of video renditions downloaded. True by default.
///
/// For example, if the primary content configuration represents stereo renditions and auxiliary content configuration represents multichannel audio renditions, auxiliary multichannel variant will be chosen so as to avoid downloading duplicate video renditions.
#[unsafe(method(optimizesAuxiliaryContentConfigurations))]
#[unsafe(method_family = none)]
pub unsafe fn optimizesAuxiliaryContentConfigurations(&self) -> bool;
/// Setter for [`optimizesAuxiliaryContentConfigurations`][Self::optimizesAuxiliaryContentConfigurations].
#[unsafe(method(setOptimizesAuxiliaryContentConfigurations:))]
#[unsafe(method_family = none)]
pub unsafe fn setOptimizesAuxiliaryContentConfigurations(
&self,
optimizes_auxiliary_content_configurations: bool,
);
/// Download interstitial assets as listed in the index file. False by default.
///
/// Ordinarily, interstitial assets are skipped when downloading content for later playback. Setting this property to true will cause interstitial assets to be downloaded as well. Playback of the downloaded content can then match the experience of online streaming playback as closely as possible.
#[unsafe(method(downloadsInterstitialAssets))]
#[unsafe(method_family = none)]
pub unsafe fn downloadsInterstitialAssets(&self) -> bool;
/// Setter for [`downloadsInterstitialAssets`][Self::downloadsInterstitialAssets].
#[unsafe(method(setDownloadsInterstitialAssets:))]
#[unsafe(method_family = none)]
pub unsafe fn setDownloadsInterstitialAssets(&self, downloads_interstitial_assets: bool);
#[cfg(all(feature = "AVMediaFormat", feature = "AVPlayerMediaSelectionCriteria"))]
/// Sets media selection on interstitials for this asset
///
/// Typically, interstitial assets have not been discovered when the main download is initiated.
/// This method allows the user to specify AVMediaSelectionCriteria for all interstitials that are discovered.
/// Each AVPlayerMediaSelectionCriteria in the array of criteria specfies a set of criteria for a variant to download.
///
/// - Parameter criteria: The array of selection criteria to set
/// - Parameter mediaCharacteristic: The AVMediaCharacteristic to which the criteria will be applied
#[unsafe(method(setInterstitialMediaSelectionCriteria:forMediaCharacteristic:))]
#[unsafe(method_family = none)]
pub unsafe fn setInterstitialMediaSelectionCriteria_forMediaCharacteristic(
&self,
criteria: &NSArray<AVPlayerMediaSelectionCriteria>,
media_characteristic: &AVMediaCharacteristic,
);
);
}
extern_class!(
/// Represents the configuration consisting of variant and the variant's media options.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadcontentconfiguration?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVAssetDownloadContentConfiguration;
);
extern_conformance!(
unsafe impl NSCopying for AVAssetDownloadContentConfiguration {}
);
unsafe impl CopyingHelper for AVAssetDownloadContentConfiguration {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for AVAssetDownloadContentConfiguration {}
);
impl AVAssetDownloadContentConfiguration {
extern_methods!(
#[cfg(feature = "AVAssetVariant")]
/// An array of variant qualifiers.
///
/// The qualifiers are expected to be added in the preferential order and will be evaluated in that order until the qualifier matches one or more AVAssetVariants. Only those variants which can be played on the current device configuration will be initially chosen for evaluation. If there is more than one match, automatic variant selection will be used to choose among the matched.
/// If a variant qualifier is constructed to explicitly choose a variant, no evaluation is performed and the variant provided will be downloaded as is, even if it is not playable on current device configuration.
/// If a variant qualifier has not been provided, or if the variant qualifier when evaluated does not match any of the variants which can be played according to the current device configuration, automatic variant selection will be used.
#[unsafe(method(variantQualifiers))]
#[unsafe(method_family = none)]
pub unsafe fn variantQualifiers(&self) -> Retained<NSArray<AVAssetVariantQualifier>>;
#[cfg(feature = "AVAssetVariant")]
/// Setter for [`variantQualifiers`][Self::variantQualifiers].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setVariantQualifiers:))]
#[unsafe(method_family = none)]
pub unsafe fn setVariantQualifiers(
&self,
variant_qualifiers: &NSArray<AVAssetVariantQualifier>,
);
#[cfg(feature = "AVMediaSelection")]
/// An array of media selections obtained from the AVAsset.
///
/// If a media selection is not provided, automatic media selection associated with the asset will be used.
#[unsafe(method(mediaSelections))]
#[unsafe(method_family = none)]
pub unsafe fn mediaSelections(&self) -> Retained<NSArray<AVMediaSelection>>;
#[cfg(feature = "AVMediaSelection")]
/// Setter for [`mediaSelections`][Self::mediaSelections].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setMediaSelections:))]
#[unsafe(method_family = none)]
pub unsafe fn setMediaSelections(&self, media_selections: &NSArray<AVMediaSelection>);
);
}
/// Methods declared on superclass `NSObject`.
impl AVAssetDownloadContentConfiguration {
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>;
);
}
extern_class!(
/// An AVAssetDownloadTask used for downloading multiple AVMediaSelections for a single AVAsset, under the umbrella of a single download task.
///
/// Should be created with -[AVAssetDownloadURLSession aggregateAssetDownloadTaskWithURLAsset:mediaSelections:assetTitle:assetArtworkData:options:. For progress tracking, monitor the delegate callbacks for each childAssetDownloadTask.
///
/// 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/avaggregateassetdownloadtask?language=objc)
#[unsafe(super(NSURLSessionTask, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
pub struct AVAggregateAssetDownloadTask;
);
extern_conformance!(
unsafe impl NSCopying for AVAggregateAssetDownloadTask {}
);
unsafe impl CopyingHelper for AVAggregateAssetDownloadTask {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for AVAggregateAssetDownloadTask {}
);
extern_conformance!(
unsafe impl NSProgressReporting for AVAggregateAssetDownloadTask {}
);
impl AVAggregateAssetDownloadTask {
extern_methods!(
#[cfg(feature = "AVAsset")]
/// The asset supplied to the download task upon initialization.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
#[unsafe(method(URLAsset))]
#[unsafe(method_family = none)]
pub unsafe fn URLAsset(&self) -> Retained<AVURLAsset>;
#[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
#[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
#[unsafe(method(originalRequest))]
#[unsafe(method_family = none)]
pub unsafe fn originalRequest(&self) -> Retained<NSURLRequest>;
#[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
#[unsafe(method(currentRequest))]
#[unsafe(method_family = none)]
pub unsafe fn currentRequest(&self) -> Retained<NSURLRequest>;
#[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
#[unsafe(method(response))]
#[unsafe(method_family = none)]
pub unsafe fn response(&self) -> Retained<NSURLResponse>;
);
}
extern_protocol!(
/// Delegate methods to implement when adopting AVAssetDownloadTask. 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/avassetdownloaddelegate?language=objc)
pub unsafe trait AVAssetDownloadDelegate:
NSURLSessionTaskDelegate + Send + Sync
{
/// Sent when a download task that has completed a download.
///
/// Unlike NSURLSessionDownloadDelegate, the delegate should NOT move the file from this directory after it has been called. Downloaded assets must remain at the system provided URL. URLSession:task:didCompleteWithError: will still be called.
///
/// - Parameter session: The session the asset download task is on.
/// - Parameter assetDownloadTask: The AVAssetDownloadTask whose downloaded completed.
/// - Parameter location: The location the asset has been downloaded to.
#[deprecated = "Use URLSession:assetDownloadTask:willDownloadToURL: instead"]
#[optional]
#[unsafe(method(URLSession:assetDownloadTask:didFinishDownloadingToURL:))]
#[unsafe(method_family = none)]
unsafe fn URLSession_assetDownloadTask_didFinishDownloadingToURL(
&self,
session: &NSURLSession,
asset_download_task: &AVAssetDownloadTask,
location: &NSURL,
);
#[cfg(feature = "objc2-core-media")]
/// Method to adopt to subscribe to progress updates of an AVAssetDownloadTask.
///
/// - Parameter session: The session the asset download task is on.
/// - Parameter assetDownloadTask: The AVAssetDownloadTask which is being updated.
/// - Parameter timeRange: A CMTimeRange indicating the time range loaded since the last time this method was called.
/// - Parameter loadedTimeRanges: A NSArray of NSValues of CMTimeRanges indicating all the time ranges loaded by this asset download task.
/// - Parameter timeRangeExpectedToLoad: A CMTimeRange indicating the single time range that is expected to be loaded when the download is complete.
#[deprecated = "Use NSURLSessionTask.progress instead"]
#[optional]
#[unsafe(method(URLSession:assetDownloadTask:didLoadTimeRange:totalTimeRangesLoaded:timeRangeExpectedToLoad:))]
#[unsafe(method_family = none)]
unsafe fn URLSession_assetDownloadTask_didLoadTimeRange_totalTimeRangesLoaded_timeRangeExpectedToLoad(
&self,
session: &NSURLSession,
asset_download_task: &AVAssetDownloadTask,
time_range: CMTimeRange,
loaded_time_ranges: &NSArray<NSValue>,
time_range_expected_to_load: CMTimeRange,
);
#[cfg(feature = "AVMediaSelection")]
/// Method called when the media selection for the download is fully resolved, including any automatic selections.
///
/// - Parameter session: The session the asset download task is on.
/// - Parameter assetDownloadTask: The AVAssetDownloadTask which is being updated.
/// - Parameter resolvedMediaSelection: The resolved media selection for the download task. For the best chance of playing back downloaded content without further network I/O, apply this selection to subsequent AVPlayerItems.
#[optional]
#[unsafe(method(URLSession:assetDownloadTask:didResolveMediaSelection:))]
#[unsafe(method_family = none)]
unsafe fn URLSession_assetDownloadTask_didResolveMediaSelection(
&self,
session: &NSURLSession,
asset_download_task: &AVAssetDownloadTask,
resolved_media_selection: &AVMediaSelection,
);
/// Method called when the asset download task determines the location this asset will be downloaded to.
///
/// This URL should be saved for future instantiations of AVAsset. While an AVAsset already exists for this content, it is advisable to re-use that instance.
///
/// - Parameter session: The session the asset download task is on.
/// - Parameter assetDownloadTask: The AVAssetDownloadTask.
/// - Parameter location: The file URL this task will download media data to.
#[optional]
#[unsafe(method(URLSession:assetDownloadTask:willDownloadToURL:))]
#[unsafe(method_family = none)]
unsafe fn URLSession_assetDownloadTask_willDownloadToURL(
&self,
session: &NSURLSession,
asset_download_task: &AVAssetDownloadTask,
location: &NSURL,
);
/// Method called when the aggregate download task determines the location this asset will be downloaded to.
///
/// This URL should be saved for future instantiations of AVAsset. While an AVAsset already exists for this content, it is advisable to re-use that instance.
///
/// - Parameter session: The session the aggregate asset download task is on.
/// - Parameter aggregateAssetDownloadTask: The AVAggregateAssetDownloadTask.
/// - Parameter location: The file URL this task will download media data to.
#[deprecated = "Use URLSession:assetDownloadTask:willDownloadToURL: instead"]
#[optional]
#[unsafe(method(URLSession:aggregateAssetDownloadTask:willDownloadToURL:))]
#[unsafe(method_family = none)]
unsafe fn URLSession_aggregateAssetDownloadTask_willDownloadToURL(
&self,
session: &NSURLSession,
aggregate_asset_download_task: &AVAggregateAssetDownloadTask,
location: &NSURL,
);
#[cfg(feature = "AVMediaSelection")]
/// Method called when a child AVAssetDownloadTask completes.
///
/// - Parameter session: The session the aggregate asset download task is on.
/// - Parameter aggregateAssetDownloadTask: The AVAggregateAssetDownloadTask.
/// - Parameter mediaSelection: The AVMediaSelection which is now fully available for offline use.
#[deprecated = "Use the NSURLSessionDownloadDelegate method instead, URLSession:task:didCompleteWithError:"]
#[optional]
#[unsafe(method(URLSession:aggregateAssetDownloadTask:didCompleteForMediaSelection:))]
#[unsafe(method_family = none)]
unsafe fn URLSession_aggregateAssetDownloadTask_didCompleteForMediaSelection(
&self,
session: &NSURLSession,
aggregate_asset_download_task: &AVAggregateAssetDownloadTask,
media_selection: &AVMediaSelection,
);
#[cfg(all(feature = "AVMediaSelection", feature = "objc2-core-media"))]
/// Method to adopt to subscribe to progress updates of an AVAggregateAssetDownloadTask
///
/// - Parameter session: The session the asset download task is on.
/// - Parameter aggregateAssetDownloadTask: The AVAggregateAssetDownloadTask.
/// - Parameter timeRange: A CMTimeRange indicating the time range loaded for the media selection being downloaded.
/// - Parameter loadedTimeRanges: A NSArray of NSValues of CMTimeRanges indicating all the time ranges loaded for the media selection being downloaded.
/// - Parameter timeRangeExpectedToLoad: A CMTimeRange indicating the single time range that is expected to be loaded when the download is complete for the media selection being downloaded.
/// - Parameter mediaSelection: The media selection which has additional media data loaded for offline use.
#[deprecated = "Use NSURLSessionTask.progress: instead"]
#[optional]
#[unsafe(method(URLSession:aggregateAssetDownloadTask:didLoadTimeRange:totalTimeRangesLoaded:timeRangeExpectedToLoad:forMediaSelection:))]
#[unsafe(method_family = none)]
unsafe fn URLSession_aggregateAssetDownloadTask_didLoadTimeRange_totalTimeRangesLoaded_timeRangeExpectedToLoad_forMediaSelection(
&self,
session: &NSURLSession,
aggregate_asset_download_task: &AVAggregateAssetDownloadTask,
time_range: CMTimeRange,
loaded_time_ranges: &NSArray<NSValue>,
time_range_expected_to_load: CMTimeRange,
media_selection: &AVMediaSelection,
);
#[cfg(feature = "AVAssetVariant")]
/// Sent when a download task has completed the variant selection.
///
/// - Parameter session: The session the asset download task is on.
/// - Parameter assetDownloadTask: The asset download task.
/// - Parameter variants: The variants chosen. Depends on the environmental condition when the download starts.
#[optional]
#[unsafe(method(URLSession:assetDownloadTask:willDownloadVariants:))]
#[unsafe(method_family = none)]
unsafe fn URLSession_assetDownloadTask_willDownloadVariants(
&self,
session: &NSURLSession,
asset_download_task: &AVAssetDownloadTask,
variants: &NSArray<AVAssetVariant>,
);
#[cfg(feature = "AVMetrics")]
/// Sent when a download task receives an AVMetricEvent.
///
/// - Parameter session: The NSURLSession corresponding to this AVAssetDownloadTask.
/// - Parameter assetDownloadTask: The asset download task.
/// - Parameter metricEvent: The metric event received.
#[optional]
#[unsafe(method(URLSession:assetDownloadTask:didReceiveMetricEvent:))]
#[unsafe(method_family = none)]
unsafe fn URLSession_assetDownloadTask_didReceiveMetricEvent(
&self,
session: &NSURLSession,
asset_download_task: &AVAssetDownloadTask,
metric_event: &AVMetricEvent,
);
}
);
extern_class!(
/// A subclass of NSURLSession to support AVAssetDownloadTask.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadurlsession?language=objc)
#[unsafe(super(NSURLSession, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVAssetDownloadURLSession;
);
extern_conformance!(
unsafe impl NSObjectProtocol for AVAssetDownloadURLSession {}
);
impl AVAssetDownloadURLSession {
extern_methods!(
/// Creates and initializes an AVAssetDownloadURLSession for use with AVAssetDownloadTasks.
///
/// - Parameter configuration: The configuration for this URLSession. Must be a background configuration.
/// - Parameter delegate: The delegate object to handle asset download progress updates and other session related events.
/// - Parameter delegateQueue: The queue to receive delegate callbacks on. If nil, a serial queue will be provided.
///
/// # Safety
///
/// `delegate_queue` possibly has additional threading requirements.
#[unsafe(method(sessionWithConfiguration:assetDownloadDelegate:delegateQueue:))]
#[unsafe(method_family = none)]
pub unsafe fn sessionWithConfiguration_assetDownloadDelegate_delegateQueue(
configuration: &NSURLSessionConfiguration,
delegate: Option<&ProtocolObject<dyn AVAssetDownloadDelegate>>,
delegate_queue: Option<&NSOperationQueue>,
) -> Retained<AVAssetDownloadURLSession>;
#[cfg(feature = "AVAsset")]
/// Creates and initializes an AVAssetDownloadTask to be used with this AVAssetDownloadURLSession.
///
/// This method may return nil if the URLSession has been invalidated.
///
/// - Parameter URLAsset: The AVURLAsset to download locally.
/// - Parameter destinationURL: The local URL to download the asset to. This must be a file URL.
/// - Parameter options: See AVAssetDownloadTask*Key above. Configures non-default behavior for the download task. Using this parameter is required for downloading non-default media selections for HLS assets.
///
/// # Safety
///
/// `options` generic should be of the correct type.
#[deprecated = "Use assetDownloadTaskWithURLAsset:assetTitle:assetArtworkData:options: instead"]
#[unsafe(method(assetDownloadTaskWithURLAsset:destinationURL:options:))]
#[unsafe(method_family = none)]
pub unsafe fn assetDownloadTaskWithURLAsset_destinationURL_options(
&self,
url_asset: &AVURLAsset,
destination_url: &NSURL,
options: Option<&NSDictionary<NSString, AnyObject>>,
) -> Option<Retained<AVAssetDownloadTask>>;
#[cfg(feature = "AVAsset")]
/// Creates and initializes an AVAssetDownloadTask to be used with this AVAssetDownloadURLSession.
///
/// This method may return nil if the URLSession has been invalidated.
///
/// - Parameter URLAsset: The AVURLAsset to download locally.
/// - Parameter title: A human readable title for this asset, expected to be as suitable as possible for the user's preferred languages. Will show up in the usage pane of the settings app.
/// - Parameter artworkData: NSData representing artwork data for this asset. Optional. Will show up in the usage pane of the settings app. Must work with +[UIImage imageWithData:].
/// - Parameter options: See AVAssetDownloadTask*Key above. Configures non-default behavior for the download task. Using this parameter is required for downloading non-default media selections for HLS assets.
///
/// # Safety
///
/// `options` generic should be of the correct type.
#[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
#[unsafe(method(assetDownloadTaskWithURLAsset:assetTitle:assetArtworkData:options:))]
#[unsafe(method_family = none)]
pub unsafe fn assetDownloadTaskWithURLAsset_assetTitle_assetArtworkData_options(
&self,
url_asset: &AVURLAsset,
title: &NSString,
artwork_data: Option<&NSData>,
options: Option<&NSDictionary<NSString, AnyObject>>,
) -> Option<Retained<AVAssetDownloadTask>>;
#[cfg(all(feature = "AVAsset", feature = "AVMediaSelection"))]
/// Creates and initializes an AVAggregateAssetDownloadTask to download multiple AVMediaSelections on an AVURLAsset.
///
/// This method may return nil if the URLSession has been invalidated. The value of AVAssetDownloadTaskMediaSelectionKey will be ignored.
///
/// - Parameter URLAsset: The AVURLAsset to download locally.
/// - Parameter mediaSelections: A list of AVMediaSelections. Each AVMediaSelection will correspond to a childAssetDownloadTask. Use -[AVAsset allMediaSelections] to download all AVMediaSelections on this AVAsset.
/// - Parameter title: A human readable title for this asset, expected to be as suitable as possible for the user's preferred languages. Will show up in the usage pane of the settings app.
/// - Parameter artworkData: Artwork data for this asset. Optional. Will show up in the usage pane of the settings app.
/// - Parameter options: See AVAssetDownloadTask*Key above. Configures non-default behavior for the download task.
///
/// # Safety
///
/// `options` generic should be of the correct type.
#[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
#[unsafe(method(aggregateAssetDownloadTaskWithURLAsset:mediaSelections:assetTitle:assetArtworkData:options:))]
#[unsafe(method_family = none)]
pub unsafe fn aggregateAssetDownloadTaskWithURLAsset_mediaSelections_assetTitle_assetArtworkData_options(
&self,
url_asset: &AVURLAsset,
media_selections: &NSArray<AVMediaSelection>,
title: &NSString,
artwork_data: Option<&NSData>,
options: Option<&NSDictionary<NSString, AnyObject>>,
) -> Option<Retained<AVAggregateAssetDownloadTask>>;
/// Creates and initializes an AVAssetDownloadTask to be used with this AVAssetDownloadURLSession.
///
/// This method will throw an exception if the URLSession has been invalidated.
///
/// - Parameter downloadConfiguration: The configuration to be used to create the download task.
#[unsafe(method(assetDownloadTaskWithConfiguration:))]
#[unsafe(method_family = none)]
pub unsafe fn assetDownloadTaskWithConfiguration(
&self,
download_configuration: &AVAssetDownloadConfiguration,
) -> Retained<AVAssetDownloadTask>;
#[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>;
#[unsafe(method(sharedSession))]
#[unsafe(method_family = none)]
pub unsafe fn sharedSession() -> Retained<NSURLSession>;
#[unsafe(method(sessionWithConfiguration:))]
#[unsafe(method_family = none)]
pub unsafe fn sessionWithConfiguration(
configuration: &NSURLSessionConfiguration,
) -> Retained<NSURLSession>;
/// # Safety
///
/// `queue` possibly has additional threading requirements.
#[unsafe(method(sessionWithConfiguration:delegate:delegateQueue:))]
#[unsafe(method_family = none)]
pub unsafe fn sessionWithConfiguration_delegate_delegateQueue(
configuration: &NSURLSessionConfiguration,
delegate: Option<&ProtocolObject<dyn NSURLSessionDelegate>>,
queue: Option<&NSOperationQueue>,
) -> Retained<NSURLSession>;
#[unsafe(method(dataTaskWithRequest:))]
#[unsafe(method_family = none)]
pub unsafe fn dataTaskWithRequest(
&self,
request: &NSURLRequest,
) -> Retained<NSURLSessionDataTask>;
#[unsafe(method(dataTaskWithURL:))]
#[unsafe(method_family = none)]
pub unsafe fn dataTaskWithURL(&self, url: &NSURL) -> Retained<NSURLSessionDataTask>;
#[unsafe(method(uploadTaskWithRequest:fromFile:))]
#[unsafe(method_family = none)]
pub unsafe fn uploadTaskWithRequest_fromFile(
&self,
request: &NSURLRequest,
file_url: &NSURL,
) -> Retained<NSURLSessionUploadTask>;
#[unsafe(method(uploadTaskWithRequest:fromData:))]
#[unsafe(method_family = none)]
pub unsafe fn uploadTaskWithRequest_fromData(
&self,
request: &NSURLRequest,
body_data: &NSData,
) -> Retained<NSURLSessionUploadTask>;
#[unsafe(method(uploadTaskWithStreamedRequest:))]
#[unsafe(method_family = none)]
pub unsafe fn uploadTaskWithStreamedRequest(
&self,
request: &NSURLRequest,
) -> Retained<NSURLSessionUploadTask>;
#[unsafe(method(downloadTaskWithRequest:))]
#[unsafe(method_family = none)]
pub unsafe fn downloadTaskWithRequest(
&self,
request: &NSURLRequest,
) -> Retained<NSURLSessionDownloadTask>;
#[unsafe(method(downloadTaskWithURL:))]
#[unsafe(method_family = none)]
pub unsafe fn downloadTaskWithURL(&self, url: &NSURL)
-> Retained<NSURLSessionDownloadTask>;
#[unsafe(method(downloadTaskWithResumeData:))]
#[unsafe(method_family = none)]
pub unsafe fn downloadTaskWithResumeData(
&self,
resume_data: &NSData,
) -> Retained<NSURLSessionDownloadTask>;
#[cfg(feature = "block2")]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(dataTaskWithRequest:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn dataTaskWithRequest_completionHandler(
&self,
request: &NSURLRequest,
completion_handler: &block2::DynBlock<
dyn Fn(NonNull<NSData>, NonNull<NSURLResponse>, NonNull<NSError>),
>,
) -> Retained<NSURLSessionDataTask>;
#[cfg(feature = "block2")]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(dataTaskWithURL:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn dataTaskWithURL_completionHandler(
&self,
url: &NSURL,
completion_handler: &block2::DynBlock<
dyn Fn(NonNull<NSData>, NonNull<NSURLResponse>, NonNull<NSError>),
>,
) -> Retained<NSURLSessionDataTask>;
#[cfg(feature = "block2")]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(uploadTaskWithRequest:fromFile:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn uploadTaskWithRequest_fromFile_completionHandler(
&self,
request: &NSURLRequest,
file_url: &NSURL,
completion_handler: &block2::DynBlock<
dyn Fn(NonNull<NSData>, NonNull<NSURLResponse>, NonNull<NSError>),
>,
) -> Retained<NSURLSessionUploadTask>;
#[cfg(feature = "block2")]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(uploadTaskWithRequest:fromData:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn uploadTaskWithRequest_fromData_completionHandler(
&self,
request: &NSURLRequest,
body_data: Option<&NSData>,
completion_handler: &block2::DynBlock<
dyn Fn(NonNull<NSData>, NonNull<NSURLResponse>, NonNull<NSError>),
>,
) -> Retained<NSURLSessionUploadTask>;
#[cfg(feature = "block2")]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(downloadTaskWithRequest:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn downloadTaskWithRequest_completionHandler(
&self,
request: &NSURLRequest,
completion_handler: &block2::DynBlock<
dyn Fn(NonNull<NSURL>, NonNull<NSURLResponse>, NonNull<NSError>),
>,
) -> Retained<NSURLSessionDownloadTask>;
#[cfg(feature = "block2")]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(downloadTaskWithURL:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn downloadTaskWithURL_completionHandler(
&self,
url: &NSURL,
completion_handler: &block2::DynBlock<
dyn Fn(NonNull<NSURL>, NonNull<NSURLResponse>, NonNull<NSError>),
>,
) -> Retained<NSURLSessionDownloadTask>;
#[cfg(feature = "block2")]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(downloadTaskWithResumeData:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn downloadTaskWithResumeData_completionHandler(
&self,
resume_data: &NSData,
completion_handler: &block2::DynBlock<
dyn Fn(NonNull<NSURL>, NonNull<NSURLResponse>, NonNull<NSError>),
>,
) -> Retained<NSURLSessionDownloadTask>;
);
}