1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix the bug of publish, server close the connection when timeout.

This commit is contained in:
winlin 2013-12-25 14:39:54 +08:00
parent ffda615124
commit 836bc413f9
7 changed files with 35 additions and 15 deletions

View file

@ -343,7 +343,7 @@ class RESTChats(object):
self.__chat_lock = threading.Lock(); self.__chat_lock = threading.Lock();
# dead time in seconds, if exceed, remove the chat. # dead time in seconds, if exceed, remove the chat.
self.__dead_time = 30; self.__dead_time = 15;
def GET(self): def GET(self):
enable_crossdomain() enable_crossdomain()

0
trunk/research/players/js/srs.player.js Normal file → Executable file
View file

17
trunk/research/players/js/srs.publisher.js Normal file → Executable file
View file

@ -35,9 +35,12 @@ function SrsPublisher(container, width, height, private_object) {
// error code defines. // error code defines.
this.errors = { this.errors = {
"100": "无法获取指定的摄像头", //error_camera_get "100": "无法获取指定的摄像头。", //error_camera_get
"101": "无法获取指定的麦克风", //error_microphone_get "101": "无法获取指定的麦克风。", //error_microphone_get
"102": "摄像头为禁用状态推流时请允许flash访问摄像头" //error_camera_muted "102": "摄像头为禁用状态推流时请允许flash访问摄像头。", //error_camera_muted
"103": "服务器关闭了连接。", //error_connection_closed
"104": "服务器连接失败。", //error_connection_failed
"199": "未知错误。"
}; };
} }
/** /**
@ -84,11 +87,17 @@ SrsPublisher.prototype.start = function() {
* @param acodec an object contains the audio codec info. * @param acodec an object contains the audio codec info.
*/ */
SrsPublisher.prototype.publish = function(url, vcodec, acodec) { SrsPublisher.prototype.publish = function(url, vcodec, acodec) {
if (url) {
this.url = url; this.url = url;
}
if (vcodec) {
this.vcodec = vcodec; this.vcodec = vcodec;
}
if (acodec) {
this.acodec = acodec; this.acodec = acodec;
}
this.callbackObj.ref.__publish(url, this.width, this.height, vcodec, acodec); this.callbackObj.ref.__publish(this.url, this.width, this.height, this.vcodec, this.acodec);
} }
SrsPublisher.prototype.stop = function() { SrsPublisher.prototype.stop = function() {
this.callbackObj.ref.__stop(); this.callbackObj.ref.__stop();

View file

@ -64,7 +64,7 @@
); );
}; };
srs_publisher.on_publisher_error = function(code, desc) { srs_publisher.on_publisher_error = function(code, desc) {
error(code, desc); error(code, desc + "请重试。");
}; };
srs_publisher.on_publisher_warn = function(code, desc) { srs_publisher.on_publisher_warn = function(code, desc) {
warn(code, desc); warn(code, desc);
@ -78,6 +78,7 @@
realtime_player = new SrsPlayer("realtime_player", 430, 185); realtime_player = new SrsPlayer("realtime_player", 430, 185);
realtime_player.on_player_ready = function() { realtime_player.on_player_ready = function() {
this.set_bt(0.5); this.set_bt(0.5);
this.set_fs("screen", 100);
}; };
realtime_player.start(); realtime_player.start();
} }
@ -229,7 +230,6 @@
var _player = new SrsPlayer("rp_raw_" + chat.id, 600, 300, chat); var _player = new SrsPlayer("rp_raw_" + chat.id, 600, 300, chat);
_player.on_player_ready = function() { _player.on_player_ready = function() {
this.set_bt(0.5); this.set_bt(0.5);
this.play();
this.set_fs("screen", 100); this.set_fs("screen", 100);
}; };
_player.start(chat.url); _player.start(chat.url);
@ -254,7 +254,6 @@
return; return;
} }
chat.player.play(); chat.player.play();
chat.player.set_fs("screen", 100);
}); });
} }
@ -419,14 +418,13 @@
$("#btn_join").text("退出会议"); $("#btn_join").text("退出会议");
info("开始推流到服务器。请戴耳机聊天,否则音箱的声音会进入麦克风"); info("开始推流到服务器。请戴耳机聊天,否则音箱的声音会进入麦克风造成回声。");
srs_publisher.publish(url, vcodec, acodec); srs_publisher.publish(url, vcodec, acodec);
if (realtime_player) { if (realtime_player) {
// directly play the url for the realtime player. // directly play the url for the realtime player.
realtime_player.stop(); realtime_player.stop();
realtime_player.play(url, 0); realtime_player.play(url, 0);
realtime_player.set_fs("screen", 100);
} }
} }
}); });
@ -513,7 +511,7 @@
<img src="img/tooltip.png"/> <img src="img/tooltip.png"/>
</span> </span>
</div> </div>
<div id="collapseM" class="accordion-body collapse in"> <div id="collapseM" class="accordion-body collapse">
<div class="accordion-inner"> <div class="accordion-inner">
<div class="row-fluid"> <div class="row-fluid">
<div class="span2"> <div class="span2">

View file

@ -64,7 +64,7 @@
); );
}; };
srs_publisher.on_publisher_error = function(code, desc) { srs_publisher.on_publisher_error = function(code, desc) {
error(code, desc); error(code, desc + "请重试。");
}; };
srs_publisher.on_publisher_warn = function(code, desc) { srs_publisher.on_publisher_warn = function(code, desc) {
warn(code, desc); warn(code, desc);

View file

@ -48,6 +48,8 @@ package
private const error_camera_get:int = 100; private const error_camera_get:int = 100;
private const error_microphone_get:int = 101; private const error_microphone_get:int = 101;
private const error_camera_muted:int = 102; private const error_camera_muted:int = 102;
private const error_connection_closed:int = 103;
private const error_connection_failed:int = 104;
public function srs_publisher() public function srs_publisher()
{ {
@ -182,6 +184,17 @@ package
contextMenu.customItems = customItems; contextMenu.customItems = customItems;
} }
if (evt.info.code == "NetConnection.Connect.Closed") {
js_call_stop();
system_error(error_connection_closed, "server closed the connection");
return;
}
if (evt.info.code == "NetConnection.Connect.Failed") {
js_call_stop();
system_error(error_connection_failed, "connect to server failed");
return;
}
// TODO: FIXME: failed event. // TODO: FIXME: failed event.
if (evt.info.code != "NetConnection.Connect.Success") { if (evt.info.code != "NetConnection.Connect.Success") {
return; return;