sourceDevicePosition
The position of the source device providing input through this port.
Declaration
var sourceDevicePosition: AVCaptureDevice.Position { get }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 ports(for: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