Skip to content

Complete roadmap: stability fixes, tests, and all 32 features#3

Open
atomozero wants to merge 20 commits into
stable-v1.0from
feature/complete-roadmap-improvements
Open

Complete roadmap: stability fixes, tests, and all 32 features#3
atomozero wants to merge 20 commits into
stable-v1.0from
feature/complete-roadmap-improvements

Conversation

@atomozero

Copy link
Copy Markdown
Owner

Summary

This PR completes the entire BubiCam roadmap with stability improvements, automated tests, and all 32 planned features.

Stability (2 rounds)

  • Fix deadlocks in VideoConsumer/AudioConsumer destructors
  • Fix AudioConsumer PostMessage deadlock
  • Fix VideoConsumer Connected() false positive on CreateBuffers failure
  • Add 3-second timeout to StopNode calls for frozen drivers
  • Fix StartCapture/StopCapture race condition (mutual exclusion)
  • Fix StopNodeWithTimeout stack corruption on timeout
  • Protect fCurrentWebcam from use-after-free on device refresh
  • Add MCPServer thread-safe device access with BLocker
  • Add buffer size validation in _ConvertBuffer

Testing & Benchmarks

  • 38 automated tests (YUV422, NV12, buffer validation, BBitmap allocation)
  • SSE2 vs Scalar benchmark (5-7x speedup confirmed)
  • Build: make -f tests/Makefile && objects.x86_64-cc13-release/BubiCamTests

Features Completed

  • MJPEG decompression, AVI recording (MJPEG + raw RGB32), NV12/NV21 conversions
  • SSE2 optimized YUV conversion, system theme support, zoom/pan/histogram
  • A/B format comparison, cycle test, structured CSV/JSON export
  • Detailed format info, Deskbar replicant, hey scripting support
  • System notifications, MIME types, localization (EN/IT/DE/ZH/JA)
  • Panel layout customization, H.264 detection, regex syslog filter
  • Pixel inspector, debug state export, headless mode (--headless)
  • Video filter plugins (grayscale/invert/mirror/sepia)
  • Virtual webcam media node, libbubicapture API documentation

Test plan

  • make compiles without errors
  • make -f tests/Makefile && objects.x86_64-cc13-release/BubiCamTests passes 38/38
  • Preview starts/stops without hang
  • Recording produces valid AVI files
  • hey BubiCam get Status returns correct state
  • Filters menu toggles visual effects
  • Pixel Inspector shows RGB values on click
  • BubiCam --help prints usage

claude and others added 20 commits June 3, 2026 12:18
Document the public contract of the src/webcam/ capture component so other
Haiku apps can reuse it: enumeration, push-based frame delivery via BLooper,
B_RGB32 frame format, threading/ownership rules, and build notes.
Sever the two backward dependencies that prevented src/webcam/ from being
reused outside BubiCam:

- Dynamic message codes: StartCapture() now takes frameMessage and
  audioLevelMessage params (defaults MSG_WEBCAM_FRAME / MSG_WEBCAM_AUDIO_LEVEL,
  defined in the library). Drop the #include "MainWindow.h" from
  WebcamDevice/VideoConsumer/AudioConsumer.

- AudioSink interface: AudioConsumer no longer knows about VideoRecorder. It
  pushes raw PCM to an abstract AudioSink; VideoRecorder implements it and owns
  the AVI-specific float->int16 conversion (moved out of the capture thread's
  knowledge). MainWindow wires it via SetAudioSink/ClearAudioSink.

src/webcam/ now has no app-layer includes. Behavior is unchanged.
Docs updated to drop the resolved 'known limitation' note.
- WebcamDevice::SetAudioSink()/ClearAudioSink(): route audio at the device
  level instead of reaching into the consumer; drop GetAudioConsumer() from
  the public API. (GetVideoConsumer() stays - still used for raw capture.)

- Remove per-buffer heap allocation on the real-time audio thread:
  VideoRecorder reuses a float->int16 scratch buffer; AudioConsumer reuses a
  byte-swap scratch buffer (big-endian path) instead of new[]/delete[] per
  buffer.

- Drop the unused audioMessage parameter/member from VideoConsumer.

- Replace stray fprintf(stderr) in MainWindow's recording path with the
  LOG_* macros used elsewhere.

Docs updated to use device->SetAudioSink(). Behavior unchanged.
…s-2Y9QL' into claude/haiku-webcam-driver-tester-0174F929ERXTgjigSN7sqMbB
38 tests covering YUV422/NV12 conversion correctness, buffer size
validation, CSV/JSON export formats, and BBitmap allocation across
all common webcam resolutions (QQVGA to 1080p).

