Files
mediamtx/internal/conf/forward_dest.go
T
98ab3009ea support forwarding streams natively (#5558)
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>
2026-08-04 21:57:15 +02:00

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
}