Screen share 3: fluxer-capture crate — traits, model types, fake backend #150

Closed
opened 2026-11-12 02:06:53 +00:00 by charles · 0 comments
Owner

Files:

  • Create: crates/fluxer-capture/{Cargo.toml,README.md}, src/{lib.rs,source.rs,screen.rs,audio.rs,fake.rs,error.rs}
  • Modify: workspace Cargo.toml (member)
  • Test: crates/fluxer-capture/tests/fake.rs

Interfaces:

  • Produces: SourceKind::{Screen, Window, SystemPicker}; CaptureSource { id: String, kind, title: String, app_name: Option<String>, pid: Option<u32>, thumbnail: Option<VideoFrame> }; CaptureTarget { max_width, max_height, fps }; trait ScreenCapturer: Send { fn capabilities(&self) -> CaptureCapabilities { in_app_picker: bool, window_audio: bool }, fn list_sources(&mut self, thumbnails: bool) -> Result<Vec<CaptureSource>, CaptureError>, fn start(&mut self, source: &SourceChoice, target: CaptureTarget, sink: Box<dyn FnMut(CaptureOutput) + Send>) -> Result<(), CaptureError>, fn switch(&mut self, source: &SourceChoice), fn update(&mut self, target: CaptureTarget), fn stop(&mut self) }; SourceChoice::{Source(String), SystemPicker}; CaptureOutput::{Frame(VideoFrame), Started { width, height }, Stalled, Resumed, Ended(EndReason), Error(String)}; AudioRule { mode: System | Applications(Vec<AppMatch>), only_speakers, only_default_speakers, ignore_devices, ignore_input_media, ignore_virtual } (defaults of spec §9); StreamAudioFrame { samples: Vec<i16>, channels: 2 } (10 ms, 48 kHz); trait StreamAudioCapturer: Send { start(rule, exclude_pid_tree: u32, sink), set_rule, stop }; FakeScreenCapturer / FakeAudioCapturer + FakeCaptureControl (sources list, scripted end/stall, test pattern at the target size and rate, 440 Hz stereo tone) behind feature fake; fn default_backends() -> (Box<dyn ScreenCapturer>, Box<dyn StreamAudioCapturer>) returning Unsupported stubs until Tasks 4/5/14/15 fill them.

  • Step 1: Write failing tests: fake_delivers_frames_at_target_rate_and_size, fake_switch_changes_source_without_ended, scripted_end_is_reported_once, stall_and_resume_after_3s_without_frames, stop_is_idempotent, fake_audio_delivers_10ms_stereo_frames, unsupported_backends_return_errors.

  • Step 2–5: FAIL → implement → PASS → commit feat(capture): capture traits and fake backends.

Depends on: Screen share 1 (#148)

Plan: https://git.forked.io/charles/fluxer-native/src/branch/main/docs/superpowers/plans/2026-11-11-screenshare.md
Spec: https://git.forked.io/charles/fluxer-native/src/branch/main/docs/superpowers/specs/2026-11-11-fluxer-native-screenshare-design.md

**Files:** - Create: `crates/fluxer-capture/{Cargo.toml,README.md}`, `src/{lib.rs,source.rs,screen.rs,audio.rs,fake.rs,error.rs}` - Modify: workspace `Cargo.toml` (member) - Test: `crates/fluxer-capture/tests/fake.rs` **Interfaces:** - Produces: `SourceKind::{Screen, Window, SystemPicker}`; `CaptureSource { id: String, kind, title: String, app_name: Option<String>, pid: Option<u32>, thumbnail: Option<VideoFrame> }`; `CaptureTarget { max_width, max_height, fps }`; `trait ScreenCapturer: Send` { `fn capabilities(&self) -> CaptureCapabilities { in_app_picker: bool, window_audio: bool }`, `fn list_sources(&mut self, thumbnails: bool) -> Result<Vec<CaptureSource>, CaptureError>`, `fn start(&mut self, source: &SourceChoice, target: CaptureTarget, sink: Box<dyn FnMut(CaptureOutput) + Send>) -> Result<(), CaptureError>`, `fn switch(&mut self, source: &SourceChoice)`, `fn update(&mut self, target: CaptureTarget)`, `fn stop(&mut self)` }; `SourceChoice::{Source(String), SystemPicker}`; `CaptureOutput::{Frame(VideoFrame), Started { width, height }, Stalled, Resumed, Ended(EndReason), Error(String)}`; `AudioRule { mode: System | Applications(Vec<AppMatch>), only_speakers, only_default_speakers, ignore_devices, ignore_input_media, ignore_virtual }` (defaults of spec §9); `StreamAudioFrame { samples: Vec<i16>, channels: 2 }` (10 ms, 48 kHz); `trait StreamAudioCapturer: Send` { `start(rule, exclude_pid_tree: u32, sink)`, `set_rule`, `stop` }; `FakeScreenCapturer` / `FakeAudioCapturer` + `FakeCaptureControl` (sources list, scripted end/stall, test pattern at the target size and rate, 440 Hz stereo tone) behind feature `fake`; `fn default_backends() -> (Box<dyn ScreenCapturer>, Box<dyn StreamAudioCapturer>)` returning `Unsupported` stubs until Tasks 4/5/14/15 fill them. - [ ] **Step 1: Write failing tests**: `fake_delivers_frames_at_target_rate_and_size`, `fake_switch_changes_source_without_ended`, `scripted_end_is_reported_once`, `stall_and_resume_after_3s_without_frames`, `stop_is_idempotent`, `fake_audio_delivers_10ms_stereo_frames`, `unsupported_backends_return_errors`. - [ ] **Step 2–5:** FAIL → implement → PASS → commit `feat(capture): capture traits and fake backends`. Depends on: Screen share 1 (#148) Plan: https://git.forked.io/charles/fluxer-native/src/branch/main/docs/superpowers/plans/2026-11-11-screenshare.md Spec: https://git.forked.io/charles/fluxer-native/src/branch/main/docs/superpowers/specs/2026-11-11-fluxer-native-screenshare-design.md
charles added this to the Screen share milestone 2026-11-12 02:06:53 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#150
No description provided.