Embed: remove forbidden modern code (blegh! filthy modern stuff brrr) from the webrtc wrapper
This commit is contained in:
parent
b6068f4627
commit
615fad6be9
10 changed files with 79 additions and 27 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
File diff suppressed because one or more lines are too long
|
@ -61,7 +61,9 @@ function MistVideo(streamName,options) {
|
|||
if (this.options.skin == "dev") {
|
||||
try {
|
||||
var msg = "["+(type ? type :"log")+"] "+(MistVideo.destroyed ? "[DESTROYED] " : "")+"[#"+(MistVideo.n)+"] "+(this.player && this.player.api ? MistUtil.format.time(this.player.api.currentTime,{ms:true})+" " : "")+message;
|
||||
if (type && (type != "log")) { console.warn(msg); }
|
||||
if (type && (type != "log")) {
|
||||
console.warn(msg);
|
||||
}
|
||||
else { console.log(msg); }
|
||||
} catch(e){}
|
||||
}
|
||||
|
@ -1016,9 +1018,18 @@ function MistVideo(streamName,options) {
|
|||
|
||||
if ("WebSocket" in window) {
|
||||
function openSocket() {
|
||||
MistVideo.log("Opening stream status stream..");
|
||||
MistVideo.log("Opening stream status stream through websocket..");
|
||||
var url = MistVideo.options.host.replace(/^http/i,"ws");
|
||||
var socket = new WebSocket(MistVideo.urlappend(url+"/json_"+encodeURIComponent(MistVideo.stream)+".js"));
|
||||
url = MistVideo.urlappend(url+"/json_"+encodeURIComponent(MistVideo.stream)+".js");
|
||||
var socket;
|
||||
try {
|
||||
socket = new WebSocket(url);
|
||||
}
|
||||
catch (e) {
|
||||
MistVideo.log("Error while attempting to open WebSocket to "+url);
|
||||
openWithGet();
|
||||
return;
|
||||
}
|
||||
MistVideo.socket = socket;
|
||||
socket.die = false;
|
||||
socket.destroy = function(){
|
||||
|
|
|
@ -2422,13 +2422,15 @@ MistSkins.dev = {
|
|||
label.set = function(val){
|
||||
if (val !== 0) { this.style.display = ""; }
|
||||
if (typeof val == "object") {
|
||||
if (val instanceof Promise) {
|
||||
val.then(function(val){
|
||||
label.set(val)
|
||||
},function(){});
|
||||
return;
|
||||
try {
|
||||
if (val instanceof Promise) {
|
||||
val.then(function(val){
|
||||
label.set(val)
|
||||
},function(){});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
catch (e) {}
|
||||
if ("val" in val) {
|
||||
value.nodeValue = val.val;
|
||||
valuec.className = "value";
|
||||
|
@ -2441,7 +2443,7 @@ MistSkins.dev = {
|
|||
else {
|
||||
//create a graph
|
||||
var graph = MistUtil.createGraph({x:[val.x],y:[val.y]},val.options);
|
||||
|
||||
|
||||
//it's (probably) a DOM element, insert it
|
||||
ele.style.display = "";
|
||||
MistUtil.empty(ele);
|
||||
|
|
|
@ -347,7 +347,7 @@ var MistUtil = {
|
|||
if (isNaN(a) || isNaN(b)) {
|
||||
return a.localeCompare(b);
|
||||
}
|
||||
return Math.sign(a-b);
|
||||
return a > b ? 1 : (a < b ? -1 : 0);
|
||||
};
|
||||
|
||||
if (!sortby.length) { return array.sort(sortfunc); }
|
||||
|
|
|
@ -7,7 +7,7 @@ mistplayers.mews = {
|
|||
},
|
||||
isBrowserSupported: function (mimetype,source,MistVideo) {
|
||||
|
||||
if ((!("WebSocket" in window)) || (!("MediaSource" in window))) { return false; }
|
||||
if ((!("WebSocket" in window)) || (!("MediaSource" in window)) || (!("Promise" in window))) { return false; }
|
||||
|
||||
//check for http/https mismatch
|
||||
if (location.protocol.replace(/^http/,"ws") != MistUtil.http.url.split(source.url.replace(/^http/,"ws")).protocol) {
|
||||
|
@ -379,7 +379,8 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
this.ws.s = this.ws.send;
|
||||
this.ws.send = function(){
|
||||
if (this.readyState == 1) {
|
||||
return this.s.apply(this,arguments);
|
||||
this.s.apply(this,arguments);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
@ -885,8 +886,15 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
send({type:"request_codec_data",supported_codecs:MistVideo.source.supportedCodecs});
|
||||
}.bind(this));
|
||||
|
||||
function send(cmd){
|
||||
function send(cmd,retry){
|
||||
if (!player.ws) { throw "No websocket to send to"; }
|
||||
if (retry > 5) { throw "Too many retries, giving up"; }
|
||||
if (player.ws.readyState < player.ws.OPEN) {
|
||||
MistVideo.timers.start(function(){
|
||||
send(cmd,++retry);
|
||||
},500);
|
||||
return;
|
||||
}
|
||||
if (player.ws.readyState >= player.ws.CLOSING) {
|
||||
//throw "WebSocket has been closed already.";
|
||||
MistVideo.log("MP4 over WS: reopening websocket");
|
||||
|
@ -913,9 +921,11 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
return;
|
||||
}
|
||||
if (player.debugging) { console.log("ws send",cmd); }
|
||||
|
||||
player.ws.serverDelay.log(cmd.type);
|
||||
player.ws.send(JSON.stringify(cmd));
|
||||
if (!player.ws.send(JSON.stringify(cmd))) {
|
||||
//not able to send, not sure why.. go back to retry
|
||||
return send(cmd,++retry);
|
||||
}
|
||||
}
|
||||
|
||||
player.findBuffer = function (position) {
|
||||
|
@ -1133,7 +1143,9 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
if (player.api.loop) {
|
||||
player.api.currentTime = 0;
|
||||
player.sb._do(function(){
|
||||
player.sb.remove(0,Infinity);
|
||||
try {
|
||||
player.sb.remove(0,Infinity);
|
||||
} catch (e) {}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ mistplayers.videojs = {
|
|||
mimes: ["html5/application/vnd.apple.mpegurl","html5/application/vnd.apple.mpegurl;version=7"],
|
||||
priority: MistUtil.object.keys(mistplayers).length + 1,
|
||||
isMimeSupported: function (mimetype) {
|
||||
return (this.mimes.indexOf(mimetype) == -1 ? false : true);
|
||||
return (MistUtil.array.indexOf(this.mimes,mimetype) == -1 ? false : true);
|
||||
},
|
||||
isBrowserSupported: function (mimetype,source,MistVideo) {
|
||||
|
||||
|
@ -82,6 +82,29 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
else {
|
||||
vjsopts.controls = false;
|
||||
}
|
||||
|
||||
//capture any errors generated before videojs is initialized and ignore them
|
||||
var captureErrors = MistUtil.event.addListener(ele,"error",function(e){
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
var msg = e.message;
|
||||
if (!msg && ele.error) {
|
||||
if (("code" in ele.error) && (ele.error.code)) {
|
||||
msg = "Code "+ele.error.code;
|
||||
for (var i in ele.error) {
|
||||
if (i == "code") { continue; }
|
||||
if (ele.error[i] == ele.error.code) {
|
||||
msg = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
msg = JSON.stringify(ele.error);
|
||||
}
|
||||
}
|
||||
MistVideo.log("Error captured and stopped because videojs has not yet loaded: "+msg);
|
||||
});
|
||||
|
||||
//for android < 7, enable override native
|
||||
function androidVersion(){
|
||||
|
@ -99,6 +122,9 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
me.onready(function(){
|
||||
MistVideo.log("Building videojs");
|
||||
me.videojs = videojs(ele,vjsopts,function(){
|
||||
//remove error grabbing
|
||||
MistUtil.event.removeListener(captureErrors);
|
||||
|
||||
MistVideo.log("Videojs initialized");
|
||||
|
||||
if (MistVideo.info.type == "live") {
|
||||
|
@ -111,7 +137,7 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
});
|
||||
|
||||
MistUtil.event.addListener(ele,"error",function(e){
|
||||
if (e.target.error.message.indexOf("NS_ERROR_DOM_MEDIA_OVERFLOW_ERR") >= 0) {
|
||||
if (e && e.target && e.target.error && e.target.error.message && (MistUtil.array.indexOf(e.target.error.message,"NS_ERROR_DOM_MEDIA_OVERFLOW_ERR") >= 0)) {
|
||||
//there is a problem with a certain segment, try reloading
|
||||
MistVideo.timers.start(function(){
|
||||
MistVideo.log("Reloading player because of NS_ERROR_DOM_MEDIA_OVERFLOW_ERR");
|
||||
|
|
|
@ -602,15 +602,16 @@ p.prototype.build = function (MistVideo,callback) {
|
|||
me.api.getStats = function(){
|
||||
if (me.webrtc && me.webrtc.isConnected) {
|
||||
return new Promise(function(resolve,reject) {
|
||||
me.webrtc.peerConn.getStats().then((a) => {
|
||||
me.webrtc.peerConn.getStats().then(function(a){
|
||||
var r = {
|
||||
audio: null,
|
||||
video: null
|
||||
};
|
||||
for (let dictionary of a.values()) {
|
||||
if (dictionary.type == "track") {
|
||||
var obj = Object.fromEntries(a);
|
||||
for (var i in obj) {
|
||||
if (obj[i].type == "track") {
|
||||
//average jitter buffer in seconds
|
||||
r[dictionary.kind] = dictionary;
|
||||
r[obj[i].kind] = obj[i];
|
||||
}
|
||||
}
|
||||
resolve(r);
|
||||
|
|
Loading…
Add table
Reference in a new issue