9ea158ad8f
* rename 1/n * 2 * 3 * fix indent
25 lines
667 B
Swift
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
|
|
}
|
|
}
|
|
}
|
|
}
|