Function

CMAudioSampleBufferCreateWithPacketDescriptions

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

Declaration

OSStatus CMAudioSampleBufferCreateWithPacketDescriptions(CFAllocatorRef allocator, CMBlockBufferRef dataBuffer, Boolean dataReady, CMSampleBufferMakeDataReadyCallback makeDataReadyCallback, void *makeDataReadyRefcon, CMFormatDescriptionRef formatDescription, CMItemCount numSamples, CMTime presentationTimeStamp, const AudioStreamPacketDescription *packetDescriptions, CMSampleBufferRef  _Nullable *sampleBufferOut);

Parameters

allocator

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

dataBuffer

CMBlockBuffer for the media data. This can be NULL, a CMBlockBuffer with no backing memory, a CMBlockBuffer with backing memory but no data yet, or a CMBlockBuffer that already contains the media data. If CMBlockBuffer contains the media data, dataReady should be true.

dataReady

Indicates whether or not the BlockBuffer already contains the media data.

makeDataReadyCallback

Callback that CMSampleBufferMakeDataReady should call to make the data ready. Can be NULL.

makeDataReadyRefcon

The reference constant,CMSampleBufferMakeDataReady, that this function should pass to the callback.

formatDescription

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

numSamples

Number of samples in the CMSampleBuffer. Must not be 0.

sbufPTS

Timestamp of the first sample in the buffer. Must be a numeric CMTime.

packetDescriptions

Array of packetDescriptions, one for each of numSamples. May be NULL if the samples are known to have a constant number of frames per packet and a constant size.

sBufOut

On output, points to the newly created CMSampleBuffer.

Return Value

A result code. See Result Codes.

Discussion

Provides an optimization over CMSampleBufferCreate() when the caller already has packetDescriptions for the audio data. This routine will use the packetDescriptions to create the sizing and timing arrays required to make the sample buffer if necessary.

See Also

Creating Sample Buffers

CMSampleBufferCreate

Creates a CMSampleBuffer.

CMSampleBufferCreateReady

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.

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.