Skip to content

Commit

Permalink
#1261, Support _definst_ for Wowza. 3.0.44
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Nov 11, 2018
2 parents 39f1629 + 99aa249 commit 24f46f5
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 5 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Please select according to languages:

### V3 changes

* v3.0, 2018-11-11, Merge [#1261][bug #1261], Support `_definst_` for Wowza. 3.0.44
* v3.0, 2018-08-26, SRS [console](https://github.com/ossrs/srs-ngb) support both [Chinese](http://ossrs.net:1985/console/ng_index.html) and [English](http://ossrs.net:1985/console/en_index.html).
* v3.0, 2018-08-25, Fix [#1093][bug #1093], Support HLS encryption. 3.0.42
* v3.0, 2018-08-25, Fix [#1051][bug #1051], Drop ts when republishing stream. 3.0.41
Expand Down Expand Up @@ -234,6 +235,8 @@ Please select according to languages:

### V2 changes

* v2.0, 2018-11-11, Merge [#1261][bug #1261], Support `_definst_` for Wowza. 2.0.260
* v2.0, 2018-11-11, Merge [#1263][bug #1263], Fix string trim bug. 2.0.259
* <strong>v2.0, 2018-10-28, [2.0 release5(2.0.258)][r2.0r5] released. 86916 lines.</strong>
* v2.0, 2018-10-28, Fix [#1250][bug #1250], Support build on OSX10.14 Mojave. 2.0.258
* v2.0, 2018-10-08, Merge [#1236][bug #1236], Fix sleep bug in us. 2.0.257
Expand Down Expand Up @@ -1460,6 +1463,8 @@ Winlin
[bug #1237]: https://github.com/ossrs/srs/issues/1237
[bug #1236]: https://github.com/ossrs/srs/issues/1236
[bug #1250]: https://github.com/ossrs/srs/issues/1250
[bug #1263]: https://github.com/ossrs/srs/issues/1263
[bug #1261]: https://github.com/ossrs/srs/issues/1261
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx

[bug #735]: https://github.com/ossrs/srs/issues/735
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// current release version
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
#define VERSION_REVISION 43
#define VERSION_REVISION 44

// generated by configure, only macros.
#include <srs_auto_headers.hpp>
Expand Down
32 changes: 29 additions & 3 deletions trunk/src/kernel/srs_kernel_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ string srs_string_trim_end(string str, string trim_chars)
ret.erase(ret.end() - 1);

// ok, matched, should reset the search
i = 0;
i = -1;
}
}

Expand All @@ -321,7 +321,7 @@ string srs_string_trim_start(string str, string trim_chars)
ret.erase(ret.begin());

// ok, matched, should reset the search
i = 0;
i = -1;
}
}

Expand All @@ -340,7 +340,7 @@ string srs_string_remove(string str, string remove_chars)
it = ret.erase(it);

// ok, matched, should reset the search
i = 0;
i = -1;
} else {
++it;
}
Expand All @@ -350,6 +350,32 @@ string srs_string_remove(string str, string remove_chars)
return ret;
}

string srs_erase_first_substr(string str, string erase_string)
{
std::string ret = str;

size_t pos = ret.find(erase_string);

if (pos != std::string::npos) {
ret.erase(pos, erase_string.length());
}

return ret;
}

string srs_erase_last_substr(string str, string erase_string)
{
std::string ret = str;

size_t pos = ret.rfind(erase_string);

if (pos != std::string::npos) {
ret.erase(pos, erase_string.length());
}

return ret;
}

bool srs_string_ends_with(string str, string flag)
{
const size_t pos = str.rfind(flag);
Expand Down
4 changes: 4 additions & 0 deletions trunk/src/kernel/srs_kernel_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ extern std::string srs_string_trim_end(std::string str, std::string trim_chars);
extern std::string srs_string_trim_start(std::string str, std::string trim_chars);
// remove char in remove_chars of str
extern std::string srs_string_remove(std::string str, std::string remove_chars);
// remove first substring from str
extern std::string srs_erase_first_substr(std::string str, std::string erase_string);
// remove last substring from str
extern std::string srs_erase_last_substr(std::string str, std::string erase_string);
// whether string end with
extern bool srs_string_ends_with(std::string str, std::string flag);
extern bool srs_string_ends_with(std::string str, std::string flag0, std::string flag1);
Expand Down
4 changes: 4 additions & 0 deletions trunk/src/protocol/srs_protocol_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ void srs_vhost_resolve(string& vhost, string& app, string& param)
app = srs_string_replace(app, "&&", "?");
app = srs_string_replace(app, "=", "?");

if (srs_string_ends_with(app, "/_definst_")) {
app = srs_erase_last_substr(app, "/_definst_");
}

if ((pos = app.find("?")) != std::string::npos) {
std::string query = app.substr(pos + 1);
app = app.substr(0, pos);
Expand Down
23 changes: 22 additions & 1 deletion trunk/src/utest/srs_utest_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,14 +1408,23 @@ VOID TEST(KernelUtilityTest, UtilityString)

str1 = srs_string_replace(str, "o", "XX");
EXPECT_STREQ("HellXX, WXXrld! HellXX, SRS!", str1.c_str());

str1 = srs_string_trim_start(str, "x");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_start(str, "S!R");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_start(str, "lHe");
EXPECT_STREQ("o, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_end(str, "x");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_end(str, "He");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_end(str, "HeS!R");
str1 = srs_string_trim_end(str, "S!R");
EXPECT_STREQ("Hello, World! Hello, ", str1.c_str());

str1 = srs_string_remove(str, "x");
Expand All @@ -1426,6 +1435,18 @@ VOID TEST(KernelUtilityTest, UtilityString)

str1 = srs_string_remove(str, "ol");
EXPECT_STREQ("He, Wrd! He, SRS!", str1.c_str());

str1 = srs_erase_first_substr(str, "Hello");
EXPECT_STREQ(", World! Hello, SRS!", str1.c_str());

str1 = srs_erase_first_substr(str, "XX");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

str1 = srs_erase_last_substr(str, "Hello");
EXPECT_STREQ("Hello, World! , SRS!", str1.c_str());

str1 = srs_erase_last_substr(str, "XX");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

EXPECT_FALSE(srs_string_ends_with("Hello", "x"));
EXPECT_TRUE(srs_string_ends_with("Hello", "o"));
Expand Down
10 changes: 10 additions & 0 deletions trunk/src/utest/srs_utest_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,16 @@ VOID TEST(ProtocolUtilityTest, DiscoveryTcUrl)
EXPECT_STREQ("live", app.c_str());
EXPECT_STREQ("show", stream.c_str());
EXPECT_EQ(19351, port);

// _definst_ at the end of app
tcUrl = "rtmp://winlin.cn/live/_definst_"; stream= "show";
srs_discovery_tc_url(tcUrl, schema, ip, vhost, app, stream, port, param);
EXPECT_STREQ("rtmp", schema.c_str());
EXPECT_STREQ("winlin.cn", ip.c_str());
EXPECT_STREQ("winlin.cn", vhost.c_str());
EXPECT_STREQ("live", app.c_str());
EXPECT_STREQ("show", stream.c_str());
EXPECT_EQ(1935, port);
}

/**
Expand Down

0 comments on commit 24f46f5

Please sign in to comment.