| 
									
										
										
										
											2023-09-21 16:29:46 +02:00
										 |  |  | // | 
					
						
							|  |  |  | //  AVCaptureDevice+toDictionary.swift | 
					
						
							|  |  |  | //  VisionCamera | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //  Created by Marc Rousavy on 21.09.23. | 
					
						
							|  |  |  | //  Copyright © 2023 mrousavy. All rights reserved. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import AVFoundation | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extension AVCaptureDevice { | 
					
						
							|  |  |  |   func toDictionary() -> [String: Any] { | 
					
						
							| 
									
										
										
										
											2023-11-24 18:20:56 +01:00
										 |  |  |     let formats = formats.map { CameraDeviceFormat(fromFormat: $0) } | 
					
						
							| 
									
										
										
										
											2023-10-13 18:33:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-21 16:29:46 +02:00
										 |  |  |     return [ | 
					
						
							|  |  |  |       "id": uniqueID, | 
					
						
							|  |  |  |       "physicalDevices": physicalDevices.map(\.deviceType.physicalDeviceDescriptor), | 
					
						
							|  |  |  |       "position": position.descriptor, | 
					
						
							|  |  |  |       "name": localizedName, | 
					
						
							|  |  |  |       "hasFlash": hasFlash, | 
					
						
							|  |  |  |       "hasTorch": hasTorch, | 
					
						
							| 
									
										
										
										
											2024-01-15 19:30:20 +01:00
										 |  |  |       "minFocusDistance": minFocusDistance, | 
					
						
							| 
									
										
										
										
											2023-09-21 16:29:46 +02:00
										 |  |  |       "minZoom": minAvailableVideoZoomFactor, | 
					
						
							|  |  |  |       "maxZoom": maxAvailableVideoZoomFactor, | 
					
						
							| 
									
										
										
										
											2023-11-24 18:20:56 +01:00
										 |  |  |       "neutralZoom": neutralZoomFactor, | 
					
						
							|  |  |  |       "minExposure": minExposureTargetBias, | 
					
						
							|  |  |  |       "maxExposure": maxExposureTargetBias, | 
					
						
							| 
									
										
										
										
											2023-09-21 16:29:46 +02:00
										 |  |  |       "isMultiCam": isMultiCam, | 
					
						
							|  |  |  |       "supportsRawCapture": false, // TODO: supportsRawCapture | 
					
						
							|  |  |  |       "supportsLowLightBoost": isLowLightBoostSupported, | 
					
						
							|  |  |  |       "supportsFocus": isFocusPointOfInterestSupported, | 
					
						
							|  |  |  |       "hardwareLevel": "full", | 
					
						
							| 
									
										
										
										
											2023-10-19 17:02:07 +02:00
										 |  |  |       // TODO: Get orientation from `AVCaptureDevice.RotationCoordinator`, then just transform `AVAssetWriter` | 
					
						
							|  |  |  |       // See https://github.com/mrousavy/react-native-vision-camera/issues/2046 | 
					
						
							|  |  |  |       "sensorOrientation": Orientation.landscapeRight.jsValue, | 
					
						
							| 
									
										
										
										
											2023-10-13 18:33:20 +02:00
										 |  |  |       "formats": formats.map { $0.toJSValue() }, | 
					
						
							| 
									
										
										
										
											2023-09-21 16:29:46 +02:00
										 |  |  |     ] | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |