AVPlayerItemVideoOutput Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 6.0 and later.
Declared in
AVPlayerItemOutput.h
Related sample code

Overview

The AVPlayerItemVideoOutput lets you coordinate the output of content associated with a Core Video pixel buffer.

Tasks

Initializing the Player Item Video Output

Accessing the Delegate

Notifying the Delegate of Changes

Getting Pixel Buffer Data

Properties

delegate

The delegate for the video output object. (read-only)

@property (nonatomic, readonly) id<AVPlayerItemOutputPullDelegate>delegate
Availability
  • Available in iOS 6.0 and later.
Declared In
AVPlayerItemOutput.h

delegateQueue

The dispatch queue on which to call delegate methods. (read-only)

@property (nonatomic, readonly) dispatch_queue_t delegateQueue
Availability
  • Available in iOS 6.0 and later.
Declared In
AVPlayerItemOutput.h

Instance Methods

copyPixelBufferForItemTime:itemTimeForDisplay:

Acquires and returns an image that is appropriate to display at the specified time.

- (CVPixelBufferRef)copyPixelBufferForItemTime:(CMTime)itemTime itemTimeForDisplay:(CMTime *)outItemTimeForDisplay
Parameters
itemTime

The time at which you want to retrieve the image from the item.

outItemTimeForDisplay

The time by which you intend to use the returned pixel buffer. You may specify nil for this parameter if you do not have a specific deadline.

Return Value

A pixel buffer containing the image data to display or nil if nothing should be displayed at the specified time. The caller is responsible for calling CVBufferRelease on the returned data when it is no longer needed.

Discussion

Typically, you call this method in response to a CVDisplayLink callback or a CADisplayLink delegate method call when the hasNewPixelBufferForItemTime: method also returns YES.

After calling this method, the video output object marks the pixel buffer data as having been acquired. This causes the hasNewPixelBufferForItemTime: method to return NO unless newer data becomes available.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVPlayerItemOutput.h

hasNewPixelBufferForItemTime:

Returns a Boolean value indicating whether video output is available for the specified item time.

- (BOOL)hasNewPixelBufferForItemTime:(CMTime)itemTime
Parameters
itemTime

The item time to query. The time value is relative to the AVPlayerItem object with which the receiver is associated.

Return Value

YES if there is available video output that has not been previously acquired or NO if there is not.

Discussion

This method returns YES if the video data at the specified time has not yet been acquired or is different from the video that was acquired previously. If you require multiple objects to acquire video output from the same AVPlayerItem object, you should create separate AVPlayerItemVideoOutput objects for each.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVPlayerItemOutput.h

initWithPixelBufferAttributes:

Initializes and returns a video output object using the specified pixel buffer attributes.

- (id)initWithPixelBufferAttributes:(NSDictionary *)pixelBufferAttributes
Parameters
pixelBufferAttributes

The pixel buffer attributes required for video output. For a list of pixel buffer attributes you can include in this dictionary, see the CVPixelBuffer.h header file in the Core Video framework.

Return Value

An initialized video output object.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVPlayerItemOutput.h

requestNotificationOfMediaDataChangeWithAdvanceInterval:

Informs the receiver that the video out put client is entering a quiescent state.

- (void)requestNotificationOfMediaDataChangeWithAdvanceInterval:(NSTimeInterval)interval
Parameters
interval

The amount of time to wait before notifying the delegate of the media change.

Discussion

Call this method before you suspend your use of a CVDisplayLinkRef type or a CADisplayLink object. After the interval expires, the video output object notifies its delegate that it should resume the display link. If the interval value you specify is large, the delegate is notified as soon as possible rather than waiting.

Do not call this method repeatedly to force the delegate to be notified for each sample.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVPlayerItemOutput.h

setDelegate:queue:

Sets the delegate and dispatch queue for the receiver.

- (void)setDelegate:(id<AVPlayerItemOutputPullDelegate>)delegate queue:(dispatch_queue_t)delegateQueue
Parameters
delegate

The delegate object for the receiver. You may specify nil for this parameter.

delegateQueue

The dispatch queue on which to call delegate methods. If you specify nil for this parameter, the video output object calls the delegate on the dispatch queue for your app’s main thread.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVPlayerItemOutput.h