Files
RTSP-Streamer/cmd/rtsp-streamer/main.go
Levi Woodard 291d37ec83 Import UniFi Protect live views + optional auto-resync
views ls/dump/import copy a Protect live view (cameras + grid) into a
layout; grid inferred from slot count (asymmetric presets TBD, see
views dump). Imported layouts link back via protect_view.

Daemon re-syncs the active linked view every view_refresh_seconds (0=
off), so Protect-side edits appear on the wall. Needs the controller
password at runtime; off by default keeps the wall credential-free.

Shared viewmap package used by CLI and daemon.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 07:18:57 -05:00

69 lines
1.5 KiB
Go

// Command rtsp-streamer is a full-screen RTSP video wall for UniFi Protect
// cameras, driven by mpv under a kiosk Wayland compositor and configured from
// the command line or an interactive TUI.
package main
import (
"fmt"
"log/slog"
"os"
"github.com/lwoodard/rtsp-streamer/internal/config"
"github.com/spf13/cobra"
)
var (
cfgPath string
logLevel string
)
// Build metadata, injected via -ldflags -X at build time (see Makefile).
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
root := &cobra.Command{
Use: "rtsp-streamer",
Short: "Full-screen RTSP camera wall for UniFi Protect",
Version: fmt.Sprintf("%s (commit %s, built %s)", version, commit, date),
SilenceUsage: true,
SilenceErrors: true,
}
root.PersistentFlags().StringVar(&cfgPath, "config", config.DefaultPath(), "path to config file")
root.PersistentFlags().StringVar(&logLevel, "log", "info", "log level: debug|info|warn|error")
root.AddCommand(
daemonCmd(),
discoverCmd(),
layoutCmd(),
statusCmd(),
tuiCmd(),
configCmd(),
versionCmd(),
viewsCmd(),
)
if err := root.Execute(); err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
os.Exit(1)
}
}
func newLogger() *slog.Logger {
var lvl slog.Level
switch logLevel {
case "debug":
lvl = slog.LevelDebug
case "warn":
lvl = slog.LevelWarn
case "error":
lvl = slog.LevelError
default:
lvl = slog.LevelInfo
}
return slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: lvl}))
}