fix: Correctly catch unsupported colorSpace
errors
This commit is contained in:
parent
0aab414088
commit
f52e9fd831
@ -112,6 +112,7 @@ enum FormatError {
|
||||
case invalidFps(fps: Int)
|
||||
case invalidHdr
|
||||
case invalidFormat
|
||||
case invalidColorSpace(colorSpace: String)
|
||||
case invalidPreset(preset: String)
|
||||
|
||||
var code: String {
|
||||
@ -124,6 +125,8 @@ enum FormatError {
|
||||
return "invalid-hdr"
|
||||
case .invalidPreset:
|
||||
return "invalid-preset"
|
||||
case .invalidColorSpace:
|
||||
return "invalid-color-space"
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,6 +138,8 @@ enum FormatError {
|
||||
return "The given FPS were not valid for the currently selected format. Make sure you select a format which `frameRateRanges` includes \(fps) FPS!"
|
||||
case .invalidHdr:
|
||||
return "The currently selected format does not support HDR capture! Make sure you select a format which `frameRateRanges` includes `supportsPhotoHDR`!"
|
||||
case let .invalidColorSpace(colorSpace):
|
||||
return "The currently selected format does not support the colorSpace \"\(colorSpace)\"! Make sure you select a format which `colorSpaces` includes \"\(colorSpace)\"!"
|
||||
case let .invalidPreset(preset):
|
||||
return "The preset \"\(preset)\" is not available for the current camera device."
|
||||
}
|
||||
|
@ -186,7 +186,12 @@ extension CameraView {
|
||||
device.automaticallyEnablesLowLightBoostWhenAvailable = lowLightBoost!.boolValue
|
||||
}
|
||||
}
|
||||
if colorSpace != nil, let avColorSpace = try? AVCaptureColorSpace(string: String(colorSpace!)) {
|
||||
if let colorSpace = self.colorSpace as String? {
|
||||
guard let avColorSpace = try? AVCaptureColorSpace(string: colorSpace),
|
||||
device.activeFormat.supportedColorSpaces.contains(avColorSpace) else {
|
||||
invokeOnError(.format(.invalidColorSpace(colorSpace: colorSpace)))
|
||||
return
|
||||
}
|
||||
device.activeColorSpace = avColorSpace
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ export type FormatError =
|
||||
| 'format/invalid-hdr'
|
||||
| 'format/invalid-low-light-boost'
|
||||
| 'format/invalid-format'
|
||||
| 'format/invalid-color-space'
|
||||
| 'format/invalid-preset';
|
||||
export type SessionError =
|
||||
| 'session/camera-not-ready'
|
||||
|
Loading…
Reference in New Issue
Block a user