Function

CMSampleBufferCreateReady

Creates a CMSampleBuffer.

Declaration

OSStatus CMSampleBufferCreateReady(CFAllocatorRef allocator, CMBlockBufferRef dataBuffer, CMFormatDescriptionRef formatDescription, CMItemCount numSamples, CMItemCount numSampleTimingEntries, const CMSampleTimingInfo *sampleTimingArray, CMItemCount numSampleSizeEntries, const size_t *sampleSizeArray, CMSampleBufferRef  _Nullable *sampleBufferOut);

Parameters

allocator

The allocator to use for allocating the CMSampleBuffer object. Pass kCFAllocatorDefault to use the default allocator.

dataBuffer

CMBlockBuffer that already contains the media data. Must not be NULL.

formatDescription

A description of the media data's format. Can be NULL.

numSamples

Number of samples in the CMSampleBuffer. Can be 0.

numSampleTimingEntries

Number of entries in sampleTimingArray. Must be 0, 1, or numSamples.

sampleTimingArray

Array of CMSampleTimingInfo structs, one struct per sample. If all samples have the same duration and are in presentation order, you can pass a single CMSampleTimingInfo struct with duration set to the duration of one sample, presentationTimeStamp set to the presentation time of the numerically earliest sample, and decodeTimeStamp set to kCMTimeInvalid. The behavior is undefined if samples in a CMSampleBuffer (or even in multiple buffers in the same stream) have the same presentationTimeStamp. Can be NULL.

numSampleSizeEntries

Number of entries in sampleSizeArray. Must be 0, 1, or numSamples.

sampleSizeArray

Array of size entries, one entry per sample. If all samples have the same size, you can pass a single size entry containing the size of one sample. Can be NULL.

Must be NULL if the samples are non-contiguous in the buffer (eg. non-interleaved audio, where the channel values for a single sample are scattered through the buffer).

sBufOut

Returned newly created CMSampleBuffer.

Discussion

This function is identical to CMSampleBufferCreate except that dataReady is always true, and so no makeDataReadyCallback or refcon needs to be passed.

See Also

Creating Sample Buffers

CMSampleBufferCreate

Creates a CMSampleBuffer.

CMSampleBufferCreateForImageBuffer

Creates a CMSampleBuffer that contains a CVImageBuffer instead of a CMBlockBuffer.

CMSampleBufferCreateReadyWithImageBuffer

Creates a CMSampleBuffer that contains a CVImageBuffer instead of a CMBlockBuffer.

CMAudioSampleBufferCreateWithPacketDescriptions

Creates a CMSampleBuffer containing the audio for a given packetDescription instead of the sizing and timing information.

CMAudioSampleBufferCreateReadyWithPacketDescriptions

Creates a CMSampleBuffer containing the audio for a given packetDescription instead of the sizing and timing information.

CMSampleBufferCreateCopy

Creates a copy of a CMSampleBuffer

CMSampleBufferCreateCopyWithNewTiming

Creates a copy of CMSampleBuffer with new timing information.