sourceDevicePosition property
The position of the source device providing input through this port.
All ports contained in an CaptureInput object’s ports array have the same sourceDevicePosition value.
When working with a microphone input in an CaptureMultiCamSession
, 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 CaptureInput.portsWithMediaType
method, you ma
discover additional hidden ports originating from the source audio device.
These ports represent individual microphones positioned to pick up audio
from one particular direction.
// Get input ports
final List<CaptureInputPort> ports = ...
//Find the audio port that captures omnidirectional audio.
final omniAudioPort = ports.where((port) {
return port.mediaType == MediaType.audio &&
port.sourceDeviceType == CaptureDeviceType.builtInMicrophone &&
port.sourceDevicePosition == CaptureDevicePosition.unspecified;
}).first;
// Find the audio port that captures front audio.
final frontAudioPort = ports.where((port) {
return port.mediaType == MediaType.audio &&
port.sourceDeviceType == CaptureDeviceType.builtInMicrophone &&
port.sourceDevicePosition == CaptureDevicePosition.front;
}).first;
// Find the audio port that captures back audio.
final backAudioPort = ports.where((port) {
return port.mediaType == MediaType.audio &&
port.sourceDeviceType == CaptureDeviceType.builtInMicrophone &&
port.sourceDevicePosition == CaptureDevicePosition.back;
}).first;
This will always return CaptureDevicePosition.unspecified for iOS versions < 13;
Implementation
final int sourceDevicePosition;