golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.1 KiB
61 lines
1.1 KiB
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) |
|
}) |
|
} |
|
}
|
|
|