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 |
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.
- 15 properties
- property DataIsReady as boolean
- property DecodeTimeStamp as CMTimeMBS
- property Duration as CMTimeMBS
- property FormatDescription as CMFormatDescriptionMBS
- property Handle as Integer
- property ImageBuffer as CVImageBufferMBS
- property IsValid as boolean
- property Lasterror as Integer
- property NumberOfSamples as Integer
- property OutputDecodeTimeStamp as CMTimeMBS
- property OutputDuration as CMTimeMBS
- property OutputPresentationTimeStamp as CMTimeMBS
- property PresentationTimeStamp as CMTimeMBS
- property Text as String
- property TotalSampleSize as UInt64
- 7 methods
- method Constructor Private
- method Copy as CMSampleBufferMBS
- method CopySampleBufferForRange(pos as Integer, len as Integer) as CMSampleBufferMBS
- method Invalidate
- method MakeDataReady
- method SampleSize(index as Integer) as UInt64
- method SetDataReady
- 15 constants
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:
- AVAssetReaderOutputMBS.NextSampleBuffer as CMSampleBufferMBS
- AVAssetWriterInputMBS.appendSampleBuffer(sampleBuffer as CMSampleBufferMBS) as boolean
- AVCaptureStillImageOutputMBS.jpegStillImageNSDataRepresentation(jpegSampleBuffer as CMSampleBufferMBS) as memoryblock
- AVSampleBufferDisplayLayerMBS.enqueueSampleBuffer(sampleBuffer as CMSampleBufferMBS)
Some events using this class:
- AVFoundationMBS.captureOutputDidDropSampleBuffer(captureOutput as AVCaptureOutputMBS, OutputSampleBuffer as CMSampleBufferMBS, connection as AVCaptureConnectionMBS)
- AVFoundationMBS.captureOutputDidOutputSampleBuffer(captureOutput as AVCaptureOutputMBS, OutputSampleBuffer as CMSampleBufferMBS, connection as AVCaptureConnectionMBS, features as variant)
- AVFoundationMBS.captureStillImageAsynchronouslyCompleted(CaptureStillImageOutput as AVCaptureStillImageOutputMBS, prepareJpegStillImage as boolean, tag as Variant, error as NSErrorMBS, imageDataSampleBuffer as CMSampleBufferMBS, JpegStillImage as memoryblock)
- AVFoundationMBS.legibleOutputDidOutputAttributedStrings(output as AVPlayerItemLegibleOutputMBS, strings() as Variant, nativeSamples() as CMSampleBufferMBS, itemTime as CMTimeMBS)
- AVFoundationMBS.requestMediaDataWhenReadyOnQueueProgress(assetWriterInput as AVAssetWriterInputMBS, assetReaderOutput as AVAssetReaderOutputMBS, convertedByteCount as Int64, LastBuffer as CMSampleBufferMBS, tag as Variant)
Some examples using this class:
- /AVFoundation/Extract video frames
- /AVFoundation/Live Barcode Detection
- /AVFoundation/Live Barcode Detection iOS/Live Barcode Detection iOS
- /AVFoundation/Live Barcode Detection with Vision/Live Barcode Detection with Vision
- /AVFoundation/Live picture processing
- /AVFoundation/Screen Input
- /AVFoundation/Still Photos
- /AVFoundation/Transcode
Blog Entries
- MBS Xojo Plugins, version 24.4pr6
- MBS Xojo Plugins, version 18.4pr3
- AVCaptureVideoDataOutput improvements
- MBS Xojo / Real Studio Plugins, version 15.4pr2
- MBS Xojo / Real Studio Plugins, version 14.5pr2
Release notes
- Version 24.4
- Changed captureStillImageAsynchronouslyCompleted event in AVFoundationMBS class, so it prepares CMSampleBufferMBS with Picture when set PrepareCIImage, PrepareNSImage and PrepareJPEGData is set in AVCaptureVideoDataOutputMBS class.
- Version 18.4
- Changed CMSampleBufferMBS to cache CVImageBufferMBS.
The items on this page are in the following plugins: MBS AVFoundation Plugin.
CMFormatDescriptionMBS - CMTimeMappingMBS