Class

AVCaptureVideoPreviewLayer

A Core Animation layer that can display video as it is being captured.

Overview

AVCaptureVideoPreviewLayer is a subclass of CALayer that you use to display video as it is being captured by an input device.

You use this preview layer in conjunction with an AV capture session, as illustrated in the following code fragment:

AVCaptureSession *captureSession = <#Get a capture session#>;
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession];
UIView *aView = <#The view in which to present the layer#>;
previewLayer.frame = aView.bounds; // Assume you want the preview layer to fill the view.
[aView.layer addSublayer:previewLayer];

You use the videoGravity property to influence how content is viewed relative to the layer bounds. On some hardware configurations, you can manipulate the orientation of the layer using orientation and mirrored.

Topics

Creating a Preview Layer

initWithSession:

Initializes a preview layer with a given capture session.

layerWithSession:

Returns a preview layer initialized with a given capture session.

initWithSessionWithNoConnection:

Initializes a preview layer using a given capture session but without making any connections.

layerWithSessionWithNoConnection:

Returns a preview layer using a given capture session but without making any connections.

Layer Configuration

videoGravity

Indicates how the video is displayed within a player layer’s bounds rect.

orientation

The layer’s orientation.

Deprecated
orientationSupported

Indicates whether the layer display supports changing the orientation.

Deprecated
mirrored

Indicates whether the layer display is mirrored.

Deprecated
mirroringSupported

Indicates whether the layer display supports mirroring.

Deprecated
automaticallyAdjustsMirroring

Indicates whether the layer display automatically adjusts mirroring.

Deprecated

Configuration

connection

The capture connection describing the AVCaptureInputPort to which the preview layer is connected.

session

The capture session instance being previewed.

setSessionWithNoConnection:

Attaches the receiver to a given session without implicitly forming a connection.

Converting Between Coordinate Systems

captureDevicePointOfInterestForPoint:

Converts a point from layer coordinates to the coordinate space of the capture device.

pointForCaptureDevicePointOfInterest:

Converts a point from the coordinate space of the capture device to the coordinate space of the layer.

transformedMetadataObjectForMetadataObject:

Converts a metadata object’s visual properties to layer coordinates.

metadataOutputRectOfInterestForRect:

Converts a rectangle in the preview layer’s coordinate system to one in the coordinate system used for metadata outputs.

rectForMetadataOutputRectOfInterest:

Converts a rectangle in the coordinate system used for metadata outputs to one in the preview layer’s coordinate system.

Relationships

Inherits From

See Also

Media Capture Preview

AVCaptureAudioPreviewOutput

A capture output that provides preview playback for audio being recorded in a capture session.