-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: New JS API for useCameraDevice
and useCameraFormat
#1784
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
mrousavy
force-pushed
the
feat/new-device-js-api
branch
from
September 14, 2023 20:33
720cfce
to
ce9abff
Compare
6 tasks
isaaccolson
pushed a commit
to isaaccolson/deliveries-mobile
that referenced
this pull request
Oct 30, 2024
… faster `getAvailableCameraDevices()` (mrousavy#1784) * Update podfile * Update useCameraFormat.ts * Update API * Delete FormatFilter.md * Format CameraViewManager.m ObjC style * Make `getAvailableCameraDevices` synchronous/blocking * Create some docs * fix: Fix HardwareLevel types * fix: Use new device/format API * Use 60 FPS format as an example * Replace `Camera.getAvailableCameraDevices` with new `CameraDevices` API/Module * Fix Lint * KTLint options * Use continuation indent of 8 * Use 2 spaces for indent * Update .editorconfig * Format code * Update .editorconfig * Format more * Update VideoStabilizationMode.kt * fix: Expose `CameraDevicesManager` to ObjC * Update CameraPage.tsx * fix: `requiresMainQueueSetup() -> false` * Always prefer higher resolution * Update CameraDevicesManager.swift * Update CameraPage.tsx * Also filter pixelFormat * fix: Add AVFoundation import
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR consists of 4 parts:
Makes
Camera.getAvailableCameraDevices()
synchronous, so it can be called instantly - no more Promise/async. This makes Camera Device selection much faster (effectively instant)! 🚀Adds listener APIs (
Camera.addCameraDevicesChangedListener(..)
) for when Camera Devices change (e.g. 'external' USB/continuity cameras being plugged in/out)Adds two new JS APIs for making device and format selection much easier:
1.
useCameraDevice
Get the best matching device for your requirements.
Examples:
Default back/front/external cameras (likely a wide-angle-camera)
Prefer triple camera to zoom 0.5x, 1x and 3x over wide-angle or fish-eye or any other cameras:
Prefer fish-eye over wide-angle, or triple/dual cameras.
2.
useCameraFormat
A new API to query the best matching format for the given requirements. Each requirement has a
priority
which specifies how to rank this format against other formats that matches different requirements.Examples:
Get any 60 FPS format:
Get any 4k video format:
Get a 4k@60 FPS video format if possible, otherwise the closest match. This will prefer a 4k@30 format over a 1080p@60 format because
videoResolution
has a higherpriority
thanfps
:Additionally, expose an imperative API which could be used outside of a function component (e.g. in a Class Component, or entirely outside a React component):
Same API as for the hooks:
getCameraDevice(..)
getCameraFormat(..)
Example Camera Devices
This is the output of
Camera.getAvailableCameraDevices()
on my iPhone 11 Pro:devices.json
Changes
Tested on
Related issues