Skip to main content

Function: useCamera()

useCamera(): object

This hook can toggle camera on/off and provides current camera state.

Returns

object

cameras

cameras: readonly Camera[]

Property that lists cameras available on device.

Returns

A promise that resolves to the list of available cameras.

currentCamera

currentCamera: null | Camera

Which camera is now used for streaming (or will be used as default when camera will be enabled)

isCameraOn

isCameraOn: boolean

Informs if user camera is streaming video

prepareCamera()

prepareCamera: (config) => Promise<boolean>

Prepares camera and starts local video track

Parameters

ParameterTypeDescription
configReadonly<CameraConfig>configuration of the camera capture

Returns

Promise<boolean>

A promise that resolves when camera is started.

setVideoTrackBandwidth()

setVideoTrackBandwidth: (bandwidth) => Promise<void>

updates maximum bandwidth for the video track. This value directly translates to quality of the stream and the amount of RTP packets being sent. In case simulcast is enabled bandwidth is split between all of the variant streams proportionally to their resolution.

Parameters

ParameterType
bandwidthnumber

Returns

Promise<void>

Deprecated

setVideoTrackEncodingBandwidth()

setVideoTrackEncodingBandwidth: (encoding, bandwidth) => Promise<void>

Updates maximum bandwidth for the given simulcast encoding of the video track

Parameters

ParameterTypeDescription
encodingTrackEncodingencoding to update
bandwidthnumberBandwidthLimit to set

Returns

Promise<void>

Deprecated

simulcastConfig

simulcastConfig: SimulcastConfig

Simulcast configuration

switchCamera()

switchCamera: (cameraId) => Promise<void>

Switches to the specified camera. List of available devices can be retrieved from cameras variable

Parameters

ParameterType
cameraIdCameraId

Returns

Promise<void>

A promise that resolves when camera is switched.

toggleCamera()

toggleCamera: () => Promise<void>

Enable/disable current camera

Returns

Promise<void>

toggleVideoTrackEncoding()

toggleVideoTrackEncoding: (encoding) => Promise<void>

Parameters

ParameterTypeDescription
encodingTrackEncodingencoding to toggle

Returns

Promise<void>

Deprecated

Toggles encoding of a video track on/off

Defined in

packages/react-native-client/src/hooks/useCamera.ts:160