1
0
Fork 0
forked from External/mediamtx

srt: support standard streamID syntax (#2469) (#2919)

This commit is contained in:
Alessandro Ros 2024-01-18 23:23:51 +01:00 committed by GitHub
parent dd7d7c6c5d
commit b3eaec50c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 183 additions and 43 deletions

View file

@ -0,0 +1,61 @@
package srt
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestStreamIDUnmarshal(t *testing.T) {
for _, ca := range []struct {
name string
raw string
dec streamID
}{
{
"mediamtx syntax 1",
"read:mypath",
streamID{
mode: streamIDModeRead,
path: "mypath",
},
},
{
"mediamtx syntax 2",
"publish:mypath:myquery",
streamID{
mode: streamIDModePublish,
path: "mypath",
query: "myquery",
},
},
{
"mediamtx syntax 3",
"read:mypath:myuser:mypass:myquery",
streamID{
mode: streamIDModeRead,
path: "mypath",
user: "myuser",
pass: "mypass",
query: "myquery",
},
},
{
"standard syntax",
"#!::u=johnny,t=file,m=publish,r=results.csv,s=mypass,h=myhost.com",
streamID{
mode: streamIDModePublish,
path: "results.csv",
user: "johnny",
pass: "mypass",
},
},
} {
t.Run(ca.name, func(t *testing.T) {
var streamID streamID
err := streamID.unmarshal(ca.raw)
require.NoError(t, err)
require.Equal(t, ca.dec, streamID)
})
}
}