Skip to content

Instantly share code, notes, and snippets.

@jdgo-mars
Created June 18, 2020 12:18
Show Gist options
  • Save jdgo-mars/d7b5bdf31df0fb1686130fdf5b54c20d to your computer and use it in GitHub Desktop.
Save jdgo-mars/d7b5bdf31df0fb1686130fdf5b54c20d to your computer and use it in GitHub Desktop.
var SBMonitor = []
var sysCallMap = {};
function getDiff(key) {
let diff = 0;
const now = new Date().getTime();
if(sysCallMap[key]) {
diff = now - sysCallMap[key];
}
sysCallMap[key] = now;
return diff;
}
function bytesToMb(b) {
return b * 9.537 * 10**-7;
}
var a = SourceBuffer.prototype.appendBuffer;
SourceBuffer.prototype.appendBuffer = function() {
console.warn('[BROWSER API] SOURCEBUFFER.APPENDBUFFER ' + 'DIFFFROMLAST ' + getDiff('appendBuffer') + 'ms' , 'Size: ' + bytesToMb(arguments[0].byteLength) + 'mb');
SBMonitor.push(arguments);
return a.apply(this, arguments);
}
var b = SourceBuffer.prototype.abort;
SourceBuffer.prototype.abort = function() {
console.warn('[BROWSER API] SOURCEBUFFER.ABORT ' + 'DIFFFROMLAST ' + getDiff('abort') + 'ms' , arguments[0]);
return b.apply(this, arguments);
}
var c = MediaSource.prototype.addSourceBuffer;
MediaSource.prototype.addSourceBuffer = function() {
console.warn('[BROWSER API] MEDIASOURCE.ADDSOURCEBUFFER ' + 'DIFFFROMLAST ' + getDiff('addSourceBuffer') + 'ms' , arguments[0]);
return c.apply(this, arguments);
}
var p = MediaSource.prototype.remove;
MediaSource.prototype.remove = function() {
console.warn('[BROWSER API] MEDIASOURCE.ADDSOURCEBUFFER ' + 'DIFFFROMLAST ' + getDiff('remove') + 'ms' , arguments[0]);
return p.apply(this, arguments);
}
var d = MediaSource.prototype.clearLiveSeekableRange;
MediaSource.prototype.clearLiveSeekableRange = function() {
console.warn('[BROWSER API] MEDIASOURCE.CLEARLIVESEEKABLERANGE ' + 'DIFFFROMLAST ' + getDiff('clearLiveSeekableRange') + 'ms' , arguments[0]);
return d.apply(this, arguments);
}
var e = MediaSource.prototype.setLiveSeekableRange;
MediaSource.prototype.setLiveSeekableRange = function() {
console.warn('[BROWSER API] MEDIASOURCE.setLiveSeekableRange ' + 'DIFFFROMLAST ' + getDiff('setLiveSeekableRange') + 'ms' , arguments[0]);
return e.apply(this, arguments);
}
var f = MediaSource.prototype.removeSourceBuffer;
MediaSource.prototype.removeSourceBuffer = function() {
console.warn('[BROWSER API] MEDIASOURCE.removeSourceBuffer ' + 'DIFFFROMLAST ' + getDiff('removeSourceBuffer') + 'ms' , arguments[0]);
return f.apply(this, arguments);
}
var g = MediaKeys.prototype.createSession;
MediaKeys.prototype.createSession = function() {
console.warn('[BROWSER API] MEDIAKEYS.createSession ' + 'DIFFFROMLAST ' + getDiff('createSession') + 'ms' , arguments[0]);
return g.apply(this, arguments);
}
var h = MediaKeySession.prototype.close;
MediaKeySession.prototype.close = function() {
console.warn('[BROWSER API] MEDIAKEYSESSION.CLOSE ' + 'DIFFFROMLAST ' + getDiff('close') + 'ms' , arguments[0]);
return h.apply(this, arguments);
}
var i = MediaKeySession.prototype.load;
MediaKeySession.prototype.load = function() {
console.warn('[BROWSER API] MEDIAKEYSESSION.LOAD ' + 'DIFFFROMLAST ' + getDiff('load') + 'ms' , arguments[0]);
return i.apply(this, arguments);
}
var j = MediaKeySession.prototype.generateRequest;
MediaKeySession.prototype.generateRequest = function() {
console.warn('[BROWSER API] MEDIAKEYSESSION.generateRequest ' + 'DIFFFROMLAST ' + getDiff('generateRequest') + 'ms' , arguments[0]);
return j.apply(this, arguments);
}
var k = MediaKeySession.prototype.remove;
MediaKeySession.prototype.remove = function() {
console.warn('[BROWSER API] MEDIAKEYSESSION.remove ' + 'DIFFFROMLAST ' + getDiff('keysessionremove') + 'ms' , arguments[0]);
return k.apply(this, arguments);
}
var l = MediaKeySession.prototype.update;
MediaKeySession.prototype.update = function() {
console.warn('[BROWSER API] MEDIAKEYSESSION.update ' + 'DIFFFROMLAST ' + getDiff('update') + 'ms' , arguments[0]);
return l.apply(this, arguments);
}
var m = MediaKeySystemAccess.prototype.createMediaKeys;
MediaKeySystemAccess.prototype.createMediaKeys = function() {
console.warn('[BROWSER API] MEDIAKEYSESSION.createMediaKeys ' + 'DIFFFROMLAST ' + getDiff('createMediaKeys') + 'ms' , arguments[0]);
return m.apply(this, arguments);
}
setInterval(function() {
var vPQ = player.getVideoElement().getVideoPlaybackQuality();
console.warn('[BROWSER API] HTMLVideoElement.getVideoPlaybackQuality()');
console.warn(vPQ);
},8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment