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>
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package forward
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestResolveDest(t *testing.T) {
|
|
for _, ca := range []struct {
|
|
name string
|
|
dest string
|
|
pathName string
|
|
matches []string
|
|
expected string
|
|
}{
|
|
{
|
|
name: "path substitution",
|
|
dest: "rtmp://example.com/live/$MTX_PATH",
|
|
pathName: "stream",
|
|
expected: "rtmp://example.com/live/stream",
|
|
},
|
|
{
|
|
name: "multi digit group substitution",
|
|
dest: "rtmp://example.com/live/$G10",
|
|
pathName: "stream",
|
|
matches: []string{"full", "g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g9", "g10"},
|
|
expected: "rtmp://example.com/live/g10",
|
|
},
|
|
{
|
|
name: "combined substitutions",
|
|
dest: "rtmp://$G1/live/$G10",
|
|
pathName: "stream",
|
|
matches: []string{"full", "host", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g9", "tail"},
|
|
expected: "rtmp://host/live/tail",
|
|
},
|
|
} {
|
|
t.Run(ca.name, func(t *testing.T) {
|
|
result := resolveDest(ca.dest, ca.pathName, ca.matches)
|
|
require.Equal(t, ca.expected, result)
|
|
})
|
|
}
|
|
}
|