SkiaCameraProps
interface SkiaCameraProps extends CameraProps, PickRepresents props for a SkiaCamera.
Properties
allowBackgroundAudioPlayback?
optional allowBackgroundAudioPlayback?: booleanIf enabled, the device may play background audio,
possibly from another app (e.g. Apple Music) while
the CameraSession is active.
If disabled (the default), any playing audio will be
stopped while the CameraSession is active.
Note
If allowBackgroundAudioPlayback is true,
background audio may also be captured in Video recordings.
Default
falseInherited from
CameraSessionConfiguration.allowBackgroundAudioPlayback
allowHapticsAndSystemSoundsPlayback?
optional allowHapticsAndSystemSoundsPlayback?: booleanIf enabled, the device may play haptics/vibrations
and system sounds during while the CameraSession
is active.
If disabled (the default), all haptics and system
sounds will be muted while the CameraSession
is active.
Note
If allowHapticsAndSystemSoundsPlayback
is true, haptics or system sounds may also be captured
in Video recordings.
Haptics may also affect stabilization or focus operations.
Default
falseInherited from
CameraSessionConfiguration.allowHapticsAndSystemSoundsPlayback
constraints?
optional constraints?: Constraint[]Constraints (e.g. { fps: 60 }) that the Camera pipeline
will try to match when configuring the CameraSession.
See
CameraSessionConnection.constraints
Inherited from
device
device:
| CameraDevice
| CameraPositionThe CameraDevice to open, or a CameraPosition
(e.g. 'back') to auto-pick a matching device via
getCameraDevice(...).
See
Inherited from
enableDistortionCorrection?
optional enableDistortionCorrection?: booleanIf set to true, the camera pipeline may correct
areas of the image that may appear distorted - for
example the edges of a ultra-wide-angle camera,
at the cost of losing a small amount of field of view.
When enableDistortionCorrection is enabled
and the camera pipeline applies a crop around the edges,
the images will be upscaled to compensate for the artificial
zoom - set enableDistortionCorrection to false
if you want to avoid this overhead.
Throws
If the CameraDevice does not support distortion
correction - see supportsDistortionCorrection.
Default
trueInherited from
CameraControllerConfiguration.enableDistortionCorrection
enableLowLightBoost?
optional enableLowLightBoost?: booleanLow light boost allows the Camera pipeline to automatically extend exposure times (and effectively drop frame rate) to receive more light, if necessary.
Throws
If the CameraDevice does not support low-light-boost -
see supportsLowLightBoost.
Default
falseInherited from
CameraControllerConfiguration.enableLowLightBoost
enablePhysicalBufferRotation?
optional enablePhysicalBufferRotation?: booleanPhysically rotates buffers to the desired target CameraOrientation
and MirrorMode.
By default, it is disabled as Skia rotates and mirrors the
Frame via efficient GPU-based transforms.
Enabling this results in the Frame always being
upright and never mirrored.
Default
falseenablePreviewSizedOutputBuffers?
optional enablePreviewSizedOutputBuffers?: booleanConfigures the underlying CameraVideoOutput
to downscale Frames to a size suitable for
preview, such as the screen size.
This may be more efficient if the CameraSession
negotiated a high-resolution output, as Skia doesn't
have to operate on high-resolution Frames.
Ideally, configure a matching ResolutionBiasConstraint
upfront so no scaling would be necessary at any point
in the pipeline.
Default
falseenableSmoothAutoFocus?
optional enableSmoothAutoFocus?: booleanIf set to true, auto-focus will switch between
focus states much slower and smoother to appear
less intrusive in video recordings.
Throws
If the CameraDevice does not support
smooth auto focus - see supportsSmoothAutoFocus.
Default
falseInherited from
CameraControllerConfiguration.enableSmoothAutoFocus
exposure?
optional exposure?:
| number
| SharedValue<number>Sets the exposureBias value
declaratively.
You can also imperatively set the exposure bias via
setExposureBias(...).
Note
This property can be animated via Reanimated by passing a SharedValue.
Default
0Inherited from
getInitialExposureBias?
optional getInitialExposureBias?: () => number | undefinedA getter for the initial exposure bias to apply when the
CameraController is created. Later, the exposure bias can be
adjusted via CameraController.setExposureBias(...).
See
CameraSessionConnection.initialExposureBias
Inherited from
CameraProps.getInitialExposureBias
getInitialZoom?
optional getInitialZoom?: () => number | undefinedA getter for the initial zoom value to apply when the
CameraController is created. Later, the zoom can be
adjusted via CameraController.setZoom(...).
See
CameraSessionConnection.initialZoom
Inherited from
isActive
isActive: booleanStarts the CameraSession when set to true, and stops it
when set back to false.
See
Inherited from
mirrorMode?
optional mirrorMode?: MirrorModeSets whether the CameraOutputs are mirrored along
the vertical axis. 'auto' mirrors
automatically on selfie cameras.
See
CameraOutputConfiguration.mirrorMode
Default
'auto'Inherited from
onConfigured?
optional onConfigured?: () => voidCalled whenever the CameraSession
has been configured with new connections via
configure(...)
and connections to the individual outputs are formed.
This is a good place to check output
capabilities, such as CameraVideoOutput.getSupportedVideoCodecs()
Inherited from
onError?
optional onError?: (error: Error) => voidCalled whenever the CameraSession
has encountered an error.
See
CameraSession.addOnErrorListener
Inherited from
onFrame
onFrame: (frame: Frame, render: (onDraw: (state: SkiaOnFrameState) => void) => void) => voidCalled on every Frame with the current state.
Note
You must render the Frame to the Canvas yourself
via render, otherwise it'll just be a black screen.
Worklet
Example
onFrame(frame, render) {
'worklet'
render(({ frameTexture, canvas }) => {
canvas.drawImage(frameTexture, 0, 0)
})
frame.dispose()
}onInterruptionEnded?
optional onInterruptionEnded?: () => voidCalled when a previous interruption
has ended and the CameraSession
is running uninterrupted again.
See
CameraSession.addOnInterruptionEndedListener
Inherited from
CameraProps.onInterruptionEnded
onInterruptionStarted?
optional onInterruptionStarted?: (interruption: InterruptionReason) => voidCalled whenever the CameraSession
has encountered an interruption of the given
InterruptionReason.
Interruptions are temporarily.
See
CameraSession.addOnInterruptionStartedListener
Inherited from
CameraProps.onInterruptionStarted
onSessionConfigSelected?
optional onSessionConfigSelected?: (config: CameraSessionConfig) => voidCalled once the given constraints have been fully resolved
into a concrete CameraSessionConfig.
See
CameraSessionConnection.onSessionConfigSelected
Inherited from
CameraProps.onSessionConfigSelected
onStarted?
optional onStarted?: () => voidCalled when the CameraSession
has been started.
See
CameraSession.addOnStartedListener
Inherited from
onStopped?
optional onStopped?: () => voidCalled when the CameraSession
has been stopped.
See
CameraSession.addOnStoppedListener
Inherited from
onSubjectAreaChanged?
optional onSubjectAreaChanged?: () => voidCalled when the subject area substantially changes, e.g. when the user pans away from a scene that was previously in focus.
This is a good point to reset any locked AE/AF/AWB focus states back to continuously auto-focus.
See
CameraController.addSubjectAreaChangedListener
Inherited from
CameraProps.onSubjectAreaChanged
orientationSource?
optional orientationSource?:
| "custom"
| OrientationSourceSet a desired OrientationSource
for automatically applying CameraOrientation
to all outputs, or 'custom' if you
prefer to manually specify CameraOrientation
yourself.
See
CameraOutput.outputOrientation
Inherited from
outputs?
optional outputs?: CameraOutput[]The CameraOutputs the device will stream into.
See
Inherited from
pixelFormat?
optional pixelFormat?: TargetVideoPixelFormatSelects the TargetVideoPixelFormat for the
Frame Output using the Skia rendering pipeline.
It is recommended to use 'native'
if the negotiated CameraSessionConfig's
nativePixelFormat
is supported by Skia as this is a zero-copy GPU-only path.
Only resort back to 'yuv'
(or possibly even 'rgb') if
CPU-based Frame access is required.
Note
Use 'native' with caution,
as the device's native format could be a format that is not
supported by Skia - for example
'raw-bayer-packed96-12-bit'.
The 'private' pixel format is the
most efficient GPU-only pixel format supported by Skia.
Default
'native' or 'yuv'ref?
optional ref?: Ref<SkiaCameraRef>A reference to a SkiaCamera.
See
targetResolution?
optional targetResolution?: SizeThe target Resolution to use for the
CameraFrameOutput driving the Skia
Camera.
Discussion
The Skia Camera's Preview is driven by a Skia Canvas
that renders Frames from a CameraFrameOutput.
The targetResolution therefore affects both the
Frame's size (via onFrame(...)),
as well as the Preview's resolution at the same time.
If enablePreviewSizedOutputBuffers is enabled,
resolution is capped to the screen's size.
As with all target resolutions, actual resolutions are negotiated across Constraints and outputs, and may not be an exact match with the specified target resolution.
torchMode?
optional torchMode?: TorchModeSets the torchMode value
declaratively.
Default
'off'Inherited from
warnIfRenderSkipped?
optional warnIfRenderSkipped?: booleanWarns the developer if the onFrame(...)
callback did not call render(...).
Disable this if you intentionally want to skip a render.
Default
truezoom?
optional zoom?:
| number
| SharedValue<number>Sets the zoom value declaratively.
You can also imperatively set zoom via
setZoom(...).
Note
This property can be animated via Reanimated by passing a SharedValue.
Default
1