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=0)}([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)}if(n.r(t),void 0===o)var o={};o.MD5=function(e){function t(e){var t=(e>>>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 a(e,t,n){return e^t^n}function i(e,t,n){return t^(e|~n)}function l(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-a),h=i}var r=c.length;c.push(128);var u=c.length%64;if(u>56){for(var s=0;s<64-u;s++)c.push(0);u=c.length%64}for(s=0;s<56-u;s++)c.push(0);c=c.concat(function(e){for(var t=[],n=0;n<8;n++)t.push(255&e),e>>>=8;return t}(8*r));var f=1732584193,d=4023233417,m=2562383102,g=271733878,h=0,S=0,y=0,v=0;for(s=0;s=0;u--)i=255&(l=arguments[u]),i<<=8,i|=255&(l>>>=8),i<<=8,i|=255&(l>>>=8),i<<=8,a+=t(i|=l>>>=8);return a}(g,m,d,f).toUpperCase()}()};var a=function(e){return o.MD5(e)},i=0;function l(e){return s(u(c(e)))}function u(e){return p(d(f(e),8*e.length))}function s(e){for(var t,n=i?"0123456789ABCDEF":"0123456789abcdef",r="",o=0;o>>4&15)+n.charAt(15&t);return r}function c(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 f(e){for(var t=Array(e.length>>2),n=0;n>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t}function p(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 d(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,a=-1732584194,i=271733878,l=-1009589776,u=0;u>16)+(t>>16)+(n>>16)<<16|65535&n}function S(e,t){return e<>>32-t}var y,v=l,_=function(e){e=e;var t=!1,n="",r="",o="",i=null,l=null,u=null,s=0,c=0,f=!1,p=!1,d=0,m=!1,g="",h={videoSSRC:0,audio1SSRC:0,audio2SSRC:0},S=!1,y=200,_=401,P=404,E=457,b=503,A="",w='Authorization: WSSE profile="UsernameToken"',T=[],C=1,M={},D="",R=null,I=null,U=null,k={},H={},L=null,O=null,F=null,B=null,G=null,x="play",V=null,N={},W=[],z=!1,Y=!1,q=0,j=0,K=3,X=0,J=8,Z=!1;function Q(){}function $(e,t){var n=e.split("#")[0];if(n){var r=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),o=n.match(r);if(null!==o)return unescape(o[2])}return null}function ee(i,l,u,s){return t?function(t,n,o,a){var i="";switch(t){case"OPTIONS":case"TEARDOWN":case"GET_PARAMETER":case"SET_PARAMETERS":i=t+" "+r+" RTSP/1.0\r\nCSeq: "+C+"\r\n"+A+"\r\n";break;case"DESCRIBE":if(i=t+" "+r+" RTSP/1.0\r\nCSeq: "+C,!0===p&&-1===r.indexOf("subtype=5")){i+="\r\nRequire: www.onvif.org/ver20/backchannel"}i=i+"\r\n"+A+"\r\n",le(),ue();break;case"SETUP":e.log("trackID: "+n),i=t+" "+r+"/trackID="+n+" RTSP/1.0\r\nCSeq: "+C+"\r\n"+A+"Transport: DH/AVP/TCP;unicast;interleaved="+2*n+"-"+(2*n+1)+"\r\n",i+=0!=I?"Session: "+I+"\r\n\r\n":"\r\n",le(),ue();break;case"PLAY":i=t+" "+r+" RTSP/1.0\r\nCSeq: "+C+"\r\nSession: "+I+";timeout=60\r\n",null!=a&&a>=0?(i+="Range: npt="+a+"-\r\n",i+=A+"\r\n"):i+=A+"\r\n",le(),ue(),Z||(X=setTimeout((function(){X&&(clearTimeout(X),X=0),q&&(clearTimeout(q),q=0),j&&(clearTimeout(j),j=0),B({errorCode:"409",description:"Rtsp Not Response"})}),1e3*J));break;case"PAUSE":i=t+" "+r+" RTSP/1.0\r\nCSeq: "+C+"\r\nSession: "+I+"\r\n\r\n";break;case"SCALE":i="PLAY "+r+" RTSP/1.0\r\nCSeq: "+C+"\r\nSession: "+I+"\r\n",i+=a<8?"Speed: "+a+"\r\n":"Scale: "+a+"\r\n",i+=A+"\r\n"}return i}(i,l,0,s):function(e,t,i,l){var u="",s="",c=a(H.username+"::"+H.password),f=n.split("://")[1].split("/")[0].split(":")[0]+":8086",g=!1;if(m){var h=$(o,"beginTime"),S=$(o,"endTime"),y=h?h.replace(/-|:|\s/g,"_"):"",_=S?S.replace(/-|:|\s/g,"_"):"";0!=y.length&&0!=_.length&&(g=!0)}var P=o&&o.replace(/&beginTime=\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}&endTime=\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/,"");switch(e){case"PLAY":var E=function(){for(var e=[],t=0;t<32;t++)e.push(String.fromCharCode(256*Math.random()|0));return a(e.join(""))}(),b=(M=new Date,R=M.getTimezoneOffset(),I=M.getTime()+60*R*1e3,U=new Date(I),k=U.getFullYear(),L=U.getMonth()+1,O=U.getDate(),F=U.getHours(),B=U.getMinutes(),G=U.getSeconds(),k+"-"+(x=function(e){return e<10?"0"+e:e})(L)+"-"+x(O)+"T"+x(F)+":"+x(B)+":"+x(G)+"Z"),T=function(e){var t,n,r,o,a,i,l,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="",c=0;for(;c>2,a=(3&t)<<4|n>>4,i=(15&n)<<2|r>>6,l=63&r,isNaN(n)?i=l=64:isNaN(r)&&(l=64),s=s+u.charAt(o)+u.charAt(a)+u.charAt(i)+u.charAt(l);return s}(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 a=[],i=0;i0?"?sourceId=".concat(P):"")+" HTTP/1.1\r\n",u+="Accept-Sdp: Private\r\n",u+=A+"\r\n",u+="Connection: keep-alive\r\nCseq: "+C+"\r\nHost: "+f+"\r\n",l?u+="Range: npt="+l+"-\r\n":d?u+="Range: npt="+d+"-\r\n":"ContinuePlay"!==D&&(u+="Range: npt=0.000000-\r\n"),p&&(s+="v=0\r\n",s+="o=- 2208989105 2208989105 IN IP4 0.0.0.0\r\n",s+="s=Media Server\r\n",s+="c=IN IP4 0.0.0.0\r\n",s+="t=0 0\r\n",s+="a=control:*\r\n",s+="a=packetization-supported:DH\r\n",s+="a=rtppayload-supported:DH\r\n",s+="a=range:npt=now-\r\n",s+="m=audio 0 RTP/AVP 8\r\n",s+="a=control:trackID=5\r\n",s+="a=rtpmap:8 PCMA/16000\r\n",u+="Private-Length: "+(s+="a=sendonly\r\n").length+"\r\n",u+="Private-Type: application/sdp\r\n"),u+=A===w?'WSSE: UsernameToken Username="'+H.username+'", PasswordDigest="'+T+'", Nonce="'+E+'", Created="'+b+'"\r\n\r\n':"\r\n",u+=s;break;case"PAUSE":u="GET "+r+(g?"&starttime=".concat(y,"&endtime=").concat(_,"&"):"&")+"method=1"+(P.length>0?"?sourceId=".concat(P):"")+" HTTP/1.1\r\n",u+="Connection: keep-alive\r\nCseq: "+C+"\r\nHost: "+f+"\r\n\r\n";break;case"KEEP_LIVE":u="GET "+r+(g?"&starttime=".concat(y,"&endtime=").concat(_,"&"):"&")+"method=2"+(P.length>0?"?sourceId=".concat(P):"")+" HTTP/1.1\r\n",u+="Connection: keep-alive\r\nCseq: "+C+"\r\nHost: "+f+"\r\n\r\n";break;case"STOP":case"TEARDOWN":u="GET "+r+(g?"&starttime=".concat(y,"&endtime=").concat(_,"&"):"&")+"method=3?sourceId="+P+" HTTP/1.1\r\n",u+="Connection: keep-alive\r\nCseq: "+C+"\r\nHost: "+f+"\r\n\r\n";break;case"SCALE":u="GET "+r+(g?"&starttime=".concat(y,"&endtime=").concat(_,"&"):"&")+"method=0"+(P.length>0?"?sourceId=".concat(P):"")+" HTTP/1.1\r\n",u+=l<8?"Speed: "+l+"\r\n":"Scale: "+l+"\r\n",u+="Connection: keep-alive\r\nCseq: "+C+"\r\nHost: "+f+"\r\n\r\n"}var M,R,I,U,k,L,O,F,B,G,x;return u}(i,0,0,s)}function te(n){e.log(n);var o,l=n.search("CSeq: ")+5;if(C=parseInt(n.slice(l,l+10))+1,(o=function(e){var t={},n=0,r=0,o=null,a=null;if(-1!==e.search("Content-Type: application/sdp")){var i=e.split("\r\n\r\n");a=i[0]}else a=e;var l=a.split("\r\n"),u=l[0].split(" ");u.length>2&&(t.ResponseCode=parseInt(u[1]),t.ResponseMessage=u[2]);if(t.ResponseCode===y){for(n=1;n1&&(t.RtpInterlevedID=parseInt(d[0]),t.RtcpInterlevedID=parseInt(d[1]))}}}else if("RTP-Info"===o[0]){o[1]=l[n].substr(9);var m=o[1].split(",");for(t.RTPInfoList=[],r=0;r0;)if(36!==f[0]){var p=String.fromCharCode.apply(null,f),d=null;if(p.includes("302 Moved"))return ae(r=p.slice(p.indexOf("rtsp://"),p.indexOf("\r\n\r\n"))),Q.prototype.disconnect(),void Q.prototype.connect(n,r,o,N);if((-1!==p.indexOf("OffLine:File Over")||-1!==p.indexOf("OffLine: File Over")||-1!==p.indexOf("OffLine:Internal Error")||p.includes("is_session_end: true"))&&(i.fileOver=!0,F()),-1!==p.indexOf("OffLine:Internal Error")&&B({errorCode:500,description:"Internal Error"}),-1!==p.indexOf("OffLine:KmsUnavailable")&&B({errorCode:203,description:"KmsUnavailable"}),"Describe"===D&&-1!==p.indexOf("a=control:trackID=")&&(W=p.split("a=control:").filter((function(e){return e.startsWith("trackID=")})).map((function(e){return e.split("\r\n")[0]}))||[]),-1!==p.indexOf("Range: npt=")){var m=p.split("Range: ")[1].split("\r\n")[0],S=m.split("npt=")[1].split("-")[0],y=m.split("-")[1];G(y-S)}var v=p.indexOf("interleaved=");if(-1!=v){var _=p.slice(v),P=_.indexOf("-");if(-1!=P){var E=_.slice(12,P);if(E/=2,-1!=(v=p.indexOf("ssrc="))){var b=p.slice(v+5,v+5+8),A=parseInt(b,16);0!=A&&(0==E?h.videoSSRC=A:1==E?h.audio1SSRC=A:2==E&&(h.audio2SSRC=A))}}}z||!Y&&-1!==p.indexOf("200 OK")?(z&&(g=p),d=p.lastIndexOf("\r\n"),z=!1,Y=!0):d=p.search("\r\n\r\n");var w=-1;if(-1===(w=t?p.search("RTSP"):p.search("HTTP")))return void(f=new Uint8Array);if(-1===d)return void(s=f.length);l=f.subarray(w,d+6),f=f.subarray(d+6),re(te(String.fromCharCode.apply(null,l))),s=f.length}else{if(x="PLAY",clearTimeout(V),V=setTimeout((function(){x="GET_PARAMETER"}),1e4),u=f.subarray(0,6),!((c=u[2]<<24|u[3]<<16|u[4]<<8|u[5])+6<=f.length))return void(s=f.length);var T=f.subarray(6,c+6);se(u,T),f=f.subarray(c+6),s=f.length}}function le(){q&&clearTimeout(q),X&&(clearTimeout(X),X=0),q=setTimeout((function(){B({errorCode:"407",description:"Request Timeout"})}),3e4)}function ue(){j&&clearTimeout(j),j=setTimeout((function(){X&&(clearTimeout(X),X=0),B({errorCode:"408",description:"Short Request Timeout"})}),1e3*K)}function se(e,t){X&&(clearTimeout(X),X=0),L(t),!0}function ce(e){var n={};n.Sessions=[];var r=null;-1!==e.search("Content-Type: application/sdp")||-1!==e.search("Private-Type: application/sdp")?r=e.split("\r\n\r\n")[1]:r=e;var o=r.split("\r\n"),a=0,i=!1;for(a=0;a0)switch(l[0]){case"a":var u=l[1].split(":");if(u.length>1){if("control"===u[0]){var s=o[a].search("control:");!0===i?-1!==s&&(n.Sessions[n.Sessions.length-1].ControlURL=o[a].substr(s+8)):-1!==s&&(n.BaseURL=o[a].substr(s+8))}else if("rtpmap"===u[0]){var c=u[1].split(" ");n.Sessions[n.Sessions.length-1].PayloadType=c[0];var f=c[1].split("/");n.Sessions[n.Sessions.length-1].CodecMime=f[0],f.length>1&&(n.Sessions[n.Sessions.length-1].ClockFreq=f[1])}else if("framesize"===u[0]){var d=u[1].split(" ");if(d.length>1){var m=d[1].split("-");n.Sessions[n.Sessions.length-1].Width=m[0],n.Sessions[n.Sessions.length-1].Height=m[1]}}else if("framerate"===u[0])n.Sessions[n.Sessions.length-1].Framerate=u[1];else if("fmtp"===u[0]){var g=o[a].split(" ");if(g.length<2)continue;for(var h=1;h1&&(n.Sessions[n.Sessions.length-1].SPS=_[0],n.Sessions[n.Sessions.length-1].PPS=_[1])}}}}}else 1===u.length&&("recvonly"===u[0]?n.Sessions[n.Sessions.length-1].TalkTransType="recvonly":"sendonly"===u[0]&&(n.Sessions[n.Sessions.length-1].TalkTransType="sendonly"));break;case"m":var P=l[1].split(" "),E={};E.Type=P[0],E.Port=P[1],E.Payload=P[3],n.Sessions.push(E),i=!0;break;case"b":if(!0===i){var b=l[1].split(":");n.Sessions[n.Sessions.length-1].Bitrate=b[1]}}}if(!t&&p)for(var A=0;Ae.length)&&(t=e.length);for(var n=0,r=new Array(t);n=8&&(a=!0),t?function(e,t,n,r,o){y._RTSP_PlayControl(e,t,n,r,o)}(e,n,r,o,a):function(e,t,n,r,o){y._RTSV_PlayControl(e,t,n,r,o)}(e,n,r,o,a)},PutStream:function(n,r){if(null!=o){var a=n.subarray(6);if(5==r)o.set(a),t?b(e,o.byteOffset,a.length,r):A(e,o.byteOffset,a.length,r);else{if(a.length>1048576)return void console.warn("StreamClient buffer not enough, DataLen:"+a.length);i.set(a),t?b(e,i.byteOffset,a.length,r):A(e,i.byteOffset,a.length,r)}}},GetPlayInfo:function(){var n=0;if(t){var r=P(function(e){var t=y._malloc(8),n=y._malloc(8);y._RTSP_GetPlayInfo(e,t,n);var r=y.HEAPF64[t>>3],o=y.HEAPF64[n>>3];return y._free(t),y._free(n),[r,o]}(e),2),o=r[0];n=r[1]-o}return n},SetMsgWaitTimeout:function(n){t?function(e,t){y._RTSP_SetMsgTimeout(e,t)}(e,n):function(e,t){y._RTSV_SetMsgTimeout(e,t)}(e,n)}},new l},T="Opera",C="Chrome",M="Firefox",D="Edge",R="Edg",I="IE",U="Safari";function k(){var e=navigator.userAgent;return e.includes("Edge")?D:e.includes("Edg")?R:e.includes("Firefox")?M:e.includes("Chrome")?C:e.includes("Safari")?U:e.includes("compatible")&&e.includes("MSIE")&&e.includes("Opera")?I:e.includes("Opera")?T:""}function H(e){return navigator.userAgent.split(e)[1].split(".")[0].slice(1)}var L=function(){var e=2;function t(){}return t.prototype={setPrintLogLevel:function(t){e=t},fatal:function(t){e>=1&&console.error(t)},error:function(t){e>=2&&console.error(t)},warn:function(t){e>=3&&console.warn(t)},info:function(t){e>=4&&console.info(t)},trace:function(t){e>=5&&console.log(t)},log:function(t){e>=6&&console.log(t)}},new t};function O(){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}(function(){function e(){}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 a=new e;return a.type=n.type,a.source=r,a},e.createFromSource=function(t,n){var r=new e;return r.type=t,r.source=n,r}})(),function(){function e(e){this.gl=e,this.program=this.gl.createProgram()}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)}}}(),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)}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)}}}();function F(e){this.buffer=e,this.previous=null,this.next=null}var B=function(e){F.call(this,e)};function G(e){var t=e||25;function n(){this.first=null,this.size=0}return n.prototype={enqueue:function(e){this.size>=t&&this.clear();var n=new B(e);if(null===this.first)this.first=n;else{for(var r=this.first;null!==r.next;)r=r.next;r.next=n}return this.size+=1,n},dequeue:function(){var e=null;return null!==this.first&&(e=this.first,this.first=this.first.next,this.size-=1),e},clear:function(){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 n}var x=function(e){var t=[],n={},r=e;function o(){for(var e in t)t[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)];0,1==r?n.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]):2==r&&(n.FTYP=new Uint8Array([105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,97,118,99,49,109,112,52,49])),n.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),n.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),n.STSC=n.STCO=n.STTS,n.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),n.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]),n.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]),n.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),n.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:[],hev1:[],hvcC:[]};var a=function(e){for(var t=8,n=Array.prototype.slice.call(arguments,1),r=0;r>>24&255,o[a++]=t>>>16&255,o[a++]=t>>>8&255,o[a++]=255&t,o.set(e,a),a+=4;for(r=0;r>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),(n=e.config,r=n.length,o=new Uint8Array([0,0,0,0,3,23+r,0,1,0,4,15+r,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([r]).concat(n).concat([6,1,2])),a(t.esds,o)));var n,r,o},l=function(e){return"audio"===e.type?a(t.stsd,n.STSD_PREFIX,i(e)):a(t.stsd,n.STSD_PREFIX,function(e){var n=e.vps||[],o=e.sps||[],i=e.pps||[],l=[],u=[],s=[],c=0;for(c=0;c>>8),l.push(255&n[c].byteLength),l=l.concat(Array.prototype.slice.call(n[c]));for(c=0;c>>8),u.push(255&o[c].byteLength),u=u.concat(Array.prototype.slice.call(o[c]));for(c=0;c>>8),s.push(255&i[c].byteLength),s=s.concat(Array.prototype.slice.call(i[c]));return 1==r?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([o.length]).concat(u).concat([i.length]).concat(s)))):2==r?a(t.hev1,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.hvcC,new Uint8Array([1,e.general_profile_flag,(4278190080&e.general_profile_compatibility_flags)>>>24,(16711680&e.general_profile_compatibility_flags)>>>16,(65280&e.general_profile_compatibility_flags)>>>8,255&e.general_profile_compatibility_flags,(0xff0000000000&e.general_constraint_indicator_flags)>>>40,(0xff00000000&e.general_constraint_indicator_flags)>>>32,(4278190080&e.general_constraint_indicator_flags)>>>24,(16711680&e.general_constraint_indicator_flags)>>>16,(65280&e.general_constraint_indicator_flags)>>>8,255&e.general_constraint_indicator_flags,e.general_level_idc,240,0,252,252|e.chroma_format_idc,248|e.bitDepthLumaMinus8,248|e.bitDepthChromaMinus8,0,0,e.rate_layers_nested_length,3].concat([32,0,1]).concat(l).concat([33,0,1]).concat(u).concat([34,0,1]).concat(s)))):void 0}(e))},u=function(e){var r=null;return r="audio"===e.type?a(t.smhd,n.SMHD):a(t.vmhd,n.VMHD),a(t.minf,r,a(t.dinf,a(t.dref,n.DREF)),function(e){return a(t.stbl,l(e),a(t.stts,n.STTS),a(t.stsc,n.STSC),a(t.stsz,n.STSZ),a(t.stco,n.STCO))}(e))},s=function(e){return a(t.mdia,function(e){var n=e.timescale,r=e.duration;return a(t.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r,85,196,0,0]))}(e),function(e){var r=null;return r="audio"===e.type?n.HDLR_AUDIO:n.HDLR_VIDEO,a(t.hdlr,r)}(e),u(e))},c=function(e){return a(t.trak,function(e){var n=e.id,r=e.duration,o=e.width,i=e.height;return a(t.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,o>>>8&255,255&o,0,0,i>>>8&255,255&i,0,0]))}(e),s(e))},f=function(e){return a(t.mvex,function(e){var n=e.id,r=new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return a(t.trex,r)}(e))},p=function(e){var n,r,o=(n=e.timescale,r=e.duration,a(t.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r,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]))),i=c(e),l=f(e);return a(t.moov,o,i,l)},d=function(e,n){return"audio"===e.type?audioTrun(e,n):function(e,n){var r,o=null,i=null,l=0,u=n;if(null===(r=e.samples||[])[0].frameDuration)for(u+=24+4*r.length,o=trunHeader(r,u),l=0;l>>24,(16711680&i.size)>>>16,(65280&i.size)>>>8,255&i.size]);else for(o=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]}(r,u+=24+4*r.length+4*r.length),l=0;l>>24,(16711680&i.frameDuration)>>>16,(65280&i.frameDuration)>>>8,255&i.frameDuration,(4278190080&i.size)>>>24,(16711680&i.size)>>>16,(65280&i.size)>>>8,255&i.size]);return a(t.trun,new Uint8Array(o))}(e,n)},m=function(e,n){return a(t.moof,function(e){var n=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return a(t.mfhd,n)}(e),function(e){var n,r,o;return n=a(t.tfhd,new Uint8Array([0,2,0,0,0,0,0,1])),r=a(t.tfdt,new Uint8Array([0,0,0,0,e.baseMediaDecodeTime>>>24&255,e.baseMediaDecodeTime>>>16&255,e.baseMediaDecodeTime>>>8&255,255&e.baseMediaDecodeTime])),72,o=d(e,72),a(t.traf,n,r,o)}(n))};return o.prototype={initSegment:function(e){var r=a(t.ftyp,n.FTYP),o=p(e),i=new Uint8Array(r.byteLength+o.byteLength);return i.set(r,0),i.set(o,r.byteLength),i},mediaSegment:function(e,n,r,o){var i=m(e,n),l=function(e){return a(t.mdat,e)}(r),u=null;return(u=new Uint8Array(i.byteLength+l.byteLength)).set(i),u.set(l,i.byteLength),u}},new o};function V(e){var t=0,n=null,r=e;function o(){t=0,n=new W}function a(e,n){var r=n,o=t+r>>3;return r=t+n&7,e[o]>>7-(7&r)&1}function i(e,n){var r=t>>3,o=8*(r+1)-t;if(o<8)for(var a=0;a<3;a++){var i=e[r+a];i=0==a?i>>o<>8-o|1<=0;l--,i++)o|=a(e,i)<0)for(d=b;d<8;d++)u(_,2);for(d=0;d>=1;e+=p(o,0),e+=".",0===n.get("general_tier_flag")?e+="L":e+="H",e+=n.get("general_level_idc");var i=n.get("general_constraint_indicator_flags"),l=[(65280&i)>>>8,(16711680&i)>>>16,(4278190080&i)>>>24,(0xff00000000&i)>>>32,(0xff0000000000&i)>>>40],u=!1,s="";for(a=5;0<=a;a--)(l[a]||u)&&(s="."+p(l[a],0)+s,u=!0);return e+=s}}},new o}var N,W=function(){this.map={}};W.prototype={put:function(e,t){this.map[e]=t},get:function(e){return this.map[e]},containsKey:function(e){return e in this.map},containsValue:function(e){for(var t in this.map)if(this.map[t]===e)return!0;return!1},isEmpty:function(e){return 0===this.size()},clear:function(){for(var e in this.map)delete this.map[e]},remove:function(e){delete this.map[e]},keys:function(){var e=new Array;for(var t in this.map)e.push(t);return e},values:function(){var e=new Array;for(var t in this.map)e.push(this.map[t]);return e},size:function(){var e=0;for(var t in this.map)e++;return e}};function z(e){return N._RENDER_Destroy(e)}var Y;function q(e,t,n){return N._RENDER_AlgoCommand(e,t,n)}var j=5,K=6,X=7,J=16,Z=18,Q=19,$=21,ee=22,te=25,ne=28,re=1,oe=2,ae=3,ie=4;function le(e,t){Y._DRAW_CleanScreen(e),Y._DRAW_DrawByRenderHandle(e,0,t)}function ue(e){this.buffer=e,this.previous=null,this.next=null}var se=function(e,t,n,r,o){var a=n,i=e,l=r,u=null,s=0,c=0,f=!1,p=null,d=0,m=0,g=!1,h=!1,S=1,y=!1,v=0,_=0,P=0,E=o,b=-1,A=0,w=!1,T=null,C=!1,M=!1,D={},R=120,I=80,U=240;function k(){p=new G(a),f=!1}var H=function(e){if(null!==u){if(!w){w=!0;var t={decodeMode:"canvas"};t.width=v,t.height=_,1==A?t.encodeMode="H264":2==A&&(t.encodeMode="H265"),T&&T(t)}return b=e.buffer.nFrameID,function(e,t,n,r){var o,a=N._malloc(80),i=0,l=null,u=0,s=null,c=0,f=null;10!=t.ImageFormat&&(i=t.width0*t.height0,l=N._malloc(i),N.writeArrayToMemory(t.DataY,l),u=t.width1*t.height1,s=N._malloc(u),N.writeArrayToMemory(t.DataU,s),c=t.width2*t.height2,f=N._malloc(c),N.writeArrayToMemory(t.DataV,f)),N.HEAP32[a/4+0]=0,N.HEAP32[a/4+1]=t.ImageFormat,N.HEAP32[a/4+2]=0,N.HEAP32[a/4+3]=0,10!=t.ImageFormat?(N.HEAP32[a/4+4]=l,N.HEAP32[a/4+5]=s,N.HEAP32[a/4+6]=f):(N.HEAP32[a/4+4]=t.DataY,N.HEAP32[a/4+5]=0,N.HEAP32[a/4+6]=0),N.HEAP32[a/4+7]=t.width0,N.HEAP32[a/4+8]=t.width1,N.HEAP32[a/4+9]=t.width2,N.HEAP32[a/4+10]=t.height0,N.HEAP32[a/4+11]=t.height1,N.HEAP32[a/4+12]=t.height2,N.HEAP32[a/4+13]=t.width0,N.HEAP32[a/4+14]=t.width1,N.HEAP32[a/4+15]=t.width2,N.HEAP32[a/4+16]=t.height0,N.HEAP32[a/4+17]=t.height1,N.HEAP32[a/4+18]=t.height2,N.HEAP32[a/4+19]=0;var p=0,d=0;if(0!==n){p=N._malloc(16),N.HEAP32[p/4+0]=n.left,N.HEAP32[p/4+1]=n.top,N.HEAP32[p/4+2]=n.right,N.HEAP32[p/4+3]=n.bottom}if(0!==r){d=N._malloc(16),N.HEAP32[d/4+0]=r.left,N.HEAP32[d/4+1]=r.top,N.HEAP32[d/4+2]=r.right,N.HEAP32[d/4+3]=r.bottom}o=N._RENDER_DrawImage(e,a,p,d),10!=t.ImageFormat&&(N._free(l),N._free(s),N._free(f)),N._free(a),0!==p&&N._free(p),0!==d&&N._free(d)}(u,e.buffer.Image,0,0),y&&le(P,e.buffer.nFrameID),delete e.buffer,e.buffer=null,e.previous=null,e.next=null,e=null,C&&!M&&(0==q(u,1,!0)&&0==function(e,t){var n=N._malloc(16);N.HEAP32[n/4+0]=t.PanoARMode,N.HEAP32[n/4+1]=t.ImageStride,N.HEAP32[n/4+2]=t.ImageWidth,N.HEAP32[n/4+3]=t.ImageHeight;var r=N._RENDER_SetAlgoParams(e,n);return N._free(n),r}(u,D)?console.log("[Trace]RENDER_AlgoCommand and RENDER_SetAlgoParams success!"):console.log("[Error]RENDER_AlgoCommand or RENDER_SetAlgoParams failed!"),M=!0),n=u,N._RENDER_Present(n),!0}var n;return!1},L=function e(t){if(!0===f){if(0===s||t-sm)null!==(n=p.dequeue())&&null!==n.buffer&&null!==n.buffer.Image.DataY&&(h&&(d=r-m),m=n.buffer.nCostTime,m-=d,H(n),c=t,h=!0);window.requestAnimationFrame(e)}};return k.prototype={draw:function(e,t,n,r,o){if(!0===f){if(E)return(a={}).Image={ImageFormat:0,DataY:e,DataU:t,DataV:n,width0:v,width1:v/2,width2:v/2,height0:_,height1:_/2,height2:_/2},a.nFrameID=r,void H(new ue(a));if(null!==p)if(document.hidden&&p.size>=25)p.clear();else{var a;(a={}).Image={ImageFormat:0,DataY:e,DataU:t,DataV:n,width0:v,width1:v/2,width2:v/2,height0:_,height1:_/2,height2:_/2},a.nFrameID=r,0==o&&(o=25);var i=1e3/o,u=p.size*i;l||(S=u>U?1.2:u=25)p.clear();else{var a;(a={}).Image={ImageFormat:10,DataY:e,DataU:0,DataV:0,width0:r,width1:0,width2:0,height0:o,height1:0,height2:0},a.nFrameID=t,0==n&&(n=25);var i=1e3/n,u=p.size*i;l||(S=u>U?1.2:u0){s[p]=Y._malloc(4*n.pElement[p].pStruct.chCount);for(var d=0;d0){s[p]=Y._malloc(4*n.pElement[p].pStruct.chCount);for(d=0;d0){var m=Y._malloc(n.wInfoLen);Y.writeArrayToMemory(n.pInfo,m),Y.HEAP32[i/4+4]=m}a=Y._DRAW_InputTrackDataEx2(e,t,i,r,o);for(p=0;p0&&Y._free(s[p]):ie==n.pElement[p].nStructType&&Y._free(c[p])),Y._free(f[p]);Y._free(l),n.wInfoLen>0&&Y._free(InfoPtr)}else Y.writeArrayToMemory(n,i),a=Y._DRAW_InputTrackDataEx2(e,t,i,r,o);Y._free(i)}(P,t,e,n,r)}}},SetLifeCount:function(e){y&&function(e,t){Y._DRAW_SetLifeCount(e,2,t)}(P,e)},DrawDrawIVS:function(e){y&&le(P,e)},SetPanoVRMode:function(e,t,n){return 0===e?q(u,1,!1):(C=!0,M=!1,D={PanoARMode:e,ImageStride:t,ImageWidth:t,ImageHeight:n}),!0},GetModelRotate:function(){return function(e){var t=N._malloc(4),n=N._malloc(4),r=N._malloc(4);N._RENDER_3DGetModelRotate(e,t,n,r);var o=N.HEAPF32[t/4],a=N.HEAPF32[n/4],i=N.HEAPF32[r/4];return N._free(t),N._free(n),N._free(r),{x:o,y:a,z:i}}(u)},SetModelRotate:function(e,t,n){return function(e,t,n,r){return N._RENDER_3DSetModelRotate(e,t,n,r)}(u,e,t,n)},SetStereoPerspectiveFovy:function(e){return function(e,t){return N._RENDER_3DSetPerspectiveFovy(e,t)}(u,e)},GetVRCoord2DTrans:function(e,t){return function(e,t,n){var r=N._malloc(4),o=N._malloc(4);N._RENDER_GetPanoARCoord2DTrans(e,t,n,r,o);var a=N.HEAPF32[r/4],i=N.HEAPF32[o/4];return N._free(r),N._free(o),{x:a,y:i}}(u,e,t)},GetVRCoord3DTrans:function(e,t){return function(e,t,n){var r=N._malloc(4),o=N._malloc(4);N._RENDER_GetPanoARCoord3DTrans(e,t,n,r,o);var a=N.HEAP32[r/4],i=N.HEAP32[o/4];return N._free(r),N._free(o),{x:a,y:i}}(u,e,t)},ResetPlayState:function(){w=!1},GetCurrentFrameID:function(){return b},SetPrintLogLevel:function(e){E||function(e){null==N&&null!=window.REModule&&(N=window.REModule),N._RENDER_SetPrintLogLevel(e)}(e),function(e){null==Y&&null!=window.IVSModule&&(Y=window.IVSModule),Y._DRAW_SetPrintLogLevel(e)}(e)},SetPlayMethod:function(e,t,n){R=e,I=t,U=n}},new k};var ce=function(){var e=null,t=null,n=null,r=0,o=0,a=!1,i=0,l=0,u=null,s=!1,c=new Float32Array(8e4),f=0,p=null,d=!1,m=0,g=0,h=null;function S(t,r){if(d){var a=r-i;(a>200||a<0)&&(o=0,f=0,s=!0,null!==p&&p.stop()),o-e.currentTime<0&&(o=0),i=r;for(var l=new Int16Array(t.buffer,t.byteOffset,t.byteLength/Int16Array.BYTES_PER_ELEMENT),g=new Float32Array(l.length),S=0;S=r.length&&(r=new Float32Array(r.length+8e4)).set(r,0);return r.set(t,n),r}(c,g,f),f+=g.length,!s){var y=0;if(f/g.length>1&&(null!==u&&(y=u*m),y>=f||null===u))return void(f=0);var v=null;(v=e.createBuffer(1,f-y,m)).getChannelData(0).set(c.subarray(y,f)),f=0,p=null,(p=e.createBufferSource()).buffer=v,p.connect(n),o||(o=e.currentTime+.01),p.start(o),o+=v.duration}}else o=0}function y(){}return y.prototype={audioInit:function(r){if(o=0,null!==e);else try{return window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.oAudioContext||window.msAudioContext,(e=new AudioContext).onstatechange=function(){"running"===e.state&&(a=!0)},t=e.createGain(),(n=e.createBiquadFilter()).connect(t),n.type="lowpass",n.frequency.value=1500,n.gain.value=40,t.connect(e.destination),this.setVolume(r),!0}catch(e){return!1}},play:function(){this.setVolume(r)},stop:function(){r=0,t.gain.value=0,o=0,e=null},bufferAudio:function(t,n){var i=o-e.currentTime;(h&&i>.25||i>10)&&(this.terminate(),this.audioInit(r)),a&&S(t,0)},setSoundState:function(e){d=e},setVolume:function(e){r=e;var n=e/1;n<=0?(t.gain.value=0,o=0):t.gain.value=n>=1?1:n},getVolume:function(){return r},Mute:function(e){if(e)t.gain.value=0,o=0;else{var n=r/1;n<=0?(t.gain.value=0,o=0):t.gain.value=n>=1?1:n}},terminate:function(){"closed"!==e.state&&(f=0,o=0,a=!1,p=null,n=null,t=null,e.close(),e=null)},setBufferingFlag:function(e,t){"init"===t?l=e:s&&(0===e||null==e?u=null:(u=e-l,l=0),s=!1)},getBufferingFlag:function(){return s},setInitVideoTimeStamp:function(e){l=e},getInitVideoTimeStamp:function(){return l},setSampleBits:function(e,t){m=e,g=t,h&&h.SetPlayParam(m,g)},getAudioBufTime:function(){if(void 0!==e){var t=o-e.currentTime;return t>0?t*=1e3:t=0,t}return 0},setAudioProcesser:function(e){(h=e)&&h.SetPlayParam(m,g)}},new y};var fe=function(e){e=e;var t=null,n="",r=null,o=null,a=null,i=null,l=null,u=null,s=null,c=null,f=1,p={timestamp:0,timestamp_usec:0,timezone:0},d={timestamp:0,timestamp_usec:0,timezone:0},m=null,g=!1,h=null,S=null,y=null,v=!1,_=!0,P=0,E=!1,b=[],A=.5,w=null,T=null,C=null,M=0,D=0,R=!1,I=null,U="png",k=1,H=O(),L=null,F=0,B=0,G=0,x=null,V=!1,N=!1,W=[],z={},Y=25,q=.5,j=!1,K=!1;function X(){}function J(){Q(),K=!0}function Z(){var e=0;if(null!==h)for(e=0;e0)return e.log("segmentWaitDecode.length: "+b.length),void b.push(t);C.updating?(e.log("updating.........."),b.push(t)):(C.appendBuffer(t),V&&(z.buffer=t))}catch(t){e.log("videoMediaSource::appendNextMediaSegment error >> initVideo"),b.length=0,x&&x({errorCode:102})}}(W.shift())}function ne(){if(null!==T)try{if(C&&C.buffered.length>0){if(function(){var e=1*C.buffered.start(C.buffered.length-1),t=1*C.buffered.end(C.buffered.length-1);t-e>60&&C.remove(e,t-10)}(),N&&!V||w.duration>q&&(w.currentTime=(w.duration-q).toFixed(3),q+=Y<10?.5:.1),w&&w.duration-w.currentTime>8){if(x&&x({errorCode:103}),C.updating)return;var t=w.duration-.1;w.currentTime=t.toFixed(3)}if(E&&!g){var n=1*C.buffered.start(C.buffered.length-1),r=1*C.buffered.end(C.buffered.length-1);if((0===w.currentTime?r-n:r-w.currentTime)>=A+.1){if(e.log("跳秒"),C.updating)return;var o=r-.1;w.currentTime=o.toFixed(3)}}}}catch(t){e.error("sourceBuffer has been removed")}}function re(){b.length>0&&C&&!C.updating&&(C.appendBuffer(b[0]),b.shift())}function oe(){}function ae(){console.log("videoMediaSource::onSourceError"),s&&s("SourceError")}function ie(){console.log("videoMediaSource::onSourceBufferErrormsg"),s&&s("SourceBufferError")}function le(){console.log("videoMediaSource::onError"),ee(),x&&x({errorCode:104}),s&&s("Error")}function ue(){if(v=!0,_=!1,N=!0,!R){R=!0;var e={decodeMode:"video"};e.width=w.videoWidth,e.height=w.videoHeight,1==r?e.encodeMode="H264":2==r&&(e.encodeMode="H265"),l&&l(e)}}function se(){v=!1,_=!0,e.log("硬解码暂停播放")}function ce(){var e=parseInt(T.duration,10),t=parseInt(w.currentTime,10),n={timestamp:p.timestamp-f*(e-t+(1!==f?1:0)),timestamp_usec:0,timezone:p.timezone};0===t||isNaN(e)||!g&&Math.abs(e-t)>4&&1===f||w.paused||(null===m?(m=n,i(0,"currentTime")):(m.timestamp<=n.timestamp&&f>=1||m.timestamp>n.timestamp&&f<1)&&(m=n,++P>4&&i(n.timestamp,"currentTime")))}function fe(){null!=C&&($(),ne())}function pe(){a()}function de(){$()}function me(){if(e.log("需要缓冲下一帧"),E=!1,0==D)M=Date.now(),D++;else{D++;var t=Date.now()-M;e.log("diffTime: "+t+" Count: "+D),D>=5&&t<6e4&&A<=1&&(A+=.1,D=0,M=0,e.log("delay + 0.1 = "+A))}}function ge(){e.log("Can play !")}function he(){e.log("Can play without waiting"),E=!0}function Se(){e.log("loadedmetadata")}function ye(e,t){var n=document.createElement("canvas");n.width=w.videoWidth,n.height=w.videoHeight;var r=n.getContext("2d");r.drawImage(w,0,0,n.width,n.height);for(var o=0;o3;d.timestamp,!0===t&&(P=0,i((d=e).timestamp,"init"),0!==p.timestamp&&g&&(w.currentTime=T.duration-.1),m=null),p=e},pause:function(){V=!0,ee()},play:function(){V=!1},setPlaybackFlag:function(e){g=e},setTimeStampInit:function(){m=null,d={timestamp:0,timestamp_usec:0,timezone:0}},close:function(){Z(),ee()},setBeginDrawCallback:function(e){l=e},setCapturePicDataCallBack:function(e){u=e},setErrorCallback:function(e){x=e},terminate:function(){null!==w&&(Z(),"open"===T.readyState&&(C&&T.removeSourceBuffer(C),T.endOfStream()),C=null,T=null,w=null,I&&(clearInterval(I),I=null),L&&(clearInterval(L),L=null),G=0,B=0,F=0,j=!1,K=!1,R=!1)},getDuration:function(){return w.duration-w.currentTime},setFPS:function(e){e&&(Y=e)},setRtspOver:function(){w.duration.toFixed(4)-0==w.currentTime.toFixed(4)-0||(F=parseInt(w.currentTime),B=parseInt(w.duration),L=setInterval((function(){F===parseInt(w.currentTime)&&B===parseInt(w.duration)?G++>10&&(L&&clearInterval(L),L=null):parseInt(w.currentTime)>=parseInt(w.duration)?(L&&clearInterval(L),L=null):(F=parseInt(w.currentTime),B=parseInt(w.duration),G=0)}),150))},getVideoBufferQueueSize:function(){return W.length},playNextFrame:function(){te()},getCurFrameInfo:function(){var e;return z.src=((e=document.createElement("canvas")).width=w.videoWidth,e.height=w.videoHeight,e.getContext("2d").drawImage(w,0,0,e.width,e.height),e.toDataURL()),z},setDecodeType:function(e){r=e},ResetPlayState:function(){R=!1}};var ve,_e,Pe,Ee,be,Ae,we,Te,Ce,Me,De,Re,Ie=(ve=window,_e=ve.document,Pe=function(){return ve.URL||ve.webkitURL||ve},Ee=_e.createElementNS("http://www.w3.org/1999/xhtml","a"),be="download"in Ee,Ae=/constructor/i.test(ve.HTMLElement),we=/CriOS\/[\d]+/.test(navigator.userAgent),Te=function(e){(ve.setImmediate||ve.setTimeout)((function(){throw e}),0)},Ce=function(e){setTimeout((function(){"string"==typeof e?Pe().revokeObjectURL(e):e.remove()}),4e4)},Me=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},Re=(De=function(e,t,n){n||(e=Me(e));var r,o=this,a="application/octet-stream"===e.type,i=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){Te(e)}}}(o,"writestart progress write writeend".split(" "))};if(o.readyState=o.INIT,be)return r=Pe().createObjectURL(e),void setTimeout((function(){var e,n;Ee.href=r,Ee.download=t,e=Ee,n=new MouseEvent("click"),e.dispatchEvent(n),i(),Ce(r),o.readyState=o.DONE}));!function(){if((we||a&&Ae)&&ve.FileReader){var t=new FileReader;return t.onloadend=function(){var e=we?t.result:t.result.replace(/^data:[^;]*;/,"data:attachment/file;");ve.open(e,"_blank")||(ve.location.href=e),e=void 0,o.readyState=o.DONE,i()},t.readAsDataURL(e),void(o.readyState=o.INIT)}r||(r=Pe().createObjectURL(e)),a?ve.location.href=r:ve.open(r,"_blank")||(ve.location.href=r),o.readyState=o.DONE,i(),Ce(r)}()}).prototype,"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return t=t||e.name||"download",n||(e=Me(e)),navigator.msSaveOrOpenBlob(e,t)}:(Re.readyState=Re.INIT=0,Re.WRITING=1,Re.DONE=2,Re.error=Re.onwritestart=Re.onprogress=Re.onwrite=Re.onabort=Re.onerror=Re.onwriteend=null,function(e,t,n){return null==t||null==t?null:new De(e,t||e.name||"download",n)}));return new X};function pe(e){return(pe="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 de(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function me(e){for(var t=1;t=n)return e;var r=n-e.length;return new Array(r).fill(String(t)).join("")+e}function ye(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 ve(e,t){var n=(e=e||{}).nameFormat||["ymd_his"];t=t||new Date;var r="";if(he(n,"string"))n=[n,{}];else{if(!he(n,"array"))return void function(e){throw new Error(e)}("name format must be string or array");he(n[0],"string")||(n[0]="ymd_his"),he(n[1],"object")||(n[1]={})}var o=n[0].split(/\{(?:[^{}]+)\}/),a=n[1];n[0].replace(/\{([^{}]*)\}/g,(function(e,t,n){o.shift();r+=ye(),r+=t in a?a[t]:e}));var i=o.shift();return r+=ye(i,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=ve(e,new Date(o)),this.allowUpDateName=!1,n=null}t=null};var Pe=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,be=function(){var e=1048576,t=null,n=null,r=0,o=void 0,a=null,i=0,l=null,u=!1;function s(){this.onMessage=function(){},this.postMessage=function(e){this.__onMessage(e)},this.__postMessage=function(e){this.onMessage(e)}}return s.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()}},s.prototype.init=function(t){this.fullSize=t.fullSize||1/0,this.singleSize=t.singleSize+20*e||520*e,o="init",u=!1,l=t.recordName,this.limitOptions=Object.assign({limitBy:"fullSize"},t.limitOptions),this.nameOptions=Object.assign({namedBy:"date",nameFormat:["ymd_his",{}]},t.nameOptions)},s.prototype._malloc=function(e){t&&n&&(n=null,t=null),t=new ArrayBuffer(e),n=new DataView(t);var r=this.nameOptions,o="";if(null!=l)o=l;else switch(this.nameOptions.namedBy.toLowerCase()){case"date":o=ve(r);break;default:o=ve()}a=new _e(o)},s.prototype._initVideoMem=function(){!t&&this.singleSize&&this._malloc(this.singleSize)},s.prototype.appendVideoBuf=function(t,o,a){var l=t.byteLength,s=0;if(5==i){s=o+l;for(var c=o;cr&&(r=s)}else{s=r+l;for(c=r;cthis.singleSize-20*e&&!u&&(u=!0,this.__postMessage({type:"close"}))},s.prototype.addBuffer=function(e){if("closed"!==o){var t=e.buffer,n=e.offset;i=e.recordType,this._initVideoMem(),o="addBuffer";var a=t.length,l=0;l=5==i?n+a:r+a,Pe.get("total")+l>this.fullSize?this.close():this.appendVideoBuf(t,n)}},s.prototype.inNodePlace=function(){if("addBuffer"===o){o="download",a.updateNameByStream(this.nameOptions,t.slice(0,20)),a.byteLength=r,a.setEndTime(),Pe.add(a);var e=t.slice(0,r);if(this.reset(),this.__postMessage({type:"download",data:me(me({},a),{},{buffer:e})}),e=null,"count"===this.limitOptions.limitBy){var n=this.limitOptions.count;n&&n===Pe.get("count")&&this.close()}}},s.prototype.reset=function(){r=0,this._malloc(this.singleSize)},s.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 s},Ae=function(e){var t=e,n=[255,511,1023,2047,4095,8191,16383,32767];function r(){}function o(e){var t,r;return e<0?(e=132-e,t=127):(e+=132,t=255),(r=a(e,n))>=8?127^t:(r<<4|e>>r+3&15)^t}function a(e,t){for(var n=0,r=t.length;n=0?t=213:(t=85,e=-e-8),(r=a(e,n))>=8?127^t:(o=r<<4,(o|=r<2?e>>4&15:e>>r+3&15)^t)}return r.prototype={setSampleRate:function(e){e},encode:function(e){for(var n=new Int16Array(e.buffer),r=new Uint8Array(n.length),a=0;a>>8*(o-1-a)&255;else for(var i=0;i>>8*i&255;return r}function p(){o=new Ae(n)}return p.prototype={setSampleRate:function(e){o.setSampleRate(e)},getRTPPacket:function(t){var p=o.encode(t),d=0;(r=new Uint8Array(a.length+40+p.length+8)).set([36,e],d),d+=2,r.set(f(40+p.length+8,4,!0),d),d+=4,r.set(i,d),d+=4,r.set([240],d),d+=1,r.set([0],d),d+=1,r.set([1],d),d+=1,r.set([0],d),d+=1,u>65535&&(u=240),r.set(f(u),d),d+=4,u++;var m=f(40+p.length+8);r.set(m,d),d+=4;var g=new Date,h=(g.getFullYear()-2e3<<26)+(g.getMonth()+1<<22)+(g.getDate()<<17)+(g.getHours()<<12)+(g.getMinutes()<<6)+g.getSeconds(),S=g.getTime(),y=null===c?0:S-c;c=S,(s+=y)>65535&&(s=65535-s),r.set(f(h),d),d+=4,r.set(f(s,2),d),d+=2,r.set([16],d),d+=1;var v=function(e,t){for(var n=0,r=t;re.length)&&(t=e.length);for(var n=0,r=new Array(t);nt)return console.error("The dstRate show be smaller than srcRate"),[e,r];for(var o=t/n,a=Math.floor(e.length/o),i=new Float32Array(a),l=0,u=0;l>0]=e.charCodeAt(0),u++}));var s=t;return t>r&&(s=r),Ee.HEAP32[i/4+129]=2,Ee.HEAP32[i/4+130]=s,Ee.HEAP32[i/4+132]=1,Ee.HEAP32[i/4+133]=16,Ee.HEAP32[i/4+138]=1,Ee.HEAP32[i/4+140]=0,Ee.HEAP32[i/4+141]=0,0!=Ee._Audio_Framework_Config(e,i)&&(Ee._free(i),i=null,Ee._free(a),a=null),[i,a]}(n,e,0,a),2);r=l[0],o=l[1]},DeInit:function(){var e,t,a;t=r,a=o,null!=(e=n)&&(Ee._Audio_Framework_DeInit(e,t,a),Ee._free(e),Ee._free(t),Ee._free(a)),n=null,r=null,o=null,v=!1},InputCaptureData:function(e,r){var o=null;null!==m?((o=new Float32Array(e.length+m.length)).set(m,0),o.set(e,m.length)):o=e;var a=Te(b(o,r,8e3),2),i=a[0],l=a[1];m=l;new Uint8Array(i.buffer);var u=E(i),s=new Uint8Array(u);null==n||t?y&&y(s):function e(t,n){if(n<=0)return;var r=320-p.nByteOffset,o=n>r?r:n,a=null;a=n>=320&&0==p.nByteOffset?t.slice(0,320):p.nByteOffset>0?t.slice(0,320-p.nByteOffset):t;if(p.pBuffer.set(a,p.nByteOffset),p.nByteOffset+=o,320==p.nByteOffset){var i=new Uint8Array(320);i.set(p.pBuffer),c.enqueue(i),p.pBuffer.fill(0),p.nByteOffset=0}h=t.slice(o),n-=o,e(h,h.length)}(s,s.length)},InputPlayData:function(e){if(_){var t=null;null!==g?((t=new Float32Array(e.length+g.length)).set(g,0),t.set(e,g.length)):t=e;var n=Te(b(t,l,8e3),2),r=n[0],o=n[1];g=o;new Uint8Array(r.buffer);var a=E(r),i=new Uint8Array(a);!function e(t,n){if(n<=0)return;var r=320-d.nByteOffset,o=n>r?r:n,a=null;a=n>=320&&0==d.nByteOffset?t.slice(0,320):d.nByteOffset>0?t.slice(0,320-d.nByteOffset):t;if(d.pBuffer.set(a,d.nByteOffset),d.nByteOffset+=o,320==d.nByteOffset){var i=new Uint8Array(320);i.set(d.pBuffer),f.enqueue(i),d.pBuffer.fill(0),d.nByteOffset=0}S=t.slice(o),n-=o,e(S,S.length)}(i,i.length)}else f.clear()},StartProcess:function(){_=!0,s=setInterval((function(){!function(){if(null!==c&&0==c.size)return;if(!v&&f.size>5){v=!0;for(var e=0;e0)t=f.dequeue();else{if(!(c.size>5))return;t.buffer=new Uint8Array(320)}var r=c.dequeue(),a={};a.data=r.buffer,a.fs=8e3,a.datalen=320,a.depth=16,a.offset=2,a.channels=1,a.buflen=320;var i={};i.data=t.buffer,i.fs=8e3,i.datalen=320,i.depth=16,i.offset=2,i.channels=1,i.buflen=320;var l={},u=new ArrayBuffer(a.datalen),s=new Uint8Array(u);l.data=s,0==function(e,t,n,r,o){if(null==e)return-1;var a=Ee._malloc(232),i=Ee._malloc(116),l=Ee._malloc(t.datalen);Ee.writeArrayToMemory(t.data,l);var u=Ee._malloc(n.datalen);Ee.writeArrayToMemory(n.data,u);var s=Ee._malloc(t.datalen);Ee.HEAP32[a/4+0]=l,Ee.HEAP32[a/4+1]=t.fs,Ee.HEAP32[a/4+2]=t.datalen,Ee.HEAP32[a/4+3]=t.depth,Ee.HEAP32[a/4+4]=t.offset,Ee.HEAP32[a/4+5]=t.channels,Ee.HEAP32[a/4+6]=t.buflen,Ee.HEAP32[a/4+29]=u,Ee.HEAP32[a/4+30]=n.fs,Ee.HEAP32[a/4+31]=n.datalen,Ee.HEAP32[a/4+32]=n.depth,Ee.HEAP32[a/4+33]=n.offset,Ee.HEAP32[a/4+34]=n.channels,Ee.HEAP32[a/4+35]=n.buflen,Ee.HEAP32[i/4+0]=s;var c=Ee._Audio_Framework_Main(e,a,i,o);return 0==c&&r.data.set(Ee.HEAPU8.subarray(s,s+t.datalen)),Ee._free(a),Ee._free(i),Ee._free(l),Ee._free(u),Ee._free(s),c}(n,a,i,l,o)&&y&&y(l.data)}()}),10)},StopProcess:function(){this.DeInit(),s&&(clearInterval(s),s=null),c.clear(),f.clear(),m=null,g=null,_=!1},SetProcessedDataCallback:function(e){y=e}},new P},De=function(e){var t=e,n=null,r=null,o=null,a=null,i=null,l=!1,u=null,s={audio:!0,video:!1},c=null;function f(){}function p(e){var t=n.getRTPPacket(e);c(t,5)}return f.prototype={initAudioOut:function(e){if(null==r)try{window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.oAudioContext||window.msAudioContext,(r=new AudioContext).onstatechange=function(){}}catch(e){return}if(t.SetProcessedDataCallback(p),null!==o&&null!==a||(o=r.createGain(),(a=r.createScriptProcessor(1024,1,1)).onaudioprocess=function(e){if(null!==u){var n=e.inputBuffer.getChannelData(0);null!==c&&!0===l&&t.InputCaptureData(n,r.sampleRate)}},o.connect(a),a.connect(r.destination),i=r.sampleRate,o.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(e){u=e,r.createMediaStreamSource(e).connect(o)})).catch((function(e){})),l=!0,n||(n=new we(0,e)).setSampleRate(i),i},controlVolumnOut:function(e){var t=e/20*2;o.gain.value=t<=0?0:t>=10?10:t},stopAudioOut:function(){if(null!==u&&l)try{for(var e=u.getAudioTracks(),t=0,n=e.length;t65535&&(f=240);a.set(m(f),i),i+=4,f++;var l=m(44+o.length+8);a.set(l,i),i+=4;var g=new Date,h=g.getFullYear()-2e3,S=g.getMonth()+1,y=g.getDate(),v=g.getHours(),_=g.getMinutes(),P=g.getSeconds(),E=(h<<26)+(S<<22)+(y<<17)+(v<<12)+(_<<6)+P,b=g.getTime(),A=null===d?0:b-d;d=b,(p+=A)>65535&&(p=65535-p);a.set(m(E),i),i+=4,a.set(m(p,2),i),i+=2,a.set([20],i),i+=1;var w=function(e,t){for(var n=0,r=t;r>>8*(o-1-a)&255;else for(var i=0;i>>8*i&255;return r}function g(){var t=document.createElement("canvas");t.height=e.width,t.width=e.height;var n=Math.floor(1e3/e.frameRate),o=0,u=0,s=t.getContext("2d");!function e(){if(!i.paused&&!i.ended){var c,f,p,d,m,g=Date.now();if(0==o||g-o>=n+u){0!=o&&(u+=n-(g-o)),o=g,s.drawImage(i,0,0,t.width,t.height);var h=s.getImageData(0,0,t.width,t.height),S=new Uint8Array(h.data),y=(c=S,f=S.length,p=h.width,d=h.height,m=l.video.frameRate,null==r&&(r=a._malloc(f)),a.HEAPU8.set(c,r),a._h264Enc(r,f,p,d,m));if(0!=y)return void console.error("H264Encode initial failed, ret:"+y)}requestAnimationFrame(e)}}()}function h(){}return h.prototype={initVideoCapture:function(e,n){t=e,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)})):Promise.reject(new Error("getUserMedia is not implemented on this browser"))}),navigator.mediaDevices.getUserMedia?navigator.mediaDevices.getUserMedia(l).then((function(e){i.srcObject=e,i.currentTime=0,i.addEventListener("play",g)})).catch((function(e){console.error("Cannot get User Media"+e)})):console.error("Cannot open local media stream! :: navigator.mediaDevices.getUserMedia is not defined!")},stopVideoPlay:function(){if(null!=i){i.pause(),i.removeAttribute("src"),i.removeEventListener("play",g);var e=a._h264EncClose();0!=e&&console.error("H264EncodeClose failed, ret:"+e)}r&&(a._free(r),r=null)},writeDataOut:function(){var e=new Blob(n,{type:"video/webm"}),t=document.createElement("a");console.warn("initial downloadElem: "+t);var r=window.URL.createObjectURL(e);t.href=r,t.download="download.dav",document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(r)},terminate:function(){this.stopVideoPlay()},setBufferCallBack:function(e){o=e}},new h};function Ie(e){return(Ie="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 Ue(e,t){for(var n=0;n999&&(this.m_VideoFrameIndex=0);var t=this.m_WebCodecsVideoFrameScope+this.m_VideoFrameIndex;window.WebCodecsVideoFrameMap.set(t,e),this.m_playMethod&&this.m_playMethod.drawWebCodecs(t,0,this.m_nFrameRate,e.codedWidth,e.codedHeight)}},{key:"OnError",value:function(e){console.log("Decode Failed!")}},{key:"GetCodecString",value:function(e){for(var t=null,n=e.length,r=[],o=0;o<=n;)if(0==e[o])if(0==e[o+1])if(1==e[o+2]){if(r.push(o),o+=3,1==this.m_nVideoEncodeType){if(5==(31&e[o])||1==(31&e[o]))break}else if(2==this.m_nVideoEncodeType&&(38==(255&e[o])||2==(255&e[o])))break}else 0==e[o+2]?o++:o+=3;else o+=2;else o+=1;if(1==this.m_nVideoEncodeType){var a=!1;for(o=0;o2&&(qe=0,Wt())}}function Wt(){if(1==Ce?Ue=!1:ke=!1,Ie)Module._PLAY_SetSupportWebMSE(n,Ue,ke);else{var e={nType:"SetSupportWebMSE",bSupportH264MSE:Ue,bSupportH265MSE:ke};it&&it.postMessage(e)}}function zt(){s&&(s.close(),s.terminate(),s=null),u=!1,y=null,c=null,f=null,S=!1,Ke=!1,w=0,P={id:1,samples:null,baseMediaDecodeTime:0},E=0,D=1,M=0,I=0,T=0,A=2}function Yt(){var e=1;if(Ie)e=Module._PLAY_StopDataRecord(n);else{it&&it.postMessage({nType:"StopRecord"})}return(Ie||5!=et)&&Je&&(Je.postMessage({type:"close"}),Je=null),tt=0,e}function qt(e,o){if(1!=Ve&&(Ve=!0,Ot()),nt=e.nFrameID,ne==oe&&re==ae&&e.nEncodeType==Te||(0!=oe&&(je=!0),oe=ne,ae=re,Te=e.nEncodeType),v!=_&&(t.info("MSE FrameRate change, PlayPort:"+n+", m_nFrameRate:"+v+", m_nPreFrameRate:"+_),_=v),je&&(zt(),je=!1),0!=Ke||0==e.nFrameSubType){if(null==c&&(c=new V(Ce)),null==f&&(f=new x(Ce)),function(e,t,n){for(var r=null,o=e.length,a=[],i=0;i<=o;)if(0==e[i])if(0==e[i+1])if(1==e[i+2]){if(a.push(i),i+=3,1==Ce){if(5==(31&e[i])||1==(31&e[i]))break}else if(2==Ce&&(38==(255&e[i])||2==(255&e[i])))break}else 0==e[i+2]?i++:i+=3;else i+=2;else i+=1;var l=0;if(1==Ce){for(i=0;i>>24,U[1]=(16711680&t)>>>16,U[2]=(65280&t)>>>8,U[3]=255&t;var r=new Uint8Array(U.length+E);if(0!==E&&r.set(b),r.set(U,E),E=(b=r).length,w%A==0&&0!==w){if(null!==P.samples[0].frameDuration&&(P.baseMediaDecodeTime=1===D?0:I,I=T),1==g)for(var o=P.samples.length,a=M/A,i=0;i=l.nTotalStreamLength&&(ft=ct-l.nTotalStreamLength);var u,s,c=Date.UTC(l.nYear,l.nMonth,l.nDay,l.nHour,l.nMinute,l.nSecond)/1e3;if(1==l.nFrameType){if(t.log("PlayFrameData, PlayPort:"+n+", nFrameID:"+l.nFrameID+", nRemainData:"+l.nRemainData),le=l.nRemainData,We&&0==le&&z(),l.bThrowFrame)return;if(8==l.nStreamType?r.timestamp=c:r.timestamp=l.nTimeStamp/1e3,r.timestamp_usec=0,2==l.nEncodeType||4==l.nEncodeType||8==l.nEncodeType?Ce=1:12==l.nEncodeType&&(Ce=2),we&&we.setEncodeType(Ce),ne=l.nWidth,re=l.nHeight,0==ne||0==re)return;if(v=l.nFrameRate,ze<=5&&ze++,18==l.nFrameSubType||19==l.nFrameSubType||20==l.nFrameSubType?ie=1:0==l.nFrameSubType&&(ie=0),2==l.nFrameSubType&&!pt){if(pt=!0,1==Ce?Ue=!1:2==Ce&&(ke=!1),Ie)Module._PLAY_SetSupportWebMSE(n,Ue,ke);else{var f={nType:"SetSupportWebMSE",bSupportH264MSE:Ue,bSupportH265MSE:ke};it&&it.postMessage(f)}return}if(we&&we.SetLifeCount(3*l.nFrameRate),(1==Ce&&1==Ue||2==Ce&&1==ke)&&!ie&&13!=l.nStreamType){if(u=l.nFrameID,0!=(s=l.nFrameSubType)&&18!=s&&20!=s&&-1!=nt&&u!=nt+1&&(t.info("checkFrame failed, PlayPort:"+n+", nFrameID:"+u+", m_nLastFrameID:"+nt),1))return;0!==gt?(nt=l.nFrameID,Ut&&Ut.decode(l,e)):qt(l,e)}else{if(!Ie&&(null==e||null==o||null==a))return;if(0!=Ve&&(Ve=!1,zt(),je=!0,oe=0,ae=0),ne!=oe||re!=ae)oe=ne,ae=re,Ie||we.resize(ne,re),(p={decodeMode:"canvas"}).width=ne,p.height=re,[2,4,8].includes(l.nEncodeType)?p.encodeMode="H264":12===l.nEncodeType&&(p.encodeMode="H265"),O(p);if(nt=l.nFrameID,Ie){var p;if(!rt)rt=!0,(p={decodeMode:"canvas"}).width=ne,p.height=re,[2,4,8].includes(l.nEncodeType)?p.encodeMode="H264":12===l.nEncodeType&&(p.encodeMode="H265"),L(p);we&&we.DrawDrawIVS(l.nFrameID)}else we&&we.draw(e,o,a,l.nFrameID,v)}var d=l.nYear,m=cn(l.nMonth),g=cn(l.nDay),h=cn(l.nHour),S=cn(l.nMinute),y=cn(l.nSecond);l.timeStamp=Date.UTC(d,m,g,h,S,y)/1e3,l.utcTimeStamp=new Date("".concat(d,"-").concat(m,"-").concat(g," ").concat(h,":").concat(S,":").concat(y)).getTime(),F(l)}else if(2==l.nFrameType){if(Ye<=10&&Ye++,!dt&&ze<5&&Ye<=10){if(v>5||0==v)return;if(ze<2)return}if(l.nSamples==Ee&&l.nBits==Ae||(Ee=l.nSamples,Ae=l.nBits,Pe.setSampleBits(l.nSamples,l.nBits)),Pe&&Pe.bufferAudio(e,0),Ie){var _=Pe.getAudioBufTime();setTimeout((function(){Module._PLAY_SetInt32(n,2057,_)}))}B(l)}}function Kt(e,t,n,r,o){if(-1!=o){if(n==He)if(Ie||Ve)o=nt;else{var a=we&&we.GetCurrentFrameID();if(-1==a||null==a)return;o=a}if(Ie){var i=new ArrayBuffer(r),l=new Uint8Array(i);l.set(Module.HEAPU8.subarray(t,t+r));var u=new DataView(l.buffer);if(Oe==n){var s={};s.nId=u.getUint32(0,!0),s.wCustom=u.getUint16(4,!0),s.chState=u.getUint8(6,!0),s.chCount=u.getUint8(7,!0);var c=u.getUint32(8,!0),f=new ArrayBuffer(12),p=new Uint8Array(f),d=new DataView(f);s.pElement=new Array(s.chCount);for(var m=0;m0&&(s.pElement[m].pStruct.pPoints=new Array(s.pElement[m].pStruct.chCount),v=y.getUint32(8,!0),_=new ArrayBuffer(4),P=new Uint8Array(_),E=new DataView(_));for(var b=0;b0&&(s.pElement[m].pStruct.pPoints=new Array(s.pElement[m].pStruct.chCount),v=y.getUint32(12,!0),A=new ArrayBuffer(4),w=new Uint8Array(A),T=new DataView(A));for(b=0;b0){var R=u.getUint32(16,!0),I=new ArrayBuffer(nInfoLen),U=new Uint8Array(I);U.set(Module.HEAPU8.subarray(R,R+nInfoLen)),s.pInfo=U}we&&we.DrawIVS(s,n,r,o)}else if(Le==n){for(var k=new DataView(i),H=r/144,L=[],O=0;O=104;break;default:n=0}return n}();var c=navigator.platform;k();if(0==c.indexOf("iPhone")&&(Ue=!1,ke=!1),Ie){var f=Module._malloc(1);if(Q=new Uint8Array(Module.HEAPU8.buffer,f,1),Module._PLAY_GetFreePort(Q.byteOffset),n=Q[0],Q=null,Module._free(f),u=Module._PLAY_SetStreamOpenMode(n,l),u=Module._PLAY_OpenStream(n,0,0,10485760),u=Module._PLAY_SetCacheMode(n,1),u=Module._PLAY_SetSupportWebMSE(n,Ue,ke),o){Module._PLAY_ViewResolutionChanged(n,parseInt(o.width),parseInt(o.height),0);var p=Module.allocateUTF8(o.id);u=Module._PLAY_Play(n,p),Module._free(p)}else Module._PLAY_ViewResolutionChanged(n,0,0,0),u=Module._PLAY_Play(n,0)}else(it=new Worker("".concat(e.strDecodeFilePath,"/VideoDecodeWorker.js"))).onmessage=Xt;(t.log("Init, PlayPort:"+n+", canvasElem:"+e.canvasElem+", videoElem:"+e.videoElem+", ivsCanvasElem:"+e.ivsCanvasElem+", bPlayBack:"+e.bPlayBack),t.log("Init, m_bSupportMultiThread:"+Ie+", m_bSupportH264MSE:"+Ue+", m_bSupportH265MSE:"+ke),u)&&(Ie&&($=Module._malloc(5242880),ee=new Uint8Array(Module.HEAPU8.buffer,$,5242880)),we=new se(o,i,!0===l?100:25,l,Ie),0>0]=e,s++}));else if(2==e){var c=new Uint8Array(16);if(u[l+s>>0]=1,s++,0==i){for(var f=0;f<16;f++)c[f]=0;i=16,a=c}a.forEach((function(e,t){u[l+s>>0]=e,s++})),r.forEach((function(e,t){u[l+s]=e,s++})),o=1+o+i,c=null}else 3==e&&r.split("").forEach((function(e,t){u[l+s>>0]=e.charCodeAt(0),s++}));Module._PLAY_SetSecurityKey(n,l,o),Module._free(l)}else{var p={nType:"SetSecurityKey",nEncryptType:e,szKey:r,nKeyLen:o,szKeyId:a,nKeyIdLen:i};it&&it.postMessage(p)}},StartRecord:function(e,r,o){t.log("StartRecord, PlayPort:"+n+", nRecordType:"+e+", nFileSize:"+r+", strRecordName:"+o);var a,i,l=1;if(Je=new be,a=o,i=parseInt(r)||500,Je.postMessage({type:"init",options:{recordName:a,singleSize:1048576*i,nameOptions:{namedBy:"date",nameFormat:["ymd_his"]},limitOptions:{limitBy:"count",count:10}}}),Je.onMessage=function(e){switch(e.type){case"pendding":break;case"download":t=e.data.name,n=e.data.buffer,r=new Blob([n]),(o=document.createElement("a")).href=URL.createObjectURL(r),o.download=t,o.click(),URL.revokeObjectURL(o.href),o=null,n=null;break;case"close":setTimeout((function(){Yt()}))}var t,n,r,o},et=e,Ie)l=Module._PLAY_StartDataRecord(n,0,et);else{var u={nType:"StartRecord",nRecordType:et};it&&it.postMessage(u)}return l},StopRecord:function(){return t.log("StopRecord, PlayPort:"+n),Yt()},OpenIVSDraw:function(e){t.log("OpenIVSDraw, PlayPort:"+n+", nWndIndex:"+e);var r=1;if(Ie)r=Module._PLAY_RenderPrivateData(n,1,0);else{it&&it.postMessage({nType:"OpenIVSDraw"})}return we&&we.OpenIVS(e,i.id),r},CloseIVSDraw:function(){t.log("CloseIVSDraw, PlayPort:"+n);var e=1;if(Ie)e=Module._PLAY_RenderPrivateData(n,0,0);else{it&&it.postMessage({nType:"CloseIVSDraw"})}return we&&we.CloseIVS(),e},SetIvsEnable:function(e,r){t.log("SetIvsEnable, PlayPort:"+n+", nIvsType:"+e+", bEnable:"+r),we&&we.SetIvsEnable(e,r)},SetPanoAR:function(e){t.log("SetPanoAR, PlayPort:"+n+", PanoARType:"+e);var r=1;return Ie&&!Ve?(r=Module._PLAY_SetPanoVRMode(n,e),gt=e,r):(0===gt&&0!==e?Ve?(je=!0,we.resize(ne,re),null===Ut&&(Ut=new Ne(we,Ce))):(we.terminate(),we.resize(ne,re)):0!==gt&&0===e&&(Ot(),we.terminate(),Ve||we.resize(ne,re),Ut=null),we.SetPanoVRMode(e,ne,re),gt=e,r)},Set3DPoint:function(e){t.log("Set3DPoint, PlayPort:"+n+", b3DPoint:"+e),Ie&&(mt=e)},OnMouseDown:function(){0===gt&&0===mt||(bt=!0)},OnMouseMove:function(e,t){if(0!==gt||0!==mt){ht&&(St=e,yt=t,0,0,ht=!1);var r=e-St,o=t-yt;if(St=e,yt=t,bt){if(Ie&&!Ve){var a=Module._malloc(8),i=Module._malloc(8);Module._PLAY_GetDoubleRegion(n,0,2050,a),Module._PLAY_GetDoubleRegion(n,0,2051,i),vt=Module.HEAPF64[a/8],_t=Module.HEAPF64[i/8],Module._free(a),Module._free(i)}else{if(!we)return void console.log("[Error]The m_playMethod is invalid in OnMouseMove!");vt=we.GetModelRotate().x,_t=we.GetModelRotate().y}Math.abs(r)>=Math.abs(o)?_t+=-2*r*Pt/Et:vt+=-2*o*Pt/Et,Ie&&!Ve?Module._PLAY_SetStereoRotate(n,0,vt,_t,0):we.SetModelRotate(vt,_t,0)}}},OnMouseUp:function(){0===gt&&0===mt||(bt=!1)},OnMouseWheel:function(e){if(0!==gt||0!==mt)if(e<0?Pt>=10&&(Pt-=2):Pt<=120&&(Pt+=2),Ie&&!Ve)Module._PLAY_SetStereoPerspectiveFovy(n,0,Pt);else{if(!we)return void console.log("[Error]The m_playMethod is invalid in OnMouseWheel!");we.SetStereoPerspectiveFovy(Pt)}},GetVRCoord2DTrans:function(e,t){return function(e,t){var r;if(Ie&&!Ve){var o=Module._malloc(4),a=Module._malloc(4);Module._PLAY_GetVRCoord2DTrans(n,0,e,t,o,a),r={x:Module.HEAPF32[o/4],y:Module.HEAPF32[a/4]},Module._free(o),Module._free(a)}else{if(!we)return void console.log("[Error]The m_playMethod is invalid in GetVRCoord2DTrans!");r=we.GetVRCoord2DTrans(e,t)}return[(r.x+1)/2*i.width,(1-r.y)/2*i.height]}(e,t)},GetVRCoord3DTrans:function(e,t){return function(e,t){var r;if(Ie&&!Ve){var o=Module._malloc(4),a=Module._malloc(4);Module._PLAY_GetVRCoord3DTrans(n,0,e,t,o,a),r={x:Module.HEAP32[OutXPtr/4],y:Module.HEAP32[OutYPtr/4]},Module._free(OutXPtr),Module._free(OutYPtr)}else{if(!we)return void console.log("[Error]The m_playMethod is invalid in GetVRCoord3DTrans!");r=we.GetVRCoord3DTrans(e,t)}return[r.x,r.y]}(e,t)},SetSoundState:function(e){t.log("SetSoundState, PlayPort:"+n+", bPlay:"+e),Pe&&Pe.setSoundState(e)},SetVolume:function(e){t.log("SetVolume, PlayPort:"+n+", nVolume:"+e),Pe&&Pe.setVolume(e)},StartTalk:function(e){t.log("StartTalk, PlayPort:"+n+", nEncodeType:"+e),lt||(ut=new Me(kt),(lt=new De(ut)).setSendAudioTalkBufferCallback(X),lt.initAudioOut(e),Pe&&!kt&&Pe.setAudioProcesser(ut))},StopTalk:function(){t.log("StopTalk, PlayPort:"+n),lt&&(lt.terminate(),lt=null),Pe&&Pe.setAudioProcesser(null),ut&&(ut.StopProcess(),ut=null)},StartVideoCapture:function(e,r,o){t.log("StartVideoCapture, PlayPort:"+n+", nEncodeType:"+r),st||((st=new Re(o)).setBufferCallBack(X),st.initVideoCapture(0,0))},StopVideoCapture:function(){t.log("StopVideoCapture, PlayPort:"+n),st&&(st.terminate(),st=null)},GetSourceBufferRemain:function(){var e=0;return e=Ie?Module._PLAY_GetSourceBufferRemain(n):ft,t.log("GetSourceBufferRemain, PlayPort:"+n+", nRemain:"+e),e},SetStreamOver:function(e){t.log("SetStreamOver, PlayPort:"+n+", bOver:"+e),(We=e)&&0==le&&z()},ResetBuffer:function(){t.log("ResetBuffer, PlayPort:"+n),Ie&&(Module._PLAY_ResetBuffer(0),Module._PLAY_ResetBuffer(1),Module._PLAY_ResetBuffer(2))},capturePic:function(e){if(t.log("capturePic, PlayPort:"+n+", strPictureName:"+e),at=e,Ve)ot=!0;else if(Ie){var r=ne*re*3/2,o=Module._malloc(r),a=new Uint8Array(Module.HEAPU8.buffer,o,r),i=Module._malloc(4),l=new Uint8Array(Module.HEAPU8.buffer,i,4);Module._PLAY_GetPicJPEG(n,a.byteOffset,r,l.byteOffset,100);var u=(l[3]<<24)+(l[2]<<16)+(l[1]<<8)+l[0],s=new ArrayBuffer(u),c=new Uint8Array(s);c.set(Module.HEAPU8.subarray(a.byteOffset,a.byteOffset+u)),j&&j(c);var f=new Blob([c.buffer],{type:"image/jpg"});sn(f,at),f=null,Module._free(o),Module._free(i),a=null,l=null,s=null,c=null}else{it&&it.postMessage({nType:"CatchPic"})}},OpenPlayGroup:function(){var e=null;return Ie&&(e=Module._PLAY_OpenPlayGroup()),t.log("OpenPlayGroup, pGroupHandle:"+e),e},AddToPlayGroup:function(e,n){t.log("AddToPlayGroup, pGroupHandle:"+e+", nPort:"+n);var r=0;return Ie&&(r=Module._PLAY_AddToPlayGroup(e,n)),r},DelFromPlayGroup:function(e,n){t.log("DelFromPlayGroup, pGroupHandle:"+e+", nPort:"+n);var r=0;return Ie&&(r=Module._PLAY_DelFromPlayGroup(e,n)),r},ClosePlayGroup:function(e){t.log("ClosePlayGroup, pGroupHandle:"+e);var n=0;return Ie&&(n=Module._PLAY_ClosePlayGroup(e)),n},PausePlayGroup:function(e,n){t.log("PausePlayGroup, pGroupHandle:"+e+", bPause:"+n);var r=0;return Ie&&(r=Module._PLAY_PausePlayGroup(e,n)),r},SetPlayGroupSpeed:function(e,n){t.log("SetPlayGroupSpeed, pGroupHandle:"+e+", fSpeed:"+n);var r=0;return Ie&&(r=Module._PLAY_SetPlayGroupSpeed(e,n)),r},SetAudioTalkFlag:function(e){t.log("SetAudioTalkFlag, PlayPort:"+n+", bAudioTalk:"+e),dt=e},SetDecodeMode:function(e,r){if(t.log("SetDecodeMode, PlayPort:"+n+", nH264DecodeMode:"+e+", nH265DecodeMode:"+r),Ue=e,ke=r,Ie)Module._PLAY_SetSupportWebMSE(n,e,r);else{var o={nType:"SetSupportWebMSE",bSupportH264MSE:e,bSupportH265MSE:r};it&&it.postMessage(o)}},GetOriginalKey:function(e,r,o){t.log("GetOriginalKey, PlayPort:"+n);var a=1;if(Ie){var i=Module.intArrayFromString(e).concat(0),l=Module._malloc(i.length);Module.HEAPU8.set(i,l);var u=Module.intArrayFromString(r).concat(0),s=Module._malloc(u.length);Module.HEAPU8.set(u,s);var c=null;if(null!==o){var f=Module.intArrayFromString(o).concat(0);c=Module._malloc(f.length),Module.HEAPU8.set(f,c)}var p=Module._malloc(256),d=Module._malloc(4);a=Module._PLAY_GetOriginalKey(n,l,s,c,p,d);var m=Module.HEAP32[d>>2],g="";if(1==a&&m<=256){var h=new ArrayBuffer(m);new Uint8Array(h).set(Module.HEAPU8.subarray(p,p+m)),g=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf-8",n=new TextDecoder(t);return n.decode(e)}(h)}if(Module._free(l),Module._free(s),Module._free(c),Module._free(p),Module._free(d),null===o)return g;N({nRet:a,outKey:g})}else if(At){wt=!0;var S={nType:"GetOriginalKeyCallBack",playToken:e,playTokenKey:r,deviceID:o};it&&it.postMessage(S)}else Tt=e,Ct=r,Mt=o;return a},SetWebSecurityKey:function(e,r,o,a){if(t.log("SetWebSecurityKey, PlayPort:"+n),!Ie)if(At){Dt=!0;var i={nType:"SetWebSecurityKey",nDecryptType:e,nFrameType:r,strKey:o,stStreamInfo:a};it&&it.postMessage(i)}else Rt=e,1==r?(It[0].nFrameType=r,It[0].strKey=o,It[0].stStreamInfo=a):21==r?(It[1].nFrameType=2,It[1].strKey=o,It[1].stStreamInfo=a):22==r&&(It[2].nFrameType=2,It[2].strKey=o,It[2].stStreamInfo=a)},ResetPlayState:function(){t.log("ResetPlayState, PlayPort:"+n),we&&we.ResetPlayState(),s&&s.ResetPlayState()},Stop:function(){t.log("Stop, PlayPort:"+n);var e=1;if(Ie){if(0==(e=Module._PLAY_Stop(n)))return e;e=Module._PLAY_CloseStream(n),ee=null,Module._free($)}else{it&&(it.postMessage({nType:"Stop"}),it.terminate(),it=null)}return zt(),ue=null,pe=null,de=null,ge=null,he=null,Se=null,ye=null,ve=null,_e=null,Ze=null,Qe=null,$e=null,Xe=0,Pe&&(Pe.stop(),Pe.setAudioProcesser(null),Pe=null),lt&&(lt.terminate(),lt=null),st&&(st.terminate(),st=null),ut&&(ut.StopProcess(),ut=null),we&&(we.stopRendering(),we.CleanScreen(0,0,0,0),we.terminate(),we=null),oe=0,ae=0,Te=0,y=null,h=null,je=!1,S=!1,qe=0,ze=0,Ye=0,Ke=!1,nt=-1,rt=!1,Ve=!1,dt=!1,ct=0,ft=0,pt=!1,e},FrameDataCallBack:function(e,t,n,o,a,i){var l={};pe||(ue=new ArrayBuffer(292),pe=new Uint8Array(ue),de=new DataView(ue)),pe.set(Module.HEAPU8.subarray(i,i+292)),l.nFrameType=de.getInt32(0,!0),l.nFrameID=de.getInt32(4,!0),l.nFrameSubType=de.getInt32(56,!0),l.nYear=de.getUint16(40,!0),l.nMonth=de.getUint16(42,!0),l.nDay=de.getUint16(46,!0),l.nHour=de.getUint16(48,!0),l.nMinute=de.getUint16(50,!0),l.nSecond=de.getUint16(52,!0);var u=Date.UTC(l.nYear,l.nMonth,l.nDay,l.nHour,l.nMinute,l.nSecond)/1e3;if(1==l.nFrameType)if(l.nRemainData=de.getInt32(36,!0),l.bThrowFrame=de.getUint8(120,!0),0==l.bThrowFrame){if(l.nEncodeType=de.getInt32(108,!0),l.nStreamType=de.getInt32(112,!0),l.nTimeStamp=de.getUint32(8,!0),8==l.nStreamType?r.timestamp=u:r.timestamp=l.nTimeStamp/1e3,r.timestamp_usec=0,2==l.nEncodeType||4==l.nEncodeType||8==l.nEncodeType?Ce=1:12==l.nEncodeType&&(Ce=2),l.nWidth=de.getInt32(12,!0),l.nHeight=de.getInt32(16,!0),0==l.nWidth||0==l.nHeight)return;if(l.nFrameRate=de.getInt32(20,!0),l.nStride=de.getInt32(116,!0),18==l.nFrameSubType||19==l.nFrameSubType||20==l.nFrameSubType?ie=1:0==l.nFrameSubType&&(ie=0),(1==Ce&&1==Ue||2==Ce&&1==ke)&&!ie&&13!=l.nStreamType)me=new ArrayBuffer(a),(te=new Uint8Array(me)).set(Module.HEAPU8.subarray(t,t+a)),jt(te,null,null,a,l);else{if(0==t||0==n||0==o)return;if(!Ie){l.nWidth==oe&&l.nHeight==ae&&null!=ye||(ge=null,he=null,Se=null,ye=null,ve=null,_e=null,ge=new ArrayBuffer(l.nWidth*l.nHeight),ye=new Uint8Array(ge),he=new ArrayBuffer(l.nWidth*l.nHeight/4),ve=new Uint8Array(he),Se=new ArrayBuffer(l.nWidth*l.nHeight/4),_e=new Uint8Array(Se));var s=0;for(s=0;s0)return;l.nBits=de.getInt32(28,!0),l.nSamples=de.getInt32(32,!0),l.nAudioChnNum=de.getInt32(24,!0);var c=new ArrayBuffer(a),f=new Uint8Array(c);f.set(Module.HEAPU8.subarray(t,t+a)),jt(f,null,null,a,l)}me=null,te=null},DecryptionResultCallBack:function(e,t,n){n,W(n)},RecordDataCallBack:function(e,n,r,o,a){tt+=r,Qe||(Ze=new ArrayBuffer(292),Qe=new Uint8Array(Ze),$e=new DataView(Ze)),Qe.set(Module.HEAPU8.subarray(a,a+292));var i=$e.getInt32(0,!0),l=$e.getInt32(4,!0);$e.getInt32(56,!0);if(1==i){t.log("RecordDataCallBack, nPort:"+e+", nFrameID:"+l);$e.getInt32(76,!0),$e.getInt32(80,!0),$e.getUint32(8,!0);var u=$e.getUint16(40,!0),s=cn($e.getUint16(42,!0)),c=cn($e.getUint16(46,!0)),f=cn($e.getUint16(48,!0)),p=cn($e.getUint16(50,!0)),d=cn($e.getUint16(52,!0)),m=Date.UTC(u,s,c,f,p,d)/1e3,g=new Date("".concat(u,"-").concat(s,"-").concat(c," ").concat(f,":").concat(p,":").concat(d)).getTime()}G&&G({frameType:i,timeStamp:g,utcTimeStamp:m,length:tt});var h=new ArrayBuffer(r),S=new Uint8Array(h);S.set(Module.HEAPU8.subarray(n,n+r)),Ie&&Je.postMessage({type:"addBuffer",buffer:S,offset:o,recordType:et}),h=null,S=null},IVSDataCallBack:function(e,n,r,o,a){t.log("IVSDataCallBack, nPort:"+e+", nType:"+r+", nLen:"+o+", nFrameID:"+a),Kt(e,n,r,o,a)},setCallback:function(e,n){switch(t.log("setCallback, type:"+e+", func:"+n),e){case"GetPlayPort":J=n;break;case"PlayStart":we.setBeginDrawCallback(n),s&&s.setBeginDrawCallback(n),L=n;break;case"DecodeStart":O=n;break;case"VideoFrameInfo":F=n;break;case"AudioFrameInfo":B=n;break;case"RecordTimeStamp":G=n;break;case"GetOriginalKey":N=n;break;case"DecryptionResult":W=n;break;case"Error":K=n;break;case"loadingBar":Y=n;break;case"audioTalk":case"videoCapture":X=n;break;case"StreamPlayOver":z=n;break;case"ARTagInfo":q=n;break;case"CapturePicDataCallBack":j=n,s&&s.setCapturePicDataCallBack(n)}},GetCurrentPlayTime:function(){return r.timestamp},SetSTFrameCallback:function(e){Z=e},setPrintLogLevel:function(e){if(Ht=e,Ie)Module._PLAY_SetPrintLogLevel(e);else{var t={nType:"setPrintLogLevel",nLogLevel:e};it&&it.postMessage(t)}we&&we.SetPrintLogLevel(e)},SetPlayMethod:function(e,t,n){we&&we.SetPlayMethod(e,t,n)}};var Jt,Zt,Qt,$t,en,tn,nn,rn,on,an,ln,un,sn=(Jt=window,Zt=Jt.document,Qt=function(){return Jt.URL||Jt.webkitURL||Jt},$t=Zt.createElementNS("http://www.w3.org/1999/xhtml","a"),en="download"in $t,tn=/constructor/i.test(Jt.HTMLElement),nn=/CriOS\/[\d]+/.test(navigator.userAgent),rn=function(e){(Jt.setImmediate||Jt.setTimeout)((function(){throw e}),0)},on=function(e){setTimeout((function(){"string"==typeof e?Qt().revokeObjectURL(e):e.remove()}),4e4)},an=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},un=(ln=function(e,t,n){n||(e=an(e));var r,o=this,a="application/octet-stream"===e.type,i=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){rn(e)}}}(o,"writestart progress write writeend".split(" "))};if(o.readyState=o.INIT,en)return r=Qt().createObjectURL(e),void setTimeout((function(){$t.href=r,$t.download=t,$t.dispatchEvent(new MouseEvent("click")),i(),on(r),o.readyState=o.DONE}));!function(){if((nn||a&&tn)&&Jt.FileReader){var t=new FileReader;return t.onloadend=function(){var e=nn?t.result:t.result.replace(/^data:[^;]*;/,"data:attachment/file;");Jt.open(e,"_blank")||(Jt.location.href=e),e=void 0,o.readyState=o.DONE,i()},t.readAsDataURL(e),void(o.readyState=o.INIT)}r||(r=Qt().createObjectURL(e)),a?Jt.location.href=r:Jt.open(r,"_blank")||(Jt.location.href=r),o.readyState=o.DONE,i(),on(r)}()}).prototype,"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return t=t||e.name||"download",n||(e=an(e)),navigator.msSaveOrOpenBlob(e,t)}:(un.readyState=un.INIT=0,un.WRITING=1,un.DONE=2,un.error=un.onwritestart=un.onprogress=un.onwrite=un.onabort=un.onerror=un.onwriteend=null,function(e,t,n){return null==t||null==t?null:new ln(e,t||e.name||"download",n)}));function cn(e){return e<10?"0".concat(e):e}function fn(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf-8",n=new TextDecoder(t),r=new Uint8Array(e),o=0;o0&&(e.strRtspvUrl+="?sourceId=",e.strRtspvUrl+=e.strSourceId),l=i.StartStream(e,u),i.SetMsgWaitTimeout(p),R||function(e){g=setTimeout((function(){g&&(clearTimeout(g),g=0),k.Error({errorCode:"409",description:"Rtsp Not Response"})}),1e3*e)}(d)}else{var h={bTalkService:e.bTalkService,bBroadcast:R,nRange:e.nRange,bPlayBack:o,bRtspFlag:u,nShortTimeout:p,nRtspResponseTimeout:d};n.connect(e.strRtspvUri,e.strRtspvUrl,e.strSourceId,h),n.setUserInfo(e.strUserName,e.strPassWord),n.setRtpDataCallback(V),n.setStreamFinishCallback(W)}return r&&r.SetStreamOver(!1),l}function F(){if(m||I?l&&(g&&(clearTimeout(g),g=0),i.StopStream(),i=null,l=null):(G("TEARDOWN"),n&&n.disconnect(),n=null),a)return a=!1,r&&r.StopRecord()}function B(e){e!=c&&(c=e,m||I?l&&i.PauseStream(e):G(e?"PAUSE":"PLAY"))}function G(e,t,r){var o;o="video"===t?{command:e,range:r||0}:{command:e,data:t},n&&n.controlPlayer(o)}function x(){s||(setTimeout((function(){r&&(f=r.GetSourceBufferRemain())}),1),o&&(f>7340032?B(!0):f<2097152&&B(!1)))}function V(e){h||(h=!0,function(){if(!m&&!I){var e=n&&n.GetSSRC(),t=n&&n.GetSdpInfo(),o={};if(o.sdpInfo=t,o.strUserName=v,o.strPassWord=P,0==y)return;1==y&&0==e.videoSSRC||(o.nSsrc=e.videoSSRC,r.SetWebSecurityKey(y,1,S,o)),1==y&&(0!=e.audio1SSRC&&(o.nSsrc=e.audio1SSRC,r.SetWebSecurityKey(y,21,S,o)),0!=e.audio2SSRC&&(o.nSsrc=e.audio2SSRC,r.SetWebSecurityKey(y,22,S,o)))}}()),!o&&f>7340032||r&&r.InputData(e)}function N(){x()}function W(){r&&r.SetStreamOver(!0)}function z(e,t){m||I?l&&i.PutStream(e,t):n&&n.sendRtpData(e)}function Y(e){if(!T){var t=r.GetOriginalKey(e.data,b,null);if(t.length>0&&-1!==t.indexOf("data")){A&&(clearTimeout(A),A=0),T=!0;var n=t.indexOf('"deviceIp":'),o=t.indexOf('",',n),a=t.slice(n+12,o);n=t.indexOf('"devicePort":'),o=t.indexOf('",',n);var i=t.slice(n+14,o);n=t.indexOf('"userName":'),o=t.indexOf('"}',n);var l=t.slice(n+12,o);n=t.indexOf('"devicePassword":'),o=t.indexOf('",',n);var u=t.slice(n+18,o);n=t.indexOf('"id":'),o=t.indexOf(",",n);var s=t.slice(n+5,o),c={strRtspvUri:"wss://"+a+":"+i,strRtspvUrl:"rtsp://"+l+":"+u+"@"+a+":"+i+"/cam/realmonitor?channel="+C+"&subtype="+M+"&proto=Private3",strSourceId:"",strUserName:l||"admin",strPassWord:u||"admin123",strDeviceID:s,bTalkService:D,nRange:0,nShortTimeout:3,nRtspResponseTimeout:8};setTimeout((function(){var e=O(c);k.GetStreamClinetHandle(e)}),1)}}}return H.prototype={Init:function(e,n,a){return function(e,n,a){null!=n&&(C=n.nChannel,M=n.nSubType,D=n.bTalkService);o=e.bPlayBack,null==r&&(r=new We(m,t),00){var l=r.GetPlayPort();m&&k.GetPlayPort(l)}for(var u in k)r.setCallback(u,k[u]);return r.SetSTFrameCallback(N),i}(e,n,a)},SetCacheMode:function(e){return function(e){return r&&r.SetCacheMode(e)}(e)},StartPullStream:function(e,t){return O(e,t)},StopPullStream:function(){F()},Pause:function(e){!function(e){s=e,B(e),r.Pause(e)}(e)},Stop:function(){r.CloseIVSDraw(),r.Stop(),r=null,h=!1,s=!1},SetSecurityKey:function(e,t,n,o,a){!function(e,t,n,o,a){r.SetSecurityKey(e,t,n,o,a)}(e,t,n,o,a)},SetSpeed:function(e){d=e,function(e){m||I?l&&i.PlayControl(-1,-1,e):G("SCALE",e);r.SetPlaySpeed(e)}(e)},SetSoundState:function(e){!function(e){r.SetSoundState(e)}(e)},SetVolume:function(e){!function(e){r.SetVolume(e)}(e)},StartRecord:function(e,t,n){return function(e,t,n){return a=!0,r.StartRecord(e,t,n)}(e,t,n)},StopRecord:function(){return a=!1,r.StopRecord()},OpenIVS:function(e){return function(e){return r.OpenIVSDraw(e)}(e)},CloseIVS:function(){return r.CloseIVSDraw()},SetIvsEnable:function(e,t){return function(e,t){return r.SetIvsEnable(e,t)}(e,t)},SetPanoAR:function(e){return function(e){return r.SetPanoAR(e)}(e)},Set3DPoint:function(e){return function(e){return r.Set3DPoint(e)}(e)},OnMouseDown:function(){return r.OnMouseDown()},OnMouseMove:function(e,t){return function(e,t){return r.OnMouseMove(e,t)}(e,t)},OnMouseUp:function(){return r.OnMouseUp()},OnMouseWheel:function(e){return function(e){return r.OnMouseWheel(e)}(e)},GetVRCoord2DTrans:function(e,t){return function(e,t){return r.GetVRCoord2DTrans(e,t)}(e,t)},GetVRCoord3DTrans:function(e,t){return function(e,t){return r.GetVRCoord3DTrans(e,t)}(e,t)},CapturePic:function(e){!function(e){r.capturePic(e)}(e)},StartTalk:function(e){!function(e){r.setCallback("audioTalk",z),r.StartTalk(e)}(e)},StopTalk:function(){r.StopTalk()},StartVideoCapture:function(e,t,n){!function(e,t,n){r.setCallback("audioTalk",z),r.StartVideoCapture(e,t,n)}(e,t,n)},StopVideoCapture:function(){r.StopVideoCapture()},SetSeekTime:function(e){!function(e){m||I?l&&i.PlayControl(e,-1,d):G("PLAY_SEEK",e);r.ResetBuffer()}(e)},OpenPlayGroup:function(){return r.OpenPlayGroup()},AddToPlayGroup:function(e,t){return function(e,t){return r.AddToPlayGroup(e,t)}(e,t)},DelFromPlayGroup:function(e,t){return function(e,t){return r.DelFromPlayGroup(e,t)}(e,t)},ClosePlayGroup:function(e){return function(e){return r.ClosePlayGroup(e)}(e)},PausePlayGroup:function(e,t){return function(e,t){return B(t),r.PausePlayGroup(e,t)}(e,t)},SetPlayGroupSpeed:function(e,t){return d=t,function(e,t){m||I?l&&i.PlayControl(-1,-1,t):G("SCALE",t);return r.SetPlayGroupSpeed(e,t)}(e,t)},GetSourceBufferRemain:function(){return f=r.GetSourceBufferRemain()},SetDecodeMode:function(e,t){!function(e,t){r.SetDecodeMode(e,t)}(e,t)},GetOriginalKey:function(e){!function(e){r.GetOriginalKey(e.strPlayToken,e.strPlayTokenKey,e.strDeviceID)}(e)},InputData:function(e){return function(e){return r&&r.InputData(e)}(e)},UserVerify:function(e,t,n,r,o){!function(e,t,n,r,o){b=o,(E=new WebSocket("wss://"+e+":"+t+"/ar/device/detail")).binaryType="arraybuffer",E.addEventListener("message",Y,!1),E.onopen=function(){var e='{\n "id":'+n+',\n "token":"'+r+'"\n}';E.send(e),T=!1,function(){A&&(clearTimeout(A),A=0);A=setTimeout((function(){k.Error({errorCode:"408",description:"Device verify failed"})}),5e3)}()},E.onerror=function(e){k.Error({errorCode:205,description:"WebSocket Verify Error"})}}(e,t,n,r,o)},SetCallBack:function(e,t){k[e]=t},SetPrintLogLevel:function(e){!function(e){U=e,t.setPrintLogLevel(e),r&&r.setPrintLogLevel(e)}(e)},SetPlayMethod:function(e,t,n){!function(e,t,n){r&&r.SetPlayMethod(e,t,n)}(e,t,n)},InputDataEx:function(e,t){if(g&&(clearTimeout(g),g=0),o&&!p){p=!0;var n=i.GetPlayInfo();k.PlayBackStreamRange(n)}var a=new ArrayBuffer(t),l=new Uint8Array(a);return l.set(SCModule.HEAPU8.subarray(e,e+t)),r&&r.InputData(l)},SetFrameData:function(e,t,n,o,a,i){x(),r.FrameDataCallBack(e,t,n,o,a,i)},SetDecryptionResult:function(e,t,n){r.DecryptionResultCallBack(e,t,n)},SetRecordData:function(e,t,n,o,a){r.RecordDataCallBack(e,t,n,o,a)},SetIVSDrawData:function(e,t,n,o,a){r.IVSDataCallBack(e,t,n,o,a)},StreamRedirectCallback:function(e){!function(e){F();var t=new ArrayBuffer(1e3),n=new Uint8Array(t);n.set(SCModule.HEAPU8.subarray(e,e+1e3));var r=function(e){for(var t="",n=0;n