From 65f451e0c50b75bfe554adeca458b5bd18744c7a Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Sat, 20 Aug 2022 15:50:58 +0300 Subject: [PATCH] Fix incoming rtsp url from Hass --- cmd/hass/hass.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/hass/hass.go b/cmd/hass/hass.go index 5d89260d..0622902b 100644 --- a/cmd/hass/hass.go +++ b/cmd/hass/hass.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/AlexxIT/go2rtc/cmd/api" "github.com/AlexxIT/go2rtc/cmd/app" + "github.com/AlexxIT/go2rtc/cmd/rtsp" "github.com/AlexxIT/go2rtc/cmd/streams" "github.com/AlexxIT/go2rtc/cmd/webrtc" "github.com/AlexxIT/go2rtc/pkg/streamer" @@ -13,6 +14,7 @@ import ( "net/http" "os" "path" + "strings" ) func Init() { @@ -80,6 +82,15 @@ func handler(w http.ResponseWriter, r *http.Request) { return } + // TODO: fixme + if strings.HasPrefix(url, "rtsp://") { + port := ":" + rtsp.Port + "/" + i := strings.Index(url, port) + if i > 0 { + url = url[i+len(port):] + } + } + stream := streams.Get(url) str, err = webrtc.ExchangeSDP(stream, string(offer), r.UserAgent()) if err != nil {