Fix incoming rtsp url from Hass

This commit is contained in:
Alexey Khit
2022-08-20 15:50:58 +03:00
parent ecd46700db
commit 65f451e0c5

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"github.com/AlexxIT/go2rtc/cmd/api" "github.com/AlexxIT/go2rtc/cmd/api"
"github.com/AlexxIT/go2rtc/cmd/app" "github.com/AlexxIT/go2rtc/cmd/app"
"github.com/AlexxIT/go2rtc/cmd/rtsp"
"github.com/AlexxIT/go2rtc/cmd/streams" "github.com/AlexxIT/go2rtc/cmd/streams"
"github.com/AlexxIT/go2rtc/cmd/webrtc" "github.com/AlexxIT/go2rtc/cmd/webrtc"
"github.com/AlexxIT/go2rtc/pkg/streamer" "github.com/AlexxIT/go2rtc/pkg/streamer"
@@ -13,6 +14,7 @@ import (
"net/http" "net/http"
"os" "os"
"path" "path"
"strings"
) )
func Init() { func Init() {
@@ -80,6 +82,15 @@ func handler(w http.ResponseWriter, r *http.Request) {
return 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) stream := streams.Get(url)
str, err = webrtc.ExchangeSDP(stream, string(offer), r.UserAgent()) str, err = webrtc.ExchangeSDP(stream, string(offer), r.UserAgent())
if err != nil { if err != nil {