Skip to content

Commit

Permalink
RTMP: If port is explicity set to 0, use default 1935 (#1754)
Browse files Browse the repository at this point in the history
  • Loading branch information
macabu authored Oct 19, 2021
1 parent 85131da commit 9a017f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions trunk/src/kernel/srs_kernel_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void srs_parse_hostport(string hostport, string& host, int& port)
if (hostport.find(":") == pos) {
host = hostport.substr(0, pos);
string p = hostport.substr(pos + 1);
if (!p.empty()) {
if (!p.empty() && p != "0") {
port = ::atoi(p.c_str());
}
return;
Expand All @@ -204,7 +204,7 @@ void srs_parse_hostport(string hostport, string& host, int& port)
// For ipv6, [host]:port.
host = hostport.substr(1, pos - 1);
string p = hostport.substr(pos + 2);
if (!p.empty()) {
if (!p.empty() && p != "0") {
port = ::atoi(p.c_str());
}
}
Expand Down
8 changes: 8 additions & 0 deletions trunk/src/utest/srs_utest_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4570,6 +4570,14 @@ VOID TEST(KernelUtilityTest, CoverTimeUtilityAll)
srs_parse_hostport("domain.com", host, port);
EXPECT_STREQ("domain.com", host.c_str());
}

if (true) {
string host;
int port = 1935;
srs_parse_hostport("domain.com:0", host, port);
EXPECT_EQ(1935, port);
EXPECT_STREQ("domain.com", host.c_str());
}

if (true) {
string ep = srs_any_address_for_listener();
Expand Down

0 comments on commit 9a017f4

Please sign in to comment.