Repository navigation
Conversation
…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.
… shutdown behavior
- 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.
There was a problem hiding this comment.
🟡 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
| def do_GET(self) -> None: # noqa: N802 - http.server API | ||
| path = self.path.split("?", 1)[0] |
|
@C-Achard One thing i observed: Stopping the preview still leaves the last frame and it can be fetched with 200 reponse. which makes it difficutl to distinguish between stale/frozen and correct views. |
Serve frames only while cameras are running and clear the browser image on fetch errors. Add tests for stopped-camera frame rejection and HTTP 503 responses.
@arturoptophys It's now a 503 Service Unavailable if up but the preview is stopped. Do you also need some way to catch stalling cams? (i.e. preview is on but frames aren't being passed) or is that fine? |
|
(Also let me know if you want this merged soon, I can try and wrap it up this week) |
Reject unrecognized Host headers while allowing IP literals, localhost, and machine names for network bindings.
Add a regression test ensuring stop() does not block the GUI thread on the cache lock and clears the JPEG cache on the shutdown thread.
Move cache cleanup to the shutdown thread so stop() cannot block on an in-progress encode. Update the regression test to detect blocking without deadlocking.


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
WebStreamerserves a viewer page and/frame.jpgfrom a stdlibThreadingHTTPServerin daemon threads; it has no Qt code.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._current_frame), or, with "Include on-screen overlays", the frame as drawn on screen with pose and bounding box (_shown_frame).WebStreamControllerowns 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.web_streamsection in the config JSON.127.0.0.1by default and0.0.0.0once "Allow other devices" is confirmed in a prompt that states the stream has no password and is view-only.