Code refactoring for Nest RTSP source

This commit is contained in:
Alex X
2025-02-22 11:39:32 +03:00
parent 13dd3084c2
commit 1abb3c8c22
2 changed files with 11 additions and 26 deletions
+5 -14
View File
@@ -33,12 +33,6 @@ func Dial(rawURL string) (core.Producer, error) {
refreshToken := query.Get("refresh_token")
projectID := query.Get("project_id")
deviceID := query.Get("device_id")
protocols := strings.Split(query.Get("protocols"), ",")
// Default to WEB_RTC for backwards compataiility
if len(protocols) == 0 {
protocols = append(protocols, "WEB_RTC")
}
if cliendID == "" || cliendSecret == "" || refreshToken == "" || projectID == "" || deviceID == "" {
return nil, errors.New("nest: wrong query")
@@ -49,16 +43,13 @@ func Dial(rawURL string) (core.Producer, error) {
return nil, err
}
// Pick the first supported protocol in order of priority (WEB_RTC, RTSP)
for _, proto := range protocols {
if proto == "WEB_RTC" {
return rtcConn(nestAPI, rawURL, projectID, deviceID)
} else if proto == "RTSP" {
return rtspConn(nestAPI, rawURL, projectID, deviceID)
}
protocols := strings.Split(query.Get("protocols"), ",")
if len(protocols) > 0 && protocols[0] == "RTSP" {
return rtspConn(nestAPI, rawURL, projectID, deviceID)
}
return nil, errors.New("nest: unsupported camera")
// Default to WEB_RTC for backwards compataiility
return rtcConn(nestAPI, rawURL, projectID, deviceID)
}
func (c *WebRTCClient) GetMedias() []*core.Media {