AVAssetResourceLoadingDataRequest Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 7.0 and later.
Declared in
AVAssetResourceLoader.h

Overview

Use the AVAssetResourceLoadingDataRequest class to request data from a resource referenced by an AVAssetResourceLoadingRequest instance.

The AVAssetResourceLoaderDelegate uses the AVAssetResourceLoadingDataRequest class to do the actual data reading, and its methods will be invoked, as necessary, to acquire data for the AVAssetResourceLoadingRequest instance.

When the resource loading delegate, which implements the AVAssetResourceLoaderDelegate protocol, receives an instance of AVAssetResourceLoadingRequest as the second parameter of the delegate’s resourceLoader:shouldWaitForLoadingOfRequestedResource: method, it has the option of accepting responsibility for loading the referenced resource. If it accepts that responsibility, by returning YES, it must check whether the dataRequest property of the AVAssetResourceLoadingRequest instance is not nil. If it is not nil, the resource loading delegate is informed of the range of bytes within the resource that are required by the underlying media system. In response, the data is provided by one or more invocations of respondWithData: as required to provide the requested data. The data can be provided in increments determined by the resource loading delegate according to convenience or efficiency.

When the AVAssetResourceLoadingRequest method finishLoading is invoked, the data request is considered fully satisfied. If the entire range of bytes requested has not yet been provided, the underlying media system assumes that the resource's length is limited to the provided content.

Tasks

Providing Data to a Request

Properties

currentOffset

The position within the resource of the next byte. (read-only)

@property(nonatomic, readonly) long long currentOffset
Discussion

When incrementally loading data you should begin loading at this offset, returning the data by invoking the respondWithData: method. Bytes previous to this value have already been provided.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVAssetResourceLoader.h

requestedLength

The length, in bytes, of the data requested. (read-only)

@property(nonatomic, readonly) NSInteger requestedLength
Discussion

If the content length of the resource is unknown, the sum of the requestedLength and requestedOffset properties may be greater than the actual content length. When this situation occurs, an application must attempt to provide as much of the requested data beginning at the requestedOffset property as the resource contains. The application must then invoke either the AVAssetResourceLoadingRequest instance’s finishLoading method upon success, or the finishLoadingWithError: method if an error is encountered during the loading.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVAssetResourceLoader.h

requestedOffset

The position within the resource of the first byte requested. (read-only)

@property(nonatomic, readonly) long long requestedOffset
Discussion

When all of the requested bytes that can be provided have been loaded—including the possible contentInformationRequest data in the AVAssetResourceLoadingRequest instance that contains the receiver—the delegate should respond by invoking finishLoading.

If the requestedOffset value is beyond the content length of the resource, the AVAssetResourceLoadingRequest instance is sent a finishLoading message without any prior invocations of respondWithData:.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVAssetResourceLoader.h

Instance Methods

respondWithData:

Provides data to the loading request.

- (void)respondWithData:(NSData *)data
Parameters
data

An instance of NSData containing some or all of the requested bytes.

Discussion

This method 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 the currentOffset property is updated to match the amount of data provided.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVAssetResourceLoader.h