Function

CMSampleBufferCallBlockForEachSample

Calls a block for every individual sample in a sample buffer.

Declaration

OSStatus CMSampleBufferCallBlockForEachSample(CMSampleBufferRef sbuf, OSStatus (^handler)(CMSampleBufferRef sampleBuffer, CMItemCount index));

Parameters

sbuf

CMSampleBuffer that may contain multiple samples.

handler

Block to be called for each individual sample.

Discussion

Temporary sample buffers will be created for individual samples, referring to the sample data and containing its timing, size and attachments. The block may retain these sample buffers if desired. If the block returns an error, iteration will stop immediately and the error will be returned.

If there are no sample sizes in the provided sample buffer, kCMSampleBufferError_CannotSubdivide will be returned. This will happen, for example, if the samples in the buffer are non-contiguous (e.g. non-interleaved audio, where the channel values for a single sample are scattered through the buffer).

See Also

Modifying Sample Buffers

CMSampleBufferSetDataFailed

Marks a sample buffer's data as "failed", to indicate that the data will not become ready.

CMSampleBufferSetInvalidateHandler

Sets the sample buffer's invalidation handler block, which is called during CMSampleBufferInvalidate.

CMSampleBufferCallForEachSample

Calls a function for every individual sample in a sample buffer.

CMSampleBufferCopySampleBufferForRange

Creates a CMSampleBuffer containing a range of samples from an existing CMSampleBuffer.

CMSampleBufferInvalidate

Makes the sample buffer invalid, calling any installed invalidation callback.

CMSampleBufferMakeDataReady

Makes a CMSampleBuffer data ready, by calling the client's CMSampleBufferMakeDataReadyCallback.

CMSampleBufferSetDataBuffer

Associates a CMSampleBuffer with its CMBlockBuffer of media data.

CMSampleBufferSetDataReady

Marks a CMSampleBuffer's data as "ready".

CMSampleBufferSetInvalidateCallback

Sets the CMSampleBuffer’s invalidation callback, which is called during CMSampleBufferInvalidate.

CMSampleBufferSetOutputPresentationTimeStamp

Sets an output presentation timestamp to be used in place of a calculated value.

CMSampleBufferTrackDataReadiness

Associates a CMSampleBuffer's data readiness with another CMSampleBuffer's data readiness.