Skip to content

fix: implement DirectShow capture pipeline and wire preview#35

Merged
webbertakken merged 10 commits intomainfrom
fix/preview-pipeline
Feb 27, 2026
Merged

fix: implement DirectShow capture pipeline and wire preview#35
webbertakken merged 10 commits intomainfrom
fix/preview-pipeline

Conversation

@webbertakken
Copy link
Owner

Summary

  • Implement DirectShow filter graph (Source -> SampleGrabber -> NullRenderer) with manually defined COM vtables for ISampleGrabber/ISampleGrabberCB
  • BGR24 bottom-up to RGB24 top-down frame conversion in callback
  • Spawn capture thread in CaptureSession::new() on Windows
  • Resolve device_id to device_path in start_preview command
  • Auto-start/stop preview when camera is selected/deselected in App.tsx
  • Show "No adjustable controls" when camera returns empty controls list
  • Add get_diagnostics IPC command for diagnostic overlay

Test plan

  • 124 Rust tests pass (cargo test --lib)
  • 169 frontend tests pass (yarn test)
  • Clippy clean (cargo clippy -- -D warnings)
  • ESLint clean (yarn lint)
  • TypeScript clean (yarn typecheck)
  • Formatting clean (cargo fmt, prettier)
  • Manual test: verify camera preview displays in the app
  • Manual test: verify controls panel shows controls or empty state

- Build Source -> SampleGrabber -> NullRenderer filter graph
- Implement ISampleGrabberCB for frame delivery via raw COM vtables
- Convert BGR24 bottom-up to RGB24 top-down in callback
- Spawn capture thread in CaptureSession::new() on Windows
- Resolve device_id to device_path in start_preview command
- Add get_diagnostics IPC command for diagnostic overlay
- Auto-start preview when camera is selected, stop on change/deselect
- Show "No adjustable controls" when camera has no controls
- Add tests for both behaviours
Previously hotplug_wnd_proc only logged device arrival/removal without
re-enumerating or invoking the callback. Now it stores HotplugContext
via GWLP_USERDATA and calls handle_device_change on WM_DEVICECHANGE
to diff devices and fire Connected/Disconnected events.
DiagnosticStats is now tracked in the capture session and updated by
the ISampleGrabberCB callback on every frame. get_diagnostics returns
the real snapshot instead of placeholder values.
error and info macros are only used inside #[cfg(target_os = "windows")]
blocks, so the import must be gated too to avoid unused import warnings
on Linux CI.
… resolution

- Use IGraphBuilder::Connect instead of ConnectDirect so DirectShow
  inserts colour-space converters for MJPG/YUY2 cameras
- Set running flag BEFORE IMediaControl::Run to avoid dropping the
  first frames
- Query actual negotiated resolution from SampleGrabber's connected
  media type instead of assuming the requested size matches
- Add tracing::error/warn logging throughout the capture graph so
  failures are visible in the yarn dev terminal
- Add `log-always` feature to tracing crate so tracing macros forward
  to the log facade (consumed by tauri-plugin-log)
- Fix clippy: remove assert!(true), use arrays instead of vec! in tests
@webbertakken
Copy link
Owner Author

/update-snapshots

@webbertakken
Copy link
Owner Author

/update-snapshots

@webbertakken webbertakken merged commit b8d2293 into main Feb 27, 2026
10 of 11 checks passed
@webbertakken webbertakken deleted the fix/preview-pipeline branch February 27, 2026 01:31
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