正在显示
5 个修改的文件
包含
48 行增加
和
2 行删除
@@ -5,3 +5,4 @@ Authors ordered by first contribution. | @@ -5,3 +5,4 @@ Authors ordered by first contribution. | ||
5 | * xiangcheng.liu<liuxc0116@foxmail.com> | 5 | * xiangcheng.liu<liuxc0116@foxmail.com> |
6 | * naijia.liu<youngcow@youngcow.net> | 6 | * naijia.liu<youngcow@youngcow.net> |
7 | * alcoholyi<alcoholyi@qq.com> | 7 | * alcoholyi<alcoholyi@qq.com> |
8 | +* byteman<wangchen2011@gmail.com> |
@@ -91,6 +91,30 @@ http_stream { | @@ -91,6 +91,30 @@ http_stream { | ||
91 | vhost __defaultVhost__ { | 91 | vhost __defaultVhost__ { |
92 | } | 92 | } |
93 | 93 | ||
94 | +# vhost for edge, edge and origin is the same vhost | ||
95 | +vhost same.edge.srs.com { | ||
96 | + # the mode of vhost, local or remote. | ||
97 | + # local: vhost is origin vhost, which provides stream source. | ||
98 | + # remote: vhost is edge vhost, which pull/push to origin. | ||
99 | + # default: local | ||
100 | + mode remote; | ||
101 | + # for edge(remote mode), user must specifies the origin server | ||
102 | + # format as: <server_name|ip>[:port] | ||
103 | + # @remark user can specifies multiple origin for error backup, by space, | ||
104 | + # for example, 192.168.1.100:1935 192.168.1.101:1935 192.168.1.102:1935 | ||
105 | + origin 127.0.0.1:1935 localhost:1935; | ||
106 | +} | ||
107 | +# vhost for edge, chnage vhost. | ||
108 | +vhost change.edge.srs.com { | ||
109 | + mode remote; | ||
110 | + origin 127.0.0.1:1935 localhost:1935 { | ||
111 | + # specify the vhost to override the vhost in client request. | ||
112 | + vhost edge2.srs.com; | ||
113 | + # specify the refer(pageUrl) to override the refer in client request. | ||
114 | + refer http://srs/index.html; | ||
115 | + } | ||
116 | +} | ||
117 | + | ||
94 | # vhost for dvr | 118 | # vhost for dvr |
95 | vhost dvr.srs.com { | 119 | vhost dvr.srs.com { |
96 | # dvr RTMP stream to file, | 120 | # dvr RTMP stream to file, |
@@ -1805,6 +1805,22 @@ int SrsConfig::get_bw_check_limit_kbps(const string &vhost) | @@ -1805,6 +1805,22 @@ int SrsConfig::get_bw_check_limit_kbps(const string &vhost) | ||
1805 | return ::atoi(conf->arg0().c_str()); | 1805 | return ::atoi(conf->arg0().c_str()); |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | +bool SrsConfig::get_vhost_is_edge(std::string vhost) | ||
1809 | +{ | ||
1810 | + SrsConfDirective* conf = get_vhost(vhost); | ||
1811 | + | ||
1812 | + if (!conf) { | ||
1813 | + return false; | ||
1814 | + } | ||
1815 | + | ||
1816 | + conf = conf->get("mode"); | ||
1817 | + if (!conf || conf->arg0() != "remote") { | ||
1818 | + return false; | ||
1819 | + } | ||
1820 | + | ||
1821 | + return true; | ||
1822 | +} | ||
1823 | + | ||
1808 | SrsConfDirective* SrsConfig::get_transcode(string vhost, string scope) | 1824 | SrsConfDirective* SrsConfig::get_transcode(string vhost, string scope) |
1809 | { | 1825 | { |
1810 | SrsConfDirective* conf = get_vhost(vhost); | 1826 | SrsConfDirective* conf = get_vhost(vhost); |
@@ -163,7 +163,7 @@ public: | @@ -163,7 +163,7 @@ public: | ||
163 | virtual int get_pithy_print_ingester(); | 163 | virtual int get_pithy_print_ingester(); |
164 | virtual int get_pithy_print_hls(); | 164 | virtual int get_pithy_print_hls(); |
165 | virtual int get_pithy_print_play(); | 165 | virtual int get_pithy_print_play(); |
166 | -// vhost section | 166 | +// vhost specified section |
167 | public: | 167 | public: |
168 | virtual SrsConfDirective* get_vhost(std::string vhost); | 168 | virtual SrsConfDirective* get_vhost(std::string vhost); |
169 | virtual void get_vhosts(std::vector<SrsConfDirective*>& vhosts); | 169 | virtual void get_vhosts(std::vector<SrsConfDirective*>& vhosts); |
@@ -190,6 +190,9 @@ public: | @@ -190,6 +190,9 @@ public: | ||
190 | virtual std::string get_bw_check_key(const std::string& vhost); | 190 | virtual std::string get_bw_check_key(const std::string& vhost); |
191 | virtual int get_bw_check_interval_ms(const std::string& vhost); | 191 | virtual int get_bw_check_interval_ms(const std::string& vhost); |
192 | virtual int get_bw_check_limit_kbps(const std::string& vhost); | 192 | virtual int get_bw_check_limit_kbps(const std::string& vhost); |
193 | +// vhost edge section | ||
194 | +public: | ||
195 | + virtual bool get_vhost_is_edge(std::string vhost); | ||
193 | // vhost transcode section | 196 | // vhost transcode section |
194 | public: | 197 | public: |
195 | virtual SrsConfDirective* get_transcode(std::string vhost, std::string scope); | 198 | virtual SrsConfDirective* get_transcode(std::string vhost, std::string scope); |
@@ -286,8 +286,10 @@ int SrsRtmpConn::stream_service_cycle() | @@ -286,8 +286,10 @@ int SrsRtmpConn::stream_service_cycle() | ||
286 | return ret; | 286 | return ret; |
287 | } | 287 | } |
288 | 288 | ||
289 | + bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost); | ||
289 | bool enabled_cache = _srs_config->get_gop_cache(req->vhost); | 290 | bool enabled_cache = _srs_config->get_gop_cache(req->vhost); |
290 | - srs_trace("source found, url=%s, enabled_cache=%d", req->get_stream_url().c_str(), enabled_cache); | 291 | + srs_trace("source found, url=%s, enabled_cache=%d, edge=%d", |
292 | + req->get_stream_url().c_str(), enabled_cache, vhost_is_edge); | ||
291 | source->set_cache(enabled_cache); | 293 | source->set_cache(enabled_cache); |
292 | 294 | ||
293 | switch (type) { | 295 | switch (type) { |
-
请 注册 或 登录 后发表评论