Merge branch 'development' into LTS_development

This commit is contained in:
Thulinma 2021-09-23 16:14:00 +02:00
commit 22188a7e4e
6 changed files with 36 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1022,9 +1022,21 @@ function MistVideo(streamName,options) {
socket.die = false;
socket.destroy = function(){
this.die = true;
if (MistVideo.reporting) {
MistVideo.reporting.reportStats();
MistVideo.reporting = false;
}
this.onclose = function(){};
this.close();
};
//add a timeout: if the websocket does not connect, switch to http polling
socket.timeOut = MistVideo.timers.start(function(){
if (socket.readyState <= 1) {
//either it hasn't opened yet, or it is open but we've not received a message so this timer hasn't been removed yet
socket.destroy();
openWithGet();
}
},5e3);
socket.onopen = function(e){
this.wasConnected = true;
@ -1096,7 +1108,7 @@ function MistVideo(streamName,options) {
this.report(d);
}
MistVideo.timers.start(function(){
MistVideo.reporting.reportStats();
if (MistVideo.reporting) { MistVideo.reporting.reportStats(); }
},5e3);
},
init: function(){
@ -1224,6 +1236,11 @@ function MistVideo(streamName,options) {
var on_ended_show_state = false;
var on_waiting_show_state = false;
socket.addEventListener("message",function(e){
if (socket.timeOut) {
MistVideo.timers.stop(socket.timeOut);
socket.timeOut = false;
}
var data = JSON.parse(e.data);
if (!data) { MistVideo.showError("Error while parsing stream status stream. Obtained: "+e.data.toString(),{reload:true}); }

View file

@ -406,6 +406,13 @@ p.prototype.build = function (MistVideo,callback) {
});
}
};
this.ws.timeOut = MistVideo.timers.start(function(){
if (player.ws.readyState == 0) {
MistVideo.log("MP4 over WS: socket timeout - try next combo");
MistVideo.nextCombo();
}
},5e3);
this.ws.listeners = {}; //kind of event listener list for websocket messages
this.ws.addListener = function(type,f){
if (!(type in this.listeners)) { this.listeners[type] = []; }

View file

@ -435,6 +435,14 @@ p.prototype.build = function (MistVideo,callback) {
this.ws.onopen = function() {
onEvent({type: "on_connected"});
};
this.ws.timeOut = MistVideo.timers.start(function(){
if (MistVideo.player.webrtc.signaling.ws.readyState == 0) {
MistVideo.log("WebRTC: socket timeout - try next combo");
MistVideo.nextCombo();
}
},5e3);
this.ws.onmessage = function(e) {
try {