wenjiegit

add linux version of band check app; add web version of band check app

... ... @@ -238,6 +238,7 @@ function srs_init(rtmp_url, hls_url, modal_player) {
$(modal_player).css("margin-left", "-" + srs_get_player_modal() / 2 +"px");
}
}
// for the chat to init the publish url.
function srs_init_publish(rtmp_url) {
update_nav();
... ... @@ -247,6 +248,34 @@ function srs_init_publish(rtmp_url) {
}
}
// for bw to init url
// url: scheme://host:port/path?query#fragment
function srs_init_bwt(rtmp_url, hls_url) {
update_nav();
if (rtmp_url) {
//var query = parse_query_string();
var search_filed = String(window.location.search).replace(" ", "").split("?")[1];
$(rtmp_url).val("rtmp://" + window.location.host + ":" + 1935 + "/app?" + search_filed);
}
if (hls_url) {
$(hls_url).val(build_default_hls_url());
}
}
function srs_bwt_check_url(url) {
if (url.indexOf("key") != -1 && url.indexOf("vhost") != -1) {
return true;
}
return false;
}
function srs_bwt_build_default_url() {
var url_default = "rtmp://" + window.location.host + ":" + 1935 + "/app?key=35c9b402c12a7246868752e2878f7e0e&vhost=bandcheck.srs.com";
return url_default;
}
/**
* when publisher ready, init the page elements.
*/
... ...
... ... @@ -53,7 +53,7 @@
// get the vhost and port to set the default url.
// for example: http://192.168.1.213/players/jwplayer6.html?port=1935&vhost=demo
// url set to: rtmp://demo:1935/live/livestream
srs_init("#txt_url", null, "#main_modal");
//srs_init("#txt_url", null, "#main_modal");
$("#main_modal").on("hide", function(){
osmf_play("http://localhost");
... ...
... ... @@ -12,10 +12,106 @@
body{
padding-top: 55px;
}
#main_modal {
width: 600px;
margin-left: -300px;
}
#check_status {
margin-left: 20px;
margin-top: -55px;
}
#pb_buffer_bg {
margin-top: 40px;
margin-bottom: 10px;
}
</style>
<script type="text/javascript">
function update_progress(percent) {
$("#progress_bar").width(percent);
}
function progress_reset() {
$("#progress_bar").width("0%");
}
function update_status(text) {
$("#check_status").text(text);
}
function get_swf_width() {
return 1;
}
function get_swf_height() {
return 1;
}
function show_modal() {
$("#main_modal").modal({show:true, keyboard:false});
}
function band_check(url) {
// remove flash contet
var bw_div = $("<div/>");
$(bw_div).attr("id", "bw_div");
$("#bw_center").append(bw_div);
var flashvars = {};
flashvars.url = url;
flashvars.update_progress = "update_progress";
flashvars.progress_reset = "progress_reset";
flashvars.update_status = "update_status";
var params = {};
params.allowFullScreen = true;
var attributes = {};
swfobject.embedSWF(
"srs_bwt/release/srs_bwt.swf", "bw_div",
get_swf_width(), get_swf_height(),
"11.1.0", "js/AdobeFlashPlayerInstall.swf",
flashvars, params, attributes
);
}
$(function(){
update_nav();
srs_init_bwt("#txt_url");
var txt_input = $("#txt_url").val();
// if valid ?
if (!srs_bwt_check_url(txt_input)) {
$("#txt_url").val(srs_bwt_build_default_url());
}
$("#main_modal").on(
"show",
function()
{
progress_reset();
update_status("");
var url = $("#txt_url").val();
/*!
url encode
*/
url = escape(url);
band_check(url);
}
);
$("#main_modal").on("hide", function(){
$("#bw_div").remove();
});
$("#btn_play").click(
function()
{
$("#main_modal").modal({show:true, keyboard:false});
}
);
});
</script>
</head>
... ... @@ -39,6 +135,34 @@
</div>
</div>
<div class="container">
<div class="form-inline">
URL:
<input type="text" id="txt_url" class="input-xxlarge" value="" placeholder="例如:rtmp://host:port/app?key=xx&vhost=yy"></input>
<button class="btn btn-primary" id="btn_play">开始测速</button>
</div>
<div id="main_modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>SRS Band Check</h3>
</div>
<div class="modal-body">
<div id="player"></div>
<div class="progress progress-striped active" id="pb_buffer_bg">
<div class="bar" style="width: 50%;" id="progress_bar"></div>
</div>
</div>
<div class="modal-body" id="bw_center">
</div>
<span id="check_status1"><font ><strong id="check_status">status</strong></font> </span>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true"> 关闭 </button>
</div>
</div>
<hr>
<footer>
<p><a href="https://github.com/winlinvip/simple-rtmp-server">SRS Team &copy; 2013</a></p>
... ...
... ... @@ -40,6 +40,8 @@ cat<<END
http://$ip/players/srs_publisher.html?vhost=players
视频会议(聊天室)应用演示:
http://$ip/players/srs_chat.html?vhost=players
默认的测速应用演示:
http://$ip/players/srs_bwt.html?key=35c9b402c12a7246868752e2878f7e0e&vhost=bandcheck.srs.com
END
echo -e "${GREEN}演示地址:${BLACK}"
echo -e "${RED} http://$ip${BLACK}"
... ...