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 invalidFps(fps: Int)
|
||||||
case invalidHdr
|
case invalidHdr
|
||||||
case invalidFormat
|
case invalidFormat
|
||||||
|
case invalidColorSpace(colorSpace: String)
|
||||||
case invalidPreset(preset: String)
|
case invalidPreset(preset: String)
|
||||||
|
|
||||||
var code: String {
|
var code: String {
|
||||||
@ -124,6 +125,8 @@ enum FormatError {
|
|||||||
return "invalid-hdr"
|
return "invalid-hdr"
|
||||||
case .invalidPreset:
|
case .invalidPreset:
|
||||||
return "invalid-preset"
|
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!"
|
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:
|
case .invalidHdr:
|
||||||
return "The currently selected format does not support HDR capture! Make sure you select a format which `frameRateRanges` includes `supportsPhotoHDR`!"
|
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):
|
case let .invalidPreset(preset):
|
||||||
return "The preset \"\(preset)\" is not available for the current camera device."
|
return "The preset \"\(preset)\" is not available for the current camera device."
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,12 @@ extension CameraView {
|
|||||||
device.automaticallyEnablesLowLightBoostWhenAvailable = lowLightBoost!.boolValue
|
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
|
device.activeColorSpace = avColorSpace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ export type FormatError =
|
|||||||
| 'format/invalid-hdr'
|
| 'format/invalid-hdr'
|
||||||
| 'format/invalid-low-light-boost'
|
| 'format/invalid-low-light-boost'
|
||||||
| 'format/invalid-format'
|
| 'format/invalid-format'
|
||||||
|
| 'format/invalid-color-space'
|
||||||
| 'format/invalid-preset';
|
| 'format/invalid-preset';
|
||||||
export type SessionError =
|
export type SessionError =
|
||||||
| 'session/camera-not-ready'
|
| 'session/camera-not-ready'
|
||||||
|
Loading…
Reference in New Issue
Block a user