void UpdateDeviceFocus (AVCaptureFocusMode focusMode, AVCaptureExposureMode exposureMode, CGPoint point, bool monitorSubjectAreaChange)
{
sessionQueue.DispatchAsync (() => {
var device = videoDeviceInput?.Device;
if (device == null)
return;
NSError error;
if (device.LockForConfiguration (out error)) {
// Setting (Focus/Exposure)PointOfInterest alone does not initiate a (focus/exposure) operation.
// Set (Focus/Exposure)Mode to apply the new point of interest.
if (device.FocusPointOfInterestSupported && device.IsFocusModeSupported (focusMode)) {
device.FocusPointOfInterest = point;
device.FocusMode = focusMode;
}
if (device.ExposurePointOfInterestSupported && device.IsExposureModeSupported (exposureMode)) {
device.ExposurePointOfInterest = point;
device.ExposureMode = exposureMode;
}
device.SubjectAreaChangeMonitoringEnabled = monitorSubjectAreaChange;
device.UnlockForConfiguration ();
} else {
Console.WriteLine ($"Could not lock device for configuration: {error.LocalizedDescription}");
}
});
}