<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMReadySampleBuffer",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "s:9CoreMedia19CMReadySampleBufferV"
  },
  "title" : "CMReadySampleBuffer"
}
-->

# CMReadySampleBuffer

Buffer carrying readily available samples of media data.

```
struct CMReadySampleBuffer<Content> where Content : CMSampleBuffer.Content
```

## Topics

### Initializers

[`init(CMReadySampleBuffer<some CMSampleBuffer.Content>)`](/documentation/CoreMedia/CMReadySampleBuffer/init(_:)-35rzo)

Convert a ready sample buffer to dynamic content.

[`init?(CMReadySampleBuffer<CMSampleBuffer.DynamicContent>)`](/documentation/CoreMedia/CMReadySampleBuffer/init(_:)-3rj25)

Converts dynamic sample buffer to a marker sample buffer.

[`init?(CMReadySampleBuffer<CMSampleBuffer.DynamicContent>)`](/documentation/CoreMedia/CMReadySampleBuffer/init(_:)-3tjyq)

Converts dynamic sample buffer to a sample buffer containing pixel buffer.

[`init?(CMReadySampleBuffer<CMSampleBuffer.DynamicContent>)`](/documentation/CoreMedia/CMReadySampleBuffer/init(_:)-4j97d)

Converts dynamic sample buffer to a sample buffer containing data buffer.

[`init?(CMReadySampleBuffer<CMSampleBuffer.DynamicContent>)`](/documentation/CoreMedia/CMReadySampleBuffer/init(_:)-6uyu8)

Converts dynamic sample buffer to a sample buffer containing tagged buffers.

[`init(audioDataBuffer: Content, formatDescription: CMAudioFormatDescription, sampleCount: Int, presentationTimeStamp: CMTime)`](/documentation/CoreMedia/CMReadySampleBuffer/init(audioDataBuffer:formatDescription:sampleCount:presentationTimeStamp:))

Creates a sample buffer carrying audio media data.

[`init(compressedAudioDataBuffer: Content, formatDescription: CMAudioFormatDescription, presentationTimeStamp: CMTime, packetDescriptions: [AudioStreamPacketDescription])`](/documentation/CoreMedia/CMReadySampleBuffer/init(compressedAudioDataBuffer:formatDescription:presentationTimeStamp:packetDescriptions:))

Creates a sample buffer carrying compressed audio media data.

[`init(dataBuffer: Content, formatDescription: CMFormatDescription, sampleProperties: CMSampleBuffer.SamplePropertiesCollection)`](/documentation/CoreMedia/CMReadySampleBuffer/init(dataBuffer:formatDescription:sampleProperties:))

Creates a sample buffer with media data.

[`init(markerAt: CMTime, duration: CMTime)`](/documentation/CoreMedia/CMReadySampleBuffer/init(markerAt:duration:))

Creates a marker-only sample buffer with no payload and no format description.

[`init(pixelBuffer: Content, formatDescription: CMVideoFormatDescription?, presentationTimeStamp: CMTime, duration: CMTime)`](/documentation/CoreMedia/CMReadySampleBuffer/init(pixelBuffer:formatDescription:presentationTimeStamp:duration:))

Creates a sample buffer carrying image buffer.

[`init(sampleDataReference: Content, formatDescription: CMFormatDescription, sampleProperties: CMSampleBuffer.SamplePropertiesCollection)`](/documentation/CoreMedia/CMReadySampleBuffer/init(sampleDataReference:formatDescription:sampleProperties:))

Creates a sample buffer with references to sample data.

[`init(taggedBuffers: Content, formatDescription: CMTaggedBufferGroupFormatDescription?, presentationTimeStamp: CMTime, duration: CMTime)`](/documentation/CoreMedia/CMReadySampleBuffer/init(taggedBuffers:formatDescription:presentationTimeStamp:duration:))

Creates a sample buffer carrying tagged buffers.

[`init(unsafeBuffer: sending CMSampleBuffer)`](/documentation/CoreMedia/CMReadySampleBuffer/init(unsafeBuffer:))

Create a ready sample buffer with dynamic content from an existing sample buffer.

[`init(unsafeMarkerOnlySampleBuffer: sending CMSampleBuffer)`](/documentation/CoreMedia/CMReadySampleBuffer/init(unsafeMarkerOnlySampleBuffer:))

Create a ready sample buffer with marker content from an existing sample buffer.

[`init(unsafeSampleDataReferenceBuffer: sending CMSampleBuffer)`](/documentation/CoreMedia/CMReadySampleBuffer/init(unsafeSampleDataReferenceBuffer:))

Create a ready sample buffer with data reference content from an existing sample buffer.

[`init(unsafeWithDataBuffer: sending CMSampleBuffer)`](/documentation/CoreMedia/CMReadySampleBuffer/init(unsafeWithDataBuffer:))

Creates a ready sample buffer with data buffer content from an existing sample buffer.

[`init(unsafeWithPixelBuffer: sending CMSampleBuffer)`](/documentation/CoreMedia/CMReadySampleBuffer/init(unsafeWithPixelBuffer:))

Creates a ready sample buffer with pixel buffer content from an existing sample buffer.

[`init(unsafeWithTaggedBuffers: sending CMSampleBuffer)`](/documentation/CoreMedia/CMReadySampleBuffer/init(unsafeWithTaggedBuffers:))

Create a ready sample buffer with tagged buffers content from an existing sample buffer.

### Instance Properties

[`var attachments: CMReadySampleBuffer<Content>.Attachments`](/documentation/CoreMedia/CMReadySampleBuffer/attachments-swift.property)

