Inherits from AVPlayerItemOutput
Declared in AVPlayerItemHapDXTOutput.h
AVPlayerItemHapDXTOutput.m

Overview

This class is the main interface for decoding hap video from AVFoundation. You create an instance of this class and add it to an AVPlayerItem as you would with any other AVPlayerItemOutput subclass. You retrieve frame data from this output by calling one of the allocFrame* methods, depending on what you want to decode and whether your want it to be decoded asynchronously or not. While it was written to be used in the AVPlayer* ecosystem, instances of this class can also be created outside AVPlayers and used to decode arbitrary frames of video (for more info, see initWithHapAssetTrack:).

Properties

destRGBPixelFormat

If outputAsRGB is YES, this is the RGB pixel format that the data should be decoded into. Accepted values are kCVPixelFormatType_32RGBA and kCVPixelFormatType_32BGRA (default is kCVPixelFormatType_32RGBA)

@property (assign, readwrite) OSType destRGBPixelFormat

Declared In

AVPlayerItemHapDXTOutput.h

outputAsRGB

NO by default. If you set this to YES, the output will provide RGB pixel data in any HapDecoderFrame instances it returns (in addition to DXT data). RGB-based decoding for this codec is fairly slow/inefficient, and should be avoided if possible in favor of DXT/OpenGL-based display techniques. If you’re using a custom HapDecoderFrameAllocBlock to allocate HapDecoderFrame instances, make sure your block also allocates memory for RGB-based pixel data if appropriate!

@property (assign, readwrite) BOOL outputAsRGB

Declared In

AVPlayerItemHapDXTOutput.h

Instance Methods

allocFrameClosestToTime:

This method returns a retained frame as close to the passed time as possible. May return nil if no frame is immediately available- this method returns immediately, but processing is asynchronous (it fetches and decodes the frame on another thread). Because of this, it generally returns the frame for the last time you requested (the previous frame) and is generally more appropriate for simple/low-impact playback.

- (HapDecoderFrame *)allocFrameClosestToTime:(CMTime)n

Parameters

n

The time at which you would like to retrieve a frame.

Return Value

This method returns immediately, but if a frame isn’t available right now it’ll return nil. If it doesn’t return nil, it returns a retained (caller must release the returned object) instance of HapDecoderFrame which has been decoded (the raw DXT data is available).

Declared In

AVPlayerItemHapDXTOutput.h

allocFrameForHapSampleBuffer:

This method immediately decodes the passed sample. Like allocFrameForTime:, this method is synchronous- you can pass it any arbitrary CMSampleBufferRef containing a frame of hap data and it will return the decoded information. This method is useful if you want to decode a CMSampleBufferRef that you obtained from another source (an AVAssetReader, for example).

- (HapDecoderFrame *)allocFrameForHapSampleBuffer:(CMSampleBufferRef)n

Parameters

n

The sample buffer containing a frame of Hap data that you would like to decode.

Return Value

The decoded frame.

Declared In

AVPlayerItemHapDXTOutput.h

allocFrameForTime:

This method immediately fetches and decodes the sample for the provided time. Unlike allocFrameClosestToTime: (which is asynchronous), this method will take a bit longer to return because it fetches and decodes the raw samples before returning (synchronous), and is generally more appropriate for situations when you immediately need the specified sample (transcoding, thumbnails, that sort of thing).

- (HapDecoderFrame *)allocFrameForTime:(CMTime)n

Parameters

n

The time at which you would like to retrieve a frame.

Return Value

The decoded frame.

Declared In

AVPlayerItemHapDXTOutput.h

initWithHapAssetTrack:

Under normal circumstances, AVPlayerItems created with the standard alloc/init calls are inoperative without an AVPlayer. However, if you create an instance of this class using this method, it will be able to decode frames outside the AVPlayer ecosystem. This is how AVAssetReaderHapTrackOutput works: it has a local instance of AVPlayerItemHapDXTOutput that it uses to retrieve and decode Hap frames (without the use of an AVPlayer).

- (id)initWithHapAssetTrack:(AVAssetTrack *)n

Parameters

n

an AVAssetTrack instance that contains video data compressed using the Hap codec.

Declared In

AVPlayerItemHapDXTOutput.h

setAllocFrameBlock:

Use this if you want to provide a custom block that allocates and configures a HapDecoderFrame instance- if you want to pool resources or manually provide the memory into which the decoded data will be written, you need to provide a custom alloc block.

- (void)setAllocFrameBlock:(HapDecoderFrameAllocBlock)n

Parameters

n

This HapDecoderFrameAllocBlock must be threadsafe, and should avoid retaining the instance of this class that “owns” the block to prevent a retain loop.

Declared In

AVPlayerItemHapDXTOutput.h

setPostDecodeBlock:

The post decode block is executed immediately after the hap frame has been decoded into DXT data. if you want to upload your DXT data to a GL texture on a GCD-spawned thread, this is a good place to implement it.

- (void)setPostDecodeBlock:(AVFHapDXTPostDecodeBlock)n

Parameters

n

This AVFHapDXTPostDecodeBlock must be threadsafe, and should avoid retaining the instance of this class that “owns” the block to prevent a retain loop.

Declared In

AVPlayerItemHapDXTOutput.h