!function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";function a(t){return(a="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}if(r.r(e),"undefined"==typeof n)var n={};n.MD5=function(t){function e(t){var e=(t>>>0).toString(16);return"00000000".substr(0,8-e.length)+e}function r(t,e,r){return t&e|~t&r}function n(t,e,r){return r&t|~r&e}function i(t,e,r){return t^e^r}function o(t,e,r){return e^(t|~r)}function s(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function u(t){for(var e=[],r=0;r>>32-i),h=o}var a=l.length;l.push(128);var u=l.length%64;if(u>56){for(var f=0;f<64-u;f++)l.push(0);u=l.length%64}for(f=0;f<56-u;f++)l.push(0);l=l.concat(function(t){for(var e=[],r=0;r<8;r++)e.push(255&t),t>>>=8;return e}(8*a));var c=1732584193,m=4023233417,d=2562383102,_=271733878,h=0,g=0,v=0,y=0;for(f=0;f=0;u--)o=255&(s=arguments[u]),o<<=8,o|=255&(s>>>=8),o<<=8,o|=255&(s>>>=8),o<<=8,i+=e(o|=s>>>=8);return i}(_,d,m,c).toUpperCase()}()};var i={log:function(){},error:function(){},count:function(){},info:function(){}};(function(){function t(){}t.createFromElementId=function(e){for(var r=document.getElementById(e),a="",n=r.firstChild;n;)3===n.nodeType&&(a+=n.textContent),n=n.nextSibling;var i=new t;return i.type=r.type,i.source=a,i},t.createFromSource=function(e,r){var a=new t;return a.type=e,a.source=r,a}})(),function(){function t(t){this.gl=t,this.program=this.gl.createProgram()}t.prototype={attach:function(t){this.gl.attachShader(this.program,t.shader)},link:function(){this.gl.linkProgram(this.program)},use:function(){this.gl.useProgram(this.program)},getAttributeLocation:function(t){return this.gl.getAttribLocation(this.program,t)},setMatrixUniform:function(t,e){var r=this.gl.getUniformLocation(this.program,t);this.gl.uniformMatrix4fv(r,!1,e)}}}(),function(){var t=null;function e(t,e,r){this.gl=t,this.size=e,this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),this.format=r||t.LUMINANCE,t.texImage2D(t.TEXTURE_2D,0,this.format,e.w,e.h,0,this.format,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}e.prototype={fill:function(t,e){var r=this.gl;r.bindTexture(r.TEXTURE_2D,this.texture),e?r.texSubImage2D(r.TEXTURE_2D,0,0,0,this.size.w,this.size.h,this.format,r.UNSIGNED_BYTE,t):r.texImage2D(r.TEXTURE_2D,0,this.format,this.size.w,this.size.h,0,this.format,r.UNSIGNED_BYTE,t)},bind:function(e,r,a){var n=this.gl;t||(t=[n.TEXTURE0,n.TEXTURE1,n.TEXTURE2]),n.activeTexture(t[e]),n.bindTexture(n.TEXTURE_2D,this.texture),n.uniform1i(n.getUniformLocation(r.program,a),e)}}}();function o(){var t=0,e=0,r=null;function a(){t=360,e=240,r=null,this._length=0,this.head=null,this.tail=null,this.curIdx=0}return a.prototype={push:function(t,a,n,i,o,s){var u=new VideoBufferNode(t,a,n,i,o,s);return this._length>0?(this.tail.next=u,u.previous=this.tail,this.tail=u):(this.head=u,this.tail=u),this._length+=1,null!==r&&this._length>=e&&r(),u},pop:function(){var t=null;return this._length>1&&(t=this.head,this.head=this.head.next,null!==this.head?this.head.previous=null:this.tail=null,this._length-=1),t},setMaxLength:function(e){(t=e)>360?t=360:t<30&&(t=30)},setBUFFERING:function(t){(e=t)>240?e=240:e<6&&(e=6)},setBufferFullCallback:function(t){r=t},searchTimestamp:function(t){var e=this.head,r=this._length,a=1;if(0===r||t<=0||null===e)throw new Error("Failure: non-existent node in this list.");for(;null!==e&&(e.timeStamp.timestamp!==t.timestamp||e.timeStamp.timestamp_usec!==t.timestamp_usec);)e=e.next,a++;return r0&&n>0){t=Date.now();var p=new Uint8Array(c);return s={data:p,option:{yaddr:Module._getY(r),uaddr:Module._getU(r),vaddr:Module._getV(r),ylen:o,height:n,beforeDecoding:t},width:o,height:n,codecType:"h264",decodingTime:a,frameType:f},Module._FrameFree(r),s}},setIsFirstFrame:function(t){p=t},isFirstFrame:function(){return p},free:function(){Module._free(f),f=null}},new m},u=new function(){var t=[],e={};function r(){for(var r in t)t[r]=[r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2),r.charCodeAt(3)];e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}t={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var a=function(t){for(var e=8,r=Array.prototype.slice.call(arguments,1),a=0;a>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e,n.set(t,i),i+=4,a=0;a>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),function(e){var r=e.config,n=r.length,i=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(r).concat([6,1,2]));return a(t.esds,i)}(e))},o=function(r){return"audio"===r.type?a(t.stsd,e.STSD_PREFIX,n(r)):a(t.stsd,e.STSD_PREFIX,function(e){var r=e.sps||[],n=e.pps||[],i=[],o=[],s=0;for(s=0;s>>8),i.push(255&r[s].byteLength),i=i.concat(Array.prototype.slice.call(r[s]));for(s=0;s>>8),o.push(255&n[s].byteLength),o=o.concat(Array.prototype.slice.call(n[s]));return a(t.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a(t.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([r.length]).concat(i).concat([n.length]).concat(o))))}(r))},s=function(r){var n=null;return n="audio"===r.type?a(t.smhd,e.SMHD):a(t.vmhd,e.VMHD),a(t.minf,n,a(t.dinf,a(t.dref,e.DREF)),function(r){return a(t.stbl,o(r),a(t.stts,e.STTS),a(t.stsc,e.STSC),a(t.stsz,e.STSZ),a(t.stco,e.STCO))}(r))},u=function(r){return a(t.mdia,function(e){var r=e.timescale,n=e.duration;return a(t.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))}(r),function(r){var n=null;return n="audio"===r.type?e.HDLR_AUDIO:e.HDLR_VIDEO,a(t.hdlr,n)}(r),s(r))},f=function(e){return a(t.trak,function(e){var r=e.id,n=e.duration,i=e.width,o=e.height;return a(t.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,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,o>>>8&255,255&o,0,0]))}(e),u(e))},l=function(e){return a(t.mvex,function(e){var r=e.id,n=new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return a(t.trex,n)}(e))},c=function(e){var r,n,o=(r=e.timescale,n=e.duration,i.log("mvhd: timescale: "+r+" duration: "+n),a(t.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,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=f(e),u=l(e);return a(t.moov,o,s,u)},p=function(e,r){return"audio"===e.type?audioTrun(e,r):function(e,r){var n,i=null,o=null,s=0,u=r;if(null===(n=e.samples||[])[0].frameDuration)for(u+=24+4*n.length,i=trunHeader(n,u),s=0;s>>24,(16711680&o.size)>>>16,(65280&o.size)>>>8,255&o.size]);else for(i=function(t,e){return[0,0,3,5,(4278190080&t.length)>>>24,(16711680&t.length)>>>16,(65280&t.length)>>>8,255&t.length,(4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e,0,0,0,0]}(n,u+=24+4*n.length+4*n.length),s=0;s>>24,(16711680&o.frameDuration)>>>16,(65280&o.frameDuration)>>>8,255&o.frameDuration,(4278190080&o.size)>>>24,(16711680&o.size)>>>16,(65280&o.size)>>>8,255&o.size]);return a(t.trun,new Uint8Array(i))}(e,r)},m=function(e,r){return a(t.moof,function(e){var r=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return a(t.mfhd,r)}(e),function(e){var r,n,i;return r=a(t.tfhd,new Uint8Array([0,2,0,0,0,0,0,1])),n=a(t.tfdt,new Uint8Array([0,0,0,0,e.baseMediaDecodeTime>>>24&255,e.baseMediaDecodeTime>>>16&255,e.baseMediaDecodeTime>>>8&255,255&e.baseMediaDecodeTime])),i=p(e,72),a(t.traf,r,n,i)}(r))};return r.prototype={initSegment:function(r){var n=a(t.ftyp,e.FTYP);i.log(r);var o=c(r),s=new Uint8Array(n.byteLength+o.byteLength);return s.set(n,0),s.set(o,n.byteLength),s},mediaSegment:function(e,r,n,i){var o=m(e,r),s=function(e){return a(t.mdat,e)}(n),u=null;return(u=new Uint8Array(o.byteLength+s.byteLength)).set(o),u.set(s,o.byteLength),u}},new r},f=function(){this.map={}};f.prototype={put:function(t,e){this.map[t]=e},get:function(t){return this.map[t]},containsKey:function(t){return t in this.map},containsValue:function(t){for(var e in this.map)if(this.map[e]===t)return!0;return!1},isEmpty:function(t){return 0===this.size()},clear:function(){for(var t in this.map)delete this.map[t]},remove:function(t){delete this.map[t]},keys:function(){var t=new Array;for(var e in this.map)t.push(e);return t},values:function(){var t=new Array;for(var e in this.map)t.push(this.map[e]);return t},size:function(){var t=0;for(var e in this.map)t++;return t}};var l=f;function c(){var t=7,e=7,r=2,a=3,n=4,i=5,o=8,s=16,u=32,f=255,c=0,p=null;function m(){c=0,p=new l}function d(r,n){var i=n,o=c+i>>a;return i=c+n&t,r[o]>>e-(i&e)&1}function _(t,e){var r=c>>a,n=8*(r+1)-c;if(n<8)for(var i=0;i<3;i++){var o=t[r+i];o=0==i?o>>n<>8-n|1<=0;o--,i++)n|=d(t,i)<921600&&!1===r?(a="video",E&&L>0&&L<=3&&(a="canvas")):a="canvas",a}function z(){this.decoder=new s,this.firstDiffTime=0,this.firstTime=0,this.lastMSW=0}return z.prototype={setReturnCallback:function(t){this.rtpReturnCallback=t},setBufferfullCallback:function(t){null!==this.videoBufferList&&this.videoBufferList.setBufferFullCallback(t)},getVideoBuffer:function(t){if(null!==this.videoBufferList)return this.videoBufferList.searchNodeAt(t)},clearBuffer:function(){null!==this.videoBufferList&&this.videoBufferList.clear()},findCurrent:function(){null!==this.videoBufferList&&this.videoBufferList.searchTimestamp(this.getTimeStamp())},setTimeStamp:function(t){this.timeData=t},getTimeStamp:function(){return this.timeData},ntohl:function(t){return(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3]>>>0},appendBuffer:function(t,e,r){if(r+e.length>=t.length){var a=new Uint8Array(t.length+1048576);a.set(t,0),t=a}return t.set(e,r),t},getFramerate:function(){return L},setGovLength:function(t){x=t},getGovLength:function(){return x},setDecodingTime:function(t){this.decodingTime=t},getDropPercent:function(){return 0},getDropCount:function(){return 0},initStartTime:function(){this.firstDiffTime=0,this.calcGov=0},setCheckDelay:function(t){this.checkDelay=t},init:function(t){b=!1,r=!1,k=t,this.decoder.setIsFirstFrame(!1),this.videoBufferList=new o,this.firstDiffTime=0,this.checkDelay=!0,this.timeData=null},setFramerate:function(t){0>>0,N=Date.UTC("20"+(j>>>26),(j>>>22&15)-1,j>>>17&31,j>>>12&31,j>>>6&63,63&j)/1e3;if(L.timeStampmsw,N+=(new Date).getTimezoneOffset()/60*3600,k||253!==s[4]||(B=0!==s[5],k=O(L.width,L.height,B)),""!==k){if(0==this.firstTime)this.firstTime=N,this.lastMSW=0,M=(s[21]<<8)+s[20],h={timestamp:this.firstTime,timestamp_usec:0};else{var G,W=(s[21]<<8)+s[20];G=W>M?W-M:W+65535-M,this.lastMSW+=G,N>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=N,h={timestamp:N,timestamp_usec:this.lastMSW},M=W}0!==this.getFramerate()&&"undefined"!==typeof this.getFramerate()||"undefined"===typeof this.getTimeStamp()||(this.setFramerate(Math.round(1e3/((h.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(h.timestamp_usec-this.getTimeStamp().timestamp_usec)))),i.log("setFramerate"+Math.round(1e3/((h.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(h.timestamp_usec-this.getTimeStamp().timestamp_usec))))),this.setTimeStamp(h);for(var V=s[22],H=s.subarray(24+V,s.length-8),X=s.subarray(s.length-8,s.length),Y=(X[7],X[6],X[5],X[4],[]),q=0;q<=H.length;)if(0==H[q])if(0==H[q+1])if(1==H[q+2]){if(Y.push(q),5==(31&H[q+=3])||1==(31&H[q]))break}else 0==H[q+2]?q++:q+=3;else q+=2;else q+=1;var J="P";t=(s[21]<<8)+s[20];var Z=0;for(q=0;q8e3&&(z.error={errorCode:101},this.rtpReturnCallback(z))),A=Q,e!==n&&(this.decoder.free(),e=n,this.decoder.setOutputSize(e)),!0===m&&"P"===J)return;!0===m&&(m=!1),"I"===J&&d<2&&d++,_.frameData=null,!0===c&&!0===r||(_.frameData=this.decoder.decode(H)),_.timeStamp=null,h=null===h.timestamp?this.getTimeStamp():h,_.timeStamp=h}else{var $=null;if(b?_.initSegmentData=null:(b=!0,L={id:1,width:T,height:S,type:"video",profileIdc:a.getSpsValue("profile_idc"),profileCompatibility:0,levelIdc:a.getSpsValue("level_idc"),sps:[v],pps:[y],timescale:1e3,fps:this.getFramerate()},i.log(JSON.stringify(L)),_.initSegmentData=u.initSegment(L),_.codecInfo=a.getCodecInfo()),Z||i.log("11111111111111111111111111111111111111111"),"I"===J){var tt=Z;$=H.subarray(tt,H.length)}else $=H.subarray(Z,H.length);var et=$.length-4;$[0]=(4278190080&et)>>>24,$[1]=(16711680&et)>>>16,$[2]=(65280&et)>>>8,$[3]=255&et;var rt=this.getFramerate(),at={duration:Math.round(1/rt*1e3),size:$.length,frame_time_stamp:null,frameDuration:null};if(r)at.frame_time_stamp=t,_.frameData=new Uint8Array($),_.mediaSample=at;else{if(!1===c){if(at.frame_time_stamp=1e3*h.timestamp+h.timestamp_usec-R,!1===D)at.frame_time_stamp=0,R=1e3*h.timestamp+h.timestamp_usec,at.frameDuration=0,g=at,D=!0;else{var nt=g.frame_time_stamp,it=at.frame_time_stamp;at.frameDuration=Math.abs(it-nt),at.frameDuration>3e3&&(at.frameDuration=0),g=at}_.frameData=new Uint8Array($),_.mediaSample=at}h=null===h.timestamp?this.getTimeStamp():h,_.timeStamp=h}}var ot=w*C;if(!0===r&&(NaN.toFixed(0),ot>786432?(P("video"),z.decodeMode="video"):(P("canvas"),z.decodeMode="canvas")),_.playback=r,_.frameData.frameIndex=L.frameIndex,z.decodedData=_,!0===I)return"I"===J&&F++,2===F&&(F=0,I=!1),void i.info("H264Session::stop");this.rtpReturnCallback(z)}},findIFrame:function(){if(null!==this.videoBufferList){var t=this.videoBufferList.findIFrame();if(null===t||"undefined"===typeof t)return!1;var e={};return this.setTimeStamp(t.timeStamp),e.frameData=this.decoder.decode(t.buffer),e.timeStamp=t.timeStamp,e}},setInitSegment:function(){b=!1,f=null,l=null},setLessRate:function(t){E=t}},new z};var m=function(){var t,e,r,a,n,o,s,u,f,l=null,c=new Uint8Array,p=!1;function m(){l=Module._OpenDecoder(1,0,0),m.prototype.setIsFirstFrame(!1)}return m.prototype={init:function(){i.log("H265 Decoder init")},setOutputSize:function(t){u!=2*t&&(u=2*t,f=Module._malloc(u),c=new Uint8Array(Module.HEAPU8.buffer,f,u))},decode:function(i,f){if(t=Date.now(),e=new Uint8Array(i),c.set(e),r=Module._FrameAlloc(),Module._DecodeFrame(l,c.byteOffset,i.byteLength,u,r),a=Date.now()-t,o=Module._getYLength(r),n=Module._getHeight(r),!m.prototype.isFirstFrame())return m.prototype.setIsFirstFrame(!0),{firstFrame:!0};if(o>0&&n>0){t=Date.now();var p=new Uint8Array(c);return s={data:p,option:{yaddr:Module._getY(r),uaddr:Module._getU(r),vaddr:Module._getV(r),ylen:o,height:n,beforeDecoding:t},width:o,height:n,codecType:"h265",decodingTime:a,frameType:f},Module._FrameFree(r),s}},setIsFirstFrame:function(t){p=t},isFirstFrame:function(){return p},free:function(){Module._free(f),f=null}},new m};function d(){var t=null,e=null,r=0,a=0,n=0,i=0,o=0;function s(){0,t=new l}function u(){return 0==n&&(i=function(){if(a>=r)return 0;var t=e[a++];return 0==t?(o++,a>--n&1}function f(t,e){for(var r=0;e>0;)r<<=1,r|=u(),e--;return r}function c(t,e){for(var n=0;a=1&&i<=5||a[1]||a[2]||a[3]||a[4]||a[5]||a[9]?t.put("general_inbld_flag",f(0,1)):t.put("general_reserved_zero_bit",f(0,1))}t.put("general_level_idc",f(0,8));var o=new Array(r),s=new Array(r);for(_=0;_0)for(var _=r;_<8;_++)u[_]=f(0,2);for(_=0;_=1&&l[_]<=5||9==l[_]||m[1]||m[2]||m[3]||m[4]||m[5]||m[9]?t.put("sub_layer_inbld_flag",f(0,1)):t.put("sub_layer_reserved_zero_bit",f(0,1))}s[_]&&t.put("sub_layer_level_idc",f(0,8))}}(1,t.get("sps_max_sub_layers_minus1"))),f(0,84),t.put("sps_seq_parameter_set_id",c()),r?(t.put("update_rep_format_flag",f(0,1)),t.get("update_rep_format_flag")&&t.put("sps_rep_format_idx",f(0,8))):(t.put("chroma_format_idc",c()),3===t.get("chroma_format_idc")&&t.put("separate_colour_plane_flag",f(0,1)),t.put("pic_width_in_luma_samples",c()),t.put("pic_height_in_luma_samples",c()),t.put("conformance_window_flag",f(0,1)),t.get("conformance_window_flag")&&(t.put("conf_win_left_offset",c()),t.put("conf_win_right_offset",c()),t.put("conf_win_top_offset",c()),t.put("conf_win_bottom_offset",c()))),!0},parse2:function(s){var u=s.length;if(s,e=s,r=s.length,a=0,n=0,i=0,o=0,0,t.clear(),u<20)return!1;f(0,16),f(0,4);var l=f(0,3);if(t.put("sps_max_sub_layers_minus1",l),l>6)return!1;f(0,1),f(0,2),f(0,1);f(0,5);f(0,32),f(0,1),f(0,1),f(0,1),f(0,1),f(0,43),f(0,1),t.put("general_level_idc",f(0,8));for(var p=[],m=[],d=0;d0)for(d=l;d<8;d++)f(0,2);for(d=0;d15)return!1;var h=c();return t.put("chroma_format_idc",h),!(_>3)&&(3==h&&f(0,1),t.put("pic_width_in_luma_samples",c()),t.put("pic_height_in_luma_samples",c()),f(0,1)&&(c(),c(),c(),c()),c()==c())},getSizeInfo:function(){var e=t.get("pic_width_in_luma_samples"),r=t.get("pic_height_in_luma_samples");if(t.get("conformance_window_flag")){var a=t.get("chroma_format_idc"),n=t.get("separate_colour_plane_flag");"undefined"===typeof n&&(n=0);var i=1!==a&&2!==a||0!==n?1:2,o=1===a&&0===n?2:1;e-=i*t.get("conf_win_right_offset")+i*t.get("conf_win_left_offset"),r-=o*t.get("conf_win_bottom_offset")+o*t.get("conf_win_top_offset")}return{width:e,height:r,decodeSize:e*r}},getSpsValue:function(e){return t.get(e)}},new s}var _=function(){var t,e=0,r=0,a=0,n=0,s=new d,u={frameData:null,timeStamp:null},f={timestamp:null,timezone:null},l=0,c=0,p=null,_=0,h={width:0,height:0},g=0,v=0;function y(){this.decoder=m(),this.firstTime=0,this.lastMSW=0}return y.prototype={setReturnCallback:function(t){this.rtpReturnCallback=t},setBufferfullCallback:function(t){null!==this.videoBufferList&&this.videoBufferList.setBufferFullCallback(t)},getVideoBuffer:function(t){if(null!==this.videoBufferList)return this.videoBufferList.searchNodeAt(t)},clearBuffer:function(){null!==this.videoBufferList&&this.videoBufferList.clear()},findCurrent:function(){null!==this.videoBufferList&&this.videoBufferList.searchTimestamp(this.getTimeStamp())},ntohl:function(t){return(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3]>>>0},appendBuffer:function(t,e,r){if(r+e.length>=t.length){var a=new Uint8Array(t.length+1048576);a.set(t,0),t=a}return t.set(e,r),t},setGovLength:function(t){p=t},getGovLength:function(){return p},setDecodingTime:function(t){this.decodingTime=t},getDropPercent:function(){return 0},getDropCount:function(){return 0},initStartTime:function(){this.firstDiffTime=0,this.calcGov=0},setCheckDelay:function(t){this.checkDelay=t},init:function(){this.decoder.setIsFirstFrame(!1),this.videoBufferList=new o,this.firstDiffTime=0,this.checkDelay=!0,this.timeData=null},parseRTPData:function(o,p,m,d,_){var y=null,b={},D=(p[19]<<24)+(p[18]<<16)+(p[17]<<8)+p[16]>>>0,T=Date.UTC("20"+(D>>>26),(D>>>22&15)-1,D>>>17&31,D>>>12&31,D>>>6&63,63&D)/1e3;if(T+=(new Date).getTimezoneOffset()/60*3600,0==this.firstTime)this.firstTime=T,this.lastMSW=0,r=(p[21]<<8)+p[20],f={timestamp:this.firstTime,timestamp_usec:0};else{var S,w=(p[21]<<8)+p[20];S=w>r?w-r:w+65535-r,this.lastMSW+=S,T>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=T,f={timestamp:T,timestamp_usec:this.lastMSW},r=w}0!==this.getFramerate()&&"undefined"!==typeof this.getFramerate()||"undefined"===typeof this.getTimeStamp()||(this.setFramerate(Math.round(1e3/((f.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(f.timestamp_usec-this.getTimeStamp().timestamp_usec)))),i.log("setFramerate"+Math.round(1e3/((f.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(f.timestamp_usec-this.getTimeStamp().timestamp_usec))))),this.setTimeStamp(f);var C=p[22];t=p.subarray(24+C,p.length-8),e=(p[21]<<8)+p[20];for(var I=[],F=0;F<=t.length;)if(0==t[F])if(0==t[F+1])if(1==t[F+2]){if(I.push(F),5==(31&t[F+=3])||1==(31&t[F]))break}else 0==t[F+2]?F++:F+=3;else F+=2;else F+=1;var A="P";for(F=0;F>1&63){default:break;case 33:A="I",s.parse2(y);var M=_;n=s.getSizeInfo().decodeSize,l=M.width,c=M.height,h.width==M.width&&h.height==M.height||(0!=h.width?(h.width=M.width,h.height=M.height,b.resolution=h,b.resolution.decodeMode="canvas",b.resolution.encodeMode="h265"):(h.width=M.width,h.height=M.height,b.decodeStart=h,b.decodeStart.decodeMode="canvas",b.decodeStart.encodeMode="h265"))}var k=1e3*f.timestamp+f.timestamp_usec;0==this.firstDiffTime?(g=0,this.firstDiffTime=Date.now()-k,i.log("firstDiff: 0")):(k-v<0&&(this.firstDiffTime=g+(Date.now()-k).toFixed(0)),(g=Date.now()-k-this.firstDiffTime)<0&&(this.firstDiffTime=0,g=0),g>8e3&&(b.error={errorCode:101},this.rtpReturnCallback(b))),v=k,u.frameData=null,a!==n&&(this.decoder.free(),a=n,this.decoder.setOutputSize(a)),u.frameData=this.decoder.decode(t),u.frameData.frameType=A,u.frameData.frameIndex=_.frameIndex,u.timeStamp=null,f=null===f.timestamp?this.getTimeStamp():f,u.timeStamp=f,m&&(b.backupData={stream:t,frameType:A,width:l,height:c,codecType:"h265"},null!==f.timestamp&&"undefined"!==typeof f.timestamp?b.backupData.timestamp_usec=f.timestamp_usec:b.backupData.timestamp=(e/90).toFixed(0)),b.decodedData=u,this.rtpReturnCallback(b)},findIFrame:function(){if(null!==this.videoBufferList){var t=this.videoBufferList.findIFrame();if(null===t||"undefined"===typeof t)return!1;var e={};return this.setTimeStamp(t.timeStamp),e.frameData=this.decoder.decode(t.buffer),e.timeStamp=t.timeStamp,e}},getFramerate:function(){return _},setFramerate:function(t){0>>0,S=Date.UTC("20"+(T>>>26),(T>>>22&15)-1,T>>>17&31,T>>>12&31,T>>>6&63,63&T)/1e3;if(S-=28800,0==this.firstTime)this.firstTime=S,this.lastMSW=0,f=(p[21]<<8)+p[20],a={timestamp:this.firstTime,timestamp_usec:0};else{var w,C=(p[21]<<8)+p[20];w=C>f?C-f:C+65535-f,this.lastMSW+=w,S>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=S,a={timestamp:S,timestamp_usec:this.lastMSW},f=C}0!==this.getFramerate()&&"undefined"!==typeof this.getFramerate()||"undefined"===typeof this.getTimeStamp()||this.setFramerate(Math.round(1e3/((a.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(a.timestamp_usec-this.getTimeStamp().timestamp_usec)))),this.setTimeStamp(a),u=(p[21]<<8)+p[20],s=c,(y=this.appendBuffer(y,D,n))[(n+=c)+s-2]=255,y[n+s-1]=217,g.width==t&&g.height==e||(0!=g.width?(g.width=t,g.height=e,l.resolution=g,l.resolution.decodeMode="canvas",l.resolution.encodeMode="mjpeg"):(g.width=t,g.height=e,l.decodeStart=g,l.decodeStart.decodeMode="canvas",l.decodeStart.encodeMode="mjpeg"));var I=1e3*a.timestamp+a.timestamp_usec;0==this.firstDiffTime?(d=0,this.firstDiffTime=Date.now()-I,i.log("firstDiff: "+this.firstTime)):(I-_<0&&(this.firstDiffTime=d+(Date.now()-I).toFixed(0)),(d=Date.now()-I-this.firstDiffTime)<0&&(this.firstDiffTime=0,d=0),d>8e3&&(l.error={errorCode:101},this.rtpReturnCallback(l))),_=I,r.frameData=null,this.decoder.setResolution(t,e),r.frameData=this.decoder.decode(y.subarray(0,n)),r.timeStamp=null,a=null===a.timestamp?this.getTimeStamp():a,r.timeStamp=a,!0===m&&(l.backupData={stream:y.subarray(0,n),width:t,height:e,codecType:"mjpeg"},null!==a.timestamp&&"undefined"!==typeof a.timestamp?l.backupData.timestamp_usec=a.timestamp_usec:l.backupData.timestamp=(u/90).toFixed(0)),n=0,r.playback=!1,l.decodedData=r,this.rtpReturnCallback(l)},getVideoBuffer:function(t){if(null!==this.videoBufferList)return this.videoBufferList.searchNodeAt(t)},clearBuffer:function(){null!==this.videoBufferList&&this.videoBufferList.clear()},findCurrent:function(){null!==this.videoBufferList&&this.videoBufferList.searchTimestamp(this.getTimeStamp())},findIFrame:function(){null!==this.videoBufferList&&this.videoBufferList.findIFrame()},SetRtpInterlevedID:function(t){this.interleavedID=t},setTimeStamp:function(t){this.timeData=t},getTimeStamp:function(){return this.timeData},getRTPPacket:function(t,e){},calculatePacketTime:function(t){},ntohl:function(t){return(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3]>>>0},appendBuffer:function(t,e,r){if(r+e.length>=t.length){var a=new Uint8Array(t.length+1048576);a.set(t,0),t=a}return t.set(e,r),t},setFramerate:function(t){00&&(u.fatherId=[]);for(var c=0;c0&&(u.track=[]);for(var p=0;p>2&3,r.coSafetyBelt=3&t[a],a+=1,r.mainSunvisor=t[a]>>2&3,r.coSunvisor=3&t[a],a+=1,e.attribute81.push(r),n}function _(t,e){e.hasOwnProperty("attribute82")||(e.attribute82=[]);var r={},a=1,n=t[a];return a+=1,r.plateEncode=t[a],a+=1,r.plateInfoLen=t[a],a+=1,r.plateInfo=t.subarray(a,a+r.plateInfoLen),e.attribute82.push(r),n}function h(t,e){e.hasOwnProperty("attribute83")||(e.attribute83=[]);var r={},a=1,n=t[a];return a+=1,r.color={},r.color.valid=t[a],a+=1,r.color.red=t[a],a+=1,r.color.green=t[a],a+=1,r.color.blue=t[a],a+=1,r.color.alpha=t[a],a+=1,r.country=String.fromCharCode.apply(null,t.subarray(a,a+4)),a+=4,r.plateType=(t[a+1]<<8)+t[a],a+=2,a+=1,r.plateWidth=(t[a+1]<<8)+t[a],e.attribute83.push(r),n}function g(t,e){e.hasOwnProperty("attribute84")||(e.attribute84=[]);var r={},a=1,n=t[a];a+=1,r.fatherCount=t[a],a+=1,r.trackCount=t[a],a+=1,r.trackType=t[a],a+=1,a+=3,r.fatherCount>0&&(r.fatherID=[]);for(var i=0;i0&&(r.track=[]);for(var o=0;o0&&(r.mainColorInfo=[]);for(var i=0;i>2&3,r.beard=3&t[a],e.attribute88.push(r),len}function T(t,e){e.hasOwnProperty("attribute89")||(e.attribute89=[]);var r={},a=1,n=t[a];a+=1,r.yawAngle=parseInt((t[a+1]<<8)+t[a]),a+=2,r.rollAngle=parseInt((t[a+1]<<8)+t[a]),a+=2,r.pitchAngle=parseInt((t[a+1]<<8)+t[a]);var i=(t[(a+=2)+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a];a+=2,r.lEyePos=[i,o],i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],a+=2,r.rEyePos=[i,o],i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],a+=2,r.nosePos=[i,o],i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],a+=2,r.lMouthPos=[i,o],i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],a+=2,r.rMouthPos=[i,o];var s=t[a];a+=3,s>0&&(r.featurePos=[]);for(var u=0;u0&&(r.hangingCount=[]);for(var i=0;i0&&(r.tissueCount=[]),i=0;i0&&(r.sunVisorCount=[]),i=0;i0&&(r.annualInspectionCount=[]),i=0;i>>0,m=Date.UTC("20"+(p>>26),(p>>22&15)-1,p>>17&31,p>>12&31,p>>6&63,63&p)/1e3;if(m-=28800,0==this.firstTime)this.firstTime=m,this.lastMSW=0,e=(n[21]<<8)+n[20],t={timestamp:this.firstTime,timestamp_usec:0};else{var d,_=(n[21]<<8)+n[20];d=_>=e?_-e:_+65535-e,this.lastMSW+=d,m>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=m,t={timestamp:m,timestamp_usec:this.lastMSW},e=_}!function(e,a,n,i){var f=a[22],l=a.subarray(24+f,a.length-8);switch(e){case 0:n({ivsDraw:o(l),timeStamp:t,channel:i});break;case 5:n({ivsDraw:s(l),timeStamp:t,channel:i});break;case 6:break;case 14:var c=[];if(function(t,e){for(var a=t.length,n=0;n+40&&(U("mediaSample",e.mediaSample),U("videoRender",e.frameData))}else U("drop",t.decodedData);null!=t.resolution&&U("MSEResolutionChanged",t.resolution),null!=t.ivsDraw&&U("ivsDraw",t)}function U(t,e,r){var a={type:t,data:e,channelId:k,option:r};"canvasRender"===t?postMessage(a,[e.buffer]):postMessage(a)}}]);