diff --git a/README.MD b/README.MD index c3625684..9965968f 100644 --- a/README.MD +++ b/README.MD @@ -58,6 +58,8 @@ | 更新日志 | 内容 | | ---- | ---- | +| 时间 | 2021/05/18 | +| - | 1.HLS(直播)性能优化、增加声音Case | | 时间 | 2021/05/16 | | - | 1.MP4点播兼容BD265产出部分特殊box case | | 时间 | 2021/05/15 | diff --git a/README_EN.MD b/README_EN.MD index 2036d363..c6e33090 100644 --- a/README_EN.MD +++ b/README_EN.MD @@ -59,6 +59,8 @@ __`~^_^~ For love` if h265web | Update | Content | | ---- | ---- | +| Time | 2021/05/18 | +| - | 1.HLS(LIVE) performance optimizing and add Audio | | Time | 2021/05/16 | | - | 1.MP4(VOD) Fixed:BD265 Mp4 box badcase | | Time | 2021/05/15 | diff --git a/dist/h265webjs-v20210516.js b/dist/h265webjs-v20210518.js similarity index 93% rename from dist/h265webjs-v20210516.js rename to dist/h265webjs-v20210518.js index 30b78562..ae81eeff 100644 --- a/dist/h265webjs-v20210516.js +++ b/dist/h265webjs-v20210518.js @@ -14,4 +14,4 @@ */ t.exports=function(e){return null!=e&&(r(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))}(e)||!!e._isBuffer)}},{}],138:[function(e,t,i){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],139:[function(e,t,i){"use strict";var r=e("inherits"),n=e("hash-base"),a=e("safe-buffer").Buffer,s=new Array(16);function o(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function l(e,t){return e<>>32-t}function f(e,t,i,r,n,a,s){return l(e+(t&i|~t&r)+n+a|0,s)+t|0}function u(e,t,i,r,n,a,s){return l(e+(t&r|i&~r)+n+a|0,s)+t|0}function h(e,t,i,r,n,a,s){return l(e+(t^i^r)+n+a|0,s)+t|0}function c(e,t,i,r,n,a,s){return l(e+(i^(t|~r))+n+a|0,s)+t|0}r(o,n),o.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var i=this._a,r=this._b,n=this._c,a=this._d;i=f(i,r,n,a,e[0],3614090360,7),a=f(a,i,r,n,e[1],3905402710,12),n=f(n,a,i,r,e[2],606105819,17),r=f(r,n,a,i,e[3],3250441966,22),i=f(i,r,n,a,e[4],4118548399,7),a=f(a,i,r,n,e[5],1200080426,12),n=f(n,a,i,r,e[6],2821735955,17),r=f(r,n,a,i,e[7],4249261313,22),i=f(i,r,n,a,e[8],1770035416,7),a=f(a,i,r,n,e[9],2336552879,12),n=f(n,a,i,r,e[10],4294925233,17),r=f(r,n,a,i,e[11],2304563134,22),i=f(i,r,n,a,e[12],1804603682,7),a=f(a,i,r,n,e[13],4254626195,12),n=f(n,a,i,r,e[14],2792965006,17),i=u(i,r=f(r,n,a,i,e[15],1236535329,22),n,a,e[1],4129170786,5),a=u(a,i,r,n,e[6],3225465664,9),n=u(n,a,i,r,e[11],643717713,14),r=u(r,n,a,i,e[0],3921069994,20),i=u(i,r,n,a,e[5],3593408605,5),a=u(a,i,r,n,e[10],38016083,9),n=u(n,a,i,r,e[15],3634488961,14),r=u(r,n,a,i,e[4],3889429448,20),i=u(i,r,n,a,e[9],568446438,5),a=u(a,i,r,n,e[14],3275163606,9),n=u(n,a,i,r,e[3],4107603335,14),r=u(r,n,a,i,e[8],1163531501,20),i=u(i,r,n,a,e[13],2850285829,5),a=u(a,i,r,n,e[2],4243563512,9),n=u(n,a,i,r,e[7],1735328473,14),i=h(i,r=u(r,n,a,i,e[12],2368359562,20),n,a,e[5],4294588738,4),a=h(a,i,r,n,e[8],2272392833,11),n=h(n,a,i,r,e[11],1839030562,16),r=h(r,n,a,i,e[14],4259657740,23),i=h(i,r,n,a,e[1],2763975236,4),a=h(a,i,r,n,e[4],1272893353,11),n=h(n,a,i,r,e[7],4139469664,16),r=h(r,n,a,i,e[10],3200236656,23),i=h(i,r,n,a,e[13],681279174,4),a=h(a,i,r,n,e[0],3936430074,11),n=h(n,a,i,r,e[3],3572445317,16),r=h(r,n,a,i,e[6],76029189,23),i=h(i,r,n,a,e[9],3654602809,4),a=h(a,i,r,n,e[12],3873151461,11),n=h(n,a,i,r,e[15],530742520,16),i=c(i,r=h(r,n,a,i,e[2],3299628645,23),n,a,e[0],4096336452,6),a=c(a,i,r,n,e[7],1126891415,10),n=c(n,a,i,r,e[14],2878612391,15),r=c(r,n,a,i,e[5],4237533241,21),i=c(i,r,n,a,e[12],1700485571,6),a=c(a,i,r,n,e[3],2399980690,10),n=c(n,a,i,r,e[10],4293915773,15),r=c(r,n,a,i,e[1],2240044497,21),i=c(i,r,n,a,e[8],1873313359,6),a=c(a,i,r,n,e[15],4264355552,10),n=c(n,a,i,r,e[6],2734768916,15),r=c(r,n,a,i,e[13],1309151649,21),i=c(i,r,n,a,e[4],4149444226,6),a=c(a,i,r,n,e[11],3174756917,10),n=c(n,a,i,r,e[2],718787259,15),r=c(r,n,a,i,e[9],3951481745,21),this._a=this._a+i|0,this._b=this._b+r|0,this._c=this._c+n|0,this._d=this._d+a|0},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=a.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=o},{"hash-base":106,inherits:136,"safe-buffer":184}],140:[function(e,t,i){var r=e("bn.js"),n=e("brorand");function a(e){this.rand=e||new n.Rand}t.exports=a,a.create=function(e){return new a(e)},a.prototype._randbelow=function(e){var t=e.bitLength(),i=Math.ceil(t/8);do{var n=new r(this.rand.generate(i))}while(n.cmp(e)>=0);return n},a.prototype._randrange=function(e,t){var i=t.sub(e);return e.add(this._randbelow(i))},a.prototype.test=function(e,t,i){var n=e.bitLength(),a=r.mont(e),s=new r(1).toRed(a);t||(t=Math.max(1,n/48|0));for(var o=e.subn(1),l=0;!o.testn(l);l++);for(var f=e.shrn(l),u=o.toRed(a);t>0;t--){var h=this._randrange(new r(2),o);i&&i(h);var c=h.toRed(a).redPow(f);if(0!==c.cmp(s)&&0!==c.cmp(u)){for(var d=1;d0;t--){var u=this._randrange(new r(2),s),h=e.gcd(u);if(0!==h.cmpn(1))return h;var c=u.toRed(n).redPow(l);if(0!==c.cmp(a)&&0!==c.cmp(f)){for(var d=1;d>8,s=255&n;a?i.push(a,s):i.push(s)}return i},r.zero2=n,r.toHex=a,r.encode=function(e,t){return"hex"===t?a(e):e}},{}],144:[function(e,t,i){var r,n,a=(r=new Date,n=4,{setLogLevel:function(e){n=e==this.debug?1:e==this.info?2:e==this.warn?3:(this.error,4)},debug:function(e,t){void 0===console.debug&&(console.debug=console.log),1>=n&&console.debug("["+a.getDurationString(new Date-r,1e3)+"]","["+e+"]",t)},log:function(e,t){this.debug(e.msg)},info:function(e,t){2>=n&&console.info("["+a.getDurationString(new Date-r,1e3)+"]","["+e+"]",t)},warn:function(e,t){3>=n&&console.warn("["+a.getDurationString(new Date-r,1e3)+"]","["+e+"]",t)},error:function(e,t){4>=n&&console.error("["+a.getDurationString(new Date-r,1e3)+"]","["+e+"]",t)}});a.getDurationString=function(e,t){var i;function r(e,t){for(var i=(""+e).split(".");i[0].length0){for(var i="",r=0;r0&&(i+=","),i+="["+a.getDurationString(e.start(r))+","+a.getDurationString(e.end(r))+"]";return i}return"(empty)"},void 0!==i&&(i.Log=a);var s=function(e){if(!(e instanceof ArrayBuffer))throw"Needs an array buffer";this.buffer=e,this.dataview=new DataView(e),this.position=0};s.prototype.getPosition=function(){return this.position},s.prototype.getEndPosition=function(){return this.buffer.byteLength},s.prototype.getLength=function(){return this.buffer.byteLength},s.prototype.seek=function(e){var t=Math.max(0,Math.min(this.buffer.byteLength,e));return this.position=isNaN(t)||!isFinite(t)?0:t,!0},s.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},s.prototype.readAnyInt=function(e,t){var i=0;if(this.position+e<=this.buffer.byteLength){switch(e){case 1:i=t?this.dataview.getInt8(this.position):this.dataview.getUint8(this.position);break;case 2:i=t?this.dataview.getInt16(this.position):this.dataview.getUint16(this.position);break;case 3:if(t)throw"No method for reading signed 24 bits values";i=this.dataview.getUint8(this.position)<<16,i|=this.dataview.getUint8(this.position)<<8,i|=this.dataview.getUint8(this.position);break;case 4:i=t?this.dataview.getInt32(this.position):this.dataview.getUint32(this.position);break;case 8:if(t)throw"No method for reading signed 64 bits values";i=this.dataview.getUint32(this.position)<<32,i|=this.dataview.getUint32(this.position);break;default:throw"readInt method not implemented for size: "+e}return this.position+=e,i}throw"Not enough bytes in buffer"},s.prototype.readUint8=function(){return this.readAnyInt(1,!1)},s.prototype.readUint16=function(){return this.readAnyInt(2,!1)},s.prototype.readUint24=function(){return this.readAnyInt(3,!1)},s.prototype.readUint32=function(){return this.readAnyInt(4,!1)},s.prototype.readUint64=function(){return this.readAnyInt(8,!1)},s.prototype.readString=function(e){if(this.position+e<=this.buffer.byteLength){for(var t="",i=0;ithis._byteLength&&(this._byteLength=t);else{for(i<1&&(i=1);t>i;)i*=2;var r=new ArrayBuffer(i),n=new Uint8Array(this._buffer);new Uint8Array(r,0,n.length).set(n),this.buffer=r,this._byteLength=t}}},o.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var e=new ArrayBuffer(this._byteLength),t=new Uint8Array(e),i=new Uint8Array(this._buffer,0,t.length);t.set(i),this.buffer=e}},o.BIG_ENDIAN=!1,o.LITTLE_ENDIAN=!0,o.prototype._byteLength=0,Object.defineProperty(o.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(o.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(e){this._buffer=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(o.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(e){this._byteOffset=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(o.prototype,"dataView",{get:function(){return this._dataView},set:function(e){this._byteOffset=e.byteOffset,this._buffer=e.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+e.byteLength}}),o.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t},o.prototype.isEof=function(){return this.position>=this._byteLength},o.prototype.mapUint8Array=function(e){this._realloc(1*e);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},o.prototype.readInt32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Int32Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readInt16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Int16Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readInt8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Int8Array(e);return o.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},o.prototype.readUint32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Uint32Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readUint16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Uint16Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readUint8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Uint8Array(e);return o.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},o.prototype.readFloat64Array=function(e,t){e=null==e?this.byteLength-this.position/8:e;var i=new Float64Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readFloat32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Float32Array(e);return o.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),o.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},o.prototype.readInt32=function(e){var t=this._dataView.getInt32(this.position,null==e?this.endianness:e);return this.position+=4,t},o.prototype.readInt16=function(e){var t=this._dataView.getInt16(this.position,null==e?this.endianness:e);return this.position+=2,t},o.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);return this.position+=1,e},o.prototype.readUint32=function(e){var t=this._dataView.getUint32(this.position,null==e?this.endianness:e);return this.position+=4,t},o.prototype.readUint16=function(e){var t=this._dataView.getUint16(this.position,null==e?this.endianness:e);return this.position+=2,t},o.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);return this.position+=1,e},o.prototype.readFloat32=function(e){var t=this._dataView.getFloat32(this.position,null==e?this.endianness:e);return this.position+=4,t},o.prototype.readFloat64=function(e){var t=this._dataView.getFloat64(this.position,null==e?this.endianness:e);return this.position+=8,t},o.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,o.memcpy=function(e,t,i,r,n){var a=new Uint8Array(e,t,n),s=new Uint8Array(i,r,n);a.set(s)},o.arrayToNative=function(e,t){return t==this.endianness?e:this.flipArrayEndianness(e)},o.nativeToEndian=function(e,t){return this.endianness==t?e:this.flipArrayEndianness(e)},o.flipArrayEndianness=function(e){for(var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=0;in;r--,n++){var a=t[n];t[n]=t[r],t[r]=a}return e},o.prototype.failurePosition=0,String.fromCharCodeUint8=function(e){for(var t=[],i=0;i>16),this.writeUint8((65280&e)>>8),this.writeUint8(255&e)},o.prototype.adjustUint32=function(e,t){var i=this.position;this.seek(e),this.writeUint32(t),this.seek(i)},o.prototype.mapInt32Array=function(e,t){this._realloc(4*e);var i=new Int32Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},o.prototype.mapInt16Array=function(e,t){this._realloc(2*e);var i=new Int16Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},o.prototype.mapInt8Array=function(e){this._realloc(1*e);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},o.prototype.mapUint32Array=function(e,t){this._realloc(4*e);var i=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},o.prototype.mapUint16Array=function(e,t){this._realloc(2*e);var i=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},o.prototype.mapFloat64Array=function(e,t){this._realloc(8*e);var i=new Float64Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=8*e,i},o.prototype.mapFloat32Array=function(e,t){this._realloc(4*e);var i=new Float32Array(this._buffer,this.byteOffset+this.position,e);return o.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i};var f=function(e){this.buffers=[],this.bufferIndex=-1,e&&(this.insertBuffer(e),this.bufferIndex=0)};(f.prototype=new o(new ArrayBuffer,0,o.BIG_ENDIAN)).initialized=function(){var e;return this.bufferIndex>-1||(this.buffers.length>0?0===(e=this.buffers[0]).fileStart?(this.buffer=e,this.bufferIndex=0,a.debug("MultiBufferStream","Stream ready for parsing"),!0):(a.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1):(a.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1))},ArrayBuffer.concat=function(e,t){a.debug("ArrayBuffer","Trying to create a new buffer of size: "+(e.byteLength+t.byteLength));var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e),0),i.set(new Uint8Array(t),e.byteLength),i.buffer},f.prototype.reduceBuffer=function(e,t,i){var r;return(r=new Uint8Array(i)).set(new Uint8Array(e,t,i)),r.buffer.fileStart=e.fileStart+t,r.buffer.usedBytes=0,r.buffer},f.prototype.insertBuffer=function(e){for(var t=!0,i=0;ir.byteLength){this.buffers.splice(i,1),i--;continue}a.warn("MultiBufferStream","Buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+") already appended, ignoring")}else e.fileStart+e.byteLength<=r.fileStart||(e=this.reduceBuffer(e,0,r.fileStart-e.fileStart)),a.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.splice(i,0,e),0===i&&(this.buffer=e);t=!1;break}if(e.fileStart0)){t=!1;break}e=this.reduceBuffer(e,n,s)}}t&&(a.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.push(e),0===i&&(this.buffer=e))},f.prototype.logBufferLevel=function(e){var t,i,r,n,s,o=[],l="";for(r=0,n=0,t=0;t0&&(l+=s.end-1+"]");var f=e?a.info:a.debug;0===this.buffers.length?f("MultiBufferStream","No more buffer in memory"):f("MultiBufferStream",this.buffers.length+" stored buffer(s) ("+r+"/"+n+" bytes): "+l)},f.prototype.cleanBuffers=function(){var e,t;for(e=0;e"+this.buffer.byteLength+")"),!0}return!1}return!1},f.prototype.findPosition=function(e,t,i){var r,n=null,s=-1;for(r=!0===e?0:this.bufferIndex;r=t?(a.debug("MultiBufferStream","Found position in existing buffer #"+s),s):-1},f.prototype.findEndContiguousBuf=function(e){var t,i,r,n=void 0!==e?e:this.bufferIndex;if(i=this.buffers[n],this.buffers.length>n+1)for(t=n+1;t>3;return 31===r&&i.data.length>=2&&(r=32+((7&i.data[0])<<3)+((224&i.data[1])>>5)),r}return null},i.DecoderConfigDescriptor=function(e){i.Descriptor.call(this,4,e)},i.DecoderConfigDescriptor.prototype=new i.Descriptor,i.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8(),this.streamType=e.readUint8(),this.bufferSize=e.readUint24(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),this.size-=13,this.parseRemainingDescriptors(e)},i.DecoderSpecificInfo=function(e){i.Descriptor.call(this,5,e)},i.DecoderSpecificInfo.prototype=new i.Descriptor,i.SLConfigDescriptor=function(e){i.Descriptor.call(this,6,e)},i.SLConfigDescriptor.prototype=new i.Descriptor,this};void 0!==i&&(i.MPEG4DescriptorParser=u);var h={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){h.FullBox.prototype=new h.Box,h.ContainerBox.prototype=new h.Box,h.SampleEntry.prototype=new h.Box,h.TrackGroupTypeBox.prototype=new h.FullBox,h.BASIC_BOXES.forEach((function(e){h.createBoxCtor(e)})),h.FULL_BOXES.forEach((function(e){h.createFullBoxCtor(e)})),h.CONTAINER_BOXES.forEach((function(e){h.createContainerBoxCtor(e[0],null,e[1])}))},Box:function(e,t,i){this.type=e,this.size=t,this.uuid=i},FullBox:function(e,t,i){h.Box.call(this,e,t,i),this.flags=0,this.version=0},ContainerBox:function(e,t,i){h.Box.call(this,e,t,i),this.boxes=[]},SampleEntry:function(e,t,i,r){h.ContainerBox.call(this,e,t),this.hdr_size=i,this.start=r},SampleGroupEntry:function(e){this.grouping_type=e},TrackGroupTypeBox:function(e,t){h.FullBox.call(this,e,t)},createBoxCtor:function(e,t){h.boxCodes.push(e),h[e+"Box"]=function(t){h.Box.call(this,e,t)},h[e+"Box"].prototype=new h.Box,t&&(h[e+"Box"].prototype.parse=t)},createFullBoxCtor:function(e,t){h[e+"Box"]=function(t){h.FullBox.call(this,e,t)},h[e+"Box"].prototype=new h.FullBox,h[e+"Box"].prototype.parse=function(e){this.parseFullHeader(e),t&&t.call(this,e)}},addSubBoxArrays:function(e){if(e){this.subBoxNames=e;for(var t=e.length,i=0;ii?(a.error("BoxParser","Box of type '"+u+"' has a size "+f+" greater than its container size "+i),{code:h.ERR_NOT_ENOUGH_DATA,type:u,size:f,hdr_size:l,start:o}):o+f>e.getEndPosition()?(e.seek(o),a.info("BoxParser","Not enough data in stream to parse the entire '"+u+"' box"),{code:h.ERR_NOT_ENOUGH_DATA,type:u,size:f,hdr_size:l,start:o}):t?{code:h.OK,type:u,size:f,hdr_size:l,start:o}:(h[u+"Box"]?r=new h[u+"Box"](f):"uuid"!==u?(a.warn("BoxParser","Unknown box type: '"+u+"'"),(r=new h.Box(u,f)).has_unparsed_data=!0):h.UUIDBoxes[s]?r=new h.UUIDBoxes[s](f):(a.warn("BoxParser","Unknown uuid type: '"+s+"'"),(r=new h.Box(u,f)).uuid=s,r.has_unparsed_data=!0),r.hdr_size=l,r.start=o,r.write===h.Box.prototype.write&&"mdat"!==r.type&&(a.info("BoxParser","'"+c+"' box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(e)),r.parse(e),(n=e.getPosition()-(r.start+r.size))<0?(a.warn("BoxParser","Parsing of box '"+c+"' did not read the entire indicated box data size (missing "+-n+" bytes), seeking forward"),e.seek(r.start+r.size)):n>0&&(a.error("BoxParser","Parsing of box '"+c+"' read "+n+" more bytes than the indicated box data size, seeking backwards"),e.seek(r.start+r.size)),{code:h.OK,box:r,size:r.size})},h.Box.prototype.parse=function(e){"mdat"!=this.type?this.data=e.readUint8Array(this.size-this.hdr_size):0===this.size?e.seek(e.getEndPosition()):e.seek(this.start+this.size)},h.Box.prototype.parseDataAndRewind=function(e){this.data=e.readUint8Array(this.size-this.hdr_size),e.position-=this.size-this.hdr_size},h.FullBox.prototype.parseDataAndRewind=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,e.position-=this.size-this.hdr_size},h.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8(),this.flags=e.readUint24(),this.hdr_size+=4},h.FullBox.prototype.parse=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},h.ContainerBox.prototype.parse=function(e){for(var t,i;e.getPosition()>10&31,t[1]=this.language>>5&31,t[2]=31&this.language,this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96)},h.SAMPLE_ENTRY_TYPE_VISUAL="Visual",h.SAMPLE_ENTRY_TYPE_AUDIO="Audio",h.SAMPLE_ENTRY_TYPE_HINT="Hint",h.SAMPLE_ENTRY_TYPE_METADATA="Metadata",h.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle",h.SAMPLE_ENTRY_TYPE_SYSTEM="System",h.SAMPLE_ENTRY_TYPE_TEXT="Text",h.SampleEntry.prototype.parseHeader=function(e){e.readUint8Array(6),this.data_reference_index=e.readUint16(),this.hdr_size+=8},h.SampleEntry.prototype.parse=function(e){this.parseHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},h.SampleEntry.prototype.parseDataAndRewind=function(e){this.parseHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,e.position-=this.size-this.hdr_size},h.SampleEntry.prototype.parseFooter=function(e){h.ContainerBox.prototype.parse.call(this,e)},h.createMediaSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_HINT),h.createMediaSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_METADATA),h.createMediaSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_SUBTITLE),h.createMediaSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_SYSTEM),h.createMediaSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_TEXT),h.createMediaSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_VISUAL,(function(e){var t;this.parseHeader(e),e.readUint16(),e.readUint16(),e.readUint32Array(3),this.width=e.readUint16(),this.height=e.readUint16(),this.horizresolution=e.readUint32(),this.vertresolution=e.readUint32(),e.readUint32(),this.frame_count=e.readUint16(),t=Math.min(31,e.readUint8()),this.compressorname=e.readString(t),t<31&&e.readString(31-t),this.depth=e.readUint16(),e.readUint16(),this.parseFooter(e)})),h.createMediaSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_AUDIO,(function(e){this.parseHeader(e),e.readUint32Array(2),this.channel_count=e.readUint16(),this.samplesize=e.readUint16(),e.readUint16(),e.readUint16(),this.samplerate=e.readUint32()/65536,this.parseFooter(e)})),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_VISUAL,"avc1"),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_VISUAL,"avc2"),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_VISUAL,"avc3"),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_VISUAL,"avc4"),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_VISUAL,"av01"),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1"),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_VISUAL,"hev1"),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a"),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3"),h.createSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3"),h.createEncryptedSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_VISUAL,"encv"),h.createEncryptedSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_AUDIO,"enca"),h.createEncryptedSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu"),h.createEncryptedSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_SYSTEM,"encs"),h.createEncryptedSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_TEXT,"enct"),h.createEncryptedSampleEntryCtor(h.SAMPLE_ENTRY_TYPE_METADATA,"encm"),h.createBoxCtor("av1C",(function(e){var t=e.readUint8();if(t>>7&!1)a.error("av1C marker problem");else if(this.version=127&t,1===this.version)if(t=e.readUint8(),this.seq_profile=t>>5&7,this.seq_level_idx_0=31&t,t=e.readUint8(),this.seq_tier_0=t>>7&1,this.high_bitdepth=t>>6&1,this.twelve_bit=t>>5&1,this.monochrome=t>>4&1,this.chroma_subsampling_x=t>>3&1,this.chroma_subsampling_y=t>>2&1,this.chroma_sample_position=3&t,t=e.readUint8(),this.reserved_1=t>>5&7,0===this.reserved_1){if(this.initial_presentation_delay_present=t>>4&1,1===this.initial_presentation_delay_present)this.initial_presentation_delay_minus_one=15&t;else if(this.reserved_2=15&t,0!==this.reserved_2)return void a.error("av1C reserved_2 parsing problem");var i=this.size-this.hdr_size-4;this.configOBUs=e.readUint8Array(i)}else a.error("av1C reserved_1 parsing problem");else a.error("av1C version "+this.version+" not supported")})),h.createBoxCtor("avcC",(function(e){var t,i;for(this.configurationVersion=e.readUint8(),this.AVCProfileIndication=e.readUint8(),this.profile_compatibility=e.readUint8(),this.AVCLevelIndication=e.readUint8(),this.lengthSizeMinusOne=3&e.readUint8(),this.nb_SPS_nalus=31&e.readUint8(),i=this.size-this.hdr_size-6,this.SPS=[],t=0;t0&&(this.ext=e.readUint8Array(i))})),h.createBoxCtor("btrt",(function(e){this.bufferSizeDB=e.readUint32(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32()})),h.createBoxCtor("clap",(function(e){this.cleanApertureWidthN=e.readUint32(),this.cleanApertureWidthD=e.readUint32(),this.cleanApertureHeightN=e.readUint32(),this.cleanApertureHeightD=e.readUint32(),this.horizOffN=e.readUint32(),this.horizOffD=e.readUint32(),this.vertOffN=e.readUint32(),this.vertOffD=e.readUint32()})),h.createBoxCtor("clli",(function(e){this.max_content_light_level=e.readUint16(),this.max_pic_average_light_level=e.readUint16()})),h.createFullBoxCtor("co64",(function(e){var t,i;if(t=e.readUint32(),this.chunk_offsets=[],0===this.version)for(i=0;i>7}else("rICC"===this.colour_type||"prof"===this.colour_type)&&(this.ICC_profile=e.readUint8Array(this.size-4))})),h.createFullBoxCtor("cprt",(function(e){this.parseLanguage(e),this.notice=e.readCString()})),h.createFullBoxCtor("cslg",(function(e){0===this.version&&(this.compositionToDTSShift=e.readInt32(),this.leastDecodeToDisplayDelta=e.readInt32(),this.greatestDecodeToDisplayDelta=e.readInt32(),this.compositionStartTime=e.readInt32(),this.compositionEndTime=e.readInt32())})),h.createFullBoxCtor("ctts",(function(e){var t,i;if(t=e.readUint32(),this.sample_counts=[],this.sample_offsets=[],0===this.version)for(i=0;i>6,this.bsid=t>>1&31,this.bsmod=(1&t)<<2|i>>6&3,this.acmod=i>>3&7,this.lfeon=i>>2&1,this.bit_rate_code=3&i|r>>5&7})),h.createBoxCtor("dec3",(function(e){var t=e.readUint16();this.data_rate=t>>3,this.num_ind_sub=7&t,this.ind_subs=[];for(var i=0;i>6,r.bsid=n>>1&31,r.bsmod=(1&n)<<4|a>>4&15,r.acmod=a>>1&7,r.lfeon=1&a,r.num_dep_sub=s>>1&15,r.num_dep_sub>0&&(r.chan_loc=(1&s)<<8|e.readUint8())}})),h.createFullBoxCtor("dfLa",(function(e){var t=[],i=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];for(this.parseFullHeader(e);;){var r=e.readUint8(),n=Math.min(127&r,i.length-1);if(n?e.readUint8Array(e.readUint24()):(e.readUint8Array(13),this.samplerate=e.readUint32()>>12,e.readUint8Array(20)),t.push(i[n]),128&r)break}this.numMetadataBlocks=t.length+" ("+t.join(", ")+")"})),h.createBoxCtor("dimm",(function(e){this.bytessent=e.readUint64()})),h.createBoxCtor("dmax",(function(e){this.time=e.readUint32()})),h.createBoxCtor("dmed",(function(e){this.bytessent=e.readUint64()})),h.createFullBoxCtor("dref",(function(e){var t,i;this.entries=[];for(var r=e.readUint32(),n=0;n=4;)this.compatible_brands[i]=e.readString(4),t-=4,i++})),h.createFullBoxCtor("hdlr",(function(e){0===this.version&&(e.readUint32(),this.handler=e.readString(4),e.readUint32Array(3),this.name=e.readString(this.size-this.hdr_size-20),"\0"===this.name[this.name.length-1]&&(this.name=this.name.slice(0,-1)))})),h.createBoxCtor("hvcC",(function(e){var t,i,r,n;this.configurationVersion=e.readUint8(),n=e.readUint8(),this.general_profile_space=n>>6,this.general_tier_flag=(32&n)>>5,this.general_profile_idc=31&n,this.general_profile_compatibility=e.readUint32(),this.general_constraint_indicator=e.readUint8Array(6),this.general_level_idc=e.readUint8(),this.min_spatial_segmentation_idc=4095&e.readUint16(),this.parallelismType=3&e.readUint8(),this.chroma_format_idc=3&e.readUint8(),this.bit_depth_luma_minus8=7&e.readUint8(),this.bit_depth_chroma_minus8=7&e.readUint8(),this.avgFrameRate=e.readUint16(),n=e.readUint8(),this.constantFrameRate=n>>6,this.numTemporalLayers=(13&n)>>3,this.temporalIdNested=(4&n)>>2,this.lengthSizeMinusOne=3&n,this.nalu_arrays=[];var a=e.readUint8();for(t=0;t>7,s.nalu_type=63&n;var o=e.readUint16();for(i=0;i>4&15,this.length_size=15&t,t=e.readUint8(),this.base_offset_size=t>>4&15,1===this.version||2===this.version?this.index_size=15&t:this.index_size=0,this.items=[];var i=0;if(this.version<2)i=e.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";i=e.readUint32()}for(var r=0;r=2&&(2===this.version?this.item_ID=e.readUint16():3===this.version&&(this.item_ID=e.readUint32()),this.item_protection_index=e.readUint16(),this.item_type=e.readString(4),this.item_name=e.readCString(),"mime"===this.item_type?(this.content_type=e.readCString(),this.content_encoding=e.readCString()):"uri "===this.item_type&&(this.item_uri_type=e.readCString()))})),h.createFullBoxCtor("ipma",(function(e){var t,i;for(entry_count=e.readUint32(),this.associations=[],t=0;t>7==1,1&this.flags?s.property_index=(127&a)<<8|e.readUint8():s.property_index=127&a}}})),h.createFullBoxCtor("iref",(function(e){var t,i;for(this.references=[];e.getPosition()>7,r.assignment_type=127&n,r.assignment_type){case 0:r.grouping_type=e.readString(4);break;case 1:r.grouping_type=e.readString(4),r.grouping_type_parameter=e.readUint32();break;case 2:case 3:break;case 4:r.sub_track_id=e.readUint32();break;default:a.warn("BoxParser","Unknown leva assignement type")}}})),h.createBoxCtor("maxr",(function(e){this.period=e.readUint32(),this.bytes=e.readUint32()})),h.createBoxCtor("mdcv",(function(e){this.display_primaries=[],this.display_primaries[0]={},this.display_primaries[0].x=e.readUint16(),this.display_primaries[0].y=e.readUint16(),this.display_primaries[1]={},this.display_primaries[1].x=e.readUint16(),this.display_primaries[1].y=e.readUint16(),this.display_primaries[2]={},this.display_primaries[2].x=e.readUint16(),this.display_primaries[2].y=e.readUint16(),this.white_point={},this.white_point.x=e.readUint16(),this.white_point.y=e.readUint16(),this.max_display_mastering_luminance=e.readUint32(),this.min_display_mastering_luminance=e.readUint32()})),h.createFullBoxCtor("mdhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.parseLanguage(e),e.readUint16()})),h.createFullBoxCtor("mehd",(function(e){1&this.flags&&(a.warn("BoxParser","mehd box incorrectly uses flags set to 1, converting version to 1"),this.version=1),1==this.version?this.fragment_duration=e.readUint64():this.fragment_duration=e.readUint32()})),h.createFullBoxCtor("meta",(function(e){this.boxes=[],h.ContainerBox.prototype.parse.call(this,e)})),h.createFullBoxCtor("mfhd",(function(e){this.sequence_number=e.readUint32()})),h.createFullBoxCtor("mfro",(function(e){this._size=e.readUint32()})),h.createFullBoxCtor("mvhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.rate=e.readUint32(),this.volume=e.readUint16()>>8,e.readUint16(),e.readUint32Array(2),this.matrix=e.readUint32Array(9),e.readUint32Array(6),this.next_track_id=e.readUint32()})),h.createBoxCtor("npck",(function(e){this.packetssent=e.readUint32()})),h.createBoxCtor("nump",(function(e){this.packetssent=e.readUint64()})),h.createFullBoxCtor("padb",(function(e){var t=e.readUint32();this.padbits=[];for(var i=0;i0){var t=e.readUint32();this.kid=[];for(var i=0;i0&&(this.data=e.readUint8Array(r))})),h.createFullBoxCtor("clef",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),h.createFullBoxCtor("enof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),h.createFullBoxCtor("prof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),h.createContainerBoxCtor("tapt",null,["clef","prof","enof"]),h.createBoxCtor("rtp ",(function(e){this.descriptionformat=e.readString(4),this.sdptext=e.readString(this.size-this.hdr_size-4)})),h.createFullBoxCtor("saio",(function(e){1&this.flags&&(this.aux_info_type=e.readUint32(),this.aux_info_type_parameter=e.readUint32());var t=e.readUint32();this.offset=[];for(var i=0;i>7,this.avgRateFlag=t>>6&1,this.durationFlag&&(this.duration=e.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=e.readUint8(),this.avgBitRate=e.readUint16(),this.avgFrameRate=e.readUint16()),this.dependency=[];for(var i=e.readUint8(),r=0;r>7,this.num_leading_samples=127&t})),h.createSampleGroupCtor("rash",(function(e){if(this.operation_point_count=e.readUint16(),this.description_length!==2+(1===this.operation_point_count?2:6*this.operation_point_count)+9)a.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=e.readUint8Array(this.description_length-2);else{if(1===this.operation_point_count)this.target_rate_share=e.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(var t=0;t>4,this.skip_byte_block=15&t,this.isProtected=e.readUint8(),this.Per_Sample_IV_Size=e.readUint8(),this.KID=h.parseHex16(e),this.constant_IV_size=0,this.constant_IV=0,1===this.isProtected&&0===this.Per_Sample_IV_Size&&(this.constant_IV_size=e.readUint8(),this.constant_IV=e.readUint8Array(this.constant_IV_size))})),h.createSampleGroupCtor("stsa",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),h.createSampleGroupCtor("sync",(function(e){var t=e.readUint8();this.NAL_unit_type=63&t})),h.createSampleGroupCtor("tele",(function(e){var t=e.readUint8();this.level_independently_decodable=t>>7})),h.createSampleGroupCtor("tsas",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),h.createSampleGroupCtor("tscl",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),h.createSampleGroupCtor("vipr",(function(e){a.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),h.createFullBoxCtor("sbgp",(function(e){this.grouping_type=e.readString(4),1===this.version?this.grouping_type_parameter=e.readUint32():this.grouping_type_parameter=0,this.entries=[];for(var t=e.readUint32(),i=0;i>6,this.sample_depends_on[r]=t>>4&3,this.sample_is_depended_on[r]=t>>2&3,this.sample_has_redundancy[r]=3&t})),h.createFullBoxCtor("senc"),h.createFullBoxCtor("sgpd",(function(e){this.grouping_type=e.readString(4),a.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),1===this.version?this.default_length=e.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=e.readUint32()),this.entries=[];for(var t=e.readUint32(),i=0;i>31&1,r.referenced_size=2147483647&n,r.subsegment_duration=e.readUint32(),n=e.readUint32(),r.starts_with_SAP=n>>31&1,r.SAP_type=n>>28&7,r.SAP_delta_time=268435455&n}})),h.SingleItemTypeReferenceBox=function(e,t,i,r){h.Box.call(this,e,t),this.hdr_size=i,this.start=r},h.SingleItemTypeReferenceBox.prototype=new h.Box,h.SingleItemTypeReferenceBox.prototype.parse=function(e){this.from_item_ID=e.readUint16();var t=e.readUint16();this.references=[];for(var i=0;i>4&15,this.sample_sizes[t+1]=15&r}else if(8===this.field_size)for(t=0;t0)for(i=0;i>4&15,this.default_skip_byte_block=15&t}this.default_isProtected=e.readUint8(),this.default_Per_Sample_IV_Size=e.readUint8(),this.default_KID=h.parseHex16(e),1===this.default_isProtected&&0===this.default_Per_Sample_IV_Size&&(this.default_constant_IV_size=e.readUint8(),this.default_constant_IV=e.readUint8Array(this.default_constant_IV_size))})),h.createFullBoxCtor("tfdt",(function(e){1==this.version?this.baseMediaDecodeTime=e.readUint64():this.baseMediaDecodeTime=e.readUint32()})),h.createFullBoxCtor("tfhd",(function(e){var t=0;this.track_id=e.readUint32(),this.size-this.hdr_size>t&&this.flags&h.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=e.readUint64(),t+=8):this.base_data_offset=0,this.size-this.hdr_size>t&&this.flags&h.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=e.readUint32(),t+=4):this.default_sample_description_index=0,this.size-this.hdr_size>t&&this.flags&h.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=e.readUint32(),t+=4):this.default_sample_duration=0,this.size-this.hdr_size>t&&this.flags&h.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=e.readUint32(),t+=4):this.default_sample_size=0,this.size-this.hdr_size>t&&this.flags&h.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=e.readUint32(),t+=4):this.default_sample_flags=0})),h.createFullBoxCtor("tfra",(function(e){this.track_ID=e.readUint32(),e.readUint24();var t=e.readUint8();this.length_size_of_traf_num=t>>4&3,this.length_size_of_trun_num=t>>2&3,this.length_size_of_sample_num=3&t,this.entries=[];for(var i=e.readUint32(),r=0;r>8,e.readUint16(),this.matrix=e.readInt32Array(9),this.width=e.readUint32(),this.height=e.readUint32()})),h.createBoxCtor("tmax",(function(e){this.time=e.readUint32()})),h.createBoxCtor("tmin",(function(e){this.time=e.readUint32()})),h.createBoxCtor("totl",(function(e){this.bytessent=e.readUint32()})),h.createBoxCtor("tpay",(function(e){this.bytessent=e.readUint32()})),h.createBoxCtor("tpyl",(function(e){this.bytessent=e.readUint64()})),h.TrackGroupTypeBox.prototype.parse=function(e){this.parseFullHeader(e),this.track_group_id=e.readUint32()},h.createTrackGroupCtor("msrc"),h.TrackReferenceTypeBox=function(e,t,i,r){h.Box.call(this,e,t),this.hdr_size=i,this.start=r},h.TrackReferenceTypeBox.prototype=new h.Box,h.TrackReferenceTypeBox.prototype.parse=function(e){this.track_ids=e.readUint32Array((this.size-this.hdr_size)/4)},h.trefBox.prototype.parse=function(e){for(var t,i;e.getPosition()t&&this.flags&h.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size-this.hdr_size>t&&this.flags&h.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=e.readUint32(),t+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>t)for(var i=0;i0&&(this.location=e.readCString())})),h.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66",!0,!1,(function(e){this.LiveServerManifest=e.readString(this.size-this.hdr_size).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")})),h.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,(function(e){this.system_id=h.parseHex16(e);var t=e.readUint32();t>0&&(this.data=e.readUint8Array(t))})),h.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1),h.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,(function(e){this.default_AlgorithmID=e.readUint24(),this.default_IV_size=e.readUint8(),this.default_KID=h.parseHex16(e)})),h.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,(function(e){this.fragment_count=e.readUint8(),this.entries=[];for(var t=0;t>4,this.chromaSubsampling=t>>1&7,this.videoFullRangeFlag=1&t,this.colourPrimaries=e.readUint8(),this.transferCharacteristics=e.readUint8(),this.matrixCoefficients=e.readUint8(),this.codecIntializationDataSize=e.readUint16(),this.codecIntializationData=e.readUint8Array(this.codecIntializationDataSize)):(this.profile=e.readUint8(),this.level=e.readUint8(),t=e.readUint8(),this.bitDepth=t>>4&15,this.colorSpace=15&t,t=e.readUint8(),this.chromaSubsampling=t>>4&15,this.transferFunction=t>>1&7,this.videoFullRangeFlag=1&t,this.codecIntializationDataSize=e.readUint16(),this.codecIntializationData=e.readUint8Array(this.codecIntializationDataSize))})),h.createBoxCtor("vttC",(function(e){this.text=e.readString(this.size-this.hdr_size)})),h.SampleEntry.prototype.isVideo=function(){return!1},h.SampleEntry.prototype.isAudio=function(){return!1},h.SampleEntry.prototype.isSubtitle=function(){return!1},h.SampleEntry.prototype.isMetadata=function(){return!1},h.SampleEntry.prototype.isHint=function(){return!1},h.SampleEntry.prototype.getCodec=function(){return this.type.replace(".","")},h.SampleEntry.prototype.getWidth=function(){return""},h.SampleEntry.prototype.getHeight=function(){return""},h.SampleEntry.prototype.getChannelCount=function(){return""},h.SampleEntry.prototype.getSampleRate=function(){return""},h.SampleEntry.prototype.getSampleSize=function(){return""},h.VisualSampleEntry.prototype.isVideo=function(){return!0},h.VisualSampleEntry.prototype.getWidth=function(){return this.width},h.VisualSampleEntry.prototype.getHeight=function(){return this.height},h.AudioSampleEntry.prototype.isAudio=function(){return!0},h.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count},h.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate},h.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize},h.SubtitleSampleEntry.prototype.isSubtitle=function(){return!0},h.MetadataSampleEntry.prototype.isMetadata=function(){return!0},h.decimalToHex=function(e,t){var i=Number(e).toString(16);for(t=null==t?t=2:t;i.length>=1;t+=h.decimalToHex(r,0),t+=".",0===this.hvcC.general_tier_flag?t+="L":t+="H",t+=this.hvcC.general_level_idc;var n=!1,a="";for(e=5;e>=0;e--)(this.hvcC.general_constraint_indicator[e]||n)&&(a="."+h.decimalToHex(this.hvcC.general_constraint_indicator[e],0)+a,n=!0);t+=a}return t},h.mp4aSampleEntry.prototype.getCodec=function(){var e=h.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI(),i=this.esds.esd.getAudioConfig();return e+"."+h.decimalToHex(t)+(i?"."+i:"")}return e},h.stxtSampleEntry.prototype.getCodec=function(){var e=h.SampleEntry.prototype.getCodec.call(this);return this.mime_format?e+"."+this.mime_format:e},h.av01SampleEntry.prototype.getCodec=function(){var e,t=h.SampleEntry.prototype.getCodec.call(this);return 2===this.av1C.seq_profile&&1===this.av1C.high_bitdepth?e=1===this.av1C.twelve_bit?"12":"10":this.av1C.seq_profile<=2&&(e=1===this.av1C.high_bitdepth?"10":"08"),t+"."+this.av1C.seq_profile+"."+this.av1C.seq_level_idx_0+(this.av1C.seq_tier_0?"H":"M")+"."+e},h.Box.prototype.writeHeader=function(e,t){this.size+=8,this.size>l&&(this.size+=8),"uuid"===this.type&&(this.size+=16),a.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+e.getPosition()+(t||"")),this.size>l?e.writeUint32(1):(this.sizePosition=e.getPosition(),e.writeUint32(this.size)),e.writeString(this.type,null,4),"uuid"===this.type&&e.writeUint8Array(this.uuid),this.size>l&&e.writeUint64(this.size)},h.FullBox.prototype.writeHeader=function(e){this.size+=4,h.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},h.Box.prototype.write=function(e){"mdat"===this.type?this.data&&(this.size=this.data.length,this.writeHeader(e),e.writeUint8Array(this.data)):(this.size=this.data?this.data.length:0,this.writeHeader(e),this.data&&e.writeUint8Array(this.data))},h.ContainerBox.prototype.write=function(e){this.size=0,this.writeHeader(e);for(var t=0;t=2&&e.writeUint32(this.default_sample_description_index),e.writeUint32(this.entries.length),t=0;t0)for(t=0;t+1-1||e[i]instanceof h.Box||t[i]instanceof h.Box||void 0===e[i]||void 0===t[i]||"function"==typeof e[i]||"function"==typeof t[i]||e.subBoxNames&&e.subBoxNames.indexOf(i.slice(0,4))>-1||t.subBoxNames&&t.subBoxNames.indexOf(i.slice(0,4))>-1||"data"===i||"start"===i||"size"===i||"creation_time"===i||"modification_time"===i||h.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(i)>-1||e[i]===t[i]))return!1;return!0},h.boxEqual=function(e,t){if(!h.boxEqualFields(e,t))return!1;for(var i=0;i=t?e:new Array(t-e.length+1).join(i)+e}function n(e){var t=Math.floor(e/3600),i=Math.floor((e-3600*t)/60),n=Math.floor(e-3600*t-60*i),a=Math.floor(1e3*(e-3600*t-60*i-n));return r(t,2)+":"+r(i,2)+":"+r(n,2)+"."+r(a,3)}for(var a=this.parseSample(i),s="",o=0;o1)for(t=1;t-1&&this.fragmentedTracks.splice(t,1)},p.prototype.setExtractionOptions=function(e,t,i){var r=this.getTrackById(e);if(r){var n={};this.extractedTracks.push(n),n.id=e,n.user=t,n.trak=r,r.nextSample=0,n.nb_samples=1e3,n.samples=[],i&&i.nbSamples&&(n.nb_samples=i.nbSamples)}},p.prototype.unsetExtractionOptions=function(e){for(var t=-1,i=0;i-1&&this.extractedTracks.splice(t,1)},p.prototype.parse=function(){var e,t;if(!this.restoreParsePosition||this.restoreParsePosition())for(;;){if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}if(this.saveParsePosition&&this.saveParsePosition(),(e=h.parseOneBox(this.stream,!1)).code===h.ERR_NOT_ENOUGH_DATA){if(this.processIncompleteBox){if(this.processIncompleteBox(e))continue;return}return}var i;switch(i="uuid"!==(t=e.box).type?t.type:t.uuid,this.boxes.push(t),i){case"mdat":this.mdats.push(t);break;case"moof":this.moofs.push(t);break;case"moov":this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0);default:void 0!==this[i]&&a.warn("ISOFile","Duplicate Box of type: "+i+", overriding previous occurrence"),this[i]=t}this.updateUsedBytes&&this.updateUsedBytes(t,e)}},p.prototype.checkBuffer=function(e){if(null==e)throw"Buffer must be defined and non empty";if(void 0===e.fileStart)throw"Buffer must have a fileStart property";return 0===e.byteLength?(a.warn("ISOFile","Ignoring empty buffer (fileStart: "+e.fileStart+")"),this.stream.logBufferLevel(),!1):(a.info("ISOFile","Processing buffer (fileStart: "+e.fileStart+")"),e.usedBytes=0,this.stream.insertBuffer(e),this.stream.logBufferLevel(),!!this.stream.initialized()||(a.warn("ISOFile","Not ready to start parsing"),!1))},p.prototype.appendBuffer=function(e,t){var i;if(this.checkBuffer(e))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(t),this.nextSeekPosition?(i=this.nextSeekPosition,this.nextSeekPosition=void 0):i=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(i=this.stream.getEndFilePositionAfter(i))):i=this.nextParsePosition?this.nextParsePosition:0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(a.info("ISOFile","Done processing buffer (fileStart: "+e.fileStart+") - next buffer to fetch should have a fileStart position of "+i),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),a.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),i},p.prototype.getInfo=function(){var e,t,i,r,n,a={},s=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(a.hasMoov=!0,a.duration=this.moov.mvhd.duration,a.timescale=this.moov.mvhd.timescale,a.isFragmented=null!=this.moov.mvex,a.isFragmented&&this.moov.mvex.mehd&&(a.fragment_duration=this.moov.mvex.mehd.fragment_duration),a.isProgressive=this.isProgressive,a.hasIOD=null!=this.moov.iods,a.brands=[],a.brands.push(this.ftyp.major_brand),a.brands=a.brands.concat(this.ftyp.compatible_brands),a.created=new Date(s+1e3*this.moov.mvhd.creation_time),a.modified=new Date(s+1e3*this.moov.mvhd.modification_time),a.tracks=[],a.audioTracks=[],a.videoTracks=[],a.subtitleTracks=[],a.metadataTracks=[],a.hintTracks=[],a.otherTracks=[],e=0;e0?a.mime+='video/mp4; codecs="':a.audioTracks&&a.audioTracks.length>0?a.mime+='audio/mp4; codecs="':a.mime+='application/mp4; codecs="',e=0;e=i.samples.length)&&(a.info("ISOFile","Sending fragmented data on track #"+r.id+" for samples ["+Math.max(0,i.nextSample-r.nb_samples)+","+(i.nextSample-1)+"]"),a.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(r.id,r.user,r.segmentStream.buffer,i.nextSample,e||i.nextSample>=i.samples.length),r.segmentStream=null,r!==this.fragmentedTracks[t]))break}}if(null!==this.onSamples)for(t=0;t=i.samples.length)&&(a.debug("ISOFile","Sending samples on track #"+s.id+" for sample "+i.nextSample),this.onSamples&&this.onSamples(s.id,s.user,s.samples),s.samples=[],s!==this.extractedTracks[t]))break}}}},p.prototype.getBox=function(e){var t=this.getBoxes(e,!0);return t.length?t[0]:null},p.prototype.getBoxes=function(e,t){var i=[];return p._sweep.call(this,e,i,t),i},p._sweep=function(e,t,i){for(var r in this.type&&this.type==e&&t.push(this),this.boxes){if(t.length&&i)return;p._sweep.call(this.boxes[r],e,t,i)}},p.prototype.getTrackSamplesInfo=function(e){var t=this.getTrackById(e);return t?t.samples:void 0},p.prototype.getTrackSample=function(e,t){var i=this.getTrackById(e);return this.getSample(i,t)},p.prototype.releaseUsedSamples=function(e,t){var i=0,r=this.getTrackById(e);r.lastValidSample||(r.lastValidSample=0);for(var n=r.lastValidSample;ne*n.timescale){f=r-1;break}t&&n.is_sync&&(l=r)}for(t&&(f=l),e=i.samples[f].cts,i.nextSample=f;i.samples[f].alreadyRead===i.samples[f].size&&i.samples[f+1];)f++;return s=i.samples[f].offset+i.samples[f].alreadyRead,a.info("ISOFile","Seeking to "+(t?"RAP":"")+" sample #"+i.nextSample+" on track "+i.tkhd.track_id+", time "+a.getDurationString(e,o)+" and offset: "+s),{offset:s,time:e/o}},p.prototype.seek=function(e,t){var i,r,n,s=this.moov,o={offset:1/0,time:1/0};if(this.moov){for(n=0;n-1){s=o;break}switch(s){case"Visual":n.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),a.set("width",t.width).set("height",t.height).set("horizresolution",72<<16).set("vertresolution",72<<16).set("frame_count",1).set("compressorname",t.type+" Compressor").set("depth",24);break;case"Audio":n.add("smhd").set("balance",t.balance||0),a.set("channel_count",t.channel_count||2).set("samplesize",t.samplesize||16).set("samplerate",t.samplerate||65536);break;case"Hint":n.add("hmhd");break;case"Subtitle":switch(n.add("sthd"),t.type){case"stpp":a.set("namespace",t.namespace||"nonamespace").set("schema_location",t.schema_location||"").set("auxiliary_mime_types",t.auxiliary_mime_types||"")}break;case"Metadata":case"System":default:n.add("nmhd")}t.description&&a.addBox(t.description),t.description_boxes&&t.description_boxes.forEach((function(e){a.addBox(e)})),n.add("dinf").add("dref").addEntry((new h["url Box"]).set("flags",1));var u=n.add("stbl");return u.add("stsd").addEntry(a),u.add("stts").set("sample_counts",[]).set("sample_deltas",[]),u.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),u.add("stco").set("chunk_offsets",[]),u.add("stsz").set("sample_sizes",[]),this.moov.mvex.add("trex").set("track_id",t.id).set("default_sample_description_index",t.default_sample_description_index||1).set("default_sample_duration",t.default_sample_duration||0).set("default_sample_size",t.default_sample_size||0).set("default_sample_flags",t.default_sample_flags||0),this.buildTrakSampleLists(i),t.id}},h.Box.prototype.computeSize=function(e){var t=e||new o;t.endianness=o.BIG_ENDIAN,this.write(t)},p.prototype.addSample=function(e,t,i){var r=i||{},n={},a=this.getTrackById(e);if(null!==a){n.number=a.samples.length,n.track_id=a.tkhd.track_id,n.timescale=a.mdia.mdhd.timescale,n.description_index=r.sample_description_index?r.sample_description_index-1:0,n.description=a.mdia.minf.stbl.stsd.entries[n.description_index],n.data=t,n.size=t.length,n.alreadyRead=n.size,n.duration=r.duration||1,n.cts=r.cts||0,n.dts=r.dts||0,n.is_sync=r.is_sync||!1,n.is_leading=r.is_leading||0,n.depends_on=r.depends_on||0,n.is_depended_on=r.is_depended_on||0,n.has_redundancy=r.has_redundancy||0,n.degradation_priority=r.degradation_priority||0,n.offset=0,n.subsamples=r.subsamples,a.samples.push(n),a.samples_size+=n.size,a.samples_duration+=n.duration,this.processSamples();var s=p.createSingleSampleMoof(n);return this.addBox(s),s.computeSize(),s.trafs[0].truns[0].data_offset=s.size+8,this.add("mdat").data=t,n}},p.createSingleSampleMoof=function(e){var t=new h.moofBox;t.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++;var i=t.add("traf");return i.add("tfhd").set("track_id",e.track_id).set("flags",h.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),i.add("tfdt").set("baseMediaDecodeTime",e.dts),i.add("trun").set("flags",h.TRUN_FLAGS_DATA_OFFSET|h.TRUN_FLAGS_DURATION|h.TRUN_FLAGS_SIZE|h.TRUN_FLAGS_FLAGS|h.TRUN_FLAGS_CTS_OFFSET).set("data_offset",0).set("first_sample_flags",0).set("sample_count",1).set("sample_duration",[e.duration]).set("sample_size",[e.size]).set("sample_flags",[0]).set("sample_composition_time_offset",[e.cts-e.dts]),t},p.prototype.lastMoofIndex=0,p.prototype.samplesDataSize=0,p.prototype.resetTables=function(){var e,t,i,r,n,a;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,e=0;e=2&&(l=n[s].grouping_type+"/0",(o=new f(n[s].grouping_type,0)).is_fragment=!0,t.sample_groups_info[l]||(t.sample_groups_info[l]=o))}else for(s=0;s=2&&(l=r[s].grouping_type+"/0",o=new f(r[s].grouping_type,0),e.sample_groups_info[l]||(e.sample_groups_info[l]=o))},p.setSampleGroupProperties=function(e,t,i,r){var n,a;for(n in t.sample_groups=[],r){var s;if(t.sample_groups[n]={},t.sample_groups[n].grouping_type=r[n].grouping_type,t.sample_groups[n].grouping_type_parameter=r[n].grouping_type_parameter,i>=r[n].last_sample_in_run&&(r[n].last_sample_in_run<0&&(r[n].last_sample_in_run=0),r[n].entry_index++,r[n].entry_index<=r[n].sbgp.entries.length-1&&(r[n].last_sample_in_run+=r[n].sbgp.entries[r[n].entry_index].sample_count)),r[n].entry_index<=r[n].sbgp.entries.length-1?t.sample_groups[n].group_description_index=r[n].sbgp.entries[r[n].entry_index].group_description_index:t.sample_groups[n].group_description_index=-1,0!==t.sample_groups[n].group_description_index)s=r[n].fragment_description?r[n].fragment_description:r[n].description,t.sample_groups[n].group_description_index>0?(a=t.sample_groups[n].group_description_index>65535?(t.sample_groups[n].group_description_index>>16)-1:t.sample_groups[n].group_description_index-1,s&&a>=0&&(t.sample_groups[n].description=s.entries[a])):s&&s.version>=2&&s.default_group_description_index>0&&(t.sample_groups[n].description=s.entries[s.default_group_description_index-1])}},p.process_sdtp=function(e,t,i){t&&(e?(t.is_leading=e.is_leading[i],t.depends_on=e.sample_depends_on[i],t.is_depended_on=e.sample_is_depended_on[i],t.has_redundancy=e.sample_has_redundancy[i]):(t.is_leading=0,t.depends_on=0,t.is_depended_on=0,t.has_redundancy=0))},p.prototype.buildSampleLists=function(){var e,t;for(e=0;ey&&(g++,y<0&&(y=0),y+=a.sample_counts[g]),t>0?(e.samples[t-1].duration=a.sample_deltas[g],e.samples_duration+=e.samples[t-1].duration,T.dts=e.samples[t-1].dts+e.samples[t-1].duration):T.dts=0,s?(t>=w&&(E++,w<0&&(w=0),w+=s.sample_counts[E]),T.cts=e.samples[t].dts+s.sample_offsets[E]):T.cts=T.dts,o?(t==o.sample_numbers[C]-1?(T.is_sync=!0,C++):(T.is_sync=!1,T.degradation_priority=0),f&&f.entries[S].sample_delta+j==t+1&&(T.subsamples=f.entries[S].subsamples,j+=f.entries[S].sample_delta,S++)):T.is_sync=!0,p.process_sdtp(e.mdia.minf.stbl.sdtp,T,T.number),T.degradation_priority=c?c.priority[t]:0,f&&f.entries[S].sample_delta+j==t&&(T.subsamples=f.entries[S].subsamples,j+=f.entries[S].sample_delta),(u.length>0||h.length>0)&&p.setSampleGroupProperties(e,T,t,e.sample_groups_info)}t>0&&(e.samples[t-1].duration=Math.max(e.mdia.mdhd.duration-e.samples[t-1].dts,0),e.samples_duration+=e.samples[t-1].duration)}},p.prototype.updateSampleLists=function(){var e,t,i,r,n,a,s,o,l,f,u,c,d,_,m;if(void 0!==this.moov)for(;this.lastMoofIndex0&&p.initSampleGroups(c,u,u.sbgps,c.mdia.minf.stbl.sgpds,u.sgpds),t=0;t0?_.dts=c.samples[c.samples.length-2].dts+c.samples[c.samples.length-2].duration:(u.tfdt?_.dts=u.tfdt.baseMediaDecodeTime:_.dts=0,c.first_traf_merged=!0),_.cts=_.dts,b.flags&h.TRUN_FLAGS_CTS_OFFSET&&(_.cts=_.dts+b.sample_composition_time_offset[i]),m=s,b.flags&h.TRUN_FLAGS_FLAGS?m=b.sample_flags[i]:0===i&&b.flags&h.TRUN_FLAGS_FIRST_FLAG&&(m=b.first_sample_flags),_.is_sync=!(m>>16&1),_.is_leading=m>>26&3,_.depends_on=m>>24&3,_.is_depended_on=m>>22&3,_.has_redundancy=m>>20&3,_.degradation_priority=65535&m;var v=!!(u.tfhd.flags&h.TFHD_FLAG_BASE_DATA_OFFSET),y=!!(u.tfhd.flags&h.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),g=!!(b.flags&h.TRUN_FLAGS_DATA_OFFSET),w=0;w=v?u.tfhd.base_data_offset:y||0===t?f.start:o,_.offset=0===t&&0===i?g?w+b.data_offset:w:o,o=_.offset+_.size,(u.sbgps.length>0||u.sgpds.length>0||c.mdia.minf.stbl.sbgps.length>0||c.mdia.minf.stbl.sgpds.length>0)&&p.setSampleGroupProperties(c,_,_.number_in_traf,u.sample_groups_info)}}if(u.subs){c.has_fragment_subsamples=!0;var E=u.first_sample_index;for(t=0;t-1))return null;var s=(i=this.stream.buffers[n]).byteLength-(r.offset+r.alreadyRead-i.fileStart);if(r.size-r.alreadyRead<=s)return a.debug("ISOFile","Getting sample #"+t+" data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-i.fileStart)+" read size: "+(r.size-r.alreadyRead)+" full size: "+r.size+")"),o.memcpy(r.data.buffer,r.alreadyRead,i,r.offset+r.alreadyRead-i.fileStart,r.size-r.alreadyRead),i.usedBytes+=r.size-r.alreadyRead,this.stream.logBufferLevel(),r.alreadyRead=r.size,r;if(0===s)return null;a.debug("ISOFile","Getting sample #"+t+" partial data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-i.fileStart)+" read size: "+s+" full size: "+r.size+")"),o.memcpy(r.data.buffer,r.alreadyRead,i,r.offset+r.alreadyRead-i.fileStart,s),r.alreadyRead+=s,i.usedBytes+=s,this.stream.logBufferLevel()}},p.prototype.releaseSample=function(e,t){var i=e.samples[t];return i.data?(this.samplesDataSize-=i.size,i.data=null,i.alreadyRead=0,i.size):0},p.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize},p.prototype.getCodecs=function(){var e,t="";for(e=0;e0&&(t+=","),t+=this.moov.traks[e].mdia.minf.stbl.stsd.entries[0].getCodec()}return t},p.prototype.getTrexById=function(e){var t;if(!this.moov||!this.moov.mvex)return null;for(t=0;t0&&(i.protection=n.ipro.protections[n.iinf.item_infos[e].protection_index-1]),n.iinf.item_infos[e].item_type?i.type=n.iinf.item_infos[e].item_type:i.type="mime",i.content_type=n.iinf.item_infos[e].content_type,i.content_encoding=n.iinf.item_infos[e].content_encoding;if(n.iloc)for(e=0;e0){var c=n.iprp.ipco.boxes[h.property_index-1];i.properties[c.type]=c,i.properties.boxes.push(c)}}}}}},p.prototype.getItem=function(e){var t,i;if(!this.meta)return null;if(!(i=this.items[e]).data&&i.size)i.data=new Uint8Array(i.size),i.alreadyRead=0,this.itemsDataSize+=i.size,a.debug("ISOFile","Allocating item #"+e+" of size "+i.size+" (total: "+this.itemsDataSize+")");else if(i.alreadyRead===i.size)return i;for(var r=0;r-1))return null;var l=(t=this.stream.buffers[s]).byteLength-(n.offset+n.alreadyRead-t.fileStart);if(!(n.length-n.alreadyRead<=l))return a.debug("ISOFile","Getting item #"+e+" extent #"+r+" partial data (alreadyRead: "+n.alreadyRead+" offset: "+(n.offset+n.alreadyRead-t.fileStart)+" read size: "+l+" full extent size: "+n.length+" full item size: "+i.size+")"),o.memcpy(i.data.buffer,i.alreadyRead,t,n.offset+n.alreadyRead-t.fileStart,l),n.alreadyRead+=l,i.alreadyRead+=l,t.usedBytes+=l,this.stream.logBufferLevel(),null;a.debug("ISOFile","Getting item #"+e+" extent #"+r+" data (alreadyRead: "+n.alreadyRead+" offset: "+(n.offset+n.alreadyRead-t.fileStart)+" read size: "+(n.length-n.alreadyRead)+" full extent size: "+n.length+" full item size: "+i.size+")"),o.memcpy(i.data.buffer,i.alreadyRead,t,n.offset+n.alreadyRead-t.fileStart,n.length-n.alreadyRead),t.usedBytes+=n.length-n.alreadyRead,this.stream.logBufferLevel(),i.alreadyRead+=n.length-n.alreadyRead,n.alreadyRead=n.length}}return i.alreadyRead===i.size?i:null},p.prototype.releaseItem=function(e){var t=this.items[e];if(t.data){this.itemsDataSize-=t.size,t.data=null,t.alreadyRead=0;for(var i=0;i0?this.moov.traks[e].samples[0].duration:0),t.push(r)}return t},h.Box.prototype.printHeader=function(e){this.size+=8,this.size>l&&(this.size+=8),"uuid"===this.type&&(this.size+=16),e.log(e.indent+"size:"+this.size),e.log(e.indent+"type:"+this.type)},h.FullBox.prototype.printHeader=function(e){this.size+=4,h.Box.prototype.printHeader.call(this,e),e.log(e.indent+"version:"+this.version),e.log(e.indent+"flags:"+this.flags)},h.Box.prototype.print=function(e){this.printHeader(e)},h.ContainerBox.prototype.print=function(e){this.printHeader(e);for(var t=0;t>8)),e.log(e.indent+"matrix: "+this.matrix.join(", ")),e.log(e.indent+"next_track_id: "+this.next_track_id)},h.tkhdBox.prototype.print=function(e){h.FullBox.prototype.printHeader.call(this,e),e.log(e.indent+"creation_time: "+this.creation_time),e.log(e.indent+"modification_time: "+this.modification_time),e.log(e.indent+"track_id: "+this.track_id),e.log(e.indent+"duration: "+this.duration),e.log(e.indent+"volume: "+(this.volume>>8)),e.log(e.indent+"matrix: "+this.matrix.join(", ")),e.log(e.indent+"layer: "+this.layer),e.log(e.indent+"alternate_group: "+this.alternate_group),e.log(e.indent+"width: "+this.width),e.log(e.indent+"height: "+this.height)};var m={createFile:function(e,t){var i=void 0===e||e,r=new p(t);return r.discardMdatData=!i,r}};void 0!==i&&(i.createFile=m.createFile)},{}],145:[function(e,t,i){t.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}},{}],146:[function(e,t,i){"use strict";var r=e("asn1.js");i.certificate=e("./certificate");var n=r.define("RSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())}));i.RSAPrivateKey=n;var a=r.define("RSAPublicKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}));i.RSAPublicKey=a;var s=r.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(o),this.key("subjectPublicKey").bitstr())}));i.PublicKey=s;var o=r.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())})),l=r.define("PrivateKeyInfo",(function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(o),this.key("subjectPrivateKey").octstr())}));i.PrivateKey=l;var f=r.define("EncryptedPrivateKeyInfo",(function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())}));i.EncryptedPrivateKey=f;var u=r.define("DSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())}));i.DSAPrivateKey=u,i.DSAparam=r.define("DSAparam",(function(){this.int()}));var h=r.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(c),this.key("publicKey").optional().explicit(1).bitstr())}));i.ECPrivateKey=h;var c=r.define("ECParameters",(function(){this.choice({namedCurve:this.objid()})}));i.signature=r.define("signature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())}))},{"./certificate":147,"asn1.js":2}],147:[function(e,t,i){"use strict";var r=e("asn1.js"),n=r.define("Time",(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),a=r.define("AttributeTypeValue",(function(){this.seq().obj(this.key("type").objid(),this.key("value").any())})),s=r.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())})),o=r.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(s),this.key("subjectPublicKey").bitstr())})),l=r.define("RelativeDistinguishedName",(function(){this.setof(a)})),f=r.define("RDNSequence",(function(){this.seqof(l)})),u=r.define("Name",(function(){this.choice({rdnSequence:this.use(f)})})),h=r.define("Validity",(function(){this.seq().obj(this.key("notBefore").use(n),this.key("notAfter").use(n))})),c=r.define("Extension",(function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())})),d=r.define("TBSCertificate",(function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(s),this.key("issuer").use(u),this.key("validity").use(h),this.key("subject").use(u),this.key("subjectPublicKeyInfo").use(o),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(c).optional())})),_=r.define("X509Certificate",(function(){this.seq().obj(this.key("tbsCertificate").use(d),this.key("signatureAlgorithm").use(s),this.key("signatureValue").bitstr())}));t.exports=_},{"asn1.js":2}],148:[function(e,t,i){var r=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,a=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,s=e("evp_bytestokey"),o=e("browserify-aes"),l=e("safe-buffer").Buffer;t.exports=function(e,t){var i,f=e.toString(),u=f.match(r);if(u){var h="aes"+u[1],c=l.from(u[2],"hex"),d=l.from(u[3].replace(/[\r\n]/g,""),"base64"),_=s(t,c.slice(0,8),parseInt(u[1],10)).key,p=[],m=o.createDecipheriv(h,_,c);p.push(m.update(d)),p.push(m.final()),i=l.concat(p)}else{var b=f.match(a);i=l.from(b[2].replace(/[\r\n]/g,""),"base64")}return{tag:f.match(n)[1],data:i}}},{"browserify-aes":23,evp_bytestokey:105,"safe-buffer":184}],149:[function(e,t,i){var r=e("./asn1"),n=e("./aesid.json"),a=e("./fixProc"),s=e("browserify-aes"),o=e("pbkdf2"),l=e("safe-buffer").Buffer;function f(e){var t;"object"!=typeof e||l.isBuffer(e)||(t=e.passphrase,e=e.key),"string"==typeof e&&(e=l.from(e));var i,f,u=a(e,t),h=u.tag,c=u.data;switch(h){case"CERTIFICATE":f=r.certificate.decode(c,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(f||(f=r.PublicKey.decode(c,"der")),i=f.algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return r.RSAPublicKey.decode(f.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return f.subjectPrivateKey=f.subjectPublicKey,{type:"ec",data:f};case"1.2.840.10040.4.1":return f.algorithm.params.pub_key=r.DSAparam.decode(f.subjectPublicKey.data,"der"),{type:"dsa",data:f.algorithm.params};default:throw new Error("unknown key id "+i)}case"ENCRYPTED PRIVATE KEY":c=function(e,t){var i=e.algorithm.decrypt.kde.kdeparams.salt,r=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),a=n[e.algorithm.decrypt.cipher.algo.join(".")],f=e.algorithm.decrypt.cipher.iv,u=e.subjectPrivateKey,h=parseInt(a.split("-")[1],10)/8,c=o.pbkdf2Sync(t,i,r,h,"sha1"),d=s.createDecipheriv(a,c,f),_=[];return _.push(d.update(u)),_.push(d.final()),l.concat(_)}(c=r.EncryptedPrivateKey.decode(c,"der"),t);case"PRIVATE KEY":switch(i=(f=r.PrivateKey.decode(c,"der")).algorithm.algorithm.join(".")){case"1.2.840.113549.1.1.1":return r.RSAPrivateKey.decode(f.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:f.algorithm.curve,privateKey:r.ECPrivateKey.decode(f.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return f.algorithm.params.priv_key=r.DSAparam.decode(f.subjectPrivateKey,"der"),{type:"dsa",params:f.algorithm.params};default:throw new Error("unknown key id "+i)}case"RSA PUBLIC KEY":return r.RSAPublicKey.decode(c,"der");case"RSA PRIVATE KEY":return r.RSAPrivateKey.decode(c,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:r.DSAPrivateKey.decode(c,"der")};case"EC PRIVATE KEY":return{curve:(c=r.ECPrivateKey.decode(c,"der")).parameters.value,privateKey:c.privateKey};default:throw new Error("unknown key type "+h)}}t.exports=f,f.signature=r.signature},{"./aesid.json":145,"./asn1":146,"./fixProc":148,"browserify-aes":23,pbkdf2:151,"safe-buffer":184}],150:[function(e,t,i){(function(e){function t(e,t){for(var i=0,r=e.length-1;r>=0;r--){var n=e[r];"."===n?e.splice(r,1):".."===n?(e.splice(r,1),i++):i&&(e.splice(r,1),i--)}if(t)for(;i--;i)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var i=[],r=0;r=-1&&!n;a--){var s=a>=0?arguments[a]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(i=s+"/"+i,n="/"===s.charAt(0))}return(n?"/":"")+(i=t(r(i.split("/"),(function(e){return!!e})),!n).join("/"))||"."},i.normalize=function(e){var a=i.isAbsolute(e),s="/"===n(e,-1);return(e=t(r(e.split("/"),(function(e){return!!e})),!a).join("/"))||a||(e="."),e&&s&&(e+="/"),(a?"/":"")+e},i.isAbsolute=function(e){return"/"===e.charAt(0)},i.join=function(){var e=Array.prototype.slice.call(arguments,0);return i.normalize(r(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},i.relative=function(e,t){function r(e){for(var t=0;t=0&&""===e[i];i--);return t>i?[]:e.slice(t,i-t+1)}e=i.resolve(e).substr(1),t=i.resolve(t).substr(1);for(var n=r(e.split("/")),a=r(t.split("/")),s=Math.min(n.length,a.length),o=s,l=0;l=1;--a)if(47===(t=e.charCodeAt(a))){if(!n){r=a;break}}else n=!1;return-1===r?i?"/":".":i&&1===r?"/":e.slice(0,r)},i.basename=function(e,t){var i=function(e){"string"!=typeof e&&(e+="");var t,i=0,r=-1,n=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!n){i=t+1;break}}else-1===r&&(n=!1,r=t+1);return-1===r?"":e.slice(i,r)}(e);return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i},i.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,i=0,r=-1,n=!0,a=0,s=e.length-1;s>=0;--s){var o=e.charCodeAt(s);if(47!==o)-1===r&&(n=!1,r=s+1),46===o?-1===t?t=s:1!==a&&(a=1):-1!==t&&(a=-1);else if(!n){i=s+1;break}}return-1===t||-1===r||0===a||1===a&&t===r-1&&t===i+1?"":e.slice(t,r)};var n="b"==="ab".substr(-1)?function(e,t,i){return e.substr(t,i)}:function(e,t,i){return t<0&&(t=e.length+t),e.substr(t,i)}}).call(this,e("_process"))},{_process:158}],151:[function(e,t,i){i.pbkdf2=e("./lib/async"),i.pbkdf2Sync=e("./lib/sync")},{"./lib/async":152,"./lib/sync":155}],152:[function(e,t,i){(function(i,r){var n,a=e("safe-buffer").Buffer,s=e("./precondition"),o=e("./default-encoding"),l=e("./sync"),f=e("./to-buffer"),u=r.crypto&&r.crypto.subtle,h={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},c=[];function d(e,t,i,r,n){return u.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then((function(e){return u.deriveBits({name:"PBKDF2",salt:t,iterations:i,hash:{name:n}},e,r<<3)})).then((function(e){return a.from(e)}))}t.exports=function(e,t,_,p,m,b){"function"==typeof m&&(b=m,m=void 0);var v=h[(m=m||"sha1").toLowerCase()];if(!v||"function"!=typeof r.Promise)return i.nextTick((function(){var i;try{i=l(e,t,_,p,m)}catch(e){return b(e)}b(null,i)}));if(s(_,p),e=f(e,o,"Password"),t=f(t,o,"Salt"),"function"!=typeof b)throw new Error("No callback provided to pbkdf2");!function(e,t){e.then((function(e){i.nextTick((function(){t(null,e)}))}),(function(e){i.nextTick((function(){t(e)}))}))}(function(e){if(r.process&&!r.process.browser)return Promise.resolve(!1);if(!u||!u.importKey||!u.deriveBits)return Promise.resolve(!1);if(void 0!==c[e])return c[e];var t=d(n=n||a.alloc(8),n,10,128,e).then((function(){return!0})).catch((function(){return!1}));return c[e]=t,t}(v).then((function(i){return i?d(e,t,_,p,v):l(e,t,_,p,m)})),b)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-encoding":153,"./precondition":154,"./sync":155,"./to-buffer":156,_process:158,"safe-buffer":184}],153:[function(e,t,i){(function(e){var i;if(e.browser)i="utf-8";else if(e.version){i=parseInt(e.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else i="utf-8";t.exports=i}).call(this,e("_process"))},{_process:158}],154:[function(e,t,i){var r=Math.pow(2,30)-1;t.exports=function(e,t){if("number"!=typeof e)throw new TypeError("Iterations not a number");if(e<0)throw new TypeError("Bad iterations");if("number"!=typeof t)throw new TypeError("Key length not a number");if(t<0||t>r||t!=t)throw new TypeError("Bad key length")}},{}],155:[function(e,t,i){var r=e("create-hash/md5"),n=e("ripemd160"),a=e("sha.js"),s=e("safe-buffer").Buffer,o=e("./precondition"),l=e("./default-encoding"),f=e("./to-buffer"),u=s.alloc(128),h={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function c(e,t,i){var o=function(e){function t(t){return a(e).update(t).digest()}return"rmd160"===e||"ripemd160"===e?function(e){return(new n).update(e).digest()}:"md5"===e?r:t}(e),l="sha512"===e||"sha384"===e?128:64;t.length>l?t=o(t):t.length1)for(var i=1;i_||new s(t).cmp(d.modulus)>=0)throw new Error("decryption error");c=i?f(new s(t),d):o(t,d);var p=u.alloc(_-c.length);if(c=u.concat([p,c],_),4===h)return function(e,t){var i=e.modulus.byteLength(),r=l("sha1").update(u.alloc(0)).digest(),s=r.length;if(0!==t[0])throw new Error("decryption error");var o=t.slice(1,s+1),f=t.slice(s+1),h=a(o,n(f,s)),c=a(f,n(h,i-s-1));if(function(e,t){e=u.from(e),t=u.from(t);var i=0,r=e.length;e.length!==t.length&&(i++,r=Math.min(e.length,t.length));var n=-1;for(;++n=t.length){a++;break}var s=t.slice(2,n-1);("0002"!==r.toString("hex")&&!i||"0001"!==r.toString("hex")&&i)&&a++;s.length<8&&a++;if(a)throw new Error("decryption error");return t.slice(n)}(0,c,i);if(3===h)return c;throw new Error("unknown padding")}},{"./mgf":160,"./withPublic":164,"./xor":165,"bn.js":161,"browserify-rsa":41,"create-hash":71,"parse-asn1":149,"safe-buffer":184}],163:[function(e,t,i){var r=e("parse-asn1"),n=e("randombytes"),a=e("create-hash"),s=e("./mgf"),o=e("./xor"),l=e("bn.js"),f=e("./withPublic"),u=e("browserify-rsa"),h=e("safe-buffer").Buffer;t.exports=function(e,t,i){var c;c=e.padding?e.padding:i?1:4;var d,_=r(e);if(4===c)d=function(e,t){var i=e.modulus.byteLength(),r=t.length,f=a("sha1").update(h.alloc(0)).digest(),u=f.length,c=2*u;if(r>i-c-2)throw new Error("message too long");var d=h.alloc(i-r-c-2),_=i-u-1,p=n(u),m=o(h.concat([f,d,h.alloc(1,1),t],_),s(p,_)),b=o(p,s(m,u));return new l(h.concat([h.alloc(1),b,m],i))}(_,t);else if(1===c)d=function(e,t,i){var r,a=t.length,s=e.modulus.byteLength();if(a>s-11)throw new Error("message too long");r=i?h.alloc(s-a-3,255):function(e){var t,i=h.allocUnsafe(e),r=0,a=n(2*e),s=0;for(;r=0)throw new Error("data too long for modulus")}return i?u(d,_):f(d,_)}},{"./mgf":160,"./withPublic":164,"./xor":165,"bn.js":161,"browserify-rsa":41,"create-hash":71,"parse-asn1":149,randombytes:166,"safe-buffer":184}],164:[function(e,t,i){var r=e("bn.js"),n=e("safe-buffer").Buffer;t.exports=function(e,t){return n.from(e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed().toArray())}},{"bn.js":161,"safe-buffer":184}],165:[function(e,t,i){t.exports=function(e,t){for(var i=e.length,r=-1;++r4294967295)throw new RangeError("requested too many random bytes");var r=n.allocUnsafe(e);if(e>0)if(e>65536)for(var s=0;su||e<0)throw new TypeError("offset must be a uint32");if(e>l||e>t)throw new RangeError("offset out of range")}function c(e,t,i){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>u||e<0)throw new TypeError("size must be a uint32");if(e+t>i||e>l)throw new RangeError("buffer too small")}function d(e,i,r,n){if(t.browser){var a=e.buffer,o=new Uint8Array(a,i,r);return f.getRandomValues(o),n?void t.nextTick((function(){n(null,e)})):e}if(!n)return s(r).copy(e,i),e;s(r,(function(t,r){if(t)return n(t);r.copy(e,i),n(null,e)}))}f&&f.getRandomValues||!t.browser?(i.randomFill=function(e,t,i,n){if(!(o.isBuffer(e)||e instanceof r.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)n=t,t=0,i=e.length;else if("function"==typeof i)n=i,i=e.length-t;else if("function"!=typeof n)throw new TypeError('"cb" argument must be a function');return h(t,e.length),c(i,t,e.length),d(e,t,i,n)},i.randomFillSync=function(e,t,i){void 0===t&&(t=0);if(!(o.isBuffer(e)||e instanceof r.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');h(t,e.length),void 0===i&&(i=e.length-t);return c(i,t,e.length),d(e,t,i)}):(i.randomFill=n,i.randomFillSync=n)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:158,randombytes:166,"safe-buffer":184}],168:[function(e,t,i){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":169}],169:[function(e,t,i){"use strict";var r=e("process-nextick-args"),n=Object.keys||function(e){var t=[];for(var i in e)t.push(i);return t};t.exports=h;var a=Object.create(e("core-util-is"));a.inherits=e("inherits");var s=e("./_stream_readable"),o=e("./_stream_writable");a.inherits(h,s);for(var l=n(o.prototype),f=0;f0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===f.prototype||(t=function(e){return f.from(e)}(t)),r?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!i?(t=s.decoder.write(t),s.objectMode||0!==t.length?w(e,s,t,!1):j(e,s)):w(e,s,t,!1))):r||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function C(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(d("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?n.nextTick(S,e):S(e))}function S(e){d("emit readable"),e.emit("readable"),M(e)}function j(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(T,e,t))}function T(e,t){for(var i=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(i=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):i=function(e,t,i){var r;ea.length?a.length:e;if(s===a.length?n+=a:n+=a.slice(0,e),0===(e-=s)){s===a.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=a.slice(s));break}++r}return t.length-=r,n}(e,t):function(e,t){var i=f.allocUnsafe(e),r=t.head,n=1;r.data.copy(i),e-=r.data.length;for(;r=r.next;){var a=r.data,s=e>a.length?a.length:e;if(a.copy(i,i.length-e,0,s),0===(e-=s)){s===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(s));break}++n}return t.length-=n,i}(e,t);return r}(e,t.buffer,t.decoder),i);var i}function P(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,n.nextTick(I,t,e))}function I(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function U(e,t){for(var i=0,r=e.length;i=t.highWaterMark||t.ended))return d("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?P(this):C(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&P(this),null;var r,n=t.needReadable;return d("need readable",n),(0===t.length||t.length-e0?k(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),i!==e&&t.ended&&P(this)),null!==r&&this.emit("data",r),r},y.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(e,t){var r=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=e;break;case 1:a.pipes=[a.pipes,e];break;default:a.pipes.push(e)}a.pipesCount+=1,d("pipe count=%d opts=%j",a.pipesCount,t);var l=(!t||!1!==t.end)&&e!==i.stdout&&e!==i.stderr?u:y;function f(t,i){d("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,d("cleanup"),e.removeListener("close",b),e.removeListener("finish",v),e.removeListener("drain",h),e.removeListener("error",m),e.removeListener("unpipe",f),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",p),c=!0,!a.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function u(){d("onend"),e.end()}a.endEmitted?n.nextTick(l):r.once("end",l),e.on("unpipe",f);var h=function(e){return function(){var t=e._readableState;d("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,M(e))}}(r);e.on("drain",h);var c=!1;var _=!1;function p(t){d("ondata"),_=!1,!1!==e.write(t)||_||((1===a.pipesCount&&a.pipes===e||a.pipesCount>1&&-1!==U(a.pipes,e))&&!c&&(d("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,_=!0),r.pause())}function m(t){d("onerror",t),y(),e.removeListener("error",m),0===o(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",v),y()}function v(){d("onfinish"),e.removeListener("close",b),y()}function y(){d("unpipe"),r.unpipe(e)}return r.on("data",p),function(e,t,i){if("function"==typeof e.prependListener)return e.prependListener(t,i);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(i):e._events[t]=[i,e._events[t]]:e.on(t,i)}(e,"error",m),e.once("close",b),e.once("finish",v),e.emit("pipe",r),a.flowing||(d("pipe resume"),r.resume()),e},y.prototype.unpipe=function(e){var t=this._readableState,i={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,i)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a-1?n:a.nextTick;v.WritableState=b;var f=Object.create(e("core-util-is"));f.inherits=e("inherits");var u={deprecate:e("util-deprecate")},h=e("./internal/streams/stream"),c=e("safe-buffer").Buffer,d=r.Uint8Array||function(){};var _,p=e("./internal/streams/destroy");function m(){}function b(t,i){o=o||e("./_stream_duplex"),t=t||{};var r=i instanceof o;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,f=t.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r&&(f||0===f)?f:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var i=e._writableState,r=i.sync,n=i.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(i),t)!function(e,t,i,r,n){--t.pendingcb,i?(a.nextTick(n,r),a.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(n(r),e._writableState.errorEmitted=!0,e.emit("error",r),S(e,t))}(e,i,r,t,n);else{var s=E(i);s||i.corked||i.bufferProcessing||!i.bufferedRequest||w(e,i),r?l(g,e,i,s,n):g(e,i,s,n)}}(i,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function v(t){if(o=o||e("./_stream_duplex"),!(_.call(v,this)||this instanceof o))return new v(t);this._writableState=new b(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),h.call(this)}function y(e,t,i,r,n,a,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,i?e._writev(n,t.onwrite):e._write(n,a,t.onwrite),t.sync=!1}function g(e,t,i,r){i||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),S(e,t)}function w(e,t){t.bufferProcessing=!0;var i=t.bufferedRequest;if(e._writev&&i&&i.next){var r=t.bufferedRequestCount,n=new Array(r),a=t.corkedRequestsFree;a.entry=i;for(var o=0,l=!0;i;)n[o]=i,i.isBuf||(l=!1),i=i.next,o+=1;n.allBuffers=l,y(e,t,!0,t.length,n,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;i;){var f=i.chunk,u=i.encoding,h=i.callback;if(y(e,t,!1,t.objectMode?1:f.length,f,u,h),i=i.next,t.bufferedRequestCount--,t.writing)break}null===i&&(t.lastBufferedRequest=null)}t.bufferedRequest=i,t.bufferProcessing=!1}function E(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function C(e,t){e._final((function(i){t.pendingcb--,i&&e.emit("error",i),t.prefinished=!0,e.emit("prefinish"),S(e,t)}))}function S(e,t){var i=E(t);return i&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,a.nextTick(C,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),i}f.inherits(v,h),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:u.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(_=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(e){return!!_.call(this,e)||this===v&&(e&&e._writableState instanceof b)}})):_=function(e){return e instanceof this},v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},v.prototype.write=function(e,t,i){var r,n=this._writableState,s=!1,o=!n.objectMode&&(r=e,c.isBuffer(r)||r instanceof d);return o&&!c.isBuffer(e)&&(e=function(e){return c.from(e)}(e)),"function"==typeof t&&(i=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),"function"!=typeof i&&(i=m),n.ended?function(e,t){var i=new Error("write after end");e.emit("error",i),a.nextTick(t,i)}(this,i):(o||function(e,t,i,r){var n=!0,s=!1;return null===i?s=new TypeError("May not write null values to stream"):"string"==typeof i||void 0===i||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),a.nextTick(r,s),n=!1),n}(this,n,e,i))&&(n.pendingcb++,s=function(e,t,i,r,n,a){if(!i){var s=function(e,t,i){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,i));return t}(t,r,n);r!==s&&(i=!0,n="buffer",r=s)}var o=t.objectMode?1:r.length;t.length+=o;var l=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),v.prototype._write=function(e,t,i){i(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(e,t,i){var r=this._writableState;"function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(e,t,i){t.ending=!0,S(e,t),i&&(t.finished?a.nextTick(i):e.once("finish",i));t.ended=!0,e.writable=!1}(this,r,i)},Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),v.prototype.destroy=p.destroy,v.prototype._undestroy=p.undestroy,v.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":169,"./internal/streams/destroy":175,"./internal/streams/stream":176,_process:158,"core-util-is":68,inherits:136,"process-nextick-args":157,"safe-buffer":177,timers:196,"util-deprecate":197}],174:[function(e,t,i){"use strict";var r=e("safe-buffer").Buffer,n=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,i=""+t.data;t=t.next;)i+=e+t.data;return i},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,i,n,a=r.allocUnsafe(e>>>0),s=this.head,o=0;s;)t=s.data,i=a,n=o,t.copy(i,n),o+=s.data.length,s=s.next;return a},e}(),n&&n.inspect&&n.inspect.custom&&(t.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":177,util:20}],175:[function(e,t,i){"use strict";var r=e("process-nextick-args");function n(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var i=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||r.nextTick(n,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?(r.nextTick(n,i,e),i._writableState&&(i._writableState.errorEmitted=!0)):t&&t(e)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":157}],176:[function(e,t,i){arguments[4][62][0].apply(i,arguments)},{dup:62,events:104}],177:[function(e,t,i){var r=e("buffer"),n=r.Buffer;function a(e,t){for(var i in e)t[i]=e[i]}function s(e,t,i){return n(e,t,i)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(a(r,i),i.Buffer=s),a(n,s),s.from=function(e,t,i){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,i)},s.alloc=function(e,t,i){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof i?r.fill(t,i):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:66}],178:[function(e,t,i){"use strict";var r=e("safe-buffer").Buffer,n=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function a(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=f,t=4;break;case"utf8":this.fillLast=o,t=4;break;case"base64":this.text=u,this.end=h,t=3;break;default:return this.write=c,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function o(e){var t=this.lastTotal-this.lastNeed,i=function(e,t,i){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==i?i:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var i=e.toString("utf16le",t);if(i){var r=i.charCodeAt(i.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function f(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,i)}return t}function u(e,t){var i=(e.length-t)%3;return 0===i?e.toString("base64",t):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-i))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function c(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}i.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,i;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i=0)return n>0&&(e.lastNeed=n-1),n;if(--r=0)return n>0&&(e.lastNeed=n-2),n;if(--r=0)return n>0&&(2===n?n=0:e.lastNeed=n-3),n;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=i;var r=e.length-(i-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":177}],179:[function(e,t,i){t.exports=e("./readable").PassThrough},{"./readable":180}],180:[function(e,t,i){(i=t.exports=e("./lib/_stream_readable.js")).Stream=i,i.Readable=i,i.Writable=e("./lib/_stream_writable.js"),i.Duplex=e("./lib/_stream_duplex.js"),i.Transform=e("./lib/_stream_transform.js"),i.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":169,"./lib/_stream_passthrough.js":170,"./lib/_stream_readable.js":171,"./lib/_stream_transform.js":172,"./lib/_stream_writable.js":173}],181:[function(e,t,i){t.exports=e("./readable").Transform},{"./readable":180}],182:[function(e,t,i){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":173}],183:[function(e,t,i){"use strict";var r=e("buffer").Buffer,n=e("inherits"),a=e("hash-base"),s=new Array(16),o=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],l=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],f=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],u=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],c=[1352829926,1548603684,1836072691,2053994217,0];function d(){a.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function _(e,t){return e<>>32-t}function p(e,t,i,r,n,a,s,o){return _(e+(t^i^r)+a+s|0,o)+n|0}function m(e,t,i,r,n,a,s,o){return _(e+(t&i|~t&r)+a+s|0,o)+n|0}function b(e,t,i,r,n,a,s,o){return _(e+((t|~i)^r)+a+s|0,o)+n|0}function v(e,t,i,r,n,a,s,o){return _(e+(t&r|i&~r)+a+s|0,o)+n|0}function y(e,t,i,r,n,a,s,o){return _(e+(t^(i|~r))+a+s|0,o)+n|0}n(d,a),d.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var i=0|this._a,r=0|this._b,n=0|this._c,a=0|this._d,d=0|this._e,g=0|this._a,w=0|this._b,E=0|this._c,C=0|this._d,S=0|this._e,j=0;j<80;j+=1){var T,A;j<16?(T=p(i,r,n,a,d,e[o[j]],h[0],f[j]),A=y(g,w,E,C,S,e[l[j]],c[0],u[j])):j<32?(T=m(i,r,n,a,d,e[o[j]],h[1],f[j]),A=v(g,w,E,C,S,e[l[j]],c[1],u[j])):j<48?(T=b(i,r,n,a,d,e[o[j]],h[2],f[j]),A=b(g,w,E,C,S,e[l[j]],c[2],u[j])):j<64?(T=v(i,r,n,a,d,e[o[j]],h[3],f[j]),A=m(g,w,E,C,S,e[l[j]],c[3],u[j])):(T=y(i,r,n,a,d,e[o[j]],h[4],f[j]),A=p(g,w,E,C,S,e[l[j]],c[4],u[j])),i=d,d=a,a=_(n,10),n=r,r=T,g=S,S=C,C=_(E,10),E=w,w=A}var x=this._b+n+C|0;this._b=this._c+a+S|0,this._c=this._d+d+g|0,this._d=this._e+i+w|0,this._e=this._a+r+E|0,this._a=x},d.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=r.alloc?r.alloc(20):new r(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=d},{buffer:66,"hash-base":106,inherits:136}],184:[function(e,t,i){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ -var r=e("buffer"),n=r.Buffer;function a(e,t){for(var i in e)t[i]=e[i]}function s(e,t,i){return n(e,t,i)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(a(r,i),i.Buffer=s),s.prototype=Object.create(n.prototype),a(n,s),s.from=function(e,t,i){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,i)},s.alloc=function(e,t,i){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=n(e);return void 0!==t?"string"==typeof i?r.fill(t,i):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:66}],185:[function(e,t,i){(function(i){"use strict";var r,n=e("buffer"),a=n.Buffer,s={};for(r in n)n.hasOwnProperty(r)&&"SlowBuffer"!==r&&"Buffer"!==r&&(s[r]=n[r]);var o=s.Buffer={};for(r in a)a.hasOwnProperty(r)&&"allocUnsafe"!==r&&"allocUnsafeSlow"!==r&&(o[r]=a[r]);if(s.Buffer.prototype=a.prototype,o.from&&o.from!==Uint8Array.from||(o.from=function(e,t,i){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return a(e,t,i)}),o.alloc||(o.alloc=function(e,t,i){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var r=a(e);return t&&0!==t.length?"string"==typeof i?r.fill(t,i):r.fill(t):r.fill(0),r}),!s.kStringMaxLength)try{s.kStringMaxLength=i.binding("buffer").kStringMaxLength}catch(e){}s.constants||(s.constants={MAX_LENGTH:s.kMaxLength},s.kStringMaxLength&&(s.constants.MAX_STRING_LENGTH=s.kStringMaxLength)),t.exports=s}).call(this,e("_process"))},{_process:158,buffer:66}],186:[function(e,t,i){var r=e("safe-buffer").Buffer;function n(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}n.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var i=this._block,n=this._blockSize,a=e.length,s=this._len,o=0;o=this._finalSize&&(this._update(this._block),this._block.fill(0));var i=8*this._len;if(i<=4294967295)this._block.writeUInt32BE(i,this._blockSize-4);else{var r=(4294967295&i)>>>0,n=(i-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var a=this._hash();return e?a.toString(e):a},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=n},{"safe-buffer":184}],187:[function(e,t,i){(i=t.exports=function(e){e=e.toLowerCase();var t=i[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),i.sha1=e("./sha1"),i.sha224=e("./sha224"),i.sha256=e("./sha256"),i.sha384=e("./sha384"),i.sha512=e("./sha512")},{"./sha":188,"./sha1":189,"./sha224":190,"./sha256":191,"./sha384":192,"./sha512":193}],188:[function(e,t,i){var r=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1518500249,1859775393,-1894007588,-899497514],o=new Array(80);function l(){this.init(),this._w=o,n.call(this,64,56)}function f(e){return e<<30|e>>>2}function u(e,t,i,r){return 0===e?t&i|~t&r:2===e?t&i|t&r|i&r:t^i^r}r(l,n),l.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},l.prototype._update=function(e){for(var t,i=this._w,r=0|this._a,n=0|this._b,a=0|this._c,o=0|this._d,l=0|this._e,h=0;h<16;++h)i[h]=e.readInt32BE(4*h);for(;h<80;++h)i[h]=i[h-3]^i[h-8]^i[h-14]^i[h-16];for(var c=0;c<80;++c){var d=~~(c/20),_=0|((t=r)<<5|t>>>27)+u(d,n,a,o)+l+i[c]+s[d];l=o,o=a,a=f(n),n=r,r=_}this._a=r+this._a|0,this._b=n+this._b|0,this._c=a+this._c|0,this._d=o+this._d|0,this._e=l+this._e|0},l.prototype._hash=function(){var e=a.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=l},{"./hash":186,inherits:136,"safe-buffer":184}],189:[function(e,t,i){var r=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1518500249,1859775393,-1894007588,-899497514],o=new Array(80);function l(){this.init(),this._w=o,n.call(this,64,56)}function f(e){return e<<5|e>>>27}function u(e){return e<<30|e>>>2}function h(e,t,i,r){return 0===e?t&i|~t&r:2===e?t&i|t&r|i&r:t^i^r}r(l,n),l.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},l.prototype._update=function(e){for(var t,i=this._w,r=0|this._a,n=0|this._b,a=0|this._c,o=0|this._d,l=0|this._e,c=0;c<16;++c)i[c]=e.readInt32BE(4*c);for(;c<80;++c)i[c]=(t=i[c-3]^i[c-8]^i[c-14]^i[c-16])<<1|t>>>31;for(var d=0;d<80;++d){var _=~~(d/20),p=f(r)+h(_,n,a,o)+l+i[d]+s[_]|0;l=o,o=a,a=u(n),n=r,r=p}this._a=r+this._a|0,this._b=n+this._b|0,this._c=a+this._c|0,this._d=o+this._d|0,this._e=l+this._e|0},l.prototype._hash=function(){var e=a.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=l},{"./hash":186,inherits:136,"safe-buffer":184}],190:[function(e,t,i){var r=e("inherits"),n=e("./sha256"),a=e("./hash"),s=e("safe-buffer").Buffer,o=new Array(64);function l(){this.init(),this._w=o,a.call(this,64,56)}r(l,n),l.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},l.prototype._hash=function(){var e=s.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=l},{"./hash":186,"./sha256":191,inherits:136,"safe-buffer":184}],191:[function(e,t,i){var r=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],o=new Array(64);function l(){this.init(),this._w=o,n.call(this,64,56)}function f(e,t,i){return i^e&(t^i)}function u(e,t,i){return e&t|i&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function c(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}r(l,n),l.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},l.prototype._update=function(e){for(var t,i=this._w,r=0|this._a,n=0|this._b,a=0|this._c,o=0|this._d,l=0|this._e,_=0|this._f,p=0|this._g,m=0|this._h,b=0;b<16;++b)i[b]=e.readInt32BE(4*b);for(;b<64;++b)i[b]=0|(((t=i[b-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+i[b-7]+d(i[b-15])+i[b-16];for(var v=0;v<64;++v){var y=m+c(l)+f(l,_,p)+s[v]+i[v]|0,g=h(r)+u(r,n,a)|0;m=p,p=_,_=l,l=o+y|0,o=a,a=n,n=r,r=y+g|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=a+this._c|0,this._d=o+this._d|0,this._e=l+this._e|0,this._f=_+this._f|0,this._g=p+this._g|0,this._h=m+this._h|0},l.prototype._hash=function(){var e=a.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=l},{"./hash":186,inherits:136,"safe-buffer":184}],192:[function(e,t,i){var r=e("inherits"),n=e("./sha512"),a=e("./hash"),s=e("safe-buffer").Buffer,o=new Array(160);function l(){this.init(),this._w=o,a.call(this,128,112)}r(l,n),l.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},l.prototype._hash=function(){var e=s.allocUnsafe(48);function t(t,i,r){e.writeInt32BE(t,r),e.writeInt32BE(i,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=l},{"./hash":186,"./sha512":193,inherits:136,"safe-buffer":184}],193:[function(e,t,i){var r=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],o=new Array(160);function l(){this.init(),this._w=o,n.call(this,128,112)}function f(e,t,i){return i^e&(t^i)}function u(e,t,i){return e&t|i&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function c(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function _(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function p(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function m(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function b(e,t){return e>>>0>>0?1:0}r(l,n),l.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},l.prototype._update=function(e){for(var t=this._w,i=0|this._ah,r=0|this._bh,n=0|this._ch,a=0|this._dh,o=0|this._eh,l=0|this._fh,v=0|this._gh,y=0|this._hh,g=0|this._al,w=0|this._bl,E=0|this._cl,C=0|this._dl,S=0|this._el,j=0|this._fl,T=0|this._gl,A=0|this._hl,x=0;x<32;x+=2)t[x]=e.readInt32BE(4*x),t[x+1]=e.readInt32BE(4*x+4);for(;x<160;x+=2){var M=t[x-30],k=t[x-30+1],P=d(M,k),I=_(k,M),U=p(M=t[x-4],k=t[x-4+1]),R=m(k,M),D=t[x-14],O=t[x-14+1],F=t[x-32],B=t[x-32+1],L=I+O|0,N=P+D+b(L,I)|0;N=(N=N+U+b(L=L+R|0,R)|0)+F+b(L=L+B|0,B)|0,t[x]=N,t[x+1]=L}for(var z=0;z<160;z+=2){N=t[z],L=t[z+1];var H=u(i,r,n),V=u(g,w,E),Y=h(i,g),q=h(g,i),X=c(o,S),W=c(S,o),G=s[z],K=s[z+1],Q=f(o,l,v),Z=f(S,j,T),J=A+W|0,$=y+X+b(J,A)|0;$=($=($=$+Q+b(J=J+Z|0,Z)|0)+G+b(J=J+K|0,K)|0)+N+b(J=J+L|0,L)|0;var ee=q+V|0,te=Y+H+b(ee,q)|0;y=v,A=T,v=l,T=j,l=o,j=S,o=a+$+b(S=C+J|0,C)|0,a=n,C=E,n=r,E=w,r=i,w=g,i=$+te+b(g=J+ee|0,J)|0}this._al=this._al+g|0,this._bl=this._bl+w|0,this._cl=this._cl+E|0,this._dl=this._dl+C|0,this._el=this._el+S|0,this._fl=this._fl+j|0,this._gl=this._gl+T|0,this._hl=this._hl+A|0,this._ah=this._ah+i+b(this._al,g)|0,this._bh=this._bh+r+b(this._bl,w)|0,this._ch=this._ch+n+b(this._cl,E)|0,this._dh=this._dh+a+b(this._dl,C)|0,this._eh=this._eh+o+b(this._el,S)|0,this._fh=this._fh+l+b(this._fl,j)|0,this._gh=this._gh+v+b(this._gl,T)|0,this._hh=this._hh+y+b(this._hl,A)|0},l.prototype._hash=function(){var e=a.allocUnsafe(64);function t(t,i,r){e.writeInt32BE(t,r),e.writeInt32BE(i,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=l},{"./hash":186,inherits:136,"safe-buffer":184}],194:[function(e,t,i){t.exports=n;var r=e("events").EventEmitter;function n(){r.call(this)}e("inherits")(n,r),n.Readable=e("readable-stream/readable.js"),n.Writable=e("readable-stream/writable.js"),n.Duplex=e("readable-stream/duplex.js"),n.Transform=e("readable-stream/transform.js"),n.PassThrough=e("readable-stream/passthrough.js"),n.Stream=n,n.prototype.pipe=function(e,t){var i=this;function n(t){e.writable&&!1===e.write(t)&&i.pause&&i.pause()}function a(){i.readable&&i.resume&&i.resume()}i.on("data",n),e.on("drain",a),e._isStdio||t&&!1===t.end||(i.on("end",o),i.on("close",l));var s=!1;function o(){s||(s=!0,e.end())}function l(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function f(e){if(u(),0===r.listenerCount(this,"error"))throw e}function u(){i.removeListener("data",n),e.removeListener("drain",a),i.removeListener("end",o),i.removeListener("close",l),i.removeListener("error",f),e.removeListener("error",f),i.removeListener("end",u),i.removeListener("close",u),e.removeListener("close",u)}return i.on("error",f),e.on("error",f),i.on("end",u),i.on("close",u),e.on("close",u),e.emit("pipe",i),e}},{events:104,inherits:136,"readable-stream/duplex.js":168,"readable-stream/passthrough.js":179,"readable-stream/readable.js":180,"readable-stream/transform.js":181,"readable-stream/writable.js":182}],195:[function(e,t,i){arguments[4][178][0].apply(i,arguments)},{dup:178,"safe-buffer":184}],196:[function(e,t,i){(function(t,r){var n=e("process/browser.js").nextTick,a=Function.prototype.apply,s=Array.prototype.slice,o={},l=0;function f(e,t){this._id=e,this._clearFn=t}i.setTimeout=function(){return new f(a.call(setTimeout,window,arguments),clearTimeout)},i.setInterval=function(){return new f(a.call(setInterval,window,arguments),clearInterval)},i.clearTimeout=i.clearInterval=function(e){e.close()},f.prototype.unref=f.prototype.ref=function(){},f.prototype.close=function(){this._clearFn.call(window,this._id)},i.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},i.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},i._unrefActive=i.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},i.setImmediate="function"==typeof t?t:function(e){var t=l++,r=!(arguments.length<2)&&s.call(arguments,1);return o[t]=!0,n((function(){o[t]&&(r?e.apply(null,r):e.call(null),i.clearImmediate(t))})),t},i.clearImmediate="function"==typeof r?r:function(e){delete o[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":158,timers:196}],197:[function(e,t,i){(function(e){function i(t){try{if(!e.localStorage)return!1}catch(e){return!1}var i=e.localStorage[t];return null!=i&&"true"===String(i).toLowerCase()}t.exports=function(e,t){if(i("noDeprecation"))return e;var r=!1;return function(){if(!r){if(i("throwDeprecation"))throw new Error(t);i("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],198:[function(e,t,i){"use strict";t.exports={DEFAILT_WEBGL_PLAY_ID:"glplayer",PLAYER_IN_TYPE_MP4:"mp4",PLAYER_IN_TYPE_RAW_265:"raw265",PLAYER_IN_TYPE_TS:"ts",PLAYER_IN_TYPE_MPEGTS:"mpegts",PLAYER_IN_TYPE_M3U8:"hls",PLAYER_IN_TYPE_M3U8_VOD:"m3u8",PLAYER_IN_TYPE_M3U8_LIVE:"hls",APPEND_TYPE_STREAM:0,APPEND_TYPE_FRAME:1,APPEND_TYPE_SEQUENCE:2,DEFAULT_WIDTH:600,DEFAULT_HEIGHT:600,DEFAULT_FPS:25,DEFAULT_FRAME_DUR:40,DEFAULT_FIXED:!1,DEFAULT_SAMPLERATE:44100,DEFAULT_CHANNELS:2,DEFAULT_CONSU_SAMPLE_LEN:20,PLAYER_MODE_VOD:"vod",PLAYER_MODE_NOTIME_LIVE:"live",AUDIO_MODE_ONCE:"ONCE",AUDIO_MODE_SWAP:"SWAP",DEFAULT_STRING_LIVE:"LIVE",CODEC_H265:0,CODEC_H264:1,PLAYER_CORE_TYPE_DEFAULT:0,PLAYER_CORE_TYPE_CNATIVE:1,V_CODEC_NAME_HEVC:265,V_CODEC_NAME_AVC:264,V_CODEC_NAME_UNKN:500,A_CODEC_NAME_AAC:112,A_CODEC_NAME_MP3:113,A_CODEC_NAME_UNKN:500}},{}],199:[function(e,t,i){"use strict";var r=window.AudioContext||window.webkitAudioContext,n=e("../consts"),a=function(){return(new Date).getTime()};t.exports=function(e){var t={options:{sampleRate:e.sampleRate||n.DEFAULT_SAMPLERATE,appendType:e.appendType||n.APPEND_TYPE_STREAM,playMode:e.playMode||n.AUDIO_MODE_SWAP},sourceChannel:-1,audioCtx:new r({latencyHint:"interactive",sampleRate:e.sampleRate}),gainNode:null,sourceList:[],startStatus:!1,sampleQueue:[],nextBuffer:null,playTimestamp:0,playStartTime:0,durationMs:-1,voice:1,onLoadCache:null,setOnLoadCache:function(e){t.onLoadCache=e},setDurationMs:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;t.durationMs=e},setVoice:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;t.voice=e,t.gainNode.gain.value=e},getAlignVPTS:function(){return t.playTimestamp+(a()-t.playStartTime)/1e3},swapSource:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;if(0==t.startStatus)return null;if(e<0||e>=t.sourceList.length)return null;if(i<0||i>=t.sourceList.length)return null;try{t.sourceChannel===e&&null!==t.sourceList[e]&&(t.sourceList[e].disconnect(t.gainNode),t.sourceList[e]=null)}catch(e){}t.sourceChannel=i;var r=t.decodeSample(i,e);-2==r&&(t.getAlignVPTS()>=t.durationMs/1e3-.04?t.pause():null!==t.onLoadCache&&t.onLoadCache())},addSample:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return!(null==e||!e||null==e)&&(0==t.sampleQueue.length&&(t.seekPos=e.pts),t.sampleQueue.push(e),!0)},runNextBuffer:function(){window.setInterval((function(){if(!(null!=t.nextBuffer||t.sampleQueue.length0&&void 0!==arguments[0]?arguments[0]:-1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;if(e<0||e>=t.sourceList.length)return-1;if(null!=t.sourceList[e]&&null!=t.sourceList[e]&&t.sourceList[e]||(t.sourceList[e]=t.audioCtx.createBufferSource(),t.sourceList[e].onended=function(){t.swapSource(e,i)}),0==t.sampleQueue.length)return-2;if(t.sourceList[e].buffer)return t.sourceList[e],t.sourceList[i],t.gainNode,t.swapSource(e,i),0;if(null==t.nextBuffer||t.nextBuffer.data.length<1)return t.sourceList[e].connect(t.gainNode),t.sourceList[e].start(),t.sourceList[e].startState=!0,t.sourceList[e].stop(),1;var r=t.nextBuffer.data.buffer;t.playTimestamp=t.nextBuffer.pts,t.playStartTime=a();try{t.audioCtx.decodeAudioData(r,(function(i){t.sourceList[e].buffer=i,t.sourceList[e].connect(t.gainNode),t.sourceList[e].start(),t.sourceList[e].startState=!0,t.sourceList[e]}),(function(e){}))}catch(e){return t.nextBuffer=null,-3}return t.nextBuffer=null,0},decodeWholeSamples:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(t.sourceChannel=e,e<0||e>=t.sourceList.length)return-1;if(null!=t.sourceList[e]&&null!=t.sourceList[e]&&t.sourceList[e]||(t.sourceList[e]=t.audioCtx.createBufferSource(),t.sourceList[e].onended=function(){}),0==t.sampleQueue.length)return-2;for(var i=null,r=null,a=0;a=2){var s=i.length/2;a=new Float32Array(s);for(var o=0,l=0;l0&&s()-this._start_time>=this._now_seg_dur&&(s(),this._start_time,this._now_seg_dur,this._start_time=-1,this._now_seg_dur=-1),s(),this._start_time<0)if(new Date,null!==this._pcm_array_buf&&this._pcm_array_buf.length>this._push_start_idx){this._swapStartPlay=!1;var e=this._push_start_idx+this._once_pop_len;e>this._pcm_array_buf.length&&(e=this._pcm_array_buf.length);var t=this._pcm_array_buf.slice(this._push_start_idx,e);this._push_start_idx+=t.length,this._now_seg_dur=1*t.length/this._sample_rate*1e3,t.length,this._sample_rate,this._now_seg_dur;var i=this._ctx.createBuffer(1,t.length,this._sample_rate);t.length,new Date,i.copyToChannel(t,0),this._active_node=this._ctx.createBufferSource(),this._active_node.buffer=i,this._active_node.connect(this._gain),this._start_time=s(),this._active_node.start(0)}else setTimeout(this.readingLoopWithF32,1)}}])&&r(t.prototype,i),o&&r(t,o),e}();i.AudioPcmPlayer=o},{"../consts":198}],201:[function(e,t,i){"use strict";t.exports={frameDataAlignCrop:function(e,t,i,r,n,a,s,o){if(0==e-r)return[a,s,o];for(var l=r*n,f=l/4,u=new Uint8Array(l),h=new Uint8Array(f),c=new Uint8Array(f),d=r,_=r/2,p=0;p0&&void 0!==arguments[0]&&arguments[0];this.showScreen=e,this.canvas&&(e?this.canvas.setAttribute("hidden",!0):this.canvas.removeAttribute("hidden"))}},{key:"getCachePTS",value:function(){return 1!==this.config.ignoreAudio&&this.audioWAudio?Math.min(this.vCachePTS,this.aCachePTS):this.vCachePTS}},{key:"getMaxPTS",value:function(){return Math.max(this.vCachePTS,this.aCachePTS)}},{key:"isPlayingState",value:function(){return this.isPlaying}},{key:"pushDone",value:function(){this.pushEOF=!0}},{key:"_clearDecInterval",value:function(){this.decVFrameInterval&&window.clearInterval(this.decVFrameInterval),this.decVFrameInterval=null}},{key:"_checkPlayFinished",value:function(){return!!(!0===this.bufRecvStat&&(this.playPTS>=this.bufLastVDTS||this.audioWAudio&&this.playPTS>=this.bufLastADTS)||this.duration-this.playPTS0&&(this.isPlaying=!0);var t=0,i=0,r=0;this.playFrameInterval=window.setInterval((function(){if(i=c(),e._videoQueue.length>0&&i-t>=e.frameTime-r){var n=e._videoQueue.shift(),a=0;if(e.isNewSeek||null===e.audioWAudio||void 0===e.audioWAudio||(a=1e3*(n.pts-e.audioWAudio.getAlignVPTS()),e.playPTS=Math.max(e.audioWAudio.getAlignVPTS(),e.playPTS)),t=i,c(),n.pts,e.seekTarget,e.playPTS=Math.max(n.pts,e.playPTS),e.isNewSeek&&e.seekTarget-e.frameDur>n.pts)return void(r=e.frameTime);if(e.isNewSeek&&(e.audioWAudio&&e.audioWAudio.setVoice(e.audioVoice),e.audioWAudio&&e.audioWAudio.play(),r=0,e.isNewSeek=!1,e.seekTarget=0),n.pts,e.showScreen?e.onRender&&e.onRender(n.line1,n.height,n.data_y,n.data_u,n.data_v):l.renderFrame(e.yuv,n.data_y,n.data_u,n.data_v,n.line1,n.height),e.onPlayingTime&&e.onPlayingTime(n.pts),!e.isNewSeek&&e.audioWAudio&&(a<0&&-1*a<=e.frameTime||a>=0)){if(n.pts>=e.duration)e.onLoadCacheFinshed&&e.onLoadCacheFinshed(),e.onPlayingFinish&&e.onPlayingFinish(),e._clearDecInterval(),e.pause();else if(e._checkPlayFinished())return;r=c()-i}else!e.isNewSeek&&e.audioWAudio&&(a<0&&e.frameTime,r=e.frameTime)}e._checkPlayFinished()}),1)}this.isNewSeek||this.audioWAudio&&this.audioWAudio.play()}},{key:"pause",value:function(){this.isPlaying=!1,this._pause()}},{key:"_pause",value:function(){this.playFrameInterval&&window.clearInterval(this.playFrameInterval),this.playFrameInterval=null,this.audioWAudio&&this.audioWAudio.pause()}},{key:"seek",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.openFrameCall=!1,this.pause(),this._clearDecInterval(),null!==this.avFeedVideoInterval&&(window.clearInterval(this.avFeedVideoInterval),this.avFeedVideoInterval=null),null!==this.avFeedAudioInterval&&(window.clearInterval(this.avFeedAudioInterval),this.avFeedAudioInterval=null),this.yuvMaxTime=0,this.playVPipe.length=0,this._videoQueue.length=0,this.audioWAudio&&this.audioWAudio.stop(),e&&e(),this.isNewSeek=!0,this.seekTarget=i.seekTime,this.audioWAudio&&this.audioWAudio.setVoice(0),this._avFeedData(i.seekTime),setTimeout((function(){t.yuvMaxTime=0,t._videoQueue.length=0,t.openFrameCall=!0,t.frameCallTag+=1,t._decVFrameIntervalFunc()}),1e3)}},{key:"setVoice",value:function(e){this.audioVoice=e,this.audioWAudio&&this.audioWAudio.setVoice(e)}},{key:"_checkDisplaySize",value:function(e,t,i){var r=t-e,n=this.config.width+Math.ceil(r/2),a=t/this.config.width>i/this.config.height,s=(n/t).toFixed(2),o=(this.config.height/i).toFixed(2),l=a?s:o,f=this.config.fixed,u=f?n:parseInt(t*l),h=f?this.config.height:parseInt(i*l);if(this.canvas.offsetWidth!=u||this.canvas.offsetHeight!=h){var c=parseInt((this.canvasBox.offsetHeight-h)/2),d=parseInt((this.canvasBox.offsetWidth-u)/2);c=c<0?0:c,d=d<0?0:d,this.canvas.style.marginTop=c+"px",this.canvas.style.marginLeft=d+"px",this.canvas.style.width=u+"px",this.canvas.style.height=h+"px"}return this.isCheckDisplay=!0,[u,h]}},{key:"_createYUVCanvas",value:function(){for(this.canvasBox=document.querySelector("#"+this.config.playerId),this.canvasBox.style.overflow="hidden";this.canvasBox.hasChildNodes();)this.canvasBox.removeChild(this.canvasBox.lastChild);this.canvas=document.createElement("canvas"),this.canvas.style.width=this.canvasBox.clientWidth+"px",this.canvas.style.height=this.canvasBox.clientHeight+"px",this.canvas.style.top="0px",this.canvas.style.left="0px",this.canvasBox.appendChild(this.canvas),this.yuv=l.setupCanvas(this.canvas,{preserveDrawingBuffer:!1})}},{key:"_avRecvPackets",value:function(){var e=this;this.bufObject.cleanPipeline(),null!==this.avRecvInterval&&(window.clearInterval(this.avRecvInterval),this.avRecvInterval=null),!0===this.config.checkProbe?this.avRecvInterval=window.setInterval((function(){a.cwrap("getSniffStreamPkg","number",["number"])(e.corePtr),e._avCheckRecvFinish()}),5):this.avRecvInterval=window.setInterval((function(){a.cwrap("getSniffStreamPkgNoCheckProbe","number",["number"])(e.corePtr),e._avCheckRecvFinish()}),5),this._avFeedData(0)}},{key:"_avCheckRecvFinish",value:function(){this.duration-this.getMaxPTS()=50&&(t.onSeekFinish&&t.onSeekFinish(),t.play(),window.clearInterval(i),i=null)}),10)}},{key:"_avFeedData",value:function(e){var t=this;if(this.playVPipe.length=0,this.audioWAudio&&this.audioWAudio.cleanQueue(),e<=0){var i=0;if(this.avFeedVideoInterval=window.setInterval((function(){var e=t.bufObject.videoBuffer.length;if(e-1>i||t.duration-t.getMaxPTS()0&&t.playVPipe[t.playVPipe.length-1].pts>=t.bufLastVDTS&&(window.clearInterval(t.avFeedVideoInterval),t.avFeedVideoInterval=null,t.playVPipe[t.playVPipe.length-1].pts,t.bufObject.videoBuffer)}else t.playVPipe.length>0&&t.playVPipe[t.playVPipe.length-1].pts>=t.duration&&(window.clearInterval(t.avFeedVideoInterval),t.avFeedVideoInterval=null,t.playVPipe[t.playVPipe.length-1].pts,t.bufObject.videoBuffer)}),5),this.audioWAudio&&this.config.ignoreAudio<1){var r=0;this.avFeedAudioInterval=window.setInterval((function(){var e=t.bufObject.audioBuffer.length;if(e-1>r||t.duration-t.getMaxPTS()0&&t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts>=t.bufLastADTS&&(window.clearInterval(t.avFeedAudioInterval),t.avFeedAudioInterval=null,t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts,t.bufObject.audioBuffer)}else t.audioWAudio.sampleQueue.length>0&&t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts>=t.duration&&(window.clearInterval(t.avFeedAudioInterval),t.avFeedAudioInterval=null,t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts,t.bufObject.audioBuffer)}),5)}}else{var n=this.bufObject.seekIDR(e),a=parseInt(n,10);this.playPTS=0;var o=a;if(this.avFeedVideoInterval=window.setInterval((function(){var i=t.bufObject.videoBuffer.length;if(i-1>o||t.duration-t.getMaxPTS()0&&t.playVPipe[t.playVPipe.length-1].pts>=t.bufLastVDTS&&(window.clearInterval(t.avFeedVideoInterval),t.avFeedVideoInterval=null,t.playVPipe[t.playVPipe.length-1].pts,t.bufObject.videoBuffer,t.onPlayingTime&&t.onPlayingTime(e),t._afterAvFeedSeekToStart())}else t.playVPipe.length>0&&t.playVPipe[t.playVPipe.length-1].pts>=t.duration&&(window.clearInterval(t.avFeedVideoInterval),t.avFeedVideoInterval=null,t.playVPipe[t.playVPipe.length-1].pts,t.bufObject.videoBuffer,t.onPlayingTime&&t.onPlayingTime(e),t._afterAvFeedSeekToStart())}),5),this.audioWAudio&&this.config.ignoreAudio<1){var l=parseInt(this.seekTarget,10);this.avFeedAudioInterval=window.setInterval((function(){var e=t.bufObject.audioBuffer.length;if(e-1>l||t.duration-t.getMaxPTS()0&&t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts>=t.bufLastADTS&&(window.clearInterval(t.avFeedAudioInterval),t.avFeedAudioInterval=null,t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts,t.bufObject.audioBuffer)}else t.audioWAudio.sampleQueue.length>0&&t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts>=t.duration&&(window.clearInterval(t.avFeedAudioInterval),t.avFeedAudioInterval=null,t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts,t.bufObject.audioBuffer)}),5)}}}},{key:"_probeFinCallback",value:function(e,t,i,r,n,s,o,l,h){var c=this;this._createYUVCanvas(),u.V_CODEC_NAME_HEVC,this.config.fps=1*r,this.frameTime=1e3/this.config.fps,this.width=t,this.height=i,this.frameDur=1/this.config.fps,this.duration=e-this.frameDur,this.vCodecID=l,this.config.sampleRate=s,this.channels=o,this.audioIdx=n;for(var d=a.HEAPU8.subarray(h,h+10),_=0;_=0&&this.config.ignoreAudio<1?(void 0!==this.audioWAudio&&null!==this.audioWAudio&&(this.audioWAudio.stop(),this.audioWAudio=null),this.audioWAudio=f({sampleRate:s,appendType:u.APPEND_TYPE_FRAME}),this.audioWAudio.setDurationMs(1e3*e),this.onLoadCache&&this.audioWAudio.setOnLoadCache((function(){if(c.retryAuSampleNo,c.retryAuSampleNo<=5){c.pause(),c.onLoadCache&&c.onLoadCache();var e=window.setInterval((function(){return c.retryAuSampleNo,c.audioWAudio.sampleQueue.length,c.audioWAudio.sampleQueue.length>2?(c.onLoadCacheFinshed&&c.onLoadCacheFinshed(),c.play(),c.retryAuSampleNo=0,window.clearInterval(e),void(e=null)):(c.retryAuSampleNo+=1,c.retryAuSampleNo>5?(c.play(),c.onLoadCacheFinshed&&c.onLoadCacheFinshed(),window.clearInterval(e),void(e=null)):void 0)}),1e3)}}))):this.audioNone=!0,this._avRecvPackets(),this._decVFrameIntervalFunc()),this.onProbeFinish&&this.onProbeFinish()}},{key:"_ptsFixed2",value:function(e){return Math.ceil(100*e)/100}},{key:"_naluCallback",value:function(e,t,i,r,n,s,o){var l=this._ptsFixed2(s),f=a.HEAPU8.subarray(e,e+t),u=new Uint8Array(f);this.bufObject.appendFrameWithDts(l,o,u,!0,i),this.bufLastVDTS=Math.max(o,this.bufLastVDTS),this.vCachePTS=Math.max(l,this.vCachePTS),this.onCacheProcess&&this.onCacheProcess(this.getCachePTS())}},{key:"_samplesCallback",value:function(e,t,i,r){}},{key:"_aacFrameCallback",value:function(e,t,i,r,n){var s=this._ptsFixed2(n);if(this.audioWAudio){var o=new Uint8Array(7+i),l=a.HEAPU8.subarray(e,e+7);o.set(l,0);var f=a.HEAPU8.subarray(t,t+i);o.set(f,7),this.bufObject.appendFrame(s,o,!1,!0),this.bufLastADTS=Math.max(s,this.bufLastVDTS),this.aCachePTS=Math.max(s,this.aCachePTS),this.onCacheProcess&&this.onCacheProcess(this.getCachePTS())}}},{key:"_decVFrameIntervalFunc",value:function(){var e=this;null==this.decVFrameInterval&&(this.decVFrameInterval=window.setInterval((function(){if(e._videoQueue.length<50&&e.playVPipe.length>0){var t=e.playVPipe.shift(),i=t.data,r=a._malloc(i.length);a.HEAP8.set(i,r);var n=parseInt(1e3*t.pts,10),s=parseInt(1e3*t.dts,10);e.yuvMaxTime=Math.max(t.pts,e.yuvMaxTime),a.cwrap("decodeVideoFrame","number",["number","number","number","number","number"])(e.corePtr,r,i.length,n,s,e.frameCallTag),e.frameCallTag,a._free(r),r=null}}),10))}},{key:"_frameCallback",value:function(e,t,i,r,n,s,o,f,u,h){if(!(!1===this.openFrameCall||h!==this.frameCallTag||u>this.yuvMaxTime+this.frameDur)){this.frameCallTag;var c=this._videoQueue.length;if(!(c>0&&u-this._videoQueue[c-1].pts>1||(this.canvas.width==r&&this.canvas.height==f||(this.canvas.width=r,this.canvas.height=f,this.isCheckDisplay)||this._checkDisplaySize(o,r,f),this.playPTS>u))){var _=a.HEAPU8.subarray(e,e+r*f),p=a.HEAPU8.subarray(t,t+n*f/2),m=a.HEAPU8.subarray(i,i+s*f/2),b=new Uint8Array(_),v=new Uint8Array(p),y=new Uint8Array(m);this.config.readyShow&&(l.renderFrame(this.yuv,b,v,y,r,f),this.config.readyShow=!1);var g=new d(b,v,y,r,n,s,o,f,u);if(c<=0||u>this._videoQueue[c-1].pts)this._videoQueue.push(g);else if(uthis._videoQueue[w].pts&&w+10&&void 0!==arguments[0]?arguments[0]:60,t={limit:e,yuvCache:[],appendCacheByCacheYuv:function(e){e.pts;return t.yuvCache.length>=t.limit?CACHE_APPEND_STATUS_CODE.OVERFLOW:(t.yuvCache.push(e),t.yuvCache.length>=t.limit?CACHE_APPEND_STATUS_CODE.FULL:CACHE_APPEND_STATUS_CODE.NOT_FULL)},getState:function(){return t.yuvCache.length<=0?CACHE_APPEND_STATUS_CODE.NULL:t.yuvCache.length>=t.limit?CACHE_APPEND_STATUS_CODE.FULL:CACHE_APPEND_STATUS_CODE.NOT_FULL},cleanPipeline:function(){t.yuvCache.length=0},vYuv:function(){return t.yuvCache.length<=0?null:t.yuvCache.shift()}};return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./cacheYuv":204}],204:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i>1;return n.indexOf(t)},GET_NALU_TYPE:function(e){var t=(126&e)>>1;if(t>=1&&t<=9)return r.DEFINE_P_FRAME;if(t>=16&&t<=21)return r.DEFINE_KEY_FRAME;var i=n.indexOf(t);return i>=0?n[i]:r.DEFINE_OTHERS_FRAME},PACK_NALU:function(e){var t=e.nalu,i=e.vlc.vlc;null==t.vps&&(t.vps=new Uint8Array);var r=new Uint8Array(t.vps.length+t.sps.length+t.pps.length+t.sei.length+i.length);return r.set(t.vps,0),r.set(t.sps,t.vps.length),r.set(t.pps,t.vps.length+t.sps.length),r.set(t.sei,t.vps.length+t.sps.length+t.pps.length),r.set(i,t.vps.length+t.sps.length+t.pps.length+t.sei.length),r}}},{"./hevc-header":205}],207:[function(e,t,i){"use strict";function r(e){return function(e){if(Array.isArray(e)){for(var t=0,i=new Array(e.length);t0&&void 0!==arguments[0]&&arguments[0];null!=t&&(t.showScreen=e,t.canvas&&(e?t.canvas.setAttribute("hidden",!0):t.canvas.removeAttribute("hidden")))},setSize:function(e,i){t.config.width=e||f.DEFAULT_WIDTH,t.config.height=i||f.DEFAULT_HEIGHT},setFrameRate:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:25;t.config.fps=e,t.config.frameDurMs=1e3/e},setDurationMs:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;t.durationMs=e,0==t.config.audioNone&&t.audio.setDurationMs(e)},setPlayingCall:function(e){t.onPlayingTime=e},setVoice:function(e){t.realVolume=e,0==t.config.audioNone&&t.audio.setVoice(t.realVolume)},isPlayingState:function(){return t.isPlaying},appendAACFrame:function(e){t.audio.addSample(e),t.aCachePTS=Math.max(e.pts,t.aCachePTS)},appendHevcFrame:function(e){var i;t.config.appendHevcType==f.APPEND_TYPE_STREAM?t.stream=new Uint8Array((i=r(t.stream)).concat.apply(i,r(e))):t.config.appendHevcType==f.APPEND_TYPE_FRAME&&(t.frameList.push(e),t.vCachePTS=Math.max(e.pts,t.vCachePTS))},getCachePTS:function(){return t.vCachePTS,t.aCachePTS,Math.max(t.vCachePTS,t.aCachePTS)},endAudio:function(){0==t.config.audioNone&&t.audio.stop()},cleanSample:function(){0==t.config.audioNone&&t.audio.cleanQueue()},cleanVideoQueue:function(){t.config.appendHevcType==f.APPEND_TYPE_STREAM?t.stream=new Uint8Array:t.config.appendHevcType==f.APPEND_TYPE_FRAME&&(t.frameList=[])},cleanCacheYUV:function(){t.cacheYuvBuf.cleanPipeline()},pause:function(){t.loop&&window.clearInterval(t.loop),t.loop=null,0==t.config.audioNone&&t.audio.pause(),t.isPlaying=!1},checkFinished:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f.PLAYER_MODE_VOD;return e==f.PLAYER_MODE_VOD&&(t.videoPTS.toFixed(1)>=(t.durationMs-t.config.frameDurMs)/1e3||t.noCacheFrame>=10)&&(null!=t.onPlayingFinish&&t.onPlayingFinish(),!0)},seek:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.isPlaying;t.nowPacket=null,t.vCachePTS=0,t.aCachePTS=0,t.pause(),t.cleanSample(),t.cleanVideoQueue(),t.cleanCacheYUV(),e&&e(),t.isNewSeek=!0,t.videoPTS=parseInt(i.seekTime);var n={seekPos:i.seekTime||-1,mode:i.mode||f.PLAYER_MODE_VOD,accurateSeek:i.accurateSeek||!0,seekEvent:i.seekEvent||!0,realPlay:r};t.play(n)},getNalu1Packet:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],i=null,r=-1;if(t.config.appendHevcType==f.APPEND_TYPE_STREAM)i=t.nextNalu();else{if(t.config.appendHevcType!=f.APPEND_TYPE_FRAME)return null;var n=t.frameList.shift();if(!n)return null;i=n.data,r=n.pts,e&&(t.videoPTS=r)}return{nalBuf:i,pts:r}},decodeNalu1Frame:function(e,i){var r=n._malloc(e.length);n.HEAP8.set(e,r);var a=parseInt(1e3*i);n.cwrap("decodeCodecContext","number",["number","number","number","number"])(t.vcodecerPtr,r,e.length,a);return n._free(r),!1},cacheThread:function(){t.cacheLoop=window.setInterval((function(){if(t.cacheYuvBuf.getState()!=CACHE_APPEND_STATUS_CODE.FULL){var e=t.getNalu1Packet(!1);if(null!=e){var i=e.nalBuf,r=e.pts;t.decodeNalu1Frame(i,r,!0)}}}),10)},loadCache:function(){if(!(t.frameList.length<=3)){var e=t.isPlaying;if(t.cacheYuvBuf.yuvCache.length<=3){t.pause(),null!=t.onLoadCache&&t.onLoadCache();var i=t.frameList.length>30?30:t.frameList.length,r=window.setInterval((function(){t.cacheYuvBuf.yuvCache.length>=i&&(null!=t.onLoadCacheFinshed&&t.onLoadCacheFinshed(),window.clearInterval(r),r=null,e&&t.play(t.playParams))}),40)}}},playFunc:function(){if(t.playParams.seekEvent||h()-t.calcuteStartTime>=t.frameTime-t.preCostTime){var e=!0;if(t.calcuteStartTime=h(),t.config.audioNone)t.playFrameYUV(e,t.playParams.accurateSeek);else{t.fix_poc_err_skip>0&&(t.fix_poc_err_skip--,e=!1);var i=t.videoPTS-t.audio.getAlignVPTS();if(i>0)return void(t.playParams.seekEvent&&!t.config.audioNone&&t.audio.setVoice(0));if(e){if(!(e=-1*i<=1*t.frameTimeSec)){for(var r=parseInt(i/t.frameTimeSec),n=0;n=t.playParams.seekPos&&!t.isNewSeek||0===t.playParams.seekPos||0===t.playParams.seekPos?(t.frameTime=1e3/t.config.fps,t.frameTimeSec=t.frameTime/1e3,0==t.config.audioNone&&t.audio.play(),t.realVolume=t.config.audioNone?0:t.audio.voice,t.playParams.seekEvent&&(t.fix_poc_err_skip=10),t.loop=window.setInterval((function(){var e=h();t.playFunc(),t.preCostTime=h()-e,t.preCostTime}),1)):(t.loop=window.setInterval((function(){t.playFrameYUV(!1,t.playParams.accurateSeek),t.checkFinished(t.playParams.mode)?(window.clearInterval(t.loop),t.loop=null):t.videoPTS>=t.playParams.seekPos&&(window.clearInterval(t.loop),t.loop=null,t.play(t.playParams))}),1),t.isNewSeek=!1)},stop:function(){t.release(),n.cwrap("initializeDecoder","number",["number"])(t.vcodecerPtr),t.stream=new Uint8Array},release:function(){return t.endAudio(),t.loop&&window.clearInterval(t.loop),t.loop=null,t.pause(),n.cwrap("release","number",["number"])(t.vcodecerPtr),t.stream=null,t.frameList.length=0,t.durationMs=-1,t.videoPTS=0,t.isPlaying=!1,!0},nextNalu:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(t.stream.length<=4)return!1;for(var i=-1,r=0;r=t.stream.length){if(-1==i)return!1;var n=t.stream.subarray(i);return t.stream=new Uint8Array,n}var a="0 0 1"==t.stream.slice(0,3).join(" "),s="0 0 0 1"==t.stream.slice(0,4).join(" ");if(a||s){if(-1==i)i=r;else{if(e<=1){var o=t.stream.subarray(i,r);return t.stream=t.stream.subarray(r),o}e-=1}r+=3}}return!1},decodeSendPacket:function(e){var i=n._malloc(e.length);n.HEAP8.set(e,i);var r=n.cwrap("decodeSendPacket","number",["number","number","number"])(t.vcodecerPtr,i,e.length);return n._free(i),r},decodeRecvFrame:function(){return n.cwrap("decodeRecv","number",["number"])(t.vcodecerPtr)},playFrameYUV:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.cacheYuvBuf.vYuv();if(null==r)return t.noCacheFrame+=1,e&&!t.playParams.seekEvent&&t.loadCache(),!1;t.noCacheFrame=0;var n=r.pts;return t.videoPTS=n,(!e&&i||e)&&e&&t.drawImage(r.width,r.height,r.imageBufferY,r.imageBufferB,r.imageBufferR),e&&!t.playParams.seekEvent&&t.isPlaying&&t.loadCache(),!0},drawImage:function(e,i,r,n,a){if(t.canvas.width===e&&t.canvas.height==i||(t.canvas.width=e,t.canvas.height=i),t.showScreen&&null!=t.onRender)t.onRender(e,i,r,n,a);else{if(!t.isCheckDisplay)t.checkDisplaySize(e,i);var s=e*i,o=e/2*(i/2),f=new Uint8Array(s+2*o);f.set(r,0),f.set(n,s),f.set(a,s+o),l.renderFrame(t.yuv,r,n,a,e,i)}},debugYUV:function(e){t.debugYUVSwitch=!0,t.debugID=e},checkDisplaySize:function(e,i){var r=e/t.config.width>i/t.config.height,n=(t.config.width/e).toFixed(2),a=(t.config.height/i).toFixed(2),s=r?n:a,o=t.config.fixed,l=o?t.config.width:parseInt(e*s),f=o?t.config.height:parseInt(i*s);if(t.canvas.offsetWidth!=l||t.canvas.offsetHeight!=f){var u=parseInt((t.canvasBox.offsetHeight-f)/2),h=parseInt((t.canvasBox.offsetWidth-l)/2);t.canvas.style.marginTop=u+"px",t.canvas.style.marginLeft=h+"px",t.canvas.style.width=l+"px",t.canvas.style.height=f+"px"}return t.isCheckDisplay=!0,[l,f]},makeWasm:function(){if(null!=t.config.token){t.vcodecerPtr=n.cwrap("registerPlayer","number",["string","string"])(t.config.token,u.PLAYER_VERSION);var e=n.addFunction((function(e,i,r,a,s,l,f,u,h){var c=n.HEAPU8.subarray(e,e+a*u),d=n.HEAPU8.subarray(i,i+s*u/2),_=n.HEAPU8.subarray(r,r+l*u/2),p=new Uint8Array(c),m=new Uint8Array(d),b=new Uint8Array(_),v=1*h/1e3,y=new o.CacheYuvStruct(v,a,u,p,m,b);t.cacheYuvBuf.appendCacheByCacheYuv(y)}));n.cwrap("setCodecType","number",["number","number","number"])(t.vcodecerPtr,t.config.videoCodec,e);n.cwrap("initMissile","number",["number"])(t.vcodecerPtr);n.cwrap("initializeDecoder","number",["number"])(t.vcodecerPtr)}else alert("请输入TOKEN!Please set token param!")},makeIt:function(){var e=document.querySelector("div#"+t.config.playerId),i=document.createElement("canvas");i.style.width=e.clientWidth+"px",i.style.height=e.clientHeight+"px",i.style.top="0px",i.style.left="0px",e.appendChild(i),t.canvasBox=e,t.canvas=i,t.yuv=l.setupCanvas(i,{preserveDrawingBuffer:!1}),0==t.config.audioNone&&(t.audio=a({sampleRate:t.config.sampleRate,appendType:t.config.appendHevcType})),t.isPlayLoadingFinish=1}};return t.makeWasm(),t.makeIt(),t.cacheThread(),t}},{"../consts":198,"../render-engine/webgl-420p":219,"../version":222,"./audio-core":199,"./cache":203,"./cacheYuv":204,"./missile.js":1}],208:[function(e,t,i){"use strict";var r=e("./bufferFrame");t.exports=function(){var e={videoBuffer:[],audioBuffer:[],idrIdxBuffer:[],appendFrame:function(t,i){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=new r.BufferFrame(t,a,i,n),o=parseInt(t);return n?(e.videoBuffer.length-1>=o?e.videoBuffer[o].push(s):e.videoBuffer.push([s]),a&&!e.idrIdxBuffer.includes(t)&&e.idrIdxBuffer.push(t)):e.audioBuffer.length-1>=o&&null!=e.audioBuffer[o]&&null!=e.audioBuffer[o]?e.audioBuffer[o]&&e.audioBuffer[o].push(s):e.audioBuffer.push([s]),!0},appendFrameWithDts:function(t,i,n){var a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=r.ConstructWithDts(t,i,s,n,a),l=parseInt(i);return a?(e.videoBuffer.length-1>=l?e.videoBuffer[l].push(o):e.videoBuffer.push([o]),s&&!e.idrIdxBuffer.includes(i)&&e.idrIdxBuffer.push(i)):e.audioBuffer.length-1>=l&&null!=e.audioBuffer[l]&&null!=e.audioBuffer[l]?e.audioBuffer[l]&&e.audioBuffer[l].push(o):e.audioBuffer.push([o]),!0},appendFrameByBufferFrame:function(t){var i=t.pts,r=parseInt(i);return t.video?(e.videoBuffer.length-1>=r?e.videoBuffer[r].push(t):e.videoBuffer.push([t]),isKey&&!e.idrIdxBuffer.includes(i)&&e.idrIdxBuffer.push(i)):e.audioBuffer.length-1>=r?e.audioBuffer[r].push(t):e.audioBuffer.push([t]),!0},cleanPipeline:function(){e.videoBuffer.length=0,e.audioBuffer.length=0},vFrame:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(!(t<0||t>e.videoBuffer.length-1))return e.videoBuffer[t]},aFrame:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(!(t<0||t>e.audioBuffer.length-1))return e.audioBuffer[t]},seekIDR:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(e.idrIdxBuffer,t<0)return null;if(e.idrIdxBuffer.includes(t))return t;for(var i=0;it){for(var r=1;r>=0;r--){var n=i-r;if(n>=0)return e.idrIdxBuffer[n]}return e.idrIdxBuffer[i]}}};return e}},{"./bufferFrame":209}],209:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i0&&i.extensionInfo.vHeight>0&&(i.size.width=i.extensionInfo.vWidth,i.size.height=i.extensionInfo.vHeight)),i.mediaInfo.duration,null!=i.onDemuxed&&i.onDemuxed(i.onReadyOBJ);for(var e=!1;;){var r=i.mpegTsObj.readPacket();if(r.size<=0)break;var n=r.dtime>0?r.dtime:r.ptime;if(!(n<0)){if(0==r.type){n<=i.vPreFramePTS&&(e=!0);var a=l.PACK_NALU(r.layer),o=1==r.keyframe,f=1==e?n+i.vStartTime:n,u=new s.BufferFrame(f,o,a,!0);i.bufObject.appendFrame(u.pts,u.data,!0,u.isKey),i.vPreFramePTS=f,null!=i.onSamples&&i.onSamples(i.onReadyOBJ,u)}else if(n<=i.aPreFramePTS&&(e=!0),"aac"==i.mediaInfo.aCodec)for(var h=r.data,c=0;c=3?(i._onTsReady(e),window.clearInterval(i.timerTsWasm),i.timerTsWasm=null):(i.mpegTsWasmRetryLoadTimes+=1,i.mpegTsObj.initDemuxer())}),3e3)}},{key:"_onTsReady",value:function(e){var t=this;t.hls.fetchM3u8(e),t.mpegTsWasmState=!0,t.timerFeed=window.setInterval((function(){if(t.tsList.length>0&&0==t.lockWait.state){var e=t.tsList.shift(),i=e.streamURI,r=e.streamDur;t.lockWait.state=!0,t.lockWait.lockMember.dur=r,t.mpegTsObj.demuxURL(i)}}),50)}},{key:"bindReady",value:function(e){this.onReadyOBJ=e}},{key:"popBuffer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return t<0?null:1==e?this.bufObject.vFrame(t):2==e?this.bufObject.aFrame(t):void 0}},{key:"getACodec",value:function(){return this.aCodec}},{key:"getDurationMs",value:function(){return this.durationMs}},{key:"getFPS",value:function(){return this.fps}},{key:"getSampleRate",value:function(){return this.sampleRate}},{key:"getSize",value:function(){return this.size}},{key:"seek",value:function(e){if(e>=0){var t=this.bufObject.seekIDR(e);this.seekPos=t}}}])&&r(t.prototype,i),u&&r(t,u),e}();i.M3u8=u},{"../consts":198,"../decoder/hevc-imp":206,"./buffer":208,"./bufferFrame":209,"./m3u8base":211,"./mpegts/mpeg.js":215}],211:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i1?(i=t[0],r=t[1].split("/"),this._preURI=i+"//"):r=t[0].split("/");for(var n=0;nh&&(i=h);var c=t[s+=1],d=this._preURI+c;this._slices.indexOf(d)<0&&(this._slices.push(d),null!=this.onTransportStream&&this.onTransportStream(d,h))}}}if(this._slices.length>a.hlsSliceLimit&&this._type==n.PLAYER_IN_TYPE_M3U8_LIVE&&(this._slices=this._slices.slice(-1*a.hlsSliceLimit)),null!=this.onFinished){var _={type:this._type,duration:-1};this.onFinished(_)}return i}},{key:"_readTag",value:function(e){var t=a.tagParse.exec(e);return null!==t?{key:t[1],value:t[3]}:null}}])&&r(t.prototype,i),s&&r(t,s),e}();i.M3u8Base=s},{"../consts":198}],212:[function(e,t,i){"use strict";var r=e("mp4box"),n=e("../decoder/hevc-header"),a=e("../decoder/hevc-imp"),s=e("./buffer"),o=e("../consts"),l={96e3:0,88200:1,64e3:2,48e3:3,44100:4,32e3:5,24e3:6,22050:7,16e3:8,12e3:9,11025:10,8e3:11,7350:12,Reserved:13,"frequency is written explictly":15};function f(){}f.prototype.setStartCode=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=null;return t?((i=e)[0]=n.DEFINE_STARTCODE[0],i[1]=n.DEFINE_STARTCODE[1],i[2]=n.DEFINE_STARTCODE[2],i[3]=n.DEFINE_STARTCODE[3]):((i=new Uint8Array(n.DEFINE_STARTCODE.length+e.length)).set(n.DEFINE_STARTCODE,0),i.set(e,n.DEFINE_STARTCODE.length)),i},f.prototype.setAACAdts=function(e){var t=null,i=this.aacProfile,r=l[this.sampleRate],n=new Uint8Array(7),a=n.length+e.length;return n[0]=255,n[1]=241,n[2]=(i-1<<6)+(r<<2)+0,n[3]=128+(a>>11),n[4]=(2047&a)>>3,n[5]=31+((7&a)<<5),n[6]=252,(t=new Uint8Array(a)).set(n,0),t.set(e,n.length),t},f.prototype.demux=function(){var e=this;e.seekPos=-1,e.mp4boxfile=r.createFile(),e.movieInfo=null,e.videoCodec=null,e.durationMs=-1,e.fps=-1,e.sampleRate=-1,e.aacProfile=2,e.size={width:-1,height:-1},e.bufObject=s(),e.audioNone=!1,e.naluHeader={vps:null,sps:null,pps:null,sei:null},e.mp4boxfile.onError=function(e){},this.mp4boxfile.onReady=function(t){for(var i in e.movieInfo=t,t.tracks)"VideoHandler"!==t.tracks[i].name&&"video"!==t.tracks[i].type||(t.tracks[i].codec,t.tracks[i].codec.indexOf("hev")>=0||t.tracks[i].codec.indexOf("hvc")>=0?e.videoCodec=o.CODEC_H265:t.tracks[i].codec.indexOf("avc")>=0&&(e.videoCodec=o.CODEC_H264));var r=-1;if(r=t.videoTracks[0].samples_duration/t.videoTracks[0].timescale,e.durationMs=1e3*r,e.fps=t.videoTracks[0].nb_samples/r,e.seekDiffTime=1/e.fps,e.size.width=t.videoTracks[0].track_width,e.size.height=t.videoTracks[0].track_height,t.audioTracks.length>0){e.sampleRate=t.audioTracks[0].audio.sample_rate;var n=t.audioTracks[0].codec.split(".");e.aacProfile=n[n.length-1]}else e.audioNone=!0;null!=e.onMp4BoxReady&&e.onMp4BoxReady(e.videoCodec),e.videoCodec===o.CODEC_H265?(e.initializeAllSourceBuffers(),e.mp4boxfile.start()):(e.videoCodec,o.CODEC_H264)},e.mp4boxfile.onSamples=function(t,i,r){var s=window.setInterval((function(){for(var i=0;i3?e.naluHeader.sei=e.setStartCode(p[3][0].data,!1):e.naluHeader.sei=new Uint8Array,e.naluHeader}else e.videoCodec==o.CODEC_H264&&(e.naluHeader.vps=new Uint8Array,e.naluHeader.sps=e.setStartCode(c.SPS[0].nalu,!1),e.naluHeader.pps=e.setStartCode(c.PPS[0].nalu,!1),e.naluHeader.sei=new Uint8Array);if(f[4],e.naluHeader.vps[4],e.naluHeader.vps,f[4]===e.naluHeader.vps[4]){var m=e.naluHeader.vps.length+4,b=e.naluHeader.vps.length+e.naluHeader.sps.length+4,v=e.naluHeader.vps.length+e.naluHeader.sps.length+e.naluHeader.pps.length+4;if(e.naluHeader.sei.length<=0&&e.naluHeader.sps.length>0&&f[m]===e.naluHeader.sps[4]&&e.naluHeader.pps.length>0&&f[b]===e.naluHeader.pps[4]&&78===f[v]){f[e.naluHeader.vps.length+4],e.naluHeader.sps[4],f[e.naluHeader.vps.length+e.naluHeader.sps.length+4],e.naluHeader.pps[4],f[e.naluHeader.vps.length+e.naluHeader.sps.length+e.naluHeader.pps.length+4];for(var y=0,g=0;g4&&f[4]===e.naluHeader.sei[4]){var w=f.subarray(0,10),E=new Uint8Array(e.naluHeader.vps.length+w.length);E.set(w,0),E.set(e.naluHeader.vps,w.length),E[3]=1,e.naluHeader.vps=null,e.naluHeader.vps=new Uint8Array(E),E=null,w=null,(f=f.subarray(10))[4],e.naluHeader.vps[4],e.naluHeader.vps}else if(0===e.naluHeader.sei.length&&78===f[4]){f=e.setStartCode(f,!0);for(var C=0,S=0;S1&&void 0!==arguments[1]?arguments[1]:0;return e.fileStart=t,this.mp4boxfile.appendBuffer(e)},f.prototype.finishBuffer=function(){this.mp4boxfile.flush()},f.prototype.play=function(){},f.prototype.getVideoCoder=function(){return this.videoCodec},f.prototype.getDurationMs=function(){return this.durationMs},f.prototype.getFPS=function(){return this.fps},f.prototype.getSampleRate=function(){return this.sampleRate},f.prototype.getSize=function(){return this.size},f.prototype.seek=function(e){if(e>=0){var t=this.bufObject.seekIDR(e);this.seekPos=t}},f.prototype.popBuffer=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return t<0?null:1==e?this.bufObject.vFrame(t):2==e?this.bufObject.aFrame(t):void 0},f.prototype.addBuffer=function(e){var t=e.id;this.mp4boxfile.setExtractionOptions(t)},f.prototype.initializeAllSourceBuffers=function(){if(this.movieInfo){for(var e=this.movieInfo,t=0;t>5)}},{key:"sliceAACFrames",value:function(e,t){for(var i=[],r=e,n=0;n>4==15){var a=this._getPktLen(t[n+3],t[n+4],t[n+5]);if(a<=0)continue;var s=t.subarray(n,n+a),o=new Uint8Array(a);o.set(s,0),i.push({ptime:r,data:o}),r+=this.frameDurSec,n+=a}else n+=1;return i}}])&&r(t.prototype,i),n&&r(t,n),e}();i.AACDecoder=n},{}],215:[function(e,t,i){(function(t){"use strict";function r(e,t){for(var i=0;i=0&&(this._setMediaInfo(),this._setExtensionInfo(),null!=this.onDemuxed&&this.onDemuxed())}},{key:"_setMediaInfo",value:function(){var e=n.cwrap("getMediaInfo","number",[])(),t=n.HEAPU32[e/4],i=n.HEAPU32[e/4+1],r=n.HEAPF64[e/8+1],o=n.HEAPF64[e/8+1+1],l=n.HEAPF64[e/8+1+1+1],f=n.HEAPF64[e/8+1+1+1+1],u=n.HEAPU32[e/4+2+2+2+2+2];this.mediaAttr.vFps=r,this.mediaAttr.vGop=u,this.mediaAttr.vDuration=o,this.mediaAttr.aDuration=l,this.mediaAttr.duration=f;var h=n.cwrap("getAudioCodecID","number",[])();h>=0?(this.mediaAttr.aCodec=s.CODEC_OFFSET_TABLE[h],this.mediaAttr.sampleRate=t>0?t:s.DEFAULT_SAMPLERATE,this.mediaAttr.sampleChannel=i>0?i:s.DEFAULT_CHANNEL):(this.mediaAttr.sampleRate=0,this.mediaAttr.sampleChannel=0);var c=n.cwrap("getVideoCodecID","number",[])();c>=0&&(this.mediaAttr.vCodec=s.CODEC_OFFSET_TABLE[c]),null==this.aacDec?this.aacDec=new a.AACDecoder(this.mediaAttr):this.aacDec.updateConfig(this.mediaAttr)}},{key:"_setExtensionInfo",value:function(){var e=n.cwrap("getExtensionInfo","number",[])(),t=n.HEAPU32[e/4],i=n.HEAPU32[e/4+1];this.extensionInfo.vWidth=t,this.extensionInfo.vHeight=i}},{key:"readMediaInfo",value:function(){return this.mediaAttr}},{key:"readExtensionInfo",value:function(){return this.extensionInfo}},{key:"_readLayer",value:function(){var e={vps:null,sps:null,pps:null,sei:null},t={vlc:null},i=n.cwrap("getSPSLen","number",[])(),r=n.cwrap("getSPS","number",[])();e.sps=new Uint8Array(i),e.sps.set(n.HEAPU8.subarray(r,r+i),0);var a=n.cwrap("getPPSLen","number",[])(),o=n.cwrap("getPPS","number",[])();e.pps=new Uint8Array(a),e.pps.set(n.HEAPU8.subarray(o,o+a),0);var l=n.cwrap("getSEILen","number",[])(),f=n.cwrap("getSEI","number",[])();e.sei=new Uint8Array(l),e.sei.set(n.HEAPU8.subarray(f,f+l),0);var u=n.cwrap("getVLCLen","number",[])(),h=n.cwrap("getVLC","number",[])();if(t.vlc=new Uint8Array(u),t.vlc.set(n.HEAPU8.subarray(h,h+u),0),this.mediaAttr.vCodec==s.DEF_HEVC||this.mediaAttr.vCodec==s.DEF_H265){var c=n.cwrap("getVPSLen","number",[])(),d=n.cwrap("getVPS","number",[])();e.vps=new Uint8Array(c),e.vps.set(n.HEAPU8.subarray(d,d+c),0)}else this.mediaAttr.vCodec==s.DEF_AVC||(this.mediaAttr.vCodec,s.DEF_H264);return{nalu:e,vlc:t}}},{key:"readPacket",value:function(){var e=n.cwrap("getPacket","number",[])(),t=n.HEAPU32[e/4],i=n.HEAPU32[e/4+1],r=n.HEAPF64[e/8+1],a=n.HEAPF64[e/8+1+1],o=n.HEAPU32[e/4+1+1+2+2],l=n.HEAPU32[e/4+1+1+2+2+1],f=n.HEAPU8.subarray(l,l+i),u=this._readLayer();return{type:t,size:i,ptime:r,dtime:a,keyframe:o,src:f,data:1==t&&this.mediaAttr.aCodec==s.DEF_AAC?this.aacDec.sliceAACFrames(r,f):f,layer:u}}},{key:"_refreshDemuxer",value:function(){this._releaseDemuxer(),this._initDemuxer()}},{key:"_initDemuxer",value:function(){n.cwrap("initTsMissile","number",[])(),n.cwrap("initializeDemuxer","number",[])()}},{key:"_releaseDemuxer",value:function(){n.cwrap("exitTsMissile","number",[])()}}])&&r(i.prototype,o),l&&r(i,l),e}();i.MPEG_JS=o}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../decoder/missile.js":1,"./consts":213,"./decoder/aac":214}],216:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i0&&e.extensionInfo.vHeight>0&&(e.size.width=e.extensionInfo.vWidth,e.size.height=e.extensionInfo.vHeight);for(var t=null;!((t=e.mpegTsObj.readPacket()).size<=0);){var i=t.dtime;if(0==t.type){var r=s.PACK_NALU(t.layer),n=1==t.keyframe;e.bufObject.appendFrame(i,r,!0,n)}else if("aac"==e.mediaInfo.aCodec)for(var a=t.data,o=0;o0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return t<0?null:1==e?this.bufObject.vFrame(t):2==e?this.bufObject.aFrame(t):void 0}},{key:"getACodec",value:function(){return this.aCodec}},{key:"getDurationMs",value:function(){return this.durationMs}},{key:"getFPS",value:function(){return this.fps}},{key:"getSampleRate",value:function(){return this.sampleRate}},{key:"getSize",value:function(){return this.size}},{key:"seek",value:function(e){if(e>=0){var t=this.bufObject.seekIDR(e);this.seekPos=t}}}])&&r(t.prototype,i),o&&r(t,o),e}();i.MpegTs=o},{"../decoder/hevc-imp":206,"./buffer":208,"./mpegts/mpeg.js":215}],217:[function(e,t,i){(function(t){"use strict";function r(e,t){for(var i=0;i0&&void 0!==arguments[0]&&arguments[0];this.player.setScreen(e)}},{key:"play",value:function(){if(this.playParam.videoCodec===u.CODEC_H265){var e={seekPos:this._getSeekTarget(),mode:this.playMode,accurateSeek:this.configFormat.accurateSeek,seekEvent:!1,realPlay:!0};this.player.play(e)}else this.player.play();return!0}},{key:"pause",value:function(){return this.player.pause(),!0}},{key:"isPlaying",value:function(){return this.player.isPlayingState()}},{key:"setVoice",value:function(e){if(e<0)return!1;this.player.setVoice(e)}},{key:"mediaInfo",value:function(){return{meta:this.playParam,videoType:this.playMode}}},{key:"seek",value:function(e){var t=this;this.seekTarget=e,this.onSeekStart&&this.onSeekStart(e),this.timerFeed&&(window.clearInterval(this.timerFeed),this.timerFeed=null);var i=this._getSeekTarget();return this.playParam.videoCodec===u.CODEC_H264&&this.configFormat.type==u.PLAYER_IN_TYPE_MP4?(this.player.seek(e),this.onSeekFinish&&this.onSeekFinish()):this.configFormat.extInfo.core===u.PLAYER_CORE_TYPE_CNATIVE?this.player.seek((function(){}),{seekTime:i,mode:t.playMode,accurateSeek:t.configFormat.accurateSeek}):this.player.seek((function(){t.configFormat.type==u.PLAYER_IN_TYPE_MP4?t.mp4Obj.seek(e):t.configFormat.type==u.PLAYER_IN_TYPE_TS||t.configFormat.type==u.PLAYER_IN_TYPE_MPEGTS?t.mpegTsObj.seek(e):t.configFormat.type==u.PLAYER_IN_TYPE_M3U8&&t.hlsObj.seek(e);var i,r=(i=0,i=t.configFormat.accurateSeek?e:t._getBoxBufSeekIDR(),parseInt(i)),n=parseInt(t._getBoxBufSeekIDR())||0;t._avFeedMP4Data(n,r)}),{seekTime:i,mode:t.playMode,accurateSeek:t.configFormat.accurateSeek}),!0}},{key:"_durationText",value:function(e){if(e<0)return"Play";var t=Math.round(e);return Math.floor(t/3600)+":"+Math.floor(t%3600/60)+":"+Math.floor(t%60)}},{key:"_getSeekTarget",value:function(){return this.configFormat.accurateSeek?this.seekTarget:this._getBoxBufSeekIDR()}},{key:"_getBoxBufSeekIDR",value:function(){return this.configFormat.type==u.PLAYER_IN_TYPE_MP4?this.mp4Obj.seekPos:this.configFormat.type==u.PLAYER_IN_TYPE_TS||this.configFormat.type==u.PLAYER_IN_TYPE_MPEGTS?this.mpegTsObj.seekPos:this.configFormat.type==u.PLAYER_IN_TYPE_M3U8?this.hlsObj.seekPos:void 0}},{key:"_playControl",value:function(){this.isPlaying()?this.pause():this.play()}},{key:"_avFeedMP4Data",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=parseInt(this.playParam.durationMs/1e3);this.timerFeed=window.setInterval((function(){var a=null,s=null;if(e.configFormat.type==u.PLAYER_IN_TYPE_MP4?(a=e.mp4Obj.popBuffer(1,t),s=e.mp4Obj.audioNone?null:e.mp4Obj.popBuffer(2,i)):e.configFormat.type==u.PLAYER_IN_TYPE_TS||e.configFormat.type==u.PLAYER_IN_TYPE_MPEGTS?(a=e.mpegTsObj.popBuffer(1,t),s=e.mpegTsObj.audioNone?null:e.mpegTsObj.popBuffer(2,i)):e.configFormat.type==u.PLAYER_IN_TYPE_M3U8&&(a=e.hlsObj.popBuffer(1,t),s=e.hlsObj.audioNone?null:e.hlsObj.popBuffer(2,i)),null!=a)for(var o=0;on||e.player.getCachePTS()>n)return window.clearInterval(e.timerFeed),e.timerFeed=null,void(null!=r&&r())}),5)}},{key:"_makeMP4Player",value:function(){this.configFormat.type,null!=this.configFormat.extInfo.core&&null!==this.configFormat.extInfo.core&&this.configFormat.extInfo.core===u.PLAYER_CORE_TYPE_CNATIVE?this._cDemuxDecoderEntry():this.configFormat.type==u.PLAYER_IN_TYPE_MP4?this.configFormat.extInfo.moovStartFlag?this._mp4EntryVodStream():this._mp4Entry():this.configFormat.type==u.PLAYER_IN_TYPE_TS||this.configFormat.type==u.PLAYER_IN_TYPE_MPEGTS?this._mpegTsEntry():this.configFormat.type==u.PLAYER_IN_TYPE_M3U8?this._m3u8Entry():this.configFormat.type===u.PLAYER_IN_TYPE_RAW_265&&this._raw265Entry()}},{key:"_makeMP4PlayerViewEvent",value:function(e,t,i,r){var a=this,s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,l=this;if(this.playParam.durationMs=e,this.playParam.fps=t,this.playParam.sampleRate=i,this.playParam.size=r,this.playParam.audioNone=s,this.playParam.videoCodec=o||u.CODEC_H265,(this.configFormat.type==u.PLAYER_IN_TYPE_M3U8&&this.hlsConf.hlsType==u.PLAYER_IN_TYPE_M3U8_LIVE||this.configFormat.type==u.PLAYER_IN_TYPE_RAW_265)&&(this.playMode=u.PLAYER_MODE_NOTIME_LIVE),l.configFormat.extInfo.autoCrop){var f=document.querySelector("#"+this.configFormat.playerId),h=r.width/r.height,c=this.configFormat.playerW/this.configFormat.playerH;h>c?f.style.height=this.configFormat.playerW/h+"px":h>1,a>>1,i),e.v.fill(n>>1,a>>1,r),e.drawArrays(e.TRIANGLE_STRIP,0,4)},setupCanvas:function(e,t){var i=e.getContext("webgl")||e.getContext("experimental-webgl");if(!i)return i;var n=i.createProgram(),a=["attribute highp vec4 aVertexPosition;","attribute vec2 aTextureCoord;","varying highp vec2 vTextureCoord;","void main(void) {"," gl_Position = aVertexPosition;"," vTextureCoord = aTextureCoord;","}"].join("\n"),s=i.createShader(i.VERTEX_SHADER);i.shaderSource(s,a),i.compileShader(s);var o=["precision highp float;","varying lowp vec2 vTextureCoord;","uniform sampler2D YTexture;","uniform sampler2D UTexture;","uniform sampler2D VTexture;","const mat4 YUV2RGB = mat4","("," 1.1643828125, 0, 1.59602734375, -.87078515625,"," 1.1643828125, -.39176171875, -.81296875, .52959375,"," 1.1643828125, 2.017234375, 0, -1.081390625,"," 0, 0, 0, 1",");","void main(void) {"," gl_FragColor = vec4( texture2D(YTexture, vTextureCoord).x, texture2D(UTexture, vTextureCoord).x, texture2D(VTexture, vTextureCoord).x, 1) * YUV2RGB;","}"].join("\n"),l=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(l,o),i.compileShader(l),i.attachShader(n,s),i.attachShader(n,l),i.linkProgram(n),i.useProgram(n),i.getProgramParameter(n,i.LINK_STATUS);var f=i.getAttribLocation(n,"aVertexPosition");i.enableVertexAttribArray(f);var u=i.getAttribLocation(n,"aTextureCoord");i.enableVertexAttribArray(u);var h=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,h),i.bufferData(i.ARRAY_BUFFER,new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0]),i.STATIC_DRAW),i.vertexAttribPointer(f,3,i.FLOAT,!1,0,0);var c=i.createBuffer();return i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,new Float32Array([1,0,0,0,1,1,0,1]),i.STATIC_DRAW),i.vertexAttribPointer(u,2,i.FLOAT,!1,0,0),i.y=new r(i),i.u=new r(i),i.v=new r(i),i.y.bind(0,n,"YTexture"),i.u.bind(1,n,"UTexture"),i.v.bind(2,n,"VTexture"),i}}},{}],220:[function(e,t,i){(function(e){"use strict";e.STATIC_MEM_wasmDecoderState=-1,e.STATICE_MEM_playerCount=-1,e.STATICE_MEM_playerIndexPtr=0}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],221:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var r=a(e);return t&&0!==t.length?"string"==typeof i?r.fill(t,i):r.fill(t):r.fill(0),r}),!s.kStringMaxLength)try{s.kStringMaxLength=i.binding("buffer").kStringMaxLength}catch(e){}s.constants||(s.constants={MAX_LENGTH:s.kMaxLength},s.kStringMaxLength&&(s.constants.MAX_STRING_LENGTH=s.kStringMaxLength)),t.exports=s}).call(this,e("_process"))},{_process:158,buffer:66}],186:[function(e,t,i){var r=e("safe-buffer").Buffer;function n(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}n.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var i=this._block,n=this._blockSize,a=e.length,s=this._len,o=0;o=this._finalSize&&(this._update(this._block),this._block.fill(0));var i=8*this._len;if(i<=4294967295)this._block.writeUInt32BE(i,this._blockSize-4);else{var r=(4294967295&i)>>>0,n=(i-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var a=this._hash();return e?a.toString(e):a},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=n},{"safe-buffer":184}],187:[function(e,t,i){(i=t.exports=function(e){e=e.toLowerCase();var t=i[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),i.sha1=e("./sha1"),i.sha224=e("./sha224"),i.sha256=e("./sha256"),i.sha384=e("./sha384"),i.sha512=e("./sha512")},{"./sha":188,"./sha1":189,"./sha224":190,"./sha256":191,"./sha384":192,"./sha512":193}],188:[function(e,t,i){var r=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1518500249,1859775393,-1894007588,-899497514],o=new Array(80);function l(){this.init(),this._w=o,n.call(this,64,56)}function f(e){return e<<30|e>>>2}function u(e,t,i,r){return 0===e?t&i|~t&r:2===e?t&i|t&r|i&r:t^i^r}r(l,n),l.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},l.prototype._update=function(e){for(var t,i=this._w,r=0|this._a,n=0|this._b,a=0|this._c,o=0|this._d,l=0|this._e,h=0;h<16;++h)i[h]=e.readInt32BE(4*h);for(;h<80;++h)i[h]=i[h-3]^i[h-8]^i[h-14]^i[h-16];for(var c=0;c<80;++c){var d=~~(c/20),_=0|((t=r)<<5|t>>>27)+u(d,n,a,o)+l+i[c]+s[d];l=o,o=a,a=f(n),n=r,r=_}this._a=r+this._a|0,this._b=n+this._b|0,this._c=a+this._c|0,this._d=o+this._d|0,this._e=l+this._e|0},l.prototype._hash=function(){var e=a.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=l},{"./hash":186,inherits:136,"safe-buffer":184}],189:[function(e,t,i){var r=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1518500249,1859775393,-1894007588,-899497514],o=new Array(80);function l(){this.init(),this._w=o,n.call(this,64,56)}function f(e){return e<<5|e>>>27}function u(e){return e<<30|e>>>2}function h(e,t,i,r){return 0===e?t&i|~t&r:2===e?t&i|t&r|i&r:t^i^r}r(l,n),l.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},l.prototype._update=function(e){for(var t,i=this._w,r=0|this._a,n=0|this._b,a=0|this._c,o=0|this._d,l=0|this._e,c=0;c<16;++c)i[c]=e.readInt32BE(4*c);for(;c<80;++c)i[c]=(t=i[c-3]^i[c-8]^i[c-14]^i[c-16])<<1|t>>>31;for(var d=0;d<80;++d){var _=~~(d/20),p=f(r)+h(_,n,a,o)+l+i[d]+s[_]|0;l=o,o=a,a=u(n),n=r,r=p}this._a=r+this._a|0,this._b=n+this._b|0,this._c=a+this._c|0,this._d=o+this._d|0,this._e=l+this._e|0},l.prototype._hash=function(){var e=a.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=l},{"./hash":186,inherits:136,"safe-buffer":184}],190:[function(e,t,i){var r=e("inherits"),n=e("./sha256"),a=e("./hash"),s=e("safe-buffer").Buffer,o=new Array(64);function l(){this.init(),this._w=o,a.call(this,64,56)}r(l,n),l.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},l.prototype._hash=function(){var e=s.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=l},{"./hash":186,"./sha256":191,inherits:136,"safe-buffer":184}],191:[function(e,t,i){var r=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],o=new Array(64);function l(){this.init(),this._w=o,n.call(this,64,56)}function f(e,t,i){return i^e&(t^i)}function u(e,t,i){return e&t|i&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function c(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function d(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}r(l,n),l.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},l.prototype._update=function(e){for(var t,i=this._w,r=0|this._a,n=0|this._b,a=0|this._c,o=0|this._d,l=0|this._e,_=0|this._f,p=0|this._g,m=0|this._h,b=0;b<16;++b)i[b]=e.readInt32BE(4*b);for(;b<64;++b)i[b]=0|(((t=i[b-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+i[b-7]+d(i[b-15])+i[b-16];for(var v=0;v<64;++v){var y=m+c(l)+f(l,_,p)+s[v]+i[v]|0,g=h(r)+u(r,n,a)|0;m=p,p=_,_=l,l=o+y|0,o=a,a=n,n=r,r=y+g|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=a+this._c|0,this._d=o+this._d|0,this._e=l+this._e|0,this._f=_+this._f|0,this._g=p+this._g|0,this._h=m+this._h|0},l.prototype._hash=function(){var e=a.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=l},{"./hash":186,inherits:136,"safe-buffer":184}],192:[function(e,t,i){var r=e("inherits"),n=e("./sha512"),a=e("./hash"),s=e("safe-buffer").Buffer,o=new Array(160);function l(){this.init(),this._w=o,a.call(this,128,112)}r(l,n),l.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},l.prototype._hash=function(){var e=s.allocUnsafe(48);function t(t,i,r){e.writeInt32BE(t,r),e.writeInt32BE(i,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=l},{"./hash":186,"./sha512":193,inherits:136,"safe-buffer":184}],193:[function(e,t,i){var r=e("inherits"),n=e("./hash"),a=e("safe-buffer").Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],o=new Array(160);function l(){this.init(),this._w=o,n.call(this,128,112)}function f(e,t,i){return i^e&(t^i)}function u(e,t,i){return e&t|i&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function c(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function _(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function p(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function m(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function b(e,t){return e>>>0>>0?1:0}r(l,n),l.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},l.prototype._update=function(e){for(var t=this._w,i=0|this._ah,r=0|this._bh,n=0|this._ch,a=0|this._dh,o=0|this._eh,l=0|this._fh,v=0|this._gh,y=0|this._hh,g=0|this._al,w=0|this._bl,E=0|this._cl,C=0|this._dl,S=0|this._el,j=0|this._fl,T=0|this._gl,A=0|this._hl,x=0;x<32;x+=2)t[x]=e.readInt32BE(4*x),t[x+1]=e.readInt32BE(4*x+4);for(;x<160;x+=2){var M=t[x-30],k=t[x-30+1],P=d(M,k),I=_(k,M),U=p(M=t[x-4],k=t[x-4+1]),R=m(k,M),D=t[x-14],O=t[x-14+1],F=t[x-32],B=t[x-32+1],L=I+O|0,N=P+D+b(L,I)|0;N=(N=N+U+b(L=L+R|0,R)|0)+F+b(L=L+B|0,B)|0,t[x]=N,t[x+1]=L}for(var z=0;z<160;z+=2){N=t[z],L=t[z+1];var H=u(i,r,n),V=u(g,w,E),Y=h(i,g),q=h(g,i),X=c(o,S),W=c(S,o),G=s[z],K=s[z+1],Q=f(o,l,v),Z=f(S,j,T),J=A+W|0,$=y+X+b(J,A)|0;$=($=($=$+Q+b(J=J+Z|0,Z)|0)+G+b(J=J+K|0,K)|0)+N+b(J=J+L|0,L)|0;var ee=q+V|0,te=Y+H+b(ee,q)|0;y=v,A=T,v=l,T=j,l=o,j=S,o=a+$+b(S=C+J|0,C)|0,a=n,C=E,n=r,E=w,r=i,w=g,i=$+te+b(g=J+ee|0,J)|0}this._al=this._al+g|0,this._bl=this._bl+w|0,this._cl=this._cl+E|0,this._dl=this._dl+C|0,this._el=this._el+S|0,this._fl=this._fl+j|0,this._gl=this._gl+T|0,this._hl=this._hl+A|0,this._ah=this._ah+i+b(this._al,g)|0,this._bh=this._bh+r+b(this._bl,w)|0,this._ch=this._ch+n+b(this._cl,E)|0,this._dh=this._dh+a+b(this._dl,C)|0,this._eh=this._eh+o+b(this._el,S)|0,this._fh=this._fh+l+b(this._fl,j)|0,this._gh=this._gh+v+b(this._gl,T)|0,this._hh=this._hh+y+b(this._hl,A)|0},l.prototype._hash=function(){var e=a.allocUnsafe(64);function t(t,i,r){e.writeInt32BE(t,r),e.writeInt32BE(i,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=l},{"./hash":186,inherits:136,"safe-buffer":184}],194:[function(e,t,i){t.exports=n;var r=e("events").EventEmitter;function n(){r.call(this)}e("inherits")(n,r),n.Readable=e("readable-stream/readable.js"),n.Writable=e("readable-stream/writable.js"),n.Duplex=e("readable-stream/duplex.js"),n.Transform=e("readable-stream/transform.js"),n.PassThrough=e("readable-stream/passthrough.js"),n.Stream=n,n.prototype.pipe=function(e,t){var i=this;function n(t){e.writable&&!1===e.write(t)&&i.pause&&i.pause()}function a(){i.readable&&i.resume&&i.resume()}i.on("data",n),e.on("drain",a),e._isStdio||t&&!1===t.end||(i.on("end",o),i.on("close",l));var s=!1;function o(){s||(s=!0,e.end())}function l(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function f(e){if(u(),0===r.listenerCount(this,"error"))throw e}function u(){i.removeListener("data",n),e.removeListener("drain",a),i.removeListener("end",o),i.removeListener("close",l),i.removeListener("error",f),e.removeListener("error",f),i.removeListener("end",u),i.removeListener("close",u),e.removeListener("close",u)}return i.on("error",f),e.on("error",f),i.on("end",u),i.on("close",u),e.on("close",u),e.emit("pipe",i),e}},{events:104,inherits:136,"readable-stream/duplex.js":168,"readable-stream/passthrough.js":179,"readable-stream/readable.js":180,"readable-stream/transform.js":181,"readable-stream/writable.js":182}],195:[function(e,t,i){arguments[4][178][0].apply(i,arguments)},{dup:178,"safe-buffer":184}],196:[function(e,t,i){(function(t,r){var n=e("process/browser.js").nextTick,a=Function.prototype.apply,s=Array.prototype.slice,o={},l=0;function f(e,t){this._id=e,this._clearFn=t}i.setTimeout=function(){return new f(a.call(setTimeout,window,arguments),clearTimeout)},i.setInterval=function(){return new f(a.call(setInterval,window,arguments),clearInterval)},i.clearTimeout=i.clearInterval=function(e){e.close()},f.prototype.unref=f.prototype.ref=function(){},f.prototype.close=function(){this._clearFn.call(window,this._id)},i.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},i.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},i._unrefActive=i.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},i.setImmediate="function"==typeof t?t:function(e){var t=l++,r=!(arguments.length<2)&&s.call(arguments,1);return o[t]=!0,n((function(){o[t]&&(r?e.apply(null,r):e.call(null),i.clearImmediate(t))})),t},i.clearImmediate="function"==typeof r?r:function(e){delete o[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":158,timers:196}],197:[function(e,t,i){(function(e){function i(t){try{if(!e.localStorage)return!1}catch(e){return!1}var i=e.localStorage[t];return null!=i&&"true"===String(i).toLowerCase()}t.exports=function(e,t){if(i("noDeprecation"))return e;var r=!1;return function(){if(!r){if(i("throwDeprecation"))throw new Error(t);i("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],198:[function(e,t,i){"use strict";t.exports={DEFAILT_WEBGL_PLAY_ID:"glplayer",PLAYER_IN_TYPE_MP4:"mp4",PLAYER_IN_TYPE_RAW_265:"raw265",PLAYER_IN_TYPE_TS:"ts",PLAYER_IN_TYPE_MPEGTS:"mpegts",PLAYER_IN_TYPE_M3U8:"hls",PLAYER_IN_TYPE_M3U8_VOD:"m3u8",PLAYER_IN_TYPE_M3U8_LIVE:"hls",APPEND_TYPE_STREAM:0,APPEND_TYPE_FRAME:1,APPEND_TYPE_SEQUENCE:2,DEFAULT_WIDTH:600,DEFAULT_HEIGHT:600,DEFAULT_FPS:25,DEFAULT_FRAME_DUR:40,DEFAULT_FIXED:!1,DEFAULT_SAMPLERATE:44100,DEFAULT_CHANNELS:2,DEFAULT_CONSU_SAMPLE_LEN:20,PLAYER_MODE_VOD:"vod",PLAYER_MODE_NOTIME_LIVE:"live",AUDIO_MODE_ONCE:"ONCE",AUDIO_MODE_SWAP:"SWAP",DEFAULT_STRING_LIVE:"LIVE",CODEC_H265:0,CODEC_H264:1,PLAYER_CORE_TYPE_DEFAULT:0,PLAYER_CORE_TYPE_CNATIVE:1,V_CODEC_NAME_HEVC:265,V_CODEC_NAME_AVC:264,V_CODEC_NAME_UNKN:500,A_CODEC_NAME_AAC:112,A_CODEC_NAME_MP3:113,A_CODEC_NAME_UNKN:500}},{}],199:[function(e,t,i){"use strict";var r=window.AudioContext||window.webkitAudioContext,n=e("../consts"),a=function(){return(new Date).getTime()};t.exports=function(e){var t={options:{sampleRate:e.sampleRate||n.DEFAULT_SAMPLERATE,appendType:e.appendType||n.APPEND_TYPE_STREAM,playMode:e.playMode||n.AUDIO_MODE_SWAP},sourceChannel:-1,audioCtx:new r({latencyHint:"interactive",sampleRate:e.sampleRate}),gainNode:null,sourceList:[],startStatus:!1,sampleQueue:[],nextBuffer:null,playTimestamp:0,playStartTime:0,durationMs:-1,voice:1,onLoadCache:null,setOnLoadCache:function(e){t.onLoadCache=e},setDurationMs:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;t.durationMs=e},setVoice:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;t.voice=e,t.gainNode.gain.value=e},getAlignVPTS:function(){return t.playTimestamp+(a()-t.playStartTime)/1e3},swapSource:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;if(0==t.startStatus)return null;if(e<0||e>=t.sourceList.length)return null;if(i<0||i>=t.sourceList.length)return null;try{t.sourceChannel===e&&null!==t.sourceList[e]&&(t.sourceList[e].disconnect(t.gainNode),t.sourceList[e]=null)}catch(e){}t.sourceChannel=i;var r=t.decodeSample(i,e);-2==r&&(t.getAlignVPTS()>=t.durationMs/1e3-.04?t.pause():null!==t.onLoadCache&&t.onLoadCache())},addSample:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return!(null==e||!e||null==e)&&(0==t.sampleQueue.length&&(t.seekPos=e.pts),t.sampleQueue.push(e),!0)},runNextBuffer:function(){window.setInterval((function(){if(!(null!=t.nextBuffer||t.sampleQueue.length0&&void 0!==arguments[0]?arguments[0]:-1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;if(e<0||e>=t.sourceList.length)return-1;if(null!=t.sourceList[e]&&null!=t.sourceList[e]&&t.sourceList[e]||(t.sourceList[e]=t.audioCtx.createBufferSource(),t.sourceList[e].onended=function(){t.swapSource(e,i)}),0==t.sampleQueue.length)return-2;if(t.sourceList[e].buffer)return t.sourceList[e],t.sourceList[i],t.gainNode,t.swapSource(e,i),0;if(null==t.nextBuffer||t.nextBuffer.data.length<1)return t.sourceList[e].connect(t.gainNode),t.sourceList[e].start(),t.sourceList[e].startState=!0,t.sourceList[e].stop(),1;var r=t.nextBuffer.data.buffer;t.playTimestamp=t.nextBuffer.pts,t.playStartTime=a();try{t.audioCtx.decodeAudioData(r,(function(i){t.sourceList[e].buffer=i,t.sourceList[e].connect(t.gainNode),t.sourceList[e].start(),t.sourceList[e].startState=!0,t.sourceList[e]}),(function(e){}))}catch(e){return t.nextBuffer=null,-3}return t.nextBuffer=null,0},decodeWholeSamples:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(t.sourceChannel=e,e<0||e>=t.sourceList.length)return-1;if(null!=t.sourceList[e]&&null!=t.sourceList[e]&&t.sourceList[e]||(t.sourceList[e]=t.audioCtx.createBufferSource(),t.sourceList[e].onended=function(){}),0==t.sampleQueue.length)return-2;for(var i=null,r=null,a=0;a=2){var s=i.length/2;a=new Float32Array(s);for(var o=0,l=0;l0&&s()-this._start_time>=this._now_seg_dur&&(s(),this._start_time,this._now_seg_dur,this._start_time=-1,this._now_seg_dur=-1),s(),this._start_time<0)if(new Date,null!==this._pcm_array_buf&&this._pcm_array_buf.length>this._push_start_idx){this._swapStartPlay=!1;var e=this._push_start_idx+this._once_pop_len;e>this._pcm_array_buf.length&&(e=this._pcm_array_buf.length);var t=this._pcm_array_buf.slice(this._push_start_idx,e);this._push_start_idx+=t.length,this._now_seg_dur=1*t.length/this._sample_rate*1e3,t.length,this._sample_rate,this._now_seg_dur;var i=this._ctx.createBuffer(1,t.length,this._sample_rate);t.length,new Date,i.copyToChannel(t,0),this._active_node=this._ctx.createBufferSource(),this._active_node.buffer=i,this._active_node.connect(this._gain),this._start_time=s(),this._active_node.start(0)}else setTimeout(this.readingLoopWithF32,1)}}])&&r(t.prototype,i),o&&r(t,o),e}();i.AudioPcmPlayer=o},{"../consts":198}],201:[function(e,t,i){"use strict";t.exports={frameDataAlignCrop:function(e,t,i,r,n,a,s,o){if(0==e-r)return[a,s,o];for(var l=r*n,f=l/4,u=new Uint8Array(l),h=new Uint8Array(f),c=new Uint8Array(f),d=r,_=r/2,p=0;p0&&void 0!==arguments[0]&&arguments[0];this.showScreen=e,this.canvas&&(e?this.canvas.setAttribute("hidden",!0):this.canvas.removeAttribute("hidden"))}},{key:"getCachePTS",value:function(){return 1!==this.config.ignoreAudio&&this.audioWAudio?Math.min(this.vCachePTS,this.aCachePTS):this.vCachePTS}},{key:"getMaxPTS",value:function(){return Math.max(this.vCachePTS,this.aCachePTS)}},{key:"isPlayingState",value:function(){return this.isPlaying}},{key:"pushDone",value:function(){this.pushEOF=!0}},{key:"_clearDecInterval",value:function(){this.decVFrameInterval&&window.clearInterval(this.decVFrameInterval),this.decVFrameInterval=null}},{key:"_checkPlayFinished",value:function(){return!!(!0===this.bufRecvStat&&(this.playPTS>=this.bufLastVDTS||this.audioWAudio&&this.playPTS>=this.bufLastADTS)||this.duration-this.playPTS0&&(this.isPlaying=!0);var t=0,i=0,r=0;this.playFrameInterval=window.setInterval((function(){if(i=c(),e._videoQueue.length>0&&i-t>=e.frameTime-r){var n=e._videoQueue.shift(),a=0;if(e.isNewSeek||null===e.audioWAudio||void 0===e.audioWAudio||(a=1e3*(n.pts-e.audioWAudio.getAlignVPTS()),e.playPTS=Math.max(e.audioWAudio.getAlignVPTS(),e.playPTS)),t=i,c(),n.pts,e.seekTarget,e.playPTS=Math.max(n.pts,e.playPTS),e.isNewSeek&&e.seekTarget-e.frameDur>n.pts)return void(r=e.frameTime);if(e.isNewSeek&&(e.audioWAudio&&e.audioWAudio.setVoice(e.audioVoice),e.audioWAudio&&e.audioWAudio.play(),r=0,e.isNewSeek=!1,e.seekTarget=0),n.pts,e.showScreen?e.onRender&&e.onRender(n.line1,n.height,n.data_y,n.data_u,n.data_v):l.renderFrame(e.yuv,n.data_y,n.data_u,n.data_v,n.line1,n.height),e.onPlayingTime&&e.onPlayingTime(n.pts),!e.isNewSeek&&e.audioWAudio&&(a<0&&-1*a<=e.frameTime||a>=0)){if(n.pts>=e.duration)e.onLoadCacheFinshed&&e.onLoadCacheFinshed(),e.onPlayingFinish&&e.onPlayingFinish(),e._clearDecInterval(),e.pause();else if(e._checkPlayFinished())return;r=c()-i}else!e.isNewSeek&&e.audioWAudio&&(a<0&&e.frameTime,r=e.frameTime)}e._checkPlayFinished()}),1)}this.isNewSeek||this.audioWAudio&&this.audioWAudio.play()}},{key:"pause",value:function(){this.isPlaying=!1,this._pause()}},{key:"_pause",value:function(){this.playFrameInterval&&window.clearInterval(this.playFrameInterval),this.playFrameInterval=null,this.audioWAudio&&this.audioWAudio.pause()}},{key:"seek",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.openFrameCall=!1,this.pause(),this._clearDecInterval(),null!==this.avFeedVideoInterval&&(window.clearInterval(this.avFeedVideoInterval),this.avFeedVideoInterval=null),null!==this.avFeedAudioInterval&&(window.clearInterval(this.avFeedAudioInterval),this.avFeedAudioInterval=null),this.yuvMaxTime=0,this.playVPipe.length=0,this._videoQueue.length=0,this.audioWAudio&&this.audioWAudio.stop(),e&&e(),this.isNewSeek=!0,this.seekTarget=i.seekTime,this.audioWAudio&&this.audioWAudio.setVoice(0),this._avFeedData(i.seekTime),setTimeout((function(){t.yuvMaxTime=0,t._videoQueue.length=0,t.openFrameCall=!0,t.frameCallTag+=1,t._decVFrameIntervalFunc()}),1e3)}},{key:"setVoice",value:function(e){this.audioVoice=e,this.audioWAudio&&this.audioWAudio.setVoice(e)}},{key:"_checkDisplaySize",value:function(e,t,i){var r=t-e,n=this.config.width+Math.ceil(r/2),a=t/this.config.width>i/this.config.height,s=(n/t).toFixed(2),o=(this.config.height/i).toFixed(2),l=a?s:o,f=this.config.fixed,u=f?n:parseInt(t*l),h=f?this.config.height:parseInt(i*l);if(this.canvas.offsetWidth!=u||this.canvas.offsetHeight!=h){var c=parseInt((this.canvasBox.offsetHeight-h)/2),d=parseInt((this.canvasBox.offsetWidth-u)/2);c=c<0?0:c,d=d<0?0:d,this.canvas.style.marginTop=c+"px",this.canvas.style.marginLeft=d+"px",this.canvas.style.width=u+"px",this.canvas.style.height=h+"px"}return this.isCheckDisplay=!0,[u,h]}},{key:"_createYUVCanvas",value:function(){for(this.canvasBox=document.querySelector("#"+this.config.playerId),this.canvasBox.style.overflow="hidden";this.canvasBox.hasChildNodes();)this.canvasBox.removeChild(this.canvasBox.lastChild);this.canvas=document.createElement("canvas"),this.canvas.style.width=this.canvasBox.clientWidth+"px",this.canvas.style.height=this.canvasBox.clientHeight+"px",this.canvas.style.top="0px",this.canvas.style.left="0px",this.canvasBox.appendChild(this.canvas),this.yuv=l.setupCanvas(this.canvas,{preserveDrawingBuffer:!1})}},{key:"_avRecvPackets",value:function(){var e=this;this.bufObject.cleanPipeline(),null!==this.avRecvInterval&&(window.clearInterval(this.avRecvInterval),this.avRecvInterval=null),!0===this.config.checkProbe?this.avRecvInterval=window.setInterval((function(){a.cwrap("getSniffStreamPkg","number",["number"])(e.corePtr),e._avCheckRecvFinish()}),5):this.avRecvInterval=window.setInterval((function(){a.cwrap("getSniffStreamPkgNoCheckProbe","number",["number"])(e.corePtr),e._avCheckRecvFinish()}),5),this._avFeedData(0)}},{key:"_avCheckRecvFinish",value:function(){this.duration-this.getMaxPTS()=50&&(t.onSeekFinish&&t.onSeekFinish(),t.play(),window.clearInterval(i),i=null)}),10)}},{key:"_avFeedData",value:function(e){var t=this;if(this.playVPipe.length=0,this.audioWAudio&&this.audioWAudio.cleanQueue(),e<=0){var i=0;if(this.avFeedVideoInterval=window.setInterval((function(){var e=t.bufObject.videoBuffer.length;if(e-1>i||t.duration-t.getMaxPTS()0&&t.playVPipe[t.playVPipe.length-1].pts>=t.bufLastVDTS&&(window.clearInterval(t.avFeedVideoInterval),t.avFeedVideoInterval=null,t.playVPipe[t.playVPipe.length-1].pts,t.bufObject.videoBuffer)}else t.playVPipe.length>0&&t.playVPipe[t.playVPipe.length-1].pts>=t.duration&&(window.clearInterval(t.avFeedVideoInterval),t.avFeedVideoInterval=null,t.playVPipe[t.playVPipe.length-1].pts,t.bufObject.videoBuffer)}),5),this.audioWAudio&&this.config.ignoreAudio<1){var r=0;this.avFeedAudioInterval=window.setInterval((function(){var e=t.bufObject.audioBuffer.length;if(e-1>r||t.duration-t.getMaxPTS()0&&t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts>=t.bufLastADTS&&(window.clearInterval(t.avFeedAudioInterval),t.avFeedAudioInterval=null,t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts,t.bufObject.audioBuffer)}else t.audioWAudio.sampleQueue.length>0&&t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts>=t.duration&&(window.clearInterval(t.avFeedAudioInterval),t.avFeedAudioInterval=null,t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts,t.bufObject.audioBuffer)}),5)}}else{var n=this.bufObject.seekIDR(e),a=parseInt(n,10);this.playPTS=0;var o=a;if(this.avFeedVideoInterval=window.setInterval((function(){var i=t.bufObject.videoBuffer.length;if(i-1>o||t.duration-t.getMaxPTS()0&&t.playVPipe[t.playVPipe.length-1].pts>=t.bufLastVDTS&&(window.clearInterval(t.avFeedVideoInterval),t.avFeedVideoInterval=null,t.playVPipe[t.playVPipe.length-1].pts,t.bufObject.videoBuffer,t.onPlayingTime&&t.onPlayingTime(e),t._afterAvFeedSeekToStart())}else t.playVPipe.length>0&&t.playVPipe[t.playVPipe.length-1].pts>=t.duration&&(window.clearInterval(t.avFeedVideoInterval),t.avFeedVideoInterval=null,t.playVPipe[t.playVPipe.length-1].pts,t.bufObject.videoBuffer,t.onPlayingTime&&t.onPlayingTime(e),t._afterAvFeedSeekToStart())}),5),this.audioWAudio&&this.config.ignoreAudio<1){var l=parseInt(this.seekTarget,10);this.avFeedAudioInterval=window.setInterval((function(){var e=t.bufObject.audioBuffer.length;if(e-1>l||t.duration-t.getMaxPTS()0&&t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts>=t.bufLastADTS&&(window.clearInterval(t.avFeedAudioInterval),t.avFeedAudioInterval=null,t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts,t.bufObject.audioBuffer)}else t.audioWAudio.sampleQueue.length>0&&t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts>=t.duration&&(window.clearInterval(t.avFeedAudioInterval),t.avFeedAudioInterval=null,t.audioWAudio.sampleQueue[t.audioWAudio.sampleQueue.length-1].pts,t.bufObject.audioBuffer)}),5)}}}},{key:"_probeFinCallback",value:function(e,t,i,r,n,s,o,l,h){var c=this;this._createYUVCanvas(),u.V_CODEC_NAME_HEVC,this.config.fps=1*r,this.frameTime=1e3/this.config.fps,this.width=t,this.height=i,this.frameDur=1/this.config.fps,this.duration=e-this.frameDur,this.vCodecID=l,this.config.sampleRate=s,this.channels=o,this.audioIdx=n;for(var d=a.HEAPU8.subarray(h,h+10),_=0;_=0&&this.config.ignoreAudio<1?(void 0!==this.audioWAudio&&null!==this.audioWAudio&&(this.audioWAudio.stop(),this.audioWAudio=null),this.audioWAudio=f({sampleRate:s,appendType:u.APPEND_TYPE_FRAME}),this.audioWAudio.setDurationMs(1e3*e),this.onLoadCache&&this.audioWAudio.setOnLoadCache((function(){if(c.retryAuSampleNo,c.retryAuSampleNo<=5){c.pause(),c.onLoadCache&&c.onLoadCache();var e=window.setInterval((function(){return c.retryAuSampleNo,c.audioWAudio.sampleQueue.length,c.audioWAudio.sampleQueue.length>2?(c.onLoadCacheFinshed&&c.onLoadCacheFinshed(),c.play(),c.retryAuSampleNo=0,window.clearInterval(e),void(e=null)):(c.retryAuSampleNo+=1,c.retryAuSampleNo>5?(c.play(),c.onLoadCacheFinshed&&c.onLoadCacheFinshed(),window.clearInterval(e),void(e=null)):void 0)}),1e3)}}))):this.audioNone=!0,this._avRecvPackets(),this._decVFrameIntervalFunc()),this.onProbeFinish&&this.onProbeFinish()}},{key:"_ptsFixed2",value:function(e){return Math.ceil(100*e)/100}},{key:"_naluCallback",value:function(e,t,i,r,n,s,o){var l=this._ptsFixed2(s),f=a.HEAPU8.subarray(e,e+t),u=new Uint8Array(f);this.bufObject.appendFrameWithDts(l,o,u,!0,i),this.bufLastVDTS=Math.max(o,this.bufLastVDTS),this.vCachePTS=Math.max(l,this.vCachePTS),this.onCacheProcess&&this.onCacheProcess(this.getCachePTS())}},{key:"_samplesCallback",value:function(e,t,i,r){}},{key:"_aacFrameCallback",value:function(e,t,i,r,n){var s=this._ptsFixed2(n);if(this.audioWAudio){var o=new Uint8Array(7+i),l=a.HEAPU8.subarray(e,e+7);o.set(l,0);var f=a.HEAPU8.subarray(t,t+i);o.set(f,7),this.bufObject.appendFrame(s,o,!1,!0),this.bufLastADTS=Math.max(s,this.bufLastVDTS),this.aCachePTS=Math.max(s,this.aCachePTS),this.onCacheProcess&&this.onCacheProcess(this.getCachePTS())}}},{key:"_decVFrameIntervalFunc",value:function(){var e=this;null==this.decVFrameInterval&&(this.decVFrameInterval=window.setInterval((function(){if(e._videoQueue.length<50&&e.playVPipe.length>0){var t=e.playVPipe.shift(),i=t.data,r=a._malloc(i.length);a.HEAP8.set(i,r);var n=parseInt(1e3*t.pts,10),s=parseInt(1e3*t.dts,10);e.yuvMaxTime=Math.max(t.pts,e.yuvMaxTime),a.cwrap("decodeVideoFrame","number",["number","number","number","number","number"])(e.corePtr,r,i.length,n,s,e.frameCallTag),e.frameCallTag,a._free(r),r=null}}),10))}},{key:"_frameCallback",value:function(e,t,i,r,n,s,o,f,u,h){if(!(!1===this.openFrameCall||h!==this.frameCallTag||u>this.yuvMaxTime+this.frameDur)){this.frameCallTag;var c=this._videoQueue.length;if(!(c>0&&u-this._videoQueue[c-1].pts>1||(this.canvas.width==r&&this.canvas.height==f||(this.canvas.width=r,this.canvas.height=f,this.isCheckDisplay)||this._checkDisplaySize(o,r,f),this.playPTS>u))){var _=a.HEAPU8.subarray(e,e+r*f),p=a.HEAPU8.subarray(t,t+n*f/2),m=a.HEAPU8.subarray(i,i+s*f/2),b=new Uint8Array(_),v=new Uint8Array(p),y=new Uint8Array(m);this.config.readyShow&&(l.renderFrame(this.yuv,b,v,y,r,f),this.config.readyShow=!1);var g=new d(b,v,y,r,n,s,o,f,u);if(c<=0||u>this._videoQueue[c-1].pts)this._videoQueue.push(g);else if(uthis._videoQueue[w].pts&&w+10&&void 0!==arguments[0]?arguments[0]:60,t={limit:e,yuvCache:[],appendCacheByCacheYuv:function(e){e.pts;return t.yuvCache.length>=t.limit?CACHE_APPEND_STATUS_CODE.OVERFLOW:(t.yuvCache.push(e),t.yuvCache.length>=t.limit?CACHE_APPEND_STATUS_CODE.FULL:CACHE_APPEND_STATUS_CODE.NOT_FULL)},getState:function(){return t.yuvCache.length<=0?CACHE_APPEND_STATUS_CODE.NULL:t.yuvCache.length>=t.limit?CACHE_APPEND_STATUS_CODE.FULL:CACHE_APPEND_STATUS_CODE.NOT_FULL},cleanPipeline:function(){t.yuvCache.length=0},vYuv:function(){return t.yuvCache.length<=0?null:t.yuvCache.shift()}};return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./cacheYuv":204}],204:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i>1;return n.indexOf(t)},GET_NALU_TYPE:function(e){var t=(126&e)>>1;if(t>=1&&t<=9)return r.DEFINE_P_FRAME;if(t>=16&&t<=21)return r.DEFINE_KEY_FRAME;var i=n.indexOf(t);return i>=0?n[i]:r.DEFINE_OTHERS_FRAME},PACK_NALU:function(e){var t=e.nalu,i=e.vlc.vlc;null==t.vps&&(t.vps=new Uint8Array);var r=new Uint8Array(t.vps.length+t.sps.length+t.pps.length+t.sei.length+i.length);return r.set(t.vps,0),r.set(t.sps,t.vps.length),r.set(t.pps,t.vps.length+t.sps.length),r.set(t.sei,t.vps.length+t.sps.length+t.pps.length),r.set(i,t.vps.length+t.sps.length+t.pps.length+t.sei.length),r}}},{"./hevc-header":205}],207:[function(e,t,i){"use strict";function r(e){return function(e){if(Array.isArray(e)){for(var t=0,i=new Array(e.length);t0&&void 0!==arguments[0]&&arguments[0];null!=t&&(t.showScreen=e,t.canvas&&(e?t.canvas.setAttribute("hidden",!0):t.canvas.removeAttribute("hidden")))},setSize:function(e,i){t.config.width=e||f.DEFAULT_WIDTH,t.config.height=i||f.DEFAULT_HEIGHT},setFrameRate:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:25;t.config.fps=e,t.config.frameDurMs=1e3/e},setDurationMs:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;t.durationMs=e,0==t.config.audioNone&&t.audio.setDurationMs(e)},setPlayingCall:function(e){t.onPlayingTime=e},setVoice:function(e){t.realVolume=e,0==t.config.audioNone&&t.audio.setVoice(t.realVolume)},isPlayingState:function(){return t.isPlaying},appendAACFrame:function(e){t.audio.addSample(e),t.aCachePTS=Math.max(e.pts,t.aCachePTS)},appendHevcFrame:function(e){var i;t.config.appendHevcType==f.APPEND_TYPE_STREAM?t.stream=new Uint8Array((i=r(t.stream)).concat.apply(i,r(e))):t.config.appendHevcType==f.APPEND_TYPE_FRAME&&(t.frameList.push(e),t.vCachePTS=Math.max(e.pts,t.vCachePTS))},getCachePTS:function(){return t.vCachePTS,t.aCachePTS,Math.max(t.vCachePTS,t.aCachePTS)},endAudio:function(){0==t.config.audioNone&&t.audio.stop()},cleanSample:function(){0==t.config.audioNone&&t.audio.cleanQueue()},cleanVideoQueue:function(){t.config.appendHevcType==f.APPEND_TYPE_STREAM?t.stream=new Uint8Array:t.config.appendHevcType==f.APPEND_TYPE_FRAME&&(t.frameList=[])},cleanCacheYUV:function(){t.cacheYuvBuf.cleanPipeline()},pause:function(){t.loop&&window.clearInterval(t.loop),t.loop=null,0==t.config.audioNone&&t.audio.pause(),t.isPlaying=!1},checkFinished:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f.PLAYER_MODE_VOD;return e==f.PLAYER_MODE_VOD&&(t.videoPTS.toFixed(1)>=(t.durationMs-t.config.frameDurMs)/1e3||t.noCacheFrame>=10)&&(null!=t.onPlayingFinish&&t.onPlayingFinish(),!0)},seek:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.isPlaying;t.nowPacket=null,t.vCachePTS=0,t.aCachePTS=0,t.pause(),t.cleanSample(),t.cleanVideoQueue(),t.cleanCacheYUV(),e&&e(),t.isNewSeek=!0,t.videoPTS=parseInt(i.seekTime);var n={seekPos:i.seekTime||-1,mode:i.mode||f.PLAYER_MODE_VOD,accurateSeek:i.accurateSeek||!0,seekEvent:i.seekEvent||!0,realPlay:r};t.play(n)},getNalu1Packet:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],i=null,r=-1;if(t.config.appendHevcType==f.APPEND_TYPE_STREAM)i=t.nextNalu();else{if(t.config.appendHevcType!=f.APPEND_TYPE_FRAME)return null;var n=t.frameList.shift();if(!n)return null;i=n.data,r=n.pts,e&&(t.videoPTS=r)}return{nalBuf:i,pts:r}},decodeNalu1Frame:function(e,i){var r=n._malloc(e.length);n.HEAP8.set(e,r);var a=parseInt(1e3*i);n.cwrap("decodeCodecContext","number",["number","number","number","number"])(t.vcodecerPtr,r,e.length,a);return n._free(r),!1},cacheThread:function(){t.cacheLoop=window.setInterval((function(){if(t.cacheYuvBuf.getState()!=CACHE_APPEND_STATUS_CODE.FULL){var e=t.getNalu1Packet(!1);if(null!=e){var i=e.nalBuf,r=e.pts;t.decodeNalu1Frame(i,r,!0)}}}),10)},loadCache:function(){if(!(t.frameList.length<=3)){var e=t.isPlaying;if(t.cacheYuvBuf.yuvCache.length<=3){t.pause(),null!=t.onLoadCache&&t.onLoadCache();var i=t.frameList.length>30?30:t.frameList.length,r=window.setInterval((function(){t.cacheYuvBuf.yuvCache.length>=i&&(null!=t.onLoadCacheFinshed&&t.onLoadCacheFinshed(),window.clearInterval(r),r=null,e&&t.play(t.playParams))}),40)}}},playFunc:function(){if(t.playParams.seekEvent||h()-t.calcuteStartTime>=t.frameTime-t.preCostTime){var e=!0;if(t.calcuteStartTime=h(),t.config.audioNone)t.playFrameYUV(e,t.playParams.accurateSeek);else{t.fix_poc_err_skip>0&&(t.fix_poc_err_skip--,e=!1);var i=t.videoPTS-t.audio.getAlignVPTS();if(i>0)return void(t.playParams.seekEvent&&!t.config.audioNone&&t.audio.setVoice(0));if(e){if(!(e=-1*i<=1*t.frameTimeSec)){for(var r=parseInt(i/t.frameTimeSec),n=0;n=t.playParams.seekPos&&!t.isNewSeek||0===t.playParams.seekPos||0===t.playParams.seekPos?(t.frameTime=1e3/t.config.fps,t.frameTimeSec=t.frameTime/1e3,0==t.config.audioNone&&t.audio.play(),t.realVolume=t.config.audioNone?0:t.audio.voice,t.playParams.seekEvent&&(t.fix_poc_err_skip=10),t.loop=window.setInterval((function(){var e=h();t.playFunc(),t.preCostTime=h()-e,t.preCostTime}),1)):(t.loop=window.setInterval((function(){t.playFrameYUV(!1,t.playParams.accurateSeek),t.checkFinished(t.playParams.mode)?(window.clearInterval(t.loop),t.loop=null):t.videoPTS>=t.playParams.seekPos&&(window.clearInterval(t.loop),t.loop=null,t.play(t.playParams))}),1),t.isNewSeek=!1)},stop:function(){t.release(),n.cwrap("initializeDecoder","number",["number"])(t.vcodecerPtr),t.stream=new Uint8Array},release:function(){return t.endAudio(),t.loop&&window.clearInterval(t.loop),t.loop=null,t.pause(),n.cwrap("release","number",["number"])(t.vcodecerPtr),t.stream=null,t.frameList.length=0,t.durationMs=-1,t.videoPTS=0,t.isPlaying=!1,!0},nextNalu:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(t.stream.length<=4)return!1;for(var i=-1,r=0;r=t.stream.length){if(-1==i)return!1;var n=t.stream.subarray(i);return t.stream=new Uint8Array,n}var a="0 0 1"==t.stream.slice(0,3).join(" "),s="0 0 0 1"==t.stream.slice(0,4).join(" ");if(a||s){if(-1==i)i=r;else{if(e<=1){var o=t.stream.subarray(i,r);return t.stream=t.stream.subarray(r),o}e-=1}r+=3}}return!1},decodeSendPacket:function(e){var i=n._malloc(e.length);n.HEAP8.set(e,i);var r=n.cwrap("decodeSendPacket","number",["number","number","number"])(t.vcodecerPtr,i,e.length);return n._free(i),r},decodeRecvFrame:function(){return n.cwrap("decodeRecv","number",["number"])(t.vcodecerPtr)},playFrameYUV:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.cacheYuvBuf.vYuv();if(null==r)return t.noCacheFrame+=1,e&&!t.playParams.seekEvent&&t.loadCache(),!1;t.noCacheFrame=0;var n=r.pts;return t.videoPTS=n,(!e&&i||e)&&e&&t.drawImage(r.width,r.height,r.imageBufferY,r.imageBufferB,r.imageBufferR),e&&!t.playParams.seekEvent&&t.isPlaying&&t.loadCache(),!0},drawImage:function(e,i,r,n,a){if(t.canvas.width===e&&t.canvas.height==i||(t.canvas.width=e,t.canvas.height=i),t.showScreen&&null!=t.onRender)t.onRender(e,i,r,n,a);else{if(!t.isCheckDisplay)t.checkDisplaySize(e,i);var s=e*i,o=e/2*(i/2),f=new Uint8Array(s+2*o);f.set(r,0),f.set(n,s),f.set(a,s+o),l.renderFrame(t.yuv,r,n,a,e,i)}},debugYUV:function(e){t.debugYUVSwitch=!0,t.debugID=e},checkDisplaySize:function(e,i){var r=e/t.config.width>i/t.config.height,n=(t.config.width/e).toFixed(2),a=(t.config.height/i).toFixed(2),s=r?n:a,o=t.config.fixed,l=o?t.config.width:parseInt(e*s),f=o?t.config.height:parseInt(i*s);if(t.canvas.offsetWidth!=l||t.canvas.offsetHeight!=f){var u=parseInt((t.canvasBox.offsetHeight-f)/2),h=parseInt((t.canvasBox.offsetWidth-l)/2);t.canvas.style.marginTop=u+"px",t.canvas.style.marginLeft=h+"px",t.canvas.style.width=l+"px",t.canvas.style.height=f+"px"}return t.isCheckDisplay=!0,[l,f]},makeWasm:function(){if(null!=t.config.token){t.vcodecerPtr=n.cwrap("registerPlayer","number",["string","string"])(t.config.token,u.PLAYER_VERSION);var e=n.addFunction((function(e,i,r,a,s,l,f,u,h){var c=n.HEAPU8.subarray(e,e+a*u),d=n.HEAPU8.subarray(i,i+s*u/2),_=n.HEAPU8.subarray(r,r+l*u/2),p=new Uint8Array(c),m=new Uint8Array(d),b=new Uint8Array(_),v=1*h/1e3,y=new o.CacheYuvStruct(v,a,u,p,m,b);t.cacheYuvBuf.appendCacheByCacheYuv(y)}));n.cwrap("setCodecType","number",["number","number","number"])(t.vcodecerPtr,t.config.videoCodec,e);n.cwrap("initMissile","number",["number"])(t.vcodecerPtr);n.cwrap("initializeDecoder","number",["number"])(t.vcodecerPtr)}else alert("请输入TOKEN!Please set token param!")},makeIt:function(){var e=document.querySelector("div#"+t.config.playerId),i=document.createElement("canvas");i.style.width=e.clientWidth+"px",i.style.height=e.clientHeight+"px",i.style.top="0px",i.style.left="0px",e.appendChild(i),t.canvasBox=e,t.canvas=i,t.yuv=l.setupCanvas(i,{preserveDrawingBuffer:!1}),0==t.config.audioNone&&(t.audio=a({sampleRate:t.config.sampleRate,appendType:t.config.appendHevcType})),t.isPlayLoadingFinish=1}};return t.makeWasm(),t.makeIt(),t.cacheThread(),t}},{"../consts":198,"../render-engine/webgl-420p":219,"../version":222,"./audio-core":199,"./cache":203,"./cacheYuv":204,"./missile.js":1}],208:[function(e,t,i){"use strict";var r=e("./bufferFrame");t.exports=function(){var e={videoBuffer:[],audioBuffer:[],idrIdxBuffer:[],appendFrame:function(t,i){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=new r.BufferFrame(t,a,i,n),o=parseInt(t);return n?(e.videoBuffer.length-1>=o?e.videoBuffer[o].push(s):e.videoBuffer.push([s]),a&&!e.idrIdxBuffer.includes(t)&&e.idrIdxBuffer.push(t)):e.audioBuffer.length-1>=o&&null!=e.audioBuffer[o]&&null!=e.audioBuffer[o]?e.audioBuffer[o]&&e.audioBuffer[o].push(s):e.audioBuffer.push([s]),!0},appendFrameWithDts:function(t,i,n){var a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=r.ConstructWithDts(t,i,s,n,a),l=parseInt(i);return a?(e.videoBuffer.length-1>=l?e.videoBuffer[l].push(o):e.videoBuffer.push([o]),s&&!e.idrIdxBuffer.includes(i)&&e.idrIdxBuffer.push(i)):e.audioBuffer.length-1>=l&&null!=e.audioBuffer[l]&&null!=e.audioBuffer[l]?e.audioBuffer[l]&&e.audioBuffer[l].push(o):e.audioBuffer.push([o]),!0},appendFrameByBufferFrame:function(t){var i=t.pts,r=parseInt(i);return t.video?(e.videoBuffer.length-1>=r?e.videoBuffer[r].push(t):e.videoBuffer.push([t]),isKey&&!e.idrIdxBuffer.includes(i)&&e.idrIdxBuffer.push(i)):e.audioBuffer.length-1>=r?e.audioBuffer[r].push(t):e.audioBuffer.push([t]),!0},cleanPipeline:function(){e.videoBuffer.length=0,e.audioBuffer.length=0},vFrame:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(!(t<0||t>e.videoBuffer.length-1))return e.videoBuffer[t]},aFrame:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(!(t<0||t>e.audioBuffer.length-1))return e.audioBuffer[t]},seekIDR:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;if(e.idrIdxBuffer,t<0)return null;if(e.idrIdxBuffer.includes(t))return t;for(var i=0;it){for(var r=1;r>=0;r--){var n=i-r;if(n>=0)return e.idrIdxBuffer[n]}return e.idrIdxBuffer[i]}}};return e}},{"./bufferFrame":209}],209:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i0&&i.extensionInfo.vHeight>0&&(i.size.width=i.extensionInfo.vWidth,i.size.height=i.extensionInfo.vHeight)),i.mediaInfo.duration,null!=i.onDemuxed&&i.onDemuxed(i.onReadyOBJ);for(var e=!1;;){var r=i.mpegTsObj.readPacket();if(r.size<=0)break;var n=r.dtime>0?r.dtime:r.ptime;if(!(n<0)){if(0==r.type){n<=i.vPreFramePTS&&(e=!0);var a=l.PACK_NALU(r.layer),o=1==r.keyframe,f=1==e?n+i.vStartTime:n,u=new s.BufferFrame(f,o,a,!0);i.bufObject.appendFrame(u.pts,u.data,!0,u.isKey),i.vPreFramePTS=f,null!=i.onSamples&&i.onSamples(i.onReadyOBJ,u)}else if(n<=i.aPreFramePTS&&(e=!0),"aac"==i.mediaInfo.aCodec)for(var h=r.data,c=0;c=3?(i._onTsReady(e),window.clearInterval(i.timerTsWasm),i.timerTsWasm=null):(i.mpegTsWasmRetryLoadTimes+=1,i.mpegTsObj.initDemuxer())}),3e3)}},{key:"_onTsReady",value:function(e){var t=this;t.hls.fetchM3u8(e),t.mpegTsWasmState=!0,t.timerFeed=window.setInterval((function(){if(t.tsList.length>0&&0==t.lockWait.state){var e=t.tsList.shift(),i=e.streamURI,r=e.streamDur;t.lockWait.state=!0,t.lockWait.lockMember.dur=r,t.mpegTsObj.demuxURL(i)}}),50)}},{key:"bindReady",value:function(e){this.onReadyOBJ=e}},{key:"popBuffer",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return t<0?null:1==e?this.bufObject.vFrame(t):2==e?this.bufObject.aFrame(t):void 0}},{key:"getACodec",value:function(){return this.aCodec}},{key:"getDurationMs",value:function(){return this.durationMs}},{key:"getFPS",value:function(){return this.fps}},{key:"getSampleRate",value:function(){return this.sampleRate}},{key:"getSize",value:function(){return this.size}},{key:"seek",value:function(e){if(e>=0){var t=this.bufObject.seekIDR(e);this.seekPos=t}}}])&&r(t.prototype,i),u&&r(t,u),e}();i.M3u8=u},{"../consts":198,"../decoder/hevc-imp":206,"./buffer":208,"./bufferFrame":209,"./m3u8base":211,"./mpegts/mpeg.js":215}],211:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i1?(i=t[0],r=t[1].split("/"),this._preURI=i+"//"):r=t[0].split("/");for(var n=0;nh&&(i=h);var c=t[s+=1],d=this._preURI+c;this._slices.indexOf(d)<0&&(this._slices.push(d),null!=this.onTransportStream&&this.onTransportStream(d,h))}}}if(this._slices.length>a.hlsSliceLimit&&this._type==n.PLAYER_IN_TYPE_M3U8_LIVE&&(this._slices=this._slices.slice(-1*a.hlsSliceLimit)),null!=this.onFinished){var _={type:this._type,duration:-1};this.onFinished(_)}return i}},{key:"_readTag",value:function(e){var t=a.tagParse.exec(e);return null!==t?{key:t[1],value:t[3]}:null}}])&&r(t.prototype,i),s&&r(t,s),e}();i.M3u8Base=s},{"../consts":198}],212:[function(e,t,i){"use strict";var r=e("mp4box"),n=e("../decoder/hevc-header"),a=e("../decoder/hevc-imp"),s=e("./buffer"),o=e("../consts"),l={96e3:0,88200:1,64e3:2,48e3:3,44100:4,32e3:5,24e3:6,22050:7,16e3:8,12e3:9,11025:10,8e3:11,7350:12,Reserved:13,"frequency is written explictly":15};function f(){}f.prototype.setStartCode=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=null;return t?((i=e)[0]=n.DEFINE_STARTCODE[0],i[1]=n.DEFINE_STARTCODE[1],i[2]=n.DEFINE_STARTCODE[2],i[3]=n.DEFINE_STARTCODE[3]):((i=new Uint8Array(n.DEFINE_STARTCODE.length+e.length)).set(n.DEFINE_STARTCODE,0),i.set(e,n.DEFINE_STARTCODE.length)),i},f.prototype.setAACAdts=function(e){var t=null,i=this.aacProfile,r=l[this.sampleRate],n=new Uint8Array(7),a=n.length+e.length;return n[0]=255,n[1]=241,n[2]=(i-1<<6)+(r<<2)+0,n[3]=128+(a>>11),n[4]=(2047&a)>>3,n[5]=31+((7&a)<<5),n[6]=252,(t=new Uint8Array(a)).set(n,0),t.set(e,n.length),t},f.prototype.demux=function(){var e=this;e.seekPos=-1,e.mp4boxfile=r.createFile(),e.movieInfo=null,e.videoCodec=null,e.durationMs=-1,e.fps=-1,e.sampleRate=-1,e.aacProfile=2,e.size={width:-1,height:-1},e.bufObject=s(),e.audioNone=!1,e.naluHeader={vps:null,sps:null,pps:null,sei:null},e.mp4boxfile.onError=function(e){},this.mp4boxfile.onReady=function(t){for(var i in e.movieInfo=t,t.tracks)"VideoHandler"!==t.tracks[i].name&&"video"!==t.tracks[i].type||(t.tracks[i].codec,t.tracks[i].codec.indexOf("hev")>=0||t.tracks[i].codec.indexOf("hvc")>=0?e.videoCodec=o.CODEC_H265:t.tracks[i].codec.indexOf("avc")>=0&&(e.videoCodec=o.CODEC_H264));var r=-1;if(r=t.videoTracks[0].samples_duration/t.videoTracks[0].timescale,e.durationMs=1e3*r,e.fps=t.videoTracks[0].nb_samples/r,e.seekDiffTime=1/e.fps,e.size.width=t.videoTracks[0].track_width,e.size.height=t.videoTracks[0].track_height,t.audioTracks.length>0){e.sampleRate=t.audioTracks[0].audio.sample_rate;var n=t.audioTracks[0].codec.split(".");e.aacProfile=n[n.length-1]}else e.audioNone=!0;null!=e.onMp4BoxReady&&e.onMp4BoxReady(e.videoCodec),e.videoCodec===o.CODEC_H265?(e.initializeAllSourceBuffers(),e.mp4boxfile.start()):(e.videoCodec,o.CODEC_H264)},e.mp4boxfile.onSamples=function(t,i,r){var s=window.setInterval((function(){for(var i=0;i3?e.naluHeader.sei=e.setStartCode(p[3][0].data,!1):e.naluHeader.sei=new Uint8Array,e.naluHeader}else e.videoCodec==o.CODEC_H264&&(e.naluHeader.vps=new Uint8Array,e.naluHeader.sps=e.setStartCode(c.SPS[0].nalu,!1),e.naluHeader.pps=e.setStartCode(c.PPS[0].nalu,!1),e.naluHeader.sei=new Uint8Array);if(f[4],e.naluHeader.vps[4],e.naluHeader.vps,f[4]===e.naluHeader.vps[4]){var m=e.naluHeader.vps.length+4,b=e.naluHeader.vps.length+e.naluHeader.sps.length+4,v=e.naluHeader.vps.length+e.naluHeader.sps.length+e.naluHeader.pps.length+4;if(e.naluHeader.sei.length<=0&&e.naluHeader.sps.length>0&&f[m]===e.naluHeader.sps[4]&&e.naluHeader.pps.length>0&&f[b]===e.naluHeader.pps[4]&&78===f[v]){f[e.naluHeader.vps.length+4],e.naluHeader.sps[4],f[e.naluHeader.vps.length+e.naluHeader.sps.length+4],e.naluHeader.pps[4],f[e.naluHeader.vps.length+e.naluHeader.sps.length+e.naluHeader.pps.length+4];for(var y=0,g=0;g4&&f[4]===e.naluHeader.sei[4]){var w=f.subarray(0,10),E=new Uint8Array(e.naluHeader.vps.length+w.length);E.set(w,0),E.set(e.naluHeader.vps,w.length),E[3]=1,e.naluHeader.vps=null,e.naluHeader.vps=new Uint8Array(E),E=null,w=null,(f=f.subarray(10))[4],e.naluHeader.vps[4],e.naluHeader.vps}else if(0===e.naluHeader.sei.length&&78===f[4]){f=e.setStartCode(f,!0);for(var C=0,S=0;S1&&void 0!==arguments[1]?arguments[1]:0;return e.fileStart=t,this.mp4boxfile.appendBuffer(e)},f.prototype.finishBuffer=function(){this.mp4boxfile.flush()},f.prototype.play=function(){},f.prototype.getVideoCoder=function(){return this.videoCodec},f.prototype.getDurationMs=function(){return this.durationMs},f.prototype.getFPS=function(){return this.fps},f.prototype.getSampleRate=function(){return this.sampleRate},f.prototype.getSize=function(){return this.size},f.prototype.seek=function(e){if(e>=0){var t=this.bufObject.seekIDR(e);this.seekPos=t}},f.prototype.popBuffer=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return t<0?null:1==e?this.bufObject.vFrame(t):2==e?this.bufObject.aFrame(t):void 0},f.prototype.addBuffer=function(e){var t=e.id;this.mp4boxfile.setExtractionOptions(t)},f.prototype.initializeAllSourceBuffers=function(){if(this.movieInfo){for(var e=this.movieInfo,t=0;t>5)}},{key:"sliceAACFrames",value:function(e,t){for(var i=[],r=e,n=0;n>4==15){var a=this._getPktLen(t[n+3],t[n+4],t[n+5]);if(a<=0)continue;var s=t.subarray(n,n+a),o=new Uint8Array(a);o.set(s,0),i.push({ptime:r,data:o}),r+=this.frameDurSec,n+=a}else n+=1;return i}}])&&r(t.prototype,i),n&&r(t,n),e}();i.AACDecoder=n},{}],215:[function(e,t,i){(function(t){"use strict";function r(e,t){for(var i=0;i=0&&(this._setMediaInfo(),this._setExtensionInfo(),null!=this.onDemuxed&&this.onDemuxed())}},{key:"_setMediaInfo",value:function(){var e=n.cwrap("getMediaInfo","number",[])(),t=n.HEAPU32[e/4],i=n.HEAPU32[e/4+1],r=n.HEAPF64[e/8+1],o=n.HEAPF64[e/8+1+1],l=n.HEAPF64[e/8+1+1+1],f=n.HEAPF64[e/8+1+1+1+1],u=n.HEAPU32[e/4+2+2+2+2+2];this.mediaAttr.vFps=r,this.mediaAttr.vGop=u,this.mediaAttr.vDuration=o,this.mediaAttr.aDuration=l,this.mediaAttr.duration=f;var h=n.cwrap("getAudioCodecID","number",[])();h>=0?(this.mediaAttr.aCodec=s.CODEC_OFFSET_TABLE[h],this.mediaAttr.sampleRate=t>0?t:s.DEFAULT_SAMPLERATE,this.mediaAttr.sampleChannel=i>0?i:s.DEFAULT_CHANNEL):(this.mediaAttr.sampleRate=0,this.mediaAttr.sampleChannel=0);var c=n.cwrap("getVideoCodecID","number",[])();c>=0&&(this.mediaAttr.vCodec=s.CODEC_OFFSET_TABLE[c]),null==this.aacDec?this.aacDec=new a.AACDecoder(this.mediaAttr):this.aacDec.updateConfig(this.mediaAttr)}},{key:"_setExtensionInfo",value:function(){var e=n.cwrap("getExtensionInfo","number",[])(),t=n.HEAPU32[e/4],i=n.HEAPU32[e/4+1];this.extensionInfo.vWidth=t,this.extensionInfo.vHeight=i}},{key:"readMediaInfo",value:function(){return this.mediaAttr}},{key:"readExtensionInfo",value:function(){return this.extensionInfo}},{key:"_readLayer",value:function(){var e={vps:null,sps:null,pps:null,sei:null},t={vlc:null},i=n.cwrap("getSPSLen","number",[])(),r=n.cwrap("getSPS","number",[])();e.sps=new Uint8Array(i),e.sps.set(n.HEAPU8.subarray(r,r+i),0);var a=n.cwrap("getPPSLen","number",[])(),o=n.cwrap("getPPS","number",[])();e.pps=new Uint8Array(a),e.pps.set(n.HEAPU8.subarray(o,o+a),0);var l=n.cwrap("getSEILen","number",[])(),f=n.cwrap("getSEI","number",[])();e.sei=new Uint8Array(l),e.sei.set(n.HEAPU8.subarray(f,f+l),0);var u=n.cwrap("getVLCLen","number",[])(),h=n.cwrap("getVLC","number",[])();if(t.vlc=new Uint8Array(u),t.vlc.set(n.HEAPU8.subarray(h,h+u),0),this.mediaAttr.vCodec==s.DEF_HEVC||this.mediaAttr.vCodec==s.DEF_H265){var c=n.cwrap("getVPSLen","number",[])(),d=n.cwrap("getVPS","number",[])();e.vps=new Uint8Array(c),e.vps.set(n.HEAPU8.subarray(d,d+c),0)}else this.mediaAttr.vCodec==s.DEF_AVC||(this.mediaAttr.vCodec,s.DEF_H264);return{nalu:e,vlc:t}}},{key:"readPacket",value:function(){var e=n.cwrap("getPacket","number",[])(),t=n.HEAPU32[e/4],i=n.HEAPU32[e/4+1],r=n.HEAPF64[e/8+1],a=n.HEAPF64[e/8+1+1],o=n.HEAPU32[e/4+1+1+2+2],l=n.HEAPU32[e/4+1+1+2+2+1],f=n.HEAPU8.subarray(l,l+i),u=this._readLayer();return{type:t,size:i,ptime:r,dtime:a,keyframe:o,src:f,data:1==t&&this.mediaAttr.aCodec==s.DEF_AAC?this.aacDec.sliceAACFrames(r,f):f,layer:u}}},{key:"_refreshDemuxer",value:function(){this._releaseDemuxer(),this._initDemuxer()}},{key:"_initDemuxer",value:function(){n.cwrap("initTsMissile","number",[])(),n.cwrap("initializeDemuxer","number",[])()}},{key:"_releaseDemuxer",value:function(){n.cwrap("exitTsMissile","number",[])()}}])&&r(i.prototype,o),l&&r(i,l),e}();i.MPEG_JS=o}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../decoder/missile.js":1,"./consts":213,"./decoder/aac":214}],216:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i0&&e.extensionInfo.vHeight>0&&(e.size.width=e.extensionInfo.vWidth,e.size.height=e.extensionInfo.vHeight);for(var t=null;!((t=e.mpegTsObj.readPacket()).size<=0);){var i=t.dtime;if(0==t.type){var r=s.PACK_NALU(t.layer),n=1==t.keyframe;e.bufObject.appendFrame(i,r,!0,n)}else if("aac"==e.mediaInfo.aCodec)for(var a=t.data,o=0;o0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return t<0?null:1==e?this.bufObject.vFrame(t):2==e?this.bufObject.aFrame(t):void 0}},{key:"getACodec",value:function(){return this.aCodec}},{key:"getDurationMs",value:function(){return this.durationMs}},{key:"getFPS",value:function(){return this.fps}},{key:"getSampleRate",value:function(){return this.sampleRate}},{key:"getSize",value:function(){return this.size}},{key:"seek",value:function(e){if(e>=0){var t=this.bufObject.seekIDR(e);this.seekPos=t}}}])&&r(t.prototype,i),o&&r(t,o),e}();i.MpegTs=o},{"../decoder/hevc-imp":206,"./buffer":208,"./mpegts/mpeg.js":215}],217:[function(e,t,i){(function(t){"use strict";function r(e,t){for(var i=0;i0&&void 0!==arguments[0]&&arguments[0];this.player.setScreen(e)}},{key:"play",value:function(){if(this.playParam.videoCodec===u.CODEC_H265){var e={seekPos:this._getSeekTarget(),mode:this.playMode,accurateSeek:this.configFormat.accurateSeek,seekEvent:!1,realPlay:!0};this.player.play(e)}else this.player.play();return!0}},{key:"pause",value:function(){return this.player.pause(),!0}},{key:"isPlaying",value:function(){return this.player.isPlayingState()}},{key:"setVoice",value:function(e){if(e<0)return!1;this.player.setVoice(e)}},{key:"mediaInfo",value:function(){return{meta:this.playParam,videoType:this.playMode}}},{key:"seek",value:function(e){var t=this;this.seekTarget=e,this.onSeekStart&&this.onSeekStart(e),this.timerFeed&&(window.clearInterval(this.timerFeed),this.timerFeed=null);var i=this._getSeekTarget();return this.playParam.videoCodec===u.CODEC_H264&&this.configFormat.type==u.PLAYER_IN_TYPE_MP4?(this.player.seek(e),this.onSeekFinish&&this.onSeekFinish()):this.configFormat.extInfo.core===u.PLAYER_CORE_TYPE_CNATIVE?this.player.seek((function(){}),{seekTime:i,mode:t.playMode,accurateSeek:t.configFormat.accurateSeek}):this.player.seek((function(){t.configFormat.type==u.PLAYER_IN_TYPE_MP4?t.mp4Obj.seek(e):t.configFormat.type==u.PLAYER_IN_TYPE_TS||t.configFormat.type==u.PLAYER_IN_TYPE_MPEGTS?t.mpegTsObj.seek(e):t.configFormat.type==u.PLAYER_IN_TYPE_M3U8&&t.hlsObj.seek(e);var i,r=(i=0,i=t.configFormat.accurateSeek?e:t._getBoxBufSeekIDR(),parseInt(i)),n=parseInt(t._getBoxBufSeekIDR())||0;t._avFeedMP4Data(n,r)}),{seekTime:i,mode:t.playMode,accurateSeek:t.configFormat.accurateSeek}),!0}},{key:"_durationText",value:function(e){if(e<0)return"Play";var t=Math.round(e);return Math.floor(t/3600)+":"+Math.floor(t%3600/60)+":"+Math.floor(t%60)}},{key:"_getSeekTarget",value:function(){return this.configFormat.accurateSeek?this.seekTarget:this._getBoxBufSeekIDR()}},{key:"_getBoxBufSeekIDR",value:function(){return this.configFormat.type==u.PLAYER_IN_TYPE_MP4?this.mp4Obj.seekPos:this.configFormat.type==u.PLAYER_IN_TYPE_TS||this.configFormat.type==u.PLAYER_IN_TYPE_MPEGTS?this.mpegTsObj.seekPos:this.configFormat.type==u.PLAYER_IN_TYPE_M3U8?this.hlsObj.seekPos:void 0}},{key:"_playControl",value:function(){this.isPlaying()?this.pause():this.play()}},{key:"_avFeedMP4Data",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=parseInt(this.playParam.durationMs/1e3);this.timerFeed=window.setInterval((function(){var a=null,s=null;if(e.configFormat.type==u.PLAYER_IN_TYPE_MP4?(a=e.mp4Obj.popBuffer(1,t),s=e.mp4Obj.audioNone?null:e.mp4Obj.popBuffer(2,i)):e.configFormat.type==u.PLAYER_IN_TYPE_TS||e.configFormat.type==u.PLAYER_IN_TYPE_MPEGTS?(a=e.mpegTsObj.popBuffer(1,t),s=e.mpegTsObj.audioNone?null:e.mpegTsObj.popBuffer(2,i)):e.configFormat.type==u.PLAYER_IN_TYPE_M3U8&&(a=e.hlsObj.popBuffer(1,t),s=e.hlsObj.audioNone?null:e.hlsObj.popBuffer(2,i)),null!=a)for(var o=0;on||e.player.getCachePTS()>n)return window.clearInterval(e.timerFeed),e.timerFeed=null,void(null!=r&&r())}),5)}},{key:"_makeMP4Player",value:function(){this.configFormat.type,null!=this.configFormat.extInfo.core&&null!==this.configFormat.extInfo.core&&this.configFormat.extInfo.core===u.PLAYER_CORE_TYPE_CNATIVE?this._cDemuxDecoderEntry():this.configFormat.type==u.PLAYER_IN_TYPE_MP4?this.configFormat.extInfo.moovStartFlag?this._mp4EntryVodStream():this._mp4Entry():this.configFormat.type==u.PLAYER_IN_TYPE_TS||this.configFormat.type==u.PLAYER_IN_TYPE_MPEGTS?this._mpegTsEntry():this.configFormat.type==u.PLAYER_IN_TYPE_M3U8?this._m3u8Entry():this.configFormat.type===u.PLAYER_IN_TYPE_RAW_265&&this._raw265Entry()}},{key:"_makeMP4PlayerViewEvent",value:function(e,t,i,r){var a=this,s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,l=this;if(this.playParam.durationMs=e,this.playParam.fps=t,this.playParam.sampleRate=i,this.playParam.size=r,this.playParam.audioNone=s,this.playParam.videoCodec=o||u.CODEC_H265,(this.configFormat.type==u.PLAYER_IN_TYPE_M3U8&&this.hlsConf.hlsType==u.PLAYER_IN_TYPE_M3U8_LIVE||this.configFormat.type==u.PLAYER_IN_TYPE_RAW_265)&&(this.playMode=u.PLAYER_MODE_NOTIME_LIVE),l.configFormat.extInfo.autoCrop){var f=document.querySelector("#"+this.configFormat.playerId),h=r.width/r.height,c=this.configFormat.playerW/this.configFormat.playerH;h>c?f.style.height=this.configFormat.playerW/h+"px":h>1,a>>1,i),e.v.fill(n>>1,a>>1,r),e.drawArrays(e.TRIANGLE_STRIP,0,4)},setupCanvas:function(e,t){var i=e.getContext("webgl")||e.getContext("experimental-webgl");if(!i)return i;var n=i.createProgram(),a=["attribute highp vec4 aVertexPosition;","attribute vec2 aTextureCoord;","varying highp vec2 vTextureCoord;","void main(void) {"," gl_Position = aVertexPosition;"," vTextureCoord = aTextureCoord;","}"].join("\n"),s=i.createShader(i.VERTEX_SHADER);i.shaderSource(s,a),i.compileShader(s);var o=["precision highp float;","varying lowp vec2 vTextureCoord;","uniform sampler2D YTexture;","uniform sampler2D UTexture;","uniform sampler2D VTexture;","const mat4 YUV2RGB = mat4","("," 1.1643828125, 0, 1.59602734375, -.87078515625,"," 1.1643828125, -.39176171875, -.81296875, .52959375,"," 1.1643828125, 2.017234375, 0, -1.081390625,"," 0, 0, 0, 1",");","void main(void) {"," gl_FragColor = vec4( texture2D(YTexture, vTextureCoord).x, texture2D(UTexture, vTextureCoord).x, texture2D(VTexture, vTextureCoord).x, 1) * YUV2RGB;","}"].join("\n"),l=i.createShader(i.FRAGMENT_SHADER);i.shaderSource(l,o),i.compileShader(l),i.attachShader(n,s),i.attachShader(n,l),i.linkProgram(n),i.useProgram(n),i.getProgramParameter(n,i.LINK_STATUS);var f=i.getAttribLocation(n,"aVertexPosition");i.enableVertexAttribArray(f);var u=i.getAttribLocation(n,"aTextureCoord");i.enableVertexAttribArray(u);var h=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,h),i.bufferData(i.ARRAY_BUFFER,new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0]),i.STATIC_DRAW),i.vertexAttribPointer(f,3,i.FLOAT,!1,0,0);var c=i.createBuffer();return i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,new Float32Array([1,0,0,0,1,1,0,1]),i.STATIC_DRAW),i.vertexAttribPointer(u,2,i.FLOAT,!1,0,0),i.y=new r(i),i.u=new r(i),i.v=new r(i),i.y.bind(0,n,"YTexture"),i.u.bind(1,n,"UTexture"),i.v.bind(2,n,"VTexture"),i}}},{}],220:[function(e,t,i){(function(e){"use strict";e.STATIC_MEM_wasmDecoderState=-1,e.STATICE_MEM_playerCount=-1,e.STATICE_MEM_playerIndexPtr=0}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],221:[function(e,t,i){"use strict";function r(e,t){for(var i=0;i= t.playParams.seekPos && !t.isNewSeek || 0 === t.playParams.seekPos || 0 === t.playParams.seekPos ? (t.frameTime = 1e3 / t.config.fps, t.frameTimeSec = t.frameTime / 1e3, 0 == t.config.audioNone && t.audio.play(), t.realVolume = t.config.audioNone ? 0 : t.audio.voice, t.playParams.seekEvent && (t.fix_poc_err_skip = 10), t.loop = window.setInterval(function () { + t.playParams = e, t.calcuteStartTime = h(), t.noCacheFrame = 0, t.isPlaying = t.playParams.realPlay, t.videoPTS >= t.playParams.seekPos && !t.isNewSeek || 0 === t.playParams.seekPos || 0 === t.playParams.seekPos ? (t.frameTime = 1e3 / t.config.fps, t.frameTimeSec = t.frameTime / 1e3, 0 == t.config.audioNone && t.audio.play(), t.realVolume = t.config.audioNone ? 0 : t.audio.voice, t.playParams.seekEvent && (t.fix_poc_err_skip = 10), t.loop = window.setInterval(function () { var e = h(); t.playFunc(), t.preCostTime = h() - e, t.preCostTime; }, 1)) : (t.loop = window.setInterval(function () { @@ -25048,7 +25045,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } -require('./h265webjs-v20210516'); +require('./h265webjs-v20210518'); var h265webjs = /*#__PURE__*/ @@ -25076,7 +25073,7 @@ function () { exports["default"] = h265webjs; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./h265webjs-v20210516":1}],3:[function(require,module,exports){ +},{"./h265webjs-v20210518":1}],3:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -25425,6 +25422,8 @@ global.makeH265webjs = function (videoURL, config) { var showLabel = document.querySelector('#showLabel'); var ptsLabel = document.querySelector('#ptsLabel'); var fullScreenBtn = document.querySelector('#fullScreenBtn'); + var coverToast = document.querySelector('#coverLayer'); + var coverBtn = document.querySelector('#coverLayerBtn'); var mediaInfo = null; playBar.disabled = true; playBar.textContent = '>'; @@ -25527,10 +25526,23 @@ global.makeH265webjs = function (videoURL, config) { progressPts.hidden = true; cachePts.hidden = true; ptsLabel.textContent = 'LIVE'; - setTimeout(function () { + + if (mediaInfo.meta.audioNone === true) { playBar.textContent = '||'; h265webjs.play(); - }, 1000); + } else { + coverToast.removeAttribute('hidden'); + + coverBtn.onclick = function () { + playBar.textContent = '||'; + h265webjs.play(); + coverToast.setAttribute('hidden', 'hidden'); + }; + } //setTimeout(() => { + //playBar.textContent = '||'; + //h265webjs.play(); + //}, 1000); + } showLabel.textContent = SHOW_DONE; diff --git a/index.html b/index.html index d3a71594..061763a9 100644 --- a/index.html +++ b/index.html @@ -13,6 +13,21 @@ body { background-color: #eeeeee; } + #coverLayer { + width: 100%; + height: 100%; + padding-top: 300px; + z-index: 10000; + position: absolute; + top: 0px; + left: 0px; + background-color: rgba(0, 0, 0, 0.5); + } + #coverLayerBtn { + width: 20%; + height: 200px; + border-radius: 50px; + } #controller { background-color: black; width: 960px; @@ -133,6 +148,12 @@ + +

