diff --git a/DEVELOPER.md b/DEVELOPER.md index 5f7c5fbd..65b71c9b 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -1080,6 +1080,7 @@ The following are the update records for the SRS Stack server. * RTSP: Rebuild the URL with escaped user info. v5.12.19 * VLive: Fix rebuild URL bug. v5.12.20 * HLS: Fix LL HLS setting bug. [v5.12.21](https://github.com/ossrs/srs-stack/releases/tag/v5.12.21) + * VLive: Support SRT URL filter. v5.12.22 * v5.11 * VLive: Decrease the latency for virtual live. v5.11.1 * Live: Refine multiple language. v5.11.2 diff --git a/platform/utils.go b/platform/utils.go index d97e44a3..7275eb21 100644 --- a/platform/utils.go +++ b/platform/utils.go @@ -1196,9 +1196,10 @@ func RebuildStreamURL(rawURL string) (*url.URL, error) { // If parse success, for example, no special chars in username and password, return the URL. // If host not parsed, we also try to rebuild the stream URL then parse it. if r0, err := url.Parse(rawURL); err == nil { + isSRT := r0.Scheme == "srt" hostIsInvalid := r0.Host == "" pathIsInvalid := r0.Path == "" && r0.RequestURI() != "/" - if !hostIsInvalid && !pathIsInvalid { + if isSRT || (!hostIsInvalid && !pathIsInvalid) { return r0, err } } diff --git a/platform/utils_test.go b/platform/utils_test.go index 1721f96c..79feceb7 100644 --- a/platform/utils_test.go +++ b/platform/utils_test.go @@ -21,6 +21,8 @@ func TestUtils_RebuildStreamURL(t *testing.T) { {url: "rtsp://Cam@Viewer:abc123@?!@121.1.2.3:554", rebuild: "rtsp://Cam%40Viewer:abc123%40%3F%21@121.1.2.3:554"}, {url: "rtsp://CamViewer:abc123@?!~#$%^&*()_+-=\\|?@121.1.2.3:554/Streaming/Channels/101", rebuild: "rtsp://CamViewer:abc123%40%3F%21~%23$%25%5E&%2A%28%29_+-=%5C%7C%3F@121.1.2.3:554/Streaming/Channels/101"}, {url: "rtsp://CamViewer:abc123@347?1!@121.1.2.3:554/Streaming/Channels/101", rebuild: "rtsp://CamViewer:abc123%40347%3F1%21@121.1.2.3:554/Streaming/Channels/101"}, + {url: "srt://213.171.194.158:10080", rebuild: "srt://213.171.194.158:10080"}, + {url: "srt://213.171.194.158:10080?streamid=#!::r=live/primary,latency=20,m=request", rebuild: "srt://213.171.194.158:10080?streamid=#!::r=live/primary,latency=20,m=request"}, } for _, urlSample := range urlSamples { if r0, err := RebuildStreamURL(urlSample.url); err != nil {