From 74b4b611981ad072a4a974ddd394ff5f79f3f7c6 Mon Sep 17 00:00:00 2001 From: eduard256 Date: Thu, 26 Mar 2026 10:18:40 +0000 Subject: [PATCH] Add frontend pages, move static to www/, add resolution to tester Frontend: - index.html: probe device, navigate to standard/homekit by type - standard.html: camera config, model search with multi-select - create.html: stream URL list, custom URL input, create test session - homekit.html: HomeKit device info, contact links, fallback to standard Backend: - Move static files to www/ package with embed (go2rtc pattern) - Add initStatic() in api with FileServer - Add width/height to test results from H264 SPS parsing - Contribute links to gostrix.github.io with auto-filled params --- internal/api/api.go | 10 +- internal/api/static.go | 16 + internal/api/web/index.html | 16 - pkg/tester/session.go | 2 + pkg/tester/worker.go | 14 + www/create.html | 665 +++++++++++++++++++++++++++++++++++ www/homekit.html | 323 +++++++++++++++++ www/index.html | 454 ++++++++++++++++++++++++ www/standard.html | 682 ++++++++++++++++++++++++++++++++++++ www/static.go | 6 + 10 files changed, 2163 insertions(+), 25 deletions(-) create mode 100644 internal/api/static.go delete mode 100644 internal/api/web/index.html create mode 100644 www/create.html create mode 100644 www/homekit.html create mode 100644 www/index.html create mode 100644 www/standard.html create mode 100644 www/static.go diff --git a/internal/api/api.go b/internal/api/api.go index cf86300..4ef2bb0 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -1,9 +1,7 @@ package api import ( - "embed" "encoding/json" - "io/fs" "net" "net/http" "time" @@ -25,10 +23,7 @@ func Init() { HandleFunc("api/health", apiHealth) HandleFunc("api/log", apiLog) - // serve frontend from embedded web/ directory - if sub, err := fs.Sub(webFS, "web"); err == nil { - http.Handle("/", http.FileServer(http.FS(sub))) - } + initStatic() Handler = middlewareCORS(http.DefaultServeMux) @@ -39,9 +34,6 @@ func Init() { go listen_serve("tcp", listen) } -//go:embed web -var webFS embed.FS - func listen_serve(network, address string) { ln, err := net.Listen(network, address) if err != nil { diff --git a/internal/api/static.go b/internal/api/static.go new file mode 100644 index 0000000..012abbf --- /dev/null +++ b/internal/api/static.go @@ -0,0 +1,16 @@ +package api + +import ( + "net/http" + + "github.com/eduard256/strix/www" +) + +func initStatic() { + root := http.FS(www.Static) + fileServer := http.FileServer(root) + + HandleFunc("", func(w http.ResponseWriter, r *http.Request) { + fileServer.ServeHTTP(w, r) + }) +} diff --git a/internal/api/web/index.html b/internal/api/web/index.html deleted file mode 100644 index de2ed02..0000000 --- a/internal/api/web/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - -Strix - - - -

Strix 2.0

- - diff --git a/pkg/tester/session.go b/pkg/tester/session.go index 1359ce6..c737e8c 100644 --- a/pkg/tester/session.go +++ b/pkg/tester/session.go @@ -27,6 +27,8 @@ type Result struct { Source string `json:"source"` Screenshot string `json:"screenshot,omitempty"` Codecs []string `json:"codecs,omitempty"` + Width uint16 `json:"width,omitempty"` + Height uint16 `json:"height,omitempty"` LatencyMs int64 `json:"latency_ms,omitempty"` Skipped bool `json:"skipped,omitempty"` } diff --git a/pkg/tester/worker.go b/pkg/tester/worker.go index f64a214..157f8af 100644 --- a/pkg/tester/worker.go +++ b/pkg/tester/worker.go @@ -7,6 +7,7 @@ import ( "time" "github.com/AlexxIT/go2rtc/pkg/core" + "github.com/AlexxIT/go2rtc/pkg/h264" "github.com/AlexxIT/go2rtc/pkg/magic" ) @@ -66,18 +67,31 @@ func testURL(s *Session, rawURL string) { latency := time.Since(start).Milliseconds() var codecs []string + var width, height uint16 + for _, media := range prod.GetMedias() { if media.Direction != core.DirectionRecvonly { continue } for _, codec := range media.Codecs { codecs = append(codecs, codec.Name) + + // extract resolution from first video codec SPS + if width == 0 && codec.Name == core.CodecH264 { + if spsBytes, _ := h264.GetParameterSet(codec.FmtpLine); spsBytes != nil { + if sps := h264.DecodeSPS(spsBytes); sps != nil { + width, height = sps.Width(), sps.Height() + } + } + } } } r := &Result{ Source: rawURL, Codecs: codecs, + Width: width, + Height: height, LatencyMs: latency, } diff --git a/www/create.html b/www/create.html new file mode 100644 index 0000000..5bc63b6 --- /dev/null +++ b/www/create.html @@ -0,0 +1,665 @@ + + + + + + + Strix - Stream URLs + + + + +
+
+ + +

Stream URLs

+

+ +
+
+
+ Building stream URLs... +
+
+
+
+ +
+ +
+ + + + + + + diff --git a/www/homekit.html b/www/homekit.html new file mode 100644 index 0000000..258efc4 --- /dev/null +++ b/www/homekit.html @@ -0,0 +1,323 @@ + + + + + + + Strix - HomeKit Device + + + + +
+
+ + +
+ + + + + +

HomeKit Device Detected

+
Apple HomeKit
+ +
+ +

+ We are working on adding Apple HomeKit camera support to Strix, but we don't have HomeKit cameras available for testing. +

+

+ The device at this IP supports HomeKit protocol. If you'd like to help us add support for HomeKit cameras, please reach out. Your contribution would be greatly appreciated. +

+ + + +
or
+ + + +
+
+
+ + + + + diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..5f1af5a --- /dev/null +++ b/www/index.html @@ -0,0 +1,454 @@ + + + + + + + Strix - Camera Stream Discovery + + + + +
+
+
+ +

STRIX

+

Camera Stream Discovery

+
+ +
+ + +

IP address of the camera

+
+ + + +
+ +
+

Examples

+
    +
  • 192.168.1.100
  • +
  • 10.0.0.50
  • +
  • 172.16.0.10
  • +
+
+
+
+ + + + + + + diff --git a/www/standard.html b/www/standard.html new file mode 100644 index 0000000..f32cea9 --- /dev/null +++ b/www/standard.html @@ -0,0 +1,682 @@ + + + + + + + Strix - Camera Configuration + + + + +
+
+ + +

Camera Configuration

+ + +
+ +
+ + + + +
+
+ + +
+ +
+ + +
+
+ + +
+ + +
+ + +
+ +
+ + +
+
+ + +
+ + + + + Advanced + +
+
+ + +

Camera channel number (0 for most cameras, 1+ for NVR)

+
+
+ + +

Only test streams on these ports. Leave empty to test all.

+
+
+
+ + + +
+
+ + + + + + + diff --git a/www/static.go b/www/static.go new file mode 100644 index 0000000..80e6b16 --- /dev/null +++ b/www/static.go @@ -0,0 +1,6 @@ +package www + +import "embed" + +//go:embed *.html +var Static embed.FS