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") {
|
if (this.options.skin == "dev") {
|
||||||
try {
|
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;
|
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); }
|
else { console.log(msg); }
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
}
|
}
|
||||||
|
@ -1016,9 +1018,18 @@ function MistVideo(streamName,options) {
|
||||||
|
|
||||||
if ("WebSocket" in window) {
|
if ("WebSocket" in window) {
|
||||||
function openSocket() {
|
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 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;
|
MistVideo.socket = socket;
|
||||||
socket.die = false;
|
socket.die = false;
|
||||||
socket.destroy = function(){
|
socket.destroy = function(){
|
||||||
|
|
|
@ -2422,13 +2422,15 @@ MistSkins.dev = {
|
||||||
label.set = function(val){
|
label.set = function(val){
|
||||||
if (val !== 0) { this.style.display = ""; }
|
if (val !== 0) { this.style.display = ""; }
|
||||||
if (typeof val == "object") {
|
if (typeof val == "object") {
|
||||||
|
try {
|
||||||
if (val instanceof Promise) {
|
if (val instanceof Promise) {
|
||||||
val.then(function(val){
|
val.then(function(val){
|
||||||
label.set(val)
|
label.set(val)
|
||||||
},function(){});
|
},function(){});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
if ("val" in val) {
|
if ("val" in val) {
|
||||||
value.nodeValue = val.val;
|
value.nodeValue = val.val;
|
||||||
valuec.className = "value";
|
valuec.className = "value";
|
||||||
|
|
|
@ -347,7 +347,7 @@ var MistUtil = {
|
||||||
if (isNaN(a) || isNaN(b)) {
|
if (isNaN(a) || isNaN(b)) {
|
||||||
return a.localeCompare(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); }
|
if (!sortby.length) { return array.sort(sortfunc); }
|
||||||
|
|
|
@ -7,7 +7,7 @@ mistplayers.mews = {
|
||||||
},
|
},
|
||||||
isBrowserSupported: function (mimetype,source,MistVideo) {
|
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
|
//check for http/https mismatch
|
||||||
if (location.protocol.replace(/^http/,"ws") != MistUtil.http.url.split(source.url.replace(/^http/,"ws")).protocol) {
|
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.s = this.ws.send;
|
||||||
this.ws.send = function(){
|
this.ws.send = function(){
|
||||||
if (this.readyState == 1) {
|
if (this.readyState == 1) {
|
||||||
return this.s.apply(this,arguments);
|
this.s.apply(this,arguments);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -885,8 +886,15 @@ p.prototype.build = function (MistVideo,callback) {
|
||||||
send({type:"request_codec_data",supported_codecs:MistVideo.source.supportedCodecs});
|
send({type:"request_codec_data",supported_codecs:MistVideo.source.supportedCodecs});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
function send(cmd){
|
function send(cmd,retry){
|
||||||
if (!player.ws) { throw "No websocket to send to"; }
|
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) {
|
if (player.ws.readyState >= player.ws.CLOSING) {
|
||||||
//throw "WebSocket has been closed already.";
|
//throw "WebSocket has been closed already.";
|
||||||
MistVideo.log("MP4 over WS: reopening websocket");
|
MistVideo.log("MP4 over WS: reopening websocket");
|
||||||
|
@ -913,9 +921,11 @@ p.prototype.build = function (MistVideo,callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player.debugging) { console.log("ws send",cmd); }
|
if (player.debugging) { console.log("ws send",cmd); }
|
||||||
|
|
||||||
player.ws.serverDelay.log(cmd.type);
|
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) {
|
player.findBuffer = function (position) {
|
||||||
|
@ -1133,7 +1143,9 @@ p.prototype.build = function (MistVideo,callback) {
|
||||||
if (player.api.loop) {
|
if (player.api.loop) {
|
||||||
player.api.currentTime = 0;
|
player.api.currentTime = 0;
|
||||||
player.sb._do(function(){
|
player.sb._do(function(){
|
||||||
|
try {
|
||||||
player.sb.remove(0,Infinity);
|
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"],
|
mimes: ["html5/application/vnd.apple.mpegurl","html5/application/vnd.apple.mpegurl;version=7"],
|
||||||
priority: MistUtil.object.keys(mistplayers).length + 1,
|
priority: MistUtil.object.keys(mistplayers).length + 1,
|
||||||
isMimeSupported: function (mimetype) {
|
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) {
|
isBrowserSupported: function (mimetype,source,MistVideo) {
|
||||||
|
|
||||||
|
@ -83,6 +83,29 @@ p.prototype.build = function (MistVideo,callback) {
|
||||||
vjsopts.controls = false;
|
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
|
//for android < 7, enable override native
|
||||||
function androidVersion(){
|
function androidVersion(){
|
||||||
var match = navigator.userAgent.toLowerCase().match(/android\s([\d\.]*)/i);
|
var match = navigator.userAgent.toLowerCase().match(/android\s([\d\.]*)/i);
|
||||||
|
@ -99,6 +122,9 @@ p.prototype.build = function (MistVideo,callback) {
|
||||||
me.onready(function(){
|
me.onready(function(){
|
||||||
MistVideo.log("Building videojs");
|
MistVideo.log("Building videojs");
|
||||||
me.videojs = videojs(ele,vjsopts,function(){
|
me.videojs = videojs(ele,vjsopts,function(){
|
||||||
|
//remove error grabbing
|
||||||
|
MistUtil.event.removeListener(captureErrors);
|
||||||
|
|
||||||
MistVideo.log("Videojs initialized");
|
MistVideo.log("Videojs initialized");
|
||||||
|
|
||||||
if (MistVideo.info.type == "live") {
|
if (MistVideo.info.type == "live") {
|
||||||
|
@ -111,7 +137,7 @@ p.prototype.build = function (MistVideo,callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
MistUtil.event.addListener(ele,"error",function(e){
|
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
|
//there is a problem with a certain segment, try reloading
|
||||||
MistVideo.timers.start(function(){
|
MistVideo.timers.start(function(){
|
||||||
MistVideo.log("Reloading player because of NS_ERROR_DOM_MEDIA_OVERFLOW_ERR");
|
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(){
|
me.api.getStats = function(){
|
||||||
if (me.webrtc && me.webrtc.isConnected) {
|
if (me.webrtc && me.webrtc.isConnected) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
me.webrtc.peerConn.getStats().then((a) => {
|
me.webrtc.peerConn.getStats().then(function(a){
|
||||||
var r = {
|
var r = {
|
||||||
audio: null,
|
audio: null,
|
||||||
video: null
|
video: null
|
||||||
};
|
};
|
||||||
for (let dictionary of a.values()) {
|
var obj = Object.fromEntries(a);
|
||||||
if (dictionary.type == "track") {
|
for (var i in obj) {
|
||||||
|
if (obj[i].type == "track") {
|
||||||
//average jitter buffer in seconds
|
//average jitter buffer in seconds
|
||||||
r[dictionary.kind] = dictionary;
|
r[obj[i].kind] = obj[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve(r);
|
resolve(r);
|
||||||
|
|
Loading…
Add table
Reference in a new issue