[`var audioStreamPacketDescriptions: [AudioStreamPacketDescription]?`](/documentation/CoreMedia/CMReadySampleBuffer/audioStreamPacketDescriptions)

[`var content: CMSampleDataReference`](/documentation/CoreMedia/CMReadySampleBuffer/content-12bds)

Payload containing the samples.

[`var content: CMSampleBuffer.DynamicContent`](/documentation/CoreMedia/CMReadySampleBuffer/content-14qb7)

Payload containing the samples.

[`var content: CVReadOnlyPixelBuffer`](/documentation/CoreMedia/CMReadySampleBuffer/content-4peot)

Payload containing the samples.

[`var content: Array<CMTaggedDynamicBuffer>`](/documentation/CoreMedia/CMReadySampleBuffer/content-5fko2)

Payload containing the samples.

[`var content: CMReadOnlyDataBlockBuffer`](/documentation/CoreMedia/CMReadySampleBuffer/content-6ihvr)

Payload containing the samples.

[`var contentType: CMSampleBuffer.ContentType`](/documentation/CoreMedia/CMReadySampleBuffer/contentType)

Type of the content carried by this sample buffer

[`var decodeTimeStamp: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/decodeTimeStamp)

Numerically earliest sample decode timestamp in the sample buffer.

[`var duration: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/duration-2ssr4)

The unmodified sum of the durations of all samples in the sample buffer.

[`var duration: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/duration-54778)

Duration of the sample buffer.

[`var duration: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/duration-94fnq)

Duration of the sample buffer.

[`var duration: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/duration-9lx3g)

Duration of the sample buffer.

[`var formatDescription: CMFormatDescription`](/documentation/CoreMedia/CMReadySampleBuffer/formatDescription-6rp0o)

The format description of the samples in the sample buffer.

[`var formatDescription: CMFormatDescription?`](/documentation/CoreMedia/CMReadySampleBuffer/formatDescription-9i48t)

The format description of the samples in the sample buffer.

[`var markerTimeStamp: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/markerTimeStamp)

Presentation timestamp of the sample buffer.

[`var outputDecodeTimeStamp: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/outputDecodeTimeStamp)

The output decode timestamp of the sample buffer.

[`var outputDuration: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/outputDuration)

The output duration of the sample buffer.

[`var outputPresentationTimeStamp: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/outputPresentationTimeStamp)

The output presentation timestamp of the sample buffer.

[`var outputSampleTimings: CMSampleBuffer.TimingPerSample?`](/documentation/CoreMedia/CMReadySampleBuffer/outputSampleTimings)

Output timing information of each sample in the sample buffer.

[`var presentationTimeStamp: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/presentationTimeStamp-19vwq)

Presentation timestamp of the sample buffer.

[`var presentationTimeStamp: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/presentationTimeStamp-266ka)

Presentation timestamp of the sample buffer.

[`var presentationTimeStamp: CMTime`](/documentation/CoreMedia/CMReadySampleBuffer/presentationTimeStamp-7ea7z)

Numerically earliest sample presentation timestamp in the sample buffer.

[`var sampleAttachments: CMSampleBuffer.SampleAttachments`](/documentation/CoreMedia/CMReadySampleBuffer/sampleAttachments-8g6nm)

Attachments for the sample in this buffer.

[`var sampleAttachments: CMSampleBuffer.SampleAttachments`](/documentation/CoreMedia/CMReadySampleBuffer/sampleAttachments-9g3d5)

Attachments for the sample in this buffer.

[`var sampleCount: Int`](/documentation/CoreMedia/CMReadySampleBuffer/sampleCount)

Number of samples in the sample buffer.

[`var sampleProperties: CMSampleBuffer.SamplePropertiesCollection`](/documentation/CoreMedia/CMReadySampleBuffer/sampleProperties)

Information about the samples in the sample buffer.

[`var totalSampleSize: Int`](/documentation/CoreMedia/CMReadySampleBuffer/totalSampleSize)

Total size in bytes of all samples in the sample buffer.

### Instance Methods

[`func attach(contentKey: AVContentKey) throws`](/documentation/CoreMedia/CMReadySampleBuffer/attach(contentKey:))

Attaches an AVContentKey to a CMReadySampleBuffer for the purpose of content decryption.
The client is expected to attach AVContentKeys to CMReadySampleBuffers that have been created by the client for enqueueing with AVSampleBufferDisplayLayer or AVSampleBufferAudioRenderer, for which the AVContentKeySpecifier matches indications of suitability that are available to the client according to the content key system that’s in use.

[`func copyPCMData(fromRange: Range<Int>, into: UnsafeMutablePointer<AudioBufferList>) throws`](/documentation/CoreMedia/CMReadySampleBuffer/copyPCMData(fromRange:into:))

Copies PCM audio data from the sample buffer into a pre-allocated `AudioBufferList`.

[`func splitSamples() -> [CMReadySampleBuffer<Content>]`](/documentation/CoreMedia/CMReadySampleBuffer/splitSamples())

Split sample buffer into a smaller representation, ideally carrying a single sample per resulting sample buffer.

[`func withUnsafeSampleBuffer<R>((CMSampleBuffer) throws -> sending R) rethrows -> sending R`](/documentation/CoreMedia/CMReadySampleBuffer/withUnsafeSampleBuffer(_:))

Access the underlying CMSampleBuffer instance.

### Type Aliases

[`typealias Attachments`](/documentation/CoreMedia/CMReadySampleBuffer/Attachments-swift.typealias)

## Relationships

### Conforms To

[`Copyable`](/documentation/Swift/Copyable)

[`Escapable`](/documentation/Swift/Escapable)

[`SupportedPayload`](/documentation/AVFoundation/AVAssetReaderOutput/SupportedPayload)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)