fix parsing and generation of control attributes that contain RTSPS URLs (#216)

This commit is contained in:
Alessandro Ros
2023-03-24 21:07:45 +01:00
committed by GitHub
parent 1ad059a80b
commit 862b1061f4
2 changed files with 12 additions and 2 deletions

View File

@@ -167,7 +167,8 @@ func (m Media) URL(contentBase *url.URL) (*url.URL, error) {
}
// control attribute contains an absolute path
if strings.HasPrefix(m.Control, "rtsp://") {
if strings.HasPrefix(m.Control, "rtsp://") ||
strings.HasPrefix(m.Control, "rtsps://") {
ur, err := url.Parse(m.Control)
if err != nil {
return nil, err

View File

@@ -39,9 +39,18 @@ func TestMediaURL(t *testing.T) {
"m=video 0 RTP/AVP 96\r\n" +
"a=rtpmap:96 H264/90000\r\n" +
"a=control:rtsp://localhost/path/trackID=7"),
mustParseURL("rtsp://myuser:mypass@192.168.1.99:554/path/"),
mustParseURL("rtsp://myuser:mypass@192.168.1.99:554/"),
mustParseURL("rtsp://myuser:mypass@192.168.1.99:554/path/trackID=7"),
},
{
"absolute control rtsps",
[]byte("v=0\r\n" +
"m=video 0 RTP/AVP 96\r\n" +
"a=rtpmap:96 H264/90000\r\n" +
"a=control:rtsps://localhost/path/trackID=7"),
mustParseURL("rtsps://myuser:mypass@192.168.1.99:554/"),
mustParseURL("rtsps://myuser:mypass@192.168.1.99:554/path/trackID=7"),
},
{
"relative control",
[]byte("v=0\r\n" +