From 11bf531524d9985e99e60f2f6e50fc01d610aef8 Mon Sep 17 00:00:00 2001 From: davidliu Date: Tue, 15 Oct 2024 19:58:13 +0900 Subject: [PATCH] Fix multi-cam support (#18) --- ios/RCTWebRTC/VideoCaptureController.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ios/RCTWebRTC/VideoCaptureController.m b/ios/RCTWebRTC/VideoCaptureController.m index 2f8447004..4307e37f3 100644 --- a/ios/RCTWebRTC/VideoCaptureController.m +++ b/ios/RCTWebRTC/VideoCaptureController.m @@ -206,6 +206,13 @@ - (AVCaptureDeviceFormat *)selectFormatForDevice:(AVCaptureDevice *)device int currentDiff = INT_MAX; for (AVCaptureDeviceFormat *format in formats) { + // Only use multi cam formats when on multi cam supported devices. + if (@available(iOS 13.0, macOS 14.0, tvOS 17.0, *)) { + if (AVCaptureMultiCamSession.multiCamSupported && !format.multiCamSupported) { + continue; + } + } + CMVideoDimensions dimension = CMVideoFormatDescriptionGetDimensions(format.formatDescription); FourCharCode pixelFormat = CMFormatDescriptionGetMediaSubType(format.formatDescription); int diff = abs(targetWidth - dimension.width) + abs(targetHeight - dimension.height); @@ -252,4 +259,4 @@ - (void)resetFrameRateForDevice:(AVCaptureDevice *)device { @end -#endif \ No newline at end of file +#endif