Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update streamid decode for get more encoder such as VMIX #1615

Merged
merged 1 commit into from
Feb 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 39 additions & 16 deletions trunk/src/srt/srt_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,43 @@
#include <vector>

bool is_streamid_valid(const std::string& streamid) {
int mode = ERR_SRT_MODE;
std::string url_subpash;

bool ret = get_streamid_info(streamid, mode, url_subpash);
if (!ret) {
return ret;
if (streamid.empty()) {
return false;
}

if ((mode != PULL_SRT_MODE) && (mode != PUSH_SRT_MODE)) {
size_t pos = streamid.find(" ");
if (pos != streamid.npos) {
return false;
}

if (url_subpash.empty()) {
int mode;
std::string subpath;

bool ret = get_streamid_info(streamid, mode, subpath);
if (!ret) {
return false;
}

if ((mode != PUSH_SRT_MODE) && (mode != PULL_SRT_MODE)) {
return false;
}

std::vector<std::string> info_vec;
string_split(url_subpash, "/", info_vec);
if (info_vec.size() < 2) {
string_split(subpath, "/", info_vec);

if (info_vec.size() < 2) {//it must be appname/stream at least.
return false;
}

for (auto item : info_vec) {
if (item.empty()) {
return false;
}
pos = item.find(" ");
if (pos != item.npos) {
return false;
}
}
return true;
}

Expand All @@ -46,13 +61,21 @@ bool get_key_value(const std::string& info, std::string& key, std::string& value
}

//eg. streamid=#!::h:live/livestream,m:publish
bool get_streamid_info(const std::string& streamid, int& mode, std::string& url_subpash) {
bool get_streamid_info(const std::string& streamid, int& mode, std::string& url_subpath) {
std::vector<std::string> info_vec;
std::string real_streamid;

size_t pos = streamid.find("#!::h");
mode = PUSH_SRT_MODE;

size_t pos = streamid.find("#!::");
if (pos != 0) {
return false;
pos = streamid.find("/");
if (pos == streamid.npos) {
url_subpath = "live/" + streamid;
Copy link
Member

@winlinvip winlinvip Feb 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

90afd06

Specify the default app name in the configuration file, which is set to "live" by default.

TRANS_BY_GPT3

return true;
}
url_subpath = streamid;
return true;
}
real_streamid = streamid.substr(4);

Expand All @@ -71,16 +94,15 @@ bool get_streamid_info(const std::string& streamid, int& mode, std::string& url_
}

if (key == "h") {
url_subpash = value;//eg. h=live/stream
url_subpath = value;//eg. h=live/stream
} else if (key == "m") {
std::string mode_str = string_lower(value);//m=publish or m=request
if (mode_str == "publish") {
mode = PUSH_SRT_MODE;
} else if (mode_str == "request") {
mode = PULL_SRT_MODE;
} else {
mode = ERR_SRT_MODE;
return false;
mode = PUSH_SRT_MODE;
}
} else {//not suport
continue;
Expand All @@ -93,6 +115,7 @@ bool get_streamid_info(const std::string& streamid, int& mode, std::string& url_
srt_conn::srt_conn(SRTSOCKET conn_fd, const std::string& streamid):_conn_fd(conn_fd),
_streamid(streamid) {
get_streamid_info(streamid, _mode, _url_subpath);

_update_timestamp = now_ms();

std::vector<std::string> path_vec;
Expand Down