Instance Property

sourceDevicePosition

The position of the source device providing input through this port.

Declaration

@property(nonatomic, readonly) AVCaptureDevicePosition sourceDevicePosition;

Discussion

All ports contained in an AVCaptureInput object’s ports array have the same sourceDevicePosition value.

When working with a microphone input in an AVCaptureMultiCamSession, it’s possible to record multiple microphone directions simultaneously. For example, you can record audio from the front microphone input to pair with video from the front camera, and record audio from the back microphone input to pair with video from the back camera.

By calling the input’s portsWithMediaType:sourceDeviceType:sourceDevicePosition: method, you may discover additional hidden ports originating from the source audio device. These ports represent individual microphones positioned to pick up audio from one particular direction.

// Find the audio port that captures omnidirectional audio.
let omniAudioPort = audioDeviceInput.ports(for: .audio,
                                           sourceDeviceType: .builtInMicrophone,
                                           sourceDevicePosition: .unspecified).first

// Find the audio port that captures front audio.
let frontAudioPort = audioDeviceInput.ports(for: .audio,
                                            sourceDeviceType: .builtInMicrophone,
                                            sourceDevicePosition: .front).first

// Find the audio port that captures back audio.
let backAudioPort = audioDeviceInput.ports(for: .audio,
                                           sourceDeviceType: .builtInMicrophone,
                                           sourceDevicePosition: .back).first

See Also

Inspecting an Input Port

enabled

Indicates whether the port is enabled.

input

The input object that owns the port.

mediaType

The port’s media type.

formatDescription

A description of the port format.

clock

An object representing the capture device’s own clock.

sourceDeviceType

The device type of the source camera providing the photo.