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