Merge tag 'v3.9.2' into HEAD

Release 3.9.2
This commit is contained in:
2024-07-23 13:10:44 -06:00
77 changed files with 2213 additions and 942 deletions

View File

@@ -473,7 +473,8 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (device == null) {
throw new Error(
throw new CameraRuntimeError(
'device/no-device',
'Camera: `device` is null! Select a valid Camera device. See: https://mrousavy.com/react-native-vision-camera/docs/guides/devices',
)
}

View File

@@ -25,6 +25,7 @@ export type SessionError =
| 'session/camera-cannot-be-opened'
| 'session/camera-has-been-disconnected'
| 'session/audio-in-use-by-other-app'
| 'session/no-outputs'
| 'session/audio-session-failed-to-activate'
export type CodeScannerError =
| 'code-scanner/not-compatible-with-outputs'
@@ -40,7 +41,10 @@ export type CaptureError =
| 'capture/recorder-error'
| 'capture/video-not-enabled'
| 'capture/photo-not-enabled'
| 'capture/frame-invalid'
| 'capture/aborted'
| 'capture/focus-canceled'
| 'capture/timed-out'
| 'capture/unknown'
export type SystemError =
| 'system/camera-module-not-found'

View File

@@ -183,10 +183,29 @@ export interface CameraProps extends ViewProps {
*
* @platform iOS
* @default
* - true // if video={true} and frameProcessor={undefined}
* - true // if frameProcessor={undefined}
* - false // otherwise
*/
enableBufferCompression?: boolean
/**
* Enables or disables GPU-sampled buffers for the video stream. This only takes effect when using a {@linkcode frameProcessor}.
*
* When recording a Video ({@linkcode video}) while a Frame Processor is running ({@linkcode frameProcessor}),
* the {@linkcode Frame | Frames} will need to be forwarded to the Media Encoder.
*
* - When `enableGpuBuffers` is `false`, the Video Pipeline will use CPU buffers causing an additional copy
* from the Frame Processor to the Media Encoder, which potentially results in increased latency.
* - When `enableGpuBuffers` is `true`, the Video Pipeline will use shared GPU buffers which greatly increases
* it's efficiency as an additional buffer copy is avoided.
* (See [`USAGE_GPU_SAMPLED_IMAGE`](https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE))
*
* In general, it is recommended to set this to `true` if possible, as this can increase performance and efficiency of the Video Pipeline.
*
* @experimental This is an experimental feature flag, use at your own risk. Some devices (especially Samsungs) may crash when trying to use GPU buffers.
* @platform Android (API 29+)
* @default false
*/
enableGpuBuffers?: boolean
/**
* Enables or disables low-light boost on this camera device.
*
@@ -227,6 +246,7 @@ export interface CameraProps extends ViewProps {
* * Dual Device fusion for greater detail ([`isDualCameraDualPhotoDeliveryEnabled`](https://developer.apple.com/documentation/avfoundation/avcapturephotosettings/2873917-isdualcameradualphotodeliveryena))
* * Sets the maximum quality prioritization to `.quality` ([`maxPhotoQualityPrioritization`](https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/3182995-maxphotoqualityprioritization))
*
* @platform iOS
* @default false
*/
enableHighQualityPhotos?: boolean

View File

@@ -12,6 +12,7 @@ export type CodeType =
| 'ean-8'
| 'itf'
| 'upc-e'
| 'upc-a'
| 'qr'
| 'pdf-417'
| 'aztec'

View File

@@ -44,6 +44,14 @@ export interface TakePhotoOptions {
* @default true
*/
enableShutterSound?: boolean
/**
* Whether to run the pre-capture sequence to properly lock AF, AE and AWB values.
* Enabling this results in greater photos, but might not work on some devices.
*
* @platform Android
* @default false
*/
enablePrecapture?: boolean
}
/**

View File

@@ -1,9 +1,17 @@
import { Dimensions } from 'react-native'
import { FormatFilter } from './getCameraFormat'
type TTemplates = {
[key: string]: FormatFilter[]
}
type PredefinedTemplates =
| 'Video'
| 'Video60Fps'
| 'VideoSlowMotion'
| 'VideoStabilized'
| 'Photo'
| 'PhotoPortrait'
| 'FrameProcessingYUV'
| 'FrameProcessingRGB'
| 'Snapchat'
| 'Instagram'
const SnapchatResolution = { width: 1920, height: 1080 }
const InstagramResolution = { width: 3840, height: 2160 }
@@ -16,7 +24,7 @@ const ScreenAspectRatio = Dimensions.get('window').height / Dimensions.get('wind
* const format = useCameraFormat(device, Templates.Snapchat)
* ```
*/
export const Templates: TTemplates = {
export const Templates: Record<PredefinedTemplates, FormatFilter[]> = {
/**
* Highest resolution video recordings (e.g. 4k)
*/