Skip to main content
Version: Next

Function: useVisionCameraSource()

useVisionCameraSource<SourceId>(sourceId, options): UseVisionCameraSourceResult

Defined in: react-native-vision-camera-source/src/useVisionCameraSource.ts:89

Publishes your VisionCamera feed to Fishjam.

A sibling of useCustomSource: the hook creates the video track, publishes it under sourceId, and cleans everything up on unmount. Each camera frame is handed to Fishjam without copying its pixels. Must be used under FishjamProvider.

const { frameOutput, stream } = useVisionCameraSource('my-camera'); useVisionCamera({ device: cameraDevice, isActive: true, outputs: [frameOutput] }); return stream ? <RTCView mediaStream={stream} objectFit="cover" /> : null;

To also run inference on the same frames, pass an onFrame worklet. To render your own content into the published video with WebGPU, use useVisionCameraWebGpuSource from @fishjam-cloud/react-native-vision-camera-source/webgpu instead.

Type Parameters​

Type Parameter
SourceId extends string

Parameters​

ParameterTypeDescription
sourceIdSourceIdIdentifies this source among the peer's tracks, like in useCustomSource.
optionsUseVisionCameraSourceOptionsSee UseVisionCameraSourceOptions.

Returns​

UseVisionCameraSourceResult