merge from 2.0.155

pull/499/head
winlin 10 years ago
commit cb148e43ee

@ -566,6 +566,7 @@ Supported operating systems and hardware:
### SRS 2.0 history
* v2.0, 2015-03-30, for [#372](https://github.com/winlinvip/simple-rtmp-server/issues/372), support transform vhost of edge 2.0.155.
* v2.0, 2015-03-30, for [#366](https://github.com/winlinvip/simple-rtmp-server/issues/366), config hls to disable cleanup of ts. 2.0.154.
* v2.0, 2015-03-31, support server cycle handler. 2.0.153.
* v2.0, 2015-03-31, support on_hls for http hooks. 2.0.152.

@ -284,6 +284,17 @@ vhost same.edge.srs.com {
token_traverse off;
}
# vhost for edge, edge transform vhost to fetch from another vhost.
vhost transform.edge.srs.com {
mode remote;
origin 127.0.0.1:1935;
# the vhost to transform for edge,
# to fetch from the specified vhost at origin,
# if not specified, use the current vhost of edge in origin, the variable [vhost].
# default: [vhost]
vhost same.edge.srs.com;
}
# vhost for dvr
vhost dvr.srs.com {
# dvr RTMP stream to file,

@ -0,0 +1,27 @@
# the config for srs origin-edge cluster
# @see https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_Edge#transform-vhost
# @see full.conf for detail config.
listen 1935;
max_connections 1000;
vhost __defaultVhost__ {
}
vhost source.srs.com {
ingest livestream {
enabled on;
input {
type file;
url ./doc/source.200kbps.768x320.flv;
}
ffmpeg ./objs/ffmpeg/bin/ffmpeg;
engine {
enabled off;
output rtmp://127.0.0.1:[port]/live?vhost=[vhost]/livestream;
}
}
}
vhost transform.srs.edge.com {
mode remote;
origin 127.0.0.1:1935;
vhost source.srs.com;
}

@ -1409,7 +1409,7 @@ int SrsConfig::check_config()
SrsConfDirective* conf = vhost->at(i);
string n = conf->name;
if (n != "enabled" && n != "chunk_size"
&& n != "mode" && n != "origin" && n != "token_traverse"
&& n != "mode" && n != "origin" && n != "token_traverse" && n != "vhost"
&& n != "dvr" && n != "ingest" && n != "hls" && n != "http_hooks"
&& n != "gop_cache" && n != "queue_length"
&& n != "refer" && n != "refer_publish" && n != "refer_play"
@ -2517,12 +2517,12 @@ bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost)
SrsConfDirective* conf = vhost;
if (!conf) {
return false;
return SRS_CONF_DEFAULT_EDGE_MODE;
}
conf = conf->get("mode");
if (!conf || conf->arg0() != "remote") {
return false;
return SRS_CONF_DEFAULT_EDGE_MODE;
}
return true;
@ -2544,17 +2544,33 @@ bool SrsConfig::get_vhost_edge_token_traverse(string vhost)
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return false;
return SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE;
}
conf = conf->get("token_traverse");
if (!conf || conf->arg0() != "on") {
return false;
return SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE;
}
return true;
}
string SrsConfig::get_vhost_edge_transform_vhost(string vhost)
{
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST;
}
conf = conf->get("vhost");
if (!conf || conf->arg0().empty()) {
return SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST;
}
return conf->arg0();
}
bool SrsConfig::get_security_enabled(string vhost)
{
SrsConfDirective* conf = get_vhost(vhost);

@ -106,6 +106,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_CONF_DEFAULT_TRANSCODE_IFORMAT "flv"
#define SRS_CONF_DEFAULT_TRANSCODE_OFORMAT "flv"
#define SRS_CONF_DEFAULT_EDGE_MODE false
#define SRS_CONF_DEFAULT_EDGE_TOKEN_TRAVERSE false
#define SRS_CONF_DEFAULT_EDGE_TRANSFORM_VHOST "[vhost]"
// hds default value
#define SRS_CONF_DEFAULT_HDS_PATH "./objs/nginx/html"
#define SRS_CONF_DEFAULT_HDS_WINDOW (60)
@ -688,6 +692,11 @@ public:
* all clients connected to edge must be tranverse to origin to verify.
*/
virtual bool get_vhost_edge_token_traverse(std::string vhost);
/**
* get the transformed vhost for edge,
* @see https://github.com/winlinvip/simple-rtmp-server/issues/372
*/
virtual std::string get_vhost_edge_transform_vhost(std::string vhost);
// vhost security section
public:
/**

@ -43,6 +43,7 @@ using namespace std;
#include <srs_rtmp_msg_array.hpp>
#include <srs_app_utility.hpp>
#include <srs_rtmp_amf0.hpp>
#include <srs_kernel_utility.hpp>
// when error, edge ingester sleep for a while and retry.
#define SRS_EDGE_INGESTER_SLEEP_US (int64_t)(1*1000*1000LL)
@ -240,9 +241,18 @@ int SrsEdgeIngester::connect_app(string ep_server, string ep_port)
std::string local_ip = ips[_srs_config->get_stats_network()];
data->set("srs_server_ip", SrsAmf0Any::str(local_ip.c_str()));
// support vhost tranform for edge,
// @see https://github.com/winlinvip/simple-rtmp-server/issues/372
std::string vhost = _srs_config->get_vhost_edge_transform_vhost(req->vhost);
vhost = srs_string_replace(vhost, "[vhost]", req->vhost);
// generate the tcUrl
std::string param = "";
std::string tc_url = srs_generate_tc_url(ep_server, req->vhost, req->app, ep_port, param);
std::string tc_url = srs_generate_tc_url(ep_server, vhost, req->app, ep_port, param);
srs_trace("edge ingest from %s:%s at %s", ep_server.c_str(), ep_port.c_str(), tc_url.c_str());
// replace the tcUrl in request,
// which will replace the tc_url in client.connect_app().
req->tcUrl = tc_url;
// upnode server identity will show in the connect_app of client.
// @see https://github.com/winlinvip/simple-rtmp-server/issues/160
@ -662,9 +672,18 @@ int SrsEdgeForwarder::connect_app(string ep_server, string ep_port)
std::string local_ip = ips[_srs_config->get_stats_network()];
data->set("srs_server_ip", SrsAmf0Any::str(local_ip.c_str()));
// support vhost tranform for edge,
// @see https://github.com/winlinvip/simple-rtmp-server/issues/372
std::string vhost = _srs_config->get_vhost_edge_transform_vhost(req->vhost);
vhost = srs_string_replace(vhost, "[vhost]", req->vhost);
// generate the tcUrl
std::string param = "";
std::string tc_url = srs_generate_tc_url(ep_server, req->vhost, req->app, ep_port, param);
std::string tc_url = srs_generate_tc_url(ep_server, vhost, req->app, ep_port, param);
srs_trace("edge forward to %s:%s at %s", ep_server.c_str(), ep_port.c_str(), tc_url.c_str());
// replace the tcUrl in request,
// which will replace the tc_url in client.connect_app().
req->tcUrl = tc_url;
// upnode server identity will show in the connect_app of client.
// @see https://github.com/winlinvip/simple-rtmp-server/issues/160

Loading…
Cancel
Save