react-native-vision-camera/package/ios/Extensions/AVCaptureDevice+toDictionary.swift
Marc Rousavy cf4882b152
feat: Add support for LiDAR, TrueDepth, External (USB) and Continuity Camera Devices (iOS 17) (#1824)
* feat: Add support for LiDAR, TrueDepth, External (USB) and Continuity Camera Devices (iOS 17)

* Rename `devices` -> `physicalDevices`

* fix: Comment out iOS 17 cameras for now

* fix: Move `supportsDepthCapture` to `format`

* fix: Fall back to `wide-angle-camera` for any unknown types

* Update CameraPage.tsx

* `descriptor` -> `physicalDeviceDescriptor`

* Update CameraDevice.ts

* Format

* feat: Expose `userPreferredCameraDevice`

Uses the new iOS 17 API where the user can prefer a default device, otherwise fall back to the first device of the available ones

* fix: Expose as property

* Add TODO comments

* fix: Format code

* fix: Compile below Swift 5.9
2023-09-21 16:29:46 +02:00

35 lines
1.0 KiB
Swift

//
// 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] {
return [
"id": uniqueID,
"physicalDevices": physicalDevices.map(\.deviceType.physicalDeviceDescriptor),
"position": position.descriptor,
"name": localizedName,
"hasFlash": hasFlash,
"hasTorch": hasTorch,
"minZoom": minAvailableVideoZoomFactor,
"neutralZoom": neutralZoomFactor,
"maxZoom": maxAvailableVideoZoomFactor,
"isMultiCam": isMultiCam,
"supportsRawCapture": false, // TODO: supportsRawCapture
"supportsLowLightBoost": isLowLightBoostSupported,
"supportsFocus": isFocusPointOfInterestSupported,
"hardwareLevel": "full",
"sensorOrientation": "portrait", // TODO: Sensor Orientation?
"formats": formats.map { format -> [String: Any] in
format.toDictionary()
},
]
}
}