diff --git a/README.md b/README.md
index f082fa7bb..5e1fed5a1 100755
--- a/README.md
+++ b/README.md
@@ -146,6 +146,7 @@ For previous versions, please read:
## V3 changes
+* v3.0, 2020-01-16, For [#1575][bug #1575], use RTMP redirect as tcUrl and redirect2 as RTMP URL. 3.0.100
* v3.0, 2020-01-15, For [#1509][bug #1509], decrease the fast vector init size from 64KB to 64B. 3.0.99
* v3.0, 2020-01-15, For [#1509][bug #1509], release coroutine when source is idle. 3.0.98
* v3.0, 2020-01-10, [3.0 alpha8(3.0.97)][r3.0a8] released. 121555 lines.
@@ -1595,6 +1596,7 @@ Winlin
[bug #1255]: https://github.com/ossrs/srs/issues/1255
[bug #1543]: https://github.com/ossrs/srs/issues/1543
[bug #1509]: https://github.com/ossrs/srs/issues/1509
+[bug #1575]: https://github.com/ossrs/srs/issues/1575
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
[exo #828]: https://github.com/google/ExoPlayer/pull/828
diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp
index 8d9d116a8..8a0592dcf 100644
--- a/trunk/src/app/srs_app_edge.cpp
+++ b/trunk/src/app/srs_app_edge.cpp
@@ -416,9 +416,14 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsCommonMessage* msg, stri
return err;
}
SrsAmf0Object* ex = prop->to_object();
-
- if ((prop = ex->ensure_property_string("redirect")) == NULL) {
- return err;
+
+ // The redirect is tcUrl while redirect2 is RTMP URL.
+ // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798
+ if ((prop = ex->ensure_property_string("redirect2")) == NULL) {
+ // TODO: FIXME: Remove it when SRS3 released, it's temporarily support for SRS3 alpha versions(a0 to a8).
+ if ((prop = ex->ensure_property_string("redirect")) == NULL) {
+ return err;
+ }
}
redirect = prop->to_str();
diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp
index 6ed6ca712..f846df0dc 100644
--- a/trunk/src/app/srs_app_rtmp_conn.cpp
+++ b/trunk/src/app/srs_app_rtmp_conn.cpp
@@ -621,8 +621,10 @@ srs_error_t SrsRtmpConn::playing(SrsSource* source)
}
return srs_error_wrap(err, "discover coworkers, url=%s", url.c_str());
}
- srs_trace("rtmp: redirect in cluster, from=%s:%d, target=%s:%d, url=%s",
- req->host.c_str(), req->port, host.c_str(), port, url.c_str());
+
+ string rurl = srs_generate_rtmp_url(host, port, req->host, req->vhost, req->app, req->stream, req->param);
+ srs_trace("rtmp: redirect in cluster, from=%s:%d, target=%s:%d, url=%s, rurl=%s",
+ req->host.c_str(), req->port, host.c_str(), port, url.c_str(), rurl.c_str());
// Ignore if host or port is invalid.
if (host.empty() || port == 0) {
@@ -630,7 +632,7 @@ srs_error_t SrsRtmpConn::playing(SrsSource* source)
}
bool accepted = false;
- if ((err = rtmp->redirect(req, host, port, accepted)) != srs_success) {
+ if ((err = rtmp->redirect(req, rurl, accepted)) != srs_success) {
srs_error_reset(err);
} else {
return srs_error_new(ERROR_CONTROL_REDIRECT, "redirected");
diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp
index b058f55a1..39e704226 100755
--- a/trunk/src/app/srs_app_source.cpp
+++ b/trunk/src/app/srs_app_source.cpp
@@ -217,7 +217,7 @@ void SrsFastVector::push_back(SrsSharedPtrMessage* msg)
for (int i = 0; i < nb_msgs; i++) {
buf[i] = msgs[i];
}
- srs_warn("fast vector incrase %d=>%d", nb_msgs, size);
+ srs_info("fast vector incrase %d=>%d", nb_msgs, size);
// use new array.
srs_freepa(msgs);
diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp
index db851d3d4..283e34e95 100644
--- a/trunk/src/core/srs_core.hpp
+++ b/trunk/src/core/srs_core.hpp
@@ -27,7 +27,7 @@
// The version config.
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
-#define VERSION_REVISION 99
+#define VERSION_REVISION 100
// The macros generated by configure script.
#include
diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp
index ae43916ce..bec1ad35c 100644
--- a/trunk/src/protocol/srs_rtmp_stack.cpp
+++ b/trunk/src/protocol/srs_rtmp_stack.cpp
@@ -2415,17 +2415,20 @@ srs_error_t SrsRtmpServer::response_connect_app(SrsRequest *req, const char* ser
}
#define SRS_RTMP_REDIRECT_TIMEOUT (3 * SRS_UTIME_SECONDS)
-srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string host, int port, bool& accepted)
+srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string url, bool& accepted)
{
srs_error_t err = srs_success;
if (true) {
- string url = srs_generate_rtmp_url(host, port, r->host, r->vhost, r->app, r->stream, r->param);
-
SrsAmf0Object* ex = SrsAmf0Any::object();
ex->set("code", SrsAmf0Any::number(302));
- ex->set("redirect", SrsAmf0Any::str(url.c_str()));
-
+
+ // The redirect is tcUrl while redirect2 is RTMP URL.
+ // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798
+ string tcUrl = srs_path_dirname(url);
+ ex->set("redirect", SrsAmf0Any::str(tcUrl.c_str()));
+ ex->set("redirect2", SrsAmf0Any::str(url.c_str()));
+
SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
pkt->data->set(StatusLevel, SrsAmf0Any::str(StatusLevelError));
diff --git a/trunk/src/protocol/srs_rtmp_stack.hpp b/trunk/src/protocol/srs_rtmp_stack.hpp
index 82c9bf006..c43c4ee17 100644
--- a/trunk/src/protocol/srs_rtmp_stack.hpp
+++ b/trunk/src/protocol/srs_rtmp_stack.hpp
@@ -707,9 +707,9 @@ public:
// @param server_ip the ip of server.
virtual srs_error_t response_connect_app(SrsRequest* req, const char* server_ip = NULL);
// Redirect the connection to another rtmp server.
- // @param the hostname or ip of target.
+ // @param a RTMP url to redirect to.
// @param whether the client accept the redirect.
- virtual srs_error_t redirect(SrsRequest* r, std::string host, int port, bool& accepted);
+ virtual srs_error_t redirect(SrsRequest* r, std::string url, bool& accepted);
// Reject the connect app request.
virtual void response_connect_reject(SrsRequest* req, const char* desc);
// Response client the onBWDone message.
diff --git a/trunk/src/utest/srs_utest_rtmp.cpp b/trunk/src/utest/srs_utest_rtmp.cpp
index 47ec84aa6..7acc3d4c2 100644
--- a/trunk/src/utest/srs_utest_rtmp.cpp
+++ b/trunk/src/utest/srs_utest_rtmp.cpp
@@ -1751,7 +1751,8 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
string host = "target.net";
int port = 8888;
bool accepted = false;
- HELPER_EXPECT_SUCCESS(r.redirect(&req, host, port, accepted));
+ string rurl = srs_generate_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param);
+ HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted));
if (true) {
MockBufferIO tio;
@@ -1776,6 +1777,14 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
prop = ex->get_property("redirect");
ASSERT_TRUE(prop && prop->is_string());
+ // The recirect is tcUrl, not RTMP URL.
+ // https://github.com/ossrs/srs/issues/1575#issuecomment-574995475
+ EXPECT_STREQ("rtmp://target.net:8888/live", prop->to_str().c_str());
+
+ prop = ex->get_property("redirect2");
+ ASSERT_TRUE(prop && prop->is_string());
+ // The recirect2 is RTMP URL.
+ // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798
EXPECT_STREQ("rtmp://target.net:8888/live/livestream", prop->to_str().c_str());
srs_freep(msg);
@@ -1808,7 +1817,8 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
string host = "target.net";
int port = 8888;
bool accepted = false;
- HELPER_EXPECT_SUCCESS(r.redirect(&req, host, port, accepted));
+ string rurl = srs_generate_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param);
+ HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted));
EXPECT_TRUE(accepted);
if (true) {
@@ -1834,6 +1844,14 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect)
prop = ex->get_property("redirect");
ASSERT_TRUE(prop && prop->is_string());
+ // The recirect is tcUrl, not RTMP URL.
+ // https://github.com/ossrs/srs/issues/1575#issuecomment-574995475
+ EXPECT_STREQ("rtmp://target.net:8888/live", prop->to_str().c_str());
+
+ prop = ex->get_property("redirect2");
+ ASSERT_TRUE(prop && prop->is_string());
+ // The recirect2 is RTMP URL.
+ // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798
EXPECT_STREQ("rtmp://target.net:8888/live/livestream", prop->to_str().c_str());
srs_freep(msg);