1 line
172 KiB
JavaScript
1 line
172 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PlaySDKInterface=t():e.PlaySDKInterface=t()}(window,(function(){return 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,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,l=[],u=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(l.push(r.value),l.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var a;n.r(t);function i(){return(a=window.SCModule)._RTSP_InitSession()}function l(e,t,n,r,o){return a._RTSP_PlayControl(e,t,n,r,o)}function u(e,t,n,r){return a._RTSP_PutStream(e,t,n,r)}function c(){return(a=window.SCModule)._RTSV_InitSession()}function s(e,t,n,r,o){return a._RTSV_PlayControl(e,t,n,r,o)}function f(e,t,n,r){return a._RTSV_PutStream(e,t,n,r)}var p=function(){var e=null,t=0,n=!1,o=null,p=null,d=null,m=null,h=null;function g(){}return g.prototype={SetLogLevel:function(e){var t;t=e,void 0!==window.SCModule&&(a=window.SCModule)._GLOBAL_SetLogLevel(t)},StartStream:function(r,u){return null==r.strDeviceID&&(r.strDeviceID=0),void 0===r.bStandardPack&&(r.bStandardPack=!1),0==(t=u)?(null===e&&(e=i()),void 0!==r.nStartNpt&&l(e,r.nStartNpt,-1,1,!1),function(e,t,n,r,o,i){var l=a.intArrayFromString(t).concat(0),u=a._malloc(l.length);a.HEAPU8.set(l,u);var c=a.intArrayFromString(n).concat(0),s=a._malloc(c.length);a.HEAPU8.set(c,s);var f=a.intArrayFromString(r).concat(0),p=a._malloc(f.length);a.HEAPU8.set(f,p);var d=a._RTSP_StartStream(e,u,s,p,o,i);a._free(u),a._free(s),a._free(p)}(e,r.strRtspvUrl,r.strRtspvUri,r.strDeviceID,r.bTalkService,r.bStandardPack)):1==t?(null!=r.nAudioType&&null!=r.nFrequency&&null!=r.nChannelNum||(r.nAudioType=14,r.nFrequency=8e3,r.nChannelNum=1),null===e&&(e=c()),void 0!==r.nStartNpt&&s(e,r.nStartNpt,-1,1,!1),function(e,t,n,r,o,i,l,u,c,s,f){var p=a.intArrayFromString(t).concat(0),d=a._malloc(p.length);a.HEAPU8.set(p,d);var m=a.intArrayFromString(n).concat(0),h=a._malloc(m.length);a.HEAPU8.set(m,h);var g=a.intArrayFromString(r).concat(0),_=a._malloc(g.length);if(a.HEAPU8.set(g,_),o&&a._RTSV_InitTalkInfo(e,i,l,u),c){var y=a.intArrayFromString(s).concat(0),S=a._malloc(y.length);a.HEAPU8.set(y,S);var v=a.intArrayFromString(f).concat(0),P=a._malloc(v.length);a.HEAPU8.set(v,P),a._RTSV_SetWSSEInfo(e,c,S,P),a._free(S),a._free(P)}var b=a._RTSV_StartStream(e,d,h,_);a._free(d),a._free(h),a._free(_)}(e,r.strRtspvUrl,r.strRtspvUri,r.strDeviceID,r.bTalkService,r.nAudioType,r.nFrequency,r.nChannelNum,!1,null,null)):2==t&&e&&function(e,t,n){var r=a.intArrayFromString(t).concat(0),o=a._malloc(r.length);a.HEAPU8.set(r,o);var i=a._VNSP_StartStream(e,o,n);a._free(o)}(e,r.strRtspvUri,r.nStreamType),(n=r.bTalkService)&&(o=a._malloc(10240),p=new Uint8Array(a.HEAPU8.buffer,o,10240),d=a._malloc(1048576),m=new Uint8Array(a.HEAPU8.buffer,d,1048576)),e},SetLoginParam:function(t){return function(e,t,n,r,o,i){var l=a.intArrayFromString(n).concat(0),u=a._malloc(l.length);a.HEAPU8.set(l,u);var c=a.intArrayFromString(r).concat(0),s=a._malloc(c.length);a.HEAPU8.set(c,s);var f=a.intArrayFromString(o).concat(0),p=a._malloc(f.length);a.HEAPU8.set(f,p);var d=a.intArrayFromString(i).concat(0),m=a._malloc(d.length);a.HEAPU8.set(d,m);var h=a._VNSP_SetLoginParam(e,t,u,s,p,m);a._free(u),a._free(s),a._free(p),a._free(m)}(e=(a=window.SCModule)._VNSP_InitSession(),t.playerType,t.deviceId,t.vnspType,t.clientMac,t.vnspVersion),e},StopStream:function(){var r;0==t?(r=e,a._RTSP_StopStream(r)):1==t?function(e){a._RTSV_StopStream(e)}(e):2==t&&function(e){a._VNSP_StopStream(e)}(e),e=null,n&&(p=null,a._free(o),m=null,a._free(d))},PauseStream:function(n){var r;n?0==t?(r=e,a._RTSP_PauseStream(r)):1==t?function(e){a._RTSV_PauseStream(e)}(e):2==t&&function(e){a._VNSP_PauseStream(e)}(e):0==t?function(e){a._RTSP_ResumeStream(e)}(e):1==t?function(e){a._RTSV_ResumeStream(e)}(e):2==t&&function(e){a._VNSP_ResumeStream(e)}(e)},PlayControl:function(n,r,o,i,u){var c,f;void 0===i&&(i=-1),0==t?l(e,n,r,o,u):1==t?s(e,n,r,o,u):2==t&&(-1==n?(c=e,f=o,a._VNSP_FastPlay(c,f)):function(e,t,n,r){var o=a.intArrayFromString(n).concat(0),i=a._malloc(o.length);a.HEAPU8.set(o,i);var l=a.intArrayFromString(r).concat(0),u=a._malloc(l.length);a.HEAPU8.set(l,u);var c=a._VNSP_SetPlayRange(e,t,i,u);a._free(i),a._free(u)}(e,i,n,r))},PlayControlUtc:function(n,r,o,i,l){void 0===i&&(i=-1),0==t&&function(e,t,n,r,o){var i=a.intArrayFromString(t).concat(0),l=a._malloc(i.length);a.HEAPU8.set(i,l);var u=a.intArrayFromString(n).concat(0),c=a._malloc(u.length);a.HEAPU8.set(u,c);var s=a._RTSP_PlayControlUtc(e,l,c,r,o);a._free(l),a._free(c)}(e,n,r,o,l)},PutStream:function(n,r){if(null!=p){var o=n.subarray(6);if(5==r)p.set(o),0==t?u(e,p.byteOffset,o.length,r):1==t?f(e,p.byteOffset,o.length,r):2==t&&function(e,t,n){a._VNSP_PutStream(e,t,n)}(e,p.byteOffset,o.length);else{if(o.length>1048576)return void console.warn("StreamClient buffer not enough, DataLen:"+o.length);m.set(o),0==t?u(e,m.byteOffset,o.length,r):1==t&&f(e,m.byteOffset,o.length,r)}}},GetPlayInfo:function(){var n=0;if(0==t){var o=r(function(e){var t=a._malloc(8),n=a._malloc(8);a._RTSP_GetPlayInfo(e,t,n);var r=a.HEAPF64[t>>3],o=a.HEAPF64[n>>3];return a._free(t),a._free(n),[r,o]}(e),2),i=o[0];n=o[1]-i}return n},SetMsgWaitTimeout:function(n){0==t?function(e,t){a._RTSP_SetMsgTimeout(e,t)}(e,n):1==t&&function(e,t){a._RTSV_SetMsgTimeout(e,t)}(e,n)},SetStreamTimeout:function(n){0==t&&function(e,t){a._RTSP_SetStreamTimeout(e,t)}(e,n)},SetOriginalKey:function(t,n,r,o,l){return 0==l?(null===e&&(e=i()),function(e,t,n,r,o){var i=a.intArrayFromString(n).concat(0),l=a._malloc(i.length);a.HEAPU8.set(i,l);var u=a.intArrayFromString(r).concat(0),c=a._malloc(u.length);a.HEAPU8.set(u,c);var s=a.intArrayFromString(o).concat(0),f=a._malloc(s.length);a.HEAPU8.set(s,f);var p=a._RTSP_SetOriginalKey(e,t,l,c,f);return a._free(l),a._free(c),a._free(f),p}(e,t,n,r,o)):1==l?(null===e&&(e=c()),function(e,t,n,r){var o=a.intArrayFromString(t).concat(0),i=a._malloc(o.length);a.HEAPU8.set(o,i);var l=a.intArrayFromString(n).concat(0),u=a._malloc(l.length);a.HEAPU8.set(l,u);var c=a.intArrayFromString(r).concat(0),s=a._malloc(c.length);a.HEAPU8.set(c,s);var f=a._RTSV_SetOriginalKey(e,i,u,s);return a._free(i),a._free(u),a._free(s),f}(e,n,r,o)):-1},SetCallback:function(e,t){switch(e){case"Error":h=t}},SetStreamFailedMsg:function(e,t){if(null!==h){switch(e){case 285868033:h({errorCode:210,description:"Parse failed."});break;case 285868034:h({errorCode:202,description:"WebSocket error."});break;case 285868035:h({errorCode:211,description:"Inter error."});break;case 285868036:case 6500424:h({errorCode:408,description:"Short request timeout."});break;case 269025680:h({errorCode:223,description:"Bad request."});break;case 269025681:h({errorCode:224,description:"Unauthorized."});break;case 269025683:h({errorCode:226,description:"Access forbidden."});break;case 269025684:h({errorCode:227,description:"Resources not found."});break;case 269025741:h({errorCode:248,description:"Unsupported transport."});break;case 269025780:h({errorCode:250,description:"Internal server error."});break;case 269025781:h({errorCode:251,description:"Not implemented."});break;case 269025783:h({errorCode:253,description:"Service unavailable."});break;case 269025784:h({errorCode:254,description:"Gateway timeout."});break;case 269025833:h({errorCode:258,description:"Account block."});break;case 32993289:h({errorCode:205,description:"Device busy."})}void 0!==t&&16391==t&&h({errorCode:206,description:"Device stop talk."})}}},new g},d="Opera",m="Chrome",h="Firefox",g="Edge",_="Edg",y="IE",S="Safari";function v(){var e=navigator.userAgent;return e.includes("Edge")?g:e.includes("Edg")?_:e.includes("Firefox")?h:e.includes("Chrome")?m:e.includes("Safari")?S:e.includes("compatible")&&e.includes("MSIE")&&e.includes("Opera")?y:e.includes("Opera")?d:""}function P(e){return navigator.userAgent.split(e)[1].split(".")[0].slice(1)}function b(){var e=v(),t=P(e);console.log("checkSupportH265MSE, browserType:"+e+", browserVersion:"+t);var n=!1;switch(e){case m:n=t>=104;break;default:n=0}return n}var w=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 A(){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 E(e){this.buffer=e,this.previous=null,this.next=null}var T=function(e){E.call(this,e)};function I(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 T(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 D=function(e){var t=[],n={},r=-1,o=e;function a(){for(var e in t)t[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)];0,1==o?n.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]):2==o&&(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 i=function(e){for(var t=8,n=Array.prototype.slice.call(arguments,1),r=0;r<n.length;r++)t+=n[r].byteLength;var o=new Uint8Array(t),a=0;o[a++]=t>>>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<n.length;r++)o.set(n[r],a),a+=n[r].byteLength;return o},l=function(e){return i(t.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&e.channelcount)>>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])),i(t.esds,o)));var n,r,o},u=function(e){return"audio"===e.type?i(t.stsd,n.STSD_PREFIX,l(e)):i(t.stsd,n.STSD_PREFIX,function(e){var n=e.vps||[],r=e.sps||[],a=e.pps||[],l=[],u=[],c=[],s=0;for(s=0;s<n.length;s++)l.push((65280&n[s].byteLength)>>>8),l.push(255&n[s].byteLength),l=l.concat(Array.prototype.slice.call(n[s]));for(s=0;s<r.length;s++)u.push((65280&r[s].byteLength)>>>8),u.push(255&r[s].byteLength),u=u.concat(Array.prototype.slice.call(r[s]));for(s=0;s<a.length;s++)c.push((65280&a[s].byteLength)>>>8),c.push(255&a[s].byteLength),c=c.concat(Array.prototype.slice.call(a[s]));return 1==o?i(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]),i(t.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([r.length]).concat(u).concat([a.length]).concat(c)))):2==o?i(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]),i(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(c)))):void 0}(e))},c=function(e){var r=null;return r="audio"===e.type?i(t.smhd,n.SMHD):i(t.vmhd,n.VMHD),i(t.minf,r,i(t.dinf,i(t.dref,n.DREF)),function(e){return i(t.stbl,u(e),i(t.stts,n.STTS),i(t.stsc,n.STSC),i(t.stsz,n.STSZ),i(t.stco,n.STCO))}(e))},s=function(e){return i(t.mdia,function(e){var n=e.timescale,r=e.duration;return i(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,i(t.hdlr,r)}(e),c(e))},f=function(e){return i(t.trak,function(e){for(var n=[],o=0;o<9;o++)n[o]=0;if(n[0]=n[4]=65536,n[8]=1<<30,r>=0){var a=0;switch(r){case 1:a=90;break;case 2:a=180;break;case 3:a=270;break;default:a=0}var l=-3.141592653589793*a/180,u=Math.cos(l),c=Math.sin(l);n[0]=65536*u,n[1]=65536*-c,n[3]=65536*c,n[4]=65536*u}var s=e.id,f=e.duration,p=e.width,d=e.height;return i(t.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,s>>>24&255,s>>>16&255,s>>>8&255,255&s,0,0,0,0,f>>>24&255,f>>>16&255,f>>>8&255,255&f,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n[0]>>>24&255,n[0]>>>16&255,n[0]>>>8&255,255&n[0],n[1]>>>24&255,n[1]>>>16&255,n[1]>>>8&255,255&n[1],0,0,0,0,n[3]>>>24&255,n[3]>>>16&255,n[3]>>>8&255,255&n[3],n[4]>>>24&255,n[4]>>>16&255,n[4]>>>8&255,255&n[4],0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,p>>>8&255,255&p,0,0,d>>>8&255,255&d,0,0]))}(e),s(e))},p=function(e){return i(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 i(t.trex,r)}(e))},d=function(e){var n,r,o=(n=e.timescale,r=e.duration,i(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]))),a=f(e),l=p(e);return i(t.moov,o,a,l)},m=function(e,n){return"audio"===e.type?audioTrun(e,n):function(e,n){var r,o=null,a=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<r.length;l++)a=r[l],o=o.concat([(4278190080&a.size)>>>24,(16711680&a.size)>>>16,(65280&a.size)>>>8,255&a.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<r.length;l++)a=r[l],o=o.concat([(4278190080&a.frameDuration)>>>24,(16711680&a.frameDuration)>>>16,(65280&a.frameDuration)>>>8,255&a.frameDuration,(4278190080&a.size)>>>24,(16711680&a.size)>>>16,(65280&a.size)>>>8,255&a.size]);return i(t.trun,new Uint8Array(o))}(e,n)},h=function(e,n){return i(t.moof,function(e){var n=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return i(t.mfhd,n)}(e),function(e){var n,r,o;return n=i(t.tfhd,new Uint8Array([0,2,0,0,0,0,0,1])),r=i(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=m(e,72),i(t.traf,n,r,o)}(n))};return a.prototype={initSegment:function(e){var r=i(t.ftyp,n.FTYP),o=d(e),a=new Uint8Array(r.byteLength+o.byteLength);return a.set(r,0),a.set(o,r.byteLength),a},mediaSegment:function(e,n,r,o){var a=h(e,n),l=function(e){return i(t.mdat,e)}(r),u=null;return(u=new Uint8Array(a.byteLength+l.byteLength)).set(a),u.set(l,a.byteLength),u},SetRotateType:function(e){r=e}},new a};function k(e){var t=0,n=null,r=e;function o(){t=0,n=new M}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<<o:2==a?i&255>>8-o|1<<o:0,e.set([i],r+a)}else e.set([0],r),e.set([1],r+1)}function l(e,t){if(t<=25)var n=u(e,t);else n=u(e,16)<<t-16|u(e,t-16);return n}function u(e,n){var r=0;if(1===n)r=a(e,0);else for(var o=0;o<n;o++)r=(r<<1)+a(e,o);return t+=n,r}function c(e,n){for(var r=0,o=0,i=n;t+i<8*e.length&&!a(e,i++);)r++;if(0===r)return t+=1,0;o=1<<r;for(var l=r-1;l>=0;l--,i++)o|=a(e,i)<<l;return t+=2*r+1,o-1}function s(e,t){var n=c(e,t);return 1&n?(n+1)/2:-n/2}function f(e){n.put("cpb_cnt_minus1",c(e,0)),n.put("bit_rate_scale",u(e,4)),n.put("cpb_size_scale",u(e,4));for(var t=n.get("cpb_cnt_minus1"),r=new Array(t),o=new Array(t),a=new Array(t),i=0;i<=t;i++)r[i]=c(e,0),o[i]=c(e,0),a[i]=u(e,1);n.put("bit_rate_value_minus1",r),n.put("cpb_size_value_minus1",o),n.put("cbr_flag",a),n.put("initial_cpb_removal_delay_length_minus1",u(e,5)),n.put("cpb_removal_delay_length_minus1",u(e,5)),n.put("dpb_output_delay_length_minus1",u(e,5)),n.put("time_offset_length",u(e,5))}function p(e,t){var n=Number(e).toString(16);for(t=null==t?t=2:t;n.length<t;)n="0"+n;return n}return o.prototype={parse:function(e){if(t=0,n.clear(),1==r){n.put("forbidden_zero_bit",u(e,1)),n.put("nal_ref_idc",u(e,2)),n.put("nal_unit_type",u(e,5)),n.put("profile_idc",u(e,8)),n.put("profile_compatibility",u(e,8)),n.put("level_idc",u(e,8)),n.put("seq_parameter_set_id",c(e,0));var o=n.get("profile_idc");if((100===o||110===o||122===o||244===o||44===o||83===o||86===o||118===o||128===o||138===o||139===o||134===o)&&(n.put("chroma_format_idc",c(e,0)),3===n.get("chroma_format_idc")&&n.put("separate_colour_plane_flag",u(e,1)),n.put("bit_depth_luma_minus8",c(e,0)),n.put("bit_depth_chroma_minus8",c(e,0)),n.put("qpprime_y_zero_transform_bypass_flag",u(e,1)),n.put("seq_scaling_matrix_present_flag",u(e,1)),n.get("seq_scaling_matrix_present_flag"))){for(var a=3!==n.get("chroma_format_idc")?8:12,p=new Array(a),d=0;d<a;d++)if(p[d]=u(e,1),p[d])for(var m=d<6?16:64,h=8,g=8,_=0;_<m;_++)g&&(g=(h+s(e,0)+256)%256),h=0===g?h:g;n.put("seq_scaling_list_present_flag",p)}if(n.put("log2_max_frame_num_minus4",c(e,0)),n.put("pic_order_cnt_type",c(e,0)),0===n.get("pic_order_cnt_type"))n.put("log2_max_pic_order_cnt_lsb_minus4",c(e,0));else if(1===n.get("pic_order_cnt_type")){n.put("delta_pic_order_always_zero_flag",u(e,1)),n.put("offset_for_non_ref_pic",s(e,0)),n.put("offset_for_top_to_bottom_field",s(e,0)),n.put("num_ref_frames_in_pic_order_cnt_cycle",c(e,0));for(var y=0;y<n.get("num_ref_frames_in_pic_order_cnt_cycle");y++)n.put("num_ref_frames_in_pic_order_cnt_cycle",s(e,0))}n.put("num_ref_frames",c(e,0)),n.put("gaps_in_frame_num_value_allowed_flag",u(e,1)),n.put("pic_width_in_mbs_minus1",c(e,0)),n.put("pic_height_in_map_units_minus1",c(e,0)),n.put("frame_mbs_only_flag",u(e,1)),0===n.get("frame_mbs_only_flag")&&n.put("mb_adaptive_frame_field_flag",u(e,1)),n.put("direct_8x8_interence_flag",u(e,1)),n.put("frame_cropping_flag",u(e,1)),1===n.get("frame_cropping_flag")&&(n.put("frame_cropping_rect_left_offset",c(e,0)),n.put("frame_cropping_rect_right_offset",c(e,0)),n.put("frame_cropping_rect_top_offset",c(e,0)),n.put("frame_cropping_rect_bottom_offset",c(e,0))),n.put("vui_parameters_present_flag",u(e,1)),n.get("vui_parameters_present_flag")&&function(e){n.put("aspect_ratio_info_present_flag",u(e,1)),n.get("aspect_ratio_info_present_flag")&&(n.put("aspect_ratio_idc",u(e,8)),255===n.get("aspect_ratio_idc")&&(i(e),n.put("sar_width",u(e,16)),i(e),n.put("sar_height",u(e,16)))),n.put("overscan_info_present_flag",u(e,1)),n.get("overscan_info_present_flag")&&n.put("overscan_appropriate_flag",u(e,1)),n.put("video_signal_type_present_flag",u(e,1)),n.get("video_signal_type_present_flag")&&(n.put("video_format",u(e,3)),n.put("video_full_range_flag",u(e,1)),n.put("colour_description_present_flag",u(e,1)),n.get("colour_description_present_flag")&&(n.put("colour_primaries",u(e,8)),n.put("transfer_characteristics",u(e,8)),n.put("matrix_coefficients",u(e,8)))),n.put("chroma_loc_info_present_flag",u(e,1)),n.get("chroma_loc_info_present_flag")&&(n.put("chroma_sample_loc_type_top_field",c(e,0)),n.put("chroma_sample_loc_type_bottom_field",c(e,0))),n.put("timing_info_present_flag",u(e,1)),n.get("timing_info_present_flag")&&(n.put("num_units_in_tick",u(e,32)),n.put("time_scale",u(e,32)),n.put("fixed_frame_rate_flag",u(e,1))),n.put("nal_hrd_parameters_present_flag",u(e,1)),n.get("nal_hrd_parameters_present_flag")&&f(e),n.put("vcl_hrd_parameters_present_flag",u(e,1)),n.get("vcl_hrd_parameters_present_flag")&&f(e),(n.get("nal_hrd_parameters_present_flag")||n.get("vcl_hrd_parameters_present_flag"))&&n.put("low_delay_hrd_flag",u(e,1)),n.put("pic_struct_present_flag",u(e,1)),n.put("bitstream_restriction_flag",u(e,1)),n.get("bitstream_restriction_flag")&&(n.put("motion_vectors_over_pic_boundaries_flag",u(e,1)),n.put("max_bytes_per_pic_denom",c(e,0)),n.put("max_bits_per_mb_denom",c(e,0)))}(e)}else if(2==r){var S=new ArrayBuffer(256),v=new Uint8Array(S);!function(e,t,n,r){for(var o=0,a=0;o+2<t&&a+2<r;++o)0==e[o]&&0==e[o+1]&&3==e[o+2]?(n[a++]=e[o++],n[a++]=e[o++]):n[a++]=e[o];for(;o<t&&a<r;)n[a++]=e[o++]}(e,e.length,v,256);var P=[],b=[];u(v,4);var w=u(v,3);for(n.put("temporalIdNested",u(v,1)),n.put("general_profile_space",u(v,2)),n.put("general_tier_flag",u(v,1)),n.put("general_profile_idc",u(v,5)),n.put("general_profile_compatibility_flags",l(v,32)),n.put("general_constraint_indicator_flags",(A=v,(E=48)<=32?l(A,E):l(A,E-32)<<32|l(A,32))),n.put("general_level_idc",u(v,8)),d=0;d<w&&d<6;d++)P[d]=u(v,1),b[d]=u(v,1);if(w>0)for(d=w;d<8;d++)u(v,2);for(d=0;d<w&&d<6;d++)b[d]&&u(v,8);c(v,0);n.put("chroma_format_idc",c(v,0));c(v,0),c(v,0);u(v,1),c(v,0),c(v,0),c(v,0),c(v,0),n.put("bitDepthLumaMinus8",c(v,0)+8),n.put("bitDepthChromaMinus8",c(v,0)+8),S=null,v=null}var A,E;return!0},getSizeInfo:function(){var e=0,t=0;0===n.get("chroma_format_idc")?e=t=0:1===n.get("chroma_format_idc")?e=t=2:2===n.get("chroma_format_idc")?(e=2,t=1):3===n.get("chroma_format_idc")&&(0===n.get("separate_colour_plane_flag")?e=t=1:1===n.get("separate_colour_plane_flag")&&(e=t=0));var r=n.get("pic_width_in_mbs_minus1")+1,o=n.get("pic_height_in_map_units_minus1")+1,a=(2-n.get("frame_mbs_only_flag"))*o,i=0,l=0,u=0,c=0;1===n.get("frame_cropping_flag")&&(i=n.get("frame_cropping_rect_left_offset"),l=n.get("frame_cropping_rect_right_offset"),u=n.get("frame_cropping_rect_top_offset"),c=n.get("frame_cropping_rect_bottom_offset"));var s=16*r*(16*a);return{width:16*r-e*(i+l),height:16*a-t*(2-n.get("frame_mbs_only_flag"))*(u+c),decodeSize:s}},getSpsValue:function(e){return n.get(e)},getCodecInfo:function(){if(1==r)return"avc1."+n.get("profile_idc").toString(16)+(n.get("profile_compatibility")<15?"0"+n.get("profile_compatibility").toString(16):n.get("profile_compatibility").toString(16))+n.get("level_idc").toString(16);if(2==r){var e="hev1.";switch(n.get("general_profile_space")){case 0:e+="";break;case 1:e+="A";break;case 2:e+="B";break;case 3:e+="C"}e+=n.get("general_profile_idc"),e+=".";for(var t=n.get("general_profile_compatibility_flags"),o=0,a=0;a<32&&(o|=1&t,31!=a);a++)o<<=1,t>>=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,c="";for(a=5;0<=a;a--)(l[a]||u)&&(c="."+p(l[a],0)+c,u=!0);return e+=c}}},new o}var C,M=function(){this.map={}};function R(e,t,n,r){e.HEAPU8[t+n]=void 0!==r?r:0}function U(e,t,n,r){e.HEAPU16[t/2+n/2]=void 0!==r?r:0}function H(e,t,n,r){e.HEAP32[t/4+n/4]=void 0!==r?r:0}function F(e,t,n,r){e.HEAPU32[t/4+n/4]=void 0!==r?r:0}function L(e,t,n,r){e.HEAPF32[t/4+n/4]=void 0!==r?r:0}M.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 x(e){return C._RENDER_Destroy(e)}var O;function B(e,t,n){return C._RENDER_AlgoCommand(e,t,n)}var V=5,G=6,N=7,W=16,z=18,j=19,Y=21,K=22,q=3,X=14,J=23,$=25,Q=28,Z=40,ee=41,te=1,ne=2,re=3,oe=4,ae=6,ie=8;function le(e){O._DRAW_SetLanguageEnvi(e)}function ue(e,t){O._DRAW_CleanScreen(e),O._DRAW_DrawByRenderHandle(e,0,t)}function ce(e){this.buffer=e,this.previous=null,this.next=null}var se=function(e,t,n,r,o,a,i){a=a;var l=i,u=n,c=e,s=r,f=null,p=0,d=0,m=0,h=!1,g=null,_=0,y=0,S=!1,v=!1,P=1,b=!1,w=0,A=0,E=0,T=0,D=o,k=-1,M=0,se=!1,fe=null,pe=!1,de=!1,me={},he=120,ge=80,_e=240,ye=null,Se=-1,ve=!1,Pe=null,be=null,we=null,Ae=null,Ee=!1,Te=!1,Ie=function(e){var t=3;switch(e.primaries){case"bt709":t=3;break;case"bt470bg":t=1;break;case"smpte170m":t=2;break;case"bt2020":t=4;break;case"smpte432":t=5;break;default:t=3}return t},De=function(e){var t=5;switch(e.transfer){case"bt709":case"smpte170m":t=5;break;case"iec61966-2-1":t=2;break;case"linear":t=1;break;case"pq":t=6;break;case"hlg":t=8;break;default:t=5}return t},ke=function(e){var t=2;switch(e.matrix){case"rgb":case"bt709":t=2;break;case"bt470bg":t=1;break;case"bt2020-ncl":t=3;break;default:t=2}return t};function Ce(){g=new I(u),h=!1}var Me=function(e){if(we(),k=e.buffer.stuFrameInfo.nFrameID,be(e.buffer.stuFrameInfo),a.log("drawFrame, m_nCurRenderFrameID:"+k+", m_bMSEDecode:"+Ee),Ee)return l.PlayMSE(e.buffer.stuFrameInfo,e.buffer.Image.DataY),delete e.buffer,e.buffer=null,e.previous=null,e.next=null,e=null,!0;if(!se){a.log("Single SW Play Start."),se=!0;var t={decodeMode:"canvas"};t.width=w,t.height=A,1==M?t.encodeMode="H264":2==M&&(t.encodeMode="H265"),fe&&fe(t)}if(null!==f){var n=-1==Se?e.buffer.stuFrameInfo.nRotateType:Se;return n>=0&&(r=f,(o=n)<0||o>3||C._RENDER_Rotate(r,o)),function(e,t,n,r){var o,a=C._malloc(80),i=0,l=null,u=0,c=null,s=0,f=null;9!=t.ImageFormat&&(i=t.width0*t.height0,l=C._malloc(i),C.writeArrayToMemory(t.DataY,l),u=t.width1*t.height1,c=C._malloc(u),C.writeArrayToMemory(t.DataU,c),s=t.width2*t.height2,f=C._malloc(s),C.writeArrayToMemory(t.DataV,f)),C.HEAP32[a/4+0]=0,C.HEAP32[a/4+1]=t.ImageFormat,C.HEAP32[a/4+2]=0,C.HEAP32[a/4+3]=0,9!=t.ImageFormat?(C.HEAP32[a/4+4]=l,C.HEAP32[a/4+5]=c,C.HEAP32[a/4+6]=f):(C.HEAP32[a/4+4]=t.DataY,C.HEAP32[a/4+5]=0,C.HEAP32[a/4+6]=0),C.HEAP32[a/4+7]=t.width0,C.HEAP32[a/4+8]=t.width1,C.HEAP32[a/4+9]=t.width2,C.HEAP32[a/4+10]=t.height0,C.HEAP32[a/4+11]=t.height1,C.HEAP32[a/4+12]=t.height2,C.HEAP32[a/4+13]=t.width0,C.HEAP32[a/4+14]=t.width1,C.HEAP32[a/4+15]=t.width2,C.HEAP32[a/4+16]=t.height0,C.HEAP32[a/4+17]=t.height1,C.HEAP32[a/4+18]=t.height2,C.HEAP32[a/4+19]=0,C.HEAPU8[a+80]=t.nColorPrimaries,C.HEAPU8[a+81]=t.nColorTransfer,C.HEAPU8[a+82]=t.nColorSpace,C.HEAPU8[a+83]=t.bColorFull;var p=0,d=0;if(0!==n&&null!=n){p=C._malloc(16),C.HEAP32[p/4+0]=n.left,C.HEAP32[p/4+1]=n.top,C.HEAP32[p/4+2]=n.right,C.HEAP32[p/4+3]=n.bottom}if(0!==r&&null!=r){d=C._malloc(16),C.HEAP32[d/4+0]=r.left,C.HEAP32[d/4+1]=r.top,C.HEAP32[d/4+2]=r.right,C.HEAP32[d/4+3]=r.bottom}o=C._RENDER_DrawImage(e,a,p,d),9!=t.ImageFormat&&(C._free(l),C._free(c),C._free(f)),C._free(a),0!==p&&C._free(p),0!==d&&C._free(d)}(f,e.buffer.Image,ye,null),b&&ue(E,e.buffer.stuFrameInfo.nFrameID),delete e.buffer,e.buffer=null,e.previous=null,e.next=null,e=null,pe&&!de&&(0==B(f,1,!0)&&0==function(e,t){var n=C._malloc(20),r=null;null!==t.PanoARCustomParams&&(r=C._malloc(12),C.HEAPF32[r/4+0]=t.PanoARCustomParams.VerFieldViewAngle,C.HEAPF32[r/4+1]=t.PanoARCustomParams.HoriFieldViewAngle,C.HEAPF32[r/4+2]=t.PanoARCustomParams.DownPressAngle),C.HEAP32[n/4+0]=t.PanoARMode,C.HEAP32[n/4+1]=t.ImageStride,C.HEAP32[n/4+2]=t.ImageWidth,C.HEAP32[n/4+3]=t.ImageHeight,C.HEAP32[n/4+4]=r;var o=C._RENDER_SetAlgoParams(e,n);return C._free(n),null!==r&&C._free(r),o}(f,me)?a.log("[Trace]RENDER_AlgoCommand and RENDER_SetAlgoParams success!"):a.log("[Error]RENDER_AlgoCommand or RENDER_SetAlgoParams failed!"),de=!0),function(e){C._RENDER_Present(e)}(f),!0}return!1;var r,o},Re=function(e){if(!Te)if(s){var t=40;if(h&&g&&0!==g.size)0===d&&(d=e),_=(n=e-d)-m,a.log("drawingInTime, timestamp:"+e+", m_nPreTimestamp:"+d+", nDifTimestamp:"+n),null!==(r=g.dequeue())&&null!==r.buffer&&null!==r.buffer.Image.DataY&&(t=r.buffer.nCostTime-_,Me(r),ve&&0===g.size&&(a.trace("PlayMethod StreamPlayOverCallback"),Ae()));m=t,d=e,t<0&&(t=0),a.log("drawingInTime, nCostTime:"+t+", m_nPreCostTime:"+m+", m_nDifferenceTime:"+_),setTimeout((function(){Re(Date.now())}),t)}else{if(h&&g&&0!==g.size){if(!Ee&&(0===p||e-p<he)){if(0===p&&(p=e),!S)null!==(r=g.dequeue())&&null!==r.buffer&&null!==r.buffer.dataY&&(S=!0,Me(r));return void window.requestAnimationFrame(Re)}var n,r;if(0===d&&(d=e),(n=e-d)>=y)null!==(r=g.dequeue())&&null!==r.buffer&&null!==r.buffer.Image.DataY&&(v&&(_=n-y),y=r.buffer.nCostTime,a.log("timestamp:"+e+"-m_nPreTimestamp:"+d+"-nDifTimestamp:"+n+"--m_nDifferenceTime:"+_+"--m_nNextPlayTime:"+y+"--videoDataQueue.size:"+g.size),y-=_,Me(r),d=e,v=!0)}window.requestAnimationFrame(Re)}};return Ce.prototype={draw:function(e,t,n,r,o){if(null!==g)if(document.hidden&&g.size>=25)g.clear();else{var a={};a.Image=Ee?{DataY:e}:{ImageFormat:0,DataY:e,DataU:t,DataV:n,width0:w,width1:w/2,width2:w/2,height0:A,height1:A/2,height2:A/2,nColorPrimaries:r.nColorPrimaries,nColorTransfer:r.nColorTransfer,nColorSpace:r.nColorSpace,bColorFull:r.bColorFull},a.stuFrameInfo=r,0==o&&(o=25);var i=1e3/o,u=g.size*i;s||(P=u>_e?1.2:u<ge?.8:1,Ee&&l.SetMSEPlaySpeed(P)),a.nCostTime=1e3/o/P,!s&&a.nCostTime<20&&(a.nCostTime=20),g.enqueue(a)}},drawWebCodecs:function(e,t,n,r,o,a){if(h){if(D)return(i={}).Image={ImageFormat:9,DataY:e,DataU:0,DataV:0,width0:r,width1:0,width2:0,height0:o,height1:0,height2:0,nColorPrimaries:Ie(a),nColorTransfer:De(a),nColorSpace:ke(a),bColorFull:a.fullRange},i.stuFrameInfo={},i.stuFrameInfo.nFrameID=t,void Me(new ce(i));if(null!==g)if(document.hidden&&g.size>=25)g.clear();else{var i;(i={}).Image={ImageFormat:9,DataY:e,DataU:0,DataV:0,width0:r,width1:0,width2:0,height0:o,height1:0,height2:0,nColorPrimaries:Ie(a),nColorTransfer:De(a),nColorSpace:ke(a),bColorFull:a.fullRange},i.stuFrameInfo={},i.stuFrameInfo.nFrameID=t,0==n&&(n=25);var l=1e3/n,u=g.size*l;s||(P=u>_e?1.2:u<ge?.8:1),i.nCostTime=1e3/n/P,i.nCostTime<20&&(i.nCostTime=20),g.enqueue(i)}}},resize:function(e,t){(this.stopRendering(),null!==g&&(g.clear(),g=null),null!==f)&&(0===x(f)&&window.nSWDecodeNum--,f=null);if(c&&null===f){if(!function(){if(window.nSWDecodeNum>=10)return a.warn("Insufficient webGL resources."),Pe&&Pe({errorCode:100,description:"Insufficient webGL resources."}),!1;return!0}())return;(f=function(e){var t=(C=window.REModule)._malloc(12),n=C.allocateUTF8(e);C.HEAP32[t/4+0]=12,C.HEAP32[t/4+1]=n,C.HEAP32[t/4+2]=0;var r=C._RENDER_Create(t);return C._free(n),C._free(t),r}(c.id))&&window.nSWDecodeNum++}g=new I(u),this.startRendering(),w=e,A=t},initStartTime:function(){0===p&&this.startRendering()},startRendering:function(){Te=!1,0===p&&(h=!0,s?setTimeout((function(){Re(Date.now())}),0):window.requestAnimationFrame(Re))},pause:function(e){h=!e,a.log("Play method pause, isRendering:"+h)},play:function(){h=!0},stopRendering:function(){h=!1,p=0},setPlaySpeed:function(e){P=e},getPlaySpeed:function(){return P},setEncodeType:function(e){M=e},SetBeginDrawCallback:function(e){fe=e},terminate:function(){(h=!1,p=0,se=!1,null!==g&&(g.clear(),g=null),null!==f)&&(0===x(f)&&window.nSWDecodeNum--,f=null);k=-1,Se=-1,Te=!0},GetVideoBufferSize:function(){return null!==g?g.size:0},OpenIVS:function(e,t){(function(e){(O=window.IVSModule)._DRAW_Open(e)})(E=e),function(e,t){var n=O.allocateUTF8(t);O._DRAW_SetWebCanvas(e,n),O._free(n)}(E,t),le(T),b=!0},CloseIVS:function(){var e;b&&(b=!1,e=E,O._DRAW_Clean(e),function(e){O._DRAW_Close(e)}(E))},SetIvsEnable:function(e,t){b&&function(e,t,n){O._DRAW_SetEnable(e,t,n)}(E,e,t)},IVSSetViewProportion:function(e,t){b&&function(e,t,n){O._DRAW_SetViewProportion(e,t,n)}(E,e,t)},IVSIoctl:function(e,t){b&&function(e,t,n){var r=-1;if((ae===t||ie===t)&&void 0!==n.nX&&void 0!==n.nY){var o=O._malloc(128);if(H(O,o,0,n.nX),H(O,o,4,n.nY),0===(r=O._DRAW_Ioctl(e,t,o,128))){var a=new ArrayBuffer(128),i=new Uint8Array(a),l=new DataView(a);i.set(O.HEAPU8.subarray(o,o+128)),n.nObjectID=l.getInt32(0,!0),n.nClassID=l.getInt32(112,!0),n.nObjectType=l.getUint8(116,!0)}O._free(o)}}(E,e,t)},IVSGeneralConfig:function(e,t){b&&function(e,t,n){var r=-1;if(q===t){var o=O._malloc(276);F(O,o,0,276),F(O,o,4,n.cfgFlag),F(O,o,8,n.ruleType),void 0!==n.ruleName&&n.ruleName<=128&&O.writeArrayToMemory(n.ruleName,o+12),R(O,o,140,n.lineDisable),R(O,o,141,n.cfgReset),0===n.lineDisable&&void 0!==n.lineAttr&&(F(O,o,144,n.lineAttr.attrFlag),L(O,o,148,n.lineAttr.lineColor.cgred),L(O,o,152,n.lineAttr.lineColor.cggreen),L(O,o,156,n.lineAttr.lineColor.cgblue),H(O,o,160,n.lineAttr.lineWidth),H(O,o,164,n.lineAttr.lineStyle),H(O,o,168,n.lineAttr.boxStyle),R(O,o,172,n.lineAttr.boxTail),R(O,o,173,n.lineAttr.hideTail),R(O,o,174,n.lineAttr.fillTransparency)),F(O,o,188,n.textAttrScope),R(O,o,192,n.textDisable),R(O,o,193,n.textDrawOnLine),0===n.textDisable&&void 0!==n.textAttr&&(F(O,o,196,n.textAttr.attrFlag),L(O,o,200,n.textAttr.textColor.cgred),L(O,o,204,n.textAttr.textColor.cggreen),L(O,o,208,n.textAttr.textColor.cgblue),R(O,o,212,n.textAttr.textFont.fontSize),R(O,o,216,n.textAttr.textPos.posFlag),R(O,o,217,n.textAttr.textPos.refPos),H(O,o,220,n.textAttr.textPos.absPos.x),H(O,o,224,n.textAttr.textPos.absPos.y)),r=O._DRAW_IVSGeneralConfig(e,t,o,276),O._free(o)}else if(X===t||J===t){var a=O._malloc(152);F(O,a,0,152),F(O,a,4,n.cfgFlag),F(O,a,8,n.objID),U(O,a,12,n.objClass),U(O,a,14,n.objType),R(O,a,16,n.lineDisable),R(O,a,17,n.cfgReset),R(O,a,18,n.algorithmID),R(O,a,19,n.adaptionID),0===n.lineDisable&&void 0!==n.lineAttr&&(F(O,a,20,n.lineAttr.attrFlag),L(O,a,24,n.lineAttr.lineColor.cgred),L(O,a,28,n.lineAttr.lineColor.cggreen),L(O,a,32,n.lineAttr.lineColor.cgblue),H(O,a,36,n.lineAttr.lineWidth),H(O,a,40,n.lineAttr.lineStyle),H(O,a,44,n.lineAttr.boxStyle),R(O,a,48,n.lineAttr.boxTail),R(O,a,49,n.lineAttr.hideTail),R(O,a,50,n.lineAttr.fillTransparency)),0===n.textDisable&&void 0!==n.textAttr&&(F(O,a,64,n.textAttr.attrFlag),L(O,a,68,n.textAttr.textColor.cgred),L(O,a,72,n.textAttr.textColor.cggreen),L(O,a,76,n.textAttr.textColor.cgblue),R(O,a,80,n.textAttr.textFont.fontSize),R(O,a,84,n.textAttr.textPos.posFlag),R(O,a,85,n.textAttr.textPos.refPos),H(O,a,88,n.textAttr.textPos.absPos.x),H(O,a,92,n.textAttr.textPos.absPos.y)),F(O,a,112,n.textSwitchOn),F(O,a,116,n.textSwitch),r=O._DRAW_IVSGeneralConfig(e,t,a,152),O._free(a)}else r=-1}(E,e,t)},SetIvsIotBoxParas:function(e,t,n){b&&function(e,t,n,r){var o=O._malloc(48),a=new DataView(O.HEAPU8.buffer);O.HEAPU8[o]=t?1:0;for(var i=O._malloc(n.length+1),l=0;l<n.length;l++)O.HEAPU8[i+l]=n.charCodeAt(l);O.HEAPU8[i+n.length]=0,a.setUint32(o+4,i,!0),O.HEAPU8[o+12]=r;var u=O._DRAW_IVSGeneralConfig(e,Z,o,1);O._free(i),O._free(o)}(E,e,t,n)},SetIvsIotBoxDisplay:function(e,t,n){b&&function(e,t,n,r){var o=O._malloc(44),a=new DataView(O.HEAPU8.buffer);O.HEAPU8[o]=1;var i=O._malloc(8);a.setInt32(i,t,!0),a.setInt32(i+4,n,!0),t<0||n<0?a.setUint32(o+4,0,!0):a.setUint32(o+4,i,!0),-1==r?a.setUint32(o+8,1,!0):(a.setUint32(o+8,0,!0),a.setUint8(o+9,r,!0));var l=O._DRAW_IVSGeneralConfig(e,ee,o,1);O._free(i),O._free(o)}(E,e,t,n)},SetIvsLanguageEnvi:function(e){T=e,b&&le(e)},CleanScreen:function(e,t,n,r){null!=f&&(g.clear(),function(e,t,n,r,o){var a=C._malloc(16);C.HEAP32[a/4+0]=t,C.HEAP32[a/4+1]=n,C.HEAP32[a/4+2]=r,C.HEAP32[a/4+3]=o;var i=C._RENDER_ClearScreen(e,a);C._free(a)}(f,e,t,n,r))},DrawIVS:function(e,t,n,r){if(b){var o=function(e){var t=0,n=0;switch(e){case W:t=$,n=1;break;case z:t=Q,n=1}return{bDeal:n,nIvsDrawType:t}}(t),a=o.bDeal,i=o.nIvsDrawType;if(a)!function(e,t,n,r,o){var a=O._malloc(r);O.writeArrayToMemory(n,a);var i=O._DRAW_InputIVSData(e,t,a,r,o);O._free(a)}(E,i,e,n,r);else switch(t){case V:!function(e,t,n,r){var o=O._malloc(n);O.writeArrayToMemory(t,o);var a=O._DRAW_InputJsonData(e,o,n,r);O._free(o)}(E,e,n,r);break;case G:!function(e,t,n,r,o){var a=O._malloc(r);O.writeArrayToMemory(n,a);var i=O._DRAW_InputTrackData(e,t,a,r,o);O._free(a)}(E,0,e,n,r);break;case N:case j:case Y:case K:!function(e,t,n,r,o){var a=!1,i=O._malloc(r);if(j==t){var l=0,u=new Array(512);O.HEAPU16[i/2+0]=n.NumberStat,O.HEAPU16[i/2+1]=n.nIntelFlowPlanNum;for(var c=O._malloc(12*n.nIntelFlowPlanNum),s=c,f=0;f<n.nIntelFlowPlanNum;f++){O.HEAPU16[s/2+0]=n.pIntelFlowPlan[f].PlanId,O.HEAPU16[s/2+1]=n.pIntelFlowPlan[f].RuleType,O.HEAPU16[s/2+4]=n.pIntelFlowPlan[f].RegionNum,u[l]=O._malloc(12*n.pIntelFlowPlan[f].RegionNum);for(var p=u[l],d=0;d<n.pIntelFlowPlan[f].RegionNum;d++)O.HEAPU16[p/2+0]=n.pIntelFlowPlan[f].pRegion[d].RegionId,O.HEAPU16[p/2+1]=n.pIntelFlowPlan[f].pRegion[d].State,O.HEAP32[p/4+1]=n.pIntelFlowPlan[f].pRegion[d].PeopleNum,p+=12;if(O.HEAP32[s/4+1]=u[l],++l>=512)break;s+=12}O.HEAP32[i/4+1]=c,a=O._DRAW_InputTrackDataEx2(e,t,i,r,o);for(var m=0;m<l;m++)O._free(u[l]);O._free(c)}else if(K==t){O.HEAP32[i/4+0]=n.nId,O.HEAP16[i/2+2]=n.wCustom,O.HEAPU8[i+6]=n.chState,O.HEAPU8[i+7]=n.chCount;for(var h=O._malloc(12*n.chCount),g=h,_=new Array(n.chCount),y=new Array(n.chCount),S=new Array(n.chCount),v=0;v<n.chCount;v++){if(O.HEAP32[g/4+0]=n.pElement[v].nStructType,O.HEAP32[g/4+1]=n.pElement[v].nStructLength,S[v]=O._malloc(n.pElement[v].nStructLength),te==n.pElement[v].nStructType)O.HEAPU8[S[v]+0]=n.pElement[v].pStruct.chType,O.HEAPU8[S[v]+1]=n.pElement[v].pStruct.chWidth,O.HEAPU8[S[v]+2]=n.pElement[v].pStruct.chStyle,O.HEAP16[S[v]/2+2]=n.pElement[v].pStruct.wRadius,O.HEAP16[S[v]/2+4]=n.pElement[v].pStruct.positionCircle.x,O.HEAP16[S[v]/2+5]=n.pElement[v].pStruct.positionCircle.y,O.HEAPU8[S[v]+12]=n.pElement[v].pStruct.chLineA,O.HEAPU8[S[v]+13]=n.pElement[v].pStruct.chLineR,O.HEAPU8[S[v]+14]=n.pElement[v].pStruct.chLineG,O.HEAPU8[S[v]+15]=n.pElement[v].pStruct.chLineB,O.HEAPU8[S[v]+16]=n.pElement[v].pStruct.chRegA,O.HEAPU8[S[v]+17]=n.pElement[v].pStruct.chRegR,O.HEAPU8[S[v]+18]=n.pElement[v].pStruct.chRegG,O.HEAPU8[S[v]+19]=n.pElement[v].pStruct.chRegB;else if(ne==n.pElement[v].nStructType){if(O.HEAPU8[S[v]+0]=n.pElement[v].pStruct.chType,O.HEAPU8[S[v]+1]=n.pElement[v].pStruct.chCount,O.HEAPU8[S[v]+2]=n.pElement[v].pStruct.chWidth,O.HEAPU8[S[v]+3]=n.pElement[v].pStruct.chStyle,O.HEAPU8[S[v]+4]=n.pElement[v].pStruct.chLineA,O.HEAPU8[S[v]+5]=n.pElement[v].pStruct.chLineR,O.HEAPU8[S[v]+6]=n.pElement[v].pStruct.chLineG,O.HEAPU8[S[v]+7]=n.pElement[v].pStruct.chLineB,n.pElement[v].pStruct.chCount>0){_[v]=O._malloc(4*n.pElement[v].pStruct.chCount);for(var P=0;P<n.pElement[v].pStruct.chCount;P++)O.HEAPU16[_[v]/2+2*P]=n.pElement[v].pStruct.pPoints[P].x,O.HEAPU16[_[v]/2+2*P+1]=n.pElement[v].pStruct.pPoints[P].y;O.HEAPU32[S[v]/4+2]=_[v]}}else if(re==n.pElement[v].nStructType){if(O.HEAPU8[S[v]+0]=n.pElement[v].pStruct.chType,O.HEAPU8[S[v]+1]=n.pElement[v].pStruct.chCount,O.HEAPU8[S[v]+2]=n.pElement[v].pStruct.chWidth,O.HEAPU8[S[v]+3]=n.pElement[v].pStruct.chStyle,O.HEAPU8[S[v]+4]=n.pElement[v].pStruct.chLineA,O.HEAPU8[S[v]+5]=n.pElement[v].pStruct.chLineR,O.HEAPU8[S[v]+6]=n.pElement[v].pStruct.chLineG,O.HEAPU8[S[v]+7]=n.pElement[v].pStruct.chLineB,O.HEAPU8[S[v]+8]=n.pElement[v].pStruct.chRegA,O.HEAPU8[S[v]+9]=n.pElement[v].pStruct.chRegR,O.HEAPU8[S[v]+10]=n.pElement[v].pStruct.chRegG,O.HEAPU8[S[v]+11]=n.pElement[v].pStruct.chRegB,n.pElement[v].pStruct.chCount>0){_[v]=O._malloc(4*n.pElement[v].pStruct.chCount);for(P=0;P<n.pElement[v].pStruct.chCount;P++)O.HEAPU16[_[v]/2+2*P]=n.pElement[v].pStruct.pPoints[P].x,O.HEAPU16[_[v]/2+2*P+1]=n.pElement[v].pStruct.pPoints[P].y;O.HEAPU32[S[v]/4+3]=_[v]}}else oe==n.pElement[v].nStructType&&(O.HEAPU8[S[v]+0]=n.pElement[v].pStruct.chType,O.HEAPU8[S[v]+1]=n.pElement[v].pStruct.chCharset,O.HEAPU16[S[v]/2+2]=n.pElement[v].pStruct.stringPos.x,O.HEAPU16[S[v]/2+3]=n.pElement[v].pStruct.stringPos.y,O.HEAPU8[S[v]+8]=n.pElement[v].pStruct.chLineA,O.HEAPU8[S[v]+9]=n.pElement[v].pStruct.chLineR,O.HEAPU8[S[v]+10]=n.pElement[v].pStruct.chLineG,O.HEAPU8[S[v]+11]=n.pElement[v].pStruct.chLineB,O.HEAPU8[S[v]+12]=n.pElement[v].pStruct.chFontSize,O.HEAPU8[S[v]+13]=n.pElement[v].pStruct.chFontAlign,O.HEAPU16[S[v]/2+7]=n.pElement[v].pStruct.wTxtLen,n.pElement[v].pStruct.wTxtLen>0&&(y[v]=O._malloc(n.pElement[v].pStruct.wTxtLen),O.writeArrayToMemory(n.pElement[v].pStruct.stringDataArray,y[v]),O.HEAPU32[S[v]/4+4]=y[v]));O.HEAP32[g/4+2]=S[v],g+=12}if(O.HEAP32[i/4+2]=h,O.HEAP16[i/2+6]=n.wInfoLen,n.wInfoLen>0){var b=O._malloc(n.wInfoLen);O.writeArrayToMemory(n.pInfo,b),O.HEAP32[i/4+4]=b}a=O._DRAW_InputTrackDataEx2(e,t,i,r,o);for(v=0;v<n.chCount;v++)te==n.pElement[v].nStructType||(ne==n.pElement[v].nStructType||re==n.pElement[v].nStructType?n.pElement[v].pStruct.chCount>0&&O._free(_[v]):oe==n.pElement[v].nStructType&&n.pElement[v].pStruct.wTxtLen>0&&O._free(y[v])),O._free(S[v]);O._free(h),n.wInfoLen>0&&O._free(InfoPtr)}else O.writeArrayToMemory(n,i),a=O._DRAW_InputTrackDataEx2(e,t,i,r,o);O._free(i)}(E,t,e,n,r)}}},SetLifeCount:function(e){b&&function(e,t){O._DRAW_SetLifeCount(e,2,t)}(E,e)},DrawDrawIVS:function(e){b&&ue(E,e)},SetPanoVRMode:function(e,t,n,r){return 0===e?B(f,1,!1):(pe=!0,de=!1,me={PanoARMode:e,ImageStride:n,ImageWidth:n,ImageHeight:r,PanoARCustomParams:t}),!0},GetModelRotate:function(){return function(e){var t=C._malloc(4),n=C._malloc(4),r=C._malloc(4);C._RENDER_3DGetModelRotate(e,t,n,r);var o=C.HEAPF32[t/4],a=C.HEAPF32[n/4],i=C.HEAPF32[r/4];return C._free(t),C._free(n),C._free(r),{x:o,y:a,z:i}}(f)},SetModelRotate:function(e,t,n){return function(e,t,n,r){return C._RENDER_3DSetModelRotate(e,t,n,r)}(f,e,t,n)},SetStereoPerspectiveFovy:function(e){return function(e,t){return C._RENDER_3DSetPerspectiveFovy(e,t)}(f,e)},GetVRCoord2DTrans:function(e,t){return function(e,t,n){var r=C._malloc(4),o=C._malloc(4);C._RENDER_GetPanoARCoord2DTrans(e,t,n,r,o);var a=C.HEAPF32[r/4],i=C.HEAPF32[o/4];return C._free(r),C._free(o),{x:a,y:i}}(f,e,t)},GetVRCoord3DTrans:function(e,t){return function(e,t,n){var r=C._malloc(4),o=C._malloc(4);C._RENDER_GetPanoARCoord3DTrans(e,t,n,r,o);var a=C.HEAP32[r/4],i=C.HEAP32[o/4];return C._free(r),C._free(o),{x:a,y:i}}(f,e,t)},ResetPlayState:function(){se=!1},GetCurrentFrameID:function(){return k},SetPrintLogLevel:function(e){!function(e){void 0!==window.REModule&&(C=window.REModule)._RENDER_SetPrintLogLevel(e)}(e),function(e){void 0!==window.IVSModule&&(O=window.IVSModule)._DRAW_SetPrintLogLevel(e)}(e)},SetPlayMethod:function(e,t,n){he=e,ge=t,_e=n,a.log("SetPlayMethod, m_nStartTime:"+he+", m_nSlowTime:"+ge+", m_nFastTime:"+_e)},SetColor:function(e,t,n,r){return function(e,t,n,r,o){C._RENDER_ColorAdjust(e,4*t-256,2*n,r,45*o/16-180)}(f,e,t,n,r)},SetDisplayRegion:function(e,t){ye=t?e:null},SetRotateType:function(e){Se=e},SetErrorCallback:function(e){Pe=e},SetDecodeMode:function(e){Ee=e},SetVideoFrameInfoCallback:function(e){be=e},SetSTFrameCallback:function(e){we=e},SetStreamOverCallback:function(e){Ae=e},SetStreamOver:function(e){a.trace("PlayMethod SetStreamOver, bOver:"+e),ve=e}},new Ce};var fe=function(){var e=null,t=null,n=null,r=0,o=0,a=!1,i=0,l=null,u=!1,c=new Float32Array(8e4),s=0,f=null,p=!1,d=0,m=0,h=null,g=!1,_=!1,y=2,S=!1,v=null,P=!1,b=0,w=1;function A(t){if(p){o-e.currentTime<0&&(o=0);var r=null,a=new Int16Array(t.buffer,t.byteOffset,t.byteLength/Int16Array.BYTES_PER_ELEMENT),i=null;if(1==w){for(var u=new Float32Array(a.length),g=0;g<a.length;g++)u[g]=a[g]/Math.pow(2,15);c=function(e,t,n){var r=e;n+t.length>=r.length&&(r=new Float32Array(r.length+8e4)).set(r,0);return r.set(t,n),r}(c,u,s);var _=0;if((s+=u.length)/u.length>1&&(null!==l&&(_=l*d),_>=s||null===l))return void(s=0);(r=e.createBuffer(w,s-_,d)).getChannelData(0).set(c.subarray(_,s)),i=u}else if(2==w){for(var y=a.length/2,S=new Float32Array(y),v=new Float32Array(y),P=0;P<y;P++)16===m?(S[P]=a[2*P]/32768,v[P]=a[2*P+1]/32768):(S[P]=(a[2*P]-128)/128,v[P]=(a[2*P+1]-128)/128);(r=e.createBuffer(w,S.length,d)).getChannelData(0).set(S),r.getChannelData(1).set(v),i=S}h&&h.InputPlayData(i),s=0,f=null,(f=e.createBufferSource()).buffer=r,f.connect(n),o||(o=e.currentTime+.01),f.start(o),o+=r.duration,b+=r.duration}else o=0}function E(){}return E.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({sampleRate:d})).onstatechange=function(){if(e&&"running"===e.state){if(_)for(;null!==v&&v.size>0;){A(v.dequeue().buffer)}a=!0}},v=new I(500),t=e.createGain(),(n=e.createBiquadFilter()).connect(t),n.type="lowshelf",n.frequency.value=500,n.gain.value=-5,t.connect(e.destination),this.setVolume(r),!0}catch(e){return!1}},play:function(){this.setVolume(r)},pause:function(t){t?e&&"running"===e.state&&e.suspend():e&&"suspended"===e.state&&e.resume()},stop:function(){r=0,t&&(t.gain.value=0),o=0,e=null},bufferAudio:function(t,n){if(void 0!==n.nAudioChnNum&&(w=n.nAudioChnNum),(!_||g)&&null!==e){var i=o-e.currentTime;(g&&i>y||i>10)&&(this.terminate(),this.audioInit(r))}if(!P&&!_&&null!==v&&v.size<31)v.enqueue(t);else if(a){for(;null!==v&&v.size>0;){A(v.dequeue().buffer)}A(t)}else null!==v&&v.size<500&&v.enqueue(t)},setSoundState:function(e){p=e},setVolume:function(e){r=e;var n=e/1;t&&(n<=0?(t.gain.value=0,o=0):t.gain.value=n>=1?1:n)},setPureAudioFlag:function(e){_=e},setTalkFlag:function(e){g=e},setVideoStartPlay:function(e){P=e},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(){s=0,o=0,a=!1,_=!1,b=0,w=1,e&&"closed"!==e.state&&(f=null,n=null,t=null,e.close(),e=null),null!==v&&(v.clear(),v=null)},setBufferingFlag:function(e,t){"init"===t?i=e:u&&(0===e||null==e?l=null:(l=e-i,i=0),u=!1)},getBufferingFlag:function(){return u},setInitVideoTimeStamp:function(e){i=e},getInitVideoTimeStamp:function(){return i},setSampleBits:function(e,t){d!==e&&(d=e,this.terminate(),this.audioInit(r)),m=t,h&&h.SetPlayParam(d,m)},getAudioBufTime:function(){if(null!==e){var t=o-e.currentTime;return t>0?t*=1e3:t=0,t}return 0},getAudioPlayedTime:function(){return null!==e?e.currentTime>b?b:e.currentTime:-1},setAudioProcesser:function(e){(h=e)&&h.SetPlayParam(d,m)},setFrameRate:function(e){!S&&e<5&&e>0&&(y=2e3/e/1e3)},SetAudioPlayMethod:function(e){S=!0,y=e}},new E};var pe=function(e){e=e;var t=null,n="",r=null,o=null,a=null,i=null,l=null,u=null,c=null,s=null,f=1,p={timestamp:0,timestamp_usec:0,timezone:0},d={timestamp:0,timestamp_usec:0,timezone:0},m=null,h=!1,g=null,_=null,y=null,S=!1,v=!0,P=0,b=!1,w=[],E=.5,T=null,I=null,D=null,k=0,C=0,M=!1,R=null,U="png",H=1,F=A(),L=null,x=0,O=0,B=0,V=null,G=!1,N=!1,W=[],z={},j=25,Y=.5,K=!1,q=!1;function X(){}function J(){Q(),q=!0}function $(){var e=0;if(null!==g)for(e=0;e<g.length;e++)D.updating||D.removeEventListener(g[e].type,g[e].function);if(null!==y)for(e=0;e<y.length;e++)I.removeEventListener(y[e].type,y[e].function);if(null!==_)for(e=0;e<_.length;e++)T.removeEventListener(_[e].type,_[e].function)}function Q(){if(null===I||"ended"===I.readyState)return function(e){(y=[]).push({type:"sourceopen",function:J}),y.push({type:"error",function:ae});for(var t=0;t<y.length;t++)e.addEventListener(y[t].type,y[t].function)}(I=new MediaSource),T.src=window.URL.createObjectURL(I),e.trace("videoMediaSource::appendInitSegment new MediaSource()"),!1;if(e.trace("videoMediaSource::appendInitSegment start"),0===I.sourceBuffers.length){I.duration=0;var r='video/mp4; codecs="'+n+'"';if(0==n.length)return!1;if(!MediaSource.isTypeSupported(r))return e.trace("not support"+r),V&&V({errorCode:101}),c&&c("InitError"),!1;!function(e){(g=[]).push({type:"error",function:ie}),g.push({type:"updateend",function:re}),g.push({type:"update",function:oe});for(var t=0;t<g.length;t++)e.updating||e.addEventListener(g[t].type,g[t].function)}(D=I.addSourceBuffer(r))}var o=t();return null===o?(I.endOfStream("network"),!1):(D.updating||0!==w.length?w.push(o):D.appendBuffer(o),e.trace("videoMediaSource::appendInitSegment end, codecInfo = "+n),!0)}function Z(){T.paused&&(a(),S||G||T.play())}function ee(){T.paused||v||(e.log("pause"),T.pause())}function te(){W.length&&function(t){if(!K&&q&&(K=Q()),null!==D&&"closed"!==I.readyState&&"ended"!==I.readyState)try{if(w.length>0)return e.trace("segmentWaitDecode.length: "+w.length),void w.push(t);D.updating?(e.trace("updating.........."),w.push(t)):(D.appendBuffer(t),G&&(z.buffer=t))}catch(t){e.trace("videoMediaSource::appendNextMediaSegment error >> initVideo"),w.length=0,V&&V({errorCode:102})}}(W.shift())}function ne(){if(null!==I)try{if(D&&D.buffered.length>0){if(function(){var e=1*D.buffered.start(D.buffered.length-1),t=1*D.buffered.end(D.buffered.length-1);t-e>60&&D.remove(e,t-10)}(),N&&!G||T.duration>Y&&(T.currentTime=(T.duration-Y).toFixed(3),Y+=j<10?.5:.1),T&&T.duration-T.currentTime>8){if(V&&V({errorCode:103}),D.updating)return;var t=T.duration-.1;T.currentTime=t.toFixed(3)}if(b&&!h){var n=1*D.buffered.start(D.buffered.length-1),r=1*D.buffered.end(D.buffered.length-1);if((0===T.currentTime?r-n:r-T.currentTime)>=Y+.2){if(e.log("跳秒"),D.updating)return;var o=r-.1;T.currentTime=o.toFixed(3)}}}}catch(t){e.error("sourceBuffer has been removed")}}function re(){w.length>0&&D&&!D.updating&&(D.appendBuffer(w[0]),w.shift())}function oe(){}function ae(){console.log("videoMediaSource::onSourceError"),c&&c("SourceError")}function ie(){console.log("videoMediaSource::onSourceBufferErrormsg"),c&&c("SourceBufferError")}function le(){console.log("videoMediaSource::onError"),ee(),V&&V({errorCode:104}),c&&c("Error")}function ue(){if(S=!0,v=!1,N=!0,!M){e.trace("HW Play Start."),M=!0;var t={decodeMode:"video"};t.width=T.videoWidth,t.height=T.videoHeight,1==r?t.encodeMode="H264":2==r&&(t.encodeMode="H265"),l&&l(t)}}function ce(){S=!1,v=!0,e.trace("硬解码暂停播放")}function se(){var e=parseInt(I.duration,10),t=parseInt(T.currentTime,10),n={timestamp:p.timestamp-f*(e-t+(1!==f?1:0)),timestamp_usec:0,timezone:p.timezone};0===t||isNaN(e)||!h&&Math.abs(e-t)>4&&1===f||T.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!=D&&ne()}function pe(){a()}function de(){Z()}function me(){if(e.log("需要缓冲下一帧"),b=!1,0==C)k=Date.now(),C++;else{C++;var t=Date.now()-k;e.log("diffTime: "+t+" Count: "+C),C>=5&&t<6e4&&E<=1&&(E+=.1,C=0,k=0,e.log("delay + 0.1 = "+E))}}function he(){e.trace("Can play !")}function ge(){e.trace("Can play without waiting"),b=!0}function _e(){e.trace("loadedmetadata")}function ye(e,t){var n=document.createElement("canvas");n.width=T.videoWidth,n.height=T.videoHeight;var r=n.getContext("2d");r.drawImage(T,0,0,n.width,n.height);for(var o=0;o<e.length;o++)e[o]&&r.drawImage(e[o],0,0,n.width,n.height);for(var a=n.toDataURL(),i=atob(a.substring("data:image/jpg;base64,".length)),l=new Uint8Array(i.length),c=0,s=i.length;c<s;++c)l[c]=i.charCodeAt(c);u&&u(l);var f=new Blob([l.buffer],{type:"image/jpg"});Me(f,t),f=null}X.prototype={init:function(t){s=A(),e.trace("videoMediaSource::init browserType = "+s),(T=t).autoplay="safari"!==s,T.controls=!1,T.preload="auto",function(e){(_=[]).push({type:"durationchange",function:fe}),_.push({type:"playing",function:ue}),_.push({type:"error",function:le}),_.push({type:"pause",function:ce}),_.push({type:"timeupdate",function:se}),_.push({type:"resize",function:pe}),_.push({type:"seeked",function:de}),_.push({type:"waiting",function:me}),_.push({type:"canplaythrough",function:ge}),_.push({type:"canplay",function:he}),_.push({type:"loadedmetadata",function:_e});for(var t=0;t<_.length;t++)e.addEventListener(_[t].type,_[t].function)}(T),Q()},setInitSegmentFunc:function(e){t=e},getVideoElement:function(){return T},setCodecInfo:function(e){n=e},setMediaSegment:function(e){W.push(e),G||te()},capturePic:function(e,t){R&&clearInterval(R),b||"edge"===F?ye(e,t):R=setInterval((function(){b&&(ye(e,t),clearInterval(R))}),200)},getCapture:function(e,t,n){R&&clearInterval(R),H=n||1,U="png","jpg"!==t&&"jpeg"!==t||(U="jpeg");var r=document.createElement("canvas"),o=null;return r.width=T.videoWidth,r.height=T.videoHeight,(b||"edge"===F||b)&&(r.getContext("2d").drawImage(T,0,0,r.width,r.height),o=r.toDataURL("image/"+U,H)),o},setInitSegment:function(){Q()},ResetInitSegmentFlag:function(){K=!1},setTimeStamp:function(e,t){o=e},setVideoSizeCallback:function(e){a=e},setAudioStartCallback:function(e){i=e},setMseErrorCallback:function(e){c=e},getPlaybackTimeStamp:function(){return o},setPlaySpeed:function(e){f!=e&&(f=e,T.playbackRate=e)},setvideoTimeStamp:function(e){var t=Math.abs(p.timestamp-e.timestamp)>3;d.timestamp,!0===t&&(P=0,i((d=e).timestamp,"init"),0!==p.timestamp&&h&&(T.currentTime=I.duration-.1),m=null),p=e},pause:function(e){G=e,e?ee():Z()},play:function(){G=!1},setPlaybackFlag:function(e){h=e},setTimeStampInit:function(){m=null,d={timestamp:0,timestamp_usec:0,timezone:0}},close:function(){$(),ee()},setBeginDrawCallback:function(e){l=e},setCapturePicDataCallBack:function(e){u=e},setErrorCallback:function(e){V=e},terminate:function(){null!==T&&($(),"open"===I.readyState&&(D&&I.removeSourceBuffer(D),I.endOfStream()),D=null,I=null,T=null,R&&(clearInterval(R),R=null),L&&(clearInterval(L),L=null),B=0,O=0,x=0,K=!1,q=!1,M=!1)},getDuration:function(){return T.duration-T.currentTime},setFPS:function(e){e&&(j=e)},setRtspOver:function(){T.duration.toFixed(4)-0==T.currentTime.toFixed(4)-0||(x=parseInt(T.currentTime),O=parseInt(T.duration),L=setInterval((function(){x===parseInt(T.currentTime)&&O===parseInt(T.duration)?B++>10&&(L&&clearInterval(L),L=null):parseInt(T.currentTime)>=parseInt(T.duration)?(L&&clearInterval(L),L=null):(x=parseInt(T.currentTime),O=parseInt(T.duration),B=0)}),150))},getVideoBufferQueueSize:function(){return W.length},playNextFrame:function(){te()},getCurFrameInfo:function(){var e;return z.src=((e=document.createElement("canvas")).width=T.videoWidth,e.height=T.videoHeight,e.getContext("2d").drawImage(T,0,0,e.width,e.height),e.toDataURL()),z},setDecodeType:function(e){r=e},ResetPlayState:function(){M=!1}};var Se,ve,Pe,be,we,Ae,Ee,Te,Ie,De,ke,Ce,Me=(Se=window,ve=Se.document,Pe=function(){return Se.URL||Se.webkitURL||Se},be=ve.createElementNS("http://www.w3.org/1999/xhtml","a"),we="download"in be,Ae=/constructor/i.test(Se.HTMLElement),Ee=/CriOS\/[\d]+/.test(navigator.userAgent),Te=function(e){(Se.setImmediate||Se.setTimeout)((function(){throw e}),0)},Ie=function(e){setTimeout((function(){"string"==typeof e?Pe().revokeObjectURL(e):e.remove()}),4e4)},De=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},Ce=(ke=function(e,t,n){n||(e=De(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,we)return r=Pe().createObjectURL(e),void setTimeout((function(){var e,n;be.href=r,be.download=t,e=be,n=new MouseEvent("click"),e.dispatchEvent(n),i(),Ie(r),o.readyState=o.DONE}));!function(){if((Ee||a&&Ae)&&Se.FileReader){var t=new FileReader;return t.onloadend=function(){var e=Ee?t.result:t.result.replace(/^data:[^;]*;/,"data:attachment/file;");Se.open(e,"_blank")||(Se.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?Se.location.href=r:Se.open(r,"_blank")||(Se.location.href=r),o.readyState=o.DONE,i(),Ie(r)}()}).prototype,"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return t=t||e.name||"download",n||(e=De(e)),navigator.msSaveOrOpenBlob(e,t)}:(Ce.readyState=Ce.INIT=0,Ce.WRITING=1,Ce.DONE=2,Ce.error=Ce.onwritestart=Ce.onprogress=Ce.onwrite=Ce.onabort=Ce.onerror=Ce.onwriteend=null,function(e,t,n){return null==t||null==t?null:new ke(e,t||e.name||"download",n)}));return new X};function de(e){return(de="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 me(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 he(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?me(Object(n),!0).forEach((function(t){ge(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):me(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ge(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=de(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=de(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==de(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _e(e,t){return t=(t=t.toLowerCase())[0].toUpperCase()+t.substr(1),Object.prototype.toString.call(e)==="[object "+t+"]"}function ye(e,t,n){if(void 0===n&&(n=2),void 0===t&&(t=0),(e=e.toString()).length>=n)return e;var r=n-e.length;return new Array(r).fill(String(t)).join("")+e}function Se(e,t){return void 0!==e&&e?(t=t||new Date,e=(e=(e=(e=(e=(e=e.replace(/y/gi,ye(t.getFullYear()),0)).replace(/m/gi,ye(t.getMonth()+1),0)).replace(/d/gi,ye(t.getDate()),0)).replace(/h/gi,ye(t.getHours()),0)).replace(/i/gi,ye(t.getMinutes()),0)).replace(/s/gi,ye(t.getSeconds()),0)):""}function ve(e,t){var n=(e=e||{}).nameFormat||["ymd_his"];t=t||new Date;var r="";if(_e(n,"string"))n=[n,{}];else{if(!_e(n,"array"))return void function(e){throw new Error(e)}("name format must be string or array");_e(n[0],"string")||(n[0]="ymd_his"),_e(n[1],"object")||(n[1]={})}var o=n[0].split(/\{(?:[^{}]+)\}/),a=n[1];n[0].replace(/\{([^{}]*)\}/g,(function(e,t,n){o.shift();r+=Se(),r+=t in a?a[t]:e}));var i=o.shift();return r+=Se(i,t)}function Pe(e,t){this.name=e,this.allowUpDateName=!0,this.byteLength=0,this.options=t,this.startTime=(new Date).toLocaleString()}Pe.prototype.setEndTime=function(){this.endTime=(new Date).toLocaleString()},Pe.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 be=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 we,Ae=function(e){var t=1048576,n=null,r=null,o=0,a=void 0,i=null,l=0,u=null,c=!1,s=e;function f(){this.onMessage=function(){},this.postMessage=function(e){this.__onMessage(e)},this.__postMessage=function(e){this.onMessage(e)}}return f.prototype.__onMessage=function(e){if("init"===e.type||null!==u){var t=e;switch(t.type){case"init":this.init(t.options);break;case"addBuffer":this.addBuffer(t);break;case"close":this.close();break;case"cancel":this.cancel()}}},f.prototype.init=function(e){null!==e.recordName&&void 0!==e.recordName&&(this.fullSize=e.fullSize||1/0,this.singleSize=e.singleSize+20*t||520*t,a="init",c=!1,u=e.recordName,this.limitOptions=Object.assign({limitBy:"fullSize"},e.limitOptions),this.nameOptions=Object.assign({namedBy:"date",nameFormat:["ymd_his",{}]},e.nameOptions))},f.prototype._malloc=function(e){n&&r&&(r=null,n=null),n=new ArrayBuffer(e),r=new DataView(n);var t=this.nameOptions,o="";if(null!=u)o=u;else switch(this.nameOptions.namedBy.toLowerCase()){case"date":o=ve(t);break;default:o=ve()}i=new Pe(o)},f.prototype._initVideoMem=function(){!n&&this.singleSize&&this._malloc(this.singleSize)},f.prototype.appendVideoBuf=function(e,n,a){var i=e.byteLength,u=0;if(5==l){u=n+i;for(var f=n;f<u;f++)r.setUint8(f,e[f-n]);u>o&&(o=u)}else{u=o+i;for(f=o;f<u;f++)r.setUint8(f,e[f-o]);o=u}this.__postMessage({type:"pendding",size:o,total:this.singleSize}),u>this.singleSize-20*t&&!c&&!s&&(c=!0,this.__postMessage({type:"close"}))},f.prototype.addBuffer=function(e){if("closed"!==a){var t=e.buffer,n=e.offset;l=e.recordType,this._initVideoMem(),a="addBuffer";var r=t.length,i=0;i=5==l?n+r:o+r,be.get("total")+i>this.fullSize?this.close():this.appendVideoBuf(t,n)}},f.prototype.inNodePlace=function(){if("addBuffer"===a){a="download",i.updateNameByStream(this.nameOptions,n.slice(0,20)),i.byteLength=o,i.setEndTime(),be.add(i);var e=n.slice(0,o);if(this.reset(),this.__postMessage({type:"download",data:he(he({},i),{},{buffer:e})}),e=null,"count"===this.limitOptions.limitBy){var t=this.limitOptions.count;t&&t===be.get("count")&&this.close()}}},f.prototype.reset=function(){o=0,this._malloc(this.singleSize)},f.prototype.close=function(){this.inNodePlace(),"closed"!==a&&void 0!==a&&(a="closed",this.__postMessage({type:"closed",message:"record was closed"}),n=null,r=null,i=null)},f.prototype.cancel=function(){"closed"!==a&&void 0!==a&&(a="closed",n=null,r=null,i=null)},new f},Ee=function(e){var t=e;function n(){}function r(e){var t,n;if((t=e<0?~e>>4:e>>4)>15){for(n=1;t>31;)t>>=1,n++;t-=16,t+=n<<4}return e>=0&&(t|=128),85^t}function o(e){var t,n,r;for((n=e<0?33+(~e>>2):33+(e>>2))>8191&&(n=8191),t=n>>6,r=1;0!=t;)r++,t>>=1;var o=8-r<<4|15-(n>>r&15);return e>=0&&(o|=128),o}return n.prototype={setSampleRate:function(e){e},encode:function(e){for(var n=new Int16Array(e.buffer),a=new Uint8Array(n.length),i=0;i<n.length;i++)a[i]=0==t?r(n[i]):o(n[i]);return a}},new n},Te=function(e,t){var n=e,r=t,o=null,a=null,i=8e3,l=[36,n,0,0,0,0],u=[68,72,65,86],c=[100,104,97,118],s=245,f=0,p=null;function d(e,t,n){var r=[],o=t||4;if(!0===n)for(var a=0;a<o;a++)r[a]=e>>>8*(o-1-a)&255;else for(var i=0;i<o;i++)r[i]=e>>>8*i&255;return r}function m(){a=new Ee(r)}return m.prototype={setSampleRate:function(e){i=e,a.setSampleRate(e)},setRtpInterlevedID:function(e){n=e},getRTPPacket:function(e){var t=a.encode(e),m=0;(o=new Uint8Array(l.length+40+t.length+8)).set([36,n],m),m+=2,o.set(d(40+t.length+8,4,!0),m),m+=4,o.set(u,m),m+=4,o.set([240],m),m+=1,o.set([0],m),m+=1,o.set([1],m),m+=1,o.set([0],m),m+=1,s>65535&&(s=240),o.set(d(s),m),m+=4,s++;var h=d(40+t.length+8);o.set(h,m),m+=4;var g=new Date,_=(g.getFullYear()-2e3<<26)+(g.getMonth()+1<<22)+(g.getDate()<<17)+(g.getHours()<<12)+(g.getMinutes()<<6)+g.getSeconds(),y=g.getTime(),S=null===p?0:y-p;p=y,(f+=S)>65535&&(f=65535-f),o.set(d(_),m),m+=4,o.set(d(f,2),m),m+=2,o.set([16],m),m+=1;var v=function(e,t){for(var n=0,r=t;r<e.length;r++)n+=e[r];return n}(o,6);o.set([v],m),m+=1;var P=2;16e3==i&&(P=4);var b=[131,1,0==r?14:10,P];o.set(b,m),m+=4;o.set([150,1,0,0],m),m+=4;var w=function(e,t){for(var n=0,r=0;r<t;r++)n+=e[r]<<r%4*8;return n}(t,t.length);return o.set([136],m),m+=1,o.set(d(w),m),m+=4,o.set([0,0,0],m),m+=3,o.set(t,m),m+=t.length,o.set(c,m),m+=4,o.set(h,m),o},terminate:function(){a=null}},new m(e)};function Ie(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,l=[],u=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(l.push(r.value),l.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return De(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?De(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function De(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var ke=function(e,t){var n=e,r=null,o=null,a=null,i=t,l=16,u=0,c=0,s=null,f=null,p=null,d={};d.pBuffer=new Uint8Array(320),d.nByteOffset=0;var m={};m.pBuffer=new Uint8Array(320),m.nByteOffset=0;var h=null,g=null,_=null,y=null,S=null,v=!1,P=!1;function b(){p=new I(20),f=new I(20)}function w(e){var t=new ArrayBuffer(2*e.length);return function(e,t,n){for(var r=0;r<n.length;r++,t+=2){var o=Math.max(-1,Math.min(1,n[r])),a=o<0?32768*o:32767*o;e.setInt16(t,a,!0)}}(new DataView(t),0,e),t}function A(e,t,n){var r=Ie(function(e,t,n){var r=null;if(n===t)return[e,r];if(n>t)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<i.length;){for(var c=Math.round((l+1)*o),s=0,f=0,p=u,d=e.length;p<c&&p<d;p++)s+=e[p],f++;i[l]=s/f,l++,u=c}if(Math.round(l*o)!==e.length){var m=Math.round(l*o);r=new Float32Array(e.subarray(m,e.length))}return[i,r]}(e,t,n),2);return[r[0],r[1]]}return b.prototype={SetPlayParam:function(e,t){0!=e&&0!=t&&8e3===i&&(u=e,c=t,r&&this.StopProcess(),this.Init(),this.Config(i,l,u,c),this.StartProcess())},SetCaptureParam:function(e,t){i=e,l=t},Init:function(){var e;return e=(we=window.ASPLiteModule)._malloc(4),0!=we._Audio_Framework_Init(e)&&(we._free(e),e=null),null!=(r=e)},Config:function(e,t,n,i){var l=Ie(function(e,t,n,r,o){if(null==e)return[null,null];var a=we._malloc(96),i=we._malloc(668),l=new Uint8Array(we.HEAPU8.buffer),u=0;"ASPLite.cfg".split("").forEach((function(e,t){l[i+u+4>>0]=e.charCodeAt(0),u++}));var c=t;return t>r&&(c=r),we.HEAP32[i/4+129]=2,we.HEAP32[i/4+130]=c,we.HEAP32[i/4+132]=1,we.HEAP32[i/4+133]=16,we.HEAP32[i/4+138]=1,we.HEAP32[i/4+140]=0,we.HEAP32[i/4+141]=0,0!=we._Audio_Framework_Config(e,i)&&(we._free(i),i=null,we._free(a),a=null),[i,a]}(r,e,0,n),2);o=l[0],a=l[1]},DeInit:function(){var e,t,n;t=o,n=a,null!=(e=r)&&(we._Audio_Framework_DeInit(e,t,n),we._free(e),we._free(t),we._free(n)),r=null,o=null,a=null,v=!1},InputCaptureData:function(e,t){var o=null;null!==h?((o=new Float32Array(e.length+h.length)).set(h,0),o.set(e,h.length)):o=e;var a=Ie(A(o,t,i),2),l=a[0],u=a[1];h=u;new Uint8Array(l.buffer);var c=w(l),s=new Uint8Array(c);null!=r&&n&&8e3===i?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}_=t.slice(o),n-=o,e(_,_.length)}(s,s.length):S&&S(s)},InputPlayData:function(e){if(P){var t=null;null!==g?((t=new Float32Array(e.length+g.length)).set(g,0),t.set(e,g.length)):t=e;var n=Ie(A(t,u,i),2),r=n[0],o=n[1];g=o;new Uint8Array(r.buffer);var a=w(r),l=new Uint8Array(a);!function e(t,n){if(n<=0)return;var r=320-m.nByteOffset,o=n>r?r:n,a=null;a=n>=320&&0==m.nByteOffset?t.slice(0,320):m.nByteOffset>0?t.slice(0,320-m.nByteOffset):t;if(m.pBuffer.set(a,m.nByteOffset),m.nByteOffset+=o,320==m.nByteOffset){var i=new Uint8Array(320);i.set(m.pBuffer),p.enqueue(i),m.pBuffer.fill(0),m.nByteOffset=0}y=t.slice(o),n-=o,e(y,y.length)}(l,l.length)}else p.clear()},StartProcess:function(){P=!0,s=setInterval((function(){!function(){if(null!==f&&0==f.size)return;if(!v&&p.size>5){v=!0;for(var e=0;e<p.size-1;e++)p.dequeue()}var t={};if(p.size>0)t=p.dequeue();else{if(!(f.size>5))return;t.buffer=new Uint8Array(320)}var n=f.dequeue(),o={};o.data=n.buffer,o.fs=8e3,o.datalen=320,o.depth=16,o.offset=2,o.channels=1,o.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(o.datalen),c=new Uint8Array(u);l.data=c,0==function(e,t,n,r,o){if(null==e)return-1;var a=we._malloc(232),i=we._malloc(116),l=we._malloc(t.datalen);we.writeArrayToMemory(t.data,l);var u=we._malloc(n.datalen);we.writeArrayToMemory(n.data,u);var c=we._malloc(t.datalen);we.HEAP32[a/4+0]=l,we.HEAP32[a/4+1]=t.fs,we.HEAP32[a/4+2]=t.datalen,we.HEAP32[a/4+3]=t.depth,we.HEAP32[a/4+4]=t.offset,we.HEAP32[a/4+5]=t.channels,we.HEAP32[a/4+6]=t.buflen,we.HEAP32[a/4+29]=u,we.HEAP32[a/4+30]=n.fs,we.HEAP32[a/4+31]=n.datalen,we.HEAP32[a/4+32]=n.depth,we.HEAP32[a/4+33]=n.offset,we.HEAP32[a/4+34]=n.channels,we.HEAP32[a/4+35]=n.buflen,we.HEAP32[i/4+0]=c;var s=we._Audio_Framework_Main(e,a,i,o);return 0==s&&r.data.set(we.HEAPU8.subarray(c,c+t.datalen)),we._free(a),we._free(i),we._free(l),we._free(u),we._free(c),s}(r,o,i,l,a)&&S&&S(l.data)}()}),10)},StopProcess:function(){this.DeInit(),s&&(clearInterval(s),s=null),f.clear(),p.clear(),h=null,g=null,P=!1},SetProcessedDataCallback:function(e){S=e}},new b},Ce=function(e,t){var n=e,r=null,o=null,a=null,i=null,l=null,u=!1,c=null,s=t,f={audio:!0,video:!1},p=null,d=null;function m(){}function h(e){d(e);var t=r.getRTPPacket(e);p(t,5)}return m.prototype={initAudioOut:function(e,t){if(null==o)try{window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.oAudioContext||window.msAudioContext,(o=new AudioContext).onstatechange=function(){}}catch(e){return}if(n.SetProcessedDataCallback(h),null!==a&&null!==i||(a=o.createGain(),(i=o.createScriptProcessor(1024,1,1)).onaudioprocess=function(e){if(null!==c){var t=e.inputBuffer.getChannelData(0);null!==p&&!0===u&&n.InputCaptureData(t,o.sampleRate)}},a.connect(i),i.connect(o.destination),l=o.sampleRate,a.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(f).then((function(e){c=e,o.createMediaStreamSource(e).connect(a)})).catch((function(e){})),u=!0,r||(r=new Te(s,e)).setSampleRate(t),l},controlVolumnOut:function(e){var t=e/20*2;a.gain.value=t<=0?0:t>=10?10:t},stopAudioOut:function(){if(null!==c&&u)try{for(var e=c.getAudioTracks(),t=0,n=e.length;t<n;t++)e[t].stop();u=!1,c=null}catch(e){}},terminate:function(){this.stopAudioOut(),o.close(),a=null,i=null,r&&(r.terminate(),r=null)},setSendAudioTalkBufferCallback:function(e){p=e},setRtpInterlevedID:function(e){s=e,r&&r.setRtpInterlevedID(e)},setCapturePcmDataCallback:function(e){d=e}},new m},Me=function(e){var t=0,n=[],r=null,o=null,a=window.H264EncModule,i=document.getElementById("video-capture"),l={audio:!1,video:e||{width:320,height:240,frameRate:15,facingMode:"user"}};window.cPlusH264EncCallBack=function(n,r,i){var l=new ArrayBuffer(r),h=new Uint8Array(l);if(h.set(a.HEAPU8.subarray(n,n+r)),o){var g=function(n,r){var o=n,a=new Uint8Array(u.length+44+o.length+8),i=0;a.set([36,t],i),i+=2,a.set(m(44+o.length+8,4,!0),i),i+=4,a.set(c,i),i+=4,1==r?(a.set([253],i),i+=1):(a.set([252],i),i+=1);a.set([0],i),i+=1,a.set([0],i),i+=1,a.set([0],i),i+=1,f>65535&&(f=240);a.set(m(f),i),i+=4,f++;var l=m(44+o.length+8);a.set(l,i),i+=4;var h=new Date,g=h.getFullYear()-2e3,_=h.getMonth()+1,y=h.getDate(),S=h.getHours(),v=h.getMinutes(),P=h.getSeconds(),b=(g<<26)+(_<<22)+(y<<17)+(S<<12)+(v<<6)+P,w=h.getTime(),A=null===d?0:w-d;d=w,(p+=A)>65535&&(p=65535-p);a.set(m(b),i),i+=4,a.set(m(p,2),i),i+=2,a.set([20],i),i+=1;var E=function(e,t){for(var n=0,r=t;r<e.length;r++)n+=e[r];return n}(a,6);a.set([E],i),i+=1;var T=[129,30,8,e.frameRate];a.set(T,i),i+=4;a.set([130,0,0,0],i),i+=4,a.set(m(e.height,2),i),i+=2,a.set(m(e.width,2),i),i+=2;var I=function(e,t){for(var n=0,r=0;r<t;r++)n+=e[r]<<r%4*8;return n}(o,o.length);return a.set([136],i),i+=1,a.set(m(I),i),i+=4,a.set([0,0,0],i),i+=3,a.set(o,i),i+=o.length,a.set(s,i),i+=4,a.set(l,i),a}(h,i);o(g,7)}};var u=[36,t,0,0,0,0],c=[68,72,65,86],s=[100,104,97,118],f=245,p=0,d=null;function m(e,t,n){var r=[],o=t||4;if(!0===n)for(var a=0;a<o;a++)r[a]=e>>>8*(o-1-a)&255;else for(var i=0;i<o;i++)r[i]=e>>>8*i&255;return r}function h(){var t=document.createElement("canvas");t.height=e.width,t.width=e.height;var n=Math.floor(1e3/e.frameRate),o=0,u=0,c=t.getContext("2d");!function e(){if(!i.paused&&!i.ended){var s,f,p,d,m,h=Date.now();if(0==o||h-o>=n+u){0!=o&&(u+=n-(h-o)),o=h,c.drawImage(i,0,0,t.width,t.height);var g=c.getImageData(0,0,t.width,t.height),_=new Uint8Array(g.data),y=(s=_,f=_.length,p=g.width,d=g.height,m=l.video.frameRate,null==r&&(r=a._malloc(f)),a.HEAPU8.set(s,r),a._h264Enc(r,f,p,d,m));if(0!=y)return void console.error("H264Encode initial failed, ret:"+y)}requestAnimationFrame(e)}}()}function g(){}return g.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",h)})).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",h);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 g};function Re(e){return(Re="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;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,He(r.key),r)}}function He(e){var t=function(e,t){if("object"!=Re(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Re(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Re(t)?t:t+""}var Fe=5,Le=13,xe=14,Oe=19,Be=22,Ve=1,Ge=2,Ne=3,We=4;window.WebCodecsVideoFrameMap=new Map;var ze=0,je=function(){return function(e,t,n){return t&&Ue(e.prototype,t),n&&Ue(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}((function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.m_VideoFrameIndex=0,this.m_WebCodecsDecoder=null,this.m_playMethod=t,this.m_imageWidth=0,this.m_imageHeight=0,this.m_nFrameRate=25,this.m_bIFrameComming=!1,this.m_WebCodecsVideoFrameScope=ze++,this.m_SPSParser=new k(n),this.m_nVideoEncodeType=n,this.errCallback=r}),[{key:"decode",value:function(e,t){if(e.nWidth!==this.m_imageWidth||e.nHeight!==this.m_imageHeight){this.close(),this.init();var n;if(null===this.m_WebCodecsDecoder)return console.log("[Error]the WebCodecsDecoder Create Failed!"),!1;if(null===(n=this.GetCodecString(t)))return console.log("[Warn]GetCodecString failed!"),!1;this.m_WebCodecsDecoder.configure({codec:n,codeWidth:e.nWidth,codeHeight:e.nHeight,hardwareAcceleration:"prefer-hardware"}),this.m_imageWidth=e.nWidth,this.m_imageHeight=e.nHeight,this.m_bIFrameComming=!1}return this.m_playMethod?null!==this.m_WebCodecsDecoder?this.m_bIFrameComming||0===e.nFrameSubType?(this.m_bIFrameComming=!0,this.m_WebCodecsDecoder.decode(new EncodedVideoChunk({type:0===e.nFrameSubType?"key":"delta",timestamp:0,duration:0,data:t})),!0):(console.log("[Error]The first frame is not I in WebCodecsDecoder!"),!1):(console.log("[Error]the WebCodecsDecoder is null!"),!1):(console.log("[Error] the m_playMethod is null!"),!1)}},{key:"flush",value:function(){this.m_WebCodecsDecoder&&this.m_WebCodecsDecoder.flush()}},{key:"close",value:function(){this.m_WebCodecsDecoder&&this.m_WebCodecsDecoder.close(),this.m_WebCodecsDecoder=null,console.log("[Warn] Decode Closed!")}},{key:"init",value:function(){this.m_WebCodecsDecoder=new VideoDecoder({output:this.OnOutput.bind(this),error:this.OnError.bind(this)})}},{key:"OnOutput",value:function(e){this.m_VideoFrameIndex++>999&&(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,e.colorSpace)}},{key:"OnError",value:function(e){console.log("[Error]HW Decode Failed!"),this.m_WebCodecsDecoder=null,this.errCallback(e)}},{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;o<r.length;o++)if(t=e.subarray(r[o]+3,r[o+1]),7==(31&e[r[o]+3])){this.m_SPSParser.parse(t),a=!0;break}return a?"avc1."+this.decimalToHex(this.m_SPSParser.getSpsValue("profile_idc"))+this.decimalToHex(this.m_SPSParser.getSpsValue("profile_compatibility"))+this.decimalToHex(this.m_SPSParser.getSpsValue("level_idc")):null}if(2==this.m_nVideoEncodeType){var i=!1;for(o=0;o<r.length;o++)if(t=e.subarray(r[o]+3,r[o+1]-1),66===(255&e[r[o]+3])){var l=e.subarray(r[o]+5,r[o+1]-1);this.m_SPSParser.parse(l),i=!0;break}return i?this.m_SPSParser.getCodecInfo():null}return null}},{key:"decimalToHex",value:function(e,t){var n=Number(e).toString(16);for(t=null==t?t=2:t;n.length<t;)n="0"+n;return n}}])}();window.nSWDecodeNum=0;var Ye=function(e,t){t=t;var n=0,r={timestamp:0,timestamp_usec:0},o=null,a=null,i=null,l=!1,u=!1,c=null,s=null,f=null,p=null,d=null,m=null,h=1,g="",_=!1,y=null,S=0,P=0,w={id:1,samples:null,baseMediaDecodeTime:0},A=0,E=null,T=2,C=0,M=0,R=0,U=1,H=null,F=0,L=null,x=null,O=null,B=null,V=null,G=null,N=null,W=null,z=null,j=null,Y=null,K=null,q=null,X=null,J=null,$=null,Q=null,Z=null,ee=null,te=null,ne=null,re=null,oe=null,ae=null,ie=null,le=0,ue=0,ce=0,de=0,me=0,he=0,ge=null,_e=null,ye=null,Se=null,ve=null,Pe=null,be=null,we=null,Ee=null,Te=null,Ie=null,De=null,Re=null,Ue=null,He=!1,ze=0,Ye=0,Ke=null,qe=0,Xe=0,Je=e,$e=!0,Qe=!1,Ze=!1,et=!1,tt=0,nt=0,rt=0,ot=!1,at=!1,it=0,lt=null,ut=null,ct=null,st=null,ft=0,pt=0,dt=!1,mt=0,ht=null,gt=!1,_t=0,yt=-1,St=-1,vt=!1,Pt=!1,bt="",wt=null,At=null,Et=null,Tt=null,It=10,Dt=0,kt=!1,Ct=!1,Mt=0,Rt=0,Ut=!0,Ht=0,Ft=0,Lt=0,xt=0,Ot=45,Bt=0,Vt=0,Gt=!1,Nt=!1,Wt=!1,zt=!1,jt="",Yt="",Kt="",qt="",Xt=!1,Jt=0,$t=[{},{},{}],Qt=null,Zt=0,en=[],tn=0,nn=0,rn=null,on=!1,an=null,ln=null,un=0,cn=-1,sn=!1;function fn(){}function pn(){return Ke&&Ke.CleanScreen(0,0,0,0),1}function dn(){null!=c&&(c.setDecodeType(Xe),c.setCodecInfo(g),c.setInitSegmentFunc(gn),c.setPlaySpeed(h),c.setFPS(S))}function mn(){null!=c&&(c.setBeginDrawCallback(x),c.setVideoSizeCallback(_n),c.setErrorCallback(Q),c.setAudioStartCallback(hn),c.setMseErrorCallback(yn),c.setCapturePicDataCallBack(J))}function hn(e,t){}function gn(){return y}function _n(){null!==K&&K(!1)}function yn(e){switch(e){case"InitError":vn();break;case"Error":case"SourceError":case"SourceBufferError":ot=!0,(++rt>2||me)&&(rt=0,vn())}}function Sn(e){t.log("error name: ".concat(e.name," detail: ").concat(e.message," code: ").concat(e.code))}function vn(){if(1==Xe?$e=!1:Qe=!1,Je)Module._PLAY_SetSupportWebMSE(n,$e,Qe);else{var e={nType:"SetSupportWebMSE",bSupportH264MSE:$e,bSupportH265MSE:Qe};wt&&wt.postMessage(e)}}function Pn(){c&&(c.close(),c.terminate(),c=null),u=!1,y=null,s=null,f=null,_=!1,at=!1,C=0,w={id:1,samples:null,baseMediaDecodeTime:0},A=0,U=1,R=0,F=0,M=0,1==T&&(T=2),yt=-1}function bn(){gt=!1;var e=1;if(Je)e=Module._PLAY_StopDataRecord(n);else{wt&&wt.postMessage({nType:"StopRecord"})}return(Je||5!=ft)&<&&(lt.postMessage({type:"close"}),lt=null),pt=0,it=0,e}function wn(e,t){var n=parseInt(e)||500;lt.postMessage({type:"init",options:{recordName:t,singleSize:1048576*n,nameOptions:{namedBy:"date",nameFormat:["ymd_his"]},limitOptions:{limitBy:"count",count:10}}}),lt.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(){bn()}))}var t,n,r,o}}function An(e,o){var i,v;if(0!==S&&(1!=Ze&&(Ze=!0,pn()),i=e.nFrameID,(0==(v=e.nFrameSubType)||18==v||20==v?(yt=i,1):19==v&&-1!==yt||-1==St||i==St+1||(t.info("checkFrame failed, PlayPort:"+n+", nFrameID:"+i+", m_nLastFrameID:"+St),0))&&(St=e.nFrameID,le==ce&&ue==de&&e.nEncodeType==qe||(0!=ce&&(ot=!0),ce=le,de=ue,qe=e.nEncodeType),S!=P&&(!0,t.info("MSE FrameRate change, PlayPort:"+n+", m_nFrameRate:"+S+", m_nPreFrameRate:"+P),P=S),ot&&(Pn(),ot=!1),0!=at||0==e.nFrameSubType||18==e.nFrameSubType||20==e.nFrameSubType))){if(null==s&&(s=new k(Xe)),null==f){var b=-1==cn?e.nRotateType:cn;(f=new D(Xe)).SetRotateType(b)}if(function(e,t){for(var n=null,r=e.length,o=[],a=0;a<=r;)if(0==e[a])if(0==e[a+1])if(1==e[a+2]){if(o.push(a),a+=3,1==Xe){if(5==(31&e[a])||1==(31&e[a]))break}else if(2==Xe&&(38==(255&e[a])||40==(255&e[a])||42==(255&e[a])||2==(255&e[a])))break}else 0==e[a+2]?a++:a+=3;else a+=2;else a+=1;var i=0;if(1==Xe){for(a=0;a<o.length;a++)switch(n=e.subarray(o[a]+3,o[a+1]),31&e[o[a]+3]){case 1:i=o[a]-1,L=e.subarray(i,e.length);break;case 5:i=o[a]-1,L=e.subarray(i,e.length),_=!1;break;case 7:s.parse(n),d=n,u=!0;break;case 8:m=n}if(!_&&u){_=!0;var l={id:1,width:le,height:ue,type:"video",profileIdc:s.getSpsValue("profile_idc"),profileCompatibility:0,levelIdc:s.getSpsValue("level_idc"),sps:[d],pps:[m],timescale:3e3*S,fps:S,duration:Math.round(1/S*1e3)};y=f.initSegment(l);var h=-1==cn?t.nRotateType:cn;h,c&&c.ResetInitSegmentFlag()}}else if(2==Xe){for(a=0;a<o.length;a++)switch(n=e.subarray(o[a]+3,o[a+1]-1),255&e[o[a]+3]){case 2:i=o[a]-1,L=e.subarray(i,e.length);break;case 38:case 40:case 42:i=o[a]-1,L=e.subarray(i,e.length),_=!1;break;case 64:p=n;break;case 66:var v=e.subarray(o[a]+5,o[a+1]-1);s.parse(v),d=n,u=!0;break;case 68:m=n}if(!_&&u){_=!0;var P=s.getSpsValue("general_profile_space"),b=s.getSpsValue("general_tier_flag"),w=s.getSpsValue("general_profile_idc"),A=s.getSpsValue("temporalIdNested");l={id:1,width:le,height:ue,type:"video",general_profile_flag:P<<6|b<<5|w,general_profile_compatibility_flags:s.getSpsValue("general_profile_compatibility_flags"),general_constraint_indicator_flags:s.getSpsValue("general_constraint_indicator_flags"),general_level_idc:s.getSpsValue("general_level_idc"),chroma_format_idc:s.getSpsValue("chroma_format_idc"),bitDepthLumaMinus8:s.getSpsValue("bitDepthLumaMinus8"),bitDepthChromaMinus8:s.getSpsValue("bitDepthChromaMinus8"),rate_layers_nested_length:11|(1&A)<<2,vps:[p],sps:[d],pps:[m],timescale:3e3*S,fps:S,duration:Math.round(1/S*1e3)};y=f.initSegment(l);var E=-1==cn?t.nRotateType:cn;E,c&&c.ResetInitSegmentFlag()}}u&&(g=s.getCodecInfo(),c&&c.setCodecInfo(g))}(o,e),0==at){null==c&&null!=a&&void 0!==a&&(c=new pe(t)).init(a);var I={decodeMode:"video"};I.width=le,I.height=ue,[2,4,8].includes(e.nEncodeType)?I.encodeMode="H264":12===e.nEncodeType&&(I.encodeMode="H265"),O&&O(I),mn(),dn(),at=!0}Pt&&(Pt=!1,c&&c.capturePic([a],bt)),c&&c.setvideoTimeStamp(r),function(){if(null!=L){if(!l&&Je){var e=Module._PLAY_GetPlaySpeed(n);c&&c.setPlaySpeed(e)}var t={duration:3e3,size:L.length,frame_time_stamp:null,frameDuration:null};t.frameDuration=t.duration,null==w.samples&&(w.samples=new Array(T)),w.samples[C]=t,C++,M+=t.frameDuration,R+=t.frameDuration;var r=L.length-4;L[0]=(4278190080&r)>>>24,L[1]=(16711680&r)>>>16,L[2]=(65280&r)>>>8,L[3]=255&r;var o=new Uint8Array(L.length+A);if(0!==A&&o.set(E),o.set(L,A),A=(E=o).length,C%T==0&&0!==C){if(null!==w.samples[0].frameDuration&&(w.baseMediaDecodeTime=1===U?0:F,F=M),1==h)for(var a=w.samples.length,i=R/T,u=0;u<a;u++)w.samples[u].frameDuration=i;R=0,H=f.mediaSegment(U,w,E,w.baseMediaDecodeTime),U++,C=0,E=null,A=0,null!==c?(c.setMediaSegment(H),!1):!1===_&&dn(),2==T&&(T=1,w.samples=null,w.samples=new Array(T))}}}(),Ke&&Ke.DrawDrawIVS(e.nFrameID)}}function En(e,a,i,l,u){var c=Date.UTC(u.nYear,u.nMonth,u.nDay,u.nHour,u.nMinute,u.nSecond)/1e3;if(1==u.nFrameType){if(t.log("PlayFrameData, PlayPort:"+n+", nFrameID:"+u.nFrameID+", nRemainData:"+u.nRemainData),he=u.nRemainData,Je&&et&&0==he&&(t.trace("PlayFrameData, StreamPlayOverCallback"),Y()),u.bThrowFrame)return;if(8==u.nStreamType?r.timestamp=c:r.timestamp=u.nTimeStamp/1e3,r.timestamp_usec=0,2==u.nEncodeType||4==u.nEncodeType||8==u.nEncodeType?Xe=1:12==u.nEncodeType&&(Xe=2),Ke&&Ke.setEncodeType(Xe),le=u.nWidth,ue=u.nHeight,0==le||0==ue)return;if(S!=u.nFrameRate&&Ue&&Ue.setFrameRate(u.nFrameRate),S=u.nFrameRate,tt<=5&&tt++,18==u.nFrameSubType||19==u.nFrameSubType||20==u.nFrameSubType?me=1:0==u.nFrameSubType&&(me=0),2==u.nFrameSubType&&!kt){if(kt=!0,1==Xe?$e=!1:2==Xe&&(Qe=!1),Je)Module._PLAY_SetSupportWebMSE(n,$e,Qe);else{var s={nType:"SetSupportWebMSE",bSupportH264MSE:$e,bSupportH265MSE:Qe};wt&&wt.postMessage(s)}return}if(Ke&&Ke.SetLifeCount(3*u.nFrameRate),(1==Xe&&1==$e||2==Xe&&1==Qe)&&13!=u.nStreamType)on||(on=!0,an=u),ln=u,0!==Rt?(St=u.nFrameID,Qt&&Qt.decode(u,e)):(1!=Ze&&(Ze=!0,pn(),Je||(Ke.SetDecodeMode(Ze),Ke.resize(le,ue))),Je?An(u,e):Ke&&Ke.draw(e,a,i,u,S));else{if(!Je&&(null==e||null==a||null==i))return;if(0!=Ze&&(Ze=!1,Ke.SetDecodeMode(Ze),Pn(),ot=!0,ce=0,de=0),le!=ce||ue!=de)ce=le,de=ue,Je||Ke.resize(le,ue),(f={decodeMode:"canvas"}).width=le,f.height=ue,[2,4,8].includes(u.nEncodeType)?f.encodeMode="H264":12===u.nEncodeType&&(f.encodeMode="H265"),O&&O(f);if(on||(on=!0,an=u),ln=u,St=u.nFrameID,Je){if(!vt){if(vt=!0,!sn){if(!Yn())return;o&&(setTimeout((function(){Module._PLAY_ViewResolutionChanged(n,parseInt(o.width),parseInt(o.height),0);var e=Module.allocateUTF8(o.id);Module._PLAY_SetDisplayRegion(n,0,null,e,1),Module._free(e)})),sn=!0,window.nSWDecodeNum++)}var f;t.log("Multi SW Play Start."),(f={decodeMode:"canvas"}).width=le,f.height=ue,[2,4,8].includes(u.nEncodeType)?f.encodeMode="H264":12===u.nEncodeType&&(f.encodeMode="H265"),x(f)}Ke&&Ke.DrawDrawIVS(u.nFrameID)}else Ke&&Ke.draw(e,a,i,u,S)}var p=u.nYear,d=Gn(u.nMonth),m=Gn(u.nDay),h=Gn(u.nHour),g=Gn(u.nMinute),_=Gn(u.nSecond);u.timeStamp=Date.UTC(p,d,m,h,g,_)/1e3,u.utcTimeStamp=new Date("".concat(p,"-").concat(d,"-").concat(m," ").concat(h,":").concat(g,":").concat(_)).getTime(),u.nSize=l,Je&&B(u)}else if(2==u.nFrameType){if(nt<30&&nt++,Ue&&(tt>=1?(Ue.setVideoStartPlay(!0),Ue.setPureAudioFlag(!1)):(nt>=30||Ct||He)&&(Ue.setVideoStartPlay(!1),Ue.setPureAudioFlag(!0))),u.nSamples==ze&&u.nBits==Ye||(ze=u.nSamples,Ye=u.nBits,Ue&&Ue.setSampleBits(u.nSamples,u.nBits)),Ue&&Ue.bufferAudio(e,u),Je&&Ue){var y=Ue.getAudioBufTime();setTimeout((function(){Module._PLAY_SetInt32(n,2057,y)}))}u.nSize=l,u.audioData=e,V(u)}}function Tn(e,t,n,r,o){if(-1!=o){if(n==Fe)if(Je||Ze)o=St;else{var a=Ke&&Ke.GetCurrentFrameID();if(-1==a||void 0===a)return;o=a}if(Je){var i=null,l=new ArrayBuffer(r),u=new Uint8Array(l);u.set(Module.HEAPU8.subarray(t,t+r));var c=new DataView(u.buffer);if($&&$(e,u,n,r,o),Oe==n){var s={};s.NumberStat=c.getUint16(0,!0),s.nIntelFlowPlanNum=c.getUint16(2,!0);var f=c.getUint32(4,!0),p=new ArrayBuffer(12),d=new Uint8Array(p),m=new DataView(p);s.pIntelFlowPlan=new Array(s.nIntelFlowPlanNum);for(var h=0;h<s.nIntelFlowPlanNum;h++){d.set(Module.HEAPU8.subarray(f+12*h,f+12*h+12)),s.pIntelFlowPlan[h]={},s.pIntelFlowPlan[h].PlanId=m.getUint16(0,!0),s.pIntelFlowPlan[h].RuleType=m.getUint16(2,!0),s.pIntelFlowPlan[h].RegionNum=m.getUint16(8,!0);var g=m.getUint32(4,!0),_=new ArrayBuffer(12),y=new Uint8Array(_),S=new DataView(_);s.pIntelFlowPlan[h].pRegion=new Array(s.pIntelFlowPlan[h].RegionNum);for(var v=0;v<s.pIntelFlowPlan[h].RegionNum;v++)y.set(Module.HEAPU8.subarray(g+12*v,g+12*v+12)),s.pIntelFlowPlan[h].pRegion[v]={},s.pIntelFlowPlan[h].pRegion[v].RegionId=S.getUint16(0,!0),s.pIntelFlowPlan[h].pRegion[v].State=S.getUint16(2,!0),s.pIntelFlowPlan[h].pRegion[v].PeopleNum=S.getUint32(4,!0)}i=s}else if(Be==n){var P={};P.nId=c.getUint32(0,!0),P.wCustom=c.getUint16(4,!0),P.chState=c.getUint8(6,!0),P.chCount=c.getUint8(7,!0);var b=c.getUint32(8,!0),w=new ArrayBuffer(12),A=new Uint8Array(w),E=new DataView(w);P.pElement=new Array(P.chCount);for(var T=0;T<P.chCount;T++){A.set(Module.HEAPU8.subarray(b+12*T,b+12*T+12)),P.pElement[T]={},P.pElement[T].nStructType=E.getUint32(0,!0),P.pElement[T].nStructLength=E.getUint32(4,!0);var I=E.getUint32(8,!0),D=P.pElement[T].nStructLength;We===P.pElement[T].nStructType&&(D=20);var k=new ArrayBuffer(D),C=new Uint8Array(k),M=new DataView(k);if(C.set(Module.HEAPU8.subarray(I,I+D)),P.pElement[T].pStruct={},Ve==P.pElement[T].nStructType)P.pElement[T].pStruct.chType=M.getUint8(0,!0),P.pElement[T].pStruct.chWidth=M.getUint8(1,!0),P.pElement[T].pStruct.chStyle=M.getUint8(2,!0),P.pElement[T].pStruct.wRadius=M.getUint16(4,!0),P.pElement[T].pStruct.positionCircle={},P.pElement[T].pStruct.positionCircle.x=M.getUint16(8,!0),P.pElement[T].pStruct.positionCircle.y=M.getUint16(10,!0),P.pElement[T].pStruct.chLineA=M.getUint8(12,!0),P.pElement[T].pStruct.chLineR=M.getUint8(13,!0),P.pElement[T].pStruct.chLineG=M.getUint8(14,!0),P.pElement[T].pStruct.chLineB=M.getUint8(15,!0),P.pElement[T].pStruct.chRegA=M.getUint8(16,!0),P.pElement[T].pStruct.chRegR=M.getUint8(17,!0),P.pElement[T].pStruct.chRegG=M.getUint8(18,!0),P.pElement[T].pStruct.chRegB=M.getUint8(19,!0);else if(Ge==P.pElement[T].nStructType){P.pElement[T].pStruct.chType=M.getUint8(0,!0),P.pElement[T].pStruct.chCount=M.getUint8(1,!0),P.pElement[T].pStruct.chWidth=M.getUint8(2,!0),P.pElement[T].pStruct.chStyle=M.getUint8(3,!0),P.pElement[T].pStruct.chLineA=M.getUint8(4,!0),P.pElement[T].pStruct.chLineR=M.getUint8(5,!0),P.pElement[T].pStruct.chLineG=M.getUint8(6,!0),P.pElement[T].pStruct.chLineB=M.getUint8(7,!0);var R=null,U=null,H=null,F=null;P.pElement[T].pStruct.chCount>0&&(P.pElement[T].pStruct.pPoints=new Array(P.pElement[T].pStruct.chCount),R=M.getUint32(8,!0),U=new ArrayBuffer(4),H=new Uint8Array(U),F=new DataView(U));for(var L=0;L<P.pElement[T].pStruct.chCount;L++)H.set(Module.HEAPU8.subarray(R+4*L,R+4*L+4)),P.pElement[T].pStruct.pPoints[L]={},P.pElement[T].pStruct.pPoints[L].x=F.getUint16(0,!0),P.pElement[T].pStruct.pPoints[L].y=F.getUint16(2,!0)}else if(Ne==P.pElement[T].nStructType){P.pElement[T].pStruct.chType=M.getUint8(0,!0),P.pElement[T].pStruct.chCount=M.getUint8(1,!0),P.pElement[T].pStruct.chWidth=M.getUint8(2,!0),P.pElement[T].pStruct.chStyle=M.getUint8(3,!0),P.pElement[T].pStruct.chLineA=M.getUint8(4,!0),P.pElement[T].pStruct.chLineR=M.getUint8(5,!0),P.pElement[T].pStruct.chLineG=M.getUint8(6,!0),P.pElement[T].pStruct.chLineB=M.getUint8(7,!0),P.pElement[T].pStruct.chRegA=M.getUint8(8,!0),P.pElement[T].pStruct.chRegR=M.getUint8(9,!0),P.pElement[T].pStruct.chRegG=M.getUint8(10,!0),P.pElement[T].pStruct.chRegB=M.getUint8(11,!0);R=null;var x=null,O=null,B=null;P.pElement[T].pStruct.chCount>0&&(P.pElement[T].pStruct.pPoints=new Array(P.pElement[T].pStruct.chCount),R=M.getUint32(12,!0),x=new ArrayBuffer(4),O=new Uint8Array(x),B=new DataView(x));for(L=0;L<P.pElement[T].pStruct.chCount;L++)O.set(Module.HEAPU8.subarray(R+4*L,R+4*L+4)),P.pElement[T].pStruct.pPoints[L]={},P.pElement[T].pStruct.pPoints[L].x=B.getUint16(0,!0),P.pElement[T].pStruct.pPoints[L].y=B.getUint16(2,!0)}else if(We==P.pElement[T].nStructType&&(P.pElement[T].pStruct.chType=M.getUint8(0,!0),P.pElement[T].pStruct.chCharset=M.getUint8(1,!0),P.pElement[T].pStruct.stringPos={},P.pElement[T].pStruct.stringPos.x=M.getUint16(4,!0),P.pElement[T].pStruct.stringPos.y=M.getUint16(6,!0),P.pElement[T].pStruct.chLineA=M.getUint8(8,!0),P.pElement[T].pStruct.chLineR=M.getUint8(9,!0),P.pElement[T].pStruct.chLineG=M.getUint8(10,!0),P.pElement[T].pStruct.chLineB=M.getUint8(11,!0),P.pElement[T].pStruct.chFontSize=M.getUint8(12,!0),P.pElement[T].pStruct.chFontAlign=M.getUint8(13,!0),P.pElement[T].pStruct.wTxtLen=M.getUint16(14,!0),P.pElement[T].pStruct.wTxtLen>0)){var V=M.getUint32(16,!0),G=new ArrayBuffer(P.pElement[T].pStruct.wTxtLen),N=new Uint8Array(G);new DataView(G);N.set(Module.HEAPU8.subarray(V,V+P.pElement[T].pStruct.wTxtLen)),P.pElement[T].pStruct.stringDataArray=N}}if(P.nInfoLen=c.getUint16(12,!0),P.nInfoLen>0){var W=c.getUint32(16,!0),z=new ArrayBuffer(P.nInfoLen),j=new Uint8Array(z);j.set(Module.HEAPU8.subarray(W,W+P.nInfoLen)),P.pInfo=j}i=P}else if(xe==n){for(var Y=new DataView(l),K=r/144,J=[],Q=0;Q<K;Q++){var Z={},ee=144*Q;Z.nIndex=Y.getInt32(ee+0,!0),Z.xPoint=Y.getUint16(ee+4,!0),Z.yPoint=Y.getUint16(ee+6,!0);var te=new ArrayBuffer(64);te=l.slice(ee+8),Z.strName=Nn(te),Z.enable=Y.getInt8(ee+72,!0),Z.titleType=Y.getInt8(ee+73,!0),Z.titleAttribute=Y.getInt8(ee+74,!0),Z.sharpType=Y.getInt8(ee+75,!0),Z.polygonNum=Y.getInt8(ee+76,!0),Z.polygon=[];for(var ne=0;ne<2*Z.polygonNum;ne+=2)Z.polygon[ne]={x:Y.getInt8(ee+79+2*ne,!0),y:Y.getInt8(ee+79+2*(ne+1),!0)};J[Q]=Z,te=null}q&&q(J),Y=null,i=J}else if(Le==n){var re=136==r?8:4,oe=new ArrayBuffer(r-re),ae=new Uint8Array(oe);ae.set(Module.HEAPU8.subarray(t+re,t+r));var ie=new DataView(ae.buffer),le=[];le.longitude=ie.getInt32(0,!0)/1e3/3600,le.latitude=ie.getInt32(4,!0)/1e3/3600,le.yaw=ie.getFloat32(20,!0),le.pitch=ie.getFloat32(24,!0),le.roll=ie.getFloat32(28,!0),le.absoluteAltitude=ie.getFloat32(32,!0),le.zoom=ie.getFloat32(36,!0),X&&X(le),ie=null,i=le}else i=u;Ke&&Ke.DrawIVS(i,n,r,o)}else $&&$(e,t,n,r,o),Ke&&Ke.DrawIVS(t,n,r,o)}}function In(e){var r=e.data.msgType,a=e.data.nPort,i=e.data.msgData,u=0,c=0;switch(o&&(u=parseInt(o.width),c=parseInt(o.height)),r){case"LoadSuccess":if(0<nn){var s={nType:"setPrintLogLevel",nLogLevel:nn};wt.postMessage(s)}s={nType:"Init",option:{bPlayback:l,bSupportMultiThread:Je,bSupportH264MSE:$e,bSupportH265MSE:Qe,nCanvasWidth:u,nCanvasHeight:c}};if(wt.postMessage(s),Nt=!0,zt||(zt=!0,0!=jt.length&&0!=Yt.length&&0!=qt.length&&GetOriginalKey(jt,Yt,qt)),Wt||(Wt=!0,0!=jt.length&&0!=Kt.length&&0!=qt.length&&Kn(jt,Kt,qt)),!Xt)for(var f=0;f<3;f++)void 0!==$t[f].nFrameType&&SetWebSecurityKey(Jt,$t[f].nFrameType,$t[f].strKey,$t[f].stStreamInfo);for(var p=0;p<tn;p++)if(1==Zt||2==Zt){s={nType:"SetSecurityKey",nEncryptType:Zt,szKey:en[p].Key,nKeyLen:en[p].KeyLen,szKeyId:en[p].KeyId,nKeyIdLen:en[p].KeyIdLen};wt&&wt.postMessage(s)}else if(3==Zt){s={nType:"SetSecurityKeyEx",nEncryptType:Zt,stDecryptKey:en[p]};wt&&wt.postMessage(s)}break;case"InitSuccess":te(n=a);break;case"VisibleDecCallBack":ne(),En(i.pBufY,i.pBufU,i.pBufV,i.nSize,i.stuFrameInfo);break;case"IVSDataCallBack":Tn(a,i.pBuf,i.nType,i.nLen,i.nReallen);break;case"DemuxdataCallBack":qn(a,i.pBuf,i.nSize,i.pMutexInfo);break;case"RecordDataCallBack":!function(e,t,n,r){if(null!==lt){pt+=t;var o=r.nYear,a=r.nMonth,i=r.nDay,l=r.nHour,u=r.nMinute,c=r.nSecond,s=Date.UTC(o,a,i,l,u,c)/1e3,f=new Date("".concat(o,"-").concat(a,"-").concat(i," ").concat(l,":").concat(u,":").concat(c)).getTime();G&&G({frameType:r.nFrameType,timeStamp:f,utcTimeStamp:s,length:pt}),N&&N({frameType:r.nFrameType,timeStamp:f,utcTimeStamp:s,data:e,length:t,offset:n}),(5===ft||n>=it)&<.postMessage({type:"addBuffer",buffer:e,offset:n,recordType:ft}),n<it?(lt.postMessage({type:"close"}),lt=null,it=0,gt&&(lt=new Ae(gt),wn(mt,ht),0==ft&&(lt.postMessage({type:"addBuffer",buffer:e,offset:n,recordType:ft}),it=n)),0==un&&(wt&&wt.terminate(),wt=null)):it=n}}(i.pRecordData,i.nLen,i.Offset,i.stuFrameInfo);break;case"DecryptionResultCallBack":i.bSuccess,j(i.bSuccess);break;case"CatchPicCallBack":J&&J(i.buffer);var d=new Blob([i.buffer.buffer],{type:"image/jpg"});Vn(d,bt);break;case"GetOriginalKeyCallBack":W(i);break;case"PlayTokenDecryptResult":z(i);break;case"ARTagInfoCallback":q&&q(i.tagInfo);break;case"GPSInfoCallback":X&&X(i.GPSInfos);break;case"WorkerReceivedData":!function(e){Dt-=e;var n=0;Ke&&(n=Ke.GetVideoBufferSize());et&&0===Dt&&(0===n&&(t.trace("WorkerReceivedData StreamPlayOverCallback"),Y()),Ke&&Ke.SetStreamOver(!0))}(i.nLength)}}fn.prototype={Init:function(e){o=e.canvasElem,a=e.videoElem,i=e.ivsCanvasElem,l=e.bPlayBack,void 0!==e.nMSEFrameCount&&(T=e.nMSEFrameCount);var r=1;Bt=o&&o.width,Vt=o&&o.height,Qe=b();var u=navigator.platform;v();if(0==u.indexOf("iPhone")&&($e=!1,Qe=!1),Je){var s=Module._malloc(1);if(re=new Uint8Array(Module.HEAPU8.buffer,s,1),Module._PLAY_GetFreePort(re.byteOffset),n=re[0],re=null,Module._free(s),r=Module._PLAY_SetStreamOpenMode(n,l),r=Module._PLAY_OpenStream(n,0,0,10485760),r=Module._PLAY_SetCacheMode(n,1),r=Module._PLAY_SetSupportWebMSE(n,$e,Qe),$e||Qe)r=Module._PLAY_Play(n,0);else{if(!Yn())return 0;Module._PLAY_ViewResolutionChanged(n,parseInt(o.width),parseInt(o.height),0);var f=Module.allocateUTF8(o.id);r=Module._PLAY_Play(n,f),Module._free(f),sn=!0,window.nSWDecodeNum++}null==o&&(Module._PLAY_ViewResolutionChanged(n,0,0,0),r=Module._PLAY_Play(n,0))}else(wt=new Worker("".concat(e.strDecodeFilePath,"/VideoDecodeWorker.js"))).onmessage=In,rn=new I(200);if(t.trace("Init, PlayPort:"+n+", canvasElem:"+e.canvasElem+", videoElem:"+e.videoElem+", ivsCanvasElem:"+e.ivsCanvasElem+", bPlayBack:"+e.bPlayBack),t.trace("Init, m_bSupportMultiThread:"+Je+", m_bSupportH264MSE:"+$e+", m_bSupportH265MSE:"+Qe),r){Je&&(oe=Module._malloc(5242880),ae=new Uint8Array(Module.HEAPU8.buffer,oe,5242880));var p=50;l&&(p=300),Ke=new se(o,i,p,l,Je,t,this),0<nn&&Ke.SetPrintLogLevel(nn),Ke.SetErrorCallback(Q),Ke.SetVideoFrameInfoCallback(B),Ke.SetBeginDrawCallback(x),Ke.SetStreamOverCallback(Y),(Qe||$e)&&a&&((c=new pe(t)).init(a),mn())}return Ue=new fe,un=1,r},SetCacheMode:function(e){t.log("SetCacheMode, PlayPort:"+n+", nMode:"+e);var r=0;return Je&&(r=Module._PLAY_SetCacheMode(n,e)),r},GetPlayPort:function(){return n},InputData:function(e){t.log("InputData, PlayPort:"+n+", length:"+e.length);var r=1;if(Je)ae&&(ae.set(e),r=Module._PLAY_InputData(n,ae.byteOffset,e.length));else{Dt+=e.length;var o={nType:"InputData",pData:e};if(Nt){for(;rn.size>0;){var a={nType:"InputData",pData:rn.dequeue().buffer};wt.postMessage(a)}wt.postMessage(o)}else rn.enqueue(e)}return r},Pause:function(e){t.log("Pause, PlayPort:"+n+", bPause:"+e);var r=1;if(Je)r=Module._PLAY_Pause(n,e);else{var o={nType:"Pause",bPause:e};wt&&wt.postMessage(o)}return Ze||Ke&&Ke.pause(e),Ue&&Ue.pause(e),r},SetPlaySpeed:function(e){t.log("SetPlaySpeed, PlayPort:"+n+", nSpeed:"+e);var r=1;if(Je)r=Module._PLAY_SetPlaySpeed(n,e);else{var o={nType:"SetPlaySpeed",nSpeed:e};wt&&wt.postMessage(o)}return Ke&&Ke.setPlaySpeed(e),c&&c.setPlaySpeed(e),h=e,r},SetSecurityKey:function(e,t,n,r,o){return zn(e,t,n,r,o)},SetSecurityKeyEx:function(e,r){var o=0;return 1==e||2==e?o=zn(e,r.Key,r.KeyLen,r.KeyId,r.KeyIdLen):3==e&&(o=function(e,r){if(t.log("setSecurityKeyEx, PlayPort:"+n+", nKeyLen:"+r.KeyLen+", nKeyIdLen:"+r.KeyIdLen),void 0===r.Key||void 0===r.KeyId)return 0;Zt=e,en[tn]=r,tn++;var o=1;if(Je){var a=Module._malloc(96),i=0,l=new Uint8Array(Module.HEAPU8.buffer),u=Module._malloc(r.KeyLen);r.Key.split("").forEach((function(e,t){l[u+i>>0]=e.charCodeAt(0),i++})),i=0;var c=Module._malloc(r.KeyIdLen);r.KeyId.split("").forEach((function(e,t){l[c+i>>0]=e.charCodeAt(0),i++})),Module.HEAP32[a/4+0]=u,Module.HEAP32[a/4+1]=r.KeyLen,Module.HEAP32[a/4+2]=c,Module.HEAP32[a/4+3]=r.KeyIdLen,o=Module._PLAY_SetSecurityKeyEx(n,e,a,r.KeyLen),Module._free(u),Module._free(c),Module._free(a)}else{var s={nType:"SetSecurityKeyEx",nEncryptType:e,stDecryptKey:r};wt&&wt.postMessage(s)}return o}(e,r)),o},SetInt32:function(e,r){var o=0;if(t.log("SetInt32, PlayPort:"+n+", nSetType:"+e+", nValue:"+r),32776==e&&(_t=r),Je)o=Module._PLAY_SetInt32(n,e,r);else{var a={nType:"SetInt32",nSetType:e,nValue:r};wt&&wt.postMessage(a)}return o},StartRecord:function(e,r,o,a){return t.log("StartRecord, PlayPort:"+n+", nRecordType:"+e+", --nFileSize:"+r+", strRecordName:"+o),dt=!0,pt=0,function(e,t,r,o){void 0!==o&&(gt=o);var a=1;if(lt=new Ae(gt),wn(t,r),ft=e,mt=t,ht=r,Je)gt&&(a=Module._PLAY_SetSegmentRecordData(n,t,null,null)),a=Module._PLAY_StartDataRecord(n,0,ft);else{it=0;var i={nType:"StartRecord",nRecordType:ft,nFileSize:mt,bSegment:gt};wt&&wt.postMessage(i)}return a}(e,r,o,a)},StopRecord:function(){return t.log("StopRecord, PlayPort:"+n),dt=!1,bn()},CancelRecord:function(){return t.log("CancelRecord, PlayPort:"+n),function(){var e=1;if(Je)e=Module._PLAY_StopDataRecord(n);else{wt&&wt.postMessage({nType:"CancelRecord"})}lt&&(lt.postMessage({type:"cancel"}),lt=null);return pt=0,e}()},OpenIVSDraw:function(e){t.log("OpenIVSDraw, PlayPort:"+n+", nWndIndex:"+e);var r=1;if(Je)r=Module._PLAY_RenderPrivateData(n,1,0);else{wt&&wt.postMessage({nType:"OpenIVSDraw"})}return Ke&&Ke.OpenIVS(e,i.id),r},CloseIVSDraw:function(){t.log("CloseIVSDraw, PlayPort:"+n);var e=1;if(Je)e=Module._PLAY_RenderPrivateData(n,0,0);else{wt&&wt.postMessage({nType:"CloseIVSDraw"})}return Ke&&Ke.CloseIVS(),e},SetIvsEnable:function(e,r){t.log("SetIvsEnable, PlayPort:"+n+", nIvsType:"+e+", bEnable:"+r),Ke&&Ke.SetIvsEnable(e,r)},IVSSetViewProportion:function(e,r){t.log("IVSSetViewProportion, PlayPort:"+n+", nWidthProportion:"+e+", nHeightProportion:"+r),Ke&&Ke.IVSSetViewProportion(e,r)},IVSIoctl:function(e,r){t.log("IVSIoctl, PlayPort:"+n+", nCmdType:"+e),Ke&&Ke.IVSIoctl(e,r)},IVSGeneralConfig:function(e,r){t.log("IVSGeneralConfig, PlayPort:"+n+", nIvsType:"+e),Ke&&Ke.IVSGeneralConfig(e,r)},SetIvsIotBoxParas:function(e,r,o){t.log("SetIvsIotBoxParas, PlayPort:"+n+", imgPath:"+r+", bRelease:"+e+", nFontsize:"+o),Ke&&Ke.SetIvsIotBoxParas(e,r,o)},SetIvsIotBoxDisplay:function(e,r,o){t.log("SetIvsIotBoxDisplay, PlayPort:"+n+", ("+e+" , "+r+") showType:"+o),Ke&&Ke.SetIvsIotBoxDisplay(e,r,o)},SetIvsLanguageEnvi:function(e){t.log("SetIvsLanguageEnvi, PlayPort:"+n+", nLanguageType:"+e),Ke&&Ke.SetIvsLanguageEnvi(e)},SetPanoAR:function(e,r){t.log("SetPanoAR, PlayPort:"+n+", PanoARType:"+e);var o=1;if(Je&&!Ze){var a=null;return null!==r&&9===e&&(a=Module._malloc(12),Module.HEAPF32[a/4+0]=r.VerFieldViewAngle,Module.HEAPF32[a/4+1]=r.HoriFieldViewAngle,Module.HEAPF32[a/4+2]=r.DownPressAngle),o=Module._PLAY_SetPanoVRMode(n,e,a),Rt=e,null!==a&&Module._free(a),o}return 0!=nn&&Ke&&Ke.SetPrintLogLevel(nn),0===Rt&&0!==e?Ze?(ot=!0,Ke.resize(le,ue),null===Qt&&(Qt=new je(Ke,Xe,Sn))):(Ke.terminate(),Ke.resize(le,ue)):0!==Rt&&0===e&&(pn(),Ke.terminate(),Ze||Ke.resize(le,ue),Qt=null),Ke.SetPanoVRMode(e,r,le,ue),Rt=e,o},Set3DPoint:function(e){t.log("Set3DPoint, PlayPort:"+n+", b3DPoint:"+e),Je&&(Mt=e)},SetRotateType:function(e){return t.log("SetRotateType, m_nPlayPort:"+n+", nRotateType:"+e),cn=e,f&&f.SetRotateType(e),Je?Module._PLAY_SetRotateAngle(n,e):(Ke&&Ke.SetRotateType(e),1)},OnMouseDown:function(){0===Rt&&0===Mt||(Gt=!0)},OnMouseMove:function(e,t){if(0!==Rt||0!==Mt){Ut&&(Ht=e,Ft=t,0,0,Ut=!1);var r=e-Ht,o=t-Ft;if(Ht=e,Ft=t,Gt){if(Je&&!Ze){var a=Module._malloc(8),i=Module._malloc(8);Module._PLAY_GetDoubleRegion(n,0,2050,a),Module._PLAY_GetDoubleRegion(n,0,2051,i),Lt=Module.HEAPF64[a/8],xt=Module.HEAPF64[i/8],Module._free(a),Module._free(i)}else{if(!Ke)return void console.log("[Error]The m_playMethod is invalid in OnMouseMove!");Lt=Ke.GetModelRotate().x,xt=Ke.GetModelRotate().y}Math.abs(r)>=Math.abs(o)?xt+=-2*r*Ot/Vt:Lt+=-2*o*Ot/Vt,Je&&!Ze?Module._PLAY_SetStereoRotate(n,0,Lt,xt,0):Ke.SetModelRotate(Lt,xt,0)}}},OnMouseUp:function(){0===Rt&&0===Mt||(Gt=!1)},OnMouseWheel:function(e){if(0!==Rt||0!==Mt)if(e<0?Ot>=10&&(Ot-=2):Ot<=120&&(Ot+=2),Je&&!Ze)Module._PLAY_SetStereoPerspectiveFovy(n,0,Ot);else{if(!Ke)return void console.log("[Error]The m_playMethod is invalid in OnMouseWheel!");Ke.SetStereoPerspectiveFovy(Ot)}},GetVRCoord2DTrans:function(e,t){return function(e,t){var r;if(Je&&!Ze){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(!Ke)return void console.log("[Error]The m_playMethod is invalid in GetVRCoord2DTrans!");r=Ke.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(Je&&!Ze){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(!Ke)return void console.log("[Error]The m_playMethod is invalid in GetVRCoord3DTrans!");r=Ke.GetVRCoord3DTrans(e,t)}return[r.x,r.y]}(e,t)},SetSoundState:function(e){t.log("SetSoundState, PlayPort:"+n+", bPlay:"+e),Ue&&Ue.setSoundState(e)},SetVolume:function(e){t.log("SetVolume, PlayPort:"+n+", nVolume:"+e),Ue&&Ue.setVolume(e)},SetPureAudio:function(e){t.log("SetPureAudio, PlayPort:"+n+", bPureAudio:"+e),He=e},SetRtpInterlevedID:function(e){At?At.setRtpInterlevedID(e):It=e},StartTalk:function(e,r){if(t.log("StartTalk, PlayPort:"+n+", nEncodeType:"+e+", nSampleRate:"+r),!At){var o=void 0!==window.ASPLiteModule;Et=new ke(o,r),(At=new Ce(Et,It)).setSendAudioTalkBufferCallback(ee),At.setCapturePcmDataCallback(jn),At.initAudioOut(e,r),Ue&&Ue.setTalkFlag(!0),Ue&&o&&Ue.setAudioProcesser(Et)}},StopTalk:function(){t.log("StopTalk, PlayPort:"+n),At&&(At.terminate(),At=null),Ue&&(Ue.setTalkFlag(!1),Ue.setAudioProcesser(null)),Et&&(Et.StopProcess(),Et=null)},StartVideoCapture:function(e,r,o){t.log("StartVideoCapture, PlayPort:"+n+", nEncodeType:"+r),Tt||((Tt=new Me(o)).setBufferCallBack(ee),Tt.initVideoCapture(0,0))},StopVideoCapture:function(){t.log("StopVideoCapture, PlayPort:"+n),Tt&&(Tt.terminate(),Tt=null)},GetSourceBufferRemain:function(){var e=0;return e=Je?Module._PLAY_GetSourceBufferRemain(n):Dt,t.log("GetSourceBufferRemain, PlayPort:"+n+", nRemain:"+e),e},SetStreamOver:function(e){if(t.trace("SetStreamOver, PlayPort:"+n+", bOver:"+e+", m_nRemainData:"+he+", m_nSTBufferRemain:"+Dt),et=e,Je)et&&0==he&&(t.trace("SetStreamOver, StreamPlayOverCallback"),Y());else{var r=0;Ke&&(r=Ke.GetVideoBufferSize()),et&&0==Dt&&(0===r&&(t.trace("SetStreamOver, StreamPlayOverCallback"),Y()),Ke&&Ke.SetStreamOver(!0)),e||Ke&&Ke.SetStreamOver(!1)}},ResetBuffer:function(e){t.log("ResetBuffer, PlayPort:"+n+", nBufType:"+e),Je&&Module._PLAY_ResetBuffer(n,e)},capturePic:function(e){if(t.log("capturePic, PlayPort:"+n+", strPictureName:"+e),bt=e,Ze)Pt=!0;else if(Je){var r=le*ue*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],c=new ArrayBuffer(u),s=new Uint8Array(c);s.set(Module.HEAPU8.subarray(a.byteOffset,a.byteOffset+u)),J&&J(s);var f=new Blob([s.buffer],{type:"image/jpg"});Vn(f,bt),f=null,Module._free(o),Module._free(i),a=null,l=null,c=null,s=null}else{wt&&wt.postMessage({nType:"CatchPic"})}},OpenPlayGroup:function(){var e=null;return Je&&(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 Je&&(r=Module._PLAY_AddToPlayGroup(e,n)),r},DelFromPlayGroup:function(e,n){t.log("DelFromPlayGroup, pGroupHandle:"+e+", nPort:"+n);var r=0;return Je&&(r=Module._PLAY_DelFromPlayGroup(e,n)),r},ClosePlayGroup:function(e){t.log("ClosePlayGroup, pGroupHandle:"+e);var n=0;return Je&&(n=Module._PLAY_ClosePlayGroup(e)),n},PausePlayGroup:function(e,n){t.log("PausePlayGroup, pGroupHandle:"+e+", bPause:"+n);var r=0;return Je&&(r=Module._PLAY_PausePlayGroup(e,n)),r},SetPlayGroupSpeed:function(e,n){t.log("SetPlayGroupSpeed, pGroupHandle:"+e+", fSpeed:"+n);var r=0;return Je&&(r=Module._PLAY_SetPlayGroupSpeed(e,n)),r},SetAudioTalkFlag:function(e){t.log("SetAudioTalkFlag, PlayPort:"+n+", bAudioTalk:"+e),Ct=e},SetDecodeMode:function(e,r){if(t.trace("SetDecodeMode, PlayPort:"+n+", nH264DecodeMode:"+e+", nH265DecodeMode:"+r),$e=e,Qe=r,Qe=b(),t.trace("After SetDecodeMode, PlayPort:"+n+", nH264DecodeMode:"+e+", nH265DecodeMode:"+r),Je)Module._PLAY_SetSupportWebMSE(n,e,r);else{var o={nType:"SetSupportWebMSE",bSupportH264MSE:e,bSupportH265MSE:r};wt&&wt.postMessage(o)}},SetColor:function(e,r,o,a){t.log("SetColor, PlayPort:"+n+", nBrightness:"+e+", nContrast:"+r+", nSaturation:"+o+", nHue:"+a),Je?Module._PLAY_SetColor(n,0,e,r,o,a):Ke.SetColor(e,r,o,a)},SetDisplayRegion:function(e,r){if(t.log("SetDisplayRegion, PlayPort:"+n+", bEnable:"+r),0==Bt||0==Vt)return 0;if(void 0===e||r&&null==e)return-1;var a={};if(null!=e){if(e.left<0||e.right<0||e.top<0||e.bottom<0||e.left>=e.right||e.top>=e.bottom||e.right>Bt||e.bottom>Vt)return-1;a.left=e.left/Bt*le,a.top=e.top/Vt*ue,a.right=e.right/Bt*le,a.bottom=e.bottom/Vt*ue}if(Je){var i=Module.allocateUTF8(o.id);if(r){var l=Module._malloc(16);Module.HEAP32[l/4+0]=a.left,Module.HEAP32[l/4+1]=a.top,Module.HEAP32[l/4+2]=a.right,Module.HEAP32[l/4+3]=a.bottom,Module._PLAY_SetDisplayRegion(n,0,l,i,1),Module._free(l)}else Module._PLAY_SetDisplayRegion(n,0,null,i,1);Module._free(i)}else Ke.SetDisplayRegion(a,r);return 1},SetYUVOSDInfoEx:function(e){if(0!=Bt&&0!=Vt&&0!=e.osdCount)if(Je){for(var t=e.osdCount,r=Module._malloc(18376),o=new Uint8Array(Module.HEAPU8.buffer),a=0;a<18376;a++)o[r+a]=0;Module.HEAPU8[r+0]=1;var i=0;"Font.bin".split("").forEach((function(e,t){var n=e.charCodeAt(0);o[r+i+1]=n,i++})),Module.HEAP32[r/4+65]=t;for(var l=0;l<t;l++){var u=e.osdList[l].pointX/Bt*le,c=e.osdList[l].pointY/Vt*ue;Module.HEAP32[r/4+66+141*l]=u,Module.HEAP32[r/4+67+141*l]=c,Module.HEAP32[r/4+68+141*l]=e.osdList[l].colorR,Module.HEAP32[r/4+69+141*l]=e.osdList[l].colorG,Module.HEAP32[r/4+70+141*l]=e.osdList[l].colorB,Module.HEAP32[r/4+71+141*l]=e.osdList[l].colorA,i=0;for(var s=Wn(e.osdList[l].strOsdData),f=0;f<s.length;f++)o[r+i+288+564*l>>0]=s[f],i++;Module.HEAP32[r/4+200+141*l]=e.osdList[l].fontX,Module.HEAP32[r/4+201+141*l]=e.osdList[l].fontY,Module.HEAP32[r/4+202+141*l]=e.osdList[l].rotateAngle,Module.HEAPU8[r+812+564*l]=e.osdList[l].coordinate8192}Module._PLAY_SetYUVOSDInfoEx(n,r),Module._free(r)}else{var p={nType:"SetYUVOSDInfoEx",OSDInfo:e};wt&&wt.postMessage(p)}},GetOriginalKey:function(e,r,o){t.log("GetOriginalKey, PlayPort:"+n);var a=1;if(Je){var i=Module.intArrayFromString(e).concat(0),l=Module._malloc(i.length);Module.HEAPU8.set(i,l);var u=Module.intArrayFromString(r).concat(0),c=Module._malloc(u.length);Module.HEAPU8.set(u,c);var s=null;if(null!==o){var f=Module.intArrayFromString(o).concat(0);s=Module._malloc(f.length),Module.HEAPU8.set(f,s)}var p=Module._malloc(256),d=Module._malloc(4);a=Module._PLAY_GetOriginalKey(n,l,c,s,p,d);var m=Module.HEAP32[d>>2],h="";if(1==a&&m<=256){var g=new ArrayBuffer(m);new Uint8Array(g).set(Module.HEAPU8.subarray(p,p+m)),h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf-8",n=new TextDecoder(t);return n.decode(e)}(g)}if(Module._free(l),Module._free(c),Module._free(s),Module._free(p),Module._free(d),null===o)return h;W({nRet:a,outKey:h})}else if(Nt){zt=!0;var _={nType:"GetOriginalKeyCallBack",playToken:e,playTokenKey:r,deviceID:o};wt&&wt.postMessage(_)}else jt=e,Yt=r,qt=o;return a},SetPlayTokenToDecrypt:function(e,t,n){Kn(e,t,n)},SetWebSecurityKey:function(e,r,o,a){if(t.log("SetWebSecurityKey, PlayPort:"+n),!Je)if(Nt){21!=r&&22!=r||(r=2),Xt=!0;var i={nType:"SetWebSecurityKey",nDecryptType:e,nFrameType:r,strKey:o,stStreamInfo:a};wt&&wt.postMessage(i)}else Jt=e,1==r?($t[0].nFrameType=r,$t[0].strKey=o,$t[0].stStreamInfo=a):21==r?($t[1].nFrameType=2,$t[1].strKey=o,$t[1].stStreamInfo=a):22==r&&($t[2].nFrameType=2,$t[2].strKey=o,$t[2].stStreamInfo=a)},ResetPlayState:function(){t.log("ResetPlayState, PlayPort:"+n),Ke&&Ke.ResetPlayState(),c&&c.ResetPlayState()},Stop:function(){return function e(){un=0;var r=1;if(Je){if(r=Module._PLAY_GetThreadRunningState(n),t.log("GetThreadRunningState, PlayPort:"+n+", nRet:"+r),0==r)return setTimeout((function(){e()}),10),1;if(t.log("Stop, PlayPort:"+n),0==(r=Module._PLAY_Stop(n)))return r;r=Module._PLAY_CloseStream(n),ae=null,Module._free(oe),sn&&(window.nSWDecodeNum--,sn=!1)}else{wt&&(wt.postMessage({nType:"Stop"}),null!=lt&&5===ft||(wt.terminate(),wt=null)),Nt=!1,null!==rn&&(rn.clear(),rn=null)}Pn(),cn=-1,-1,ge=null,_e=null,ye=null,we=null,Ee=null,Te=null,Ie=null,De=null,Re=null,ut=null,ct=null,st=null,it=0,dt=!1,Ue&&(Ue.terminate(),Ue.setAudioProcesser(null),Ue=null,He=!1);At&&(At.terminate(),At=null);Tt&&(Tt.terminate(),Tt=null);Et&&(Et.StopProcess(),Et=null);Ke&&(Ke.stopRendering(),Ke.CleanScreen(0,0,0,0),Ke.terminate(),Ke=null);ce=0,de=0,qe=0,y=null,g=null,ot=!1,_=!1,rt=0,tt=0,nt=0,at=!1,St=-1,vt=!1,Ze=!1,Ct=!1,Dt=0,kt=!1,on=!1,an=null,ln=null,Zt=0;for(var o=0;o<tn;o++)en[o]={};return tn=0,ft=0,mt=0,ht=null,r}()},FrameDataCallBack:function(e,t,n,o,a,i){var l={};_e||(ge=new ArrayBuffer(292),_e=new Uint8Array(ge),ye=new DataView(ge)),_e.set(Module.HEAPU8.subarray(i,i+292)),l.nFrameType=ye.getInt32(0,!0),l.nFrameID=ye.getInt32(4,!0),l.nFrameSubType=ye.getInt32(56,!0),l.nYear=ye.getUint16(40,!0),l.nMonth=ye.getUint16(42,!0),l.nDay=ye.getUint16(46,!0),l.nHour=ye.getUint16(48,!0),l.nMinute=ye.getUint16(50,!0),l.nSecond=ye.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=ye.getInt32(36,!0),l.bThrowFrame=ye.getUint8(120,!0),0==l.bThrowFrame){if(l.nEncodeType=ye.getInt32(108,!0),l.nStreamType=ye.getInt32(112,!0),l.nTimeStamp=ye.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?Xe=1:12==l.nEncodeType&&(Xe=2),l.nWidth=ye.getInt32(12,!0),l.nHeight=ye.getInt32(16,!0),0==l.nWidth||0==l.nHeight)return;if(l.nFrameRate=ye.getInt32(20,!0),l.nStride=ye.getInt32(116,!0),l.nRotateType=ye.getUint8(122,!0),18==l.nFrameSubType||19==l.nFrameSubType||20==l.nFrameSubType?me=1:0==l.nFrameSubType&&(me=0),(1==Xe&&1==$e||2==Xe&&1==Qe)&&13!=l.nStreamType)be=new ArrayBuffer(a),(ie=new Uint8Array(be)).set(Module.HEAPU8.subarray(t,t+a)),En(ie,null,null,a,l);else{if(0==t||0==n||0==o)return;if(!Je){l.nWidth==ce&&l.nHeight==de&&null!=Ie||(we=null,Ee=null,Te=null,Ie=null,De=null,Re=null,we=new ArrayBuffer(l.nWidth*l.nHeight),Ie=new Uint8Array(we),Ee=new ArrayBuffer(l.nWidth*l.nHeight/4),De=new Uint8Array(Ee),Te=new ArrayBuffer(l.nWidth*l.nHeight/4),Re=new Uint8Array(Te));var c=0;for(c=0;c<l.nHeight;c++)Ie.set(Module.HEAPU8.subarray(t+c*l.nStride,t+c*l.nStride+l.nWidth),c*l.nWidth);for(c=0;c<l.nHeight/2;c++)De.set(Module.HEAPU8.subarray(n+c*l.nStride/2,n+c*l.nStride/2+l.nWidth/2),c*l.nWidth/2);for(c=0;c<l.nHeight/2;c++)Re.set(Module.HEAPU8.subarray(o+c*l.nStride/2,o+c*l.nStride/2+l.nWidth/2),c*l.nWidth/2)}En(Ie,De,Re,a,l)}}else En(null,null,null,0,l);else if(2==l.nFrameType){if(l.nTotalChannel=ye.getInt32(68,!0),l.nCurChannel=ye.getInt32(72,!0),l.nCurChannel>0)return;l.nBits=ye.getInt32(28,!0),l.nSamples=ye.getInt32(32,!0),l.nAudioChnNum=ye.getInt32(24,!0);var s=new ArrayBuffer(a),f=new Uint8Array(s);f.set(Module.HEAPU8.subarray(t,t+a)),En(f,null,null,a,l)}be=null,ie=null},DecryptionResultCallBack:function(e,t,n){n,j(n)},RecordDataCallBack:function(e,n,r,o,a){if(null!==lt){pt+=r,ct||(ut=new ArrayBuffer(292),ct=new Uint8Array(ut),st=new DataView(ut)),ct.set(Module.HEAPU8.subarray(a,a+292));var i=st.getInt32(0,!0),l=st.getInt32(4,!0);st.getInt32(56,!0);if(1==i){t.log("RecordDataCallBack, nPort:"+e+", nFrameID:"+l);st.getInt32(76,!0),st.getInt32(80,!0),st.getUint32(8,!0);var u=st.getUint16(40,!0),c=Gn(st.getUint16(42,!0)),s=Gn(st.getUint16(46,!0)),f=Gn(st.getUint16(48,!0)),p=Gn(st.getUint16(50,!0)),d=Gn(st.getUint16(52,!0)),m=Date.UTC(u,c,s,f,p,d)/1e3,h=new Date("".concat(u,"-").concat(c,"-").concat(s," ").concat(f,":").concat(p,":").concat(d)).getTime()}G&&G({frameType:i,timeStamp:h,utcTimeStamp:m,length:pt});var g=new ArrayBuffer(r),_=new Uint8Array(g);_.set(Module.HEAPU8.subarray(n,n+r)),N&&N({frameType:i,timeStamp:h,utcTimeStamp:m,data:_,length:r,offset:o}),(5===ft||o>=it)&&(lt.postMessage({type:"addBuffer",buffer:_,offset:o,recordType:ft}),g=null,_=null),o<it&>?(lt.postMessage({type:"close"}),lt=null,lt=new Ae(gt),wn(mt,ht),it=0,0==ft&&(lt.postMessage({type:"addBuffer",buffer:_,offset:o,recordType:ft}),g=null,_=null,it=o)):it=o}},IVSDataCallBack:function(e,n,r,o,a){t.log("IVSDataCallBack, nPort:"+e+", nType:"+r+", nLen:"+o+", nFrameID:"+a),Tn(e,n,r,o,a)},DemuxDataCallBack:function(e,t,n,r){qn(e,t,n,r)},setCallback:function(e,n){switch(t.log("setCallback, type:"+e+", func:"+n),e){case"GetPlayPort":te=n;break;case"PlayStart":Ke.SetBeginDrawCallback(n),c&&c.setBeginDrawCallback(n),x=n;break;case"DecodeStart":O=n;break;case"VideoFrameInfo":B=n,Ke&&Ke.SetVideoFrameInfoCallback(n);break;case"AudioFrameInfo":V=n;break;case"RecordTimeStamp":G=n;break;case"RecordDataInfo":N=n;break;case"GetOriginalKey":W=n;case"PlayTokenDecryptResult":z=n;break;case"DecryptionResult":j=n;break;case"Error":Q=n,Ke&&Ke.SetErrorCallback(Q);break;case"loadingBar":K=n;break;case"audioTalk":case"videoCapture":ee=n;break;case"StreamPlayOver":Y=n,Ke&&Ke.SetStreamOverCallback(Y);break;case"ARTagInfo":q=n;break;case"GPSInfo":X=n;break;case"CapturePicDataCallBack":J=n,c&&c.setCapturePicDataCallBack(n);break;case"IVSDrawData":$=n;break;case"DemuxData":Z=n}},GetCurrentPlayTime:function(){return r.timestamp},GetCurrentPlayedTime:function(){return null!=ln&&null!=an?3600*ln.nDay*24+3600*ln.nHour+60*ln.nMinute+ln.nSecond-(3600*an.nDay*24+3600*an.nHour+60*an.nMinute+an.nSecond):-1},GetCurrentFrameInfo:function(){return ln},SetSTFrameCallback:function(e){ne=e,Ke&&Ke.SetSTFrameCallback(ne)},setPrintLogLevel:function(e){if(nn=e,Je)Module._PLAY_SetPrintLogLevel(e);else{var t={nType:"setPrintLogLevel",nLogLevel:e};wt&&wt.postMessage(t)}Ke&&Ke.SetPrintLogLevel(e)},SetPlayMethod:function(e,r,o){t.log("SetPlayMethod, PlayPort:"+n+", nStartTime:"+e+", nSlowTime:"+r+", nFastTime:"+o),Ke&&Ke.SetPlayMethod(e,r,o)},PlayMSE:function(e,t){An(e,t)},SetMSEPlaySpeed:function(e){Je||c&&c.setPlaySpeed(e)},SetAudioPlayMethod:function(e){t.log("SetAudioPlayMethod, PlayPort:"+n+", nClearTime:"+e),Ue&&Ue.SetAudioPlayMethod(e)},SetPrivacyRecover:function(e){t.log("SetPrivacyRecover, PlayPort:"+n+", bRecover:"+e);var r=0;if(Je)r=Module._PLAY_SetPrivacyRecover(n,e);else{var o={nType:"SetPrivacyRecover",bRecover:e};wt&&wt.postMessage(o)}return r},GetAudioPlayedTime:function(){return Ue?Ue.getAudioPlayedTime():-1},GetVideoBufferSize:function(){return Je||null===Ke?0:Ke.GetVideoBufferSize()}};var Dn,kn,Cn,Mn,Rn,Un,Hn,Fn,Ln,xn,On,Bn,Vn=(Dn=window,kn=Dn.document,Cn=function(){return Dn.URL||Dn.webkitURL||Dn},Mn=kn.createElementNS("http://www.w3.org/1999/xhtml","a"),Rn="download"in Mn,Un=/constructor/i.test(Dn.HTMLElement),Hn=/CriOS\/[\d]+/.test(navigator.userAgent),Fn=function(e){(Dn.setImmediate||Dn.setTimeout)((function(){throw e}),0)},Ln=function(e){setTimeout((function(){"string"==typeof e?Cn().revokeObjectURL(e):e.remove()}),4e4)},xn=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},Bn=(On=function(e,t,n){n||(e=xn(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){Fn(e)}}}(o,"writestart progress write writeend".split(" "))};if(o.readyState=o.INIT,Rn)return r=Cn().createObjectURL(e),void setTimeout((function(){Mn.href=r,Mn.download=t,Mn.dispatchEvent(new MouseEvent("click")),i(),Ln(r),o.readyState=o.DONE}));!function(){if((Hn||a&&Un)&&Dn.FileReader){var t=new FileReader;return t.onloadend=function(){var e=Hn?t.result:t.result.replace(/^data:[^;]*;/,"data:attachment/file;");Dn.open(e,"_blank")||(Dn.location.href=e),e=void 0,o.readyState=o.DONE,i()},t.readAsDataURL(e),void(o.readyState=o.INIT)}r||(r=Cn().createObjectURL(e)),a?Dn.location.href=r:Dn.open(r,"_blank")||(Dn.location.href=r),o.readyState=o.DONE,i(),Ln(r)}()}).prototype,"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return t=t||e.name||"download",n||(e=xn(e)),navigator.msSaveOrOpenBlob(e,t)}:(Bn.readyState=Bn.INIT=0,Bn.WRITING=1,Bn.DONE=2,Bn.error=Bn.onwritestart=Bn.onprogress=Bn.onwrite=Bn.onabort=Bn.onerror=Bn.onwriteend=null,function(e,t,n){return null==t||void 0===t?null:new On(e,t||e.name||"download",n)}));function Gn(e){return e<10?"0".concat(e):e}function Nn(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;o<r.length&&0!==r[o];)o++;return n.decode(e.slice(0,o))}function Wn(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);r>=0&&r<=127?(1,t.push(r)):r>=128&&r<=2047?(2,t.push(192|31&r>>6),t.push(128|63&r)):r>=2048&&r<=55295||r>=57344&&r<=65535?(3,t.push(224|15&r>>12),t.push(128|63&r>>6),t.push(128|63&r)):r>=65536&&r<=1114111&&(4,t.push(240|7&r>>18),t.push(128|63&r>>12),t.push(128|63&r>>6),t.push(128|63&r))}return t}function zn(e,r,o,a,i){if(t.log("setSecurityKey, PlayPort:"+n+", nKeyLen:"+o+", nKeyIdLen:"+i),null==r)return 0;Zt=e;var l={};l.Key=r,l.KeyLen=o,l.KeyId=a,l.KeyIdLen=i,en[tn]=l,tn++;var u=1;if(Je){var c=Module._malloc(49),s=new Uint8Array(Module.HEAPU8.buffer),f=0;if(1==e)r.forEach((function(e,t){s[c+f>>0]=e,f++}));else if(2==e){if(null==a)return 0;var p=new Uint8Array(16);if(s[c+f>>0]=1,f++,0==i){for(var d=0;d<16;d++)p[d]=0;i=16,a=p}a.forEach((function(e,t){s[c+f>>0]=e,f++})),r.forEach((function(e,t){s[c+f]=e,f++})),o=1+o+i,p=null}else 16==e&&r.split("").forEach((function(e,t){s[c+f>>0]=e.charCodeAt(0),f++}));u=Module._PLAY_SetSecurityKey(n,c,o),Module._free(c)}else{var m={nType:"SetSecurityKey",nEncryptType:e,szKey:r,nKeyLen:o,szKeyId:a,nKeyIdLen:i};wt&&wt.postMessage(m)}return u}function jn(e){if(0!==_t&&dt)if(Je){var t=Module._malloc(e.length),r=new Uint8Array(Module.HEAPU8.buffer,t,e.length);r.set(e),Module._PLAY_InputAudioData(n,r.byteOffset,e.length,16,8e3),Module._free(t)}else{var o={nType:"InputAudioData",audioData:e};wt&&wt.postMessage(o)}}function Yn(){return!(window.nSWDecodeNum>=10)||(console.warn("Insufficient webGL resources."),Q&&Q({errorCode:100,description:"Insufficient webGL resources."}),!1)}function Kn(e,r,o){t.log("setPlayTokenToDecrypt, PlayPort:"+n),void 0!==e&&void 0!==r&&void 0!==o||returrn;var a=1;if(Je){var i=Module.intArrayFromString(e).concat(0),l=Module._malloc(i.length);Module.HEAPU8.set(i,l);var u=Module.intArrayFromString(r).concat(0),c=Module._malloc(u.length);Module.HEAPU8.set(u,c);var s=Module.intArrayFromString(o).concat(0),f=Module._malloc(s.length);Module.HEAPU8.set(s,f),a=Module._PLAY_SetPlayTokenToDecrypt(n,l,c,f),Module._free(l),Module._free(c),Module._free(f),z(a)}else if(Nt){Wt=!0;var p={nType:"SetPlayTokenToDecrypt",playToken:e,keySalt:r,deviceID:o};wt&&wt.postMessage(p)}else jt=e,Kt=r,qt=o}function qn(e,t,n,r){var o={};Je?(ve||(Se=new ArrayBuffer(72),ve=new Uint8Array(Se),Pe=new DataView(Se)),ve.set(Module.HEAPU8.subarray(r,r+72)),o.nFrameType=Pe.getInt32(0,!0),o.nFrameSubType=Pe.getInt32(4,!0),o.nEncodeType=Pe.getInt32(8,!0),o.nFrameID=Pe.getInt32(12,!0),o.nWidth=Pe.getInt32(16,!0),o.nHeight=Pe.getInt32(20,!0),o.nFrameRate=Pe.getInt32(24,!0),o.nYear=Pe.getUint16(28,!0),o.nMonth=Pe.getUint16(32,!0),o.nDay=Pe.getUint16(36,!0),o.nHour=Pe.getUint16(40,!0),o.nMinute=Pe.getUint16(44,!0),o.nSecond=Pe.getUint16(48,!0),o.nTimeStamp=Pe.getUint32(52,!0),o.nTotalChannel=Pe.getInt32(56,!0),o.nBits=Pe.getInt32(60,!0),o.nSamples=Pe.getInt32(64,!0),o.nMillisecond=Pe.getInt32(68,!0)):o=r,Z&&Z(o)}return new fn};function Ke(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var u=r&&r.prototype instanceof l?r:l,c=Object.create(u.prototype);return qe(c,"_invoke",function(n,r,o){var a,l,u,c=0,s=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return a=t,l=0,u=e,p.n=n,i}};function d(n,r){for(l=n,u=r,t=0;!f&&c&&!o&&t<s.length;t++){var o,a=s[t],d=p.p,m=a[2];n>3?(o=m===r)&&(u=a[(l=a[4])?5:(l=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=n<2&&d<a[1])?(l=0,p.v=r,p.n=a[1]):d<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,p.n=m,l=0))}if(o||n>1)return i;throw f=!0,r}return function(o,s,m){if(c>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),l=s,u=m;(t=l<2?e:u)||!f;){a||(l?l<3?(l>1&&(p.n=-1),d(l,u)):p.n=u:p.v=u);try{if(c=2,a){if(l||(o="next"),t=a[o]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,l<2&&(l=0)}else 1===l&&(t=a.return)&&t.call(a),l<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),l=1);a=e}else if((t=(f=p.n<0)?u:n.call(r,p))!==i)break}catch(t){a=e,l=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,o,a),!0),c}var i={};function l(){}function u(){}function c(){}t=Object.getPrototypeOf;var s=[][r]?t(t([][r]())):(qe(t={},r,(function(){return this})),t),f=c.prototype=l.prototype=Object.create(s);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,qe(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,qe(f,"constructor",c),qe(c,"constructor",u),u.displayName="GeneratorFunction",qe(c,o,"GeneratorFunction"),qe(f),qe(f,o,"Generator"),qe(f,r,(function(){return this})),qe(f,"toString",(function(){return"[object Generator]"})),(Ke=function(){return{w:a,m:p}})()}function qe(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}(qe=function(e,t,n,r){if(t)o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n;else{var a=function(t,n){qe(e,t,(function(e){return this._invoke(t,n,e)}))};a("next",0),a("throw",1),a("return",2)}})(e,t,n,r)}function Xe(e,t,n,r,o,a,i){try{var l=e[a](i),u=l.value}catch(e){return void n(e)}l.done?t(u):Promise.resolve(u).then(r,o)}function Je(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){Xe(a,r,o,i,l,"next",e)}function l(e){Xe(a,r,o,i,l,"throw",e)}i(void 0)}))}}var $e=function(e){e=e;var t={h265data:null,h265datalen:0,pvFrameLen:0,pvparsered:!1,bCloseState:!1,bGetUserMedia:!1,url:null};return t.pc=new RTCPeerConnection(null),t.m_localSDPInfoCallBack=null,t.videoStream=new MediaStream,t.talkStream=new MediaStream,t.defaultPath="/webrtc/play/",t.play=function(){var e=Je(Ke().m((function e(n){var r,o;return Ke().w((function(e){for(;;)switch(e.n){case 0:if(n){e.n=3;break}return e.n=1,t.pc.createOffer();case 1:return r=e.v,e.n=2,t.pc.setLocalDescription(r);case 2:t.m_localSDPInfoCallBack(r.sdp),e.n=6;break;case 3:return e.n=4,t.pc.createAnswer();case 4:return o=e.v,e.n=5,t.pc.setLocalDescription(o);case 5:t.m_localSDPInfoCallBack(o.sdp);case 6:return e.a(2,!0)}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.setRemoteSDP=function(n,r){e.log("RtcPlayer setRemoteSDP, bRemoteOffer:"+r),r?t.pc.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:n})):t.pc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:n}))},t.getLocalSDPInfoCallBack=function(e){t.m_localSDPInfoCallBack=e},t.playTalk=function(){var n=Je(Ke().m((function n(r){var o,a,i;return Ke().w((function(n){for(;;)switch(n.n){case 0:return e.log("RtcPlayer playTalk, bSetRemote:"+r),o=!0,r||t.pc.addTransceiver("audio",{direction:"sendrecv"}),t.defaultPath="/webrtc/talk/",t.bGetUserMedia=!0,n.n=1,navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then((function(e){e.getTracks().forEach((function(e){t.bCloseState?(e.stop(),e=null):(t.pc.addTrack(e),r&&t.pc.addTransceiver(e,{direction:"sendrecv"}),t.ontalkTrack&&t.ontalkTrack({track:e}))})),t.bCloseState&&(e=null)})).catch((function(t){e.error("RtcPlayer, GetUserMedia error: "+t.name+" and "+t.error+"\r\ngetUserMedia return undefined, try open this web use 'https' or check your media device!"),o=!1}));case 1:if(t.bGetUserMedia=!1,r){n.n=4;break}return n.n=2,t.pc.createOffer();case 2:return a=n.v,n.n=3,t.pc.setLocalDescription(a);case 3:t.m_localSDPInfoCallBack(a.sdp),n.n=7;break;case 4:return n.n=5,t.pc.createAnswer();case 5:return i=n.v,n.n=6,t.pc.setLocalDescription(i);case 6:t.m_localSDPInfoCallBack(i.sdp);case 7:return t.bCloseState&&(t.close(),o=!1),n.a(2,o)}}),n)})));return function(e){return n.apply(this,arguments)}}(),t.close=function(){e.log("RtcPlayer close, bGetUserMedia:"+t.bGetUserMedia),t.bCloseState=!0,t.bGetUserMedia||(t.videoStream&&(t.videoStream.getTracks().forEach((function(e){e.stop(),e=null})),t.videoStream=null),t.talkStream&&(t.talkStream.getTracks().forEach((function(e){e.stop(),e=null})),t.talkStream=null),t.pc&&t.pc.close(),t.pc=null)},t.onvideoTrack=function(e){t.videoStream.addTrack(e.track)},t.ontalkTrack=function(e){t.talkStream.addTrack(e.track)},t.bytesToInt=function(e,t){var n=255&e[t],r=255&e[t+1],o=255&e[t+2];return(255&e[t+3])<<24|o<<16|r<<8|n},t.checkPVStream=function(e){var t=e.length;return 68==e[0]&&72==e[1]&&65==e[2]&&86==e[3]&&100==e[t-8]&&104==e[t-7]&&97==e[t-6]&&118==e[t-5]},t.getPVFrameLen=function(e){return t.bytesToInt(e,12)},t.receiveChannelCallback=function(n){e.log("Receive data channel callback"),t.receiveChannel=n.channel,t.receiveChannel.binaryType="arraybuffer",t.receiveChannel.onmessage=t.onReceiveMessageCallback,t.receiveChannel.onopen=t.onReceiveChannelStateChange,t.receiveChannel.onclose=t.onReceiveChannelStateChange},t.onReceiveMessageCallback=function(n){var r=new Uint8Array(n.data);if(t.pvparsered||(t.pvFrameLen=t.getPVFrameLen(r),t.h265data=new Uint8Array(t.pvFrameLen),t.pvparsered=!0),t.h265datalen+n.data.byteLength<t.pvFrameLen)return t.h265data.set(r),void(t.h265datalen+=n.data.byteLength);t.h265data.length>=n.data.byteLength+t.h265datalen&&t.h265data.set(r,t.h265datalen),t.pvparsered=!1,t.h265datalen=0,t.pvFrameLen=0,t.checkPVStream(t.h265data)||e.log("size: ".concat(n.data.byteLength,'" data: ').concat(t.h265data[0]," ").concat(t.h265data[1]," ").concat(t.h265data[2]," ").concat(t.h265data[3]," ").concat(t.h265data[4]))},t.onReceiveChannelStateChange=function(){var n=t.receiveChannel.readyState;e.log("Receive channel state is: ".concat(n))},t.onSendChannelStateChange=function(){if(e.log("on send channel state change"),t.sendChannel){var n=t.sendChannel.readyState;e.log("Send channel state is: ".concat(n)),"open"===n&&t.sendChannel.send("start streaming")}},t.onError=function(n){t.sendChannel?e.error("Error in sendChannel:",n):e.log("Error in sendChannel which is already closed:",n)},t.senddate=function(){if(t.sendChannel){var n=t.sendChannel.readyState;e.log("Send channel state is: ".concat(n)),"open"===n&&t.sendChannel.send("this is a datachannel test demo")}},t.pc.ontrack=function(n){t.onvideoTrack&&t.onvideoTrack(n);var r=n.receiver;"jitterBufferTarget"in r&&e.log("self.pc.ontrack set jitterBufferTarget",r.jitterBufferTarget)},t.pc.onconnectionstatechange=function(){},t.pc.oniceconnectionstatechange=function(){},t.pc.onstatsended=function(){},t.pc.onsignalingstatechange=function(){},t.pc.onicegatheringstatechange=function(){},t.pc.onicecandidate=function(e){},t.__internal={prepareUrl:function(e){var n=t.__internal.parse(e),r=n.user_query.schema;r=r?r+":":window.location.protocol;var o=n.port||9001;"https:"===r&&(o=n.port||9002);var a=n.user_query.play||t.defaultPath;a.lastIndexOf("/")!==a.length-1&&(a+="/");var i=(i=r+"//"+n.server+":"+o+a).replace(a+"&",a+"?");return{apiUrl:i,streamUrl:n.url,schema:r,urlObject:n,port:o,tid:Number(parseInt((new Date).getTime()*Math.random()*100)).toString(16).substr(0,7)}},parse:function(e){var n=document.createElement("a");n.href=e.replace("rtmp://","http://").replace("webrtc://","http://").replace("rtc://","http://");var r=n.hostname,o=n.pathname.substr(1,n.pathname.lastIndexOf("/")-1),a=n.pathname.substr(n.pathname.lastIndexOf("/")+1);if((o=o.replace("...vhost...","?vhost=")).indexOf("?")>=0){var i=o.substr(o.indexOf("?"));o=o.substr(0,o.indexOf("?")),i.indexOf("vhost=")>0&&(r=i.substr(i.indexOf("vhost=")+"vhost=".length)).indexOf("&")>0&&(r=r.substr(0,r.indexOf("&")))}if(n.hostname===r){/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.test(n.hostname)&&(r="__defaultVhost__")}var l="rtmp";e.indexOf("://")>0&&(l=e.substr(0,e.indexOf("://")));var u=n.port;u||("http"===l?u=80:"https"===l?u=443:"rtmp"===l&&(u=1935));var c={url:e,schema:l,server:n.hostname,port:u,vhost:r,app:o,stream:a};return t.__internal.fill_query(n.search,c),c.port||"webrtc"!==l&&"rtc"!==l||("https"===c.user_query.schema||0===window.location.href.indexOf("https://")?c.port=9002:c.port=9001),c},fill_query:function(e,t){if(t.user_query={},0!==e.length){e.indexOf("?")>=0&&(e=e.split("?")[1]);for(var n=e.split("&"),r=0;r<n.length;r++){var o=n[r].split("=");t[o[0]]=o[1],t.user_query[o[0]]=o[1]}t.domain&&(t.vhost=t.domain)}}},t};function Qe(e){return(Qe="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 Ze(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return et(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?et(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){l=!0,a=e},f:function(){try{i||null==n.return||n.return()}finally{if(l)throw a}}}}function et(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,rt(r.key),r)}}function nt(e,t,n){return t&&tt(e.prototype,t),n&&tt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function rt(e){var t=function(e,t){if("object"!=Qe(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Qe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Qe(t)?t:t+""}function ot(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var at=1,it=2,lt=1,ut=2,ct=0,st=1,ft=nt((function e(){ot(this,e),this.epoch_time=0,this.offset=0,this.type=ct,this.length=-1})),pt=function(){function e(){ot(this,e),this.path="",this.region="",this.duration=0,this.epoch_time=0,this.kps=[]}return nt(e,null,[{key:"from",value:function(t){var n=new e;return n.path=t.path,n.region=t.region,n.duration=t.duration,n.epoch_time=t.epoch_time,n.kps=t.kps.map((function(e){var t=new ft;return Object.assign(t,e),t})),n}}])}(),dt=function(){return nt((function e(){ot(this,e),this.m_lSlice=[],this.m_cpos=0,this.m_end_pos=0,this.m_is_end=!1,this.m_m3u8_sequence=-1,this.m_slice_sequence=-1,this.m_targetduration=0}),[{key:"_strSplit",value:function(e,t){return e.split(new RegExp(t))}},{key:"addIndex",value:function(e,t,n){if(!e||0===e.length)return at,!1;this.m_lSlice=[];var r=this._strSplit(e,"\r\n");r.length<=1&&(r=this._strSplit(e,"\n"));for(var o=t,a=null,i=0,l=0;l<r.length;l++){var u=r[l].trim();if(u)if("#EXT-X-ENDLIST"!==u){if(u.startsWith("#EXT-X-MEDIA-SEQUENCE:")){var c=parseInt(u.split(":")[1]);if(this.m_m3u8_sequence===c)return console.warn("m3u8文件未更新,当前序列号: ".concat(this.m_m3u8_sequence)),it,!1;c<this.m_m3u8_sequence&&(this.m_slice_sequence=c),-1===this.m_m3u8_sequence&&(this.m_slice_sequence=c),this.m_m3u8_sequence=c}if(u.startsWith("#EXT-X-TARGETDURATION:")){var s=parseInt(u.split(":")[1]);console.log("HLS blb targetduration ".concat(s)),this.m_targetduration=s}if(u.startsWith("#EXTINF:")){var f=parseFloat(u.split(":")[1].split(",")[0]);i=f,(a=new pt).duration=f,this.m_lSlice.push(a)}if(u.startsWith("#EXT-REGIONID:")){var p=u.split(":")[1].trim();a&&(a.region="®ionid=".concat(p))}if(u.startsWith("#EXT-X-IF:")){var d=u.substring("#EXT-X-IF:".length).trim().split(/\s+/);if(d.length>=2&&a){var m=new ft;m.epoch_time=parseFloat(d[0]),m.offset=parseInt(d[1]),m.type=ct,m.length=d.length>2?parseInt(d[2]):-1,a.kps.push(m),1===a.kps.length&&(a.epoch_time=m.epoch_time)}}if(u.startsWith("#EXT-X-PF:")){var h=u.substring("#EXT-X-PF:".length).trim().split(/\s+/);if(h.length>=2&&a){var g=new ft;g.epoch_time=parseFloat(h[0]),g.offset=parseInt(h[1]),g.type=st,g.length=h.length>2?parseInt(h[2]):-1,a.kps.push(g)}}!u.startsWith("#")&&a&&(a.path=u,a.duration=i,a.epoch_time=o,o+=i)}else this.m_is_end=!0}return this.updateSeq(),0===this.m_end_pos&&(this.m_end_pos=this.m_lSlice.length-1),!0}},{key:"updateSeq",value:function(){console.log("updateSeq m_slice_sequence[".concat(this.m_slice_sequence,"] m_m3u8_sequence[").concat(this.m_m3u8_sequence,"]")),this.m_m3u8_sequence>this.m_slice_sequence?(this.m_slice_sequence=this.m_m3u8_sequence,this.m_cpos=0):this.m_cpos=this.m_slice_sequence-this.m_m3u8_sequence}},{key:"firstSlice",value:function(e){return this.m_cpos=0,this.nextSlice(e)}},{key:"nextSlice",value:function(e){return!(this.m_cpos>this.m_end_pos||this.m_cpos>=this.m_lSlice.length)&&(Object.assign(e,pt.from(this.m_lSlice[this.m_cpos])),this.m_cpos++,this.m_slice_sequence++,!0)}},{key:"seekSlice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(0===this.m_lSlice.length)return console.error("Can't find the slice, because m_lSlice size is zero"),!1;for(var r=-1,o=-1,a=null,i=0;i<this.m_lSlice.length;i++){var l=this.m_lSlice[i];if(e<=l.epoch_time+l.duration){r=i,this.m_cpos=i+1,a=pt.from(l),console.log("Find the slice at position ".concat(r));break}if(i===this.m_lSlice.length-1)return console.error("Can't find the slice, please check the seektime"),!1}if(0===a.kps.length){var u=new ft;return u.epoch_time=a.epoch_time,u.offset=0,u.type=ct,u.length=-1,t.push(a),n.push(u),!0}for(var c=null,s=a.kps.length-1;s>=0;s--){if(e>=a.kps[s].epoch_time){c=a.kps[s],o=s,console.log("Find the frame at keyPos ".concat(o));break}if(0===s){var f=new ft;return f.epoch_time=a.epoch_time,f.offset=0,f.type=ct,f.length=-1,t.push(a),n.push(f),!0}}if(c.type===st){for(var p=r;p>=0;p--)for(var d=this.m_lSlice[p],m=p===r?o:d.kps.length-1,h=m;h>=0;h--)if(d.kps[h].type===ct)return t.push(d),n.push(d.kps[h]),console.log("Find reference I frame at sPos ".concat(p," kPos ").concat(h)),!0;return t.length=0,n.length=0,console.error("Can't find the key_I frame, please check"),!1}return t.push(a),n.push(c),console.log("Slice Pos ".concat(r," keyPos ").concat(o)),!0}},{key:"seekSliceWithOption",value:function(e,t,n,r){for(var o=0;o<this.m_lSlice.length;o++){var a=this.m_lSlice[o];if(e<=a.epoch_time+a.duration){Object.assign(n,pt.from(a)),t===lt?this.m_cpos=o+1:t===ut&&(this.m_end_pos=o-1);for(var i=a.kps.length-1;i>=0;i--)if(e>a.kps[i].epoch_time)return Object.assign(r,a.kps[i]),!0;return r.epoch_time=a.epoch_time,r.offset=0,t===ut&&(r.offset=-1),!0}if(t===ut&&o===this.m_lSlice.length-1){this.m_end_pos=this.m_lSlice.length-1;var l=this.m_lSlice[this.m_lSlice.length-1];return Object.assign(n,pt.from(l)),l.kps.length>0?Object.assign(r,l.kps[l.kps.length-1]):(r.epoch_time=l.epoch_time,r.offset=0),!0}}return!1}},{key:"getRemainDuration",value:function(){for(var e=0,t=this.m_cpos;t<this.m_lSlice.length;t++)e+=this.m_lSlice[t].duration;return e}},{key:"getDuration",value:function(){var e,t=0,n=Ze(this.m_lSlice);try{for(n.s();!(e=n.n()).done;){t+=e.value.duration}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"dumpIndex",value:function(){for(var e=0;e<this.m_lSlice.length;e++){var t=this.m_lSlice[e];console.log("切片[".concat(e,"]: URL=").concat(t.path,", 时间=").concat(t.epoch_time));for(var n=0;n<t.kps.length;n++){var r=t.kps[n];console.log(" 关键帧[".concat(n,"]: 类型=").concat(r.type===ct?"I":"P",", 时间=").concat(r.epoch_time,", 偏移=").concat(r.offset))}}}},{key:"isEnd",value:function(){return this.m_is_end}},{key:"getTargetDuration",value:function(){return this.m_targetduration}},{key:"getSliceSize",value:function(){return this.m_lSlice.length}},{key:"getBackSlice",value:function(e){return 0!==this.m_lSlice.length&&(Object.assign(e,pt.from(this.m_lSlice[this.m_lSlice.length-1])),!0)}},{key:"getBackKeypoint",value:function(e){if(0===this.m_lSlice.length)return!1;var t=this.m_lSlice[this.m_lSlice.length-1];return 0!==t.kps.length&&(Object.assign(e,t.kps[t.kps.length-1]),!0)}},{key:"resetEndSlicePos",value:function(){this.m_end_pos=this.m_lSlice.length-1}}])}();function mt(e){return(mt="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 ht(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(mt(e)+" is not iterable")}function gt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var u=r&&r.prototype instanceof l?r:l,c=Object.create(u.prototype);return _t(c,"_invoke",function(n,r,o){var a,l,u,c=0,s=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return a=t,l=0,u=e,p.n=n,i}};function d(n,r){for(l=n,u=r,t=0;!f&&c&&!o&&t<s.length;t++){var o,a=s[t],d=p.p,m=a[2];n>3?(o=m===r)&&(u=a[(l=a[4])?5:(l=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=n<2&&d<a[1])?(l=0,p.v=r,p.n=a[1]):d<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,p.n=m,l=0))}if(o||n>1)return i;throw f=!0,r}return function(o,s,m){if(c>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),l=s,u=m;(t=l<2?e:u)||!f;){a||(l?l<3?(l>1&&(p.n=-1),d(l,u)):p.n=u:p.v=u);try{if(c=2,a){if(l||(o="next"),t=a[o]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,l<2&&(l=0)}else 1===l&&(t=a.return)&&t.call(a),l<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),l=1);a=e}else if((t=(f=p.n<0)?u:n.call(r,p))!==i)break}catch(t){a=e,l=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,o,a),!0),c}var i={};function l(){}function u(){}function c(){}t=Object.getPrototypeOf;var s=[][r]?t(t([][r]())):(_t(t={},r,(function(){return this})),t),f=c.prototype=l.prototype=Object.create(s);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,_t(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,_t(f,"constructor",c),_t(c,"constructor",u),u.displayName="GeneratorFunction",_t(c,o,"GeneratorFunction"),_t(f),_t(f,o,"Generator"),_t(f,r,(function(){return this})),_t(f,"toString",(function(){return"[object Generator]"})),(gt=function(){return{w:a,m:p}})()}function _t(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}(_t=function(e,t,n,r){if(t)o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n;else{var a=function(t,n){_t(e,t,(function(e){return this._invoke(t,n,e)}))};a("next",0),a("throw",1),a("return",2)}})(e,t,n,r)}function yt(e,t,n,r,o,a,i){try{var l=e[a](i),u=l.value}catch(e){return void n(e)}l.done?t(u):Promise.resolve(u).then(r,o)}function St(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){yt(a,r,o,i,l,"next",e)}function l(e){yt(a,r,o,i,l,"throw",e)}i(void 0)}))}}var vt=function(e,t){function n(){return r.apply(this,arguments)}function r(){return(r=St(gt().m((function e(){var t,n,r,o,a,i,l,u,c=this;return gt().w((function(e){for(;;)switch(e.n){case 0:return e.p=0,console.log("Enter download index\n"),e.n=1,fetch(this.m_m3uUrl);case 1:if((t=e.v).ok){e.n=2;break}throw new Error("HTTP ".concat(t.status));case 2:return e.n=3,t.text();case 3:if(this.m_m3u8_context=e.v,console.log("After downloadIndexTask"),!this.m_m3u8_context.includes("#EXT-X-STREAM-INF:")){e.n=7;break}if(n="",-1!==(r=this.m_m3u8_context.indexOf("#EXT-X-STREAM-INF"))&&(-1===(o=this.m_m3u8_context.indexOf("\r\n",r))&&(o=this.m_m3u8_context.indexOf("\n",r)),-1!==o&&(o=-1!==this.m_m3u8_context.indexOf("\r\n",r)?o+"\r\n".length:o+"\n".length,a=this.m_m3u8_context.substring(o),-1===(i=a.indexOf("\r\n"))&&(i=a.indexOf("\n")),-1!==i&&(n=a.substring(0,i),console.log("m3u8 new file[".concat(n,"]"))))),!n){e.n=7;break}return e.n=4,fetch(n);case 4:if((l=e.v).ok){e.n=5;break}throw new Error("HTTP ".concat(l.status));case 5:return e.n=6,l.text();case 6:this.m_m3u8_context=e.v;case 7:return 0,this.m_m3uParser.addIndex(this.m_m3u8_context,this.m_startTime,0)&&function(){var e=new pt;if(c.m_m3uParser.getBackSlice(e)){var t=new ft;c.m_m3uParser.getBackKeypoint(t)?c.m_endTime=t.epoch_time:c.m_endTime=e.epoch_time+e.duration}else c.m_endTime=c.m_startTime;c.m_m3uParser.resetEndSlicePos()}(),this.m_indexDownloaded=!0,e.a(2,this.m_m3u8_context);case 8:throw e.p=8,u=e.v,console.error("Download failed: ".concat(u.message)),u;case 9:return e.a(2)}}),e,this,[[0,8]])})))).apply(this,arguments)}function o(){return a.apply(this,arguments)}function a(){return(a=St(gt().m((function e(){var t,n,r,o,a,i,l,u,c,s,f,p,d,m,h,g,_,y,S,v=this;return gt().w((function(e){for(;;)switch(e.n){case 0:if(console.log("Enter downloadPaasSliceTask"),e.p=1,this.m_abortDownload=!1,this.m_seek_keyList=this.m_seek_keyList||[],this.m_seek_sliceList=this.m_seek_sliceList||[],!(this.m_seek_keyList.length>1)){e.n=6;break}return t=this.m_seek_keyList[1],n=this.m_seek_sliceList[1],console.log("[seek I-frame download]:<".concat(n.epoch_time,"> ").concat(n.path," offset=").concat(t.offset,"-").concat(t.offset+t.length-1)),e.n=2,new Promise((function(e){v.m_cbAuthorizeInfoCallback(v.m_recordRegionId,n.path,v.m_token,(function(t){v.m_sRealUrl=t,e()}))}));case 2:return r="bytes=".concat(t.offset,"-").concat(t.offset+t.length-1),e.n=3,fetch(this.m_sRealUrl,{headers:{Range:r}});case 3:if((o=e.v).ok){e.n=4;break}throw new Error("Download failed, HTTP ".concat(o.status));case 4:return e.n=5,o.arrayBuffer();case 5:a=e.v,this.playsdkInterface.InputHlsStreamData(new Uint8Array(a),a.byteLength);case 6:if(!(this.m_seek_sliceList.length>0)){e.n=11;break}return i=this.m_seek_keyList[0],l=this.m_seek_sliceList[0],console.log("[seek slice download]:<".concat(l.epoch_time,"> ").concat(l.path," offset=").concat(i.offset)),e.n=7,new Promise((function(e){v.m_cbAuthorizeInfoCallback(v.m_recordRegionId,l.path,v.m_token,(function(t){v.m_sRealUrl=t,e()}))}));case 7:return u="bytes=".concat(i.offset,"-"),e.n=8,fetch(this.m_sRealUrl,{headers:{Range:u}});case 8:if((c=e.v).ok){e.n=9;break}throw new Error("Download failed, HTTP ".concat(c.status));case 9:return e.n=10,c.arrayBuffer();case 10:s=e.v,this.playsdkInterface.InputHlsStreamData(new Uint8Array(s),s.byteLength);case 11:this.m_seek_keyList=[],this.m_seek_sliceList=[],f=new pt,p=gt().m((function e(){var t,n,r;return gt().w((function(e){for(;;)switch(e.n){case 0:return console.log("[play slice]:<".concat(f.epoch_time,"> ").concat(f.path)),t=f.path,e.n=1,new Promise((function(e){v.m_cbAuthorizeInfoCallback(v.m_recordRegionId,t,v.m_token,(function(t){v.m_sRealUrl=t,e()}))}));case 1:return console.log("After cAuthorizeCallBack"),e.n=2,fetch(v.m_sRealUrl);case 2:if((n=e.v).ok){e.n=3;break}throw new Error("Download failed,download error url[".concat(v.m_sRealUrl,"],HTTP ").concat(n.status));case 3:return e.n=4,n.arrayBuffer();case 4:if(r=e.v,console.log("Finished downloading ".concat(r.byteLength," bytes from URL ").concat(v.m_sRealUrl)),!v._isPaused||!v._resumePromise){e.n=5;break}return e.n=5,v._resumePromise;case 5:v.playsdkInterface.InputHlsStreamData(new Uint8Array(r),r.byteLength);case 6:return e.a(2)}}),e)}));case 12:if(!this.m_m3uParser||!this.m_m3uParser.nextSlice(f)||this.m_abortDownload){e.n=14;break}return e.d(ht(p()),13);case 13:e.n=12;break;case 14:if(!(this.m_m3uParser&&this.m_endTime>0)||this.m_abortDownload){e.n=20;break}if(d=new pt,m=new ft,this.m_m3uParser&&(this.m_m3uParser.getBackSlice(d),this.m_m3uParser.getBackKeypoint(m)),!(m.offset>=0)){e.n=20;break}return h=d.path,console.log("[url play slice]:<".concat(d.epoch_time,"> ").concat(d.path)),e.n=15,new Promise((function(e){v.m_cbAuthorizeInfoCallback(v.m_recordRegionId,h,v.m_token,(function(t){v.m_sRealUrl=t,e()}))}));case 15:return console.log("After cAuthorizeCallBack"),g="bytes=0-".concat(m.offset+m.length-1),e.n=16,fetch(this.m_sRealUrl,{headers:{Range:g}});case 16:if((_=e.v).ok){e.n=17;break}throw new Error("Download failed,download error url[".concat(this.m_sRealUrl,"],HTTP ").concat(_.status));case 17:return e.n=18,_.arrayBuffer();case 18:if(y=e.v,console.log("Finished downloading ".concat(y.byteLength," bytes from URL ").concat(this.m_sRealUrl)),!this._isPaused||!this._resumePromise){e.n=19;break}return e.n=19,this._resumePromise;case 19:this.playsdkInterface.InputHlsStreamData(new Uint8Array(y),y.byteLength);case 20:e.n=22;break;case 21:e.p=21,S=e.v,console.error("Download error:",S),this.playsdkInterface.StreamFinishCallback(),this.m_cur_finish=!0;case 22:return e.p=22,console.log("Download Done!"),0==this.m_bSeek&&(console.log("StreamFinishCallback!"),this.playsdkInterface.StreamFinishCallback()),this.m_cur_finish=!0,e.f(22);case 23:return e.a(2)}}),e,this,[[1,21,22,23]])})))).apply(this,arguments)}function i(e){this.playsdkInterface=e,null==this.m_m3uParser&&(this.m_m3uParser=new dt),this.m_indexDownloaded=!1,this.m_abortDownload=!1,this.m_cur_finish=!1,this.m_bSeek=!1,this._isPaused=!1,this._resumePromise=null,this._resumeResolver=null,this.m_m3uUrl="",this.m_sliceUrlPrefix="",this.m_startTime=0,this.m_seekTime=0,this.m_endTime=0,this.m_timeout=0,this.m_protoType=0,this.m_sToken="",this.m_client="",this.m_iFrameExtractInv=0,this.m_fFrameExtractStartTime=0,this.m_JsonString="",this.m_deviceId="",this.m_channelId="",this.m_recordRegionId="",this.m_recordPath="",this.m_token="",this.m_totalDuration=0,this.m_m3u8_context="",this.m_seek_keyList=[],this.m_seek_sliceList=[],this.m_headers=[],this.m_sRealUrl="",this.m_cbAuthorizeInfoCallback=null}var l;return this.playsdkInterface=t,this.m_abortDownload=!1,this.m_cur_finish=!1,this.m_bSeek=!1,this._isPaused=!1,this._resumePromise=null,this._resumeResolver=null,this.m_m3uUrl="",this.m_sliceUrlPrefix="",this.m_startTime=0,this.m_seekTime=0,this.m_endTime=0,this.m_timeout=0,this.m_protoType=0,this.m_sToken="",this.m_client="",this.m_iFrameExtractInv=0,this.m_fFrameExtractStartTime=0,this.m_JsonString="",this.m_deviceId="",this.m_channelId="",this.m_recordRegionId="",this.m_recordPath="",this.m_token="",this.m_totalDuration=0,this.m_m3u8_context="",this.m_m3uParser=null,this.m_seek_keyList=[],this.m_seek_sliceList=[],this.m_headers=[],this.m_sRealUrl="",this.m_cbAuthorizeInfoCallback=null,i.prototype={Init:function(e){if(console.log("Enter lchls init!"),this.m_m3uUrl=e.m3uUrl,this.m_sliceUrlPrefix=e.sliceUrlPrefix,this.m_startTime=e.startTime,this.m_seekTime=e.seekTime,this.m_endTime=e.endTime,this.m_timeout=e.timeout,this.m_protoType=e.nProtoType,this.m_sToken=e.sToken,this.m_client=e.client,this.m_iFrameExtractInv=e.nFrameExtractInv,this.m_fFrameExtractStartTime=e.fFrameExtractSatrtTime,this.m_JsonString=e.jsonString,!this.m_sliceUrlPrefix&&this.m_m3uUrl){var t=this.m_m3uUrl.lastIndexOf("/");-1!==t&&(this.m_sliceUrlPrefix=this.m_m3uUrl.substring(0,t+1))}if(6!=this.m_protoType)return!1;var n=JSON.parse(this.m_JsonString);return this.m_deviceId=n.deviceId||"",this.m_channelId=n.channelId||"",this.m_recordRegionId=n.recordRegionId||"",this.m_recordPath=n.recordPath||"",this.m_token=n.token||"",!0},GetDuration:function(){return this.m_m3uParser.getDuration()},SetAuthorizeInfoCallback:function(e){this.m_cbAuthorizeInfoCallback=e},Start:function(e){var t=this;console.log("Enter lchls start!"),n.call(this).then((function(e){console.log("Download successful",e),t.m_seekTime>0&&t.Seek(t.m_seekTime),o.call(t).then((function(){console.log("Slice download completed successfully")})).catch((function(e){console.error("Slice download failed:",e)}))})).catch((function(e){console.error("Download failed",e)}))},Stop:function(){console.log("Enter lchls stop!")},Pause:function(){var e=this;console.log("Enter lchls pause!"),this._isPaused=!0,this._resumePromise=new Promise((function(t){e._resumeResolver=t}))},Resume:function(){console.log("Enter lchls resume!"),this._isPaused=!1,this._resumeResolver&&(this._resumeResolver(),this._resumeResolver=null,this._resumePromise=null)},Destroy:function(){console.log("Enter lchls destroy!"),this.m_m3uParser&&(this.m_m3uParser=null),this._resumeResolver&&(this._resumeResolver(),this._resumeResolver=null,this._resumePromise=null),this.m_seek_keyList=[],this.m_seek_sliceList=[],this.m_headers=[],this.m_m3uUrl="",this.m_sliceUrlPrefix="",this.m_sRealUrl="",this.m_JsonString="",this.m_token="",this.m_cbAuthorizeInfoCallback=null},Seek:(l=St(gt().m((function e(t){return gt().w((function(e){for(;;)switch(e.n){case 0:if(this.m_indexDownloaded){e.n=2;break}return e.n=1,new Promise((function(e){return setTimeout(e,1)}));case 1:e.n=0;break;case 2:if(console.log("Enter lchls seek ".concat(t," !")),this.m_seek_keyList=[],this.m_seek_sliceList=[],!this.m_m3uParser||this.m_m3uParser.seekSlice(t,this.m_seek_sliceList,this.m_seek_keyList)){e.n=3;break}return console.error("Seek failed for time:",t),e.a(2,!1);case 3:if(0!==this.m_seek_keyList.length&&0!==this.m_seek_sliceList.length){e.n=4;break}return console.error("No seek results found"),e.a(2,!1);case 4:console.log("Seek success, found ".concat(this.m_seek_keyList.length," keyframes")),this.m_abortDownload=!0,this.m_bSeek=!0;case 5:if(this.m_cur_finish){e.n=7;break}return e.n=6,new Promise((function(e){return setTimeout(e,1)}));case 6:e.n=5;break;case 7:if(this.m_cur_finish){e.n=8;break}return console.error("Seek timeout - current download not finished"),e.a(2,!1);case 8:return this.m_cur_finish=!1,this.m_bSeek=!1,o.call(this).catch((function(e){console.error("Download after seek failed:",e)})),e.a(2,!0)}}),e,this)}))),function(e){return l.apply(this,arguments)})},new i(this.playsdkInterface)};function Pt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,r,o,a){var u=r&&r.prototype instanceof l?r:l,c=Object.create(u.prototype);return bt(c,"_invoke",function(n,r,o){var a,l,u,c=0,s=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return a=t,l=0,u=e,p.n=n,i}};function d(n,r){for(l=n,u=r,t=0;!f&&c&&!o&&t<s.length;t++){var o,a=s[t],d=p.p,m=a[2];n>3?(o=m===r)&&(u=a[(l=a[4])?5:(l=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=n<2&&d<a[1])?(l=0,p.v=r,p.n=a[1]):d<m&&(o=n<3||a[0]>r||r>m)&&(a[4]=n,a[5]=r,p.n=m,l=0))}if(o||n>1)return i;throw f=!0,r}return function(o,s,m){if(c>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,m),l=s,u=m;(t=l<2?e:u)||!f;){a||(l?l<3?(l>1&&(p.n=-1),d(l,u)):p.n=u:p.v=u);try{if(c=2,a){if(l||(o="next"),t=a[o]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,l<2&&(l=0)}else 1===l&&(t=a.return)&&t.call(a),l<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),l=1);a=e}else if((t=(f=p.n<0)?u:n.call(r,p))!==i)break}catch(t){a=e,l=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,o,a),!0),c}var i={};function l(){}function u(){}function c(){}t=Object.getPrototypeOf;var s=[][r]?t(t([][r]())):(bt(t={},r,(function(){return this})),t),f=c.prototype=l.prototype=Object.create(s);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,bt(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,bt(f,"constructor",c),bt(c,"constructor",u),u.displayName="GeneratorFunction",bt(c,o,"GeneratorFunction"),bt(f),bt(f,o,"Generator"),bt(f,r,(function(){return this})),bt(f,"toString",(function(){return"[object Generator]"})),(Pt=function(){return{w:a,m:p}})()}function bt(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}(bt=function(e,t,n,r){if(t)o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n;else{var a=function(t,n){bt(e,t,(function(e){return this._invoke(t,n,e)}))};a("next",0),a("throw",1),a("return",2)}})(e,t,n,r)}function wt(e,t,n,r,o,a,i){try{var l=e[a](i),u=l.value}catch(e){return void n(e)}l.done?t(u):Promise.resolve(u).then(r,o)}function At(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){wt(a,r,o,i,l,"next",e)}function l(e){wt(a,r,o,i,l,"throw",e)}i(void 0)}))}}t.default=function(e){var t,n=new w,r=null,o=!1,a=!1,i=null,l=null,u=null,c=null,s=!1,f=!1,d=!1,m=0,h=!1,g=1,_=!1,y=e,S=0,v=null,P=null,b=0,A=!1,E=1,T=0,I=!1,D=!1,k=!1,C=8,M=0,R=!1,U=0,H={Disconnect:function(){},GetPlayPort:function(){},PlayStart:function(){},DecodeStart:function(){},VideoFrameInfo:function(){},AudioFrameInfo:function(){},RecordTimeStamp:function(){},RecordDataInfo:function(){},GetOriginalKey:function(){},PlayTokenDecryptResult:function(){},DecryptionResult:function(){},PlayBackStreamRange:function(){},StreamPlayOver:function(){},StreamRedirect:function(){},ARTagInfo:function(){},GPSInfo:function(){},CapturePicDataCallBack:function(){},IVSDrawData:function(){},AVTalkDataSendSuccess:function(){},GetLocalSDPInfo:function(){},DemuxData:function(){},ServerUserDefCode:function(){},Error:function(){},AuthorizeInfo:function(){}};function F(){}function L(e,t){for(var o in n.trace("startPullStream url:"+e.strRtspvUrl+", nProtocolType:"+t),I=e.bTalkService,function(){null!==v&&(v.onerror=null);null!==v&&v.readyState===v.OPEN&&(v.close(),v=null)}(),r.SetAudioTalkFlag(e.bTalkService),r.ResetPlayState(),null!=e.bBroadcast&&(D=e.bBroadcast),null==l&&(l=new p,0<U&&l.SetLogLevel(U)),H)l&&l.SetCallback(o,H[o]);var a=e.strRtspvUri;0==(M=null==t?-1!=e.strRtspvUrl.indexOf("rtsp://")?0:1:t)?-1!=e.strRtspvUri.indexOf("?")?e.strRtspvUri+="&rtspoverwebsocket":e.strRtspvUri+="/rtspoverwebsocket":1==M&&(-1!=e.strRtspvUri.indexOf("?")?e.strRtspvUri+="&httpprivateoverwebsocket":e.strRtspvUri+="/httpprivateoverwebsocket");var i=e.nShortTimeout||3,c=e.nRtspResponseTimeout||8;if(C=c,1==M&&-1==e.strRtspvUrl.indexOf("http://")){var s=a.indexOf("://");a=a.slice(s),e.strRtspvUrl="http"+a+e.strRtspvUrl}return e.strSourceId.length>0&&(e.strRtspvUrl+="?sourceId=",e.strRtspvUrl+=e.strSourceId),u=l.StartStream(e,M),l.SetMsgWaitTimeout(i),void 0!==e.nStreamTimeout&&l.SetStreamTimeout(e.nStreamTimeout),r&&r.SetStreamOver(!1),u}function x(){if(n.trace("stopPullStream"),I=!1,u&&(S&&(clearTimeout(S),S=0),l&&(l.StopStream(),l=null,u=null),k=!1),a)return a=!1,r&&r.StopRecord()}function O(e){e!=d&&(d=e,u&&l.PauseStream(e),i&&(1==e?i.Pause():i.Resume()))}function B(e){return V.apply(this,arguments)}function V(){return(V=At(Pt().m((function e(t){var o;return Pt().w((function(e){for(;;)switch(e.n){case 0:if(n.trace("lchls seek"),!i){e.n=2;break}return e.n=1,i.Seek(t);case 1:for(o=1;o<5;o++)r&&r.ResetBuffer(o);case 2:return e.a(2)}}),e)})))).apply(this,arguments)}function G(e){H.GetLocalSDPInfo(e)}function N(){if(!f&&o){setTimeout((function(){r&&(m=r.GetSourceBufferRemain())}),1);var e=0;y||null===r||(e=r.GetVideoBufferSize()),m>7340032||e>70?O(!0):m<2097152&&e<20&&O(!1)}}function W(){N()}function z(e,t){I&&(u&&(n.trace("SendAVTalkData, data length:"+e.length+", dataType:"+t),l.PutStream(e,t)),R||(H.AVTalkDataSendSuccess(),R=!0))}function j(e){if(!A){var t=r.GetOriginalKey(e.data,P,null);if(t.length>0&&-1!==t.indexOf("data")){b&&(clearTimeout(b),b=0),A=!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 c=t.slice(n+5,o),s={strRtspvUri:"wss://"+a+":"+i,strRtspvUrl:"rtsp://"+l+":"+u+"@"+a+":"+i+"/cam/realmonitor?channel="+E+"&subtype="+T+"&proto=Private3",strSourceId:"",strUserName:l,strPassWord:u,strDeviceID:c,bTalkService:I,nRange:0,nShortTimeout:3,nRtspResponseTimeout:8};setTimeout((function(){var e=L(s);H.GetStreamClinetHandle(e)}),1)}}}function Y(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;o<r.length&&0!==r[o];)o++;return n.decode(e.slice(0,o))}return F.prototype={Init:function(e,t){return function(e,t){null!=t&&(E=t.nChannel,T=t.nSubType,I=t.bTalkService);o=e.bPlayBack,null==r&&(r=new Ye(y,n),0<U&&r.setPrintLogLevel(U));var a=r.Init(e);if(a>0){var i=r.GetPlayPort();y&&H.GetPlayPort(i)}for(var u in H)r.setCallback(u,H[u]);r.SetSTFrameCallback(W),null===l&&(l=new p,0<U&&l.SetLogLevel(U));return a}(e,t)},SetCacheMode:function(e){return function(e){return r&&r.SetCacheMode(e)}(e)},StartPullStream:function(e,t){return L(e,t)},SetLoginParam:function(e){!function(e){null==l&&(l=new p);l.SetLoginParam(e)}(e)},StopPullStream:function(){x()},Pause:function(e){!function(e){f=e,O(e),r.Pause(e)}(e)},Stop:function(){!function(){r&&(r.CloseIVSDraw(),r.Stop(),r=null);!1,f=!1}()},SetSecurityKey:function(e,t,n,o,a){return function(e,t,n,o,a){r.SetSecurityKey(e,t,n,o,a)}(e,t,n,o,a)},SetSecurityKeyEx:function(e,t){return function(e,t){r.SetSecurityKeyEx(e,t)}(e,t)},SetSpeed:function(e,t){g=e,void 0!==t&&(_=t),function(e,t){u&&l.PlayControl(-1,-1,e,-1,t);r.SetPlaySpeed(e)}(e,_)},SetSoundState:function(e){!function(e){r.SetSoundState(e)}(e)},SetVolume:function(e){!function(e){r.SetVolume(e)}(e)},SetPureAudio:function(e){!function(e){r.SetPureAudio(e)}(e)},SetInt32:function(e,t){return function(e,t){return r.SetInt32(e,t)}(e,t)},StartRecord:function(e,t,n,o){return function(e,t,n,o){return a=!0,r.StartRecord(e,t,n,o)}(e,t,n,o)},StopRecord:function(){return a=!1,r.StopRecord()},CancelRecord:function(){return a=!1,r.CancelRecord()},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)},IVSSetViewProportion:function(e,t){!function(e,t){r.IVSSetViewProportion(e,t)}(e,t)},IVSIoctl:function(e,t){return function(e,t,n){return r.IVSIoctl(e,t,n)}(e,t)},IVSGeneralConfig:function(e,t){return function(e,t){return r.IVSGeneralConfig(e,t)}(e,t)},SetIvsIotBoxParas:function(e,t,n){return function(e,t,n){return r.SetIvsIotBoxParas(e,t,n)}(e,t,n)},SetIvsIotBoxDisplay:function(e,t,n){return function(e,t,n){return r.SetIvsIotBoxDisplay(e,t,n)}(e,t,n)},SetIvsLanguageEnvi:function(e){!function(e){r.SetIvsLanguageEnvi(e)}(e)},SetPanoAR:function(e,t){return function(e,t){return r.SetPanoAR(e,t)}(e,t)},Set3DPoint:function(e){return function(e){return r.Set3DPoint(e)}(e)},SetRotateType:function(e){return function(e){return r.SetRotateType(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,t){!function(e,t){void 0===t&&(t=8e3);r.setCallback("audioTalk",z),r.StartTalk(e,t)}(e,t)},StopTalk:function(){r.StopTalk(),R=!1},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()},LchlsCreate:function(e){return function(e){n.trace("lchls Create");var t=null;i&&(i=null);(i=new vt(n,e))&&(t=i,i.SetAuthorizeInfoCallback(H.AuthorizeInfo));return t}(e)},LchlsInit:function(e){!function(e){n.trace("lchls Init"),i&&i.Init(e)}(e)},LchlsDestroy:function(){n.trace("lchls Destroy"),i&&(i.Destroy(),i=null)},LchlsStart:function(e){!function(e){n.trace("lchls Start"),i&&i.Start(e)}(e)},LchlsStop:function(){n.trace("lchls Stop"),i&&i.Stop()},LchlsSetAuthorizeDone:function(e,t){!function(e,t){n.trace("lchls SetAuthorizeDone"),i&&i.SetAuthorizeDone(e,t)}(e,t)},LchlsSeek:(t=At(Pt().m((function e(t){return Pt().w((function(e){for(;;)switch(e.n){case 0:return e.n=1,B(t);case 1:return e.a(2)}}),e)}))),function(e){return t.apply(this,arguments)}),RtcOpen:function(e){!function(e){n.trace("rtc Open"),c&&(c.close(),c=null,s=!1);(c=new $e(n))&&(e.srcObject=c.videoStream,e.muted=!1)}(e)},RtcTalk:function(){n.trace("rtc Talk"),c&&(c.getLocalSDPInfoCallBack(G),c.playTalk(s).then((function(e){})).catch((function(e){c&&(c.close(),c=null),s=!1,n.error("rtc error:"+e)})))},RtcSetRemoteSDP:function(e,t){!function(e,t){n.trace("rtc SetRemoteSDP, bRemoteOffer:"+t),c&&(s=!0,c.setRemoteSDP(e,t))}(e,t)},RtcClose:function(){n.trace("rtc Close"),c&&(c.close(),c=null,s=!1)},SetSeekTime:function(e,t,o){!function(e,t,o){n.trace("setSeekTime, nStartTime:"+e+", nEndTime:"+t+", nSourceType:"+o),void 0===t&&(t=-1);u&&l.PlayControl(e,t,g,o,_);for(var a=1;a<5;a++)r&&r.ResetBuffer(a)}(e,t,o)},SetSeekTimeUtc:function(e,t,o){!function(e,t,o){n.trace("setSeekTimeUtc, nStartTime:"+e+", nEndTime:"+t+", nSourceType:"+o),void 0===t&&(t=-1);u&&l.PlayControlUtc(e,t,g,o,_);for(var a=1;a<5;a++)r&&r.ResetBuffer(a)}(e,t,o)},ResetBuffer:function(e){!function(e){r&&r.ResetBuffer(e)}(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 O(t),r.PausePlayGroup(e,t)}(e,t)},SetPlayGroupSpeed:function(e,t,n){return g=t,void 0!==n&&(_=n),function(e,t,n){u&&l.PlayControl(-1,-1,t,-1,n);return r.SetPlayGroupSpeed(e,t)}(e,t,_)},GetSourceBufferRemain:function(){return m=r.GetSourceBufferRemain()},SetDecodeMode:function(e,t){!function(e,t){r.SetDecodeMode(e,t)}(e,t)},SetColor:function(e,t,n,o){!function(e,t,n,o){r.SetColor(e,t,n,o)}(e,t,n,o)},SetDisplayRegion:function(e,t){return function(e,t){return r.SetDisplayRegion(e,t)}(e,t)},SetYUVOSDInfoEx:function(e){!function(e){r.SetYUVOSDInfoEx(e)}(e)},GetOriginalKey:function(e){!function(e){r.GetOriginalKey(e.strPlayToken,e.strPlayTokenKey,e.strDeviceID)}(e)},SetPlayTokenToDecrypt:function(e){!function(e){r.SetPlayTokenToDecrypt(e.strPlayToken,e.strKeySalt,e.strDeviceID)}(e)},SetOriginalKey:function(e,t,n,r,o){return function(e,t,n,r,o){if(null!==l)return l.SetOriginalKey(e,t,n,r,o);return-1}(e,t,n,r,o)},GetCurrentPlayedTime:function(){return r.GetCurrentPlayedTime()},GetCurrentFrameInfo:function(){return r.GetCurrentFrameInfo()},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){P=o,(v=new WebSocket("wss://"+e+":"+t+"/ar/device/detail")).binaryType="arraybuffer",v.addEventListener("message",j,!1),v.onopen=function(){var e='{\n "id":'+n+',\n "token":"'+r+'"\n}';v.send(e),A=!1,function(){b&&(clearTimeout(b),b=0);b=setTimeout((function(){H.Error({errorCode:"408",description:"Device verify failed"})}),5e3)}()},v.onerror=function(e){H.Error({errorCode:205,description:"WebSocket Verify Error"})}}(e,t,n,r,o)},SetCallBack:function(e,t){H[e]=t},SetPrintLogLevel:function(e){!function(e){U=e,n.setPrintLogLevel(e),r&&r.setPrintLogLevel(e),l&&l.SetLogLevel(e)}(e)},SetPlayMethod:function(e,t,n){!function(e,t,n){r&&r.SetPlayMethod(e,t,n)}(e,t,n)},SetAudioPlayMethod:function(e){!function(e){r&&r.SetAudioPlayMethod(e)}(e)},SetPrivacyRecover:function(e){!function(e){null!==r&&(e&&r.SetDecodeMode(!1,!1),r.SetPrivacyRecover(e))}(e)},GetAudioPlayedTime:function(){return function(){if(r)return r.GetAudioPlayedTime();return-1}()},InputDataEx:function(e,t){if(S&&(clearTimeout(S),S=0),o&&!h){h=!0;var a=l.GetPlayInfo();n.trace("PlayBackStreamRange, nStreamRange:"+a),H.PlayBackStreamRange(a)}var i=new ArrayBuffer(t),u=new Uint8Array(i);return u.set(SCModule.HEAPU8.subarray(e,e+t)),r&&r.InputData(u)},InputHlsStreamData:function(e,t){if(o&&!h&&(h=!0,i)){var a=i.GetDuration();n.trace("PlayBackStreamRange, nStreamRange:"+a),H.PlayBackStreamRange(a)}return r&&r.InputData(e)},SetDemuxData:function(e,t,n,o){r&&r.DemuxDataCallBack(e,t,n,o)},SetFrameData:function(e,t,n,o,a,i){r&&(N(),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)},StreamMsgPlay:function(){D||k||(k=!0,S=setTimeout((function(){S&&(clearTimeout(S),S=0),H.Error({errorCode:"409",description:"Rtsp Not Response"})}),1e3*C))},StreamRedirectCallback:function(e){!function(e){x();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<e.length;n++){var r=String.fromCharCode(e[n]);if(t+=r,"\0"==r)break}return t}(n);H.StreamRedirect(r)}(e)},StreamDisconnectCallback:function(){null!==l&&H.Disconnect()},StreamFinishCallback:function(){r&&r.SetStreamOver(!0)},StreamFailedCallback:function(e,t){S&&(clearTimeout(S),S=0),n.trace("StreamFailedCallback, attach:"+e+", type:"+t),l&&l.SetStreamFailedMsg(e,t)},ServerUserDefCodeCallback:function(e){H.ServerUserDefCode({errorCode:e,description:"User-DefCode"})}},window.cAuthorizeCallBack=function(){var e=At(Pt().m((function e(t,n,r,o,a,i){var l,u,c,s,f,p;return Pt().w((function(e){for(;;)switch(e.n){case 0:return l=new ArrayBuffer(n),new Uint8Array(l).set(LchlsModule.HEAPU8.subarray(t,t+n)),u=Y(l),c=new ArrayBuffer(o),new Uint8Array(c).set(LchlsModule.HEAPU8.subarray(r,r+o)),s=Y(c),f=new ArrayBuffer(i),new Uint8Array(f).set(LchlsModule.HEAPU8.subarray(a,a+i)),p=Y(f),e.n=1,H.AuthorizeInfo(u,s,p);case 1:return e.a(2)}}),e)})));return function(t,n,r,o,a,i){return e.apply(this,arguments)}}(),new F}}]).default})); |