fix: Use simple wide-angle device if no options are passed (#1909)

This commit is contained in:
Marc Rousavy 2023-10-03 12:03:20 +02:00 committed by GitHub
parent bdd81cf2fb
commit 24f77fb224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -45,9 +45,7 @@ export function CameraPage({ navigation }: Props): React.ReactElement {
const [enableNightMode, setEnableNightMode] = useState(false)
// camera format settings
const device = useCameraDevice(cameraPosition, {
physicalDevices: ['ultra-wide-angle-camera', 'wide-angle-camera', 'telephoto-camera'],
})
const device = useCameraDevice(cameraPosition)
const [targetFps, setTargetFps] = useState(60)
@ -148,14 +146,13 @@ export function CameraPage({ navigation }: Props): React.ReactElement {
})
//#endregion
if (device != null && format != null) {
console.log(
`Re-rendering camera page with ${isActive ? 'active' : 'inactive'} camera. ` +
`Device: "${device.name}" (${format.photoWidth}x${format.photoHeight} photo / ${format.videoWidth}x${format.videoHeight} video @ ${fps}fps)`,
)
} else {
console.log('re-rendering camera page without active camera')
}
useEffect(() => {
const f =
format != null
? `(${format.photoWidth}x${format.photoHeight} photo / ${format.videoWidth}x${format.videoHeight}@${format.maxFps} video @ ${fps}fps)`
: undefined
console.log(`Camera: ${device?.name} | Format: ${f}`)
}, [device?.name, format, fps])
const frameProcessor = useFrameProcessor((frame) => {
'worklet'

View File

@ -54,8 +54,11 @@ export function getCameraDevice(devices: CameraDevice[], position: CameraPositio
if (!explicitlyWantsNonWideAngle) {
// prefer wide-angle-camera as a default
if (bestDevice.physicalDevices.includes('wide-angle-camera')) leftPoints += 1
if (device.physicalDevices.includes('wide-angle-camera')) rightPoints += 1
if (bestDevice.physicalDevices.includes('wide-angle-camera')) leftPoints += 2
if (device.physicalDevices.includes('wide-angle-camera')) rightPoints += 2
// if we have more than one device, we rank it lower. we only want a simple camera
if (bestDevice.physicalDevices.length > device.physicalDevices.length) leftPoints -= 1
if (device.physicalDevices.length > bestDevice.physicalDevices.length) rightPoints -= 1
}
// compare devices. two possible scenarios: