react-native-vision-camera/ios/Extensions/AVCaptureVideoDataOutput+setOrientation.swift
Marc Rousavy 9ea158ad8f
chore: Move to /mrousavy/ (#224)
* rename 1/n

* 2

* 3

* fix indent
2021-06-21 22:42:46 +02:00

25 lines
667 B
Swift

//
// AVCaptureVideoDataOutput+setOrientation.swift
// mrousavy
//
// Created by Marc Rousavy on 18.01.21.
// Copyright © 2021 mrousavy. All rights reserved.
//
import AVFoundation
extension AVCaptureVideoDataOutput {
func setOrientation(forCameraPosition position: AVCaptureDevice.Position) {
let isMirrored = position == .front
connections.forEach { connection in
if connection.isVideoMirroringSupported {
connection.automaticallyAdjustsVideoMirroring = false
connection.isVideoMirrored = isMirrored
}
if connection.isVideoOrientationSupported {
connection.videoOrientation = .portrait
}
}
}
}