fix: Expose minExposure
/maxExposure
in format
(#2179)
* fix: Expose `minExposure`/`maxExposure` in `format` I forgot to do that on iOS before * Update CameraDeviceFormat.swift
This commit is contained in:
parent
ba0aa88cb9
commit
9c5eb9105e
@ -187,14 +187,14 @@ extension CameraSession {
|
|||||||
|
|
||||||
ReactLogger.log(level: .info, message: "Configuring Format (\(targetFormat))...")
|
ReactLogger.log(level: .info, message: "Configuring Format (\(targetFormat))...")
|
||||||
|
|
||||||
let currentFormat = CameraDeviceFormat(fromFormat: device.activeFormat)
|
let currentFormat = CameraDeviceFormat(fromFormat: device.activeFormat, forDevice: device)
|
||||||
if currentFormat == targetFormat {
|
if currentFormat == targetFormat {
|
||||||
ReactLogger.log(level: .info, message: "Already selected active format, no need to configure.")
|
ReactLogger.log(level: .info, message: "Already selected active format, no need to configure.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find matching format (JS Dictionary -> strongly typed Swift class)
|
// Find matching format (JS Dictionary -> strongly typed Swift class)
|
||||||
let format = device.formats.first { targetFormat.isEqualTo(format: $0) }
|
let format = device.formats.first { targetFormat.isEqualTo(format: $0, device: device) }
|
||||||
guard let format else {
|
guard let format else {
|
||||||
throw CameraError.format(.invalidFormat)
|
throw CameraError.format(.invalidFormat)
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import AVFoundation
|
|||||||
|
|
||||||
extension AVCaptureDevice {
|
extension AVCaptureDevice {
|
||||||
func toDictionary() -> [String: Any] {
|
func toDictionary() -> [String: Any] {
|
||||||
let formats = formats.map { CameraDeviceFormat(fromFormat: $0) }
|
let formats = formats.map { CameraDeviceFormat(fromFormat: $0, forDevice: self) }
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"id": uniqueID,
|
"id": uniqueID,
|
||||||
|
@ -22,6 +22,9 @@ struct CameraDeviceFormat: Equatable, CustomStringConvertible {
|
|||||||
let minFps: Double
|
let minFps: Double
|
||||||
let maxFps: Double
|
let maxFps: Double
|
||||||
|
|
||||||
|
let minExposure: Float
|
||||||
|
let maxExposure: Float
|
||||||
|
|
||||||
let minISO: Float
|
let minISO: Float
|
||||||
let maxISO: Float
|
let maxISO: Float
|
||||||
|
|
||||||
@ -38,13 +41,15 @@ struct CameraDeviceFormat: Equatable, CustomStringConvertible {
|
|||||||
|
|
||||||
let supportsDepthCapture: Bool
|
let supportsDepthCapture: Bool
|
||||||
|
|
||||||
init(fromFormat format: AVCaptureDevice.Format) {
|
init(fromFormat format: AVCaptureDevice.Format, forDevice device: AVCaptureDevice) {
|
||||||
videoWidth = Int(format.videoDimensions.width)
|
videoWidth = Int(format.videoDimensions.width)
|
||||||
videoHeight = Int(format.videoDimensions.height)
|
videoHeight = Int(format.videoDimensions.height)
|
||||||
photoWidth = Int(format.photoDimensions.width)
|
photoWidth = Int(format.photoDimensions.width)
|
||||||
photoHeight = Int(format.photoDimensions.height)
|
photoHeight = Int(format.photoDimensions.height)
|
||||||
minFps = format.minFps
|
minFps = format.minFps
|
||||||
maxFps = format.maxFps
|
maxFps = format.maxFps
|
||||||
|
minExposure = device.minExposureTargetBias
|
||||||
|
maxExposure = device.maxExposureTargetBias
|
||||||
minISO = format.minISO
|
minISO = format.minISO
|
||||||
maxISO = format.maxISO
|
maxISO = format.maxISO
|
||||||
fieldOfView = format.videoFieldOfView
|
fieldOfView = format.videoFieldOfView
|
||||||
@ -67,6 +72,8 @@ struct CameraDeviceFormat: Equatable, CustomStringConvertible {
|
|||||||
maxFps = jsValue["maxFps"] as! Double
|
maxFps = jsValue["maxFps"] as! Double
|
||||||
minISO = jsValue["minISO"] as! Float
|
minISO = jsValue["minISO"] as! Float
|
||||||
maxISO = jsValue["maxISO"] as! Float
|
maxISO = jsValue["maxISO"] as! Float
|
||||||
|
minExposure = jsValue["minExposure"] as! Float
|
||||||
|
maxExposure = jsValue["maxExposure"] as! Float
|
||||||
fieldOfView = jsValue["fieldOfView"] as! Float
|
fieldOfView = jsValue["fieldOfView"] as! Float
|
||||||
maxZoom = jsValue["maxZoom"] as! Double
|
maxZoom = jsValue["maxZoom"] as! Double
|
||||||
let jsVideoStabilizationModes = jsValue["videoStabilizationModes"] as! [String]
|
let jsVideoStabilizationModes = jsValue["videoStabilizationModes"] as! [String]
|
||||||
@ -81,8 +88,8 @@ struct CameraDeviceFormat: Equatable, CustomStringConvertible {
|
|||||||
// swiftlint:enable force_cast
|
// swiftlint:enable force_cast
|
||||||
}
|
}
|
||||||
|
|
||||||
func isEqualTo(format other: AVCaptureDevice.Format) -> Bool {
|
func isEqualTo(format other: AVCaptureDevice.Format, device otherDevice: AVCaptureDevice) -> Bool {
|
||||||
let other = CameraDeviceFormat(fromFormat: other)
|
let other = CameraDeviceFormat(fromFormat: other, forDevice: otherDevice)
|
||||||
return self == other
|
return self == other
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,8 +101,10 @@ struct CameraDeviceFormat: Equatable, CustomStringConvertible {
|
|||||||
"photoWidth": photoWidth,
|
"photoWidth": photoWidth,
|
||||||
"videoHeight": videoHeight,
|
"videoHeight": videoHeight,
|
||||||
"videoWidth": videoWidth,
|
"videoWidth": videoWidth,
|
||||||
"maxISO": maxISO,
|
|
||||||
"minISO": minISO,
|
"minISO": minISO,
|
||||||
|
"maxISO": maxISO,
|
||||||
|
"minExposure": minExposure,
|
||||||
|
"maxExposure": maxExposure,
|
||||||
"fieldOfView": fieldOfView,
|
"fieldOfView": fieldOfView,
|
||||||
"maxZoom": maxZoom,
|
"maxZoom": maxZoom,
|
||||||
"supportsVideoHdr": supportsVideoHdr,
|
"supportsVideoHdr": supportsVideoHdr,
|
||||||
|
Loading…
Reference in New Issue
Block a user