Platforms to show: All Mac Windows Linux Cross-Platform

CMSampleBufferMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
CMSampleBuffers are CF objects containing zero or more compressed (or uncompressed) samples of a particular media type (audio, video, muxed, etc), that are used to move media sample data through the media system.

A CMSampleBuffer can contain a CMBlockBuffer of one or more media samples or a CVImageBuffer, a reference to the format description for the stream of CMSampleBuffers, size and timing information for each of the contained media samples, and both buffer-level and sample-level attachments. The buffer-level attachments of a CMSampleBuffer are distinct from the attachments of its contained CMBlockBuffer. An example of a sample-level attachment is an annotation about video frame dependencies (eg. "droppable", "other frames depend on me", "I depend on other frames", etc). Each sample (video frame) in the CMSampleBuffer would need its own attachment in this case. Another sample-level attachment example is SMPTE timecode acquired during capture. To get and set a CMSampleBuffer's buffer-level attachments, use the APIs in in CMAttachmentBearer.h (CMGetAttachment et al).
It is possible for a CMSampleBuffer to describe samples it does not yet contain. For example, some media services may have access to sample size, timing and format information before the data is read. Such services may create CMSampleBuffers with that information and insert them into queues early, and attach (or fill) the CMBlockBuffers of media data later, when the data becomes ready. To this end, CMSampleBuffers have the concept of data-readiness, which can be tested, set, forced to become ready "now", etc. It is also possible for a CMSampleBuffer to contain nothing but a special buffer-level attachment that describes a media stream event (eg. "discontinuity: drain and reset decoder before processing the next CMSampleBuffer"). Such a special attachment can also be attached to regular CMSampleBuffers (ie. that contain media sample data), and if so, the event it describes is defined to occur after the samples in that CMSampleBuffer.

The MBS Plugin implements a subset of what's available. If you need more, please do not hesitate to contact us.
This is an abstract class. You can't create an instance, but you can get one from various plugin functions.

Error Codes

Constant Value Description
kAllocationFailed -12730 An allocation failed.
kAlreadyHasDataBuffer -12732 Attempt was made to set a dataBuffer on a CMSampleBuffer that already has one.
kArrayTooSmall -12737 Output array was not large enough for the array being requested.
kBufferHasNoSampleSizes -12735 Attempt to get sample size information when there was none.
kBufferHasNoSampleTimingInfo -12736 Attempt to get sample timing information when there was none.
kBufferNotReady -12733 Buffer could not be made ready.
kCannotSubdivide -12739 Sample buffer does not contain sample sizes. This can happen when the samples in the buffer are non-contiguous (eg. non-interleaved audio, where the channel values for a single sample are scattered through the buffer).
kInvalidated -12744 the sample buffer was invalidated.
kInvalidEntryCount -12738 Timing info or size array entry count was not 0, 1, or numSamples.
kInvalidMediaFormat -12743 The format of the given media does not match the given format description (eg. a format description paired with a CVImageBuffer that fails CMVideoFormatDescriptionMatchesImageBuffer).
kInvalidMediaTypeForOperation -12741 The media type specified by a format description is not valid for the given operation (eg. a CMSampleBuffer with a non-audio format description passed to GetAudioStreamPacketDescriptions).
kInvalidSampleData -12742 Buffer contains bad data. Only returned by CMSampleBuffer functions that inspect its sample data.
kRequiredParameterMissing -12731 Nil or 0 was passed for a required parameter.
kSampleIndexOutOfRange -12734 Sample index was not between 0 and numSamples-1, inclusive.
kSampleTimingInfoInvalid -12740 Buffer unexpectedly contains a non-numeric sample timing info.

This class has no sub classes.

Some methods using this class:

Some events using this class:

Some examples using this class:

Blog Entries

Release notes


The items on this page are in the following plugins: MBS AVFoundation Plugin.


CMFormatDescriptionMBS   -   CMTimeMappingMBS


The biggest plugin in space...