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
This commit is contained in:
@@ -14,7 +14,7 @@ export type CameraPosition = 'front' | 'back' | 'external';
|
||||
* Indentifiers for a physical camera (one that actually exists on the back/front of the device)
|
||||
*
|
||||
* * `"ultra-wide-angle-camera"`: A built-in camera with a shorter focal length than that of a wide-angle camera. (focal length between below 24mm)
|
||||
* * `"wide-angle-camera"`: A built-in wide-angle camera. (focal length between 24mm and 35mm)
|
||||
* * `"wide-angle-camera"`: A built-in wide-angle camera. (focal length between 24mm and 43mm)
|
||||
* * `"telephoto-camera"`: A built-in camera device with a longer focal length than a wide-angle camera. (focal length between above 85mm)
|
||||
*
|
||||
* Some Camera devices consist of multiple physical devices. They can be interpreted as _logical devices_, for example:
|
||||
@@ -89,6 +89,10 @@ export interface CameraDeviceFormat {
|
||||
* Specifies whether this format supports HDR mode for photo capture
|
||||
*/
|
||||
supportsPhotoHDR: boolean;
|
||||
/**
|
||||
* Specifies whether this format supports delivering depth data for photo or video capture.
|
||||
*/
|
||||
supportsDepthCapture: boolean;
|
||||
/**
|
||||
* The minum frame rate this Format needs to run at. High resolution formats often run at lower frame rates.
|
||||
*/
|
||||
@@ -121,14 +125,14 @@ export interface CameraDevice {
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The physical devices this `CameraDevice` contains.
|
||||
* The physical devices this `CameraDevice` consists of.
|
||||
*
|
||||
* * If this camera device is a **logical camera** (combination of multiple physical cameras), there are multiple cameras in this array.
|
||||
* * If this camera device is a **physical camera**, there is only a single element in this array.
|
||||
* * If this camera device is a **logical camera** (combination of multiple physical cameras, e.g. "Triple Camera"), there are multiple cameras in this array.
|
||||
* * If this camera device is a **physical camera** (e.g. "wide-angle-camera"), there is only a single element in this array.
|
||||
*
|
||||
* You can check if the camera is a logical multi-camera by using the `isMultiCam` property.
|
||||
*/
|
||||
devices: PhysicalCameraDeviceType[];
|
||||
physicalDevices: PhysicalCameraDeviceType[];
|
||||
/**
|
||||
* Specifies the physical position of this camera. (back or front)
|
||||
*/
|
||||
@@ -187,12 +191,6 @@ export interface CameraDevice {
|
||||
* Whether this camera device supports low light boost.
|
||||
*/
|
||||
supportsLowLightBoost: boolean;
|
||||
/**
|
||||
* Whether this camera supports taking photos with depth data.
|
||||
*
|
||||
* **! Work in Progress !**
|
||||
*/
|
||||
supportsDepthCapture: boolean;
|
||||
/**
|
||||
* Whether this camera supports taking photos in RAW format
|
||||
*
|
||||
|
@@ -4,6 +4,7 @@ import { CameraDevice } from './CameraDevice';
|
||||
const CameraDevicesManager = NativeModules.CameraDevices as {
|
||||
getConstants: () => {
|
||||
availableCameraDevices: CameraDevice[];
|
||||
userPreferredCameraDevice: CameraDevice | undefined;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -18,6 +19,7 @@ eventEmitter.addListener(DEVICES_CHANGED_NAME, (newDevices: CameraDevice[]) => {
|
||||
});
|
||||
|
||||
export const CameraDevices = {
|
||||
userPreferredCameraDevice: constants.userPreferredCameraDevice,
|
||||
getAvailableCameraDevices: () => devices,
|
||||
addCameraDevicesChangedListener: (callback: (newDevices: CameraDevice[]) => void) => {
|
||||
return eventEmitter.addListener(DEVICES_CHANGED_NAME, callback);
|
||||
|
@@ -43,11 +43,11 @@ export function getCameraDevice(devices: CameraDevice[], position: CameraPositio
|
||||
// 1. user wants all cameras ([ultra-wide, wide, tele]) to zoom. prefer those devices that have all 3 cameras.
|
||||
// 2. user wants only one ([wide]) for faster performance. prefer those devices that only have one camera, if they have more, we rank them lower.
|
||||
if (filter.physicalDevices != null) {
|
||||
for (const device of left.devices) {
|
||||
for (const device of left.physicalDevices) {
|
||||
if (filter.physicalDevices.includes(device)) leftPoints += 1;
|
||||
else leftPoints -= 1;
|
||||
}
|
||||
for (const device of right.devices) {
|
||||
for (const device of right.physicalDevices) {
|
||||
if (filter.physicalDevices.includes(device)) rightPoints += 1;
|
||||
else rightPoints -= 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user