var PlayerControl=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=74)}([function(t,e,n){"use strict";t.exports={ATOM_MOOV:"moov",ATOM_MVHD:"mvhd",ATOM_TRAK:"trak",ATOM_TKHD:"tkhd",ATOM_MDIA:"mdia",ATOM_MDHD:"mdhd",ATOM_MINF:"minf",ATOM_HDLR:"hdlr",ATOM_VMHD:"vmhd",ATOM_SMHD:"smhd",ATOM_STBL:"stbl",ATOM_STSZ:"stsz",ATOM_STCO:"stco",ATOM_STSS:"stss",ATOM_STTS:"stts",ATOM_STSC:"stsc",ATOM_CO64:"co64",ATOM_STSD:"stsd",ATOM_CTTS:"ctts",ATOM_AVC1:"avc1",ATOM_AVCC:"avcC",ATOM_HEV1:"hev1",ATOM_HVC1:"hvc1",ATOM_HVCC:"hvcC",ATOM_MP4A:"mp4a",ATOM_ESDS:"esds",ATOM_MDAT:"mdat",ATOM_FTYP:"ftyp",TRACK_TYPE_VIDEO:"vide",TRACK_TYPE_AUDIO:"soun",COMPONENT_NAME_VIDEO:"VideoHandler",COMPONENT_NAME_AUDIO:"SoundHandler",COMPRESSOR_NAME:"NodeVideoLibrary",createAtom:function(t){return new(n(63)("./atom-"+t))}}},function(t,e,n){"use strict";function r(t,e){for(var n=0;n=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function y(t,e){if(s.isBuffer(t))return t.length;if("undefined"!==typeof ArrayBuffer&&"function"===typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!==typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return V(t).length;default:if(r)return z(t).length;e=(""+e).toLowerCase(),r=!0}}function d(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function m(t,e,n,r,o){if(0===t.length)return-1;if("string"===typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"===typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,o);if("number"===typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"===typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,n,r,o){var i,a=1,u=t.length,s=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;a=2,u/=2,s/=2,n/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var f=-1;for(i=n;iu&&(n=u-s),i=n;i>=0;i--){for(var l=!0,h=0;ho&&(r=o):r=o;var i=e.length;if(i%2!==0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function _(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function E(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o239?4:c>223?3:c>191?2:1;if(o+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128===(192&(i=t[o+1]))&&(s=(31&c)<<6|63&i)>127&&(f=s);break;case 3:i=t[o+1],a=t[o+2],128===(192&i)&&128===(192&a)&&(s=(15&c)<<12|(63&i)<<6|63&a)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:i=t[o+1],a=t[o+2],u=t[o+3],128===(192&i)&&128===(192&a)&&128===(192&u)&&(s=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&u)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),o+=l}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var n="",r=0;for(;rthis.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return E(this,e,n);case"ascii":return k(this,e,n);case"latin1":case"binary":return R(this,e,n);case"base64":return _(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},s.prototype.compare=function(t,e,n,r,o){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),u=Math.min(i,a),c=this.slice(r,o),f=t.slice(e,n),l=0;lo)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return g(this,t,e,n);case"ascii":return w(this,t,e,n);case"latin1":case"binary":return S(this,t,e,n);case"base64":return O(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function k(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;or)&&(n=r);for(var o="",i=e;in)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,n,r,o,i){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function M(t,e,n,r){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);o>>8*(r?o:1-o)}function B(t,e,n,r){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);o>>8*(r?o:3-o)&255}function D(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(t,e,n,r,i){return i||D(t,0,n,4),o.write(t,e,n,r,23,4),n+4}function j(t,e,n,r,i){return i||D(t,0,n,8),o.write(t,e,n,r,52,8),n+8}s.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(o*=256);)r+=this[t+--e]*o;return r},s.prototype.readUInt8=function(t,e){return e||x(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||x(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||x(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||x(t,e,this.length);for(var r=this[t],o=1,i=0;++i=(o*=128)&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||x(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},s.prototype.readInt8=function(t,e){return e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||x(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){e||x(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||x(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||x(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||x(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||x(t,8,this.length),o.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||I(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i=0&&(i*=256);)this[e+o]=t/i&255;return e+n},s.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):B(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);I(this,t,e,n,o-1,-o)}var i=0,a=1,u=0;for(this[e]=255&t;++i>0)-u&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);I(this,t,e,n,o-1,-o)}var i=n-1,a=1,u=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/a>>0)-u&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):B(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,n){return U(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return U(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return j(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return j(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--o)t[o+e]=this[o+n];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"===typeof t)for(i=e;i55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function V(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(L,"")).length<2)return"";for(;t.length%4!==0;)t+="=";return t}(t))}function N(t,e,n,r){for(var o=0;o=e.length||o>=t.length);++o)e[o+n]=t[o];return o}}).call(this,n(56))},function(t,e,n){"use strict";function r(t){return(r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){var n;if("undefined"===typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"===typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(t,e)}(t))||e&&t&&"number"===typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==n.return||n.return()}finally{if(s)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&(r+=n*(o+1)),r}},{key:"writeUInt64BE",value:function(t,e,n){var r=0,i=e;e>o&&(r=e/(o+1)<<0,i=e%(o+1)),t.writeUInt32BE(r,n),t.writeUInt32BE(i,n+4)}}],(n=null)&&r(e.prototype,n),i&&r(e,i),t}();t.exports=i},function(t,e,n){"use strict";function r(t){return(r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var n=0;n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==n.return||n.return()}finally{if(s)throw a}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&-1!==[o.ATOM_FTYP,o.ATOM_MOOV,o.ATOM_MDAT].indexOf(t.toString("ascii",4,8))}}],(n=null)&&r(e.prototype,n),a&&r(e,a),t}();t.exports=a},function(t,e,n){"use strict";function r(t){return(r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var n=0;n>7&1)&&(n+=2),1===(r>>6&1)&&(n+=t[n]+1),1===(r>>5&1)&&(n+=2);n13&&5===t[n++]&&(n+=(i=f(t,n)).read,this.extraData=e.allocUnsafe(i.size),t.copy(this.extraData,0,n,n+i.size));break}n+=i.size}}},{key:"build",value:function(t,e){t.writeUInt32BE(this.bufferSize(),e),t.write(this.type(),e+4),e+=8,e+=4,t[e++]=3,t[e++]=23+this.extraData.length,t.writeUInt16BE(this.streamId,e),e+=2,t[e++]=0,t[e++]=4,t[e++]=15+this.extraData.length,t[e++]=64,t[e++]=21,e+=11,t[e++]=5,t[e++]=this.extraData.length,this.extraData.copy(t,e),e+=this.extraData.length,t[e++]=6,t[e++]=1,t[e++]=2}},{key:"bufferSize",value:function(){return 37+this.extraData.length}}])&&o(n.prototype,r),u&&o(n,u),h}();t.exports=l}).call(this,n(2).Buffer)},function(t,e,n){"use strict";function r(t){return(r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var n=0;n0&&(n+=16);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==n.return||n.return()}finally{if(s)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&0===this.fragments[this.fragments.length-1].duration&&this.fragments.splice(this.fragments.length-2,1)}},{key:"relativeDuration",value:function(){return this.timescale?this.duration/this.timescale:this.duration||0}},{key:"size",value:function(){return[this.video,this.audio].filter(function(t){return null!==t}).reduce(function(t,e){return t+e.size},0)}},{key:"count",value:function(){return this.fragments.length}},{key:"get",value:function(t){var e=this.fragments[t];if(e){var n=new o;return n.timestamp=e.timestamp,n.duration=e.duration,n.samples=e.samples,n.timescale=this.timescale,this.video&&(n.videoExtraData=this.video.extraData),this.audio&&(n.audioExtraData=this.audio.extraData),n}}}])&&r(e.prototype,n),i&&r(e,i),t}();t.exports=i},function(t,e,n){"use strict";(function(e){function r(t,e){for(var n=0;n=c.offset+c.size?(c.bufferIndex=i.length-1,c.bufferOffset=c.offset-a.offset):(a={offset:c.offset,size:1048576,buffer:e.allocUnsafe(1048576)},i.push(a),c.bufferIndex=i.length-1,c.bufferOffset=0)}for(var f=o.create(n),l=0,h=i.length;l0?a-4:a;for(n=0;n>16&255,s[f++]=e>>8&255,s[f++]=255&e;2===u&&(e=o[t.charCodeAt(n)]<<2|o[t.charCodeAt(n+1)]>>4,s[f++]=255&e);1===u&&(e=o[t.charCodeAt(n)]<<10|o[t.charCodeAt(n+1)]<<4|o[t.charCodeAt(n+2)]>>2,s[f++]=e>>8&255,s[f++]=255&e);return s},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],a=0,u=n-o;au?u:a+16383));1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return i.join("")};for(var r=[],o=[],i="undefined"!==typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,s=a.length;u0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function f(t,e,n){for(var o,i,a=[],u=e;u>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,o){var i,a,u=8*o-r-1,s=(1<>1,f=-7,l=n?o-1:0,h=n?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=u;f>0;i=256*i+t[e+l],l+=h,f-=8);for(a=i&(1<<-f)-1,i>>=-f,f+=r;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===i)i=1-c;else{if(i===s)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),i-=c}return(p?-1:1)*a*Math.pow(2,i-r)},e.write=function(t,e,n,r,o,i){var a,u,s,c=8*i-o-1,f=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,y=r?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-a))<1&&(a--,s*=2),(e+=a+l>=1?h/s:h*Math.pow(2,1-l))*s>=2&&(a++,s/=2),a+l>=f?(u=0,a=f):a+l>=1?(u=(e*s-1)*Math.pow(2,o),a+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,o),a=0));o>=8;t[n+p]=255&u,p+=y,u/=256,o-=8);for(a=a<0;t[n+p]=255&a,p+=y,a/=256,c-=8);t[n+p-y]|=128*d}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";(function(e){function r(t){return(r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var n=0;n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==n.return||n.return()}finally{if(s)throw a}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&(P=S[0],B=S[1]);for(var D=new Array(w.length),U=0,j=0,L=T.length;j=g[2*C]&&(C++,x=0)),V.compositionOffset=N,M0&&(D[U++]=V),++R=S[3*P]&&(B=S[3*P+1],P++)),E+=F,I++}U0&&this.movie.addTrack(y)}}}}}}])&&i(n.prototype,o),d&&i(n,d),t}();t.exports=d}).call(this,n(2).Buffer)},function(t,e,n){"use strict";function r(t){return(r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var n=0;n>3,this.rateIndex=((7&t)<<1)+((128&e)>>7&1),this.sampleRate=f[this.rateIndex]||null,this.channelsIndex=(127&e)>>3,this.channels=l[this.channelsIndex]||null}},{key:"codec",value:function(){return"mp4a.40.".concat(this.profileObjectType)}}])&&o(e.prototype,n),r&&o(e,r),h}();t.exports=h},function(t,e,n){"use strict";function r(t){return(r="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var n=0;n>5&1),n=this.extraData.readUInt32LE(2).toString(16).replace(/0+$/,""),r=this.extraData[12],o=[],i=6;i<12;i++)o.push(this.extraData[i]);for(var a=0,u=o.length-1;u>0;u--)if(o[u]>0){a=u;break}for(var s=["hvc1",(t>>6)+(31&t),n,"".concat(e?"H":"L").concat(r)],c=0;c<=a;c++)s.push(o[c].toString(16).replace(/0+$/,""));return s.join(".")}},{key:"_readNalUnit",value:function(){var t=this.extraData.readUInt16BE(this._pos);this._pos+=2;var e=this.extraData.slice(this._pos,this._pos+t);return this._pos+=t,e}}])&&o(e.prototype,n),r&&o(e,r),f}();t.exports=f},function(t,e,n){"use strict";(function(e){function r(t,e){for(var n=0;n0&&(e.sortSamples(),e.ensureDuration(),t.movie.addTrack(e))}),this.movie.ensureDuration(),this.movie}},{key:"_parseHeader",value:function(){var t=e.allocUnsafe(i.HEADER_SIZE);if(this.reader.read(t,0),t.toString("ascii",0,3)!==i.HEADER_PREFIX||t[3]!==i.HEADER_VERSION)throw new Error("FLV header not found");this.pos=t[8]}},{key:"_createMovie",value:function(){this.movie=new a,this.movie.timescale=i.MOVIE_TIMESCALE,this.videoTrack=new s,this.videoTrack.timescale=i.MOVIE_TIMESCALE,this.audioTrack=new u,this.audioTrack.timescale=i.MOVIE_TIMESCALE}},{key:"_parseBody",value:function(){for(var t=e.allocUnsafe(15),n=this.reader.size();this.pos1){var a=r[1];if(void 0!==a.duration){var u=a.duration*i.MOVIE_TIMESCALE;this.movie.duration=u,this.videoTrack.duration=u,this.audioTrack.duration=u}void 0!==a.width&&(this.videoTrack.width=a.width),void 0!==a.height&&(this.videoTrack.height=a.height)}}},{key:"_parseAudio",value:function(t,n){var r=e.allocUnsafe(2);this.reader.read(r,this.pos);var o=r[0],a=1&o,u=(2&o)>>1,s=(12&o)>>2,f=(240&o)>>4;if(i.AUDIO_FORMAT_AAC===f)if(0===r[1]){this.audioTrack.channels=1===a?2:1,this.audioTrack.sampleRate=5512.5*(1<>4,s=r.readUIntBE(2,3);if(i.VIDEO_FORMAT_H264===a)if(0===r[1]){var c=e.allocUnsafe(4+t-5);c.write("avcC"),this.reader.read(c,this.pos+5,4),this.videoTrack.extraData=c,this.videoTrack.codec=h.parse(c).codec()}else{var l=Object.create(f.prototype);l.timestamp=n,l.timescale=this.videoTrack.timescale,l.size=t-5,l.offset=this.pos+5,l.compositionOffset=s,l.keyframe=1===u,0>29&14|240&r|1,t[e+1]=n>>22,t[e+2]=n>>14|1,t[e+3]=n>>7,t[e+4]=n<<1|1,5}},{key:"_writePid",value:function(t,e,n){return t[e+0]=224+(n>>8&31),t[e+1]=255&n,t[e+2]=240,t[e+3]=0,4}}],(r=[{key:"packFragment",value:function(){var t=[],n=0,r=90*this.fragment.timescale,o=this._buildHeader();t.push(o),n+=o.length;for(var i=[],a=0,u=null,f=0,l=function(){var r=this._packAudioPayload(e.concat(i,a),u,f);t.push(r),n+=r.length,i=[],a=0}.bind(this),h=0,p=this.fragment.samples.length;h0&&l();var b=m+(r*y.compositionOffset/y.timescale<<0),g=this._convertVideoSample(d,y.keyframe),w=this._packVideoPayload(g,y,b,m);t.push(w),n+=w.length}}return i.length>0&&l(),e.concat(t,n)}},{key:"_convertAudioSample",value:function(t){var n=7+t.length,r=e.allocUnsafe(n);return r[0]=255,r[1]=241,r[2]=((this._audioCodecInfo.profileObjectType-1&3)<<6)+(this._audioCodecInfo.rateIndex<<2&60)+(this._audioCodecInfo.channelsIndex>>2&1)&255,r[3]=(3&this._audioCodecInfo.channelsIndex)<<6&255,r[5]=5+((7&n)<<5)&255,n>>=3,r[4]=255&n,n>>=8,r[3]+=3&n,r[6]=4092,t.copy(r,7),r}},{key:"_convertVideoSample",value:function(t,n){var r=6+t.length+(n?this._videoConfig.length:0);this._videoCodecInfo.type()===l.CODEC_H265&&r++;var o=e.allocUnsafe(r),i=0;for(o.writeUInt32BE(1,i),i+=4,this._videoCodecInfo.type()===l.CODEC_H265?(o[i++]=70,o[i++]=1):o[i++]=9,o[i++]=16,n&&(this._videoConfig.copy(o,i),i+=this._videoConfig.length),t.copy(o,i);i>8&255,i[a++]=255&u,i[a++]=128,i[a++]=128,i[a++]=5,a+=t._writeTime(i,a,o,32),n.copy(i,a),this._packPayload(i,r,257,o)}},{key:"_packVideoPayload",value:function(n,r,o,i){var a=e.allocUnsafe(19+n.length),u=0;return a[u++]=0,a[u++]=0,a[u++]=1,a[u++]=224,a[u++]=0,a[u++]=0,a[u++]=128,a[u++]=192,a[u++]=10,u+=t._writeTime(a,u,o,48),u+=t._writeTime(a,u,i,16),n.copy(a,u),this._packPayload(a,r,256,i)}},{key:"_packPayload",value:function(t,n,r,o){var i=Math.ceil(t.length/184);n instanceof s&&184*i-8>8&31),a[h++]=255&r,a[h++]=this._counter.next(n)+(l?48:16),l){var p=0;if(n instanceof s&&0===c&&(p=7),f<183&&(p=Math.max(p,183-f)),a[h++]=p,0>25&255,a[h+2]=o>>17&255,a[h+3]=o>>9&255,a[h+4]=o>>1&255,a[h+5]=(1&o)<<7|126,a[h+6]=0),a[h]=d,h+=y,y>8&15),n[r++]=255&o,n[r++]=0,n[r++]=1,n[r++]=193,n[r++]=0,n[r++]=0,n[r++]=0,n[r++]=1,n[r++]=239,n[r++]=255,n.writeInt32BE(a.checksum(n,r-o+1,r),r),(r+=4)<188&&(n.fill(-1,r,188),r+=188-r),n[r++]=71,n[r++]=79,n[r++]=255,n[r++]=16,n[r++]=0,o=13;var i=0;return this.fragment.hasAudio()&&(o+=5,i=257),this.fragment.hasVideo()&&(o+=5,i=256),n[r++]=2,n[r++]=176+(o>>8&15),n[r++]=255&o,n[r++]=0,n[r++]=1,n[r++]=193,n[r++]=0,n[r++]=0,r+=t._writePid(n,r,i),this.fragment.hasVideo()&&(n[r++]=h[this._videoCodecInfo.type()]||0,r+=t._writePid(n,r,256)),this.fragment.hasAudio()&&(n[r++]=h[this._audioCodecInfo.type()]||0,r+=t._writePid(n,r,257)),n.writeInt32BE(a.checksum(n,r-o+1,r),r),(r+=4)<376&&n.fill(-1,r),n}},{key:"_buildVideoConfig",value:function(){for(var t=this._videoCodecInfo.units(),n=e.allocUnsafe(4*t.length+t.reduce(function(t,e){return t+e.length},0)),r=0,o=0,i=t.length;o>8&16777215;return(i=a)>>>24|i>>8&65280|i<<8&16711680|i<<24}}},function(t,e,n){"use strict";function r(t,e){for(var n=0;n-1||t.indexOf("edge/")>-1?(n="ie","Microsoft Internet Explorer"===e?(t=/msie ([0-9]{1,}[\.0-9]{0,})/.exec(t),n+=parseInt(t[1])):t.indexOf("trident")>-1?n+=11:t.indexOf("edge/")>-1&&(n="edge")):t.indexOf("safari")>-1?n=t.indexOf("chrome")>-1?"chrome":"safari":t.indexOf("firefox")>-1&&(n="firefox"),n}var i=function(){function t(){}return t.createFromElementId=function(e){for(var n=document.getElementById(e),r="",o=n.firstChild;o;)3===o.nodeType&&(r+=o.textContent),o=o.nextSibling;var i=new t;return i.type=n.type,i.source=r,i},t.createFromSource=function(e,n){var r=new t;return r.type=e,r.source=n,r},t}(),a=function(){return function(t,e){if("x-shader/x-fragment"===e.type)this.shader=t.createShader(t.FRAGMENT_SHADER);else{if("x-shader/x-vertex"!==e.type)return void error("Unknown shader type: "+e.type);this.shader=t.createShader(t.VERTEX_SHADER)}t.shaderSource(this.shader,e.source),t.compileShader(this.shader),t.getShaderParameter(this.shader,t.COMPILE_STATUS)||error("An error occurred compiling the shaders: "+t.getShaderInfoLog(this.shader))}}(),u=function(){function t(t){this.gl=t,this.program=this.gl.createProgram()}return t.prototype={attach:function(t){this.gl.attachShader(this.program,t.shader)},link:function(){this.gl.linkProgram(this.program)},use:function(){this.gl.useProgram(this.program)},getAttributeLocation:function(t){return this.gl.getAttribLocation(this.program,t)},setMatrixUniform:function(t,e){var n=this.gl.getUniformLocation(this.program,t);this.gl.uniformMatrix4fv(n,!1,e)}},t}(),s=function(){var t=null;function e(t,e,n){this.gl=t,this.size=e,this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),this.format=n||t.LUMINANCE,t.texImage2D(t.TEXTURE_2D,0,this.format,e.w,e.h,0,this.format,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}return e.prototype={fill:function(t,e){var n=this.gl;n.bindTexture(n.TEXTURE_2D,this.texture),e?n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.size.w,this.size.h,this.format,n.UNSIGNED_BYTE,t):n.texImage2D(n.TEXTURE_2D,0,this.format,this.size.w,this.size.h,0,this.format,n.UNSIGNED_BYTE,t)},bind:function(e,n,r){var o=this.gl;t||(t=[o.TEXTURE0,o.TEXTURE1,o.TEXTURE2]),o.activeTexture(t[e]),o.bindTexture(o.TEXTURE_2D,this.texture),o.uniform1i(o.getUniformLocation(n.program,r),e)}},e}();var c=1e-6;function f(){}function l(){}function h(){}function p(){}f.prototype={e:function(t){return t<1||t>this.elements.length?null:this.elements[t-1]},dimensions:function(){return this.elements.length},modulus:function(){return Math.sqrt(this.dot(this))},eql:function(t){var e=this.elements.length,n=t.elements||t;if(e!=n.length)return!1;do{if(Math.abs(this.elements[e-1]-n[e-1])>c)return!1}while(--e);return!0},dup:function(){return f.create(this.elements)},map:function(t){var e=[];return this.each(function(n,r){e.push(t(n,r))}),f.create(e)},each:function(t){var e,n=this.elements.length,r=n;do{e=r-n,t(this.elements[e],e+1)}while(--n)},toUnitVector:function(){var t=this.modulus();return 0===t?this.dup():this.map(function(e){return e/t})},angleFrom:function(t){var e=t.elements||t,n=this.elements.length;if(n!=e.length)return null;var r=0,o=0,i=0;if(this.each(function(t,n){r+=t*e[n-1],o+=t*t,i+=e[n-1]*e[n-1]}),o=Math.sqrt(o),i=Math.sqrt(i),o*i===0)return null;var a=r/(o*i);return a<-1&&(a=-1),a>1&&(a=1),Math.acos(a)},isParallelTo:function(t){var e=this.angleFrom(t);return null===e?null:e<=c},isAntiparallelTo:function(t){var e=this.angleFrom(t);return null===e?null:Math.abs(e-Math.PI)<=c},isPerpendicularTo:function(t){var e=this.dot(t);return null===e?null:Math.abs(e)<=c},add:function(t){var e=t.elements||t;return this.elements.length!=e.length?null:this.map(function(t,n){return t+e[n-1]})},subtract:function(t){var e=t.elements||t;return this.elements.length!=e.length?null:this.map(function(t,n){return t-e[n-1]})},multiply:function(t){return this.map(function(e){return e*t})},x:function(t){return this.multiply(t)},dot:function(t){var e=t.elements||t,n=0,r=this.elements.length;if(r!=e.length)return null;do{n+=this.elements[r-1]*e[r-1]}while(--r);return n},cross:function(t){var e=t.elements||t;if(3!=this.elements.length||3!=e.length)return null;var n=this.elements;return f.create([n[1]*e[2]-n[2]*e[1],n[2]*e[0]-n[0]*e[2],n[0]*e[1]-n[1]*e[0]])},max:function(){var t,e=0,n=this.elements.length,r=n;do{t=r-n,Math.abs(this.elements[t])>Math.abs(e)&&(e=this.elements[t])}while(--n);return e},indexOf:function(t){var e,n=null,r=this.elements.length,o=r;do{e=o-r,null===n&&this.elements[e]==t&&(n=e+1)}while(--r);return n},toDiagonalMatrix:function(){return l.Diagonal(this.elements)},round:function(){return this.map(function(t){return Math.round(t)})},snapTo:function(t){return this.map(function(e){return Math.abs(e-t)<=c?t:e})},distanceFrom:function(t){if(t.anchor)return t.distanceFrom(this);var e=t.elements||t;if(e.length!=this.elements.length)return null;var n,r=0;return this.each(function(t,o){n=t-e[o-1],r+=n*n}),Math.sqrt(r)},liesOn:function(t){return t.contains(this)},liesIn:function(t){return t.contains(this)},rotate:function(t,e){var n,r,o,i,a;switch(this.elements.length){case 2:return 2!=(n=e.elements||e).length?null:(r=l.Rotation(t).elements,o=this.elements[0]-n[0],i=this.elements[1]-n[1],f.create([n[0]+r[0][0]*o+r[0][1]*i,n[1]+r[1][0]*o+r[1][1]*i]));case 3:if(!e.direction)return null;var u=e.pointClosestTo(this).elements;return r=l.Rotation(t,e.direction).elements,o=this.elements[0]-u[0],i=this.elements[1]-u[1],a=this.elements[2]-u[2],f.create([u[0]+r[0][0]*o+r[0][1]*i+r[0][2]*a,u[1]+r[1][0]*o+r[1][1]*i+r[1][2]*a,u[2]+r[2][0]*o+r[2][1]*i+r[2][2]*a]);default:return null}},reflectionIn:function(t){if(t.anchor){var e=this.elements.slice(),n=t.pointClosestTo(e).elements;return f.create([n[0]+(n[0]-e[0]),n[1]+(n[1]-e[1]),n[2]+(n[2]-(e[2]||0))])}var r=t.elements||t;return this.elements.length!=r.length?null:this.map(function(t,e){return r[e-1]+(r[e-1]-t)})},to3D:function(){var t=this.dup();switch(t.elements.length){case 3:break;case 2:t.elements.push(0);break;default:return null}return t},inspect:function(){return"["+this.elements.join(", ")+"]"},setElements:function(t){return this.elements=(t.elements||t).slice(),this}},f.create=function(t){return(new f).setElements(t)},f.i=f.create([1,0,0]),f.j=f.create([0,1,0]),f.k=f.create([0,0,1]),f.Random=function(t){var e=[];do{e.push(Math.random())}while(--t);return f.create(e)},f.Zero=function(t){var e=[];do{e.push(0)}while(--t);return f.create(e)},l.prototype={e:function(t,e){return t<1||t>this.elements.length||e<1||e>this.elements[0].length?null:this.elements[t-1][e-1]},row:function(t){return t>this.elements.length?null:f.create(this.elements[t-1])},col:function(t){if(t>this.elements[0].length)return null;var e,n=[],r=this.elements.length,o=r;do{e=o-r,n.push(this.elements[e][t-1])}while(--r);return f.create(n)},dimensions:function(){return{rows:this.elements.length,cols:this.elements[0].length}},rows:function(){return this.elements.length},cols:function(){return this.elements[0].length},eql:function(t){var e=t.elements||t;if("undefined"==typeof e[0][0]&&(e=l.create(e).elements),this.elements.length!=e.length||this.elements[0].length!=e[0].length)return!1;var n,r,o,i=this.elements.length,a=i,u=this.elements[0].length;do{n=a-i,r=u;do{if(o=u-r,Math.abs(this.elements[n][o]-e[n][o])>c)return!1}while(--r)}while(--i);return!0},dup:function(){return l.create(this.elements)},map:function(t){var e,n,r,o=[],i=this.elements.length,a=i,u=this.elements[0].length;do{n=u,o[e=a-i]=[];do{r=u-n,o[e][r]=t(this.elements[e][r],e+1,r+1)}while(--n)}while(--i);return l.create(o)},isSameSizeAs:function(t){var e=t.elements||t;return"undefined"==typeof e[0][0]&&(e=l.create(e).elements),this.elements.length==e.length&&this.elements[0].length==e[0].length},add:function(t){var e=t.elements||t;return"undefined"==typeof e[0][0]&&(e=l.create(e).elements),this.isSameSizeAs(e)?this.map(function(t,n,r){return t+e[n-1][r-1]}):null},subtract:function(t){var e=t.elements||t;return"undefined"==typeof e[0][0]&&(e=l.create(e).elements),this.isSameSizeAs(e)?this.map(function(t,n,r){return t-e[n-1][r-1]}):null},canMultiplyFromLeft:function(t){var e=t.elements||t;return"undefined"==typeof e[0][0]&&(e=l.create(e).elements),this.elements[0].length==e.length},multiply:function(t){if(!t.elements)return this.map(function(e){return e*t});var e=!!t.modulus;if("undefined"==typeof(y=t.elements||t)[0][0]&&(y=l.create(y).elements),!this.canMultiplyFromLeft(y))return null;var n,r,o,i,a,u,s=this.elements.length,c=s,f=y[0].length,h=this.elements[0].length,p=[];do{p[n=c-s]=[],r=f;do{o=f-r,i=0,a=h;do{u=h-a,i+=this.elements[n][u]*y[u][o]}while(--a);p[n][o]=i}while(--r)}while(--s);var y=l.create(p);return e?y.col(1):y},x:function(t){return this.multiply(t)},minor:function(t,e,n,r){var o,i,a,u=[],s=n,c=this.elements.length,f=this.elements[0].length;do{u[o=n-s]=[],i=r;do{a=r-i,u[o][a]=this.elements[(t+o-1)%c][(e+a-1)%f]}while(--i)}while(--s);return l.create(u)},transpose:function(){var t,e,n,r=this.elements.length,o=this.elements[0].length,i=[],a=o;do{i[t=o-a]=[],e=r;do{n=r-e,i[t][n]=this.elements[n][t]}while(--e)}while(--a);return l.create(i)},isSquare:function(){return this.elements.length==this.elements[0].length},max:function(){var t,e,n,r=0,o=this.elements.length,i=o,a=this.elements[0].length;do{t=i-o,e=a;do{n=a-e,Math.abs(this.elements[t][n])>Math.abs(r)&&(r=this.elements[t][n])}while(--e)}while(--o);return r},indexOf:function(t){var e,n,r,o=this.elements.length,i=o,a=this.elements[0].length;do{e=i-o,n=a;do{if(r=a-n,this.elements[e][r]==t)return{i:e+1,j:r+1}}while(--n)}while(--o);return null},diagonal:function(){if(!this.isSquare)return null;var t,e=[],n=this.elements.length,r=n;do{t=r-n,e.push(this.elements[t][t])}while(--n);return f.create(e)},toRightTriangular:function(){var t,e,n,r,o=this.dup(),i=this.elements.length,a=i,u=this.elements[0].length;do{if(e=a-i,0==o.elements[e][e])for(j=e+1;jc){o++;break}}while(--e)}while(--i);return o},rk:function(){return this.rank()},augment:function(t){var e=t.elements||t;"undefined"==typeof e[0][0]&&(e=l.create(e).elements);var n,r,o,i=this.dup(),a=i.elements[0].length,u=i.elements.length,s=u,c=e[0].length;if(u!=e.length)return null;do{n=s-u,r=c;do{o=c-r,i.elements[n][a+o]=e[n][o]}while(--r)}while(--u);return i},inverse:function(){if(!this.isSquare()||this.isSingular())return null;var t,e,n,r,o,i,a,u=this.elements.length,s=u,c=this.augment(l.I(u)).toRightTriangular(),f=c.elements[0].length,h=[];do{o=[],n=f,h[t=u-1]=[],i=c.elements[t][t];do{r=f-n,a=c.elements[t][r]/i,o.push(a),r>=s&&h[t].push(a)}while(--n);for(c.elements[t]=o,e=0;e3||e.elements.length>3)return null;var n=e.modulus();return 0===n?null:(this.anchor=t,this.direction=f.create([e.elements[0]/n,e.elements[1]/n,e.elements[2]/n]),this)}},h.create=function(t,e){return(new h).setVectors(t,e)},h.X=h.create(f.Zero(3),f.i),h.Y=h.create(f.Zero(3),f.j),h.Z=h.create(f.Zero(3),f.k),p.prototype={eql:function(t){return this.contains(t.anchor)&&this.isParallelTo(t)},dup:function(){return p.create(this.anchor,this.normal)},translate:function(t){var e=t.elements||t;return p.create([this.anchor.elements[0]+e[0],this.anchor.elements[1]+e[1],this.anchor.elements[2]+(e[2]||0)],this.normal)},isParallelTo:function(t){var e;return t.normal?(e=this.normal.angleFrom(t.normal),Math.abs(e)<=c||Math.abs(Math.PI-e)<=c):t.direction?this.normal.isPerpendicularTo(t.direction):null},isPerpendicularTo:function(t){var e=this.normal.angleFrom(t.normal);return Math.abs(Math.PI/2-e)<=c},distanceFrom:function(t){if(this.intersects(t)||this.contains(t))return 0;if(t.anchor){var e=this.anchor.elements,n=t.anchor.elements,r=this.normal.elements;return Math.abs((e[0]-n[0])*r[0]+(e[1]-n[1])*r[1]+(e[2]-n[2])*r[2])}var o=t.elements||t;e=this.anchor.elements,r=this.normal.elements;return Math.abs((e[0]-o[0])*r[0]+(e[1]-o[1])*r[1]+(e[2]-(o[2]||0))*r[2])},contains:function(t){if(t.normal)return null;if(t.direction)return this.contains(t.anchor)&&this.contains(t.anchor.add(t.direction));var e=t.elements||t,n=this.anchor.elements,r=this.normal.elements;return Math.abs(r[0]*(n[0]-e[0])+r[1]*(n[1]-e[1])+r[2]*(n[2]-(e[2]||0)))<=c},intersects:function(t){return"undefined"==typeof t.direction&&"undefined"==typeof t.normal?null:!this.isParallelTo(t)},intersectionWith:function(t){if(!this.intersects(t))return null;if(t.direction){var e=t.anchor.elements,n=t.direction.elements,r=this.anchor.elements,o=((a=this.normal.elements)[0]*(r[0]-e[0])+a[1]*(r[1]-e[1])+a[2]*(r[2]-e[2]))/(a[0]*n[0]+a[1]*n[1]+a[2]*n[2]);return f.create([e[0]+n[0]*o,e[1]+n[1]*o,e[2]+n[2]*o])}if(t.normal){for(var i=this.normal.cross(t.normal).toUnitVector(),a=this.normal.elements,u=(e=this.anchor.elements,t.normal.elements),s=t.anchor.elements,c=l.Zero(2,2),p=0;c.isSingular();)p++,c=l.create([[a[p%3],a[(p+1)%3]],[u[p%3],u[(p+1)%3]]]);for(var y=c.inverse().elements,d=a[0]*e[0]+a[1]*e[1]+a[2]*e[2],m=u[0]*s[0]+u[1]*s[1]+u[2]*s[2],v=[y[0][0]*d+y[0][1]*m,y[1][0]*d+y[1][1]*m],b=[],g=1;g<=3;g++)b.push(p==g?0:v[(g+(5-p)%3)%3]);return h.create(b,i)}},pointClosestTo:function(t){var e=t.elements||t,n=this.anchor.elements,r=this.normal.elements,o=(n[0]-e[0])*r[0]+(n[1]-e[1])*r[1]+(n[2]-(e[2]||0))*r[2];return f.create([e[0]+r[0]*o,e[1]+r[1]*o,(e[2]||0)+r[2]*o])},rotate:function(t,e){var n=l.Rotation(t,e.direction).elements,r=e.pointClosestTo(this.anchor).elements,o=this.anchor.elements,i=this.normal.elements,a=r[0],u=r[1],s=r[2],c=o[0]-a,f=o[1]-u,h=o[2]-s;return p.create([a+n[0][0]*c+n[0][1]*f+n[0][2]*h,u+n[1][0]*c+n[1][1]*f+n[1][2]*h,s+n[2][0]*c+n[2][1]*f+n[2][2]*h],[n[0][0]*i[0]+n[0][1]*i[1]+n[0][2]*i[2],n[1][0]*i[0]+n[1][1]*i[1]+n[1][2]*i[2],n[2][0]*i[0]+n[2][1]*i[1]+n[2][2]*i[2]])},reflectionIn:function(t){if(t.normal){var e=this.anchor.elements,n=this.normal.elements,r=e[0],o=e[1],i=e[2],a=n[0],u=n[1],s=n[2],c=this.anchor.reflectionIn(t).elements,f=r+a,l=o+u,h=i+s,y=t.pointClosestTo([f,l,h]).elements,d=[y[0]+(y[0]-f)-c[0],y[1]+(y[1]-l)-c[1],y[2]+(y[2]-h)-c[2]];return p.create(c,d)}if(t.direction)return this.rotate(Math.PI,t);var m=t.elements||t;return p.create(this.anchor.reflectionIn([m[0],m[1],m[2]||0]),this.normal)},setVectors:function(t,e,n){if(null===(t=(t=f.create(t)).to3D()))return null;if(null===(e=(e=f.create(e)).to3D()))return null;if("undefined"==typeof n)n=null;else if(null===(n=(n=f.create(n)).to3D()))return null;var r,o,i=t.elements[0],a=t.elements[1],u=t.elements[2],s=e.elements[0],c=e.elements[1],l=e.elements[2];if(null!==n){var h=n.elements[0],p=n.elements[1],y=n.elements[2];if(0===(o=(r=f.create([(c-a)*(y-u)-(l-u)*(p-a),(l-u)*(h-i)-(s-i)*(y-u),(s-i)*(p-a)-(c-a)*(h-i)])).modulus()))return null;r=f.create([r.elements[0]/o,r.elements[1]/o,r.elements[2]/o])}else{if(0===(o=Math.sqrt(s*s+c*c+l*l)))return null;r=f.create([e.elements[0]/o,e.elements[1]/o,e.elements[2]/o])}return this.anchor=t,this.normal=r,this}},l.Translation=function(t){var e;if(2===t.elements.length)return(e=l.I(3)).elements[2][0]=t.elements[0],e.elements[2][1]=t.elements[1],e;if(3===t.elements.length)return(e=l.I(4)).elements[0][3]=t.elements[0],e.elements[1][3]=t.elements[1],e.elements[2][3]=t.elements[2],e;throw"Invalid length for Translation"},l.prototype.flatten=function(){var t=[];if(0===this.elements.length)return[];for(var e=0;e4||this.elements[0].length>4)return null;for(t=0;t>>1,n.prototype.h>>>1)},length:function(){return n.prototype.w*n.prototype.h}},new n(t,e)}O.prototype.alloc=function(){var t=null;return 0===this._objpool.length?(t=new Image,this.metrics.totalalloc++):(t=this._objpool.pop(),this.metrics.totalfree--),t},O.prototype.free=function(t){t.length>0&&(r.log("It is not zero length = "+t.length),this._objpool.push(t),this.metrics.totalfree++)},O.prototype.collect=function(t){this._objpool=[];var e=this.metrics.totalalloc-this.metrics.totalfree;this._clearMetrics(e)},O.prototype._clearMetrics=function(t){this.metrics.totalalloc=t||0,this.metrics.totalfree=0};var _=function(t,e,n,o){var i=e,a=o,u=t,s=n,c=null,f=null,l=null,h=null,p=null,y=null,d=null,m=null,w=0,S=null,_=0,E=0,A=0,k=0,R=new O,P=null,C="",x=!1,I=!1,M=16.7,B=0,D=!1,U={},j=[],L=function(t,e,n,r,o,i,a,u){for(var s in function(t){this.buffer=t,this.previous=null,this.next=null}.call(this,t),this.width=e,this.height=n,this.codecType=r,this.frameType=o,this.timeStamp=i,this.frameIndex=a,this.option={},u)this.option[s]=u[s]},F=null;function z(){var t=a||15;function e(){this.first=null,this.size=0}return e.prototype={enqueue:function(e,n,r,o,i,a,u,s){this.size>=t&&this.clear();var c=new L(e,n,r,o,i,a,u,s);if(null===this.first)this.first=c;else{for(var f=this.first;null!==f.next;)f=f.next;f.next=c}return this.size+=1,c},dequeue:function(){var t=null;return null!==this.first&&(t=this.first,this.first=this.first.next,this.size-=1),t},clear:function(){r.log("BufferQueue clear!");for(var t=null;null!==this.first;)t=this.first,this.first=this.first.next,this.size-=1,t.buffer=null,t=null;this.size=0,this.first=null}},new e}function V(){h="rgb2d",y=null,F=new z,p=M,I=!1}var N=function(t,e){var n=new T(t,e);switch(h){case"RGB2d":c=new RGB2dCanvas(s,n);break;case"YUVWebGL":c=new g(s,n);break;case"ImageWebGL":c=new b(s,n);break;case"WebGL":c=new v(s,n)}};function H(t,e){var n=s.width,r=s.height,o=document.createElement("canvas");o.width=n,o.height=r;for(var i=o.getContext("2d"),a=0;a0)){if("undefined"!==typeof f&&"undefined"!==typeof l&&f===P.width&&l===P.height&&y===P.codecType||(h="h264"===P.codecType||"h265"===P.codecType?"YUVWebGL":"ImageWebGL",N(P.width,P.height),"undefined"!=f&&null!=f&&0!=f||d("PlayStart"),f=P.width,l=P.height,y=P.codecType),S=P.timeStamp,i.timeStamp(S),"undefined"!==typeof c)return c.drawCanvas(P.buffer,P.option),s.updatedCanvas=!0,m(S),Math.abs(S.timestamp-_)>3&&i.waitingCallback(!1),I||((U=P).src=s.toDataURL()),_=S.timestamp,x&&(x=!1,H([s].concat(j),C)),"mjpeg"===P.codecType?R.free(P.buffer):(delete P.buffer,P.buffer=null),P.previous=null,P.next=null,P=null,!0;r.log("drawer is undefined in StreamDrawer!")}return!1},q=function t(e){if(!0===I){if(0===w||e-w<200)return 0===w&&(w=e),void(null!==F&&window.requestAnimationFrame(t));(k+=e-E)>A&&W()&&(A+=p),k>1e3&&(A=0,k=0),E=e,window.requestAnimationFrame(t)}};return V.prototype={getDrawingStrategy:function(){return h},reassignCanvas:function(){var t=$('canvas[kind-channel-id="'+u+'"]')[0];s!==t&&(f=0,l=0)},drawMJPEG:function(t,e,n,r,o,i,a,u){var s=R.alloc();s.width=e,s.height=n,s.codecType=r,s.frameType=o,s.frameIndex=a,s.time=i,s.onload=function(){null!==F&&F.enqueue(this,this.width,this.height,this.codecType,this.frameType,this.time,this.frameIndex,this.option)},s.setAttribute("src","data:image/jpeg;base64,"+function(t){for(var e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=new Uint8Array(t),o=r.byteLength,i=o%3,a=o-i,u=0,s=0;s>18]+n[(258048&u)>>12]+n[(4032&u)>>6]+n[63&u];return 1===i?e+=n[(252&(u=r[a]))>>2]+n[(3&u)<<4]+"==":2===i&&(e+=n[(64512&(u=r[a]<<8|r[a+1]))>>10]+n[(1008&u)>>4]+n[(15&u)<<2]+"="),e}(t))},draw:function(t,e,n,r,o,i,a,u){null!==F&&(document.hidden&&F.size>=15?F.clear():F.enqueue(t,e,n,r,o,i,a,u))},capture:function(t,e){C=t,x=!0,j=e.ivsCanvasArr},digitalZoom:function(t){"undefined"!==typeof c&&null!==c&&c.updateVertexArray(t)},setResizeCallback:function(t){},getCodecType:function(){return y},getFrameTimestamp:function(){return S},initStartTime:function(){0===w&&window.requestAnimationFrame(q)},startRendering:function(){0===w&&(I=!0,window.requestAnimationFrame(q))},pause:function(){I=!1},play:function(){I=!0},stopRendering:function(){I=!1,w=0},setFPS:function(t){"undefined"===typeof t?p=M:0===t?p=M:p=1e3/t,B=p},setFrameInterval:function(t){p=t*B},getCanvas:function(){return s},renewCanvas:function(){N(f,l),"undefined"!==typeof c&&null!==c&&c.initCanvas()},setBeginDrawCallback:function(t){d=t},setupdateCanvasCallback:function(t){m=t},terminate:function(){w=0,S=null,null!==F&&(F.clear(),F=null),c&&c.clearCanvas(),c=null,D=!1},setRtspOver:function(){D=!0},playNextFrame:W,getVideoBufferQueueSize:function(){return F.size},getCurFrameInfo:function(){return U}},new V},E=n(49),A=n.n(E),k=n(20),R=n.n(k);var P=function(t){var e=null,n="",i=null,a=null,u=null,s=null,c=null,f=1,l={timestamp:0,timestamp_usec:0,timezone:0},h={timestamp:0,timestamp_usec:0,timezone:0},p=null,y=!1,d=null,m=null,v=null,b=!1,g=!0,w=0,S=t,O=!1,T=[],_=.5,E=null,A=null,k=null,R=0,P=0,C=!1,x=null,I=o(),M=null,B=0,D=0,U=0,j=8,L=null,F=!1,z=!1,V=[],N=[],H={},Y=25,W=.5;function q(){}function G(){Z()}function X(){var t=0;if(null!==d)for(t=0;t0)return r.count("1.segmentWaitDecode.length: "+T.length),T.push(t),void r.count("2.segmentWaitDecode.length: "+T.length);k.updating?(r.log("updating.........."),T.push(t)):(k.appendBuffer(t),F&&(H.frameIndex=e,H.buffer=t,H.src=function(){var t=document.createElement("canvas");return t.width=E.videoWidth,t.height=E.videoHeight,t.getContext("2d").drawImage(E,0,0,t.width,t.height),t.toDataURL()}()))}catch(t){r.log("videoMediaSource::appendNextMediaSegment error >> initVideo"),T.length=0,S.initVideo(!1),L&&L({errorCode:101})}}function J(){E.paused&&(a(),b||F||E.play())}function Q(){E.paused||g||(r.log("pause"),E.pause())}function $(){V.length&&K(V.shift(),N.shift())}function tt(){if(null!==A)try{if(k&&k.buffered.length>0&&(function(){var t=1*k.buffered.start(k.buffered.length-1),e=1*k.buffered.end(k.buffered.length-1);e-t>60&&k.remove(t,e-10)}(),z&&!F||E.duration>W&&(E.currentTime=(E.duration-W).toFixed(3),W+=Y<10?.5:.1),E&&E.duration-E.currentTime>j&&L&&L({errorCode:101}),O&&!y)){var t=1*k.buffered.start(k.buffered.length-1),e=1*k.buffered.end(k.buffered.length-1);if((0===E.currentTime?e-t:e-E.currentTime)>=_+.1){if(r.log("\u8df3\u79d2"),k.updating)return;var n=e-_;E.currentTime=n.toFixed(3)}}}catch(t){r.log("sourceBuffer has been removed")}}function et(){}function nt(){T.length>0&&(r.count("1. onSourceUpdate .segmentWaitDecode.length: "+T.length),k.updating||(r.count("2. onSourceUpdate .appendBuffer: "+T.length+" "+T[0].length),k.appendBuffer(T[0]),T.shift()))}function rt(){r.log("videoMediaSource::onSourceError")}function ot(){r.log("videoMediaSource::onSourceBufferErrormsg")}function it(){r.log("videoMediaSource::onError"),Q(),L&&L({errorCode:101})}function at(){b=!0,g=!1,z=!0,r.log("playing "),C||(C=!0,s("PlayStart"))}function ut(){b=!1,g=!0,r.log("\u6682\u505c\u64ad\u653e----------------------------------------------")}function st(){var t=parseInt(A.duration,10),e=parseInt(E.currentTime,10),n={timestamp:l.timestamp-f*(t-e+(1!==f?1:0)),timestamp_usec:0,timezone:l.timezone};0===e||isNaN(t)||(y&&S.waitingCallback(!1),!y&&Math.abs(t-e)>4&&1===f||E.paused||(null===p?(p=n,u(0,"currentTime")):(p.timestamp<=n.timestamp&&f>=1||p.timestamp>n.timestamp&&f<1)&&(y&&S.timeStamp(n),p=n,++w>4&&u(n.timestamp,"currentTime"))))}function ct(){J(),tt()}function ft(){a()}function lt(){J()}function ht(){if(r.log("\u9700\u8981\u7f13\u51b2\u4e0b\u4e00\u5e27"),O=!1,y&&b&&S.waitingCallback(!0),0==P)R=Date.now(),P++;else{P++;var t=Date.now()-R;r.log("diffTime: "+t+" Count: "+P),P>=5&&t<6e4&&_<=1.8&&(_+=.1,P=0,R=0,r.log("delay + 0.1 = "+_))}}function pt(){r.log("Can play !")}function yt(){r.log("Can play without waiting"),O=!0}function dt(){r.log("loadedmetadata")}function mt(t,e,n){for(var r=t.width,o=t.height,i=t.getContext("2d"),a=0;a3;0===h.timestamp&&S.timeStamp(t),!0===e&&(w=0,u((h=t).timestamp,"init"),0!==l.timestamp&&y&&(E.currentTime=A.duration-.1,S.waitingCallback(!1)),p=null),l=t},pause:function(){F=!0,Q()},play:function(){F=!1},setPlaybackFlag:function(t){y=t},setTimeStampInit:function(){p=null,h={timestamp:0,timestamp_usec:0,timezone:0}},close:function(){X(),Q()},setBeginDrawCallback:function(t){s=t},setErrorCallback:function(t){L=t},terminate:function(){null!==E&&(X(),"open"===A.readyState&&(k&&A.removeSourceBuffer(k),A.endOfStream()),k=null,k=null,A=null,E=null,x&&(clearInterval(x),x=null),M&&(clearInterval(M),M=null),U=0,D=0,B=0)},getDuration:function(){return E.duration-E.currentTime},setFPS:function(t){t&&(Y=t)},setRtspOver:function(){E.duration.toFixed(4)-0===E.currentTime.toFixed(4)-0?(S.timeStamp(l),S.fileOverCallback()):(B=parseInt(E.currentTime),D=parseInt(E.duration),M=setInterval(function(){B===parseInt(E.currentTime)&&D===parseInt(E.duration)?U++>10&&(M&&clearInterval(M),M=null,S.timeStamp(l),S.fileOverCallback()):parseInt(E.currentTime)>=parseInt(E.duration)?(M&&clearInterval(M),M=null,S.timeStamp(l),S.fileOverCallback()):(B=parseInt(E.currentTime),D=parseInt(E.duration),U=0)},150))},getVideoBufferQueueSize:function(){return V.length},playNextFrame:function(){$()},getCurFrameInfo:function(){return H}};var vt=function(t){var e=t.document,n=function(){return t.URL||t.webkitURL||t},r=e.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,i=/constructor/i.test(t.HTMLElement),a=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(e){(t.setImmediate||t.setTimeout)(function(){throw e},0)},s=function(t){setTimeout(function(){"string"===typeof t?n().revokeObjectURL(t):t.remove()},4e4)},c=function(t){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob([String.fromCharCode(65279),t],{type:t.type}):t},f=function(e,f,l){l||(e=c(e));var h,p=this,y="application/octet-stream"===e.type,d=function(){!function(t,e,n){for(var r=(e=[].concat(e)).length;r--;){var o=t["on"+e[r]];if("function"===typeof o)try{o.call(t,n||t)}catch(t){u(t)}}}(p,"writestart progress write writeend".split(" "))};if(p.readyState=p.INIT,o)return h=n().createObjectURL(e),void setTimeout(function(){r.href=h,r.download=f,function(t){var e=new MouseEvent("click");t.dispatchEvent(e)}(r),d(),s(h),p.readyState=p.DONE});!function(){if((a||y&&i)&&t.FileReader){var r=new FileReader;return r.onloadend=function(){var e=a?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");t.open(e,"_blank")||(t.location.href=e),e=void 0,p.readyState=p.DONE,d()},r.readAsDataURL(e),void(p.readyState=p.INIT)}h||(h=n().createObjectURL(e)),y?t.location.href=h:t.open(h,"_blank")||(t.location.href=h),p.readyState=p.DONE,d(),s(h)}()},l=f.prototype;return"undefined"!==typeof navigator&&navigator.msSaveOrOpenBlob?function(t,e,n){return e=e||t.name||"download",n||(t=c(t)),navigator.msSaveOrOpenBlob(t,e)}:(l.readyState=l.INIT=0,l.WRITING=1,l.DONE=2,l.error=l.onwritestart=l.onprogress=l.onwrite=l.onabort=l.onerror=l.onwriteend=null,function(t,e,n){return new f(t,e||t.name||"download",n)})}(window);return new q},C=new function(){var t=[],e={};function n(){for(var n in t)t[n]=[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)];e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}t={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var o=function(t){for(var e=8,n=Array.prototype.slice.call(arguments,1),r=0;r>>24&255,o[i++]=e>>>16&255,o[i++]=e>>>8&255,o[i++]=255&e,o.set(t,i),i+=4,r=0;r>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),function(e){var n=e.config,r=n.length,i=new Uint8Array([0,0,0,0,3,23+r,0,1,0,4,15+r,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([r]).concat(n).concat([6,1,2]));return o(t.esds,i)}(e))},a=function(n){return"audio"===n.type?o(t.stsd,e.STSD_PREFIX,i(n)):o(t.stsd,e.STSD_PREFIX,function(e){var n=e.sps||[],r=e.pps||[],i=[],a=[],u=0;for(u=0;u>>8),i.push(255&n[u].byteLength),i=i.concat(Array.prototype.slice.call(n[u]));for(u=0;u>>8),a.push(255&r[u].byteLength),a=a.concat(Array.prototype.slice.call(r[u]));return o(t.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o(t.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([n.length]).concat(i).concat([r.length]).concat(a))))}(n))},u=function(n){var r=null;return r="audio"===n.type?o(t.smhd,e.SMHD):o(t.vmhd,e.VMHD),o(t.minf,r,o(t.dinf,o(t.dref,e.DREF)),function(n){return o(t.stbl,a(n),o(t.stts,e.STTS),o(t.stsc,e.STSC),o(t.stsz,e.STSZ),o(t.stco,e.STCO))}(n))},s=function(n){return o(t.mdia,function(e){var n=e.timescale,r=e.duration;return o(t.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r,85,196,0,0]))}(n),function(n){var r=null;return r="audio"===n.type?e.HDLR_AUDIO:e.HDLR_VIDEO,o(t.hdlr,r)}(n),u(n))},c=function(e){return o(t.trak,function(e){var n=e.id,r=e.duration,i=e.width,a=e.height;return o(t.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>>8&255,255&i,0,0,a>>>8&255,255&a,0,0]))}(e),s(e))},f=function(e){return o(t.mvex,function(e){var n=e.id,r=new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return o(t.trex,r)}(e))},l=function(e){var n,i,a=(n=e.timescale,i=e.duration,r.log("mvhd: timescale: "+n+" duration: "+i),o(t.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))),u=c(e),s=f(e);return o(t.moov,a,u,s)},h=function(e,n){return"audio"===e.type?audioTrun(e,n):function(e,n){var r,i=null,a=null,u=0,s=n;if(null===(r=e.samples||[])[0].frameDuration)for(s+=24+4*r.length,i=trunHeader(r,s),u=0;u>>24,(16711680&a.size)>>>16,(65280&a.size)>>>8,255&a.size]);else for(i=function(t,e){return[0,0,3,5,(4278190080&t.length)>>>24,(16711680&t.length)>>>16,(65280&t.length)>>>8,255&t.length,(4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e,0,0,0,0]}(r,s+=24+4*r.length+4*r.length),u=0;u>>24,(16711680&a.frameDuration)>>>16,(65280&a.frameDuration)>>>8,255&a.frameDuration,(4278190080&a.size)>>>24,(16711680&a.size)>>>16,(65280&a.size)>>>8,255&a.size]);return o(t.trun,new Uint8Array(i))}(e,n)},p=function(e,n){return o(t.moof,function(e){var n=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return o(t.mfhd,n)}(e),function(e){var n,r,i;return n=o(t.tfhd,new Uint8Array([0,2,0,0,0,0,0,1])),r=o(t.tfdt,new Uint8Array([0,0,0,0,e.baseMediaDecodeTime>>>24&255,e.baseMediaDecodeTime>>>16&255,e.baseMediaDecodeTime>>>8&255,255&e.baseMediaDecodeTime])),i=h(e,72),o(t.traf,n,r,i)}(n))};return n.prototype={initSegment:function(n){var i=o(t.ftyp,e.FTYP);r.log(n);var a=l(n),u=new Uint8Array(i.byteLength+a.byteLength);return u.set(i,0),u.set(a,i.byteLength),u},mediaSegment:function(e,n,r,i){var a=p(e,n),u=function(e){return o(t.mdat,e)}(r),s=null;return(s=new Uint8Array(a.byteLength+u.byteLength)).set(a),s.set(u,a.byteLength),s}},new n};function x(t){return(x="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var I=function(){var t={},e=null,n=a(),o=a();function i(t,e){this.data=t,this.timeStamp=e,this.next=null}function a(){function t(){this.first=null,this.size=0}return t.prototype={enqueue:function(t){if(null===this.first)this.first=t;else{for(var e=this.first;null!==e.next;)e=e.next;e.next=t}this.size+=1},dequeue:function(){var t=null;return null!==this.first&&(t=this.first,this.first=this.first.next,this.size-=1),t},clear:function(){this.size=0,this.first=null}},new t}function u(t,n){var r=n.first;if(r)if(t>r.timeStamp){for(;r&&t>r.timeStamp;)(r=n.dequeue())&&r.data&&2===r.data.type&&e&&e(r.data);r&&e&&e(r.data)}else tt||a<0)&&(s=0,d=0,p=!0,null!==m&&m.stop()),s-n.currentTime<0&&(s=0),f=o,y=function(t,e,n){var r=t;n+e.length>=r.length&&(r=new Float32Array(r.length+8e4)).set(r,0);return r.set(e,n),r}(y,r,d),d+=r.length,!p){var c=0;if(d/r.length>1&&(null!==h&&(c=h*e),c>=d||null===h))return void(d=0);var l=null;if(/Apple Computer/.test(navigator.vendor)&&/Safari/.test(navigator.userAgent))if(u.samplingRate<32e3){8e3==u.samplingRate?y=function(t){for(var e=0,n=0,r=0,o=0,i=(1-Math.cos(.2*Math.PI))/2,a=new Float32Array(4*t.length),u=0,s=0;u=1?1:n},getVolume:function(){return a},terminate:function(){n&&"closed"!==n.state&&(s=0,c=!1,n.close())},setBufferingFlag:function(t,e){"init"===e?l=t:p&&(0===t||"undefined"===typeof t||null===t?h=null:(h=t-l,l=0),p=!1)},getBufferingFlag:function(){return p},setInitVideoTimeStamp:function(t){l=t},getInitVideoTimeStamp:function(){return l},setSamplingRate:function(t){u.samplingRate=t},pause:function(){g=!0},timeUpdate:function(){},setRtspOver:function(){!0},audioPlayBegin:function(){},audioPlayEnd:function(){}},w=new A}var B=function(){var t=null,e=null,n=null,o=null,i=!1,a=null,u={audio:!0,video:!1},s=null;function c(){}return c.prototype={init:function(){if(void 0===t||null===t)try{window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.oAudioContext||window.msAudioContext,(t=new AudioContext).onstatechange=function(){r.info("Audio Context State changed :: "+t.state)}}catch(t){return void r.error("Web Audio API is not supported in this web browser! : "+t)}},initAudioOut:function(){if(null!==e&&null!==n||(e=t.createGain(),(n=t.createScriptProcessor(4096,1,1)).onaudioprocess=function(t){if(null!==a){var e=t.inputBuffer.getChannelData(0);null!==s&&!0===i&&s(e)}},e.connect(n),n.connect(t.destination),o=t.sampleRate,e.gain.value=1),void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(t,e,n){var r=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return r?new Promise(function(e,n){r.call(navigator,t,e,n)}):(n(),Promise.reject(new Error("getUserMedia is not implemented in this browser")))}),navigator.mediaDevices.getUserMedia)return navigator.mediaDevices.getUserMedia(u).then(function(n){a=n,t.createMediaStreamSource(n).connect(e)}).catch(function(t){r.error(t)}),i=!0,o;r.error("Cannot open local media stream! :: navigator.mediaDevices.getUserMedia is not defined!")},controlVolumnOut:function(t){var n=t/20*2;e.gain.value=n<=0?0:n>=10?10:n},stopAudioOut:function(){if(null!==a&&i)try{for(var t=a.getAudioTracks(),e=0,n=t.length;e2&&void 0!==arguments[2]?arguments[2]:null,u={type:"sdpInfo",data:{sdpInfo:o,aacCodecInfo:i,decodeMode:j,govLength:x,checkDelay:L,lessRateCanvas:St,mp4Codec:a}};if(D){e.postMessage(u);try{window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.oAudioContext||window.msAudioContext,(n=new U.a).onmessage=Ct,null===s&&((s=new B).init(),s.setSendAudioTalkBufferCallback(xt)),n.postMessage(u),u={type:"sampleRate",data:s.initAudioOut()},n.postMessage(u)}catch(t){return void r.error("Web Audio API is not supported in this web browser! : "+t)}}else t.postMessage(u),e.postMessage(u);ct=null,ot=!1},parseRTPData:function(n,o){var a=o[4],u=128,s=129,c=130,f=131,l=132,h=133,p=136,y=137,d=138,m=139,v=140,g=144,S=145,O=146,T=147,_=148,E=149,A=150,k=151,R=152,P=153,C=154,x=155,I=156,M=160,B=176,D=255,U={type:"MediaData",data:{rtspInterleave:n,payload:o},info:null,channel:i.channel},j={};if(253==a||254==a||252==a||251==a){if(function(){var t=o[22]+24;j.frameIndex=(o[11]<<24)+(o[10]<<16)+(o[9]<<8)+o[8];for(var e=24;et)return r.log("i: "+e),-1;j.width=o[e+2]<<3,j.height=o[e+3]<<3,e+=4}else if(s==o[e]){if(e+4>o.length)return r.log("i: "+e),-1;j.I_frame_interval=o[e+1],j.encode_type=o[e+2],j.frame_rate=o[e+3],e+=4}else if(c==o[e])j.width=(o[e+5]<<8)+o[e+4],j.height=(o[e+7]<<8)+o[e+6],e+=8;else if(f==o[e])e+=4;else if(p==o[e])e+=8;else if(l==o[e]){if(e+4>t)return r.log("i: "+e),-1;var n=(o[e+2]<<8)+o[e+3];e+=n}else if(_==o[e])j.h264_svc_flag=!0,j.svc=o[e+2],e+=4;else if(d==o[e])e+=8;else if(S==o[e])e+=8;else if(P==o[e]){var i=o[e+1],a=o[e+2];e+=8,e+=i*a*16}else if(C==o[e])e+=8;else if(x==o[e])e+=8;else if(O==o[e])e+=8;else if(T==o[e])e+=8;else if(E==o[e])e+=8;else if(M<=o[e]&&o[e]=2&&pt&&pt();break;case"canvasRender":Bt(0,"currentTime"),n=i.data,o=i.option,null!==n&&null!==a&&("mjpeg"===E.codecType?a.drawMJPEG(n,E.width,E.height,E.codecType,E.frameType,E.timeStamp,E.frameIndex,o):a.draw(n,E.width,E.height,E.codecType,E.frameType,E.timeStamp,E.frameIndex,o));break;case"initSegment":W=i.data,Mt();break;case"mediaSample":null===G.samples&&(G.samples=new Array(rt)),null===i.data.frame_time_stamp&&(i.data.frameDuration=Math.round(st/k)),1!==nt&&(i.data.frameDuration=st/Math.abs(nt)),G.samples[X++]=i.data,at+=i.data.frameDuration,ut+=i.data.frameDuration;break;case"videoRender":var u=new Uint8Array(i.data.length+Z);if(0!==Z&&u.set(K),u.set(i.data,Z),Z=(K=u).length,X%rt===0&&0!==X){if(null!==G.samples[0].frameDuration?(G.baseMediaDecodeTime=1===J?0:it,it=at):G.baseMediaDecodeTime=Math.round(st/k)*rt*(J-1),"chrome"==T&&1===nt)for(var s=G.samples.length,c=ut/rt,f=0;f=2&&pt&&pt();break;case"render":if(!0===N)break;ct!==e.codec&&(null!==u&&(ft=u.getVolume(),lt=u.getInitVideoTimeStamp(),u.terminate()),31===e.audio_type&&"edge"===T?(u=null,null!==d&&d({errorCode:201})):(u=new M).setSamplingRate(e.samplingRate),null!==u&&(u.setInitVideoTimeStamp(lt),!0===D&&(ft=1),u.audioInit(ft)||(u=null)),ct=e.codec),null!==u&&(!0===D&&u.setBufferingFlag(),null===E||"undefined"===typeof E?u.bufferAudio(e.data,e.rtpTimeStamp,null):u.bufferAudio(e.data,e.rtpTimeStamp,E.codecType))}}function Ct(t){var e=t.data;switch(e.type){case"rtpData":l(e.data)}}function xt(t){var e={type:"getRtpData",data:t};n.postMessage(e)}function It(t){null!==Y&&(Y.close(),Y=null),rt=!1===t?et:Math.abs(nt),G.samples=new Array(rt),ot=!1,J=1,q=null,X=0,K=null,Z=0}function Mt(){ot=!0,null===Y?((Y=P(i)).setCodecInfo(Q),Y.setInitSegmentFunc(At),Y.setVideoSizeCallback(kt),Y.setBeginDrawCallback(f),Y.init($),Y.setErrorCallback(d),Y.setSpeedPlay(nt),Y.setPlaybackFlag(H),Y.setFPS(k)):(Y.getVideoElement(),Y.setInitSegment()),Y.setAudioStartCallback(Bt)}function Bt(t,e){null!==u&&u.setBufferingFlag(t,e)}return new Et},F=n(51),z=n.n(F);function V(t,e){function n(t,e){n.prototype.w=t,n.prototype.h=e}return n.prototype={toString:function(){return"("+n.prototype.w+", "+n.prototype.h+")"},getHalfSize:function(){return new V(n.prototype.w>>>1,n.prototype.h>>>1)},length:function(){return n.prototype.w*n.prototype.h}},new n(t,e)}var N=function(){var t=null,e=null,n=null,o=!0,i=0,a=new Map,u=this,s=null;function c(){}function f(o){var u=o.data;switch(u.type){case"WorkerReady":e&&e();break;case"canvasRender":!function(e,r){if(null!=e){if(null===n){var o=new V(r.ylen,r.height);n=new g(t,o)}var u=Math.floor((l(r.time).getTime()-i)/1e3),s={frameData:e,option:r};a.size>600&&a.clear(),!1===a.has(u)&&a.set(u,s)}}(u.data,u.option);break;default:r.log("workerManager::videoWorker unknown data = "+u.data)}}function l(t){var e=2e3+(t>>26),n=t>>22&15,r=t>>17&31,o=t>>12&31,i=t>>6&63,a=63&t,u=new Date;return u.setFullYear(e,n-1,r),u.setHours(o,i,a,0),u}return c.prototype={init:function(e,n){t=e,u.channel=n,(s=new z.a).onmessage=f},parseRTPData:function(t,e){!0===o&&(i=l(i=(e[19]<<24)+(e[18]<<16)+(e[17]<<8)+e[16]>>>0).getTime()),o=!1;var n=e[4],r={type:"MediaData",data:{rtspInterleave:t,payload:e},info:null,channel:u.channel};253!=n&&254!=n&&252!=n&&251!=n||s.postMessage(r)},setCallback:function(t,n){switch(t){case"WorkerReady":e=n;break;case"FileOver":this.fileOverCallback=n;break;default:r.log(t),r.log("workerManager::setCallback() : type is unknown")}},terminate:function(){s&&(s.terminate(),s=null),a&&(a=null)},play:function(){},initStartTime:function(){},pause:function(){},setLiveMode:function(){},setPlayMode:function(){},setFPS:function(){},sendSdpInfo:function(){},postRtspOver:function(){},setLessRate:function(t){},gotoSecond:function(e,r){if(e=(e=e<0?0:e)>r?r:e,!0===a.has(e)){var o=a.get(e);return n.drawCanvas(o.frameData,o.option),{pngData:t.toDataURL(),option:o.option}}return!1},checkLeftSize:function(t,e,n,r){var o=!1;if("next"===e)for(var i=1;i<=r;i++){var u=t+i>n?n:t+i;if(!1===(o=a.has(u)))break}else if("pre"===e)for(i=1;i<=r&&(u=t-i<1?1:t-i,!1!==(o=a.has(u)));i++);return o},clearMap:function(){a.clear()}},new c};function H(t){return(H="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}if("undefined"==typeof Y)var Y={};Y.MD5=function(t){function e(t){var e=(t>>>0).toString(16);return"00000000".substr(0,8-e.length)+e}function n(t,e,n){return t&e|~t&n}function r(t,e,n){return n&t|~n&e}function o(t,e,n){return t^e^n}function i(t,e,n){return e^(t|~n)}function a(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function u(t){for(var e=[],n=0;n>>32-i),m=a}var u=c.length;c.push(128);var s=c.length%64;if(s>56){for(var f=0;f<64-s;f++)c.push(0);s=c.length%64}for(f=0;f<56-s;f++)c.push(0);c=c.concat(function(t){for(var e=[],n=0;n<8;n++)e.push(255&t),t>>>=8;return e}(8*u));var h=1732584193,p=4023233417,y=2562383102,d=271733878,m=0,v=0,b=0,g=0;for(f=0;f=0;s--)a=255&(u=arguments[s]),a<<=8,a|=255&(u>>>=8),a<<=8,a|=255&(u>>>=8),a<<=8,i+=e(a|=u>>>=8);return i}(d,y,p,h).toUpperCase()}()};var W=function(t){return Y.MD5(t)};function q(t){return function(t){if(Array.isArray(t))return G(t)}(t)||function(t){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"===typeof t)return G(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return G(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n1&&void 0!==arguments[1]?arguments[1]:4,n=[];if(!0===(arguments.length>2?arguments[2]:void 0))for(var r=0;r>>8*(e-1-r)&255;else for(var o=0;o>>8*o&255;return n}var J=function(){function t(e,n,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.RtpInterlevedID=e,this.timestamp=0,this.currTime=null,this.preTime=null,this.VideoCodec=n,this.AudioCodec=r,this.MAXFRAMEINTERVAL=65535,this.rtpDataHeadExtLength=12,this.rtpDataHeadLength=24+this.rtpDataHeadExtLength,this.rtpDataFootLength=8,this.rtpPacketHead=[36,e,0,0,0,0],this.DHAV=[68,72,65,86],this.dhav=[100,104,97,118],this.frameNum=245}var e,n,r;return e=t,(n=[{key:"getRTPPacket",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ArrayBuffer(0),e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0;this.rtpDataHeadExtLength=8+("audio"===e.type?4:e.width>2048||e.height>2048?12:8),this.rtpDataHeadLength=24+this.rtpDataHeadExtLength;var r=new Uint8Array(this.rtpPacketHead.length+this.rtpDataHeadLength+t.byteLength+this.rtpDataFootLength);r.set([36,this.RtpInterlevedID],n),n+=2,r.set(K(this.rtpDataHeadLength+t.byteLength+this.rtpDataFootLength,4,!0),n),n+=4,r.set(this.DHAV,n),n+=4;var o="audio"===e.type?[240]:e.keyframe?[253]:[252];r.set(o,n),n+=1,r.set([0],n),n+=1,r.set([1],n),n+=1,r.set([0],n),n+=1,this.frameNum>65535&&(this.frameNum=240),r.set(K(this.frameNum),n),n+=4,this.frameNum++;var i=K(this.rtpDataHeadLength+t.byteLength+this.rtpDataFootLength);r.set(i,n),n+=4;var a=new Date("2000-01-01 00:00:00").getTime();this.timestamp=1e3*e.timestamp/e.timescale,this.timestamp>this.MAXFRAMEINTERVAL&&(this.timestamp=this.timestamp-this.MAXFRAMEINTERVAL),r.set(K(Math.floor((a+this.timestamp)/1e3)),n),n+=4,r.set(K(this.timestamp,2),n),n+=2,r.set([this.rtpDataHeadExtLength],n),n+=1;var u=function(t,e){for(var n=0,r=e;r2048||e.height>2048?[130,0,0,0].concat(q(K(e.width,2)),q(K(e.height,2))):[128,0,e.width/8,e.height/8]:[131,1,26,Z[e.timescale]],r.set(s,n),n+=s.length,"video"===e.type&&(r.set([129,0,this.getHexByCodec(this.VideoCodec),50],n),n+=4);var c=function(t,e){for(var n=0,r=0;r=t.offset+t.size){var e=null;if(t instanceof tt.VideoSample){var n=this.set_nal_unit_type(this.MovieBuffer.subarray(t.offset-this.currentDeleteLen,t.offset+t.size-this.currentDeleteLen));e=this.packetDHAV.getRTPPacket(n,t)}else e=this.packetDHAV.getRTPPacket(this.MovieBuffer.subarray(t.offset-this.currentDeleteLen,t.offset+t.size-this.currentDeleteLen),t);(this.isSeek&&t.keyframe||!this.isSeek)&&(this.TrackCallback(e),this.isSeek=!1),this.MovieBuffer=this.MovieBuffer.subarray(t.offset+t.size-this.currentDeleteLen,this.MovieBuffer.length),this.currentDeleteLen=t.offset+t.size,this.currentFrame++,this.currentFrame=n)return 0;for(;t<=e;){var r=parseInt((e+t)/2),o=this.track[r];if(n===o.offset)return r;if(n>o.offset){if(n0&&void 0!==arguments[0]?arguments[0]:new Uint8Array,e=0,n=0,r=function(e,n){var r="";return t.slice(e,n).map(function(t){return r+=1===t.toString(16).length?"0"+t.toString(16):t.toString(16)}),parseInt(r,16)};t.length>4&&n=60?60:t.length;nt[n].timescale){e=n;break}return e}},{key:"parseToString",value:function(t){for(var e="",n=0,r=t.length;n=n)return t;var r=n-t.length;return new Array(r).fill(String(e)).join("")+t}function ut(t,e){return void 0!==t&&t?(e=e||new Date,t=(t=(t=(t=(t=(t=t.replace(/y/gi,at(e.getFullYear()),0)).replace(/m/gi,at(e.getMonth()+1),0)).replace(/d/gi,at(e.getDate()),0)).replace(/h/gi,at(e.getHours()),0)).replace(/i/gi,at(e.getMinutes()),0)).replace(/s/gi,at(e.getSeconds()),0)):""}function st(t,e){var n=(t=t||{}).nameFormat||["ymd_his"];e=e||new Date;var r="";if(it(n,"string"))n=[n,{}];else{if(!it(n,"array"))return void function(t){throw new Error(t)}("name format must be string or array");it(n[0],"string")||(n[0]="ymd_his"),it(n[1],"object")||(n[1]={})}var o=n[0].split(/\{(?:[^{}]+)\}/),i=n[1];n[0].replace(/\{([^{}]*)\}/g,function(t,e,n){o.shift();r+=ut(),r+=e in i?i[e]:t});var a=o.shift();return r+=ut(a,e)}function ct(t,e){this.name=t,this.allowUpDateName=!0,this.byteLength=0,this.options=e,this.startTime=(new Date).toLocaleString()}ct.prototype.setEndTime=function(){this.endTime=(new Date).toLocaleString()},ct.prototype.updateNameByStream=function(t,e){if(this.allowUpDateName){var n=new Uint8Array(e),r=(n[19]<<24)+(n[18]<<16)+(n[17]<<8)+n[16]>>>0,o="20"+(r>>26)+"/"+(r>>22&15)+"/"+(r>>17&31)+" "+(r>>12&31)+":"+(r>>6&63)+":"+(63&r);this.name=st(t,new Date(o)),this.allowUpDateName=!1,n=null}e=null};var ft=new function(){var t={count:0,total:0,group:[]},e=function(){};return e.prototype.add=function(e){t.count++,t.total+=e.byteLength,t.group.push(e)},e.prototype.get=function(e){return e in t?t[e]:t},new e};var lt=function(){var t=1048576,e=null,n=null,r=0,o=void 0,i=null;function a(){this.onMessage=function(){},this.postMessage=function(t){this.__onMessage(t)},this.__postMessage=function(t){this.onMessage(t)}}return a.prototype.__onMessage=function(t){var e=t;switch(e.type){case"init":this.init(e.options);break;case"addBuffer":this.addBuffer(e);break;case"close":this.close()}},a.prototype.init=function(e){this.fullSize=e.fullSize||1/0,this.singleSize=e.singleSize+20*t||520*t,o="init",this.limitOptions=Object.assign({limitBy:"fullSize"},e.limitOptions),this.nameOptions=Object.assign({namedBy:"date",nameFormat:["ymd_his",{}]},e.nameOptions)},a.prototype._malloc=function(t){e&&n&&(n=null,e=null),e=new ArrayBuffer(t),n=new DataView(e);var r=this.nameOptions,o="";switch(this.nameOptions.namedBy.toLowerCase()){case"date":o=st(r);break;default:o=st()}i=new ct(o)},a.prototype._initVideoMem=function(){!e&&this.singleSize&&this._malloc(this.singleSize)},a.prototype.appendVideoBuf=function(e){var o=e.byteLength,i=r+o;if(i>this.singleSize-20*t)this.inNodePlace(),this.addBuffer({buffer:e});else{for(var a=r;athis.fullSize?this.close():this.appendVideoBuf(e)}},a.prototype.inNodePlace=function(){if("addBuffer"===o){o="download",i.updateNameByStream(this.nameOptions,e.slice(0,20)),i.byteLength=r,i.setEndTime(),ft.add(i);var t=e.slice(0,r);if(this.reset(),this.__postMessage({type:"download",data:rt(rt({},i),{},{buffer:t})}),t=null,"count"===this.limitOptions.limitBy){var n=this.limitOptions.count;n&&n===ft.get("count")&&this.close()}}},a.prototype.reset=function(){r=0,this._malloc(this.singleSize)},a.prototype.close=function(){this.inNodePlace(),"closed"!==o&&void 0!==o&&(o="closed",this.__postMessage({type:"closed",message:"record was closed"}),e=null,n=null)},new a},ht=function(t,e,n){t=t;var o=null,i=(n=n||{}).isTalkService,a=6,u=null,s=null,c=0,f=0,l=!1,h=!1,p=-1!==e.search("&srctype=raw"),y=new et,d=n.dType,m=null;m="Train"===d?new N:new L;var v=new lt,b=!1,g=new Function;n.isRecord&&(["init","sendSdpInfo","parseRTPData","setCallback"].forEach(function(t,e){m[t]=function(){}}),v.postMessage({type:"init",options:{singleSize:524288e3,nameOptions:{namedBy:"date",nameFormat:["ymd_his"]},limitOptions:{limitBy:"count",count:10}}}),v.onMessage=function(t){switch(t.type){case"pendding":g(t);break;case"download":!function(t,e){t=(t=(t||Date.now())+"").toLowerCase().split(".dav")[0];var n=new Blob([e]),r=document.createElement("a");r.href=URL.createObjectURL(n),r.download=t+".dav",r.click(),URL.revokeObjectURL(r.href),r=null,e=null}(t.data.name,t.data.buffer);break;case"closed":g(t),b=!1}});var w={OK:200,UNAUTHORIZED:401,NOTFOUND:404,INVALID_RANGE:457,NOTSERVICE:503,DISCONNECT:999},S=4e4,O="",T=[],_=1,E=function(){},A={},k="Options",R=null,P=null,C="",x=null,I={},M=e,B=null,D=null,U=!0,j={},F="",z=!1,V=0,H=0;function Y(){}function q(t,e,n,o){var a="";switch(t){case"OPTIONS":case"TEARDOWN":case"GET_PARAMETER":case"SET_PARAMETERS":a=t+" "+M+" RTSP/1.0\r\nCSeq: "+_+"\r\n"+O+"\r\n";break;case"DESCRIBE":a=t+" "+M+" RTSP/1.0\r\nCSeq: "+_,!0===i&&(a+="\r\nRequire: www.onvif.org/ver20/backchannel"),a=a+"\r\n"+O+"\r\n";break;case"SETUP":r.log("trackID: "+e),a=t+" "+M+"/trackID="+e+" RTSP/1.0\r\nCSeq: "+_+"\r\n"+O+"Transport: DH/AVP/TCP;unicast;interleaved="+2*e+"-"+(2*e+1)+"\r\n",a+=0!=P?"Session: "+P+"\r\n\r\n":"\r\n";break;case"PLAY":a=t+" "+M+" RTSP/1.0\r\nCSeq: "+_+"\r\nSession: "+P+"\r\n",void 0!=o&&0!=o?(a+="Range:".concat(p?"byte":" npt","=").concat(o,"-\r\n"),a+=O+"\r\n"):a+=O+"\r\n";break;case"PAUSE":a=t+" "+M+" RTSP/1.0\r\nCSeq: "+_+"\r\nSession: "+P+"\r\n\r\n";break;case"SCALE":a="PLAY "+M+" RTSP/1.0\r\nCSeq: "+_+"\r\nSession: "+P+"\r\n",a+="Scale: "+o+"\r\n",a+=O+"\r\n";break;case"SPEED":a="PLAY "+M+" RTSP/1.0\r\nCSeq: "+_+"\r\nSession: "+P+"\r\n",a+="SPEED: "+o+".000\r\n",a+=O+"\r\n"}return r.log(a),a}function G(t){r.log(t);var e,n=t.search("CSeq: ")+5;if(_=parseInt(t.slice(n,n+10))+1,(e=function(t){var e={},n=0,r=0,o=null,i=null;if(-1!==t.search("Content-Type: application/sdp")){var a=t.split("\r\n\r\n");i=a[0]}else i=t;var u=i.split("\r\n"),s=u[0].split(" ");if(s.length>2&&(e.ResponseCode=parseInt(s[1]),e.ResponseMessage=s[2]),e.ResponseCode===w.OK){for(n=1;n1&&(e.RtpInterlevedID=parseInt(y[0]),e.RtcpInterlevedID=parseInt(y[1]))}}}else if("RTP-Info"===o[0]){o[1]=u[n].substr(9);var d=o[1].split(",");for(e.RTPInfoList=[],r=0;r0;)if(36!==e[0]){var r=String.fromCharCode.apply(null,e),i=null;-1===r.indexOf("OffLine:File Over")&&-1===r.indexOf("OffLine:Internal Error")||(o.fileOver=!0,m.postRtspOver()),-1!==r.indexOf("OffLine:KmsUnavailable")&&E({errorCode:203}),!0===l?(i=r.lastIndexOf("\r\n"),l=!1):i=r.search("\r\n\r\n");var h=r.search("RTSP");if(-1===h)return void(e=new Uint8Array);if(-1===i)return void(c=e.length);u=e.subarray(h,i+a),e=e.subarray(i+a),Z(G(String.fromCharCode.apply(null,u))),c=e.length}else{if("RAW"===T[0].codecName)return void(/.aac/.test(M)?m.sendBufferToAudioWorker(e.subarray(a,e.length)):y.setMovieData(e.subarray(a,e.length)));if(!0===U&&D&&D(),U=!1,s=e.subarray(0,a),!((f=s[2]<<24|s[3]<<16|s[4]<<8|s[5])+a<=e.length))return void(c=e.length);var p=e.subarray(a,f+a);b&&v.postMessage({type:"addBuffer",buffer:p}),Q(s,p),e=e.subarray(f+a),c=e.length}}function Q(t,e){m.parseRTPData(t,e)}function $(t){var e={Sessions:[]},n=(-1!==t.search("Content-Type: application/sdp")?t.split("\r\n\r\n")[1]:t).split("\r\n"),r=0,o=!1;for(r=0;r0)switch(i[0]){case"a":var a=i[1].split(":");if(a.length>1){if("control"===a[0]){var u=n[r].search("control:");!0===o?-1!==u&&(e.Sessions[e.Sessions.length-1].ControlURL=n[r].substr(u+8)):-1!==u&&(e.BaseURL=n[r].substr(u+8))}else if("rtpmap"===a[0]){var s=a[1].split(" ");e.Sessions[e.Sessions.length-1].PayloadType=s[0];var c=s[1].split("/");e.Sessions[e.Sessions.length-1].CodecMime=c[0],c.length>1&&(e.Sessions[e.Sessions.length-1].ClockFreq=c[1])}else if("framesize"===a[0]){var f=a[1].split(" ");if(f.length>1){var l=f[1].split("-");e.Sessions[e.Sessions.length-1].Width=l[0],e.Sessions[e.Sessions.length-1].Height=l[1]}}else if("framerate"===a[0])e.Sessions[e.Sessions.length-1].Framerate=a[1];else if("fmtp"===a[0]){var h=n[r].split(" ");if(h.length<2)continue;for(var p=1;p1&&(e.Sessions[e.Sessions.length-1].SPS=v[0],e.Sessions[e.Sessions.length-1].PPS=v[1])}}}}}else 1===a.length&&("recvonly"===a[0]?e.Sessions[e.Sessions.length-1].TalkTransType="recvonly":"sendonly"===a[0]&&(e.Sessions[e.Sessions.length-1].TalkTransType="sendonly"));break;case"m":var b=i[1].split(" "),g={};g.Type=b[0],g.Port=b[1],g.Payload=b[3],e.Sessions.push(g),o=!0;break;case"b":if(!0===o){var w=i[1].split(":");e.Sessions[e.Sessions.length-1].Bitrate=w[1]}}}return e}return Y.prototype={init:function(t,e,n,r,o){"Train"===d?m.init(t,n):m.init(t,e,n,r,o)},talkInit:function(){m.talkInit()},connect:function(){o||((o=new WebSocket(t)).binaryType="arraybuffer",o.fileOver=!1,o.addEventListener("message",J,!1),o.onopen=function(){var t=K("OPTIONS "+M+" RTSP/1.0\r\nCSeq: "+_+"\r\n\r\n");o.send(t)},o.onerror=function(t){E({errorCode:202,description:"Open WebSocket Error"})},o.onclose=function(t){o&&!o.fileOver&&E({errorCode:202,description:"Open WebSocket Error"})})},disconnect:function(){Z(q("TEARDOWN",null)),clearInterval(x),x=null,o&&(o.close(),o=null,P=null),m.terminate(),H&&clearTimeout(H)},controlPlayer:function(t){var e="";switch(F=t.command,t.command){case"PLAY":if(k="Play",m.play(),null!=t.range){e=q("PLAY",null,0,t.range);break}e=q("PLAY",null),F&&m.initStartTime();break;case"PAUSE":if("PAUSE"===k)break;k="PAUSE",e=q("PAUSE",null),m.pause();break;case"SCALE":e=q("SCALE",null,0,t.data),m.playbackSpeed(t.data);break;case"SPEED":e=q("SPEED",null,0,t.data),m.playbackSpeed(t.data);break;case"TEARDOWN":e=q("TEARDOWN",null);break;case"audioPlay":if("start"===t.data)k="Play",e=q("PLAY",null,0,t.range);else if("stop"===t.data)e=q("TEARDOWN",null);else{if("PAUSE"===k)break;k="PAUSE",e=q("PAUSE",null)}m.controlAudio(t.command,t.data);break;case"volumn":case"audioSamplingRate":m.controlAudio(t.command,t.data);break;case"playNextFrame":m.getVideoBufferQueueSize()<5&&this.getNextFrameData(1e3),m.playNextFrame();break;case"startRecod":(b=t.data)||v.postMessage({type:"close"});break;default:r.log("\u672a\u77e5\u6307\u4ee4: "+t.command)}""!=e&&Z(e)},setLiveMode:function(t){m.setLiveMode(t)},setPlayMode:function(t,e){z=t,V=e,m.setPlayMode(t)},setRTSPURL:function(t){M=t},setCallback:function(t,e){"GetFrameRate"===t?B=e:"GetFirstFrame"===t?D=e:"recordChanged"===t?g=e:m.setCallback(t,e),"Error"==t&&(E=e)},setUserInfo:function(t,e){j.username=t,j.passWord=e},capture:function(t,e){m.capture(t,e)},setLessRate:function(t){m.setLessRate(t)},getNextFrameData:function(t){Z(q("PLAY",null)),setTimeout(function(){Z(q("PAUSE",null))},t)},gotoSecond:function(t){return m.gotoSecond(t)},checkLeftSize:function(t,e){return m.checkLeftSize(t,e)},clearMap:function(){m.clearMap()}},y.CodecCallback=function(t){I=t.AudioCodecInfo,T[0].Framerate=t.Framerate,"H264"===I.VideoCodec&&Y.prototype.setLiveMode("video"),m.sendSdpInfo(T,I,t)},y.TrackCallback=function(t){var e=new Uint8Array(t.subarray(6,t.length));Q(t.subarray(0,6),e)},new Y},pt=function(t){this.wsURL=t.wsURL,this.rtspURL=t.rtspURL,this.isTalkService=t.isTalkService,this.isPlayback=t.playback||!1,this.playBackRange=t.range||!1,this.isAudioFlag=t.isAudioFlag||!1,this.lessRateCanvas=t.lessRateCanvas||!1,this.audioState="stop",this.ws=null,this.decodeMode=t.decodeMode,this.events={ResolutionChanged:function(){},PlayStart:function(){},DecodeStart:function(){},UpdateCanvas:function(){},GetFrameRate:function(){},FrameTypeChange:function(){},Error:function(){},MSEResolutionChanged:function(){},audioChange:function(){},WorkerReady:function(){},IvsDraw:function(){},FileOver:function(){},Waiting:function(){},UpdateTime:function(){},recordChanged:function(){},GetFirstFrame:function(){}},this.username=t.username,this.password=t.password,this.deployType=t.deployType,this.duration=t.duration};pt.prototype={init:function(t,e,n){for(var r in this.ws=new ht(this.wsURL,this.rtspURL,{dType:this.deployType}),this.ws.init(t,e,n,this.isPlayback,this.isAudioFlag),this.ws.setLiveMode(this.decodeMode),this.ws.setUserInfo(this.username,this.password),this.ws.setPlayMode(this.isPlayback,this.playBackRange),this.ws.setLessRate(this.lessRateCanvas),this.events)this.ws.setCallback(r,this.events[r]);this.events=null},startRecod:function(t){if(t){if(this.ws)return;for(var e in this.ws=new ht(this.wsURL,this.rtspURL,{isRecord:!0}),this.ws.setUserInfo(this.username,this.password),this.events)this.ws.setCallback(e,this.events[e]);this.controlPlayer("startRecod",!0),this.connect()}else this.ws&&(this.controlPlayer("startRecod",!1),this.ws.disconnect(),this.ws=null)},connect:function(){this.ws.connect(),this.audioState="play"},play:function(){this.controlPlayer("PLAY")},pause:function(){this.controlPlayer("PAUSE")},stop:function(){this.controlPlayer("TEARDOWN")},close:function(){this.ws.disconnect()},playByTime:function(t){t=t<0?0:t,this.duration>0&&t>this.duration&&(t=this.duration),this.controlPlayer("PLAY","video",t)},playFF:function(t){this.controlPlayer("PAUSE"),this.controlPlayer("SCALE",t)},playSpeed:function(t){this.controlPlayer("PAUSE"),this.controlPlayer("SPEED",t)},playRewind:function(){},playNextFrame:function(){this.controlPlayer("playNextFrame")},audioPlay:function(){this.controlPlayer("audioPlay","start"),this.audioState="play"},audioStop:function(){this.controlPlayer("audioPlay","stop")},audioPause:function(){this.controlPlayer("audioPlay","pause"),this.audioState="pause"},setAudioSamplingRate:function(t){this.controlPlayer("audioSamplingRate",t)},setAudioVolume:function(t){this.controlPlayer("volumn",t)},gotoSecond:function(t){var e=this;window.clearInterval(e.checkRsPre),window.clearInterval(e.checkRsNext),window.clearInterval(e.checkRsGoto),e.ws.clearMap(),!0===e.running&&(e.pause(),e.running=!1),e.playByTime(t-5),e.running=!0,e.checkRsGoto=window.setTimeout(function(){e.pause(),e.running=!1},12e3)},nextSecond:function(t,e){var n=this,r=n.ws.gotoSecond(t);!1===r?(!1===n.running&&(n.playByTime(t),n.running=!0),n.checkRsNext=window.setInterval(function(){!1!==(r=n.ws.gotoSecond(t))&&(window.clearInterval(n.checkRsNext),window.setTimeout(function(){n.running=!1,n.pause()},9e3),e(r))},2e3)):(n.ws.checkLeftSize(t,"next")<=2&&!1===n.running&&(n.playByTime(t+1),n.running=!0,window.setTimeout(function(){n.pause(),n.running=!1},9e3)),e(r))},preSecond:function(t,e){var n=this,r=n.ws.gotoSecond(t);!1===r?(!1===n.running&&(n.playByTime(t-5),n.running=!0),n.checkRsPre=window.setInterval(function(){!1!==(r=n.ws.gotoSecond(t))&&(window.clearInterval(n.checkRsPre),window.setTimeout(function(){n.running=!1,n.pause()},9e3),e(r))},2e3)):(n.ws.checkLeftSize(t,"pre")<=2&&!1===n.running&&(n.playByTime(t-5),n.running=!0,window.setTimeout(function(){n.pause(),n.running=!1},9e3)),e(r))},controlPlayer:function(t,e,n){var r;r="video"===e?{command:t,range:n||0}:"audioPlay"===t?{command:t,data:e,range:n||0}:{command:t,data:e},this.ws.controlPlayer(r)},setPlayMode:function(t){this.ws.setLiveMode(t)},setPlayPath:function(t){this.ws.setRTSPURL(t)},capture:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ivsCanvasArr:[]};this.ws.capture(t,e)},talk:function(t){if("on"===t){for(var e in this.ws=new ht(this.wsURL,this.rtspURL,{isTalkService:this.isTalkService}),this.ws.talkInit(),this.ws.setUserInfo(this.username,this.password),this.events)this.ws.setCallback(e,this.events[e]);this.ws.connect()}else this.ws.disconnect()},on:function(t,e){this.events[t]=e}};e.default=pt}]).default;