Skip to content

Add go2rtc config override and update submodule to dev#384

Merged
matteius merged 9 commits intomainfrom
feature/go2rtc-config-override
Apr 14, 2026
Merged

Add go2rtc config override and update submodule to dev#384
matteius merged 9 commits intomainfrom
feature/go2rtc-config-override

Conversation

@matteius
Copy link
Copy Markdown
Contributor

@matteius matteius commented Apr 14, 2026

Summary

  • Update go2rtc submodule to track upstream dev branch — 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.
  • Add per-stream go2rtc source override — a text field on each stream for custom go2rtc source definitions (single URL or multi-source YAML list). Written directly into go2rtc.yaml; auto-registration is skipped.
  • Add global go2rtc config override — a YAML text field in settings appended to go2rtc.yaml for custom ffmpeg presets, publish destinations, preload settings, log levels, etc.
  • Add sub-stream support (closes discussion Main and sub Stream #366) — optional low-res sub-stream URL per camera. Registered with go2rtc as {name}_sub. Frontend grid view automatically uses the sub-stream when available; fullscreen and recording always use the main stream.
  • Copilot review fixes — single-URL YAML scalar form, YAML-escaped stream names, DB guard for early config generation, settings override restart dispatch fix.

Test plan

  • Build succeeds with no new warnings
  • Add a stream with default config — verify normal auto-registration works
  • Edit stream, add go2rtc source override — verify go2rtc.yaml contains override, API registration skipped
  • Clear override — verify stream reverts to auto-registration
  • Add global config override in settings — verify it appears in go2rtc.yaml and triggers go2rtc restart
  • Add sub-stream URL to a stream — verify {name}_sub appears in go2rtc, grid view uses sub-stream
  • Remove sub-stream URL — verify grid falls back to main stream
  • Verify recording still uses main stream URL (never sub-stream)

🤖 Generated with Claude Code

matteius and others added 2 commits April 14, 2026 01:58
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
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 49.77974% with 114 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/web/api_handlers_streams_modify.c 0.00% 58 Missing ⚠️
src/web/api_handlers_settings.c 0.00% 43 Missing ⚠️
src/database/db_streams.c 70.83% 7 Missing ⚠️
src/web/api_handlers_streams_get.c 0.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

matteius and others added 2 commits April 14, 2026 02:09
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_override stored in system_settings and appended to generated go2rtc.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.

matteius and others added 2 commits April 14, 2026 02:15
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

matteius and others added 2 commits April 14, 2026 03:04
…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>
@matteius matteius merged commit 27844db into main Apr 14, 2026
6 checks passed
@matteius matteius deleted the feature/go2rtc-config-override branch April 14, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants