Class

AVCapture​Session

An object that manages capture activity and coordinates the flow of data from input devices to capture outputs.

Overview

To perform a real-time or offline capture, you instantiate an AVCapture​Session object and add appropriate inputs (such as AVCapture​Device​Input), and outputs (such as AVCapture​Movie​File​Output). The following code fragment illustrates how to configure a capture device to record audio:

AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *audioCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
NSError *error = nil;
AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioCaptureDevice error:&error];
if (audioInput) {
    [captureSession addInput:audioInput];
}
else {
    // Handle the failure.
}

You invoke start​Running() to start the flow of data from the inputs to the outputs, and invoke stop​Running() to stop the flow.

You use the session​Preset property to customize the quality level, bitrate, or other settings for the output. Most common capture configurations are available through session presets; however, some specialized options (such as high frame rate) require directly setting a capture format on an AVCapture​Device instance.

Symbols

Managing Inputs and Outputs

var inputs:​ [Any]!

The capture session’s inputs.

func can​Add​Input(AVCapture​Input!)

Returns a Boolean value that indicates whether a given input can be added to the session.

func add​Input(AVCapture​Input!)

Adds a given input to the session.

var outputs:​ [Any]!

The capture session’s outputs.

func can​Add​Output(AVCapture​Output!)

Returns a Boolean value that indicates whether a given output can be added to the session.

func add​Output(AVCapture​Output!)

Adds a given output to the session.

Managing Running State

func start​Running()

Tells the receiver to start running.

func stop​Running()

Tells the receiver to stop running.

var is​Running:​ Bool

Indicates whether the receiver is running.

var is​Interrupted:​ Bool

Indicates whether the receiver has been interrupted.

Configuration Change

func begin​Configuration()

Indicates the start of a set of configuration changes to be made atomically.

func commit​Configuration()

Commits a set of configuration changes.

Managing Session Presets

var session​Preset:​ String!

A constant value indicating the quality level or bitrate of the output.

func can​Set​Session​Preset(String!)

Returns a Boolean value that indicates whether the receiver can use the given preset.

Managing Connections

func add(AVCapture​Connection!)

Adds a given capture connection to the session.

func can​Add(AVCapture​Connection!)

Returns a Boolean value that indicates whether a given connection can be added to the receiver.

func add​Input​With​No​Connections(AVCapture​Input!)

Adds an capture input to the session without forming any connections.

func add​Output​With​No​Connections(AVCapture​Output!)

Adds an capture output to the session without forming any connections.

func remove(AVCapture​Connection!)

Removes a capture connection from the session.

Sharing the Application’s Audio Session

var uses​Application​Audio​Session:​ Bool

Indicates whether the capture session will make use of the app’s shared audio session.

var automatically​Configures​Application​Audio​Session:​ Bool

A Boolean value that indicates whether the capture session automatically changes settings in the app’s shared audio session.

Synchronizing Multiple Inputs and Outputs

var master​Clock:​ CMClock!

A clock object used for output synchronization.

Managing Color Spaces

var automatically​Configures​Capture​Device​For​Wide​Color:​ Bool

A Boolean value that specifies whether the session should automatically use wide-gamut color where available.

Constants

AVCapture​Video​Orientation

Constants indicating video orientation.

Notification User Info Keys

Keys to retrieve information from a notification from a capture session.

AVCapture​Session​Interruption​Reason

Constants identifying the reason a capture session was interrupted, found in a AVCapture​Session​Was​Interrupted user info dictionary.

Video Input Presets

Constants to define capture setting presets using the session​Preset property.

Relationships

Inherits From