winlin

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

... ... @@ -343,7 +343,7 @@ class RESTChats(object):
self.__chat_lock = threading.Lock();
# dead time in seconds, if exceed, remove the chat.
self.__dead_time = 30;
self.__dead_time = 15;
def GET(self):
enable_crossdomain()
... ...
... ... @@ -35,9 +35,12 @@ function SrsPublisher(container, width, height, private_object) {
// error code defines.
this.errors = {
"100": "无法获取指定的摄像头", //error_camera_get
"101": "无法获取指定的麦克风", //error_microphone_get
"102": "摄像头为禁用状态,推流时请允许flash访问摄像头" //error_camera_muted
"100": "无法获取指定的摄像头。", //error_camera_get
"101": "无法获取指定的麦克风。", //error_microphone_get
"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.
*/
SrsPublisher.prototype.publish = function(url, vcodec, acodec) {
this.url = url;
this.vcodec = vcodec;
this.acodec = acodec;
if (url) {
this.url = url;
}
if (vcodec) {
this.vcodec = vcodec;
}
if (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() {
this.callbackObj.ref.__stop();
... ...
... ... @@ -64,7 +64,7 @@
);
};
srs_publisher.on_publisher_error = function(code, desc) {
error(code, desc);
error(code, desc + "请重试。");
};
srs_publisher.on_publisher_warn = function(code, desc) {
warn(code, desc);
... ... @@ -78,6 +78,7 @@
realtime_player = new SrsPlayer("realtime_player", 430, 185);
realtime_player.on_player_ready = function() {
this.set_bt(0.5);
this.set_fs("screen", 100);
};
realtime_player.start();
}
... ... @@ -229,7 +230,6 @@
var _player = new SrsPlayer("rp_raw_" + chat.id, 600, 300, chat);
_player.on_player_ready = function() {
this.set_bt(0.5);
this.play();
this.set_fs("screen", 100);
};
_player.start(chat.url);
... ... @@ -254,7 +254,6 @@
return;
}
chat.player.play();
chat.player.set_fs("screen", 100);
});
}
... ... @@ -419,14 +418,13 @@
$("#btn_join").text("退出会议");
info("开始推流到服务器。请戴耳机聊天,否则音箱的声音会进入麦克风");
info("开始推流到服务器。请戴耳机聊天,否则音箱的声音会进入麦克风造成回声。");
srs_publisher.publish(url, vcodec, acodec);
if (realtime_player) {
// directly play the url for the realtime player.
realtime_player.stop();
realtime_player.play(url, 0);
realtime_player.set_fs("screen", 100);
}
}
});
... ... @@ -513,7 +511,7 @@
<img src="img/tooltip.png"/>
</span>
</div>
<div id="collapseM" class="accordion-body collapse in">
<div id="collapseM" class="accordion-body collapse">
<div class="accordion-inner">
<div class="row-fluid">
<div class="span2">
... ...
... ... @@ -64,7 +64,7 @@
);
};
srs_publisher.on_publisher_error = function(code, desc) {
error(code, desc);
error(code, desc + "请重试。");
};
srs_publisher.on_publisher_warn = function(code, desc) {
warn(code, desc);
... ...
... ... @@ -48,6 +48,8 @@ package
private const error_camera_get:int = 100;
private const error_microphone_get:int = 101;
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()
{
... ... @@ -181,6 +183,17 @@ package
}
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.
if (evt.info.code != "NetConnection.Connect.Success") {
... ...