fix demo script, start nginx. fix warning of utest on ubuntu14
正在显示
7 个修改的文件
包含
37 行增加
和
16 行删除
@@ -4,7 +4,7 @@ if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; | @@ -4,7 +4,7 @@ if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; | ||
4 | 4 | ||
5 | # step 1: build srs | 5 | # step 1: build srs |
6 | echo "编译SRS" | 6 | echo "编译SRS" |
7 | -./configure --x86-x64 && make | 7 | +./configure --x86-x64 --with-nginx && make |
8 | ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi | 8 | ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi |
9 | 9 | ||
10 | echo "编译SRS成功" | 10 | echo "编译SRS成功" |
@@ -8,6 +8,9 @@ GREEN="\\e[32m" | @@ -8,6 +8,9 @@ GREEN="\\e[32m" | ||
8 | YELLOW="\\e[33m" | 8 | YELLOW="\\e[33m" |
9 | BLACK="\\e[0m" | 9 | BLACK="\\e[0m" |
10 | 10 | ||
11 | +sudo ./objs/nginx/sbin/nginx | ||
12 | +echo "启动nginx" | ||
13 | + | ||
11 | ./etc/init.d/srs-demo restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi | 14 | ./etc/init.d/srs-demo restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi |
12 | echo "启动SRS服务器成功" | 15 | echo "启动SRS服务器成功" |
13 | 16 |
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | +sudo ./objs/nginx/sbin/nginx -s stop | ||
4 | +echo "停止nginx" | ||
5 | + | ||
3 | ./etc/init.d/srs-demo stop; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:停止SRS失败"; exit $ret; fi | 6 | ./etc/init.d/srs-demo stop; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:停止SRS失败"; exit $ret; fi |
4 | echo "停止SRS服务器成功" | 7 | echo "停止SRS服务器成功" |
5 | 8 |
@@ -262,18 +262,7 @@ int srs_connect_app(srs_rtmp_t rtmp) | @@ -262,18 +262,7 @@ int srs_connect_app(srs_rtmp_t rtmp) | ||
262 | srs_assert(rtmp != NULL); | 262 | srs_assert(rtmp != NULL); |
263 | Context* context = (Context*)rtmp; | 263 | Context* context = (Context*)rtmp; |
264 | 264 | ||
265 | - string tcUrl = "rtmp://"; | ||
266 | - // TODO: FIXME: extrace shared method | ||
267 | - if (context->vhost == RTMP_VHOST_DEFAULT) { | ||
268 | - tcUrl += context->ip; | ||
269 | - } else { | ||
270 | - tcUrl += context->vhost; | ||
271 | - } | ||
272 | - tcUrl += ":"; | ||
273 | - tcUrl += context->port; | ||
274 | - tcUrl += "/"; | ||
275 | - tcUrl += context->app; | ||
276 | - | 265 | + string tcUrl = srs_generate_tc_url(context->ip, context->vhost, context->app, context->port); |
277 | if ((ret = context->rtmp->connect_app(context->app, tcUrl)) != ERROR_SUCCESS) { | 266 | if ((ret = context->rtmp->connect_app(context->app, tcUrl)) != ERROR_SUCCESS) { |
278 | return ret; | 267 | return ret; |
279 | } | 268 | } |
@@ -24,11 +24,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -24,11 +24,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
24 | #include <srs_protocol_utility.hpp> | 24 | #include <srs_protocol_utility.hpp> |
25 | 25 | ||
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | +using namespace std; | ||
27 | 28 | ||
28 | #include <srs_kernel_log.hpp> | 29 | #include <srs_kernel_log.hpp> |
29 | #include <srs_kernel_utility.hpp> | 30 | #include <srs_kernel_utility.hpp> |
30 | 31 | ||
31 | -void srs_vhost_resolve(std::string& vhost, std::string& app) | 32 | +void srs_vhost_resolve(string& vhost, string& app) |
32 | { | 33 | { |
33 | app = srs_string_replace(app, "...", "?"); | 34 | app = srs_string_replace(app, "...", "?"); |
34 | 35 | ||
@@ -71,3 +72,24 @@ void srs_random_generate(char* bytes, int size) | @@ -71,3 +72,24 @@ void srs_random_generate(char* bytes, int size) | ||
71 | bytes[i] = cdata[rand() % (sizeof(cdata) - 1)]; | 72 | bytes[i] = cdata[rand() % (sizeof(cdata) - 1)]; |
72 | } | 73 | } |
73 | } | 74 | } |
75 | + | ||
76 | +string srs_generate_tc_url(string ip, string vhost, string app, string port) | ||
77 | +{ | ||
78 | + string tcUrl = "rtmp://"; | ||
79 | + | ||
80 | + if (vhost == RTMP_VHOST_DEFAULT) { | ||
81 | + tcUrl += ip; | ||
82 | + } else { | ||
83 | + tcUrl += vhost; | ||
84 | + } | ||
85 | + | ||
86 | + if (port != RTMP_DEFAULT_PORT) { | ||
87 | + tcUrl += ":"; | ||
88 | + tcUrl += port; | ||
89 | + } | ||
90 | + | ||
91 | + tcUrl += "/"; | ||
92 | + tcUrl += app; | ||
93 | + | ||
94 | + return tcUrl; | ||
95 | +} |
@@ -31,9 +31,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,9 +31,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
31 | 31 | ||
32 | #include <string> | 32 | #include <string> |
33 | 33 | ||
34 | -// default vhost for rtmp | 34 | +// default vhost of rtmp |
35 | #define RTMP_VHOST_DEFAULT "__defaultVhost__" | 35 | #define RTMP_VHOST_DEFAULT "__defaultVhost__" |
36 | - | 36 | +// default port of rtmp |
37 | #define RTMP_DEFAULT_PORT "1935" | 37 | #define RTMP_DEFAULT_PORT "1935" |
38 | 38 | ||
39 | // the default chunk size for system. | 39 | // the default chunk size for system. |
@@ -45,6 +45,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -45,6 +45,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
45 | // app...vhost...request_vhost | 45 | // app...vhost...request_vhost |
46 | extern void srs_vhost_resolve(std::string& vhost, std::string& app); | 46 | extern void srs_vhost_resolve(std::string& vhost, std::string& app); |
47 | 47 | ||
48 | +// generate ramdom data for handshake. | ||
48 | extern void srs_random_generate(char* bytes, int size); | 49 | extern void srs_random_generate(char* bytes, int size); |
49 | 50 | ||
51 | +// generate the tcUrl. | ||
52 | +extern std::string srs_generate_tc_url(std::string ip, std::string vhost, std::string app, std::string port); | ||
53 | + | ||
50 | #endif | 54 | #endif |
此 diff 太大无法显示。
-
请 注册 或 登录 后发表评论