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.
Contributor
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
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 |
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.


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.