fix: Fix app hard-crashing when FPS value is not supported (#391)
This commit is contained in:
parent
dc02a6ec7c
commit
3c845ed4b0
@ -160,6 +160,14 @@ extension CameraView {
|
||||
try device.lockForConfiguration()
|
||||
|
||||
if let fps = self.fps?.int32Value {
|
||||
let supportsGivenFps = device.activeFormat.videoSupportedFrameRateRanges.contains { range in
|
||||
return range.includes(fps: Double(fps))
|
||||
}
|
||||
if !supportsGivenFps {
|
||||
invokeOnError(.format(.invalidFps(fps: Int(fps))))
|
||||
return
|
||||
}
|
||||
|
||||
let duration = CMTimeMake(value: 1, timescale: fps)
|
||||
device.activeVideoMinFrameDuration = duration
|
||||
device.activeVideoMaxFrameDuration = duration
|
||||
|
Loading…
Reference in New Issue
Block a user