CMAudioSampleBufferCreateWithPacketDescriptions(allocator:dataBuffer:dataReady:makeDataReadyCallback:refcon:formatDescription:sampleCount:presentationTimeStamp:packetDescriptions:sampleBufferOut:)
Creates a sample buffer with packet descriptions and a callback to make the data ready for use.
Declaration
func CMAudioSampleBufferCreateWithPacketDescriptions(allocator: CFAllocator?, dataBuffer: CMBlockBuffer?, dataReady: Bool, makeDataReadyCallback: CMSampleBufferMakeDataReadyCallback?, refcon makeDataReadyRefcon: UnsafeMutableRawPointer?, formatDescription: CMFormatDescription, sampleCount numSamples: CMItemCount, presentationTimeStamp: CMTime, packetDescriptions: UnsafePointer<AudioStreamPacketDescription>?, sampleBufferOut: UnsafeMutablePointer<CMSampleBuffer?>) -> OSStatusParameters
- allocator:
The allocator to use for allocating the
CMSampleBufferobject. PasskCFAllocatorDefaultto use the default allocator. - dataBuffer:
CMBlockBufferfor the media data. This can beNULL, aCMBlockBufferwith no backing memory, aCMBlockBufferwith backing memory but no data yet, or aCMBlockBufferthat already contains the media data. IfCMBlockBuffercontains the media data,dataReadyshould betrue. - dataReady:
Indicates whether or not the
BlockBufferalready contains the media data. - makeDataReadyCallback:
Callback that
CMSampleBufferMakeDataReadyshould call to make the data ready. Can beNULL. - makeDataReadyRefcon:
The reference constant, Cmsamplebuffermakedataready(_:), that this function should pass to the callback.
- formatDescription:
A description of the media data’s format. Can’t be
NULL. - numSamples:
Number of samples in the
CMSampleBuffer. Must not be 0. - presentationTimeStamp:
Timestamp of the first sample in the buffer. Must be a numeric
CMTime. - packetDescriptions:
Array of
packetDescriptions, one for each ofnumSamples. May beNULLif the samples are known to have a constant number of frames per packet and a constant size. - sampleBufferOut:
On output, points to the newly created
CMSampleBuffer.
Return Value
A result code. See Sample Buffer Error Codes.
Discussion
Provides an optimization over CMSampleBufferCreate() when the caller already has packetDescriptions for the audio data. This routine uses the packetDescriptions to create the sizing and timing arrays required to make the sample buffer if necessary.
Topics
Callbacks
See Also
Creating Sample Buffers
CMSampleBufferCreateReady(allocator:dataBuffer:formatDescription:sampleCount:sampleTimingEntryCount:sampleTimingArray:sampleSizeEntryCount:sampleSizeArray:sampleBufferOut:)CMSampleBufferCreateReadyWithImageBuffer(allocator:imageBuffer:formatDescription:sampleTiming:sampleBufferOut:)CMAudioSampleBufferCreateReadyWithPacketDescriptions(allocator:dataBuffer:formatDescription:sampleCount:presentationTimeStamp:packetDescriptions:sampleBufferOut:)CMSampleBufferCreateWithMakeDataReadyHandler(_:_:_:_:_:_:_:_:_:_:_:)CMSampleBufferCreateForImageBufferWithMakeDataReadyHandler(_:_:_:_:_:_:_:)CMAudioSampleBufferCreateWithPacketDescriptionsAndMakeDataReadyHandler(_:_:_:_:_:_:_:_:_:)CMSampleBufferCreate(allocator:dataBuffer:dataReady:makeDataReadyCallback:refcon:formatDescription:sampleCount:sampleTimingEntryCount:sampleTimingArray:sampleSizeEntryCount:sampleSizeArray:sampleBufferOut:)CMSampleBufferCreateForImageBuffer(allocator:imageBuffer:dataReady:makeDataReadyCallback:refcon:formatDescription:sampleTiming:sampleBufferOut:)