Add go2rtc config override and update submodule to dev#384
Conversation
Rebase opensensor fork onto AlexxIT/go2rtc dev branch to pull in WebCodecs player, WebP streaming, HKSV support, system monitoring API, WebRTC error handling, and UI improvements. The two go.mod patches (security alert, dependency cleanup) were already addressed in dev; only the Stream.Stop() fix needed cherry-picking. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allow power users to customize go2rtc behavior without lightNVR needing to expose every option. Two levels of override: - Per-stream source override: a text field on each stream that replaces the auto-constructed go2rtc source URL. Supports single URLs or multi-source YAML lists for failover, transcoding, and hardware acceleration. Written directly into go2rtc.yaml streams section; API-based auto-registration is skipped for overridden streams. - Global config override: a YAML text field in settings (stored in system_settings table) appended to go2rtc.yaml after auto-generated sections. Handles custom ffmpeg presets, publish destinations, preload settings, log levels, etc. Uses last-key-wins for duplicates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
The unit tests use embedded migrations (not filesystem SQL files) to initialize test databases. Without the embedded entry for 0040, the go2rtc_source_override column was missing and caused test_db_streams, test_db_zones, test_db_motion_config, and test_zone_filter to fail. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds advanced go2rtc configuration overrides (per-stream source override + global YAML append) and updates the go2rtc submodule tracking to the upstream dev branch, enabling power-user customization of go2rtc behavior beyond the auto-generated configuration.
Changes:
- Add per-stream
go2rtc_source_override(DB + API + UI) and skip API registration when present. - Add global
go2rtc_config_overridestored insystem_settingsand appended to generatedgo2rtc.yaml. - Update go2rtc config generation to embed overridden streams directly in YAML; update i18n strings and UI controls.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| web/public/locales/pt-BR.json | Adds PT-BR translations for the new go2rtc override settings. |
| web/public/locales/en.json | Adds EN translations for the new go2rtc override settings. |
| web/js/components/preact/StreamsView.jsx | Adds stream model fields and API payload mapping for go2rtc_source_override. |
| web/js/components/preact/StreamConfigModal.jsx | Adds a new accordion section + textarea for per-stream go2rtc overrides. |
| web/js/components/preact/SettingsView.jsx | Adds a settings textarea for the global YAML override. |
| src/web/api_handlers_streams_modify.c | Parses and persists go2rtc_source_override on POST/PUT stream APIs. |
| src/web/api_handlers_streams_get.c | Exposes go2rtc_source_override in stream GET endpoints. |
| src/web/api_handlers_settings.c | Reads/writes global go2rtc override via system_settings. |
| src/video/go2rtc/go2rtc_process.c | Writes overridden streams into go2rtc.yaml and appends global override. |
| src/video/go2rtc/go2rtc_integration.c | Skips API registration/sync for streams with overrides. |
| src/database/db_streams.c | Adds DB persistence and retrieval for the new override column. |
| include/core/config.h | Extends stream_config_t with go2rtc_source_override. |
| db/migrations/0040_add_go2rtc_source_override.sql | Adds go2rtc_source_override column to streams. |
| .gitmodules | Sets go2rtc submodule to track the dev branch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Cover the new column in db_streams.c: default empty, INSERT round-trip with multi-line YAML, UPDATE, get_all bulk read, and clearing the override back to empty. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Stop stripping leading whitespace from override lines so that nested YAML (e.g. list items with indented subkeys) is preserved correctly. Base indentation (4 spaces) is still prepended to every line. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sub-stream support (closes discussion #366): - Add sub_stream_url field to stream config, coupled into migration 0040 - Register sub-streams with go2rtc as "{name}_sub" when URL is provided - Frontend grid view uses sub-stream (low-res) when available; fullscreen and recording always use the main stream - Sub-stream URL field added to stream config modal (Basic Information) - MSE, HLS, and WebRTC video cells accept useSubStream prop Copilot review fixes: - Single-URL overrides now emit valid inline YAML scalar form ("cam": rtsp://...) instead of block form - Stream names are YAML-escaped in double-quoted keys (handles " and \) - DB calls in config generation guarded with get_db_handle() != NULL to avoid noisy errors when DB isn't initialized yet - go2rtc_config_override restart dispatch moved outside if(settings_changed) so DB-backed overrides actually trigger a go2rtc restart Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 23 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…log level
- Sub-stream registration no longer bypassed when main stream has
go2rtc_source_override — all three registration paths
(register_all, sync_from_database, register_stream) now skip only
the main stream API call while still registering {name}_sub via API
- Validate go2rtc_config_override length on save (reject >= 4096 bytes)
- Downgrade full config file dump from INFO to DEBUG to avoid leaking
credentials from overrides into production logs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The PUT worker previously only reloaded go2rtc registration when
URL/protocol/record_audio/credentials changed. Now:
- go2rtc_source_override changes: remove the old API-registered stream,
then re-register via go2rtc_integration_register_stream() which
handles the override-vs-API decision
- sub_stream_url changes: remove old {name}_sub from go2rtc, then
re-register with the new URL (or leave removed if cleared)
Both paths are tracked with dedicated flags in put_stream_task_t
so the worker can act on them independently of URL changes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
devbranch — rebases the opensensor fork onto AlexxIT/go2rtc dev, bringing in WebCodecs player, WebP streaming, HKSV support, system monitoring API, graceful WebRTC error handling, and UI improvements.{name}_sub. Frontend grid view automatically uses the sub-stream when available; fullscreen and recording always use the main stream.Test plan
{name}_subappears in go2rtc, grid view uses sub-stream🤖 Generated with Claude Code