Skip to content

feat!: feed the mixer from a VisionCamera output - #1

Merged
bhyoo99 merged 4 commits into
mainfrom
feat/vision-camera
Sep 23, 2026
Merged

bhyoo99 merged 4 commits into
mainfrom
feat/vision-camera

Conversation

@bhyoo99

@bhyoo99 bhyoo99 commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Summary

The library no longer opens the camera itself. VisionCamera (v5) owns the camera session, and the stream plugs into it as a CameraOutput that feeds the mixer.

Breaking change: CameraSource is replaced by CameraLayer.

API

  • createCameraSource() → createCameraLayer(). The layer exposes output (a VisionCamera CameraOutput), isFrontCamera and isReceivingFrames.
  • useRtmpStream returns cameraOutput for <Camera outputs={[stream.cameraOutput]}>. The camera option, stream.camera, flipCamera() and setCameraPosition() are removed; switch cameras by changing VisionCamera's device.
  • Camera permission is VisionCamera's (useCameraPermission); requestStreamPermissions only handles the microphone.
  • The native preview view is renamed RtmpPreviewView to avoid clashing with VisionCamera's PreviewView. The JS export names are unchanged.
  • react-native-vision-camera ^5.2.3 is a new peer dependency (it brings react-native-nitro-image).

iOS

  • RtmpCameraOutput: an AVCaptureVideoDataOutput added to VisionCamera's session. BGRA frames are rotated to outputOrientation and never mirrored.
  • Frames still go through the mixer's one-slot queue. If no frame arrives for 700 ms, the mixer falls back to timer mode.

Android

  • RtmpCameraOutput: a CameraX Preview use case that renders straight into a mixer SurfaceTexture, so frames stay on the GPU.
  • Every SurfaceRequest gets a new CameraSurface, released only once both CameraX (the request result) and the mixer (retire) are done with it.
  • VisionCamera is linked via prefab, and camera-core is added.

Migration

Documented in README → "Migrating from 0.3".

Test plan

  • yarn jest (32 tests) and tsc pass
  • iOS device: preview, publish, front/back switch, rotation
  • Android device: the same, plus stopping the camera (isActive={false}) while publishing, to check that the stream continues via timer frames

Follow-ups

  • Android: make the CameraX dependency compileOnly so this library never changes the version VisionCamera resolves.
  • Android: request.camera is a restricted API; widen the catch (or use a public API) to survive CameraX alpha changes.
  • ready no longer waits for camera frames, so the first published frames may be timer frames until the camera delivers.

…mera

The library no longer captures the camera itself. `CameraLayer` owns a
VisionCamera 5 `CameraOutput` (an AVCaptureVideoDataOutput on iOS, a CameraX
Preview use case drawing into the mixer's SurfaceTexture on Android) that
VisionCamera negotiates, rotates, starts and stops with its session. Frames
still go from the camera to the mixer natively; JavaScript only hands
`stream.cameraOutput` to `<Camera outputs>`.

- Remove CameraSource (AVCaptureSession / Camera2), camera permission
  handling and the `camera`, `flipCamera`, `setCameraPosition` hook API
- Add `createCameraLayer()`, `RtmpStream.cameraOutput`; the hook requests the
  microphone permission only
- Rename the native view to `RtmpPreviewView` (VisionCamera registers
  `PreviewView`); the JS `PreviewView` and `RtmpPreview` names stay
- Android: one SurfaceTexture per SurfaceRequest, released only after CameraX
  reports the surface unused and the mixer retired it
- Depend on react-native-vision-camera ^5.2.3 (pod, gradle module, prefab)
  and limit nitrogen to this package's specs (`**/node_modules`)
- Example app runs VisionCamera's Camera with the stream's output

BREAKING CHANGE: react-native-vision-camera (and its peer
react-native-nitro-image) is required. `useRtmpStream` no longer takes
`camera` and no longer exposes `camera`, `flipCamera` or `setCameraPosition`;
pass `stream.cameraOutput` to VisionCamera and switch cameras through its
`device` prop. `createCameraSource` is replaced by `createCameraLayer`.
- README: a "Migrating from 0.3" section mapping the removed camera API to
  VisionCamera's device, permission and constraints
- CONTRIBUTING: which VisionCamera surfaces the output may use, why nitrogen
  ignores nested node_modules, how to build the native library alone, and
  that camera streaming needs a device
@bhyoo99
bhyoo99 merged commit aa1abf7 into main Sep 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant