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