<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMBufferCallbacks",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@SA@CMBufferCallbacks"
  },
  "title" : "CMBufferCallbacks"
}
-->

# CMBufferCallbacks

A structure that stores the callbacks that perform buffer operations.

```
struct CMBufferCallbacks
```

## Overview

With the exception of `isDataReady`, all these callbacks must always return the same result for the same arguments.

A buffer’s duration, timestamps, or position relative to other buffers must not appear to change while it is in the queue. Once `isDataReady` has returned true for a given `CMBuffer`, it must always return true for that `CMBuffer`.

Durations must always be positive.

## Topics

### Properties

[`compare`](/documentation/CoreMedia/CMBufferCallbacks/compare)

This callback is called multiple times from [`CMBufferQueueEnqueue(_:buffer:)`](/documentation/CoreMedia/CMBufferQueueEnqueue(_:buffer:)), to perform an insertion sort.

[`CMBufferCompareCallback`](/documentation/CoreMedia/CMBufferCompareCallback)

Callback that compares one `CMBuffer` with another.

[`CMBufferGetBooleanCallback`](/documentation/CoreMedia/CMBufferGetBooleanCallback)

Callback that returns a Boolean value from a `CMBuffer`.

[`CMBufferGetTimeCallback`](/documentation/CoreMedia/CMBufferGetTimeCallback)

Callback that returns a `CMTime` from a `CMBuffer`.

[`dataBecameReadyNotification`](/documentation/CoreMedia/CMBufferCallbacks/dataBecameReadyNotification)

If triggers of type `kCMBufferQueueTrigger_WhenDataBecomesReady` are installed, the queue will listen for this notification on the head buffer.

[`getDecodeTimeStamp`](/documentation/CoreMedia/CMBufferCallbacks/getDecodeTimeStamp)

Client callback that returns a `CMTime` from a `CMBuffer`.

[`getDuration`](/documentation/CoreMedia/CMBufferCallbacks/getDuration)

This callback is called (once) during enqueue and dequeue operations to update the total duration of the queue.

[`getPresentationTimeStamp`](/documentation/CoreMedia/CMBufferCallbacks/getPresentationTimeStamp)

Client callback that returns a `CMTime` from a `CMBuffer`.

[`getSize`](/documentation/CoreMedia/CMBufferCallbacks/getSize)

[`isDataReady`](/documentation/CoreMedia/CMBufferCallbacks/isDataReady)

This callback is called from [`CMBufferQueueDequeueIfDataReady(_:)`](/documentation/CoreMedia/CMBufferQueueDequeueIfDataReady(_:)), to ask if the buffer that is about to be dequeued is ready.

[`refcon`](/documentation/CoreMedia/CMBufferCallbacks/refcon)

Contextual data to be passed to all callbacks.

[`version`](/documentation/CoreMedia/CMBufferCallbacks/version)

The callback version.

### Initializers

[`init(version:refcon:getDecodeTimeStamp:getPresentationTimeStamp:getDuration:isDataReady:compare:dataBecameReadyNotification:getSize:)`](/documentation/CoreMedia/CMBufferCallbacks/init(version:refcon:getDecodeTimeStamp:getPresentationTimeStamp:getDuration:isDataReady:compare:dataBecameReadyNotification:getSize:))



---

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)