diff --git a/package/example/src/CameraPage.tsx b/package/example/src/CameraPage.tsx index 164315bcb0..d2d2c7a5ca 100644 --- a/package/example/src/CameraPage.tsx +++ b/package/example/src/CameraPage.tsx @@ -212,6 +212,7 @@ export function CameraPage({ navigation }: Props): React.ReactElement { video={true} audio={hasMicrophonePermission} frameProcessor={frameProcessor} + enableHighQualityPhotos={true} /> diff --git a/package/ios/Core/CameraSession+Configuration.swift b/package/ios/Core/CameraSession+Configuration.swift index a75fab9c4b..89c8f30620 100644 --- a/package/ios/Core/CameraSession+Configuration.swift +++ b/package/ios/Core/CameraSession+Configuration.swift @@ -81,21 +81,9 @@ extension CameraSession { photoOutput.maxPhotoQualityPrioritization = qualityPrioritization } if photo.enableHighQualityPhotos { - // TODO: Refactor this into an extension method. Same for AVCapturePhotoOutput. - if #available(iOS 16.0, *) { - if let device = videoDeviceInput?.device, - let targetFormat = configuration.format { - guard let format = device.formats.first(where: { f in targetFormat.isEqualTo(format: f) }) else { - throw CameraError.parameter(.invalid(unionName: "format", receivedValue: targetFormat.toJSValue().description)) - } - guard let maxSupportedDimension = format.supportedMaxPhotoDimensions.max(by: { ($0.width * $0.height) < ($1.width * $1.height) }) else { - throw CameraError.unknown(message: "supportedMaxPhotoDimensions was empty!", cause: nil) - } - photoOutput.maxPhotoDimensions = maxSupportedDimension - } - } else { - photoOutput.isHighResolutionCaptureEnabled = true - } + // This is deprecated in favor of `maxPhotoDimensions`, but maxPhotoDimensions is by default + // already set to the highest resolution possible (i think?), so we don't need to set that again. + photoOutput.isHighResolutionCaptureEnabled = true } // TODO: Enable isResponsiveCaptureEnabled? (iOS 17+) // TODO: Enable isFastCapturePrioritizationEnabled? (iOS 17+) @@ -215,29 +203,6 @@ extension CameraSession { ReactLogger.log(level: .info, message: "Successfully configured Format!") } - func configurePhotoOutputResolution(configuration: CameraConfiguration) { - guard case let .enabled(photo) = configuration.photo, - let photoOutput, let videoDeviceInput else { - // Video is not enabled - return - } - - // Configure the PhotoOutput to use the maximum available resolution. - // We need to do this after device.activeFormat has been set. - if #available(iOS 16.0, *) { - let format = videoDeviceInput.device.activeFormat - let maxPhotoResolution = format.supportedMaxPhotoDimensions.max(by: { left, right in - (left.width * left.height) < (right.width * right.height) - }) - guard let maxPhotoResolution else { - return - } - photoOutput.maxPhotoDimensions = maxPhotoResolution - } else { - photoOutput.isHighResolutionCaptureEnabled = true - } - } - func configurePixelFormat(configuration: CameraConfiguration) throws { guard case let .enabled(video) = configuration.video, let videoOutput else { diff --git a/package/ios/Core/CameraSession+Photo.swift b/package/ios/Core/CameraSession+Photo.swift index cc78628681..57f0b0eec8 100644 --- a/package/ios/Core/CameraSession+Photo.swift +++ b/package/ios/Core/CameraSession+Photo.swift @@ -44,11 +44,7 @@ extension CameraSession { // high resolution capture if photo.enableHighQualityPhotos { // TODO: On iOS 16+ this will be removed in favor of maxPhotoDimensions. - if #available(iOS 16.0, *) { - photoSettings.maxPhotoDimensions = photoOutput.maxPhotoDimensions - } else { - photoSettings.isHighResolutionPhotoEnabled = true - } + photoSettings.isHighResolutionPhotoEnabled = photoOutput.isHighResolutionCaptureEnabled } // depth data diff --git a/package/ios/Core/CameraSession.swift b/package/ios/Core/CameraSession.swift index bd95fc86d7..3357aa2db9 100644 --- a/package/ios/Core/CameraSession.swift +++ b/package/ios/Core/CameraSession.swift @@ -159,19 +159,15 @@ class CameraSession: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate, AVC if difference.outputsChanged || difference.formatChanged { try self.configurePixelFormat(configuration: config) } - // 6. After step 2. and 4. we also need to configure the photo output resolution - if difference.outputsChanged || difference.formatChanged { - self.configurePhotoOutputResolution(configuration: config) - } - // 7. Configure side-props (fps, lowLightBoost) + // 6. Configure side-props (fps, lowLightBoost) if difference.sidePropsChanged { try self.configureSideProps(configuration: config, device: device) } - // 8. Configure zoom + // 7. Configure zoom if difference.zoomChanged { self.configureZoom(configuration: config, device: device) } - // 9. Configure exposure bias + // 8. Configure exposure bias if difference.exposureChanged { self.configureExposure(configuration: config, device: device) } @@ -183,10 +179,10 @@ class CameraSession: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate, AVC self.captureSession.commitConfiguration() } - // 10. Start or stop the session if needed + // 9. Start or stop the session if needed self.checkIsActive(configuration: config) - // 11. Enable or disable the Torch if needed (requires session to be running) + // 10. Enable or disable the Torch if needed (requires session to be running) if difference.torchChanged { try device.lockForConfiguration() defer {