<!--
{
  "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/CMReadOnlyDataBlockBuffer",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "s:9CoreMedia25CMReadOnlyDataBlockBufferV"
  },
  "title" : "CMReadOnlyDataBlockBuffer"
}
-->

# CMReadOnlyDataBlockBuffer

A block buffer that provides read-only access to the a range of bytes.

```
struct CMReadOnlyDataBlockBuffer
```

## Overview

Block buffer provides a contiguous range of data offsets (from 0 to [`count`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/count)) across a possibly non-contiguous
range of bytes. The byte range may contain memory blocks and buffer references. The bytes held by this buffer can
not be modified. However, the composition of the byte range can be changed by appending other memory blocks or
buffer references.

## Topics

### Structures

[`struct BlockRegion`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/BlockRegion)

A contiguous region of memory within a block buffer.

### Operators

[`static func + (CMReadOnlyDataBlockBuffer, CMReadOnlyDataBlockBuffer) -> CMReadOnlyDataBlockBuffer`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/+(_:_:)-58lg4)

Creates a new block buffer by concatenating two block buffers.

[`static func + (CMReadOnlyDataBlockBuffer, consuming CMMutableDataBlockBuffer) -> CMReadOnlyDataBlockBuffer`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/+(_:_:)-92jke)

Creates a new block buffer by concatenating two block buffers.

[`static func += (inout CMReadOnlyDataBlockBuffer, CMReadOnlyDataBlockBuffer)`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/+=(_:_:)-67kx8)

Appends the bytes of another block buffer without copying.

[`static func += (inout CMReadOnlyDataBlockBuffer, consuming CMMutableDataBlockBuffer)`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/+=(_:_:)-7fm8e)

Appends the bytes of another block buffer without copying.

### Initializers

[`init(consuming CMMutableDataBlockBuffer)`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/init(_:)-5fdm2)

Create a readonly block buffer from existing block buffer.

[`init(DispatchData)`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/init(_:)-80jym)

[`init(Data)`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/init(_:)-w7h3)

Create a new block buffer referencing bytes from Data.

[`init(subBlockCapacity: Int)`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/init(subBlockCapacity:))

Create empty block buffer.

[`init(unsafeBlockBuffer: sending CMBlockBuffer)`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/init(unsafeBlockBuffer:))

Create a readonly block buffer from an existing block buffer.

### Instance Properties

[`var attachments: CMReadOnlyDataBlockBuffer.Attachments`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/attachments-swift.property)

[`var isContiguous: Bool`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/isContiguous)

Determine whether the block buffer is contiguous.

### Instance Methods

[`func append(referenceOf: CMReadOnlyDataBlockBuffer, optimizeDepth: Bool)`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/append(referenceOf:optimizeDepth:)-2x1ta)

Append a reference to a range of another block buffer.

[`func append(referenceOf: consuming CMMutableDataBlockBuffer, optimizeDepth: Bool)`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/append(referenceOf:optimizeDepth:)-5g65c)

Append a reference to a range of another block buffer.

[`func withContiguousStorageIfAvailable<R>((UnsafeRawBufferPointer) throws -> sending R) rethrows -> sending R?`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/withContiguousStorageIfAvailable(_:)-7tacg)

Access contents of the buffer if available as contiguous memory block.

[`func withUnsafeBlockBuffer<R>((CMBlockBuffer) throws -> sending R) rethrows -> sending R`](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/withUnsafeBlockBuffer(_:))

Access the underlying CMBlockBuffer instance.

### Type Aliases

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

### Default Implementations

[Collection Implementations](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/Collection-Implementations)

[DataProtocol Implementations](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/DataProtocol-Implementations)

[RandomAccessCollection Implementations](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/RandomAccessCollection-Implementations)

[Sequence Implementations](/documentation/CoreMedia/CMReadOnlyDataBlockBuffer/Sequence-Implementations)

## Relationships

### Conforms To

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

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

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

[`ContentWithFormatDescription`](/documentation/CoreMedia/CMSampleBuffer/ContentWithFormatDescription)

[`Content`](/documentation/CoreMedia/CMSampleBuffer/Content)

[`DataProtocol`](/documentation/Foundation/DataProtocol)

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

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

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

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

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

[`MultiSampleContent`](/documentation/CoreMedia/CMSampleBuffer/MultiSampleContent)

---

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)