Skip to content

Commit

Permalink
SRT: parse srt url to supports multiple QueryStrings.(ossrs#2893)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouxiaojun2008 committed Feb 9, 2022
1 parent c9dcee7 commit 6d40668
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions trunk/src/srt/srt_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ bool get_streamid_info(const std::string& streamid, int& mode, std::string& url_
real_streamid = streamid.substr(4);

string_split(real_streamid, ",", info_vec);
if (info_vec.size() < 2) {
if (info_vec.size() < 1) {
return false;
}


std::string secret;
std::string token;

for (size_t index = 0; index < info_vec.size(); index++) {
std::string key;
std::string value;
Expand All @@ -113,11 +117,33 @@ bool get_streamid_info(const std::string& streamid, int& mode, std::string& url_
} else {
mode = PUSH_SRT_MODE;
}
} else {//not suport
}else if (key == "secret") {
secret = value;
}else if (key == "token"){
token = value;
}else {
continue;
}
}

//SRT url supports multiple QueryStrings, which are passed to RTMP to realize authentication and other capabilities
//@see https://github.com/ossrs/srs/issues/2893
std::string params = "?";
if (!secret.empty()) {
params += "secret=" + secret;
if (!token.empty())
params += "&token=" + token;
}else {
if (!token.empty())
params += "token=" + token;
}

pos = url_subpath.rfind("/");
if ((params.length() > 1) &&
pos != std::string::npos) {
url_subpath.insert(pos, params);
}

return true;
}

Expand Down

0 comments on commit 6d40668

Please sign in to comment.