Add multi-backend capture with automatic fallback chain#29
Merged
infinityabundance merged 7 commits intomainfrom Feb 13, 2026
Merged
Add multi-backend capture with automatic fallback chain#29infinityabundance merged 7 commits intomainfrom
infinityabundance merged 7 commits intomainfrom
Conversation
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
- Moved capture and encoder init from main.c to service_run_host() - Made input init non-fatal to allow testing in restricted environments - Modified display detection to allow fallback when DRM unavailable - Verified fallback chain works: DRM → X11 → Dummy Pattern - Successfully tested dummy pattern backend in headless environment Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Code review identified that the backends array was local and would go out of scope, causing ctx->capture_backend to point to invalid memory. Fixed by making the array static to persist beyond function scope. Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add multi-backend display capture infrastructure
Add multi-backend capture with automatic fallback chain
Feb 12, 2026
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces hard failure on DRM initialization with graceful degradation through X11 SHM and dummy pattern backends. Enables operation in VMs, CI environments, and systems with broken/missing DRM drivers.
Details
What changed?
Capture Backend Abstraction
capture_backend_tstruct with init/capture/cleanup function pointersNew Backends
src/x11_capture.c: XGetImage-based screen capture for X11 systemssrc/dummy_capture.c: Animated test pattern (gradient + color bars + checkerboard)Integration
main.ctoservice_run_host()after backend selectionstaticto persist beyond function scopeBuild Fixes (pre-existing)
audio_playback.c: Renamed local typedef to avoid conflict with headernetwork.c: Added missing goto in #else branchcrypto.c: Check fgets() return valueMakefile: Added missingsrc/core.cRationale
Current implementation exits immediately if DRM fails, making the application unusable on:
Fallback backends enable development/testing without display hardware and provide recovery path for production environments.
Testing
make)Fallback chain verified:
Notes
Original prompt
PHASE 1: Multi-Fallback Display Capture Infrastructure
Current State
drm_capture.cexists and implements DRM/KMS framebuffer captureservice_run_host()has main streaming loopProblem
Currently, if DRM initialization fails,
service_run_host()immediately returns -1 and exits. On systems with:The entire application fails with no recovery path.
Solution: Multi-Backend Capture with Automatic Fallback
1. Create capture backend abstraction struct
2. Implement three capture backends (in priority order):
PRIMARY: DRM/KMS (
src/drm_capture.c)FALLBACK 1: X11 SHM Screen Grab (
src/x11_capture.c- NEW)FALLBACK 2: Dummy Test Pattern (
src/dummy_capture.c- NEW)3. Implement fallback selection logic in
service_run_host():Replace hard failure:
With resilient fallback chain:
4. Update the main capture frame call to use backend:
5. Store backend selection in context:
Add to
rootstream_ctx_t:Files to Create/Modify
NEW FILES:
src/x11_capture.c- X11 SHM screen grab fallbacksrc/dummy_capture.c- Test pattern generatorMODIFY:
src/service.c- Add fallback selection logic inservice_run_host()include/rootstream.h- Add backend struct and function signaturesCMakeLists.txt- Add X11 dependency check (optional, fallback if missing)Implementation Details
src/x11_capture.c- X11 SHM ImplementationXOpenDisplay()DefaultRootWindow()XGetImage(display, root_window, 0, 0, width, height, ...)src/dummy_capture.c- Test Pattern ImplementationTesting
--capture-backend=dummySuccess Criteria
service_run_host()succeeds even if DRM unavailableThis pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.