45 lines
10 KiB
JavaScript
45 lines
10 KiB
JavaScript
|
|
||
|
var OGVDemuxerOggW = (function() {
|
||
|
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||
|
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||
|
return (
|
||
|
function(OGVDemuxerOggW) {
|
||
|
OGVDemuxerOggW = OGVDemuxerOggW || {};
|
||
|
|
||
|
|
||
|
var a;a||(a=typeof OGVDemuxerOggW !== 'undefined' ? OGVDemuxerOggW : {});var h,k;a.ready=new Promise(function(b,c){h=b;k=c});var l={},m;for(m in a)a.hasOwnProperty(m)&&(l[m]=a[m]);var n="object"===typeof window,p="function"===typeof importScripts,q="",r,t,u,v,w;
|
||
|
if("object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node)q=p?require("path").dirname(q)+"/":__dirname+"/",r=function(b,c){v||(v=require("fs"));w||(w=require("path"));b=w.normalize(b);return v.readFileSync(b,c?null:"utf8")},u=function(b){b=r(b,!0);b.buffer||(b=new Uint8Array(b));b.buffer||x("Assertion failed: undefined");return b},t=function(b,c,d){v||(v=require("fs"));w||(w=require("path"));b=w.normalize(b);v.readFile(b,function(e,f){e?d(e):c(f.buffer)})},
|
||
|
1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("unhandledRejection",x),a.inspect=function(){return"[Emscripten Module object]"};else if(n||p)p?q=self.location.href:"undefined"!==typeof document&&document.currentScript&&(q=document.currentScript.src),_scriptDir&&(q=_scriptDir),0!==q.indexOf("blob:")?q=q.substr(0,q.lastIndexOf("/")+1):q="",r=function(b){var c=new XMLHttpRequest;c.open("GET",b,!1);c.send(null);return c.responseText},p&&(u=function(b){var c=
|
||
|
new XMLHttpRequest;c.open("GET",b,!1);c.responseType="arraybuffer";c.send(null);return new Uint8Array(c.response)}),t=function(b,c,d){var e=new XMLHttpRequest;e.open("GET",b,!0);e.responseType="arraybuffer";e.onload=function(){200==e.status||0==e.status&&e.response?c(e.response):d()};e.onerror=d;e.send(null)};a.print||console.log.bind(console);var y=a.printErr||console.warn.bind(console);for(m in l)l.hasOwnProperty(m)&&(a[m]=l[m]);l=null;var z;a.wasmBinary&&(z=a.wasmBinary);
|
||
|
var noExitRuntime=a.noExitRuntime||!0;"object"!==typeof WebAssembly&&x("no native wasm support detected");var A,B=!1;"undefined"!==typeof TextDecoder&&new TextDecoder("utf8");var C,D,E;function F(){var b=A.buffer;C=b;a.HEAP8=new Int8Array(b);a.HEAP16=new Int16Array(b);a.HEAP32=E=new Int32Array(b);a.HEAPU8=D=new Uint8Array(b);a.HEAPU16=new Uint16Array(b);a.HEAPU32=new Uint32Array(b);a.HEAPF32=new Float32Array(b);a.HEAPF64=new Float64Array(b)}var G,H=[],I=[],J=[];
|
||
|
function K(){var b=a.preRun.shift();H.unshift(b)}var L=0,M=null,N=null;a.preloadedImages={};a.preloadedAudios={};function x(b){if(a.onAbort)a.onAbort(b);y(b);B=!0;b=new WebAssembly.RuntimeError("abort("+b+"). Build with -s ASSERTIONS=1 for more info.");k(b);throw b;}function O(){return P.startsWith("data:application/octet-stream;base64,")}var P;P="ogv-demuxer-ogg-wasm.wasm";if(!O()){var Q=P;P=a.locateFile?a.locateFile(Q,q):q+Q}
|
||
|
function R(){var b=P;try{if(b==P&&z)return new Uint8Array(z);if(u)return u(b);throw"both async and sync fetching of the wasm failed";}catch(c){x(c)}}
|
||
|
function aa(){if(!z&&(n||p)){if("function"===typeof fetch&&!P.startsWith("file://"))return fetch(P,{credentials:"same-origin"}).then(function(b){if(!b.ok)throw"failed to load wasm binary file at '"+P+"'";return b.arrayBuffer()}).catch(function(){return R()});if(t)return new Promise(function(b,c){t(P,function(d){b(new Uint8Array(d))},c)})}return Promise.resolve().then(function(){return R()})}
|
||
|
function S(b){for(;0<b.length;){var c=b.shift();if("function"==typeof c)c(a);else{var d=c.B;"number"===typeof d?void 0===c.v?G.get(d)():G.get(d)(c.v):d(void 0===c.v?null:c.v)}}}
|
||
|
var T={},ba={d:function(b,c,d){D.copyWithin(b,c,c+d)},e:function(b){var c=D.length;b>>>=0;if(2147483648<b)return!1;for(var d=1;4>=d;d*=2){var e=c*(1+.2/d);e=Math.min(e,b+100663296);e=Math.max(b,e);0<e%65536&&(e+=65536-e%65536);a:{try{A.grow(Math.min(2147483648,e)-C.byteLength+65535>>>16);F();var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},f:function(b,c,d,e){b=T.C(b);c=T.A(b,c,d);E[e>>2]=c;return 0},a:function(b,c,d,e){var f=A.buffer;a.audioPackets.push({data:f.slice?f.slice(b,b+c):(new Uint8Array(new Uint8Array(f,
|
||
|
b,c))).buffer,timestamp:d,discardPadding:e})},c:function(b,c){function d(e){for(var f="",g=new Uint8Array(A.buffer);0!=g[e];e++)f+=String.fromCharCode(g[e]);return f}b&&(a.videoCodec=d(b));c&&(a.audioCodec=d(c));b=a._ogv_demuxer_media_duration();a.duration=0<=b?b:NaN;a.loadedMetadata=!0},b:function(b,c,d,e,f){var g=A.buffer;a.videoPackets.push({data:g.slice?g.slice(b,b+c):(new Uint8Array(new Uint8Array(g,b,c))).buffer,timestamp:d,keyframeTimestamp:e,isKeyframe:!!f})}};
|
||
|
(function(){function b(f){a.asm=f.exports;A=a.asm.g;F();G=a.asm.s;I.unshift(a.asm.h);L--;a.monitorRunDependencies&&a.monitorRunDependencies(L);0==L&&(null!==M&&(clearInterval(M),M=null),N&&(f=N,N=null,f()))}function c(f){b(f.instance)}function d(f){return aa().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){y("failed to asynchronously prepare wasm: "+g);x(g)})}var e={a:ba};L++;a.monitorRunDependencies&&a.monitorRunDependencies(L);if(a.instantiateWasm)try{return a.instantiateWasm(e,
|
||
|
b)}catch(f){return y("Module.instantiateWasm callback failed with error: "+f),!1}(function(){return z||"function"!==typeof WebAssembly.instantiateStreaming||O()||P.startsWith("file://")||"function"!==typeof fetch?d(c):fetch(P,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(c,function(g){y("wasm streaming compile failed: "+g);y("falling back to ArrayBuffer instantiation");return d(c)})})})().catch(k);return{}})();
|
||
|
a.___wasm_call_ctors=function(){return(a.___wasm_call_ctors=a.asm.h).apply(null,arguments)};a._ogv_demuxer_init=function(){return(a._ogv_demuxer_init=a.asm.i).apply(null,arguments)};a._ogv_demuxer_receive_input=function(){return(a._ogv_demuxer_receive_input=a.asm.j).apply(null,arguments)};a._ogv_demuxer_process=function(){return(a._ogv_demuxer_process=a.asm.k).apply(null,arguments)};a._ogv_demuxer_destroy=function(){return(a._ogv_demuxer_destroy=a.asm.l).apply(null,arguments)};
|
||
|
a._ogv_demuxer_media_length=function(){return(a._ogv_demuxer_media_length=a.asm.m).apply(null,arguments)};a._ogv_demuxer_media_duration=function(){return(a._ogv_demuxer_media_duration=a.asm.n).apply(null,arguments)};a._ogv_demuxer_seekable=function(){return(a._ogv_demuxer_seekable=a.asm.o).apply(null,arguments)};a._ogv_demuxer_keypoint_offset=function(){return(a._ogv_demuxer_keypoint_offset=a.asm.p).apply(null,arguments)};
|
||
|
a._ogv_demuxer_seek_to_keypoint=function(){return(a._ogv_demuxer_seek_to_keypoint=a.asm.q).apply(null,arguments)};a._ogv_demuxer_flush=function(){return(a._ogv_demuxer_flush=a.asm.r).apply(null,arguments)};a._malloc=function(){return(a._malloc=a.asm.t).apply(null,arguments)};a._free=function(){return(a._free=a.asm.u).apply(null,arguments)};var U;N=function ca(){U||V();U||(N=ca)};
|
||
|
function V(){function b(){if(!U&&(U=!0,a.calledRun=!0,!B)){S(I);h(a);if(a.onRuntimeInitialized)a.onRuntimeInitialized();if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;){var c=a.postRun.shift();J.unshift(c)}S(J)}}if(!(0<L)){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)K();S(H);0<L||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1);b()},1)):b())}}a.run=V;
|
||
|
if(a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.pop()();V();var W,X,Y;"undefined"===typeof performance||"undefined"===typeof performance.now?Y=Date.now:Y=performance.now.bind(performance);function Z(b){var c=Y();b=b();c=Y()-c;a.cpuTime+=c;return b}a.loadedMetadata=!1;a.videoCodec=null;a.audioCodec=null;a.duration=NaN;a.onseek=null;a.cpuTime=0;a.audioPackets=[];Object.defineProperty(a,"hasAudio",{get:function(){return a.loadedMetadata&&a.audioCodec}});
|
||
|
Object.defineProperty(a,"audioReady",{get:function(){return 0<a.audioPackets.length}});Object.defineProperty(a,"audioTimestamp",{get:function(){return 0<a.audioPackets.length?a.audioPackets[0].timestamp:-1}});a.videoPackets=[];Object.defineProperty(a,"hasVideo",{get:function(){return a.loadedMetadata&&a.videoCodec}});Object.defineProperty(a,"frameReady",{get:function(){return 0<a.videoPackets.length}});
|
||
|
Object.defineProperty(a,"frameTimestamp",{get:function(){return 0<a.videoPackets.length?a.videoPackets[0].timestamp:-1}});Object.defineProperty(a,"keyframeTimestamp",{get:function(){return 0<a.videoPackets.length?a.videoPackets[0].keyframeTimestamp:-1}});Object.defineProperty(a,"nextKeyframeTimestamp",{get:function(){for(var b=0;b<a.videoPackets.length;b++){var c=a.videoPackets[b];if(c.isKeyframe)return c.timestamp}return-1}});Object.defineProperty(a,"processing",{get:function(){return!1}});
|
||
|
Object.defineProperty(a,"seekable",{get:function(){return!!a._ogv_demuxer_seekable()}});a.init=function(b){Z(function(){a._ogv_demuxer_init()});b()};a.receiveInput=function(b,c){Z(function(){var d=b.byteLength;W&&X>=d||(W&&a._free(W),X=d,W=a._malloc(X));var e=W;(new Uint8Array(A.buffer,e,d)).set(new Uint8Array(b));a._ogv_demuxer_receive_input(e,d)});c()};a.process=function(b){var c=Z(function(){return a._ogv_demuxer_process()});b(!!c)};
|
||
|
a.dequeueVideoPacket=function(b){if(a.videoPackets.length){var c=a.videoPackets.shift().data;b(c)}else b(null)};a.dequeueAudioPacket=function(b){if(a.audioPackets.length){var c=a.audioPackets.shift();b(c.data,c.discardPadding)}else b(null)};a.getKeypointOffset=function(b,c){var d=Z(function(){return a._ogv_demuxer_keypoint_offset(1E3*b)});c(d)};
|
||
|
a.seekToKeypoint=function(b,c){var d=Z(function(){return a._ogv_demuxer_seek_to_keypoint(1E3*b)});d&&(a.audioPackets.splice(0,a.audioPackets.length),a.videoPackets.splice(0,a.videoPackets.length));c(!!d)};a.flush=function(b){Z(function(){a.audioPackets.splice(0,a.audioPackets.length);a.videoPackets.splice(0,a.videoPackets.length);a._ogv_demuxer_flush()});b()};a.close=function(){};
|
||
|
|
||
|
|
||
|
return OGVDemuxerOggW.ready
|
||
|
}
|
||
|
);
|
||
|
})();
|
||
|
if (typeof exports === 'object' && typeof module === 'object')
|
||
|
module.exports = OGVDemuxerOggW;
|
||
|
else if (typeof define === 'function' && define['amd'])
|
||
|
define([], function() { return OGVDemuxerOggW; });
|
||
|
else if (typeof exports === 'object')
|
||
|
exports["OGVDemuxerOggW"] = OGVDemuxerOggW;
|