It is now possible to define forward destinations for each path configuration. For each destination, the server will create a client that will forward the stream to the intended destination. Supported protocols are RTSP, RTMP, SRT. API and metrics have also been improved to allow monitoring the new forwarding system. --------- Co-authored-by: aler9 <46489434+aler9@users.noreply.github.com>
41 lines
757 B
Go
41 lines
757 B
Go
package conf
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
// ForwardDest is a destination to which a path is forwarded.
|
|
type ForwardDest struct {
|
|
Dest string `json:"dest"`
|
|
}
|
|
|
|
func validateForwardDest(dest string) (*url.URL, error) {
|
|
replaced := strings.ReplaceAll(dest, "$MTX_PATH", "path")
|
|
|
|
return validateURL(replaced)
|
|
}
|
|
|
|
// Validate validates the configuration.
|
|
func (p *ForwardDest) Validate() error {
|
|
if p.Dest == "" {
|
|
return fmt.Errorf("destination is empty")
|
|
}
|
|
|
|
u, err := validateForwardDest(p.Dest)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
switch u.Scheme {
|
|
case "rtmp", "rtmps", "rtsp", "rtsps", "srt":
|
|
default:
|
|
return fmt.Errorf(
|
|
"unsupported scheme '%s', supported ones are rtmp, rtmps, rtsp, rtsps and srt",
|
|
u.Scheme)
|
|
}
|
|
|
|
return nil
|
|
}
|