objc2_av_foundation/generated/
AVAssetDownloadTask.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-media")]
7use objc2_core_media::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern "C" {
13    /// 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.
14    /// The value for this key should be a NSNumber.
15    ///
16    /// By default, the highest media bitrate will be selected for download.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskminimumrequiredmediabitratekey?language=objc)
19    pub static AVAssetDownloadTaskMinimumRequiredMediaBitrateKey: &'static NSString;
20}
21
22extern "C" {
23    /// 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.
24    /// The value for this key should be a NSValue of CGSize.
25    ///
26    /// By default, the highest media presentation size will be selected for download.
27    ///
28    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskminimumrequiredpresentationsizekey?language=objc)
29    pub static AVAssetDownloadTaskMinimumRequiredPresentationSizeKey: &'static NSString;
30}
31
32extern "C" {
33    /// The media selection for this download.
34    /// The value for this key should be an AVMediaSelection.
35    ///
36    /// By default, media selections for AVAssetDownloadTask will be automatically selected.
37    ///
38    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskmediaselectionkey?language=objc)
39    pub static AVAssetDownloadTaskMediaSelectionKey: &'static NSString;
40}
41
42extern "C" {
43    /// Download the specified media selections with or without support for multichannel playback.
44    /// The value for this key should be an NSNumber representing a BOOL.
45    ///
46    /// By default AVAssetDownloadTask will prefer multichannel by downloading the most capable multichannel rendition available in additon to stereo.
47    ///
48    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskmediaselectionprefersmultichannelkey?language=objc)
49    pub static AVAssetDownloadTaskMediaSelectionPrefersMultichannelKey: &'static NSString;
50}
51
52extern "C" {
53    /// Download the specified media selections in lossless audio representation.
54    /// The value for this key should be an NSNumber representing a BOOL.
55    ///
56    /// By default AVAssetDownloadTask will prefer lossy audio representation.
57    ///
58    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskpreferslosslessaudiokey?language=objc)
59    pub static AVAssetDownloadTaskPrefersLosslessAudioKey: &'static NSString;
60}
61
62extern "C" {
63    /// Download the specified media selections with or without HDR content.
64    /// The value for this key should be an NSNumber representing a BOOL.
65    ///
66    /// By default AVAssetDownloadTask will prefer HDR content.
67    ///
68    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtaskprefershdrkey?language=objc)
69    pub static AVAssetDownloadTaskPrefersHDRKey: &'static NSString;
70}
71
72extern_class!(
73    /// A NSURLSessionTask that accepts remote AVURLAssets to download locally.
74    ///
75    /// 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.
76    ///
77    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadtask?language=objc)
78    #[unsafe(super(NSURLSessionTask, NSObject))]
79    #[derive(Debug, PartialEq, Eq, Hash)]
80    pub struct AVAssetDownloadTask;
81);
82
83unsafe impl NSCopying for AVAssetDownloadTask {}
84
85unsafe impl CopyingHelper for AVAssetDownloadTask {
86    type Result = Self;
87}
88
89unsafe impl NSObjectProtocol for AVAssetDownloadTask {}
90
91unsafe impl NSProgressReporting for AVAssetDownloadTask {}
92
93impl AVAssetDownloadTask {
94    extern_methods!(
95        #[cfg(feature = "AVAsset")]
96        /// The asset supplied to the download task upon initialization.
97        #[unsafe(method(URLAsset))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn URLAsset(&self) -> Retained<AVURLAsset>;
100
101        /// The file URL supplied to the download task upon initialization.
102        ///
103        /// This URL may have been appended with the appropriate extension for the asset.
104        #[deprecated = "Use the URL property of URLAsset instead"]
105        #[unsafe(method(destinationURL))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn destinationURL(&self) -> Retained<NSURL>;
108
109        /// The options supplied to the download task upon initialization.
110        #[deprecated = "Use AVAssetDownloadConfiguration instead"]
111        #[unsafe(method(options))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn options(&self) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
114
115        /// 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.
116        ///
117        /// Returns an NSArray of NSValues containing CMTimeRanges.
118        #[deprecated = "Use NSURLSessionTask.progress instead"]
119        #[unsafe(method(loadedTimeRanges))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn loadedTimeRanges(&self) -> Retained<NSArray<NSValue>>;
122
123        #[unsafe(method(init))]
124        #[unsafe(method_family = init)]
125        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
126
127        #[unsafe(method(new))]
128        #[unsafe(method_family = new)]
129        pub unsafe fn new() -> Retained<Self>;
130
131        #[unsafe(method(originalRequest))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn originalRequest(&self) -> Retained<NSURLRequest>;
134
135        #[unsafe(method(currentRequest))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn currentRequest(&self) -> Retained<NSURLRequest>;
138
139        #[unsafe(method(response))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn response(&self) -> Retained<NSURLResponse>;
142    );
143}
144
145extern_class!(
146    /// Configuration parameters for the download task.
147    ///
148    /// 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.
149    /// For example, the primary content configuration may represent stereo audio renditions and auxiliary configuration may represent complementing multichannel audio renditions.
150    ///
151    /// 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.
152    ///
153    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadconfiguration?language=objc)
154    #[unsafe(super(NSObject))]
155    #[derive(Debug, PartialEq, Eq, Hash)]
156    pub struct AVAssetDownloadConfiguration;
157);
158
159unsafe impl NSObjectProtocol for AVAssetDownloadConfiguration {}
160
161impl AVAssetDownloadConfiguration {
162    extern_methods!(
163        #[unsafe(method(init))]
164        #[unsafe(method_family = init)]
165        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
166
167        #[unsafe(method(new))]
168        #[unsafe(method_family = new)]
169        pub unsafe fn new() -> Retained<Self>;
170
171        #[cfg(feature = "AVAsset")]
172        /// Creates and initializes a download configuration object.
173        ///
174        /// This method will throw an exception if AVURLAsset has been invalidated.
175        ///
176        /// Parameter `asset`: The asset to create the download configuration for.
177        ///
178        /// 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.
179        #[unsafe(method(downloadConfigurationWithAsset:title:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn downloadConfigurationWithAsset_title(
182            asset: &AVURLAsset,
183            title: &NSString,
184        ) -> Retained<Self>;
185
186        /// 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:].
187        #[unsafe(method(artworkData))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn artworkData(&self) -> Option<Retained<NSData>>;
190
191        /// Setter for [`artworkData`][Self::artworkData].
192        #[unsafe(method(setArtworkData:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn setArtworkData(&self, artwork_data: Option<&NSData>);
195
196        /// The primary content for the download.
197        #[unsafe(method(primaryContentConfiguration))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn primaryContentConfiguration(
200            &self,
201        ) -> Retained<AVAssetDownloadContentConfiguration>;
202
203        /// The auxiliary content for the download. Optional.
204        ///
205        /// 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.
206        #[unsafe(method(auxiliaryContentConfigurations))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn auxiliaryContentConfigurations(
209            &self,
210        ) -> Retained<NSArray<AVAssetDownloadContentConfiguration>>;
211
212        /// Setter for [`auxiliaryContentConfigurations`][Self::auxiliaryContentConfigurations].
213        #[unsafe(method(setAuxiliaryContentConfigurations:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn setAuxiliaryContentConfigurations(
216            &self,
217            auxiliary_content_configurations: &NSArray<AVAssetDownloadContentConfiguration>,
218        );
219
220        /// Optimizes auxiliary content selection depending on the primary to minimize total number of video renditions downloaded. True by default.
221        ///
222        /// 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.
223        #[unsafe(method(optimizesAuxiliaryContentConfigurations))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn optimizesAuxiliaryContentConfigurations(&self) -> bool;
226
227        /// Setter for [`optimizesAuxiliaryContentConfigurations`][Self::optimizesAuxiliaryContentConfigurations].
228        #[unsafe(method(setOptimizesAuxiliaryContentConfigurations:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn setOptimizesAuxiliaryContentConfigurations(
231            &self,
232            optimizes_auxiliary_content_configurations: bool,
233        );
234
235        /// Download interstitial assets as listed in the index file. False by default.
236        ///
237        /// 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.
238        #[unsafe(method(downloadsInterstitialAssets))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn downloadsInterstitialAssets(&self) -> bool;
241
242        /// Setter for [`downloadsInterstitialAssets`][Self::downloadsInterstitialAssets].
243        #[unsafe(method(setDownloadsInterstitialAssets:))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn setDownloadsInterstitialAssets(&self, downloads_interstitial_assets: bool);
246    );
247}
248
249extern_class!(
250    /// Represents the configuration consisting of variant and the variant's media options.
251    ///
252    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadcontentconfiguration?language=objc)
253    #[unsafe(super(NSObject))]
254    #[derive(Debug, PartialEq, Eq, Hash)]
255    pub struct AVAssetDownloadContentConfiguration;
256);
257
258unsafe impl NSCopying for AVAssetDownloadContentConfiguration {}
259
260unsafe impl CopyingHelper for AVAssetDownloadContentConfiguration {
261    type Result = Self;
262}
263
264unsafe impl NSObjectProtocol for AVAssetDownloadContentConfiguration {}
265
266impl AVAssetDownloadContentConfiguration {
267    extern_methods!(
268        #[cfg(feature = "AVAssetVariant")]
269        /// An array of variant qualifiers.
270        ///
271        /// 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.
272        /// 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.
273        /// 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.
274        #[unsafe(method(variantQualifiers))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn variantQualifiers(&self) -> Retained<NSArray<AVAssetVariantQualifier>>;
277
278        #[cfg(feature = "AVAssetVariant")]
279        /// Setter for [`variantQualifiers`][Self::variantQualifiers].
280        #[unsafe(method(setVariantQualifiers:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn setVariantQualifiers(
283            &self,
284            variant_qualifiers: &NSArray<AVAssetVariantQualifier>,
285        );
286
287        #[cfg(feature = "AVMediaSelection")]
288        /// An array of media selections obtained from the AVAsset.
289        ///
290        /// If a media selection is not provided, automatic media selection associated with the asset will be used.
291        #[unsafe(method(mediaSelections))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn mediaSelections(&self) -> Retained<NSArray<AVMediaSelection>>;
294
295        #[cfg(feature = "AVMediaSelection")]
296        /// Setter for [`mediaSelections`][Self::mediaSelections].
297        #[unsafe(method(setMediaSelections:))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn setMediaSelections(&self, media_selections: &NSArray<AVMediaSelection>);
300    );
301}
302
303/// Methods declared on superclass `NSObject`.
304impl AVAssetDownloadContentConfiguration {
305    extern_methods!(
306        #[unsafe(method(init))]
307        #[unsafe(method_family = init)]
308        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
309
310        #[unsafe(method(new))]
311        #[unsafe(method_family = new)]
312        pub unsafe fn new() -> Retained<Self>;
313    );
314}
315
316extern_class!(
317    /// An AVAssetDownloadTask used for downloading multiple AVMediaSelections for a single AVAsset, under the umbrella of a single download task.
318    ///
319    /// Should be created with -[AVAssetDownloadURLSession aggregateAssetDownloadTaskWithURLAsset:mediaSelections:assetTitle:assetArtworkData:options:. For progress tracking, monitor the delegate callbacks for each childAssetDownloadTask.
320    ///
321    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
322    ///
323    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avaggregateassetdownloadtask?language=objc)
324    #[unsafe(super(NSURLSessionTask, NSObject))]
325    #[derive(Debug, PartialEq, Eq, Hash)]
326    #[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
327    pub struct AVAggregateAssetDownloadTask;
328);
329
330unsafe impl NSCopying for AVAggregateAssetDownloadTask {}
331
332unsafe impl CopyingHelper for AVAggregateAssetDownloadTask {
333    type Result = Self;
334}
335
336unsafe impl NSObjectProtocol for AVAggregateAssetDownloadTask {}
337
338unsafe impl NSProgressReporting for AVAggregateAssetDownloadTask {}
339
340impl AVAggregateAssetDownloadTask {
341    extern_methods!(
342        #[cfg(feature = "AVAsset")]
343        /// The asset supplied to the download task upon initialization.
344        #[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
345        #[unsafe(method(URLAsset))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn URLAsset(&self) -> Retained<AVURLAsset>;
348
349        #[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
350        #[unsafe(method(init))]
351        #[unsafe(method_family = init)]
352        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
353
354        #[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
355        #[unsafe(method(new))]
356        #[unsafe(method_family = new)]
357        pub unsafe fn new() -> Retained<Self>;
358
359        #[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
360        #[unsafe(method(originalRequest))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn originalRequest(&self) -> Retained<NSURLRequest>;
363
364        #[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
365        #[unsafe(method(currentRequest))]
366        #[unsafe(method_family = none)]
367        pub unsafe fn currentRequest(&self) -> Retained<NSURLRequest>;
368
369        #[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
370        #[unsafe(method(response))]
371        #[unsafe(method_family = none)]
372        pub unsafe fn response(&self) -> Retained<NSURLResponse>;
373    );
374}
375
376extern_protocol!(
377    /// Delegate methods to implement when adopting AVAssetDownloadTask.
378    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
379    ///
380    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloaddelegate?language=objc)
381    pub unsafe trait AVAssetDownloadDelegate: NSURLSessionTaskDelegate {
382        /// Sent when a download task that has completed a download.
383        ///
384        /// 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.
385        ///
386        /// Parameter `session`: The session the asset download task is on.
387        ///
388        /// Parameter `assetDownloadTask`: The AVAssetDownloadTask whose downloaded completed.
389        ///
390        /// Parameter `location`: The location the asset has been downloaded to.
391        #[deprecated = "Use URLSession:assetDownloadTask:willDownloadToURL: instead"]
392        #[optional]
393        #[unsafe(method(URLSession:assetDownloadTask:didFinishDownloadingToURL:))]
394        #[unsafe(method_family = none)]
395        unsafe fn URLSession_assetDownloadTask_didFinishDownloadingToURL(
396            &self,
397            session: &NSURLSession,
398            asset_download_task: &AVAssetDownloadTask,
399            location: &NSURL,
400        );
401
402        #[cfg(feature = "objc2-core-media")]
403        /// Method to adopt to subscribe to progress updates of an AVAssetDownloadTask.
404        ///
405        /// Parameter `session`: The session the asset download task is on.
406        ///
407        /// Parameter `assetDownloadTask`: The AVAssetDownloadTask which is being updated.
408        ///
409        /// Parameter `timeRange`: A CMTimeRange indicating the time range loaded since the last time this method was called.
410        ///
411        /// Parameter `loadedTimeRanges`: A NSArray of NSValues of CMTimeRanges indicating all the time ranges loaded by this asset download task.
412        ///
413        /// Parameter `timeRangeExpectedToLoad`: A CMTimeRange indicating the single time range that is expected to be loaded when the download is complete.
414        #[deprecated = "Use NSURLSessionTask.progress instead"]
415        #[optional]
416        #[unsafe(method(URLSession:assetDownloadTask:didLoadTimeRange:totalTimeRangesLoaded:timeRangeExpectedToLoad:))]
417        #[unsafe(method_family = none)]
418        unsafe fn URLSession_assetDownloadTask_didLoadTimeRange_totalTimeRangesLoaded_timeRangeExpectedToLoad(
419            &self,
420            session: &NSURLSession,
421            asset_download_task: &AVAssetDownloadTask,
422            time_range: CMTimeRange,
423            loaded_time_ranges: &NSArray<NSValue>,
424            time_range_expected_to_load: CMTimeRange,
425        );
426
427        #[cfg(feature = "AVMediaSelection")]
428        #[optional]
429        #[unsafe(method(URLSession:assetDownloadTask:didResolveMediaSelection:))]
430        #[unsafe(method_family = none)]
431        unsafe fn URLSession_assetDownloadTask_didResolveMediaSelection(
432            &self,
433            session: &NSURLSession,
434            asset_download_task: &AVAssetDownloadTask,
435            resolved_media_selection: &AVMediaSelection,
436        );
437
438        #[optional]
439        #[unsafe(method(URLSession:assetDownloadTask:willDownloadToURL:))]
440        #[unsafe(method_family = none)]
441        unsafe fn URLSession_assetDownloadTask_willDownloadToURL(
442            &self,
443            session: &NSURLSession,
444            asset_download_task: &AVAssetDownloadTask,
445            location: &NSURL,
446        );
447
448        #[deprecated = "Use URLSession:assetDownloadTask:willDownloadToURL: instead"]
449        #[optional]
450        #[unsafe(method(URLSession:aggregateAssetDownloadTask:willDownloadToURL:))]
451        #[unsafe(method_family = none)]
452        unsafe fn URLSession_aggregateAssetDownloadTask_willDownloadToURL(
453            &self,
454            session: &NSURLSession,
455            aggregate_asset_download_task: &AVAggregateAssetDownloadTask,
456            location: &NSURL,
457        );
458
459        #[cfg(feature = "AVMediaSelection")]
460        #[deprecated = "Use the NSURLSessionDownloadDelegate method instead, URLSession:task:didCompleteWithError:"]
461        #[optional]
462        #[unsafe(method(URLSession:aggregateAssetDownloadTask:didCompleteForMediaSelection:))]
463        #[unsafe(method_family = none)]
464        unsafe fn URLSession_aggregateAssetDownloadTask_didCompleteForMediaSelection(
465            &self,
466            session: &NSURLSession,
467            aggregate_asset_download_task: &AVAggregateAssetDownloadTask,
468            media_selection: &AVMediaSelection,
469        );
470
471        #[cfg(all(feature = "AVMediaSelection", feature = "objc2-core-media"))]
472        #[deprecated = "Use NSURLSessionTask.progress: instead"]
473        #[optional]
474        #[unsafe(method(URLSession:aggregateAssetDownloadTask:didLoadTimeRange:totalTimeRangesLoaded:timeRangeExpectedToLoad:forMediaSelection:))]
475        #[unsafe(method_family = none)]
476        unsafe fn URLSession_aggregateAssetDownloadTask_didLoadTimeRange_totalTimeRangesLoaded_timeRangeExpectedToLoad_forMediaSelection(
477            &self,
478            session: &NSURLSession,
479            aggregate_asset_download_task: &AVAggregateAssetDownloadTask,
480            time_range: CMTimeRange,
481            loaded_time_ranges: &NSArray<NSValue>,
482            time_range_expected_to_load: CMTimeRange,
483            media_selection: &AVMediaSelection,
484        );
485
486        #[cfg(feature = "AVAssetVariant")]
487        /// Sent when a download task has completed the variant selection.
488        ///
489        /// Parameter `session`: The session the asset download task is on.
490        ///
491        /// Parameter `assetDownloadTask`: The asset download task.
492        ///
493        /// Parameter `variants`: The variants chosen. Depends on the environmental condition when the download starts.
494        #[optional]
495        #[unsafe(method(URLSession:assetDownloadTask:willDownloadVariants:))]
496        #[unsafe(method_family = none)]
497        unsafe fn URLSession_assetDownloadTask_willDownloadVariants(
498            &self,
499            session: &NSURLSession,
500            asset_download_task: &AVAssetDownloadTask,
501            variants: &NSArray<AVAssetVariant>,
502        );
503    }
504);
505
506extern_class!(
507    /// A subclass of NSURLSession to support AVAssetDownloadTask.
508    ///
509    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetdownloadurlsession?language=objc)
510    #[unsafe(super(NSURLSession, NSObject))]
511    #[derive(Debug, PartialEq, Eq, Hash)]
512    pub struct AVAssetDownloadURLSession;
513);
514
515unsafe impl NSObjectProtocol for AVAssetDownloadURLSession {}
516
517impl AVAssetDownloadURLSession {
518    extern_methods!(
519        /// Creates and initializes an AVAssetDownloadURLSession for use with AVAssetDownloadTasks.
520        ///
521        /// Parameter `configuration`: The configuration for this URLSession. Must be a background configuration.
522        ///
523        /// Parameter `delegate`: The delegate object to handle asset download progress updates and other session related events.
524        ///
525        /// Parameter `delegateQueue`: The queue to receive delegate callbacks on. If nil, a serial queue will be provided.
526        #[unsafe(method(sessionWithConfiguration:assetDownloadDelegate:delegateQueue:))]
527        #[unsafe(method_family = none)]
528        pub unsafe fn sessionWithConfiguration_assetDownloadDelegate_delegateQueue(
529            configuration: &NSURLSessionConfiguration,
530            delegate: Option<&ProtocolObject<dyn AVAssetDownloadDelegate>>,
531            delegate_queue: Option<&NSOperationQueue>,
532        ) -> Retained<AVAssetDownloadURLSession>;
533
534        #[cfg(feature = "AVAsset")]
535        /// Creates and initializes an AVAssetDownloadTask to be used with this AVAssetDownloadURLSession.
536        ///
537        /// This method may return nil if the URLSession has been invalidated.
538        ///
539        /// Parameter `URLAsset`: The AVURLAsset to download locally.
540        ///
541        /// Parameter `destinationURL`: The local URL to download the asset to. This must be a file URL.
542        ///
543        /// 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.
544        #[deprecated = "Use assetDownloadTaskWithURLAsset:assetTitle:assetArtworkData:options: instead"]
545        #[unsafe(method(assetDownloadTaskWithURLAsset:destinationURL:options:))]
546        #[unsafe(method_family = none)]
547        pub unsafe fn assetDownloadTaskWithURLAsset_destinationURL_options(
548            &self,
549            url_asset: &AVURLAsset,
550            destination_url: &NSURL,
551            options: Option<&NSDictionary<NSString, AnyObject>>,
552        ) -> Option<Retained<AVAssetDownloadTask>>;
553
554        #[cfg(feature = "AVAsset")]
555        /// Creates and initializes an AVAssetDownloadTask to be used with this AVAssetDownloadURLSession.
556        ///
557        /// This method may return nil if the URLSession has been invalidated.
558        ///
559        /// Parameter `URLAsset`: The AVURLAsset to download locally.
560        ///
561        /// 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.
562        ///
563        /// 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:].
564        ///
565        /// 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.
566        #[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
567        #[unsafe(method(assetDownloadTaskWithURLAsset:assetTitle:assetArtworkData:options:))]
568        #[unsafe(method_family = none)]
569        pub unsafe fn assetDownloadTaskWithURLAsset_assetTitle_assetArtworkData_options(
570            &self,
571            url_asset: &AVURLAsset,
572            title: &NSString,
573            artwork_data: Option<&NSData>,
574            options: Option<&NSDictionary<NSString, AnyObject>>,
575        ) -> Option<Retained<AVAssetDownloadTask>>;
576
577        #[cfg(all(feature = "AVAsset", feature = "AVMediaSelection"))]
578        /// Creates and initializes an AVAggregateAssetDownloadTask to download multiple AVMediaSelections on an AVURLAsset.
579        ///
580        /// This method may return nil if the URLSession has been invalidated. The value of AVAssetDownloadTaskMediaSelectionKey will be ignored.
581        ///
582        /// Parameter `URLAsset`: The AVURLAsset to download locally.
583        ///
584        /// Parameter `mediaSelections`: A list of AVMediaSelections. Each AVMediaSelection will correspond to a childAssetDownloadTask. Use -[AVAsset allMediaSelections] to download all AVMediaSelections on this AVAsset.
585        ///
586        /// 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.
587        ///
588        /// Parameter `artworkData`: Artwork data for this asset. Optional. Will show up in the usage pane of the settings app.
589        ///
590        /// Parameter `options`: See AVAssetDownloadTask*Key above. Configures non-default behavior for the download task.
591        #[deprecated = "Use assetDownloadTaskWithConfiguration: instead"]
592        #[unsafe(method(aggregateAssetDownloadTaskWithURLAsset:mediaSelections:assetTitle:assetArtworkData:options:))]
593        #[unsafe(method_family = none)]
594        pub unsafe fn aggregateAssetDownloadTaskWithURLAsset_mediaSelections_assetTitle_assetArtworkData_options(
595            &self,
596            url_asset: &AVURLAsset,
597            media_selections: &NSArray<AVMediaSelection>,
598            title: &NSString,
599            artwork_data: Option<&NSData>,
600            options: Option<&NSDictionary<NSString, AnyObject>>,
601        ) -> Option<Retained<AVAggregateAssetDownloadTask>>;
602
603        /// Creates and initializes an AVAssetDownloadTask to be used with this AVAssetDownloadURLSession.
604        ///
605        /// This method will throw an exception if the URLSession has been invalidated.
606        ///
607        /// Parameter `downloadConfiguration`: The configuration to be used to create the download task.
608        #[unsafe(method(assetDownloadTaskWithConfiguration:))]
609        #[unsafe(method_family = none)]
610        pub unsafe fn assetDownloadTaskWithConfiguration(
611            &self,
612            download_configuration: &AVAssetDownloadConfiguration,
613        ) -> Retained<AVAssetDownloadTask>;
614
615        #[unsafe(method(init))]
616        #[unsafe(method_family = init)]
617        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
618
619        #[unsafe(method(new))]
620        #[unsafe(method_family = new)]
621        pub unsafe fn new() -> Retained<Self>;
622
623        #[unsafe(method(sharedSession))]
624        #[unsafe(method_family = none)]
625        pub unsafe fn sharedSession() -> Retained<NSURLSession>;
626
627        #[unsafe(method(sessionWithConfiguration:))]
628        #[unsafe(method_family = none)]
629        pub unsafe fn sessionWithConfiguration(
630            configuration: &NSURLSessionConfiguration,
631        ) -> Retained<NSURLSession>;
632
633        #[unsafe(method(sessionWithConfiguration:delegate:delegateQueue:))]
634        #[unsafe(method_family = none)]
635        pub unsafe fn sessionWithConfiguration_delegate_delegateQueue(
636            configuration: &NSURLSessionConfiguration,
637            delegate: Option<&ProtocolObject<dyn NSURLSessionDelegate>>,
638            queue: Option<&NSOperationQueue>,
639        ) -> Retained<NSURLSession>;
640
641        #[unsafe(method(dataTaskWithRequest:))]
642        #[unsafe(method_family = none)]
643        pub unsafe fn dataTaskWithRequest(
644            &self,
645            request: &NSURLRequest,
646        ) -> Retained<NSURLSessionDataTask>;
647
648        #[unsafe(method(dataTaskWithURL:))]
649        #[unsafe(method_family = none)]
650        pub unsafe fn dataTaskWithURL(&self, url: &NSURL) -> Retained<NSURLSessionDataTask>;
651
652        #[unsafe(method(uploadTaskWithRequest:fromFile:))]
653        #[unsafe(method_family = none)]
654        pub unsafe fn uploadTaskWithRequest_fromFile(
655            &self,
656            request: &NSURLRequest,
657            file_url: &NSURL,
658        ) -> Retained<NSURLSessionUploadTask>;
659
660        #[unsafe(method(uploadTaskWithRequest:fromData:))]
661        #[unsafe(method_family = none)]
662        pub unsafe fn uploadTaskWithRequest_fromData(
663            &self,
664            request: &NSURLRequest,
665            body_data: &NSData,
666        ) -> Retained<NSURLSessionUploadTask>;
667
668        #[unsafe(method(uploadTaskWithStreamedRequest:))]
669        #[unsafe(method_family = none)]
670        pub unsafe fn uploadTaskWithStreamedRequest(
671            &self,
672            request: &NSURLRequest,
673        ) -> Retained<NSURLSessionUploadTask>;
674
675        #[unsafe(method(downloadTaskWithRequest:))]
676        #[unsafe(method_family = none)]
677        pub unsafe fn downloadTaskWithRequest(
678            &self,
679            request: &NSURLRequest,
680        ) -> Retained<NSURLSessionDownloadTask>;
681
682        #[unsafe(method(downloadTaskWithURL:))]
683        #[unsafe(method_family = none)]
684        pub unsafe fn downloadTaskWithURL(&self, url: &NSURL)
685            -> Retained<NSURLSessionDownloadTask>;
686
687        #[unsafe(method(downloadTaskWithResumeData:))]
688        #[unsafe(method_family = none)]
689        pub unsafe fn downloadTaskWithResumeData(
690            &self,
691            resume_data: &NSData,
692        ) -> Retained<NSURLSessionDownloadTask>;
693
694        #[cfg(feature = "block2")]
695        #[unsafe(method(dataTaskWithRequest:completionHandler:))]
696        #[unsafe(method_family = none)]
697        pub unsafe fn dataTaskWithRequest_completionHandler(
698            &self,
699            request: &NSURLRequest,
700            completion_handler: &block2::Block<
701                dyn Fn(NonNull<NSData>, NonNull<NSURLResponse>, NonNull<NSError>),
702            >,
703        ) -> Retained<NSURLSessionDataTask>;
704
705        #[cfg(feature = "block2")]
706        #[unsafe(method(dataTaskWithURL:completionHandler:))]
707        #[unsafe(method_family = none)]
708        pub unsafe fn dataTaskWithURL_completionHandler(
709            &self,
710            url: &NSURL,
711            completion_handler: &block2::Block<
712                dyn Fn(NonNull<NSData>, NonNull<NSURLResponse>, NonNull<NSError>),
713            >,
714        ) -> Retained<NSURLSessionDataTask>;
715
716        #[cfg(feature = "block2")]
717        #[unsafe(method(uploadTaskWithRequest:fromFile:completionHandler:))]
718        #[unsafe(method_family = none)]
719        pub unsafe fn uploadTaskWithRequest_fromFile_completionHandler(
720            &self,
721            request: &NSURLRequest,
722            file_url: &NSURL,
723            completion_handler: &block2::Block<
724                dyn Fn(NonNull<NSData>, NonNull<NSURLResponse>, NonNull<NSError>),
725            >,
726        ) -> Retained<NSURLSessionUploadTask>;
727
728        #[cfg(feature = "block2")]
729        #[unsafe(method(uploadTaskWithRequest:fromData:completionHandler:))]
730        #[unsafe(method_family = none)]
731        pub unsafe fn uploadTaskWithRequest_fromData_completionHandler(
732            &self,
733            request: &NSURLRequest,
734            body_data: Option<&NSData>,
735            completion_handler: &block2::Block<
736                dyn Fn(NonNull<NSData>, NonNull<NSURLResponse>, NonNull<NSError>),
737            >,
738        ) -> Retained<NSURLSessionUploadTask>;
739
740        #[cfg(feature = "block2")]
741        #[unsafe(method(downloadTaskWithRequest:completionHandler:))]
742        #[unsafe(method_family = none)]
743        pub unsafe fn downloadTaskWithRequest_completionHandler(
744            &self,
745            request: &NSURLRequest,
746            completion_handler: &block2::Block<
747                dyn Fn(NonNull<NSURL>, NonNull<NSURLResponse>, NonNull<NSError>),
748            >,
749        ) -> Retained<NSURLSessionDownloadTask>;
750
751        #[cfg(feature = "block2")]
752        #[unsafe(method(downloadTaskWithURL:completionHandler:))]
753        #[unsafe(method_family = none)]
754        pub unsafe fn downloadTaskWithURL_completionHandler(
755            &self,
756            url: &NSURL,
757            completion_handler: &block2::Block<
758                dyn Fn(NonNull<NSURL>, NonNull<NSURLResponse>, NonNull<NSError>),
759            >,
760        ) -> Retained<NSURLSessionDownloadTask>;
761
762        #[cfg(feature = "block2")]
763        #[unsafe(method(downloadTaskWithResumeData:completionHandler:))]
764        #[unsafe(method_family = none)]
765        pub unsafe fn downloadTaskWithResumeData_completionHandler(
766            &self,
767            resume_data: &NSData,
768            completion_handler: &block2::Block<
769                dyn Fn(NonNull<NSURL>, NonNull<NSURLResponse>, NonNull<NSError>),
770            >,
771        ) -> Retained<NSURLSessionDownloadTask>;
772    );
773}