!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);n1048576)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>>24&255,o[a++]=t>>>16&255,o[a++]=t>>>8&255,o[a++]=255&t,o.set(e,a),a+=4;for(r=0;r>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),(n=e.config,r=n.length,o=new Uint8Array([0,0,0,0,3,23+r,0,1,0,4,15+r,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([r]).concat(n).concat([6,1,2])),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>>8),l.push(255&n[s].byteLength),l=l.concat(Array.prototype.slice.call(n[s]));for(s=0;s>>8),u.push(255&r[s].byteLength),u=u.concat(Array.prototype.slice.call(r[s]));for(s=0;s>>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>>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>>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<>8-o|1<=0;l--,i++)o|=a(e,i)<0)for(d=w;d<8;d++)u(v,2);for(d=0;d>=1;e+=p(o,0),e+=".",0===n.get("general_tier_flag")?e+="L":e+="H",e+=n.get("general_level_idc");var i=n.get("general_constraint_indicator_flags"),l=[(65280&i)>>>8,(16711680&i)>>>16,(4278190080&i)>>>24,(0xff00000000&i)>>>32,(0xff0000000000&i)>>>40],u=!1,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=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=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=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=512)break;s+=12}O.HEAP32[i/4+1]=c,a=O._DRAW_InputTrackDataEx2(e,t,i,r,o);for(var m=0;m0){_[v]=O._malloc(4*n.pElement[v].pStruct.chCount);for(var P=0;P0){_[v]=O._malloc(4*n.pElement[v].pStruct.chCount);for(P=0;P0&&(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;v0&&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=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;P0;){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;e0)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;o3;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=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;fo&&(o=u)}else{u=o+i;for(f=o;fthis.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>>8*(o-1-a)&255;else for(var i=0;i>>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;re.length)&&(t=e.length);for(var n=0,r=Array(t);nt)return console.error("The dstRate show be smaller than srcRate"),[e,r];for(var o=t/n,a=Math.floor(e.length/o),i=new Float32Array(a),l=0,u=0;l>0]=e.charCodeAt(0),u++}));var 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;e0)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;t65535&&(f=240);a.set(m(f),i),i+=4,f++;var l=m(44+o.length+8);a.set(l,i),i+=4;var 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>>8*(o-1-a)&255;else for(var i=0;i>>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;n999&&(this.m_VideoFrameIndex=0);var t=this.m_WebCodecsVideoFrameScope+this.m_VideoFrameIndex;window.WebCodecsVideoFrameMap.set(t,e),this.m_playMethod&&this.m_playMethod.drawWebCodecs(t,0,this.m_nFrameRate,e.codedWidth,e.codedHeight,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;o2||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>>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=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;h0&&(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;L0&&(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;L0)){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=it)&<.postMessage({type:"addBuffer",buffer:e,offset:n,recordType:ft}),n0;){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>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;o0)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),o1&&void 0!==arguments[1]?arguments[1]:"utf-8",n=new TextDecoder(t),r=new Uint8Array(e),o=0;o=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&&t3?(o=m===r)&&(u=a[(l=a[4])?5:(l=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=n<2&&dr||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=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=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=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=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=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=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&&t3?(o=m===r)&&(u=a[(l=a[4])?5:(l=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=n<2&&dr||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&&t3?(o=m===r)&&(u=a[(l=a[4])?5:(l=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=n<2&&dr||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,00&&(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;o0){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