react-native-vision-camera/ios/Extensions/AVCaptureSession+setVideoStabilizationMode.swift
Marc Rousavy 0b5d277514
feat: Video Stabilization (#160)
* Set video stabilization mode

* Fix video stabilization below iOS 13

* swift format
2021-06-03 15:42:02 +02:00

29 lines
703 B
Swift

//
// AVCaptureSession+setVideoStabilizationMode.swift
// VisionCamera
//
// Created by Marc Rousavy on 02.06.21.
// Copyright © 2021 Facebook. All rights reserved.
//
import AVFoundation
import Foundation
extension AVCaptureSession {
/**
Set the given video stabilization mode for all capture connections.
*/
func setVideoStabilizationMode(_ mode: String) {
if #available(iOS 13.0, *) {
guard let mode = try? AVCaptureVideoStabilizationMode(withString: mode) else {
return
}
connections.forEach { connection in
if connection.isVideoStabilizationSupported {
connection.preferredVideoStabilizationMode = mode
}
}
}
}
}