Rewrite HomeKit pairing API

This commit is contained in:
Alexey Khit
2023-09-01 22:48:06 +03:00
parent 0621b82aff
commit 9f404d965f
11 changed files with 367 additions and 275 deletions

View File

@@ -1,6 +1,8 @@
package homekit
import (
"strings"
"github.com/AlexxIT/go2rtc/internal/api"
"github.com/AlexxIT/go2rtc/internal/app"
"github.com/AlexxIT/go2rtc/internal/srtp"
@@ -23,3 +25,24 @@ var log zerolog.Logger
func streamHandler(url string) (core.Producer, error) {
return homekit.Dial(url, srtp.Server)
}
func findHomeKitURL(stream *streams.Stream) string {
sources := stream.Sources()
if len(sources) == 0 {
return ""
}
url := sources[0]
if strings.HasPrefix(url, "homekit") {
return url
}
if strings.HasPrefix(url, "hass") {
location, _ := streams.Location(url)
if strings.HasPrefix(location, "homekit") {
return url
}
}
return ""
}