From 21dc30b28fe118058687b134b94dce7766cdccae Mon Sep 17 00:00:00 2001 From: webbrain-one <295484252+webbrain-one@users.noreply.github.com> Date: Sat, 1 Aug 2026 14:09:28 +0300 Subject: [PATCH 1/2] fix: route camera stream to selected entrance Previously, the stream handler defaulted to entrance 1, causing live streams to fail while snapshots worked. Updated handlers/stream.go to properly route the stream to the configured entrance, enabling correct playback for multi-entrance buildings. Closes #26 --- handlers/stream.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/handlers/stream.go b/handlers/stream.go index 1ebbff4..5090b40 100644 --- a/handlers/stream.go +++ b/handlers/stream.go @@ -22,6 +22,12 @@ func (h *Handler) Stream(r *http.Request) (string, error) { query := r.URL.Query() cameraID := query.Get("cameraID") + placeID := query.Get("placeID") + + var placeIDInt int64 + if placeID != "" { + placeIDInt, _ = strconv.ParseInt(placeID, 10, 64) + } targetRawURL := fmt.Sprintf(API_CAMERA_GET_STREAM, cameraID) @@ -42,7 +48,7 @@ func (h *Handler) Stream(r *http.Request) (string, error) { rt := WithHeader(client.Transport) rt.Set("Host", API_HOST) rt.Set("Content-Type", "application/json; charset=UTF-8") - rt.Set("User-Agent", GenerateUserAgent(h.Config.Operator, h.Config.UUID, 0)) + rt.Set("User-Agent", GenerateUserAgent(h.Config.Operator, h.Config.UUID, placeIDInt)) rt.Set("Operator", operator) rt.Set("Authorization", "Bearer "+h.Config.Token) client.Transport = rt From c1cb662feb90a2e19c5f79ed427c462e36c867f8 Mon Sep 17 00:00:00 2001 From: ad Date: Sat, 1 Aug 2026 16:37:32 +0300 Subject: [PATCH 2/2] fix: don't forward placeID upstream, document stream param --- README.md | 2 +- handlers/stream.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3609170..2a32bf9 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ You can find docker image in packages section of this github repository or pull | `/operators` | GET | Get operators list | | `/places` | GET | Get places list | | `/snapshot` | GET | Get snapshot by `placeID` and `accessControlID` | -| `/stream` | GET | Get link to stream by `cameraID` | +| `/stream` | GET | Get link to stream by `cameraID`, optionally `placeID` to select the entrance | ## 🤝  Found a bug? Missing a specific feature? diff --git a/handlers/stream.go b/handlers/stream.go index 5090b40..4043932 100644 --- a/handlers/stream.go +++ b/handlers/stream.go @@ -22,17 +22,17 @@ func (h *Handler) Stream(r *http.Request) (string, error) { query := r.URL.Query() cameraID := query.Get("cameraID") - placeID := query.Get("placeID") - var placeIDInt int64 - if placeID != "" { - placeIDInt, _ = strconv.ParseInt(placeID, 10, 64) - } + // Конвертируем placeID из строки в int64 + placeIDInt, _ := strconv.ParseInt(query.Get("placeID"), 10, 64) targetRawURL := fmt.Sprintf(API_CAMERA_GET_STREAM, cameraID) targetURL, _ := url.Parse(targetRawURL) - targetURL.RawQuery = r.URL.RawQuery + + // placeID нужен только для User-Agent, наверх его не передаём + query.Del("placeID") + targetURL.RawQuery = query.Encode() request, err := http.NewRequest("GET", targetURL.String(), nil) if err != nil {