From 305e50df23ccef602ff3068f70b56f3575d4bfcf Mon Sep 17 00:00:00 2001 From: Bogdan Gusiev Date: Wed, 15 Jan 2025 17:22:16 +0100 Subject: [PATCH] Check HDR mode supported --- .../Helpers/Capture Device/CaptureDevice+AVCaptureDevice.swift | 2 ++ .../Capture Device/CaptureDevice+MockCaptureDevice.swift | 1 + .../Internal/Manager/Helpers/Capture Device/CaptureDevice.swift | 1 + 3 files changed, 4 insertions(+) diff --git a/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice+AVCaptureDevice.swift b/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice+AVCaptureDevice.swift index dacf5cafd..3dd7114ba 100644 --- a/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice+AVCaptureDevice.swift +++ b/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice+AVCaptureDevice.swift @@ -19,6 +19,7 @@ extension AVCaptureDevice: CaptureDevice { var maxISO: Float { activeFormat.maxISO } var minFrameRate: Float64? { activeFormat.videoSupportedFrameRateRanges.first?.minFrameRate } var maxFrameRate: Float64? { activeFormat.videoSupportedFrameRateRanges.first?.maxFrameRate } + var isVideoHDRSupported: Bool { activeFormat.isVideoHDRSupported } } // MARK: Getters & Setters @@ -34,6 +35,7 @@ extension AVCaptureDevice { else { return .off } } set { + guard isVideoHDRSupported else { return } automaticallyAdjustsVideoHDREnabled = newValue == .auto if newValue != .auto { isVideoHDREnabled = newValue == .on } } diff --git a/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice+MockCaptureDevice.swift b/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice+MockCaptureDevice.swift index ed56d157f..33cb79fbe 100644 --- a/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice+MockCaptureDevice.swift +++ b/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice+MockCaptureDevice.swift @@ -31,6 +31,7 @@ class MockCaptureDevice: NSObject, CaptureDevice { var hasTorch: Bool { true } var isExposurePointOfInterestSupported: Bool { true } var isFocusPointOfInterestSupported: Bool { true } + var isVideoHDRSupported: Bool { true } // MARK: Setters var videoZoomFactor: CGFloat = 1 diff --git a/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice.swift b/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice.swift index ee35084ed..8fac4bb85 100644 --- a/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice.swift +++ b/Sources/Internal/Manager/Helpers/Capture Device/CaptureDevice.swift @@ -31,6 +31,7 @@ protocol CaptureDevice: NSObject { var hasTorch: Bool { get } var isExposurePointOfInterestSupported: Bool { get } var isFocusPointOfInterestSupported: Bool { get } + var isVideoHDRSupported: Bool { get } // MARK: Getters & Setters var videoZoomFactor: CGFloat { get set }