<!--
{
  "documentType" : "article",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/cmattachment-api",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "CMAttachment"
}
-->

# CMAttachment

Add supporting metadata to sample buffers.

## Discussion

An attachment bearer is a Core Foundation type object that supports the suite of key, value, and mode attachment APIs. You can attach any Core Foundation object to an attachment bearer to store additional information.

## Topics

### Processing Attachments

[`func CMGetAttachment(CMAttachmentBearer, key: CFString, attachmentModeOut: UnsafeMutablePointer<CMAttachmentMode>?) -> CFTypeRef?`](/documentation/CoreMedia/CMGetAttachment(_:key:attachmentModeOut:))

Returns an attachment from an attachment bearer object.

[`func CMCopyDictionaryOfAttachments(allocator: CFAllocator?, target: CMAttachmentBearer, attachmentMode: CMAttachmentMode) -> sending CFDictionary?`](/documentation/CoreMedia/CMCopyDictionaryOfAttachments(allocator:target:attachmentMode:))

Returns a dictionary of all attachments for an attachment bearer object.

[`func CMSetAttachment(CMAttachmentBearer, key: CFString, value: CFTypeRef?, attachmentMode: CMAttachmentMode)`](/documentation/CoreMedia/CMSetAttachment(_:key:value:attachmentMode:))

Sets or adds an attachment to an attachment bearer object.

[`func CMSetAttachments(CMAttachmentBearer, attachments: CFDictionary, attachmentMode: CMAttachmentMode)`](/documentation/CoreMedia/CMSetAttachments(_:attachments:attachmentMode:))

Sets a dictionary of attachments on an attachment bearer object.

[`func CMRemoveAttachment(CMAttachmentBearer, key: CFString)`](/documentation/CoreMedia/CMRemoveAttachment(_:key:))

Removes a specific attachment from an attachment bearer object.

[`func CMRemoveAllAttachments(CMAttachmentBearer)`](/documentation/CoreMedia/CMRemoveAllAttachments(_:))

Removes all attachments from an attachment bearer object.

[`func CMPropagateAttachments(CMAttachmentBearer, destination: CMAttachmentBearer)`](/documentation/CoreMedia/CMPropagateAttachments(_:destination:))

Copies all propagable attachments from one attachment bearer object to another.

### Data Types

[`protocol CMAttachmentBearerProtocol`](/documentation/CoreMedia/CMAttachmentBearerProtocol)

A protocol for objects that can carry attachments.

[`typealias CMAttachmentBearer`](/documentation/CoreMedia/CMAttachmentBearer)

An object that can carry attachments.

[`typealias CMAttachmentMode`](/documentation/CoreMedia/CMAttachmentMode)

The mode to use when propagating attachments.

### Constants

[`var kCMAttachmentMode_ShouldNotPropagate: CMAttachmentMode`](/documentation/CoreMedia/kCMAttachmentMode_ShouldNotPropagate)

A mode that doesn’t propagate attachments to another object.

[`var kCMAttachmentMode_ShouldPropagate: CMAttachmentMode`](/documentation/CoreMedia/kCMAttachmentMode_ShouldPropagate)

A mode that propagates attachments to another object.

[`let kCMSampleAttachmentKey_HEVCTemporalLevelInfo: CFString`](/documentation/CoreMedia/kCMSampleAttachmentKey_HEVCTemporalLevelInfo)

An attachment that indicates a video frame’s level within a hierarchical frame dependency structure.

[`let kCMSampleAttachmentKey_HEVCTemporalSubLayerAccess: CFString`](/documentation/CoreMedia/kCMSampleAttachmentKey_HEVCTemporalSubLayerAccess)

An attachment that indicates a temporal sublayer access grouping.

[`let kCMSampleAttachmentKey_HEVCStepwiseTemporalSubLayerAccess: CFString`](/documentation/CoreMedia/kCMSampleAttachmentKey_HEVCStepwiseTemporalSubLayerAccess)

An attachment that indicates a step-wise temporal sublayer access (STSA) sample grouping.

[`let kCMSampleAttachmentKey_HEVCSyncSampleNALUnitType: CFString`](/documentation/CoreMedia/kCMSampleAttachmentKey_HEVCSyncSampleNALUnitType)

An attachment that indicates a sync sample NAL unit type.

[`let kCMSampleAttachmentKey_CryptorSubsampleAuxiliaryData: CFString`](/documentation/CoreMedia/kCMSampleAttachmentKey_CryptorSubsampleAuxiliaryData)

An attachment that describes the ranges of protected and unprotected data within a protected sample buffer.

[`let kCMSampleAttachmentKey_AudioIndependentSampleDecoderRefreshCount: CFString`](/documentation/CoreMedia/kCMSampleAttachmentKey_AudioIndependentSampleDecoderRefreshCount)

An attachment that’s only present if the audio sample is an independent frame or immediate playout frame.

[`let kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix: CFString`](/documentation/CoreMedia/kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix)

An attachment that indicates a 3x3 camera intrinsic matrix to apply to the current sample buffer.



---

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)