The AVSampleBufferDisplayLayer class is a subclass of CALayer that displays compressed or uncompressed video frames.


Initiating Media Data Requests

func requestMediaDataWhenReady(on: DispatchQueue, using: () -> Void)

Instructs the target to invoke a client-supplied block repeatedly, at its convenience, in order to gather sample buffers for display.

var isReadyForMoreMediaData: Bool

A Boolean value that indicates the readiness of the layer to accept more sample buffers.

func stopRequestingMediaData()

Cancels any current media data request.

Flushing Sample Buffers

func flush()

Instructs the layer to discard enqueued sample buffers that are pending.

func flushAndRemoveImage()

Instructs the layer to discard pending enqueued sample buffers and remove any currently displayed image.

Getting and Setting the Timebase

var controlTimebase: CMTimebase?

The layer's control timebase, which governs how timestamps are interpreted.

Enqueuing the Sample Buffer

func enqueue(CMSampleBuffer)

Sends a sample buffer for display.

Setting the Video Gravity

var videoGravity: AVLayerVideoGravity

A string defining how the video is displayed within the bounds rect of a sample buffer display layer.

Getting Display Layer Settings

var error: Error?

Returns the error if the status indicates failure.

var status: AVQueuedSampleBufferRenderingStatus

The ability of the display layer to be used for enqueuing sample buffers.


enum AVQueuedSampleBufferRenderingStatus

Constants that describe the possible values of the status property.


Constant that describes the key for the userInfo field in the AVSampleBufferDisplayLayerFailedToDecode notification.


static let AVSampleBufferDisplayLayerFailedToDecode: NSNotification.Name

Posted when a buffer display layer failed to decode.