An object containing zero or more media samples of a uniform media type.
- Core Media
CMSample is a Core Foundation object 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 pipeline. A
CMSample can contain:
CMBlockof one or more media samples, or
CVImage, a reference to the format description for the stream of
CMSample, size and timing information for each of the contained media samples, and both buffer-level and sample-level attachments.
A sample buffer can contain both sample-level and buffer-level attachments. Sample-level attachments are associated with each individual sample (frame) in a buffer and include information such as timestamps and video frame dependencies. You can read and write sample-level attachments using the
CMSample function. Buffer-level attachments provide information about the buffer as a whole, such as playback speed and actions to be performed upon consuming the buffer. You can read and write buffer-level attachments using the APIs described in CMAttachment and the keys listed under Sample Buffer Attachment Keys.
It is possible for a
CMSample 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
CMSample with that information and insert them into queues early, and attach (or fill) the
CMBlock of media data later, when the data becomes ready. To this end,
CMSample have the concept of data-readiness, which can be tested, set, forced to become ready “now" and so on. It is also possible for a
CMSample to contain nothing but a special buffer-level attachment that describes a media stream event (for example, "discontinuity: drain and reset decoder before processing the next
CMSample”). Such a special attachment can also be attached to regular
CMSample (i.e. that contain media sample data), and if so, the event it describes is defined to occur after the samples in that