fix the bug of publish, server close the connection when timeout.
正在显示
7 个修改的文件
包含
35 行增加
和
15 行删除
@@ -343,7 +343,7 @@ class RESTChats(object): | @@ -343,7 +343,7 @@ class RESTChats(object): | ||
343 | self.__chat_lock = threading.Lock(); | 343 | self.__chat_lock = threading.Lock(); |
344 | 344 | ||
345 | # dead time in seconds, if exceed, remove the chat. | 345 | # dead time in seconds, if exceed, remove the chat. |
346 | - self.__dead_time = 30; | 346 | + self.__dead_time = 15; |
347 | 347 | ||
348 | def GET(self): | 348 | def GET(self): |
349 | enable_crossdomain() | 349 | enable_crossdomain() |
trunk/research/players/js/srs.player.js
100644 → 100755
trunk/research/players/js/srs.publisher.js
100644 → 100755
@@ -35,9 +35,12 @@ function SrsPublisher(container, width, height, private_object) { | @@ -35,9 +35,12 @@ function SrsPublisher(container, width, height, private_object) { | ||
35 | 35 | ||
36 | // error code defines. | 36 | // error code defines. |
37 | this.errors = { | 37 | this.errors = { |
38 | - "100": "无法获取指定的摄像头", //error_camera_get | ||
39 | - "101": "无法获取指定的麦克风", //error_microphone_get | ||
40 | - "102": "摄像头为禁用状态,推流时请允许flash访问摄像头" //error_camera_muted | 38 | + "100": "无法获取指定的摄像头。", //error_camera_get |
39 | + "101": "无法获取指定的麦克风。", //error_microphone_get | ||
40 | + "102": "摄像头为禁用状态,推流时请允许flash访问摄像头。", //error_camera_muted | ||
41 | + "103": "服务器关闭了连接。", //error_connection_closed | ||
42 | + "104": "服务器连接失败。", //error_connection_failed | ||
43 | + "199": "未知错误。" | ||
41 | }; | 44 | }; |
42 | } | 45 | } |
43 | /** | 46 | /** |
@@ -84,11 +87,17 @@ SrsPublisher.prototype.start = function() { | @@ -84,11 +87,17 @@ SrsPublisher.prototype.start = function() { | ||
84 | * @param acodec an object contains the audio codec info. | 87 | * @param acodec an object contains the audio codec info. |
85 | */ | 88 | */ |
86 | SrsPublisher.prototype.publish = function(url, vcodec, acodec) { | 89 | SrsPublisher.prototype.publish = function(url, vcodec, acodec) { |
87 | - this.url = url; | ||
88 | - this.vcodec = vcodec; | ||
89 | - this.acodec = acodec; | 90 | + if (url) { |
91 | + this.url = url; | ||
92 | + } | ||
93 | + if (vcodec) { | ||
94 | + this.vcodec = vcodec; | ||
95 | + } | ||
96 | + if (acodec) { | ||
97 | + this.acodec = acodec; | ||
98 | + } | ||
90 | 99 | ||
91 | - this.callbackObj.ref.__publish(url, this.width, this.height, vcodec, acodec); | 100 | + this.callbackObj.ref.__publish(this.url, this.width, this.height, this.vcodec, this.acodec); |
92 | } | 101 | } |
93 | SrsPublisher.prototype.stop = function() { | 102 | SrsPublisher.prototype.stop = function() { |
94 | this.callbackObj.ref.__stop(); | 103 | this.callbackObj.ref.__stop(); |
@@ -64,7 +64,7 @@ | @@ -64,7 +64,7 @@ | ||
64 | ); | 64 | ); |
65 | }; | 65 | }; |
66 | srs_publisher.on_publisher_error = function(code, desc) { | 66 | srs_publisher.on_publisher_error = function(code, desc) { |
67 | - error(code, desc); | 67 | + error(code, desc + "请重试。"); |
68 | }; | 68 | }; |
69 | srs_publisher.on_publisher_warn = function(code, desc) { | 69 | srs_publisher.on_publisher_warn = function(code, desc) { |
70 | warn(code, desc); | 70 | warn(code, desc); |
@@ -78,6 +78,7 @@ | @@ -78,6 +78,7 @@ | ||
78 | realtime_player = new SrsPlayer("realtime_player", 430, 185); | 78 | realtime_player = new SrsPlayer("realtime_player", 430, 185); |
79 | realtime_player.on_player_ready = function() { | 79 | realtime_player.on_player_ready = function() { |
80 | this.set_bt(0.5); | 80 | this.set_bt(0.5); |
81 | + this.set_fs("screen", 100); | ||
81 | }; | 82 | }; |
82 | realtime_player.start(); | 83 | realtime_player.start(); |
83 | } | 84 | } |
@@ -229,7 +230,6 @@ | @@ -229,7 +230,6 @@ | ||
229 | var _player = new SrsPlayer("rp_raw_" + chat.id, 600, 300, chat); | 230 | var _player = new SrsPlayer("rp_raw_" + chat.id, 600, 300, chat); |
230 | _player.on_player_ready = function() { | 231 | _player.on_player_ready = function() { |
231 | this.set_bt(0.5); | 232 | this.set_bt(0.5); |
232 | - this.play(); | ||
233 | this.set_fs("screen", 100); | 233 | this.set_fs("screen", 100); |
234 | }; | 234 | }; |
235 | _player.start(chat.url); | 235 | _player.start(chat.url); |
@@ -254,7 +254,6 @@ | @@ -254,7 +254,6 @@ | ||
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | chat.player.play(); | 256 | chat.player.play(); |
257 | - chat.player.set_fs("screen", 100); | ||
258 | }); | 257 | }); |
259 | } | 258 | } |
260 | 259 | ||
@@ -419,14 +418,13 @@ | @@ -419,14 +418,13 @@ | ||
419 | 418 | ||
420 | $("#btn_join").text("退出会议"); | 419 | $("#btn_join").text("退出会议"); |
421 | 420 | ||
422 | - info("开始推流到服务器。请戴耳机聊天,否则音箱的声音会进入麦克风"); | 421 | + info("开始推流到服务器。请戴耳机聊天,否则音箱的声音会进入麦克风造成回声。"); |
423 | srs_publisher.publish(url, vcodec, acodec); | 422 | srs_publisher.publish(url, vcodec, acodec); |
424 | 423 | ||
425 | if (realtime_player) { | 424 | if (realtime_player) { |
426 | // directly play the url for the realtime player. | 425 | // directly play the url for the realtime player. |
427 | realtime_player.stop(); | 426 | realtime_player.stop(); |
428 | realtime_player.play(url, 0); | 427 | realtime_player.play(url, 0); |
429 | - realtime_player.set_fs("screen", 100); | ||
430 | } | 428 | } |
431 | } | 429 | } |
432 | }); | 430 | }); |
@@ -513,7 +511,7 @@ | @@ -513,7 +511,7 @@ | ||
513 | <img src="img/tooltip.png"/> | 511 | <img src="img/tooltip.png"/> |
514 | </span> | 512 | </span> |
515 | </div> | 513 | </div> |
516 | - <div id="collapseM" class="accordion-body collapse in"> | 514 | + <div id="collapseM" class="accordion-body collapse"> |
517 | <div class="accordion-inner"> | 515 | <div class="accordion-inner"> |
518 | <div class="row-fluid"> | 516 | <div class="row-fluid"> |
519 | <div class="span2"> | 517 | <div class="span2"> |
@@ -64,7 +64,7 @@ | @@ -64,7 +64,7 @@ | ||
64 | ); | 64 | ); |
65 | }; | 65 | }; |
66 | srs_publisher.on_publisher_error = function(code, desc) { | 66 | srs_publisher.on_publisher_error = function(code, desc) { |
67 | - error(code, desc); | 67 | + error(code, desc + "请重试。"); |
68 | }; | 68 | }; |
69 | srs_publisher.on_publisher_warn = function(code, desc) { | 69 | srs_publisher.on_publisher_warn = function(code, desc) { |
70 | warn(code, desc); | 70 | warn(code, desc); |
@@ -48,6 +48,8 @@ package | @@ -48,6 +48,8 @@ package | ||
48 | private const error_camera_get:int = 100; | 48 | private const error_camera_get:int = 100; |
49 | private const error_microphone_get:int = 101; | 49 | private const error_microphone_get:int = 101; |
50 | private const error_camera_muted:int = 102; | 50 | private const error_camera_muted:int = 102; |
51 | + private const error_connection_closed:int = 103; | ||
52 | + private const error_connection_failed:int = 104; | ||
51 | 53 | ||
52 | public function srs_publisher() | 54 | public function srs_publisher() |
53 | { | 55 | { |
@@ -181,6 +183,17 @@ package | @@ -181,6 +183,17 @@ package | ||
181 | } | 183 | } |
182 | contextMenu.customItems = customItems; | 184 | contextMenu.customItems = customItems; |
183 | } | 185 | } |
186 | + | ||
187 | + if (evt.info.code == "NetConnection.Connect.Closed") { | ||
188 | + js_call_stop(); | ||
189 | + system_error(error_connection_closed, "server closed the connection"); | ||
190 | + return; | ||
191 | + } | ||
192 | + if (evt.info.code == "NetConnection.Connect.Failed") { | ||
193 | + js_call_stop(); | ||
194 | + system_error(error_connection_failed, "connect to server failed"); | ||
195 | + return; | ||
196 | + } | ||
184 | 197 | ||
185 | // TODO: FIXME: failed event. | 198 | // TODO: FIXME: failed event. |
186 | if (evt.info.code != "NetConnection.Connect.Success") { | 199 | if (evt.info.code != "NetConnection.Connect.Success") { |
-
请 注册 或 登录 后发表评论