winlin

add MIT license to bandwidth check/test as/js library.

  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013-2014 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
1 package 23 package
2 { 24 {
3 import flash.events.NetStatusEvent; 25 import flash.events.NetStatusEvent;
@@ -42,9 +64,9 @@ package @@ -42,9 +64,9 @@ package
42 /** 64 /**
43 * constructor, do nothing 65 * constructor, do nothing
44 */ 66 */
45 - public function SrsBandwidth()  
46 - {  
47 - } 67 + public function SrsBandwidth()
  68 + {
  69 + }
48 70
49 /** 71 /**
50 * initialize the bandwidth test tool, the callbacks. null to ignore. 72 * initialize the bandwidth test tool, the callbacks. null to ignore.
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013-2014 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
1 /** 23 /**
2 * the SrsBandwidth library for js to do bandwidth test. 24 * the SrsBandwidth library for js to do bandwidth test.
3 * @param container the html container id. 25 * @param container the html container id.
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013-2014 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
1 package 23 package
2 -{  
3 - import flash.display.LoaderInfo;  
4 - import flash.display.Sprite;  
5 - import flash.display.StageAlign;  
6 - import flash.display.StageScaleMode;  
7 - import flash.events.Event;  
8 - import flash.events.NetStatusEvent;  
9 - import flash.events.TimerEvent;  
10 - import flash.external.ExternalInterface;  
11 - import flash.net.NetConnection;  
12 - import flash.net.ObjectEncoding;  
13 - import flash.system.System;  
14 - import flash.ui.ContextMenu;  
15 - import flash.ui.ContextMenuItem;  
16 - import flash.utils.Timer;  
17 - import flash.utils.setTimeout;  
18 -  
19 - public class srs_bwt extends Sprite 24 +{
  25 + import flash.display.LoaderInfo;
  26 + import flash.display.Sprite;
  27 + import flash.display.StageAlign;
  28 + import flash.display.StageScaleMode;
  29 + import flash.events.Event;
  30 + import flash.events.NetStatusEvent;
  31 + import flash.events.TimerEvent;
  32 + import flash.external.ExternalInterface;
  33 + import flash.net.NetConnection;
  34 + import flash.net.ObjectEncoding;
  35 + import flash.system.System;
  36 + import flash.ui.ContextMenu;
  37 + import flash.ui.ContextMenuItem;
  38 + import flash.utils.Timer;
  39 + import flash.utils.setTimeout;
  40 +
  41 + public class srs_bwt extends Sprite
20 { 42 {
21 /** 43 /**
22 * the SRS bandwidth check/test library object. 44 * the SRS bandwidth check/test library object.
@@ -27,9 +49,9 @@ package @@ -27,9 +49,9 @@ package
27 * when not specifies any param, directly run the swf. 49 * when not specifies any param, directly run the swf.
28 */ 50 */
29 private var default_url:String = "rtmp://dev:1935/app?key=35c9b402c12a7246868752e2878f7e0e&vhost=bandcheck.srs.com"; 51 private var default_url:String = "rtmp://dev:1935/app?key=35c9b402c12a7246868752e2878f7e0e&vhost=bandcheck.srs.com";
30 -  
31 - public function srs_bwt()  
32 - { 52 +
  53 + public function srs_bwt()
  54 + {
33 if (!this.stage) { 55 if (!this.stage) {
34 this.addEventListener(Event.ADDED_TO_STAGE, this.system_on_add_to_stage); 56 this.addEventListener(Event.ADDED_TO_STAGE, this.system_on_add_to_stage);
35 } else { 57 } else {
@@ -37,8 +59,8 @@ package @@ -37,8 +59,8 @@ package
37 } 59 }
38 } 60 }
39 private function system_on_add_to_stage(evt:Event):void { 61 private function system_on_add_to_stage(evt:Event):void {
40 - this.stage.scaleMode = StageScaleMode.NO_SCALE;  
41 - this.stage.align = StageAlign.TOP_LEFT; 62 + this.stage.scaleMode = StageScaleMode.NO_SCALE;
  63 + this.stage.align = StageAlign.TOP_LEFT;
42 64
43 // init context menu 65 // init context menu
44 var myMenu:ContextMenu = new ContextMenu(); 66 var myMenu:ContextMenu = new ContextMenu();
@@ -52,7 +74,7 @@ package @@ -52,7 +74,7 @@ package
52 private function check_bandwidth():void { 74 private function check_bandwidth():void {
53 // closure 75 // closure
54 var self:srs_bwt = this; 76 var self:srs_bwt = this;
55 - 77 +
56 ///////////////////////////////////////////////////////////////////// 78 /////////////////////////////////////////////////////////////////////
57 // initialize the bandwidth check/test library 79 // initialize the bandwidth check/test library
58 ///////////////////////////////////////////////////////////////////// 80 /////////////////////////////////////////////////////////////////////
@@ -130,18 +152,18 @@ package @@ -130,18 +152,18 @@ package
130 } 152 }
131 contextMenu.customItems = customItems; 153 contextMenu.customItems = customItems;
132 } 154 }
133 - public function on_status_change(code:String, data:String): void {  
134 - trace(code);  
135 - switch(code){  
136 - case "NetConnection.Connect.Failed": 155 + public function on_status_change(code:String, data:String): void {
  156 + trace(code);
  157 + switch(code){
  158 + case "NetConnection.Connect.Failed":
137 trace("连接服务器失败!"); 159 trace("连接服务器失败!");
138 - break;  
139 - case "NetConnection.Connect.Rejected": 160 + break;
  161 + case "NetConnection.Connect.Rejected":
140 trace("服务器拒绝连接!"); 162 trace("服务器拒绝连接!");
141 - break;  
142 - case "NetConnection.Connect.Success": 163 + break;
  164 + case "NetConnection.Connect.Success":
143 trace("连接服务器成功!"); 165 trace("连接服务器成功!");
144 - break; 166 + break;
145 case SrsBandwidth.StatusSrsBwtcPlayStart: 167 case SrsBandwidth.StatusSrsBwtcPlayStart:
146 trace("开始测试下行带宽"); 168 trace("开始测试下行带宽");
147 break; 169 break;
@@ -154,11 +176,11 @@ package @@ -154,11 +176,11 @@ package
154 case SrsBandwidth.StatusSrsBwtcPublishStop: 176 case SrsBandwidth.StatusSrsBwtcPublishStop:
155 trace("上行带宽测试完毕," + data + "kbps,"); 177 trace("上行带宽测试完毕," + data + "kbps,");
156 break; 178 break;
157 - case "NetConnection.Connect.Closed":  
158 - trace("连接已断开!");  
159 - break;  
160 - }  
161 - } 179 + case "NetConnection.Connect.Closed":
  180 + trace("连接已断开!");
  181 + break;
  182 + }
  183 + }
162 private function on_complete( 184 private function on_complete(
163 start_time:Number, end_time:Number, play_kbps:Number, publish_kbps:Number, 185 start_time:Number, end_time:Number, play_kbps:Number, publish_kbps:Number,
164 play_bytes:Number, publish_bytes:Number, play_time:Number, publish_time:Number 186 play_bytes:Number, publish_bytes:Number, play_time:Number, publish_time:Number
@@ -167,5 +189,5 @@ package @@ -167,5 +189,5 @@ package
167 + " 测试时间: " + Number((end_time - start_time) / 1000).toFixed(1) + " 秒"; 189 + " 测试时间: " + Number((end_time - start_time) / 1000).toFixed(1) + " 秒";
168 trace(status); 190 trace(status);
169 } 191 }
170 - } 192 + }
171 } 193 }