mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
push! PUSH!!
This commit is contained in:
@@ -18,3 +18,6 @@ paths:
|
||||
rpiCameraExposure: long
|
||||
rpiCameraHFlip: false
|
||||
rpiCameraVFlip: false
|
||||
# Replace ROVER_ID with the rover's configured name before deploy.
|
||||
whipPublishURLs:
|
||||
- http://192.168.0.86:8889/whip/ROVER_ID
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -60,7 +59,6 @@ type MediaConfig struct {
|
||||
WhepPort int `yaml:"whepPort" json:"-"`
|
||||
WhepPath string `yaml:"whepPath" json:"-"`
|
||||
LegacyPublish string `yaml:"publishUrl,omitempty" json:"-"`
|
||||
BridgeWhepURL string `yaml:"-" json:"bridgeWhepUrl,omitempty"`
|
||||
Manage bool `yaml:"manage"`
|
||||
Service string `yaml:"service"`
|
||||
HealthURL string `yaml:"healthUrl"`
|
||||
@@ -143,38 +141,9 @@ func LoadConfig(path string) (*Config, error) {
|
||||
scheme := "http"
|
||||
cfg.Media.WhepURL = fmt.Sprintf("%s://%s:%d%s", scheme, ip, effectivePort(cfg.Media.WhepPort), path)
|
||||
}
|
||||
if bridge, err := buildBridgeURL(cfg.Media.WhepURL); err == nil {
|
||||
cfg.Media.BridgeWhepURL = bridge
|
||||
}
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
func buildBridgeURL(src string) (string, error) {
|
||||
if src == "" {
|
||||
return "", errors.New("empty whep url")
|
||||
}
|
||||
parsed, err := url.Parse(src)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if parsed.Host == "" {
|
||||
return "", errors.New("missing host")
|
||||
}
|
||||
proto := "whep"
|
||||
if parsed.Scheme == "https" {
|
||||
proto = "wheps"
|
||||
}
|
||||
path := strings.Trim(parsed.Path, "/")
|
||||
if strings.HasPrefix(path, "whep/") {
|
||||
path = strings.TrimPrefix(path, "whep/")
|
||||
}
|
||||
path = strings.Trim(path, "/")
|
||||
if path == "" {
|
||||
path = "rovercam"
|
||||
}
|
||||
return fmt.Sprintf("%s://%s/%s/whep", proto, parsed.Host, path), nil
|
||||
}
|
||||
|
||||
func ensureLeadingSlash(path string) string {
|
||||
if !strings.HasPrefix(path, "/") {
|
||||
return "/" + path
|
||||
|
||||
Reference in New Issue
Block a user