objc2_av_foundation/generated/AVAssetResourceLoader.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetresourceloader?language=objc)
14 #[unsafe(super(NSObject))]
15 #[derive(Debug, PartialEq, Eq, Hash)]
16 pub struct AVAssetResourceLoader;
17);
18
19extern_conformance!(
20 unsafe impl NSObjectProtocol for AVAssetResourceLoader {}
21);
22
23impl AVAssetResourceLoader {
24 extern_methods!(
25 #[unsafe(method(init))]
26 #[unsafe(method_family = init)]
27 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
28
29 #[unsafe(method(new))]
30 #[unsafe(method_family = new)]
31 pub unsafe fn new() -> Retained<Self>;
32
33 #[cfg(feature = "dispatch2")]
34 /// Sets the receiver's delegate that will mediate resource loading and the dispatch queue on which delegate methods will be invoked.
35 ///
36 /// Parameter `delegate`: An object conforming to the AVAssetResourceLoaderDelegate protocol.
37 ///
38 /// Parameter `delegateQueue`: A dispatch queue on which all delegate methods will be invoked.
39 ///
40 /// If you employ an AVAssetResourceLoader delegate that loads media data for playback, you should set the value of your AVPlayer’s automaticallyWaitsToMinimizeStalling property to NO. Allowing the value of automaticallyWaitsToMinimizeStalling to remain YES — its default value — when an AVAssetResourceLoader delegate is used for the loading of media data can result in poor start-up times for playback and poor recovery from stalls, because the behaviors provided by AVPlayer when automaticallyWaitsToMinimizeStalling has a value of YES depend on predictions of the future availability of media data that that do not function as expected when data is loaded via a client-controlled means, using the AVAssetResourceLoader delegate interface.
41 ///
42 /// You can allow the value of automaticallyWaitsToMinimizeStalling to remain YES if you use an AVAssetResourceLoader delegate to manage content keys for FairPlay Streaming, to provide dynamically-generated master playlists for HTTP Live Streaming, or to respond to authentication challenges, but not to load media data for playback.
43 #[unsafe(method(setDelegate:queue:))]
44 #[unsafe(method_family = none)]
45 pub unsafe fn setDelegate_queue(
46 &self,
47 delegate: Option<&ProtocolObject<dyn AVAssetResourceLoaderDelegate>>,
48 delegate_queue: Option<&DispatchQueue>,
49 );
50
51 /// The receiver's delegate.
52 ///
53 /// The value of this property is an object conforming to the AVAssetResourceLoaderDelegate protocol. The delegate is set using the setDelegate:queue: method. The delegate is held using a zeroing-weak reference, so this property will have a value of nil after a delegate that was previously set has been deallocated.
54 #[unsafe(method(delegate))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn delegate(
57 &self,
58 ) -> Option<Retained<ProtocolObject<dyn AVAssetResourceLoaderDelegate>>>;
59
60 #[cfg(feature = "dispatch2")]
61 /// The dispatch queue on which all delegate methods will be invoked.
62 ///
63 /// The value of this property is a dispatch_queue_t. The queue is set using the setDelegate:queue: method.
64 #[unsafe(method(delegateQueue))]
65 #[unsafe(method_family = none)]
66 pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;
67 );
68}
69
70extern_protocol!(
71 /// The AVAssetResourceLoaderDelegate protocol defines methods that allow your code to handle resource loading requests coming from an AVURLAsset.
72 ///
73 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetresourceloaderdelegate?language=objc)
74 pub unsafe trait AVAssetResourceLoaderDelegate: NSObjectProtocol {
75 /// Invoked when assistance is required of the application to load a resource.
76 ///
77 /// Parameter `resourceLoader`: The instance of AVAssetResourceLoader for which the loading request is being made.
78 ///
79 /// Parameter `loadingRequest`: An instance of AVAssetResourceLoadingRequest that provides information about the requested resource.
80 ///
81 /// Returns: YES if the delegate can load the resource indicated by the AVAssetResourceLoadingRequest; otherwise NO.
82 ///
83 /// Delegates receive this message when assistance is required of the application to load a resource. For example, this method is invoked to load decryption keys that have been specified using custom URL schemes.
84 /// If the result is YES, the resource loader expects invocation, either subsequently or immediately, of either -[AVAssetResourceLoadingRequest finishLoading] or -[AVAssetResourceLoadingRequest finishLoadingWithError:]. If you intend to finish loading the resource after your handling of this message returns, you must retain the instance of AVAssetResourceLoadingRequest until after loading is finished.
85 /// If the result is NO, the resource loader treats the loading of the resource as having failed.
86 /// Note that if the delegate's implementation of -resourceLoader:shouldWaitForLoadingOfRequestedResource: returns YES without finishing the loading request immediately, it may be invoked again with another loading request before the prior request is finished; therefore in such cases the delegate should be prepared to manage multiple loading requests.
87 ///
88 /// If an AVURLAsset is added to an AVContentKeySession object and a delegate is set on its AVAssetResourceLoader, that delegate's resourceLoader:shouldWaitForLoadingOfRequestedResource: method must specify which custom URL requests should be handled as content keys. This is done by returning YES and passing either AVStreamingKeyDeliveryPersistentContentKeyType or AVStreamingKeyDeliveryContentKeyType into -[AVAssetResourceLoadingContentInformationRequest setContentType:] and then calling -[AVAssetResourceLoadingRequest finishLoading].
89 #[optional]
90 #[unsafe(method(resourceLoader:shouldWaitForLoadingOfRequestedResource:))]
91 #[unsafe(method_family = none)]
92 unsafe fn resourceLoader_shouldWaitForLoadingOfRequestedResource(
93 &self,
94 resource_loader: &AVAssetResourceLoader,
95 loading_request: &AVAssetResourceLoadingRequest,
96 ) -> bool;
97
98 /// Invoked when assistance is required of the application to renew a resource.
99 ///
100 /// Parameter `resourceLoader`: The instance of AVAssetResourceLoader for which the loading request is being made.
101 ///
102 /// Parameter `renewalRequest`: An instance of AVAssetResourceRenewalRequest that provides information about the requested resource.
103 ///
104 /// Returns: YES if the delegate can renew the resource indicated by the AVAssetResourceLoadingRequest; otherwise NO.
105 ///
106 /// Delegates receive this message when assistance is required of the application to renew a resource previously loaded by resourceLoader:shouldWaitForLoadingOfRequestedResource:. For example, this method is invoked to renew decryption keys that require renewal, as indicated in a response to a prior invocation of resourceLoader:shouldWaitForLoadingOfRequestedResource:.
107 /// If the result is YES, the resource loader expects invocation, either subsequently or immediately, of either -[AVAssetResourceRenewalRequest finishLoading] or -[AVAssetResourceRenewalRequest finishLoadingWithError:]. If you intend to finish loading the resource after your handling of this message returns, you must retain the instance of AVAssetResourceRenewalRequest until after loading is finished.
108 /// If the result is NO, the resource loader treats the loading of the resource as having failed.
109 /// Note that if the delegate's implementation of -resourceLoader:shouldWaitForRenewalOfRequestedResource: returns YES without finishing the loading request immediately, it may be invoked again with another loading request before the prior request is finished; therefore in such cases the delegate should be prepared to manage multiple loading requests.
110 ///
111 /// If an AVURLAsset is added to an AVContentKeySession object and a delegate is set on its AVAssetResourceLoader, that delegate's resourceLoader:shouldWaitForRenewalOfRequestedResource:renewalRequest method must specify which custom URL requests should be handled as content keys. This is done by returning YES and passing either AVStreamingKeyDeliveryPersistentContentKeyType or AVStreamingKeyDeliveryContentKeyType into -[AVAssetResourceLoadingContentInformationRequest setContentType:] and then calling -[AVAssetResourceLoadingRequest finishLoading].
112 #[optional]
113 #[unsafe(method(resourceLoader:shouldWaitForRenewalOfRequestedResource:))]
114 #[unsafe(method_family = none)]
115 unsafe fn resourceLoader_shouldWaitForRenewalOfRequestedResource(
116 &self,
117 resource_loader: &AVAssetResourceLoader,
118 renewal_request: &AVAssetResourceRenewalRequest,
119 ) -> bool;
120
121 /// Informs the delegate that a prior loading request has been cancelled.
122 ///
123 /// Parameter `loadingRequest`: The loading request that has been cancelled.
124 ///
125 /// Previously issued loading requests can be cancelled when data from the resource is no longer required or when a loading request is superseded by new requests for data from the same resource. For example, if to complete a seek operation it becomes necessary to load a range of bytes that's different from a range previously requested, the prior request may be cancelled while the delegate is still handling it.
126 #[optional]
127 #[unsafe(method(resourceLoader:didCancelLoadingRequest:))]
128 #[unsafe(method_family = none)]
129 unsafe fn resourceLoader_didCancelLoadingRequest(
130 &self,
131 resource_loader: &AVAssetResourceLoader,
132 loading_request: &AVAssetResourceLoadingRequest,
133 );
134
135 /// Invoked when assistance is required of the application to respond to an authentication challenge.
136 ///
137 /// Parameter `resourceLoader`: The instance of AVAssetResourceLoader asking for help with an authentication challenge.
138 ///
139 /// Parameter `authenticationChallenge`: An instance of NSURLAuthenticationChallenge.
140 ///
141 /// Delegates receive this message when assistance is required of the application to respond to an authentication challenge.
142 /// If the result is YES, the resource loader expects you to send an appropriate response, either subsequently or immediately, to the NSURLAuthenticationChallenge's sender, i.e. [authenticationChallenge sender], via use of one of the messages defined in the NSURLAuthenticationChallengeSender protocol (see NSAuthenticationChallenge.h). If you intend to respond to the authentication challenge after your handling of -resourceLoader:shouldWaitForResponseToAuthenticationChallenge: returns, you must retain the instance of NSURLAuthenticationChallenge until after your response has been made.
143 #[optional]
144 #[unsafe(method(resourceLoader:shouldWaitForResponseToAuthenticationChallenge:))]
145 #[unsafe(method_family = none)]
146 unsafe fn resourceLoader_shouldWaitForResponseToAuthenticationChallenge(
147 &self,
148 resource_loader: &AVAssetResourceLoader,
149 authentication_challenge: &NSURLAuthenticationChallenge,
150 ) -> bool;
151
152 /// Informs the delegate that a prior authentication challenge has been cancelled.
153 ///
154 /// Parameter `authenticationChallenge`: The authentication challenge that has been cancelled.
155 #[optional]
156 #[unsafe(method(resourceLoader:didCancelAuthenticationChallenge:))]
157 #[unsafe(method_family = none)]
158 unsafe fn resourceLoader_didCancelAuthenticationChallenge(
159 &self,
160 resource_loader: &AVAssetResourceLoader,
161 authentication_challenge: &NSURLAuthenticationChallenge,
162 );
163 }
164);
165
166extern_class!(
167 /// AVAssetResourceLoadingRequestor represents the originator of loading request
168 ///
169 ///
170 /// Information about the originator of a loading request, in order to decide whether or how to fulfill the request.
171 ///
172 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetresourceloadingrequestor?language=objc)
173 #[unsafe(super(NSObject))]
174 #[derive(Debug, PartialEq, Eq, Hash)]
175 pub struct AVAssetResourceLoadingRequestor;
176);
177
178extern_conformance!(
179 unsafe impl NSObjectProtocol for AVAssetResourceLoadingRequestor {}
180);
181
182impl AVAssetResourceLoadingRequestor {
183 extern_methods!(
184 #[unsafe(method(init))]
185 #[unsafe(method_family = init)]
186 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
187
188 #[unsafe(method(new))]
189 #[unsafe(method_family = new)]
190 pub unsafe fn new() -> Retained<Self>;
191
192 /// Whether the requestor provides expired session reports (see AVContentKeySession)
193 #[unsafe(method(providesExpiredSessionReports))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn providesExpiredSessionReports(&self) -> bool;
196 );
197}
198
199extern_class!(
200 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetresourceloadingrequest?language=objc)
201 #[unsafe(super(NSObject))]
202 #[derive(Debug, PartialEq, Eq, Hash)]
203 pub struct AVAssetResourceLoadingRequest;
204);
205
206extern_conformance!(
207 unsafe impl NSObjectProtocol for AVAssetResourceLoadingRequest {}
208);
209
210impl AVAssetResourceLoadingRequest {
211 extern_methods!(
212 #[unsafe(method(init))]
213 #[unsafe(method_family = init)]
214 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
215
216 #[unsafe(method(new))]
217 #[unsafe(method_family = new)]
218 pub unsafe fn new() -> Retained<Self>;
219
220 /// An NSURLRequest for the requested resource.
221 #[unsafe(method(request))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn request(&self) -> Retained<NSURLRequest>;
224
225 /// Indicates whether loading of the resource has been finished.
226 ///
227 /// The value of this property becomes YES only in response to an invocation of either -finishLoading or -finishLoadingWithError:.
228 #[unsafe(method(isFinished))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn isFinished(&self) -> bool;
231
232 /// Indicates whether the request has been cancelled.
233 ///
234 /// The value of this property becomes YES when the resource loader cancels the loading of a request, just prior to sending the message -resourceLoader:didCancelLoadingRequest: to its delegate.
235 #[unsafe(method(isCancelled))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn isCancelled(&self) -> bool;
238
239 /// An instance of AVAssetResourceLoadingContentInformationRequest that you must populate with information about the resource before responding to any AVAssetResourceLoadingDataRequests for the resource. The value of this property will be nil if no such information is being requested.
240 #[unsafe(method(contentInformationRequest))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn contentInformationRequest(
243 &self,
244 ) -> Option<Retained<AVAssetResourceLoadingContentInformationRequest>>;
245
246 /// An instance of AVAssetResourceLoadingDataRequest that indicates the range of resource data that's being requested. If an AVAssetResourceLoadingContentInformationRequest has been provided, you must set its properties appropriately before responding to any AVAssetResourceLoadingDataRequests. The value of this property will be nil if no data is being requested.
247 #[unsafe(method(dataRequest))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn dataRequest(&self) -> Option<Retained<AVAssetResourceLoadingDataRequest>>;
250
251 /// Set the value of this property to an instance of NSURLResponse indicating a response to the loading request. If no response is needed, leave the value of this property set to nil.
252 #[unsafe(method(response))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn response(&self) -> Option<Retained<NSURLResponse>>;
255
256 /// Setter for [`response`][Self::response].
257 #[unsafe(method(setResponse:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn setResponse(&self, response: Option<&NSURLResponse>);
260
261 /// Set the value of this property to an instance of NSURLRequest indicating a redirection of the loading request to another URL. If no redirection is needed, leave the value of this property set to nil.
262 ///
263 /// AVAssetResourceLoader supports redirects to HTTP URLs only. Redirects to other URLs will result in a loading failure.
264 #[unsafe(method(redirect))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn redirect(&self) -> Option<Retained<NSURLRequest>>;
267
268 /// Setter for [`redirect`][Self::redirect].
269 #[unsafe(method(setRedirect:))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn setRedirect(&self, redirect: Option<&NSURLRequest>);
272
273 /// The AVAssetResourceLoadingRequestor that made this request
274 #[unsafe(method(requestor))]
275 #[unsafe(method_family = none)]
276 pub unsafe fn requestor(&self) -> Retained<AVAssetResourceLoadingRequestor>;
277
278 /// Causes the receiver to treat the processing of the request as complete.
279 ///
280 /// If a dataRequest is present, and the resource does not contain the full extent of the data that has been requested according to the values of the requestedOffset and requestedLength properties of the dataRequest, or if requestsAllDataToEndOfResource has a value of YES, -finishLoading may be invoked after providing as much of the requested data as the resource contains. If the contentInformationRequest property is not nil and specifies a non-empty allowedContentTypes array, the contentInformationRequest's contentType property must be set to a value within allowedContentTypes. Otherwise, this method will throw an exception.
281 #[unsafe(method(finishLoading))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn finishLoading(&self);
284
285 /// Causes the receiver to treat the request as having failed.
286 ///
287 /// Parameter `error`: An instance of NSError indicating the reason for failure.
288 #[unsafe(method(finishLoadingWithError:))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn finishLoadingWithError(&self, error: Option<&NSError>);
291 );
292}
293
294extern_class!(
295 /// AVAssetResourceRenewalRequest encapsulates information about a resource request issued by a resource loader for the purpose of renewing a request previously issued.
296 ///
297 ///
298 /// When an AVURLAsset needs to renew a resource (because contentInformationRequest.renewalDate has been set on a previous loading request), it asks its AVAssetResourceLoader object to assist. The resource loader encapsulates the request information by creating an instance of this object, which it then hands to its delegate for processing. The delegate uses the information in this object to perform the request and report on the success or failure of the operation.
299 ///
300 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetresourcerenewalrequest?language=objc)
301 #[unsafe(super(AVAssetResourceLoadingRequest, NSObject))]
302 #[derive(Debug, PartialEq, Eq, Hash)]
303 pub struct AVAssetResourceRenewalRequest;
304);
305
306extern_conformance!(
307 unsafe impl NSObjectProtocol for AVAssetResourceRenewalRequest {}
308);
309
310impl AVAssetResourceRenewalRequest {
311 extern_methods!();
312}
313
314/// Methods declared on superclass `AVAssetResourceLoadingRequest`.
315impl AVAssetResourceRenewalRequest {
316 extern_methods!(
317 #[unsafe(method(init))]
318 #[unsafe(method_family = init)]
319 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
320
321 #[unsafe(method(new))]
322 #[unsafe(method_family = new)]
323 pub unsafe fn new() -> Retained<Self>;
324 );
325}
326
327extern_class!(
328 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetresourceloadingcontentinformationrequest?language=objc)
329 #[unsafe(super(NSObject))]
330 #[derive(Debug, PartialEq, Eq, Hash)]
331 pub struct AVAssetResourceLoadingContentInformationRequest;
332);
333
334extern_conformance!(
335 unsafe impl NSObjectProtocol for AVAssetResourceLoadingContentInformationRequest {}
336);
337
338impl AVAssetResourceLoadingContentInformationRequest {
339 extern_methods!(
340 #[unsafe(method(init))]
341 #[unsafe(method_family = init)]
342 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
343
344 #[unsafe(method(new))]
345 #[unsafe(method_family = new)]
346 pub unsafe fn new() -> Retained<Self>;
347
348 /// A UTI that indicates the type of data contained by the requested resource.
349 ///
350 /// Before you finish loading an AVAssetResourceLoadingRequest, if its contentInformationRequest is not nil, you should set the value of this property to a UTI indicating the type of data contained by the requested resource.
351 #[unsafe(method(contentType))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn contentType(&self) -> Option<Retained<NSString>>;
354
355 /// Setter for [`contentType`][Self::contentType].
356 #[unsafe(method(setContentType:))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn setContentType(&self, content_type: Option<&NSString>);
359
360 /// An array showing the types of data which will be accepted as a valid response for the requested resource.
361 ///
362 /// If an AVAssetResourceLoadingRequest's contentInformationRequest is not nil, ensure that the value assigned to the contentType property is in this array. Otherwise, calling -finishLoading on the associated request will result in an exception.
363 #[unsafe(method(allowedContentTypes))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn allowedContentTypes(&self) -> Option<Retained<NSArray<NSString>>>;
366
367 /// Indicates the length of the requested resource, in bytes.
368 ///
369 /// Before you finish loading an AVAssetResourceLoadingRequest, if its contentInformationRequest is not nil, you should set the value of this property to the number of bytes contained by the requested resource.
370 #[unsafe(method(contentLength))]
371 #[unsafe(method_family = none)]
372 pub unsafe fn contentLength(&self) -> c_longlong;
373
374 /// Setter for [`contentLength`][Self::contentLength].
375 #[unsafe(method(setContentLength:))]
376 #[unsafe(method_family = none)]
377 pub unsafe fn setContentLength(&self, content_length: c_longlong);
378
379 /// Indicates whether random access to arbitrary ranges of bytes of the resource is supported. Such support also allows portions of the resource to be requested more than once.
380 ///
381 /// Before you finish loading an AVAssetResourceLoadingRequest, if its contentInformationRequest is not nil, you should set the value of this property to YES if you support random access to arbitrary ranges of bytes of the resource. If you do not set this property to YES for resources that must be loaded incrementally, loading of the resource may fail. Such resources include anything that contains media data.
382 #[unsafe(method(isByteRangeAccessSupported))]
383 #[unsafe(method_family = none)]
384 pub unsafe fn isByteRangeAccessSupported(&self) -> bool;
385
386 /// Setter for [`isByteRangeAccessSupported`][Self::isByteRangeAccessSupported].
387 #[unsafe(method(setByteRangeAccessSupported:))]
388 #[unsafe(method_family = none)]
389 pub unsafe fn setByteRangeAccessSupported(&self, byte_range_access_supported: bool);
390
391 /// For resources that expire, the date at which a new AVAssetResourceLoadingRequest will be issued for a renewal of this resource, if the media system still requires it.
392 ///
393 /// Before you finish loading an AVAssetResourceLoadingRequest, if the resource is prone to expiry you should set the value of this property to the date at which a renewal should be triggered. This value should be set sufficiently early enough to allow an AVAssetResourceRenewalRequest, delivered to your delegate via -resourceLoader:shouldWaitForRenewalOfRequestedResource:, to finish before the actual expiry time. Otherwise media playback may fail.
394 #[unsafe(method(renewalDate))]
395 #[unsafe(method_family = none)]
396 pub unsafe fn renewalDate(&self) -> Option<Retained<NSDate>>;
397
398 /// Setter for [`renewalDate`][Self::renewalDate].
399 #[unsafe(method(setRenewalDate:))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn setRenewalDate(&self, renewal_date: Option<&NSDate>);
402
403 /// Indicates whether asset data loading can expect data to be produced immediately.
404 ///
405 /// Before you finish loading an AVAssetResourceLoadingRequest, if its contentInformationRequest is not nil, you may set this property to YES to indicate that all asset data can be produced immediately, e.g., because the data is fully cached, or because the custom URL scheme ultimately refers to files on local storage. This allows significant data flow optimizations. For backward compatibility, this property defaults to NO.
406 #[unsafe(method(isEntireLengthAvailableOnDemand))]
407 #[unsafe(method_family = none)]
408 pub unsafe fn isEntireLengthAvailableOnDemand(&self) -> bool;
409
410 /// Setter for [`isEntireLengthAvailableOnDemand`][Self::isEntireLengthAvailableOnDemand].
411 #[unsafe(method(setEntireLengthAvailableOnDemand:))]
412 #[unsafe(method_family = none)]
413 pub unsafe fn setEntireLengthAvailableOnDemand(
414 &self,
415 entire_length_available_on_demand: bool,
416 );
417 );
418}
419
420extern_class!(
421 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetresourceloadingdatarequest?language=objc)
422 #[unsafe(super(NSObject))]
423 #[derive(Debug, PartialEq, Eq, Hash)]
424 pub struct AVAssetResourceLoadingDataRequest;
425);
426
427extern_conformance!(
428 unsafe impl NSObjectProtocol for AVAssetResourceLoadingDataRequest {}
429);
430
431impl AVAssetResourceLoadingDataRequest {
432 extern_methods!(
433 #[unsafe(method(init))]
434 #[unsafe(method_family = init)]
435 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
436
437 #[unsafe(method(new))]
438 #[unsafe(method_family = new)]
439 pub unsafe fn new() -> Retained<Self>;
440
441 /// The position within the resource of the first byte requested.
442 #[unsafe(method(requestedOffset))]
443 #[unsafe(method_family = none)]
444 pub unsafe fn requestedOffset(&self) -> c_longlong;
445
446 /// The length of the data requested.
447 ///
448 /// Note that requestsAllDataToEndOfResource will be set to YES when the entire remaining length of the resource is being requested from requestedOffset to the end of the resource. This can occur even when the content length has not yet been reported by you via a prior finished loading request.
449 /// When requestsAllDataToEndOfResource has a value of YES, you should disregard the value of requestedLength and incrementally provide as much data starting from the requestedOffset as the resource contains, until you have provided all of the available data successfully and invoked -finishLoading, until you have encountered a failure and invoked -finishLoadingWithError:, or until you have received -resourceLoader:didCancelLoadingRequest: for the AVAssetResourceLoadingRequest from which the AVAssetResourceLoadingDataRequest was obtained.
450 /// When requestsAllDataToEndOfResource is YES and the content length has not yet been provided by you via a prior finished loading request, the value of requestedLength is set to NSIntegerMax. Starting in macOS 10.11 and iOS 9.0, in 32-bit applications requestedLength is also set to NSIntegerMax when all of the remaining resource data is being requested and the known length of the remaining data exceeds NSIntegerMax.
451 #[unsafe(method(requestedLength))]
452 #[unsafe(method_family = none)]
453 pub unsafe fn requestedLength(&self) -> NSInteger;
454
455 /// Specifies that the entire remaining length of the resource from requestedOffset to the end of the resource is being requested.
456 ///
457 /// When requestsAllDataToEndOfResource has a value of YES, you should disregard the value of requestedLength and incrementally provide as much data starting from the requestedOffset as the resource contains, until you have provided all of the available data successfully and invoked -finishLoading, until you have encountered a failure and invoked -finishLoadingWithError:, or until you have received -resourceLoader:didCancelLoadingRequest: for the AVAssetResourceLoadingRequest from which the AVAssetResourceLoadingDataRequest was obtained.
458 #[unsafe(method(requestsAllDataToEndOfResource))]
459 #[unsafe(method_family = none)]
460 pub unsafe fn requestsAllDataToEndOfResource(&self) -> bool;
461
462 /// The position within the resource of the next byte within the resource following the bytes that have already been provided via prior invocations of -respondWithData.
463 #[unsafe(method(currentOffset))]
464 #[unsafe(method_family = none)]
465 pub unsafe fn currentOffset(&self) -> c_longlong;
466
467 /// Provides data to the receiver.
468 ///
469 /// Parameter `data`: An instance of NSData containing some or all of the requested bytes.
470 ///
471 /// May be invoked multiple times on the same instance of AVAssetResourceLoadingDataRequest to provide the full range of requested data incrementally. Upon each invocation, the value of currentOffset will be updated to accord with the amount of data provided.
472 /// The instance of NSData that you provide may be retained for use in parsing or other processing for an indefinite period of time after this method returns. For this reason, if you are providing an instance of NSMutableData, you should avoid mutating it further after sharing its contents. If you are managing your own memory pool for I/O and resource loading, consider using -[NSData initWithBytesNoCopy:length:deallocator:] in order to receive notification of the earliest opportunity for safe recycling of the underlying memory.
473 #[unsafe(method(respondWithData:))]
474 #[unsafe(method_family = none)]
475 pub unsafe fn respondWithData(&self, data: &NSData);
476 );
477}
478
479/// AVAssetResourceLoaderContentKeySupport.
480impl AVAssetResourceLoader {
481 extern_methods!(
482 /// When YES, eligible content keys will be loaded as eagerly as possible, potentially handled by the delegate. Setting to YES may result in network activity.
483 ///
484 /// Any work done as a result of setting this property will be performed asynchronously.
485 #[unsafe(method(preloadsEligibleContentKeys))]
486 #[unsafe(method_family = none)]
487 pub unsafe fn preloadsEligibleContentKeys(&self) -> bool;
488
489 /// Setter for [`preloadsEligibleContentKeys`][Self::preloadsEligibleContentKeys].
490 #[unsafe(method(setPreloadsEligibleContentKeys:))]
491 #[unsafe(method_family = none)]
492 pub unsafe fn setPreloadsEligibleContentKeys(&self, preloads_eligible_content_keys: bool);
493 );
494}
495
496/// AVAssetResourceLoaderCommonMediaClientDataSupport.
497impl AVAssetResourceLoader {
498 extern_methods!(
499 #[unsafe(method(sendsCommonMediaClientDataAsHTTPHeaders))]
500 #[unsafe(method_family = none)]
501 pub unsafe fn sendsCommonMediaClientDataAsHTTPHeaders(&self) -> bool;
502
503 /// Setter for [`sendsCommonMediaClientDataAsHTTPHeaders`][Self::sendsCommonMediaClientDataAsHTTPHeaders].
504 #[unsafe(method(setSendsCommonMediaClientDataAsHTTPHeaders:))]
505 #[unsafe(method_family = none)]
506 pub unsafe fn setSendsCommonMediaClientDataAsHTTPHeaders(
507 &self,
508 sends_common_media_client_data_as_http_headers: bool,
509 );
510 );
511}
512
513/// AVAssetResourceLoadingRequestContentKeyRequestSupport.
514impl AVAssetResourceLoadingRequest {
515 extern_methods!(
516 /// Obtains a streaming content key request for a specific combination of application and content.
517 ///
518 /// Parameter `appIdentifier`: An opaque identifier for the application. The value of this identifier depends on the particular system used to provide the decryption key.
519 ///
520 /// Parameter `contentIdentifier`: An opaque identifier for the content. The value of this identifier depends on the particular system used to provide the decryption key.
521 ///
522 /// Parameter `options`: Additional information necessary to obtain the key, or nil if none.
523 ///
524 /// Parameter `outError`: If obtaining the streaming content key request fails, will be set to an instance of NSError describing the failure.
525 ///
526 /// Returns: The key request data that must be transmitted to the key vendor to obtain the content key.
527 #[deprecated = "Use -[AVContentKeyRequest makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:] instead"]
528 #[unsafe(method(streamingContentKeyRequestDataForApp:contentIdentifier:options:error:_))]
529 #[unsafe(method_family = none)]
530 pub unsafe fn streamingContentKeyRequestDataForApp_contentIdentifier_options_error(
531 &self,
532 app_identifier: &NSData,
533 content_identifier: &NSData,
534 options: Option<&NSDictionary<NSString, AnyObject>>,
535 ) -> Result<Retained<NSData>, Retained<NSError>>;
536
537 /// Obtains a persistable content key from a context.
538 ///
539 /// Parameter `keyVendorResponse`: The response returned from the key vendor as a result of a request generated from streamingContentKeyRequestDataForApp:contentIdentifier:options:error:.
540 ///
541 /// Parameter `options`: Additional information necessary to obtain the persistable content key, or nil if none.
542 ///
543 /// Parameter `outError`: If obtaining the persistable content key fails, will be set to an instance of NSError describing the failure.
544 ///
545 /// Returns: The persistable content key data that may be stored offline to answer future loading requests of the same content key.
546 ///
547 /// The data returned from this method may be used to immediately satisfy an AVAssetResourceLoadingDataRequest, as well as any subsequent requests for the same key url. The value of AVAssetResourceLoadingContentInformationRequest.contentType must be set to AVStreamingKeyDeliveryPersistentContentKeyType when responding with data created with this method.
548 #[deprecated = "Use -[AVPersistableContentKeyRequest persistableContentKeyFromKeyVendorResponse:options:error:] instead"]
549 #[unsafe(method(persistentContentKeyFromKeyVendorResponse:options:error:_))]
550 #[unsafe(method_family = none)]
551 pub unsafe fn persistentContentKeyFromKeyVendorResponse_options_error(
552 &self,
553 key_vendor_response: &NSData,
554 options: Option<&NSDictionary<NSString, AnyObject>>,
555 ) -> Result<Retained<NSData>, Retained<NSError>>;
556 );
557}
558
559extern "C" {
560 /// Specifies whether the content key request should require a persistable key to be returned from the key vendor. Value should be a NSNumber created with +[NSNumber numberWithBool:].
561 ///
562 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avassetresourceloadingrequeststreamingcontentkeyrequestrequirespersistentkey?language=objc)
563 pub static AVAssetResourceLoadingRequestStreamingContentKeyRequestRequiresPersistentKey:
564 &'static NSString;
565}
566
567/// AVAssetResourceLoadingRequestDeprecated.
568impl AVAssetResourceLoadingRequest {
569 extern_methods!(
570 /// Causes the receiver to finish loading a resource that a delegate has previously assumed responsibility for loading by returning YES as the result of -resourceLoader:shouldWaitForLoadingOfRequestedResource:.
571 ///
572 /// Parameter `response`: The NSURLResponse for the NSURLRequest of the receiver. Should be nil if no response is required.
573 ///
574 /// Parameter `data`: An instance of NSData containing the data of the resource. Should be nil if no such data is available.
575 ///
576 /// Parameter `redirect`: An instance of NSURLRequest indicating a redirect of the loading request. Should be nil if no redirect is needed.
577 ///
578 /// This method is deprecated. Use the following methods instead.
579 /// -[AVAssetResourceLoadingRequest setResponse:] to set the response property,
580 /// -[AVAssetResourceLoadingRequest setRedirect:] to set the redirect property,
581 /// -[AVAssetResourceLoadingDataRequest respondWithData:] to provide data, and
582 /// -[AVAssetResourceLoadingRequest finishLoading] to indicate that loading is finished.
583 #[deprecated = "Use -[AVAssetResourceLoadingRequest setResponse:], -[AVAssetResourceLoadingRequest setRedirect:], -[AVAssetResourceLoadingDataRequest respondWithData:], -[AVAssetResourceLoadingRequest finishLoading]"]
584 #[unsafe(method(finishLoadingWithResponse:data:redirect:))]
585 #[unsafe(method_family = none)]
586 pub unsafe fn finishLoadingWithResponse_data_redirect(
587 &self,
588 response: Option<&NSURLResponse>,
589 data: Option<&NSData>,
590 redirect: Option<&NSURLRequest>,
591 );
592 );
593}