@@ -143,7 +143,7 @@ final class DefaultCamera: NSObject, Camera {
143
143
let captureVideoOutput = FLTDefaultCaptureVideoDataOutput (
144
144
captureVideoOutput: AVCaptureVideoDataOutput ( ) )
145
145
captureVideoOutput. videoSettings = [
146
- kCVPixelBufferPixelFormatTypeKey as String : videoFormat as Any
146
+ kCVPixelBufferPixelFormatTypeKey as String : videoFormat
147
147
]
148
148
captureVideoOutput. alwaysDiscardsLateVideoFrames = true
149
149
@@ -210,11 +210,6 @@ final class DefaultCamera: NSObject, Camera {
210
210
mediaSettingsAVWrapper. beginConfiguration ( for: videoCaptureSession)
211
211
defer { mediaSettingsAVWrapper. commitConfiguration ( for: videoCaptureSession) }
212
212
213
- // Possible values for presets are hard-coded in FLT interface having
214
- // corresponding AVCaptureSessionPreset counterparts.
215
- // If _resolutionPreset is not supported by camera there is
216
- // fallback to lower resolution presets.
217
- // If none can be selected there is error condition.
218
213
try setCaptureSessionPreset ( mediaSettings. resolutionPreset)
219
214
220
215
FLTSelectBestFormatForRequestedFrameRate (
@@ -239,14 +234,20 @@ final class DefaultCamera: NSObject, Camera {
239
234
updateOrientation ( )
240
235
}
241
236
237
+ // Possible values for presets are hard-coded in FLT interface having
238
+ // corresponding AVCaptureSessionPreset counterparts.
239
+ // If _resolutionPreset is not supported by camera there is
240
+ // fallback to lower resolution presets.
241
+ // If none can be selected there is error condition.
242
242
private func setCaptureSessionPreset(
243
243
_ resolutionPreset: FCPPlatformResolutionPreset
244
244
) throws {
245
245
switch resolutionPreset {
246
246
case . max:
247
247
if let bestFormat = highestResolutionFormat ( forCaptureDevice: captureDevice) {
248
248
videoCaptureSession. sessionPreset = . inputPriority
249
- if ( try ? captureDevice. lockForConfiguration ( ) ) != nil {
249
+ do {
250
+ try captureDevice. lockForConfiguration ( )
250
251
// Set the best device format found and finish the device configuration.
251
252
captureDevice. activeFormat = bestFormat
252
253
captureDevice. unlockForConfiguration ( )
@@ -427,8 +428,9 @@ final class DefaultCamera: NSObject, Camera {
427
428
// Get all the state on the current thread, not the main thread.
428
429
let state = FCPPlatformCameraState . make (
429
430
withPreviewSize: FCPPlatformSize . make (
430
- withWidth: Double ( previewSize!. width) ,
431
- height: Double ( previewSize!. height)
431
+ // previewSize is set during init, so it will never be nil.
432
+ withWidth: previewSize!. width,
433
+ height: previewSize!. height
432
434
) ,
433
435
exposureMode: exposureMode,
434
436
focusMode: focusMode,
@@ -736,7 +738,7 @@ final class DefaultCamera: NSObject, Camera {
736
738
private func updateOrientation( ) {
737
739
guard !isRecording else { return }
738
740
739
- let orientation : UIDeviceOrientation =
741
+ let orientation =
740
742
( lockedCaptureOrientation != . unknown)
741
743
? lockedCaptureOrientation
742
744
: deviceOrientation
@@ -751,11 +753,11 @@ final class DefaultCamera: NSObject, Camera {
751
753
if let connection = captureOutput. connection ( withMediaType: . video) ,
752
754
connection. isVideoOrientationSupported
753
755
{
754
- connection. videoOrientation = getVideoOrientation ( forDeviceOrientation: orientation)
756
+ connection. videoOrientation = videoOrientation ( forDeviceOrientation: orientation)
755
757
}
756
758
}
757
759
758
- private func getVideoOrientation ( forDeviceOrientation deviceOrientation: UIDeviceOrientation )
760
+ private func videoOrientation ( forDeviceOrientation deviceOrientation: UIDeviceOrientation )
759
761
-> AVCaptureVideoOrientation
760
762
{
761
763
switch deviceOrientation {
0 commit comments