{{stream.id}} |
{{stream.name| sc_filter_less}} |
+ {{stream |sc_filter_streamURL}} |
{{stream.owner.name}} |
{{stream.publish.active| sc_filter_has_stream}} |
{{stream.clients}}人 |
diff --git a/trunk/src/app/srs_app_http_static.cpp b/trunk/src/app/srs_app_http_static.cpp
index a8a137551..b9e3d5a2f 100644
--- a/trunk/src/app/srs_app_http_static.cpp
+++ b/trunk/src/app/srs_app_http_static.cpp
@@ -72,6 +72,10 @@ srs_error_t SrsHlsStream::serve_m3u8_ctx(ISrsHttpResponseWriter* w, ISrsHttpMess
{
string ctx = r->query_get(SRS_CONTEXT_IN_HLS);
+ // Correct the app and stream by path, which is created from template.
+ // @remark Be careful that the stream has extension now, might cause identify fail.
+ req->stream = srs_path_basename(r->path());
+
// Always make the ctx alive now.
alive(ctx, req);
diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp
index 1a20d9e31..246f54b1e 100755
--- a/trunk/src/app/srs_app_http_stream.cpp
+++ b/trunk/src/app/srs_app_http_stream.cpp
@@ -523,6 +523,10 @@ srs_error_t SrsLiveStream::update_auth(SrsLiveSource* s, SrsRequest* r)
srs_error_t SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
{
srs_error_t err = srs_success;
+
+ // Correct the app and stream by path, which is created from template.
+ // @remark Be careful that the stream has extension now, might cause identify fail.
+ req->stream = srs_path_basename(r->path());
if ((err = http_hooks_on_play(r)) != srs_success) {
return srs_error_wrap(err, "http hook");
@@ -588,7 +592,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
SrsHttpConn* hc = dynamic_cast(hr->connection());
// update client ip
- req->ip = hc->remote_ip();
+ req->ip = hc->remote_ip();
// update the statistic when source disconveried.
SrsStatistic* stat = SrsStatistic::instance();
diff --git a/trunk/src/app/srs_app_srt_conn.cpp b/trunk/src/app/srs_app_srt_conn.cpp
index be484c8d5..a6bedb312 100644
--- a/trunk/src/app/srs_app_srt_conn.cpp
+++ b/trunk/src/app/srs_app_srt_conn.cpp
@@ -263,7 +263,7 @@ srs_error_t SrsMpegtsSrtConn::do_cycle()
// Detect streamid of srt to request.
SrtMode mode = SrtModePull;
- if (! srs_srt_streamid_to_request(streamid, mode, req_)) {
+ if (!srs_srt_streamid_to_request(streamid, mode, req_)) {
return srs_error_new(ERROR_SRT_CONN, "invalid srt streamid=%s", streamid.c_str());
}
@@ -288,9 +288,6 @@ srs_error_t SrsMpegtsSrtConn::do_cycle()
return srs_error_wrap(err, "on connect");
}
- // Build the tcUrl which is vhost/app.
- req_->tcUrl = srs_generate_tc_url(req_->host, req_->vhost, req_->app, req_->port);
-
if (mode == SrtModePush) {
err = publishing();
} else if (mode == SrtModePull) {
diff --git a/trunk/src/app/srs_app_srt_utility.cpp b/trunk/src/app/srs_app_srt_utility.cpp
index 9db695a2c..cd7fd8cb0 100644
--- a/trunk/src/app/srs_app_srt_utility.cpp
+++ b/trunk/src/app/srs_app_srt_utility.cpp
@@ -139,5 +139,9 @@ bool srs_srt_streamid_to_request(const std::string& streamid, SrtMode& mode, Srs
request->param = stream_with_params.substr(pos + 1);
}
+ request->host = srs_get_public_internet_address();
+ if (request->vhost.empty()) request->vhost = request->host;
+ request->tcUrl = srs_generate_tc_url("srt", request->host, request->vhost, request->app, request->port);
+
return ret;
}
diff --git a/trunk/src/core/srs_core_version5.hpp b/trunk/src/core/srs_core_version5.hpp
index 1a5e273a8..874565004 100644
--- a/trunk/src/core/srs_core_version5.hpp
+++ b/trunk/src/core/srs_core_version5.hpp
@@ -9,6 +9,6 @@
#define VERSION_MAJOR 5
#define VERSION_MINOR 0
-#define VERSION_REVISION 53
+#define VERSION_REVISION 54
#endif
diff --git a/trunk/src/protocol/srs_protocol_rtmp_conn.cpp b/trunk/src/protocol/srs_protocol_rtmp_conn.cpp
index bcffe5e58..cf9c87aec 100644
--- a/trunk/src/protocol/srs_protocol_rtmp_conn.cpp
+++ b/trunk/src/protocol/srs_protocol_rtmp_conn.cpp
@@ -111,7 +111,7 @@ srs_error_t SrsBasicRtmpClient::do_connect_app(string local_ip, bool debug)
// generate the tcUrl
std::string param = "";
std::string target_vhost = req->vhost;
- std::string tc_url = srs_generate_tc_url(req->host, req->vhost, req->app, req->port);
+ std::string tc_url = srs_generate_tc_url("rtmp", req->host, req->vhost, req->app, req->port);
// replace the tcUrl in request,
// which will replace the tc_url in client.connect_app().
diff --git a/trunk/src/protocol/srs_protocol_rtmp_stack.cpp b/trunk/src/protocol/srs_protocol_rtmp_stack.cpp
index 23a997574..8a7587e52 100644
--- a/trunk/src/protocol/srs_protocol_rtmp_stack.cpp
+++ b/trunk/src/protocol/srs_protocol_rtmp_stack.cpp
@@ -1544,6 +1544,7 @@ void SrsRequest::strip()
SrsRequest* SrsRequest::as_http()
{
schema = "http";
+ tcUrl = srs_generate_tc_url(schema, host, vhost, app, port);
return this;
}
diff --git a/trunk/src/protocol/srs_protocol_utility.cpp b/trunk/src/protocol/srs_protocol_utility.cpp
index 31a282ab1..c99f06e9d 100644
--- a/trunk/src/protocol/srs_protocol_utility.cpp
+++ b/trunk/src/protocol/srs_protocol_utility.cpp
@@ -175,9 +175,9 @@ long srs_random()
return random();
}
-string srs_generate_tc_url(string host, string vhost, string app, int port)
+string srs_generate_tc_url(string schema, string host, string vhost, string app, int port)
{
- string tcUrl = "rtmp://";
+ string tcUrl = schema + "://";
if (vhost == SRS_CONSTS_RTMP_DEFAULT_VHOST) {
tcUrl += host.empty() ? SRS_CONSTS_RTMP_DEFAULT_VHOST : host;
@@ -324,10 +324,9 @@ string srs_generate_stream_url(string vhost, string app, string stream)
if (SRS_CONSTS_RTMP_DEFAULT_VHOST != vhost){
url += vhost;
}
- url += "/";
- url += app;
- url += "/";
- url += stream;
+ url += "/" + app;
+ // Note that we ignore any extension.
+ url += "/" + srs_path_filename(stream);
return url;
}
diff --git a/trunk/src/protocol/srs_protocol_utility.hpp b/trunk/src/protocol/srs_protocol_utility.hpp
index 8b834b864..6324789c7 100644
--- a/trunk/src/protocol/srs_protocol_utility.hpp
+++ b/trunk/src/protocol/srs_protocol_utility.hpp
@@ -76,7 +76,7 @@ extern long srs_random();
* generate the tcUrl without param.
* @remark Use host as tcUrl.vhost if vhost is default vhost.
*/
-extern std::string srs_generate_tc_url(std::string host, std::string vhost, std::string app, int port);
+extern std::string srs_generate_tc_url(std::string schema, std::string host, std::string vhost, std::string app, int port);
/**
* Generate the stream with param.
diff --git a/trunk/src/utest/srs_utest_protocol.cpp b/trunk/src/utest/srs_utest_protocol.cpp
index 7b3cacee5..cddc971fd 100644
--- a/trunk/src/utest/srs_utest_protocol.cpp
+++ b/trunk/src/utest/srs_utest_protocol.cpp
@@ -581,15 +581,15 @@ VOID TEST(ProtocolUtilityTest, GenerateTcUrl)
string ip; string vhost; string app; int port; string tcUrl; string param;
ip = "127.0.0.1"; vhost = "__defaultVhost__"; app = "live"; port = 1935;
- tcUrl = srs_generate_tc_url(ip, vhost, app, port);
+ tcUrl = srs_generate_tc_url("rtmp", ip, vhost, app, port);
EXPECT_STREQ("rtmp://127.0.0.1/live", tcUrl.c_str());
ip = "127.0.0.1"; vhost = "demo"; app = "live"; port = 1935;
- tcUrl = srs_generate_tc_url(ip, vhost, app, port);
+ tcUrl = srs_generate_tc_url("rtmp", ip, vhost, app, port);
EXPECT_STREQ("rtmp://demo/live", tcUrl.c_str());
ip = "127.0.0.1"; vhost = "demo"; app = "live"; port = 19351;
- tcUrl = srs_generate_tc_url(ip, vhost, app, port);
+ tcUrl = srs_generate_tc_url("rtmp", ip, vhost, app, port);
EXPECT_STREQ("rtmp://demo:19351/live", tcUrl.c_str());
}
@@ -7023,3 +7023,15 @@ VOID TEST(ProtocolKbpsTest, RAWStatisticSugar)
}
}
+VOID TEST(ProtocolKbpsTest, StreamIdentify)
+{
+ EXPECT_STREQ("/live/livestream", srs_generate_stream_url("", "live", "livestream").c_str());
+ EXPECT_STREQ("/live/livestream", srs_generate_stream_url("", "live", "livestream.flv").c_str());
+ EXPECT_STREQ("/live/livestream", srs_generate_stream_url("", "live", "livestream.m3u8").c_str());
+ EXPECT_STREQ("/live/livestream", srs_generate_stream_url("__defaultVhost__", "live", "livestream").c_str());
+
+ EXPECT_STREQ("ossrs.io/live/livestream", srs_generate_stream_url("ossrs.io", "live", "livestream").c_str());
+ EXPECT_STREQ("ossrs.io/live/livestream", srs_generate_stream_url("ossrs.io", "live", "livestream.flv").c_str());
+ EXPECT_STREQ("ossrs.io/live/livestream", srs_generate_stream_url("ossrs.io", "live", "livestream.m3u8").c_str());
+}
+
diff --git a/trunk/src/utest/srs_utest_srt.cpp b/trunk/src/utest/srs_utest_srt.cpp
index ecdcaf163..beb11f3fc 100644
--- a/trunk/src/utest/srs_utest_srt.cpp
+++ b/trunk/src/utest/srs_utest_srt.cpp
@@ -423,7 +423,7 @@ VOID TEST(ProtocolSrtTest, SrtStreamIdToRequest)
SrsRequest req;
EXPECT_TRUE(srs_srt_streamid_to_request("#!::r=live/livestream?key1=val1,key2=val2", mode, &req));
EXPECT_EQ(mode, SrtModePull);
- EXPECT_STREQ(req.vhost.c_str(), "");
+ EXPECT_STREQ(req.vhost.c_str(), srs_get_public_internet_address().c_str());
EXPECT_STREQ(req.app.c_str(), "live");
EXPECT_STREQ(req.stream.c_str(), "livestream");
EXPECT_STREQ(req.param.c_str(), "key1=val1&key2=val2");
@@ -445,7 +445,7 @@ VOID TEST(ProtocolSrtTest, SrtStreamIdToRequest)
SrsRequest req;
EXPECT_TRUE(srs_srt_streamid_to_request("#!::h=live/livestream?key1=val1,key2=val2", mode, &req));
EXPECT_EQ(mode, SrtModePull);
- EXPECT_STREQ(req.vhost.c_str(), "");
+ EXPECT_STREQ(req.vhost.c_str(), srs_get_public_internet_address().c_str());
EXPECT_STREQ(req.app.c_str(), "live");
EXPECT_STREQ(req.stream.c_str(), "livestream");
EXPECT_STREQ(req.param.c_str(), "key1=val1&key2=val2");