From f35249a65ba5e1fd2878a5c2b3d0f7dcc54c416b Mon Sep 17 00:00:00 2001 From: davidliu Date: Mon, 14 Oct 2024 23:39:17 +0900 Subject: [PATCH] Fix multi-cam support --- 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