Merge branch '4.0release' into develop

pull/2128/head
winlin 4 years ago
commit 8fa093c53c

@ -209,6 +209,7 @@ For previous versions, please read:
## V3 changes
* v3.0, 2020-12-26, For RTMP edge/forward, pass vhost in tcUrl, not in stream. 3.0.156
* v3.0, 2020-12-17, Fix [#1694][bug #1694], Support DVR 2GB+ MP4 file. 3.0.155
* v3.0, 2020-12-17, Fix [#1548][bug #1548], Add edts in MP4 for Windows10. 3.0.154
* <strong>v3.0, 2020-10-31, [3.0 release2(3.0.153)][r3.0r2] released. 122663 lines.</strong>

@ -125,8 +125,10 @@ srs_error_t SrsEdgeRtmpUpstream::connect(SrsRequest* r, SrsLbRoundRobin* lb)
if ((err = sdk->connect()) != srs_success) {
return srs_error_wrap(err, "edge pull %s failed, cto=%dms, sto=%dms.", url.c_str(), srsu2msi(cto), srsu2msi(sto));
}
if ((err = sdk->play(_srs_config->get_chunk_size(req->vhost))) != srs_success) {
// For RTMP client, we pass the vhost in tcUrl when connecting,
// so we publish without vhost in stream.
if ((err = sdk->play(_srs_config->get_chunk_size(req->vhost), false)) != srs_success) {
return srs_error_wrap(err, "edge pull %s stream failed", url.c_str());
}
@ -506,8 +508,10 @@ srs_error_t SrsEdgeForwarder::start()
if ((err = sdk->connect()) != srs_success) {
return srs_error_wrap(err, "sdk connect %s failed, cto=%dms, sto=%dms.", url.c_str(), srsu2msi(cto), srsu2msi(sto));
}
if ((err = sdk->publish(_srs_config->get_chunk_size(req->vhost))) != srs_success) {
// For RTMP client, we pass the vhost in tcUrl when connecting,
// so we publish without vhost in stream.
if ((err = sdk->publish(_srs_config->get_chunk_size(req->vhost), false)) != srs_success) {
return srs_error_wrap(err, "sdk publish");
}
@ -517,7 +521,7 @@ srs_error_t SrsEdgeForwarder::start()
if ((err = trd->start()) != srs_success) {
return srs_error_wrap(err, "coroutine");
}
srs_trace("edge-fwr publish url %s", url.c_str());
srs_trace("edge-fwr publish url %s, stream=%s%s", url.c_str(), req->stream.c_str(), req->param.c_str());
return err;
}

@ -222,8 +222,10 @@ srs_error_t SrsForwarder::do_cycle()
if ((err = sdk->connect()) != srs_success) {
return srs_error_wrap(err, "sdk connect url=%s, cto=%dms, sto=%dms.", url.c_str(), srsu2msi(cto), srsu2msi(sto));
}
if ((err = sdk->publish(_srs_config->get_chunk_size(req->vhost))) != srs_success) {
// For RTMP client, we pass the vhost in tcUrl when connecting,
// so we publish without vhost in stream.
if ((err = sdk->publish(_srs_config->get_chunk_size(req->vhost), false)) != srs_success) {
return srs_error_wrap(err, "sdk publish");
}

@ -24,6 +24,6 @@
#ifndef SRS_CORE_VERSION3_HPP
#define SRS_CORE_VERSION3_HPP
#define SRS_VERSION3_REVISION 155
#define SRS_VERSION3_REVISION 156
#endif

@ -200,24 +200,26 @@ string srs_generate_tc_url(string host, string vhost, string app, int port)
return tcUrl;
}
string srs_generate_stream_with_query(string host, string vhost, string stream, string param)
string srs_generate_stream_with_query(string host, string vhost, string stream, string param, bool with_vhost)
{
string url = stream;
string query = param;
// If no vhost in param, try to append one.
string guessVhost;
if (query.find("vhost=") == string::npos) {
if (vhost != SRS_CONSTS_RTMP_DEFAULT_VHOST) {
guessVhost = vhost;
} else if (!srs_is_ipv4(host)) {
guessVhost = host;
if (with_vhost) {
// If no vhost in param, try to append one.
string guessVhost;
if (query.find("vhost=") == string::npos) {
if (vhost != SRS_CONSTS_RTMP_DEFAULT_VHOST) {
guessVhost = vhost;
} else if (!srs_is_ipv4(host)) {
guessVhost = host;
}
}
// Well, if vhost exists, always append in query string.
if (!guessVhost.empty()) {
query += "&vhost=" + guessVhost;
}
}
// Well, if vhost exists, always append in query string.
if (!guessVhost.empty()) {
query += "&vhost=" + guessVhost;
}
// Remove the start & when param is empty.

@ -82,7 +82,7 @@ extern std::string srs_generate_tc_url(std::string host, std::string vhost, std:
* Generate the stream with param.
* @remark Append vhost in query string if not default vhost.
*/
extern std::string srs_generate_stream_with_query(std::string host, std::string vhost, std::string stream, std::string param);
extern std::string srs_generate_stream_with_query(std::string host, std::string vhost, std::string stream, std::string param, bool with_vhost = true);
/**
* create shared ptr message from bytes.

@ -148,12 +148,12 @@ srs_error_t SrsBasicRtmpClient::do_connect_app(string local_ip, bool debug)
return err;
}
srs_error_t SrsBasicRtmpClient::publish(int chunk_size)
srs_error_t SrsBasicRtmpClient::publish(int chunk_size, bool with_vhost)
{
srs_error_t err = srs_success;
// Pass params in stream, @see https://github.com/ossrs/srs/issues/1031#issuecomment-409745733
string stream = srs_generate_stream_with_query(req->host, req->vhost, req->stream, req->param);
string stream = srs_generate_stream_with_query(req->host, req->vhost, req->stream, req->param, with_vhost);
// publish.
if ((err = client->publish(stream, stream_id, chunk_size)) != srs_success) {
@ -163,12 +163,12 @@ srs_error_t SrsBasicRtmpClient::publish(int chunk_size)
return err;
}
srs_error_t SrsBasicRtmpClient::play(int chunk_size)
srs_error_t SrsBasicRtmpClient::play(int chunk_size, bool with_vhost)
{
srs_error_t err = srs_success;
// Pass params in stream, @see https://github.com/ossrs/srs/issues/1031#issuecomment-409745733
string stream = srs_generate_stream_with_query(req->host, req->vhost, req->stream, req->param);
string stream = srs_generate_stream_with_query(req->host, req->vhost, req->stream, req->param, with_vhost);
if ((err = client->play(stream, stream_id, chunk_size)) != srs_success) {
return srs_error_wrap(err, "connect with server failed, stream=%s, stream_id=%d", stream.c_str(), stream_id);

@ -74,8 +74,8 @@ protected:
virtual srs_error_t connect_app();
virtual srs_error_t do_connect_app(std::string local_ip, bool debug);
public:
virtual srs_error_t publish(int chunk_size);
virtual srs_error_t play(int chunk_size);
virtual srs_error_t publish(int chunk_size, bool with_vhost = true);
virtual srs_error_t play(int chunk_size, bool with_vhost = true);
virtual void kbps_sample(const char* label, int64_t age);
virtual void kbps_sample(const char* label, int64_t age, int msgs);
virtual int sid();

Loading…
Cancel
Save