1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

API: Parse fragment of URI. v5.0.106 (#3295)

* parse fragment of uri
* adapt FMLE URL: 'rtmp://ip/app/app2#k=v/stream', then add more test case

Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
Haibo Chen 2022-12-08 15:48:10 +08:00 committed by GitHub
parent 0e550d496b
commit c5a0c5947f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 4 deletions

View file

@ -53,8 +53,9 @@ void srs_discovery_tc_url(string tcUrl, string& schema, string& host, string& vh
fullUrl += param.empty() ? "" : (param.at(0) == '?' ? param : "?" + param);
// First, we covert the FMLE URL to standard URL:
// rtmp://ip/app/app2?k=v/stream
size_t pos_query = fullUrl.find("?");
// rtmp://ip/app/app2?k=v/stream , or:
// rtmp://ip/app/app2#k=v/stream
size_t pos_query = fullUrl.find_first_of("?#");
size_t pos_rslash = fullUrl.rfind("/");
if (pos_rslash != string::npos && pos_query != string::npos && pos_query < pos_rslash) {
fullUrl = fullUrl.substr(0, pos_query) // rtmp://ip/app/app2
@ -81,6 +82,7 @@ void srs_discovery_tc_url(string tcUrl, string& schema, string& host, string& vh
port = uri.get_port();
stream = srs_path_basename(uri.get_path());
param = uri.get_query().empty() ? "" : "?" + uri.get_query();
param += uri.get_fragment().empty() ? "" : "#" + uri.get_fragment();
// Parse app without the prefix slash.
app = srs_path_dirname(uri.get_path());