Class: AVAssetReader

Inherits:
NSObject show all

Overview

You use an AVAssetReader object to obtain media data of an asset, whether the asset is file-based or represents an assemblage of media data from multiple sources (as with an AVComposition object).

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (AVAsset) asset (readonly)

The asset with which the receiver was initialized. (read-only) Concrete instances of AVAssetReader with specific AVAssetTrack instances must obtain those tracks from the asset returned by this property.

Returns:

- (NSError) error (readonly)

Describes the error that occurred if the status is AVAssetReaderStatusFailed. (read-only) This property is thread safe.The value of this property describes what caused the reader to no longer be able to read its asset. If the reader’s status is not AVAssetReaderStatusFailed, the value of this property is nil.

Returns:

- (Array) outputs (readonly)

The outputs from which clients of reader can read media data. (read-only) The array contains concrete instances of AVAssetReaderOutput associated with the reader.

Returns:

- (AVAssetReaderStatus) status (readonly)

The status of the reading of sample buffers from the asset. (read-only) This property is thread safe. For possible values, see “Reader Status Constants.”The value of this property indicates whether reading is in progress, has completed successfully, has been canceled, or has failed. You should check the value of this property copyNextSampleBuffer (AVAssetReaderOutput) returns NULL to determine why no more samples could be read.

Returns:

  • (AVAssetReaderStatus)

- (CMTimeRange) timeRange

The time range of the asset that should be read. The intersection of the value of this property and CMTimeRangeMake(kCMTimeZero, asset.duration) determines the time range of the asset from which media data will be read.The default value is CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity). You cannot change the value of this property after reading has started.

Returns:

  • (CMTimeRange)

Class Method Details

+ (AVAssetReader) assetReaderWithAsset(asset, error:outError)

Returns an asset reader for reading media data from a specified asset.

Parameters:

  • asset (AVAsset)

    The asset from which media data is to be read.

  • outError (Pointer)

    If initialization of the reader fails, upon return contains an error that describes the problem.

Returns:

  • (AVAssetReader)

    An asset reader, initialized for reading media data from asset.

Instance Method Details

- (Object) addOutput(output)

Adds a given output to the receiver. Outputs are created with a reference to one or more AVAssetTrack objects. Adding an output to an asset reader indicates to the reader that it should source from those tracks. The tracks must be owned by the asset returned by the reader’s asset property.You cannot add an output after reading has started.

Parameters:

Returns:

- (Boolean) canAddOutput(output)

Returns a Boolean value that indicates whether a given output can be added to the receiver. You cannot add an output that reads from a track of an asset other than the asset used to initialize the receiver.

Parameters:

Returns:

  • (Boolean)

    YES if output can be added to the receiver, otherwise NO.

- (Object) cancelReading

Cancels any background work and prevents the receiver’s outputs from reading more samples. If you want to stop reading samples from the receiver before reaching the end of its time range, you should call this method to stop any background read ahead operations that the may have been in progress.

Returns:

- (Object) initWithAsset(asset, error:outError)

Initializes an asset reader for reading media data from a specified asset.

Parameters:

  • asset (AVAsset)

    The asset from which media data is to be read.

  • outError (Pointer)

    If initialization of the reader fails, upon return contains an error that describes the problem.

Returns:

  • (Object)

    An asset reader, initialized for reading media data from asset.

- (Boolean) startReading

Prepares the receiver for obtaining sample buffers from the asset. This method validates the entire collection of settings for outputs for tracks, for audio mixdown, and for video composition and initiates reading of all outputs.status signals the terminal state of the asset reader, and if a failure occurs, error describes the failure.

Returns:

  • (Boolean)

    YES if the reader is able to start reading, otherwise NO.