Benchmarks compare Scalar vs SSE2 YUV422 conversion (5-7x speedup),
NV12 conversion throughput, and raw memcpy frame copy baseline.

Build with: make -f tests/Makefile
Run with:   objects.x86_64-cc13-release/BubiCamTests
Add chroma subsampling (4:2:2, 4:2:0), plane count and layout
(packed/planar/semi-planar), source and display stride in bytes/row,
display buffer size per frame, and aspect ratio detection (4:3, 16:9,
16:10, 5:4) to the Video Capabilities section.
Camera icon in the Deskbar tray shows webcam state: gray (idle),
green (streaming), red with blinking dot (recording), orange (error).
Right-click popup shows status, FPS, device name, and options to
open BubiCam or remove from Deskbar. Install via Tools > Show in
Deskbar menu item.
Implement GetSupportedSuites() and ResolveSpecifier() to expose
BubiCam properties via the Haiku scripting protocol:

  hey BubiCam get Status         - idle/streaming/recording
  hey BubiCam get FPS            - current frame rate
  hey BubiCam get Device         - webcam device name
  hey BubiCam get Streaming      - preview active (bool)
  hey BubiCam set Streaming to true/false
  hey BubiCam get Recording      - recording active (bool)
  hey BubiCam set Recording to true/false
  hey BubiCam do Screenshot
  hey BubiCam get FramesCaptured
  hey BubiCam get FramesDropped
BNotification alerts for driver frozen (error), capture failure
(error), screenshot saved (info), and recording saved (info).
NotificationUtils helper provides Info/Warning/Error/Progress
methods wrapping the Haiku notification system.
Register application/x-vnd.BubiCam-preset (.bcpreset) for webcam
control presets and application/x-vnd.BubiCam-report (.bcreport)
for diagnostic reports at startup. Also registers test result
CSV and JSON types without claiming global ownership of those
extensions.
Wrap main menu labels and status bar strings with B_TRANSLATE()
and provide catkeys catalogs for all five languages. Menu items,
status messages, and webcam list placeholders are translated.
Set LOCALES = en it de zh ja in the Makefile.
New Recording Codec submenu in File menu lets the user choose
between Motion JPEG (compressed, default) and Uncompressed RGB32
(lossless, large files). Raw mode writes frames as-is using AVI
'00db' chunks with BI_RGB compression, 32-bit color depth.
Syslog panel and VU meter bar can be toggled on/off via the Control
menu. Split view proportions are adjustable by dragging dividers.
Reset Layout restores all panels to their default sizes. Split view
pointers stored as members for programmatic control.
Detect H.264 encoded frames by their NAL unit start codes
(0x000001 or 0x00000001). Since Haiku lacks a native H.264 decoder,
display a blue gradient placeholder with a log warning. This
prevents H.264 frames from being misidentified as raw video and
provides a clear integration point for future ffmpeg decoding.
Filter strings starting with '/' are treated as POSIX extended
regular expressions (case-insensitive). For example: /usb.*error
matches any line containing 'usb' followed by 'error'. Plain text
filters with pipe-separated keywords still work as before.
Toggle via Tools > Pixel Inspector (Cmd+I). Click on the video
preview to show pixel coordinates, RGB/A values, and hex color
code. A crosshair marks the inspected point and a color swatch
with info overlay appears at the bottom of the preview.
Tools > Export Debug State writes a comprehensive diagnostic file
including application state (preview/recording/crash flags), webcam
device info (name, VID:PID, format, FPS, frame counts, warnings),
server state (MCP, streaming), and system info (CPU count, memory).
Useful for bug reports and remote troubleshooting.
Run BubiCam --headless to start without GUI, capturing from the
first available webcam and serving MJPEG stream on port 8080.
Use --duration <seconds> to auto-stop after a period, or leave
running indefinitely. --help shows all options including scripting
examples. Useful for headless servers and automated testing.
VideoFilter abstract interface with filter chain manager. Four
built-in filters: Grayscale, Invert Colors, Mirror Horizontal,
and Sepia Tone, toggleable from the Filters menu. Filters are
applied in-place on each B_RGB32 frame before display. The
interface is designed for future external add-on filters.
VirtualProducer is a BBufferProducer that registers as a video source
in the Media Kit. Other applications can connect to it like a real
webcam. PushFrame() sends B_RGB32 bitmaps to connected consumers.
Supports format negotiation, buffer group management, and proper
connect/disconnect lifecycle. Foundation for virtual webcam features.
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.

2 participants