MijickCamera/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice+AVCaptureDevice.swift

42 lines
1.4 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// CaptureDevice+AVCaptureDevice.swift of MijickCamera
//
// Created by Tomasz Kurylik. Sending from Kraków!
// - Mail: tomasz.kurylik@mijick.com
// - GitHub: https://github.com/FulcrumOne
// - Medium: https://medium.com/@mijick
//
// Copyright ©2024 Mijick. All rights reserved.
import AVKit
// MARK: Getters
extension AVCaptureDevice: CaptureDevice {
var minExposureDuration: CMTime { activeFormat.minExposureDuration }
var maxExposureDuration: CMTime { activeFormat.maxExposureDuration }
var minISO: Float { activeFormat.minISO }
var maxISO: Float { activeFormat.maxISO }
var minFrameRate: Float64? { activeFormat.videoSupportedFrameRateRanges.first?.minFrameRate }
var maxFrameRate: Float64? { activeFormat.videoSupportedFrameRateRanges.first?.maxFrameRate }
}
// MARK: Getters & Setters
extension AVCaptureDevice {
var lightMode: CameraLightMode {
get { torchMode == .off ? .off : .on }
set { torchMode = newValue == .off ? .off : .on }
}
var hdrMode: CameraHDRMode {
get {
if automaticallyAdjustsVideoHDREnabled { return .auto }
else if isVideoHDREnabled { return .on }
else { return .off }
}
set {
automaticallyAdjustsVideoHDREnabled = newValue == .auto
if newValue != .auto { isVideoHDREnabled = newValue == .on }
}
}
}