Skip to content

Add minimal web streaming interface - #131

Draft
C-Achard wants to merge 7 commits into
masterfrom
cy/camera-web-stream
Draft

C-Achard wants to merge 7 commits into
masterfrom
cy/camera-web-stream

Conversation

@C-Achard

@C-Achard C-Achard commented Nov 5, 2026

Copy link
Copy Markdown
Member

Adds an opt-in, low-rate (5 FPS by default) view of the camera preview in a browser, on the same machine or on other devices on the network, controlled from View ▸ Web stream. Documentation, authentication and a Host-header check not included yet.

Main changes

  • WebStreamer serves a viewer page and /frame.jpg from a stdlib ThreadingHTTPServer in daemon threads; it has no Qt code.
  • The server encodes a frame only when a browser requests one, at most once per 1/fps, downscaled to the configured maximum size; all clients share the cached JPEG, so encoding cost does not depend on the number of viewers.
  • The stream reads the tiled frame the GUI display timer already builds (_current_frame), or, with "Include on-screen overlays", the frame as drawn on screen with pose and bounding box (_shown_frame).
  • WebStreamController owns the View ▸ Web stream submenu: Stream to browser, Allow other devices (no password), Include on-screen overlays, Open <url>, and Copy link for other devices.
  • On/off, network access and overlays are local QSettings preferences written only by the menu toggles; port, fps, size and JPEG quality are a new web_stream section in the config JSON.
  • The server binds 127.0.0.1 by default and 0.0.0.0 once "Allow other devices" is confirmed in a prompt that states the stream has no password and is view-only.

…ing; add tests for configuration and functionality
- Update WebStreamSettings to ensure that the enabled state is a local preference.
- Modify main window to handle web stream settings more robustly, including restoring user preferences.
- Implement a custom threading HTTP server to manage port binding more effectively.
- Add tests for web stream settings persistence and behavior under various conditions.
- Ensure that web stream settings do not carry over in shareable configurations.
- Moved web stream settings and lifecycle management to a new WebStreamController class.
- Updated the main window to utilize the new controller for managing web stream actions and preferences.
- Removed direct handling of web stream settings from the main window, ensuring separation of concerns.
- Enhanced settings storage to include network exposure preferences.
- Updated tests to reflect changes in web stream management and settings handling.
- Improved error handling and user prompts for network access when enabling the web stream.
@C-Achard C-Achard added enhancement New feature or request camera Related to cameras and camera backends gui Related to the GUI itself : windows and fields bugs, UI, UX, ... config Related to user configs, oading, saving, etc labels Nov 5, 2026
@C-Achard C-Achard self-assigned this Nov 5, 2026
@C-Achard
C-Achard requested a balanced review from Copilot November 5, 2026 11:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved flaws let accepted clients obtain new frames after shutdown and expose loopback camera frames to DNS rebinding, while non-blocking shutdown can still freeze the GUI during encoding.

3 open issues
What changed in this PR

Adds an opt-in browser view of the camera preview, integrated into the GUI’s View menu, with localhost access by default and optional network sharing.

Changes:

  • Adds an on-demand JPEG server with shared caching, resizing, and a default 5 FPS limit.
  • Adds stream controls, optional overlays, network confirmation, and browser/link actions.
  • Separates local preferences from shareable stream configuration and adds tests.
File Description
tests/​utils/​test_settings_store.py Tests persistence of stream preferences.
tests/​test_config.py Tests stream defaults, validation, and configuration round trips.
tests/​services/​test_web_streamer.py Tests HTTP responses, caching, server lifecycle, and URLs.
tests/​gui/​main_window/​test_web_stream.py Tests menu controls, preferences, network access, and overlays.
dlclivegui/​utils/​settings_store.py Stores local enablement, network, and overlay preferences.
dlclivegui/​services/​web_streamer.py Implements the threaded HTTP viewer and cached JPEG encoding.
dlclivegui/​gui/​web_stream.py Manages stream controls, confirmation, links, and lifecycle.
dlclivegui/​gui/​main_window.py Integrates streaming with preview frames, menus, and shutdown.
dlclivegui/​config.py Adds validated stream parameters to application configuration.

Review effort: Balanced

Comment on lines +174 to +176
server.shutdown()
finally:
server.server_close()
Comment on lines +220 to +221
def do_GET(self) -> None: # noqa: N802 - http.server API
path = self.path.split("?", 1)[0]
Comment on lines +172 to +182
def _shutdown() -> None:
try:
server.shutdown()
finally:
server.server_close()

shutdown_thread = threading.Thread(target=_shutdown, name="WebStreamerShutdown", daemon=True)
shutdown_thread.start()
with self._cache_lock:
self._cached_src = None
self._cached_jpeg = None
@C-Achard C-Achard linked an issue Nov 6, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

camera Related to cameras and camera backends config Related to user configs, oading, saving, etc enhancement New feature or request gui Related to the GUI itself : windows and fields bugs, UI, UX, ...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Stream video out

2 participants