Skip to content

Commit

Permalink
adapt FMLE URL: 'rtmp://ip/app/app2#k=v/stream', then add more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
duiniuluantanqin committed Dec 8, 2022
1 parent 29cc533 commit a1f60e6
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions trunk/src/protocol/srs_protocol_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,16 @@ 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
+ fullUrl.substr(pos_rslash) // /stream
+ fullUrl.substr(pos_query, pos_rslash - pos_query); // ?k=v
}

// covert the FMLE URL to standard URL:
// rtmp://ip/app/app2#k=v/stream
size_t pos_fragment = fullUrl.find("#");
pos_rslash = fullUrl.rfind("/");
if (pos_rslash != string::npos && pos_fragment != string::npos && pos_fragment < pos_rslash) {
fullUrl = fullUrl.substr(0, pos_fragment) // rtmp://ip/app/app2
+ fullUrl.substr(pos_rslash) // /stream
+ fullUrl.substr(pos_fragment, pos_rslash - pos_fragment); // #k=v
}

// Remove the _definst_ of FMLE URL.
if (fullUrl.find("/_definst_") != string::npos) {
fullUrl = srs_string_replace(fullUrl, "/_definst_", "");
Expand Down

0 comments on commit a1f60e6

Please sign in to comment.