Class

AVSampleCursor

An object that provides information about the current media sample at its current position.

Declaration

class AVSampleCursor : NSObject

Overview

An AVSampleCursor instance is always positioned at a specific media sample in a sequence of samples as defined by a higher-level construct, such as an AVAssetTrack. It can be moved to a new position in that sequence either backwards or forwards, either in decode order or in presentation order. Movement can be requested according to a count of samples or according to a delta in time.

An AVSampleCursor can provide information about the media sample at its current position, such as its duration, its presentation and decode timestamps, whether it can be decoded independently of other media samples, its offset and length in its storage container, and whether the track signals that the sample is intended to be loaded with other contiguous media samples in a “chunk”.

AVSampleCursor instances can be compared by position within the sample sequence. They can also be used synchronously to perform I/O in order to load media data of one or more media samples into memory.

Topics

Traversing Samples

func step(byDecodeTime: CMTime, wasPinned: UnsafeMutablePointer<ObjCBool>?) -> CMTime

Moves the cursor by a given delta time on the decode timeline.

func step(byPresentationTime: CMTime, wasPinned: UnsafeMutablePointer<ObjCBool>?) -> CMTime

Moves the cursor by a given delta time on the presentation timeline.

func stepInDecodeOrder(byCount: Int64) -> Int64

Moves the cursor a given number of samples in decode order.

func stepInPresentationOrder(byCount: Int64) -> Int64

Moves the cursor a given number of samples in presentation order.

Getting Samples

func maySamplesWithEarlierDecodeTimeStampsHavePresentationTimeStamps(laterThan: AVSampleCursor) -> Bool

Determines whether a sample earlier in decode order can have a presentation timestamp later than that of the specified sample cursor.

func maySamplesWithLaterDecodeTimeStampsHavePresentationTimeStamps(earlierThan: AVSampleCursor) -> Bool

Determines whether a sample later in decode order can have a presentation timestamp earlier than that of the specified sample cursor.

var samplesRequiredForDecoderRefresh: Int

The number of samples prior to the current sample, in decode order, the decoder requires in order to achieve a coherent output at the current decode time.

Getting Timestamps

var decodeTimeStamp: CMTime

The decode timestamp of the sample at the current position of the cursor.

var presentationTimeStamp: CMTime

The presentation timestamp of the sample at the current position of the cursor.

Comparing Sample Cursors

func comparePositionInDecodeOrder(withPositionOf: AVSampleCursor) -> ComparisonResult

Compares the relative positions of two sample cursors and returns their relative positions.

Getting Current Sample Information

var currentChunkInfo: AVSampleCursorChunkInfo

A value that provides information about the chunk of samples to which the current sample belongs.

struct AVSampleCursorChunkInfo

A value that provides information about a chunk of media samples.

var currentChunkStorageRange: AVSampleCursorStorageRange

The sample range in the current chunk storage URL that is intended to be loaded together with the current sample as a chunk.

struct AVSampleCursorStorageRange

A struct indicating the offset and length of storage occupied by a media sample or its chunk.

var currentChunkStorageURL: URL?

The URL of the storage container of the current sample and other samples that are intended to be loaded in the same operation as a chunk.

var currentSampleDependencyInfo: AVSampleCursorDependencyInfo

The dependency information that describes relationships between a media sample and other media samples in the same sample sequence.

struct AVSampleCursorDependencyInfo

A value for describing dependencies between a media sample and other media samples in the same sample sequence.

var currentSampleDuration: CMTime

The presentation duration of the sample at the receiver's current position.

var currentSampleIndexInChunk: Int64

The index of the current sample within the chunk to which it belongs.

var currentSampleStorageRange: AVSampleCursorStorageRange

The offset and length of the current sample in the current chunk storage URL.

var currentSampleSyncInfo: AVSampleCursorSyncInfo

The synchronization information for the current sample for consideration when resynchronizing a decoder.

struct AVSampleCursorSyncInfo

A value that describes attributes of a media sample for consideration when resynchronizing a decoder.

func copyCurrentSampleFormatDescription() -> CMFormatDescription

Returns the format description of the sample at the receiver's current position.

Relationships

Inherits From

See Also

Sample Buffer Manipulation

class AVSampleBufferRequest

An object that describes a sample buffer creation request.

class AVSampleBufferGenerator

An object used to create sample buffer opaque objects.

protocol AVQueuedSampleBufferRendering

Methods you can implement to enqueue sample buffers for presentation.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software