add linux version of band check app; add web version of band check app
正在显示
4 个修改的文件
包含
156 行增加
和
1 行删除
@@ -238,6 +238,7 @@ function srs_init(rtmp_url, hls_url, modal_player) { | @@ -238,6 +238,7 @@ function srs_init(rtmp_url, hls_url, modal_player) { | ||
238 | $(modal_player).css("margin-left", "-" + srs_get_player_modal() / 2 +"px"); | 238 | $(modal_player).css("margin-left", "-" + srs_get_player_modal() / 2 +"px"); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | + | ||
241 | // for the chat to init the publish url. | 242 | // for the chat to init the publish url. |
242 | function srs_init_publish(rtmp_url) { | 243 | function srs_init_publish(rtmp_url) { |
243 | update_nav(); | 244 | update_nav(); |
@@ -247,6 +248,34 @@ function srs_init_publish(rtmp_url) { | @@ -247,6 +248,34 @@ function srs_init_publish(rtmp_url) { | ||
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
251 | +// for bw to init url | ||
252 | +// url: scheme://host:port/path?query#fragment | ||
253 | +function srs_init_bwt(rtmp_url, hls_url) { | ||
254 | + update_nav(); | ||
255 | + | ||
256 | + if (rtmp_url) { | ||
257 | + //var query = parse_query_string(); | ||
258 | + var search_filed = String(window.location.search).replace(" ", "").split("?")[1]; | ||
259 | + $(rtmp_url).val("rtmp://" + window.location.host + ":" + 1935 + "/app?" + search_filed); | ||
260 | + } | ||
261 | + if (hls_url) { | ||
262 | + $(hls_url).val(build_default_hls_url()); | ||
263 | + } | ||
264 | +} | ||
265 | + | ||
266 | +function srs_bwt_check_url(url) { | ||
267 | + if (url.indexOf("key") != -1 && url.indexOf("vhost") != -1) { | ||
268 | + return true; | ||
269 | + } | ||
270 | + | ||
271 | + return false; | ||
272 | +} | ||
273 | + | ||
274 | +function srs_bwt_build_default_url() { | ||
275 | + var url_default = "rtmp://" + window.location.host + ":" + 1935 + "/app?key=35c9b402c12a7246868752e2878f7e0e&vhost=bandcheck.srs.com"; | ||
276 | + return url_default; | ||
277 | +} | ||
278 | + | ||
250 | /** | 279 | /** |
251 | * when publisher ready, init the page elements. | 280 | * when publisher ready, init the page elements. |
252 | */ | 281 | */ |
@@ -53,7 +53,7 @@ | @@ -53,7 +53,7 @@ | ||
53 | // get the vhost and port to set the default url. | 53 | // get the vhost and port to set the default url. |
54 | // for example: http://192.168.1.213/players/jwplayer6.html?port=1935&vhost=demo | 54 | // for example: http://192.168.1.213/players/jwplayer6.html?port=1935&vhost=demo |
55 | // url set to: rtmp://demo:1935/live/livestream | 55 | // url set to: rtmp://demo:1935/live/livestream |
56 | - srs_init("#txt_url", null, "#main_modal"); | 56 | + //srs_init("#txt_url", null, "#main_modal"); |
57 | 57 | ||
58 | $("#main_modal").on("hide", function(){ | 58 | $("#main_modal").on("hide", function(){ |
59 | osmf_play("http://localhost"); | 59 | osmf_play("http://localhost"); |
@@ -12,10 +12,106 @@ | @@ -12,10 +12,106 @@ | ||
12 | body{ | 12 | body{ |
13 | padding-top: 55px; | 13 | padding-top: 55px; |
14 | } | 14 | } |
15 | + #main_modal { | ||
16 | + width: 600px; | ||
17 | + margin-left: -300px; | ||
18 | + } | ||
19 | + #check_status { | ||
20 | + margin-left: 20px; | ||
21 | + margin-top: -55px; | ||
22 | + } | ||
23 | + #pb_buffer_bg { | ||
24 | + margin-top: 40px; | ||
25 | + margin-bottom: 10px; | ||
26 | + } | ||
15 | </style> | 27 | </style> |
16 | <script type="text/javascript"> | 28 | <script type="text/javascript"> |
29 | + | ||
30 | + function update_progress(percent) { | ||
31 | + $("#progress_bar").width(percent); | ||
32 | + } | ||
33 | + | ||
34 | + function progress_reset() { | ||
35 | + $("#progress_bar").width("0%"); | ||
36 | + } | ||
37 | + | ||
38 | + function update_status(text) { | ||
39 | + $("#check_status").text(text); | ||
40 | + } | ||
41 | + | ||
42 | + function get_swf_width() { | ||
43 | + return 1; | ||
44 | + } | ||
45 | + | ||
46 | + function get_swf_height() { | ||
47 | + return 1; | ||
48 | + } | ||
49 | + | ||
50 | + function show_modal() { | ||
51 | + $("#main_modal").modal({show:true, keyboard:false}); | ||
52 | + } | ||
53 | + | ||
54 | + function band_check(url) { | ||
55 | + | ||
56 | + // remove flash contet | ||
57 | + var bw_div = $("<div/>"); | ||
58 | + $(bw_div).attr("id", "bw_div"); | ||
59 | + $("#bw_center").append(bw_div); | ||
60 | + | ||
61 | + var flashvars = {}; | ||
62 | + flashvars.url = url; | ||
63 | + flashvars.update_progress = "update_progress"; | ||
64 | + flashvars.progress_reset = "progress_reset"; | ||
65 | + flashvars.update_status = "update_status"; | ||
66 | + | ||
67 | + var params = {}; | ||
68 | + params.allowFullScreen = true; | ||
69 | + | ||
70 | + var attributes = {}; | ||
71 | + | ||
72 | + swfobject.embedSWF( | ||
73 | + "srs_bwt/release/srs_bwt.swf", "bw_div", | ||
74 | + get_swf_width(), get_swf_height(), | ||
75 | + "11.1.0", "js/AdobeFlashPlayerInstall.swf", | ||
76 | + flashvars, params, attributes | ||
77 | + ); | ||
78 | + } | ||
79 | + | ||
17 | $(function(){ | 80 | $(function(){ |
18 | update_nav(); | 81 | update_nav(); |
82 | + srs_init_bwt("#txt_url"); | ||
83 | + | ||
84 | + var txt_input = $("#txt_url").val(); | ||
85 | + // if valid ? | ||
86 | + if (!srs_bwt_check_url(txt_input)) { | ||
87 | + $("#txt_url").val(srs_bwt_build_default_url()); | ||
88 | + } | ||
89 | + | ||
90 | + $("#main_modal").on( | ||
91 | + "show", | ||
92 | + function() | ||
93 | + { | ||
94 | + progress_reset(); | ||
95 | + update_status(""); | ||
96 | + var url = $("#txt_url").val(); | ||
97 | + /*! | ||
98 | + url encode | ||
99 | + */ | ||
100 | + url = escape(url); | ||
101 | + band_check(url); | ||
102 | + } | ||
103 | + ); | ||
104 | + | ||
105 | + $("#main_modal").on("hide", function(){ | ||
106 | + $("#bw_div").remove(); | ||
107 | + }); | ||
108 | + | ||
109 | + $("#btn_play").click( | ||
110 | + function() | ||
111 | + { | ||
112 | + $("#main_modal").modal({show:true, keyboard:false}); | ||
113 | + } | ||
114 | + ); | ||
19 | }); | 115 | }); |
20 | </script> | 116 | </script> |
21 | </head> | 117 | </head> |
@@ -39,6 +135,34 @@ | @@ -39,6 +135,34 @@ | ||
39 | </div> | 135 | </div> |
40 | </div> | 136 | </div> |
41 | <div class="container"> | 137 | <div class="container"> |
138 | + | ||
139 | + <div class="form-inline"> | ||
140 | + URL: | ||
141 | + <input type="text" id="txt_url" class="input-xxlarge" value="" placeholder="例如:rtmp://host:port/app?key=xx&vhost=yy"></input> | ||
142 | + <button class="btn btn-primary" id="btn_play">开始测速</button> | ||
143 | + </div> | ||
144 | + | ||
145 | + <div id="main_modal" class="modal hide fade"> | ||
146 | + <div class="modal-header"> | ||
147 | + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | ||
148 | + <h3>SRS Band Check</h3> | ||
149 | + </div> | ||
150 | + <div class="modal-body"> | ||
151 | + <div id="player"></div> | ||
152 | + <div class="progress progress-striped active" id="pb_buffer_bg"> | ||
153 | + <div class="bar" style="width: 50%;" id="progress_bar"></div> | ||
154 | + </div> | ||
155 | + </div> | ||
156 | + | ||
157 | + <div class="modal-body" id="bw_center"> | ||
158 | + </div> | ||
159 | + <span id="check_status1"><font ><strong id="check_status">status</strong></font> </span> | ||
160 | + | ||
161 | + <div class="modal-footer"> | ||
162 | + <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true"> 关闭 </button> | ||
163 | + </div> | ||
164 | + </div> | ||
165 | + | ||
42 | <hr> | 166 | <hr> |
43 | <footer> | 167 | <footer> |
44 | <p><a href="https://github.com/winlinvip/simple-rtmp-server">SRS Team © 2013</a></p> | 168 | <p><a href="https://github.com/winlinvip/simple-rtmp-server">SRS Team © 2013</a></p> |
@@ -40,6 +40,8 @@ cat<<END | @@ -40,6 +40,8 @@ cat<<END | ||
40 | http://$ip/players/srs_publisher.html?vhost=players | 40 | http://$ip/players/srs_publisher.html?vhost=players |
41 | 视频会议(聊天室)应用演示: | 41 | 视频会议(聊天室)应用演示: |
42 | http://$ip/players/srs_chat.html?vhost=players | 42 | http://$ip/players/srs_chat.html?vhost=players |
43 | +默认的测速应用演示: | ||
44 | + http://$ip/players/srs_bwt.html?key=35c9b402c12a7246868752e2878f7e0e&vhost=bandcheck.srs.com | ||
43 | END | 45 | END |
44 | echo -e "${GREEN}演示地址:${BLACK}" | 46 | echo -e "${GREEN}演示地址:${BLACK}" |
45 | echo -e "${RED} http://$ip${BLACK}" | 47 | echo -e "${RED} http://$ip${BLACK}" |
-
请 注册 或 登录 后发表评论