Camera 12: apps/fluxer camera runtime, and the camera sounds (#964) #986

Closed
charles wants to merge 0 commits from camera-12-appsfluxer-camera-runtime-and into camera
Owner

What this builds (Camera plan Task 12; spec §5.5, §13, §15)

  • apps/fluxer/src/camera_rt.rs: CameraRuntime, a worker thread owning the CameraCapturer (as capture_rt). Effect::Camera → the capturer; CameraOutput → CoreEvent::Camera; start errors mapped to CameraFailure. Frames go through a FrameFilter slot (Identity; spec §15's seam for background effects) to FrameBus[LocalCamera] always, and to VoiceHandle::push_camera only while published: the runtime sets the gate from voice.camera.is_published() after every event, before that event's effects run (so an UnpublishCamera finds it already closed). The bus key is removed on Stop and on Ended.
  • Release: CameraRuntime::shutdown() is called right after the main loop ends, before the shortcuts, the install-on-quit wait, the gateway close and the storage flush; Drop does the same, so an aborted or panicking runtime task releases the device.
  • CameraBackend (system() = fluxer_capture::camera::default_camera(), fake(control), unsupported(reason), info()), Runtime::with_camera_backend, --camera-fake (feature capture-fake; the fake is always used with --devserver), exported from lib.rs.
  • --debug-info: camera: <back end or unavailable: reason> and one camera device: <name> line per camera (names only, never ids). Listing opens nothing.
  • Remote cameras: voice_rt's VideoRouting is now keyed by (identity, TrackSource). SetSubscribed for Camera routes that camera's frames to Remote { sid }, apart from the watched shares. A camera never stands in for a share, and it never reaches the stream-preview uploader, which reads LocalCapture only.
  • Sounds: fluxer-audio Chime::{CameraOn, CameraOff} (appended; ALL is now 15). The files are camera-on.mp3 / camera-off.mp3, copied unchanged from the fork's fluxer_app/src/media/sounds/ (named in features/notification/utils/SoundUtils.ts:45-46). audio_rt::engine_chime now always returns an engine chime.

Deviations from the plan

  • Listing on login. fluxer-core never sends CameraCommand::List/Watch, and it applies CameraEvent::Devices only while an account is logged in. So the worker lists and watches at startup (that list is dropped before login), and the runtime asks for List again when an account logs in. None of these listings opens a device. It might be cleaner for the core to send List itself; that would be a core change, so I left it out of this task.
  • The plan names crates/fluxer-audio/assets/{camera-on,camera-off}.*. The files are in assets/sounds/, beside the other chimes.
  • main.rs needed no change.
  • I added one test that is not in the plan: remote_camera_reaches_bus_only_while_shown.

How it was tested

  • apps/fluxer/tests/camera_runtime.rs (fake camera, fake room, devserver camera scenario), 19 tests: frames_reach_bus_in_preview_and_room_only_when_published; open_now_is_zero_after_{turn_off,toggle_off,leave,room_lost,device_lost,publish_refused,preview_closed,runtime_dropped,shutdown_with_a_stuck_room}; listing_at_startup_opens_nothing (and on hot-plug); nothing_opens_on_join_or_reconnect; device_change_restarts_on_new_device; preview_uploader_never_reads_camera; remote_camera_reaches_bus_only_while_shown; share_and_camera_run_together; log_and_recording_hold_no_frame_bytes (a run of the pattern's luma bytes, raw and as Debug prints them, is searched for in the debug-level log and in every --record file); debug_info_names_backend_and_devices; camera_chimes_play.
  • Unit tests: error mapping, the identity filter, the source-keyed routing (cameras_and_shares_are_routed_by_their_source), --camera-fake parsing, and the chime table.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passed locally. I ran no FLUXER_DESKTOP_TESTS test, opened no camera, and never ran the client.

For Charles to check

  • With a real camera: the light comes on only when you open the preview or turn the camera on. It goes off within a second of turning off, leaving the call, closing the preview, and quitting (the quit path stops the camera first).
  • flaxative --debug-info lists your camera by name, with no path or serial.
  • Windows: this task adds no cfg(windows) code. The back end name comes from cfg! in a const.

Closes #964

🤖 Generated with Claude Code

https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K

## What this builds (Camera plan Task 12; spec §5.5, §13, §15) - `apps/fluxer/src/camera_rt.rs`: `CameraRuntime`, a worker thread owning the `CameraCapturer` (as `capture_rt`). `Effect::Camera` → the capturer; `CameraOutput` → `CoreEvent::Camera`; start errors mapped to `CameraFailure`. Frames go through a `FrameFilter` slot (`Identity`; spec §15's seam for background effects) to `FrameBus[LocalCamera]` always, and to `VoiceHandle::push_camera` only while published: the runtime sets the gate from `voice.camera.is_published()` after every event, before that event's effects run (so an `UnpublishCamera` finds it already closed). The bus key is removed on `Stop` and on `Ended`. - Release: `CameraRuntime::shutdown()` is called right after the main loop ends, before the shortcuts, the install-on-quit wait, the gateway close and the storage flush; `Drop` does the same, so an aborted or panicking runtime task releases the device. - `CameraBackend` (`system()` = `fluxer_capture::camera::default_camera()`, `fake(control)`, `unsupported(reason)`, `info()`), `Runtime::with_camera_backend`, `--camera-fake` (feature `capture-fake`; the fake is always used with `--devserver`), exported from `lib.rs`. - `--debug-info`: `camera: <back end or unavailable: reason>` and one `camera device: <name>` line per camera (names only, never ids). Listing opens nothing. - Remote cameras: `voice_rt`'s `VideoRouting` is now keyed by (identity, `TrackSource`). `SetSubscribed` for `Camera` routes that camera's frames to `Remote { sid }`, apart from the watched shares. A camera never stands in for a share, and it never reaches the stream-preview uploader, which reads `LocalCapture` only. - Sounds: `fluxer-audio` `Chime::{CameraOn, CameraOff}` (appended; `ALL` is now 15). The files are `camera-on.mp3` / `camera-off.mp3`, copied unchanged from the fork's `fluxer_app/src/media/sounds/` (named in `features/notification/utils/SoundUtils.ts:45-46`). `audio_rt::engine_chime` now always returns an engine chime. ## Deviations from the plan - **Listing on login.** `fluxer-core` never sends `CameraCommand::List`/`Watch`, and it applies `CameraEvent::Devices` only while an account is logged in. So the worker lists and watches at startup (that list is dropped before login), and the runtime asks for `List` again when an account logs in. None of these listings opens a device. It might be cleaner for the core to send `List` itself; that would be a core change, so I left it out of this task. - The plan names `crates/fluxer-audio/assets/{camera-on,camera-off}.*`. The files are in `assets/sounds/`, beside the other chimes. - `main.rs` needed no change. - I added one test that is not in the plan: `remote_camera_reaches_bus_only_while_shown`. ## How it was tested - `apps/fluxer/tests/camera_runtime.rs` (fake camera, fake room, devserver `camera` scenario), 19 tests: `frames_reach_bus_in_preview_and_room_only_when_published`; `open_now_is_zero_after_{turn_off,toggle_off,leave,room_lost,device_lost,publish_refused,preview_closed,runtime_dropped,shutdown_with_a_stuck_room}`; `listing_at_startup_opens_nothing` (and on hot-plug); `nothing_opens_on_join_or_reconnect`; `device_change_restarts_on_new_device`; `preview_uploader_never_reads_camera`; `remote_camera_reaches_bus_only_while_shown`; `share_and_camera_run_together`; `log_and_recording_hold_no_frame_bytes` (a run of the pattern's luma bytes, raw and as `Debug` prints them, is searched for in the debug-level log and in every `--record` file); `debug_info_names_backend_and_devices`; `camera_chimes_play`. - Unit tests: error mapping, the identity filter, the source-keyed routing (`cameras_and_shares_are_routed_by_their_source`), `--camera-fake` parsing, and the chime table. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passed locally. I ran no `FLUXER_DESKTOP_TESTS` test, opened no camera, and never ran the client. ## For Charles to check - With a real camera: the light comes on only when you open the preview or turn the camera on. It goes off within a second of turning off, leaving the call, closing the preview, and quitting (the quit path stops the camera first). - `flaxative --debug-info` lists your camera by name, with no path or serial. - Windows: this task adds no `cfg(windows)` code. The back end name comes from `cfg!` in a const. Closes #964 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Refs #964

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
CameraRuntime drives the camera back end on a worker thread: Effect::Camera
to the CameraCapturer, its reports to CoreEvent::Camera, frames through an
identity FrameFilter slot to FrameBus[LocalCamera] always and to
VoiceHandle::push_camera only while the store says the room has the camera
published. The cameras are listed and watched at startup and listed again on
login (opening nothing); the runtime's shutdown closes the camera before
anything that can wait, and Drop does too. Remote video is routed by
RemoteVideo::source, so shown cameras reach Remote { sid } apart from the
watched shares. --camera-fake (feature capture-fake; always with
--devserver), Runtime::with_camera_backend, the camera lines of --debug-info,
and the camera-on / camera-off chimes, copied unchanged from the fork's
fluxer_app/src/media/sounds/.

Refs #964

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0161qMQMsCyJhjYw4gqa6e4K
Author
Owner

Merged into camera by hand (the merge API returns 405); the commits are in the branch.

Merged into `camera` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-20 04:11:47 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.