h265web.js demo

@@ -188,10 +209,12 @@

h265web.js demo

// var type = "ts"; // var url = "res/hls/v-000.ts" - // var type = "hls"; + //var type = "hls"; // var url = "res/m3u82/cg720phevc.m3u8"; // var url = "res/m3u8/cg.m3u8"; // var url = "res/hls/veilside.m3u8"; + //var url = "res/hls/veilside_live.m3u8"; + //var url = "res/hls-an/veilside_live.m3u8"; // var url = "res/hls1/test.m3u8"; const PLAYER_CORE_TYPE_DEFAULT = 0; // 默认内核 recommand!!!!!! diff --git a/play.js b/play.js index 32ada657..2ef01775 100644 --- a/play.js +++ b/play.js @@ -31,6 +31,8 @@ global.makeH265webjs = (videoURL, config) => { let showLabel = document.querySelector('#showLabel'); let ptsLabel = document.querySelector('#ptsLabel'); let fullScreenBtn = document.querySelector('#fullScreenBtn'); + let coverToast = document.querySelector('#coverLayer'); + let coverBtn = document.querySelector('#coverLayerBtn'); let mediaInfo = null; playBar.disabled = true; @@ -131,10 +133,24 @@ global.makeH265webjs = (videoURL, config) => { progressPts.hidden = true; cachePts.hidden = true; ptsLabel.textContent = 'LIVE'; - setTimeout(() => { + + if (mediaInfo.meta.audioNone === true) { playBar.textContent = '||'; h265webjs.play(); - }, 1000); + } else { + coverToast.removeAttribute('hidden'); + coverBtn.onclick = () => { + playBar.textContent = '||'; + h265webjs.play(); + coverToast.setAttribute('hidden', 'hidden'); + }; + } + + //setTimeout(() => { + //playBar.textContent = '||'; + //h265webjs.play(); + //}, 1000); + } showLabel.textContent = SHOW_DONE;