support publishing, reading, proxying with SRT (#2068)

This commit is contained in:
Alessandro Ros 2023-07-31 21:20:09 +02:00 committed by GitHub
parent d696a782f7
commit b4e3033ea3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 2184 additions and 213 deletions

View file

@ -159,6 +159,10 @@ type Conf struct {
WebRTCICEUDPMuxAddress string `json:"webrtcICEUDPMuxAddress"`
WebRTCICETCPMuxAddress string `json:"webrtcICETCPMuxAddress"`
// SRT
SRT bool `json:"srt"`
SRTAddress string `json:"srtAddress"`
// paths
Paths map[string]*PathConf `json:"paths"`
}
@ -336,6 +340,10 @@ func (conf *Conf) UnmarshalJSON(b []byte) error {
conf.WebRTCAllowOrigin = "*"
conf.WebRTCICEServers2 = []WebRTCICEServer{{URL: "stun:stun.l.google.com:19302"}}
// SRT
conf.SRT = true
conf.SRTAddress = ":8890"
type alias Conf
d := json.NewDecoder(bytes.NewReader(b))
d.DisallowUnknownFields()

View file

@ -210,6 +210,16 @@ func (pconf *PathConf) check(conf *Conf, name string) error {
return fmt.Errorf("'%s' is not a valid IP", host)
}
case strings.HasPrefix(pconf.Source, "srt://"):
if pconf.Regexp != nil {
return fmt.Errorf("a path with a regular expression (or path 'all') cannot have a SRT source. use another path")
}
_, err := gourl.Parse(pconf.Source)
if err != nil {
return fmt.Errorf("'%s' is not a valid HLS URL", pconf.Source)
}
case pconf.Source == "redirect":
if pconf.SourceRedirect == "" {
return fmt.Errorf("source redirect must be filled")
@ -337,6 +347,7 @@ func (pconf PathConf) HasStaticSource() bool {
strings.HasPrefix(pconf.Source, "http://") ||
strings.HasPrefix(pconf.Source, "https://") ||
strings.HasPrefix(pconf.Source, "udp://") ||
strings.HasPrefix(pconf.Source, "srt://") ||
pconf.Source == "rpiCamera"
}