fuyang-jieshou/public/webs/module/videoWorker.worker.js

1 line
66 KiB
JavaScript

!function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t,r){"use strict";var n=r(1);Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserDetect=function(){var e=navigator.userAgent.toLowerCase(),t=navigator.appName,r=null;"Microsoft Internet Explorer"===t||e.indexOf("trident")>-1||e.indexOf("edge/")>-1?(r="ie","Microsoft Internet Explorer"===t?(e=/msie ([0-9]{1,}[\.0-9]{0,})/.exec(e),r+=parseInt(e[1])):e.indexOf("trident")>-1?r+=11:e.indexOf("edge/")>-1&&(r="edge")):e.indexOf("safari")>-1?r=e.indexOf("chrome")>-1?"chrome":"safari":e.indexOf("firefox")>-1&&(r="firefox");return r},t.CommonAudioUtil=function(){var e=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384],t=function(e,t,r){var n=0,a=0;for(n=0;n<r&&!(e<t[a]);n++)a++;return n},r=function(r,n){var a=0,i=0,o=0,u=0,s=0;return i=t(a=r>0?r:8191&-r,e,15)-6,o=i+(n>>6&15)-13,u=(0===a?32:i>=0?a>>i:a<<-i)*(n&parseInt("077",8))+48>>4,s=o>=0?u<<o&32767:u>>-o,(r^n)<0?-s:s};this.g726InitState=function(){var e={},t=0;for(e.pp=new Array(2),e.zp=new Array(6),e.pk=new Array(2),e.dq=new Array(6),e.sr=new Array(2),e.yl=34816,e.yu=544,e.dms=0,e.dml=0,e.ppp=0,t=0;t<2;t++)e.pp[t]=0,e.pk[t]=0,e.sr[t]=32;for(t=0;t<6;t++)e.zp[t]=0,e.dq[t]=32;return e.td=0,e},this.predictorZero=function(e){var t=0,n=0;for(n=r(e.zp[0]>>2,e.dq[0]),t=1;t<6;t++)n+=r(e.zp[t]>>2,e.dq[t]);return n},this.predictorPole=function(e){return r(e.pp[1]>>2,e.sr[1])+r(e.pp[0]>>2,e.sr[0])},this.stepSize=function(e){var t=0,r=0,n=0;return e.ppp>=256?e.yu:(t=e.yl>>6,r=e.yu-t,n=e.ppp>>2,r>0?t+=r*n>>6:r<0&&(t+=r*n+63>>6),t)},this.quantize=function(r,n,a,i){var o=0,u=0,s=0;return o=Math.abs(r),u=t(o>>1,e,15),s=t((u<<7)+(o<<7>>u&127)-(n>>2),a,i),r<0?1+(i<<1)-s:0===s?1+(i<<1):s},this.reconstruct=function(e,t,r){var n=0,a=0;return(n=t+(r>>2))<0?e?-32768:0:(a=128+(127&n)<<7>>14-(n>>7&15),e?a-32768:a)},this.update=function(r,n,a,i,o,u,s,f){var l=0,c=0,p=0,d=0,m=0,_=0,h=0,g=0,v=0,y=0,b=0,D=0,S=0,w=0;if(w=s<0?1:0,c=32767&o,v=f.yl>>15,D=f.yl>>10&31,S=32+D<<v,b=(y=v>9?31744:S)+(y>>1)>>1,g=0===f.td?0:c<=b?0:1,f.yu=n+(a-n>>5),f.yu<544?f.yu=544:f.yu>5120&&(f.yu=5120),f.yl+=f.yu+(-f.yl>>6),1===g)f.pp[0]=0,f.pp[1]=0,f.zp[0]=0,f.zp[1]=0,f.zp[2]=0,f.zp[3]=0,f.zp[4]=0,f.zp[5]=0,d=0;else for(_=w^f.pk[0],d=f.pp[1]-(f.pp[1]>>7),0!==s&&((h=_?f.pp[0]:-f.pp[0])<-8191?d-=256:d+=h>8191?255:h>>5,w^f.pk[1]?d<=-12160?d=-12288:d>=12416?d=12288:d-=128:d<=-12416?d=-12288:d>=12160?d=12288:d+=128),f.pp[1]=d,f.pp[0]-=f.pp[0]>>8,0!==s&&(0===_?f.pp[0]+=192:f.pp[0]-=192),m=15360-d,f.pp[0]<-m?f.pp[0]=-m:f.pp[0]>m&&(f.pp[0]=m),l=0;l<6;l++)f.zp[l]-=5===r?f.zp[l]>>9:f.zp[l]>>8,32767&o&&((o^f.dq[l])>=0?f.zp[l]+=128:f.zp[l]-=128);for(l=5;l>0;l--)f.dq[l]=f.dq[l-1];return 0===c?f.dq[0]=o>=0?32:64544:(p=t(c,e,15),f.dq[0]=o>=0?(p<<6)+(c<<6>>p):(p<<6)+(c<<6>>p)-1024),f.sr[1]=f.sr[0],0===u?f.sr[0]=32:u>0?(p=t(u,e,15),f.sr[0]=(p<<6)+(u<<6>>p)):u>-32768?(p=t(c=-u,e,15),f.sr[0]=(p<<6)+(c<<6>>p)-1024):f.sr[0]=64544,f.pk[1]=f.pk[0],f.pk[0]=w,f.td=1===g?0:d<-11776?1:0,f.dms+=i-f.dms>>5,f.dml+=(i<<2)-f.dml>>7,1===g?f.ppp=256:n<1536?f.ppp+=512-f.ppp>>4:1===f.td?f.ppp+=512-f.ppp>>4:Math.abs((f.dms<<2)-f.dml)>=f.dml>>3?f.ppp+=512-f.ppp>>4:f.ppp+=-f.ppp>>4,f}},t.Texture=t.Shader=t.Script=t.Queue=t.Program=void 0,t.VideoBufferList=function(){var e=0,t=0,r=null;function n(){e=360,t=240,r=null,this._length=0,this.head=null,this.tail=null,this.curIdx=0}return n.prototype={push:function(e,n,a,i,o,u){var s=new VideoBufferNode(e,n,a,i,o,u);return this._length>0?(this.tail.next=s,s.previous=this.tail,this.tail=s):(this.head=s,this.tail=s),this._length+=1,null!==r&&this._length>=t&&r(),s},pop:function(){var e=null;return this._length>1&&(e=this.head,this.head=this.head.next,null!==this.head?this.head.previous=null:this.tail=null,this._length-=1),e},setMaxLength:function(t){(e=t)>360?e=360:e<30&&(e=30)},setBUFFERING:function(e){(t=e)>240?t=240:t<6&&(t=6)},setBufferFullCallback:function(e){r=e},searchTimestamp:function(e){var t=this.head,r=this._length,n=1;if(0===r||e<=0||null===t)throw new Error("Failure: non-existent node in this list.");for(;null!==t&&(t.timeStamp.timestamp!==e.timestamp||t.timeStamp.timestamp_usec!==e.timestamp_usec);)t=t.next,n++;return r<n?t=null:this.curIdx=n,t},findIFrame:function(e){var t=this.head,r=this._length,n=1;if(0===r)throw new Error("Failure: non-existent node in this list.");for(;n<this.curIdx;)t=t.next,n++;if(!0===e)for(;"I"!==t.frameType;)t=t.next,n++;else for(;"I"!==t.frameType;)t=t.previous,n--;return r<n?t=null:this.curIdx=n,t}},new n},t.debug=void 0,t.formAuthorizationResponse=function(e,t,r,n,a,i){var u=null,s=null;return u=(0,o.default)(e+":"+n+":"+t).toLowerCase(),s=(0,o.default)(i+":"+r).toLowerCase(),(0,o.default)(u+":"+a+":"+s).toLowerCase()},t.stringToUint8Array=function(e){for(var t=e.length,r=new Uint8Array(new ArrayBuffer(t)),n=0;n<t;n++)r[n]=e.charCodeAt(n);return r};var a=n(r(6)),i=n(r(7)),o=n(r(10));t.debug={log:function(){},error:function(){},count:function(){},info:function(){}};t.Script=function(){function e(){}return e.createFromElementId=function(t){for(var r=document.getElementById(t),n="",a=r.firstChild;a;)3===a.nodeType&&(n+=a.textContent),a=a.nextSibling;var i=new e;return i.type=r.type,i.source=n,i},e.createFromSource=function(t,r){var n=new e;return n.type=t,n.source=r,n},e}(),t.Shader=function(){return function(e,t){if("x-shader/x-fragment"===t.type)this.shader=e.createShader(e.FRAGMENT_SHADER);else{if("x-shader/x-vertex"!==t.type)return void error("Unknown shader type: "+t.type);this.shader=e.createShader(e.VERTEX_SHADER)}e.shaderSource(this.shader,t.source),e.compileShader(this.shader),e.getShaderParameter(this.shader,e.COMPILE_STATUS)||error("An error occurred compiling the shaders: "+e.getShaderInfoLog(this.shader))}}(),t.Program=function(){function e(e){this.gl=e,this.program=this.gl.createProgram()}return e.prototype={attach:function(e){this.gl.attachShader(this.program,e.shader)},link:function(){this.gl.linkProgram(this.program)},use:function(){this.gl.useProgram(this.program)},getAttributeLocation:function(e){return this.gl.getAttribLocation(this.program,e)},setMatrixUniform:function(e,t){var r=this.gl.getUniformLocation(this.program,e);this.gl.uniformMatrix4fv(r,!1,t)}},e}(),t.Texture=function(){var e=null;function t(e,t,r){this.gl=e,this.size=t,this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),this.format=r||e.LUMINANCE,e.texImage2D(e.TEXTURE_2D,0,this.format,t.w,t.h,0,this.format,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}return t.prototype={fill:function(e,t){var r=this.gl;r.bindTexture(r.TEXTURE_2D,this.texture),t?r.texSubImage2D(r.TEXTURE_2D,0,0,0,this.size.w,this.size.h,this.format,r.UNSIGNED_BYTE,e):r.texImage2D(r.TEXTURE_2D,0,this.format,this.size.w,this.size.h,0,this.format,r.UNSIGNED_BYTE,e)},bind:function(t,r,n){var a=this.gl;e||(e=[a.TEXTURE0,a.TEXTURE1,a.TEXTURE2]),a.activeTexture(e[t]),a.bindTexture(a.TEXTURE_2D,this.texture),a.uniform1i(a.getUniformLocation(r.program,n),t)}},t}();t.Queue=function(){function e(){(0,a.default)(this,e),this.first=null,this.size=0}return(0,i.default)(e,[{key:"enqueue",value:function(e){if(null===this.first)this.first=e;else{for(var t=this.first;null!==t.next;)t=t.next;t.next=e}this.size+=1}},{key:"dequeue",value:function(){var e=null;return null!==this.first&&(e=this.first,this.first=this.first.next,this.size-=1),e}},{key:"clear",value:function(){this.size=0,this.first=null}}]),e}()},function(e,t){e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(){this.map={}};n.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}};t.default=n},function(e,t,r){"use strict";var n=r(1),a=n(r(5)),i=n(r(13)),o=n(r(15)),u=n(r(17)),s=r(0);importScripts("/module/libDecodeSDK.js"),addEventListener("message",function(e){var t=e.data;switch(b=e.data.channelId,t.type){case"sdpInfo":l=t.data,0,function(e){f=[],m=!1;for(var t=0;t<e.sdpInfo.length;t++)c=null,p=e.decodeMode,"H264"===e.sdpInfo[t].codecName||"RAW"===e.sdpInfo[t].codecName&&e.mp4Codec&&"H264"===e.mp4Codec.VideoCodec?(null===h&&(h=(0,a.default)()),(c=h).init(e.decodeMode),c.setFramerate(e.sdpInfo[t].Framerate),c.setGovLength(e.govLength),c.setCheckDelay(e.checkDelay),c.setLessRate(e.lessRateCanvas)):"H265"===e.sdpInfo[t].codecName||"RAW"===e.sdpInfo[t].codecName&&e.mp4Codec&&"H265"===e.mp4Codec.VideoCodec?(null===g&&(g=(0,i.default)()),(c=g).init(),c.setFramerate(e.sdpInfo[t].Framerate),c.setGovLength(e.govLength),c.setCheckDelay(e.checkDelay)):"JPEG"===e.sdpInfo[t].codecName?(null===v&&(v=(0,o.default)()),(c=v).init(),c.setFramerate(e.sdpInfo[t].Framerate)):"stream-assist-frame"===e.sdpInfo[t].codecName&&(s.debug.log(e.sdpInfo[t]),null===y&&(y=(0,u.default)()),(c=y).init()),"undefined"!==typeof e.sdpInfo[t].Framerate&&e.sdpInfo[t].Framerate,null!==c&&(c.setBufferfullCallback(S),c.setReturnCallback(w),_=e.sdpInfo[t].RtpInterlevedID,f[_]=c)}(l);break;case"MediaData":if(!0===m){!function(e){_=e.data.rtspInterleave[1],"undefined"!==typeof f[_]&&f[_].bufferingRtpData(e.data.rtspInterleave,e.data.header,e.data.payload)}(t);break}_=t.data.rtspInterleave[1],"undefined"!==typeof f[_]&&f[_].parseRTPData(t.data.rtspInterleave,t.data.payload,d,D,t.info,t.channel);break;case"initStartTime":f[_].initStartTime();break;case"end":T("end")}},!1),Module.onRuntimeInitialized=function(){Module._DECODE_Init(),T("WorkerReady")};var f=[],l=null,c=null,p="",d=!1,m=!1,_=-1,h=null,g=null,v=null,y=null,b=null,D=1;function S(){f[_].findCurrent(),T("stepPlay","BufferFull")}function w(e){var t=null;if(null===e||"undefined"===typeof e)return t=null,void null;if("undefined"!==typeof e.error?(T("error",e.error),t=e.decodedData):(t=e.decodedData,null!==e.decodeMode&&"undefined"!==typeof e.decodeMode&&(p=e.decodeMode,T("setVideoTagMode",e.decodeMode))),null!=e.decodeStart&&(T("DecodeStart",e.decodeStart),p=e.decodeStart.decodeMode),null!==t&&"undefined"!==typeof t)if(void 0!==t.frameData&&null!==t.frameData&&"canvas"===p){!0===t.frameData.firstFrame&&T("firstFrame",t.frameData.firstFrame);var r={bufferIdx:t.frameData.bufferIdx,width:t.frameData.width,height:t.frameData.height,codecType:t.frameData.codecType,frameType:t.frameData.frameType,timeStamp:null,frameIndex:t.frameData.frameIndex};null!==t.timeStamp&&"undefined"!==typeof t.timeStamp&&(r.timeStamp=t.timeStamp),T("videoInfo",r),"undefined"!==typeof t.frameData.data&&null!==t.frameData.data&&T("canvasRender",t.frameData.data,t.frameData.option)}else if(null!==t.frameData&&"video"===p){null!==t.initSegmentData&&(T("codecInfo",t.codecInfo),T("initSegment",t.initSegmentData));r={codecType:t.frameData.codecType,frameIndex:t.frameData.frameIndex};"undefined"!==typeof t.frameData.width&&(r.width=t.frameData.width,r.height=t.frameData.height),T("videoInfo",r),T("videoTimeStamp",t.timeStamp),t.frameData.length>0&&(T("mediaSample",t.mediaSample),T("videoRender",t.frameData))}else T("drop",e.decodedData);null!=e.resolution&&T("MSEResolutionChanged",e.resolution),null!=e.ivsDraw&&T("ivsDraw",e)}function T(e,t,r){var n={type:e,data:t,channelId:b,option:r};"canvasRender"===e?postMessage(n,[t.buffer]):postMessage(n)}},function(e,t,r){"use strict";var n=r(1);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=r(0),i=n(r(11)),o=n(r(12)),u=n(r(3));function s(){var e=7,t=7,r=2,n=3,a=4,i=5,o=8,s=16,f=32,l=255,c=0,p=null;function d(){c=0,p=new u.default}function m(r,a){var i=a,o=c+i>>n;return i=c+a&e,r[o]>>t-(i&t)&1}function _(e,t){var r=c>>n,a=8*(r+1)-c;if(a<8)for(var i=0;i<3;i++){var o=e[r+i];o=0==i?o>>a<<a:2==i?o&255>>8-a|1<<a:0,e.set([o],r+i)}else e.set([0],r),e.set([1],r+1)}function h(e,t){var r=0;if(1===t)r=m(e,0);else for(var n=0;n<t;n++)r=(r<<1)+m(e,n);return c+=t,r}function g(e,t){for(var n=0,a=0,i=t;c+i<8*e.length&&!m(e,i++);)n++;if(0===n)return c+=1,0;a=1<<n;for(var o=n-1;o>=0;o--,i++)a|=m(e,i)<<o;return c+=n*r+1,a-1}function v(e,t){var n=g(e,t);return 1&n?(n+1)/r:-n/r}function y(e){p.put("cpb_cnt_minus1",g(e,0)),p.put("bit_rate_scale",h(e,a)),p.put("cpb_size_scale",h(e,a));for(var t=p.get("cpb_cnt_minus1"),r=new Array(t),n=new Array(t),o=new Array(t),u=0;u<=t;u++)r[u]=g(e,0),n[u]=g(e,0),o[u]=h(e,1);p.put("bit_rate_value_minus1",r),p.put("cpb_size_value_minus1",n),p.put("cbr_flag",o),p.put("initial_cpb_removal_delay_length_minus1",h(e,i)),p.put("cpb_removal_delay_length_minus1",h(e,i)),p.put("dpb_output_delay_length_minus1",h(e,i)),p.put("time_offset_length",h(e,i))}return d.prototype={parse:function(e){c=0,p.clear(),p.put("forbidden_zero_bit",h(e,1)),p.put("nal_ref_idc",h(e,r)),p.put("nal_unit_type",h(e,i)),p.put("profile_idc",h(e,o)),p.put("profile_compatibility",h(e,o)),p.put("level_idc",h(e,o)),p.put("seq_parameter_set_id",g(e,0));var t=p.get("profile_idc");if((100===t||110===t||122===t||244===t||44===t||83===t||86===t||118===t||128===t||138===t||139===t||134===t)&&(p.put("chroma_format_idc",g(e,0)),p.get("chroma_format_idc")===n&&p.put("separate_colour_plane_flag",h(e,1)),p.put("bit_depth_luma_minus8",g(e,0)),p.put("bit_depth_chroma_minus8",g(e,0)),p.put("qpprime_y_zero_transform_bypass_flag",h(e,1)),p.put("seq_scaling_matrix_present_flag",h(e,1)),p.get("seq_scaling_matrix_present_flag"))){for(var a=p.get("chroma_format_idc")!==n?o:12,u=new Array(a),d=0;d<a;d++)if(u[d]=h(e,1),u[d])for(var m=d<6?s:64,b=8,D=8,S=0;S<m;S++)D&&(D=(b+v(e,0)+256)%256),b=0===D?b:D;p.put("seq_scaling_list_present_flag",u)}if(p.put("log2_max_frame_num_minus4",g(e,0)),p.put("pic_order_cnt_type",g(e,0)),0===p.get("pic_order_cnt_type"))p.put("log2_max_pic_order_cnt_lsb_minus4",g(e,0));else if(1===p.get("pic_order_cnt_type")){p.put("delta_pic_order_always_zero_flag",h(e,1)),p.put("offset_for_non_ref_pic",v(e,0)),p.put("offset_for_top_to_bottom_field",v(e,0)),p.put("num_ref_frames_in_pic_order_cnt_cycle",g(e,0));for(var w=0;w<p.get("num_ref_frames_in_pic_order_cnt_cycle");w++)p.put("num_ref_frames_in_pic_order_cnt_cycle",v(e,0))}return p.put("num_ref_frames",g(e,0)),p.put("gaps_in_frame_num_value_allowed_flag",h(e,1)),p.put("pic_width_in_mbs_minus1",g(e,0)),p.put("pic_height_in_map_units_minus1",g(e,0)),p.put("frame_mbs_only_flag",h(e,1)),0===p.get("frame_mbs_only_flag")&&p.put("mb_adaptive_frame_field_flag",h(e,1)),p.put("direct_8x8_interence_flag",h(e,1)),p.put("frame_cropping_flag",h(e,1)),1===p.get("frame_cropping_flag")&&(p.put("frame_cropping_rect_left_offset",g(e,0)),p.put("frame_cropping_rect_right_offset",g(e,0)),p.put("frame_cropping_rect_top_offset",g(e,0)),p.put("frame_cropping_rect_bottom_offset",g(e,0))),p.put("vui_parameters_present_flag",h(e,1)),p.get("vui_parameters_present_flag")&&function(e){p.put("aspect_ratio_info_present_flag",h(e,1)),p.get("aspect_ratio_info_present_flag")&&(p.put("aspect_ratio_idc",h(e,o)),p.get("aspect_ratio_idc")===l&&(_(e),p.put("sar_width",h(e,s)),_(e),p.put("sar_height",h(e,s)))),p.put("overscan_info_present_flag",h(e,1)),p.get("overscan_info_present_flag")&&p.put("overscan_appropriate_flag",h(e,1)),p.put("video_signal_type_present_flag",h(e,1)),p.get("video_signal_type_present_flag")&&(p.put("video_format",h(e,n)),p.put("video_full_range_flag",h(e,1)),p.put("colour_description_present_flag",h(e,1)),p.get("colour_description_present_flag")&&(p.put("colour_primaries",h(e,o)),p.put("transfer_characteristics",h(e,o)),p.put("matrix_coefficients",h(e,o)))),p.put("chroma_loc_info_present_flag",h(e,1)),p.get("chroma_loc_info_present_flag")&&(p.put("chroma_sample_loc_type_top_field",g(e,0)),p.put("chroma_sample_loc_type_bottom_field",g(e,0))),p.put("timing_info_present_flag",h(e,1)),p.get("timing_info_present_flag")&&(p.put("num_units_in_tick",h(e,f)),p.put("time_scale",h(e,f)),p.put("fixed_frame_rate_flag",h(e,1))),p.put("nal_hrd_parameters_present_flag",h(e,1)),p.get("nal_hrd_parameters_present_flag")&&y(e),p.put("vcl_hrd_parameters_present_flag",h(e,1)),p.get("vcl_hrd_parameters_present_flag")&&y(e),(p.get("nal_hrd_parameters_present_flag")||p.get("vcl_hrd_parameters_present_flag"))&&p.put("low_delay_hrd_flag",h(e,1)),p.put("pic_struct_present_flag",h(e,1)),p.put("bitstream_restriction_flag",h(e,1)),p.get("bitstream_restriction_flag")&&(p.put("motion_vectors_over_pic_boundaries_flag",h(e,1)),p.put("max_bytes_per_pic_denom",g(e,0)),p.put("max_bits_per_mb_denom",g(e,0)))}(e),!0},getSizeInfo:function(){var e=0,t=0;0===p.get("chroma_format_idc")?e=t=0:1===p.get("chroma_format_idc")?e=t=r:p.get("chroma_format_idc")===r?(e=r,t=1):p.get("chroma_format_idc")===n&&(0===p.get("separate_colour_plane_flag")?e=t=1:1===p.get("separate_colour_plane_flag")&&(e=t=0));var a=p.get("pic_width_in_mbs_minus1")+1,i=p.get("pic_height_in_map_units_minus1")+1,o=(r-p.get("frame_mbs_only_flag"))*i,u=0,f=0,l=0,c=0;1===p.get("frame_cropping_flag")&&(u=p.get("frame_cropping_rect_left_offset"),f=p.get("frame_cropping_rect_right_offset"),l=p.get("frame_cropping_rect_top_offset"),c=p.get("frame_cropping_rect_bottom_offset"));var d=a*s*(o*s);return{width:a*s-e*(u+f),height:o*s-t*(r-p.get("frame_mbs_only_flag"))*(l+c),decodeSize:d}},getSpsValue:function(e){return p.get(e)},getCodecInfo:function(){return p.get("profile_idc").toString(s)+(p.get("profile_compatibility")<15?"0"+p.get("profile_compatibility").toString(s):p.get("profile_compatibility").toString(s))+p.get("level_idc").toString(s)}},new d}t.default=function(){var e=0,t=0,r=!1,n=(new Uint8Array(1048576),new Uint8Array(["0x00","0x00","0x00","0x01"]),new s),u=0,f=null,l=null,c=0,p=!1,d=0,m={frameData:null,timeStamp:null,initSegmentData:null,mediaSample:null,dropPercent:0,dropCount:0,codecInfo:"",playback:!1},_={timestamp:null,timezone:null},h={},g=null,v=null,y=!1,b=!1,D=0,S=0,w=0,T=0,C=!1,M=0,x=null,I=null,A="",F=null,k=0,E=0,P={width:0,height:0},U=null,L=!1;function O(e){e!==A&&("video"===e?A="video":(A="canvas",p=!0,d=0,m.frameData.firstFrame=!0))}function B(e,t,r){var n="";return e*t>921600&&!1===r?(n="video",L&&k>0&&k<=3&&(n="canvas")):n="canvas",n}function R(){this.decoder=new i.default,this.firstDiffTime=0,this.firstTime=0,this.lastMSW=0}return R.prototype={setReturnCallback:function(e){this.rtpReturnCallback=e},setBufferfullCallback:function(e){null!==this.videoBufferList&&this.videoBufferList.setBufferFullCallback(e)},getVideoBuffer:function(e){if(null!==this.videoBufferList)return this.videoBufferList.searchNodeAt(e)},clearBuffer:function(){null!==this.videoBufferList&&this.videoBufferList.clear()},findCurrent:function(){null!==this.videoBufferList&&this.videoBufferList.searchTimestamp(this.getTimeStamp())},setTimeStamp:function(e){this.timeData=e},getTimeStamp:function(){return this.timeData},ntohl:function(e){return(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3]>>>0},appendBuffer:function(e,t,r){if(r+t.length>=e.length){var n=new Uint8Array(e.length+1048576);n.set(e,0),e=n}return e.set(t,r),e},getFramerate:function(){return k},setGovLength:function(e){F=e},getGovLength:function(){return F},setDecodingTime:function(e){this.decodingTime=e},getDropPercent:function(){return 0},getDropCount:function(){return 0},initStartTime:function(){this.firstDiffTime=0,this.calcGov=0},setCheckDelay:function(e){this.checkDelay=e},init:function(e){y=!1,r=!1,A=e,this.decoder.setIsFirstFrame(!1),this.videoBufferList=new a.VideoBufferList,this.firstDiffTime=0,this.checkDelay=!0,this.timeData=null},setFramerate:function(e){0<e&&"undefined"!==typeof e&&(k=e,null!==this.videoBufferList&&(this.videoBufferList.setMaxLength(6*k),this.videoBufferList.setBUFFERING(4*k)))},parseRTPData:function(i,s,F,k,L){var R,z=null,j={},N=(s[19]<<24)+(s[18]<<16)+(s[17]<<8)+s[16]>>>0;R=N>>26===0?"2000":"20"+(N>>26);var H=Date.UTC(R,(N>>22&15)-1,N>>17&31,N>>12&31,N>>6&63,63&N)/1e3;if(L.timeStampmsw,H+=(new Date).getTimezoneOffset()/60*3600,A||253!==s[4]||(U=0!==s[5],A=B(L.width,L.height,U)),""!==A){if(0==this.firstTime)this.firstTime=H,this.lastMSW=0,I=(s[21]<<8)+s[20],_={timestamp:this.firstTime,timestamp_usec:0};else{var G,V=(s[21]<<8)+s[20];G=V>I?V-I:V+65535-I,this.lastMSW+=G,H>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=H,_={timestamp:H,timestamp_usec:this.lastMSW},I=V}0!==this.getFramerate()&&"undefined"!==typeof this.getFramerate()||"undefined"===typeof this.getTimeStamp()||(this.setFramerate(Math.round(1e3/((_.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(_.timestamp_usec-this.getTimeStamp().timestamp_usec)))),a.debug.log("setFramerate"+Math.round(1e3/((_.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(_.timestamp_usec-this.getTimeStamp().timestamp_usec))))),this.setTimeStamp(_);for(var W=s[22],X=s.subarray(24+W,s.length-8),q=s.subarray(s.length-8,s.length),J=(q[7],q[6],q[5],q[4],[]),Y=0;Y<=X.length;)if(0==X[Y])if(0==X[Y+1])if(1==X[Y+2]){if(J.push(Y),5==(31&X[Y+=3])||1==(31&X[Y]))break}else 0==X[Y+2]?Y++:Y+=3;else Y+=2;else Y+=1;var Z="P";e=(s[21]<<8)+s[20];var K=0;for(Y=0;Y<J.length;Y++)switch(z=X.subarray(J[Y]+3,J[Y+1]),31&X[J[Y]+3]){default:break;case 1:Z="P",K=J[Y]-1;break;case 5:Z="I",K=J[Y]-1;break;case 28:break;case 7:n.parse(z);var Q=L;u=n.getSizeInfo().decodeSize,null!==f&&null!==l&&f.width===Q.width&&f.height===Q.height&&l===n.getCodecInfo()||(y=!1,f=Q,l=n.getCodecInfo(),this.decoder.setIsFirstFrame(!1)),w=D=Q.width,T=S=Q.height,g=z,P.width==Q.width&&P.height==Q.height||(0!=P.width?(P.width=Q.width,P.height=Q.height,j.resolution=P,j.resolution.decodeMode=B(P.width,P.height,U),j.resolution.encodeMode="h264"):(P.width=Q.width,P.height=Q.height,j.decodeStart=P,j.decodeStart.decodeMode=A,j.decodeStart.encodeMode="h264"));break;case 8:v=z;break;case 6:case 9:}if(F&&!1===p&&(j.backupData={stream:new Uint8Array(X),frameType:Z,width:w,height:T,codecType:"h264"},null!==_.timestamp&&"undefined"!==typeof _.timestamp?j.backupData.timestamp_usec=_.timestamp_usec:j.backupData.timestamp=(e/90).toFixed(0)),"canvas"===A){var $=1e3*_.timestamp+_.timestamp_usec;if(0==this.firstDiffTime?(c=0,this.firstDiffTime=Date.now()-$,a.debug.log("firstDiff: "+E)):($-x<0&&(this.firstDiffTime=c+(Date.now()-$).toFixed(0)),(c=Date.now()-$-this.firstDiffTime)<0&&(this.firstDiffTime=0,c=0),c>8e3&&(j.error={errorCode:101},this.rtpReturnCallback(j))),x=$,t!==u&&(this.decoder.free(),t=u,this.decoder.setOutputSize(t)),!0===p&&"P"===Z)return;!0===p&&(p=!1),"I"===Z&&d<2&&d++,m.frameData=null,!0===F&&!0===r||(m.frameData=this.decoder.decode(s)),m.timeStamp=null,_=null===_.timestamp?this.getTimeStamp():_,m.timeStamp=_}else{var ee=null;if(y?m.initSegmentData=null:(y=!0,L={id:1,width:D,height:S,type:"video",profileIdc:n.getSpsValue("profile_idc"),profileCompatibility:0,levelIdc:n.getSpsValue("level_idc"),sps:[g],pps:[v],timescale:1e3,fps:this.getFramerate()},a.debug.log(JSON.stringify(L)),m.initSegmentData=o.default.initSegment(L),m.codecInfo=n.getCodecInfo()),K||a.debug.log("11111111111111111111111111111111111111111"),"I"===Z){var te=K;ee=X.subarray(te,X.length)}else ee=X.subarray(K,X.length);var re=ee.length-4;ee[0]=(4278190080&re)>>>24,ee[1]=(16711680&re)>>>16,ee[2]=(65280&re)>>>8,ee[3]=255&re;var ne=this.getFramerate(),ae={duration:Math.round(1/ne*1e3),size:ee.length,frame_time_stamp:null,frameDuration:null};if(r)ae.frame_time_stamp=e,m.frameData=new Uint8Array(ee),m.mediaSample=ae;else{if(!1===F){if(ae.frame_time_stamp=1e3*_.timestamp+_.timestamp_usec-E,!1===b)ae.frame_time_stamp=0,E=1e3*_.timestamp+_.timestamp_usec,ae.frameDuration=0,h=ae,b=!0;else{var ie=h.frame_time_stamp,oe=ae.frame_time_stamp;ae.frameDuration=Math.abs(oe-ie),ae.frameDuration>3e3&&(ae.frameDuration=0),h=ae}m.frameData=new Uint8Array(ee),m.mediaSample=ae}_=null===_.timestamp?this.getTimeStamp():_,m.timeStamp=_}}var ue=w*T;if(!0===r&&(NaN.toFixed(0),ue>786432?(O("video"),j.decodeMode="video"):(O("canvas"),j.decodeMode="canvas")),m.playback=r,m.frameData.frameIndex=L.frameIndex,j.decodedData=m,!0===C)return"I"===Z&&M++,2===M&&(M=0,C=!1),void a.debug.info("H264Session::stop");this.rtpReturnCallback(j)}},findIFrame:function(){if(null!==this.videoBufferList){var e=this.videoBufferList.findIFrame();if(null===e||"undefined"===typeof e)return!1;var t={};return this.setTimeStamp(e.timeStamp),t.frameData=this.decoder.decode(e.buffer),t.timeStamp=e.timeStamp,t}},setInitSegment:function(){y=!1,f=null,l=null},setLessRate:function(e){L=e}},new R}},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(8);function a(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,n(a.key),a)}}e.exports=function(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(2).default,a=r(9);e.exports=function(e){var t=a(e,"string");return"symbol"==n(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(2).default;e.exports=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";var n=r(1);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=n(r(2));if("undefined"==typeof i)var i={};i.MD5=function(e){function t(e){var t=(e>>>0).toString(16);return"00000000".substr(0,8-t.length)+t}function r(e,t,r){return e&t|~e&r}function n(e,t,r){return r&e|~r&t}function i(e,t,r){return e^t^r}function o(e,t,r){return t^(e|~r)}function u(e,t){return e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function s(e){for(var t=[],r=0;r<e.length;r++)if(e.charCodeAt(r)<=127)t.push(e.charCodeAt(r));else for(var n=encodeURIComponent(e.charAt(r)).substr(1).split("%"),a=0;a<n.length;a++)t.push(parseInt(n[a],16));return t}function f(e){for(var t=new Array(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}var l=null,c=null;function p(e,t){return 4294967295&e+t}return"string"==typeof e?l=s(e):e.constructor==Array?0===e.length?l=e:"string"==typeof e[0]?l=function(e){for(var t=[],r=0;r<e.length;r++)t=t.concat(s(e[r]));return t}(e):"number"==typeof e[0]?l=e:c=(0,a.default)(e[0]):"undefined"!=typeof ArrayBuffer?e instanceof ArrayBuffer?l=f(new Uint8Array(e)):e instanceof Uint8Array||e instanceof Int8Array?l=f(e):e instanceof Uint32Array||e instanceof Int32Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Float32Array||e instanceof Float64Array?l=f(new Uint8Array(e.buffer)):c=(0,a.default)(e):c=(0,a.default)(e),c&&alert("MD5 type mismatch, cannot process "+c),function(){function e(e,t,r,n){var a,i,o=y;y=v,v=g,g=p(g,(a=p(h,p(e,p(t,r))))<<(i=n)&4294967295|a>>>32-i),h=o}var a=l.length;l.push(128);var s=l.length%64;if(s>56){for(var f=0;f<64-s;f++)l.push(0);s=l.length%64}for(f=0;f<56-s;f++)l.push(0);l=l.concat(function(e){for(var t=[],r=0;r<8;r++)t.push(255&e),e>>>=8;return t}(8*a));var c=1732584193,d=4023233417,m=2562383102,_=271733878,h=0,g=0,v=0,y=0;for(f=0;f<l.length/64;f++){h=c;var b=64*f;e(r(g=d,v=m,y=_),3614090360,u(l,b),7),e(r(g,v,y),3905402710,u(l,b+4),12),e(r(g,v,y),606105819,u(l,b+8),17),e(r(g,v,y),3250441966,u(l,b+12),22),e(r(g,v,y),4118548399,u(l,b+16),7),e(r(g,v,y),1200080426,u(l,b+20),12),e(r(g,v,y),2821735955,u(l,b+24),17),e(r(g,v,y),4249261313,u(l,b+28),22),e(r(g,v,y),1770035416,u(l,b+32),7),e(r(g,v,y),2336552879,u(l,b+36),12),e(r(g,v,y),4294925233,u(l,b+40),17),e(r(g,v,y),2304563134,u(l,b+44),22),e(r(g,v,y),1804603682,u(l,b+48),7),e(r(g,v,y),4254626195,u(l,b+52),12),e(r(g,v,y),2792965006,u(l,b+56),17),e(r(g,v,y),1236535329,u(l,b+60),22),e(n(g,v,y),4129170786,u(l,b+4),5),e(n(g,v,y),3225465664,u(l,b+24),9),e(n(g,v,y),643717713,u(l,b+44),14),e(n(g,v,y),3921069994,u(l,b),20),e(n(g,v,y),3593408605,u(l,b+20),5),e(n(g,v,y),38016083,u(l,b+40),9),e(n(g,v,y),3634488961,u(l,b+60),14),e(n(g,v,y),3889429448,u(l,b+16),20),e(n(g,v,y),568446438,u(l,b+36),5),e(n(g,v,y),3275163606,u(l,b+56),9),e(n(g,v,y),4107603335,u(l,b+12),14),e(n(g,v,y),1163531501,u(l,b+32),20),e(n(g,v,y),2850285829,u(l,b+52),5),e(n(g,v,y),4243563512,u(l,b+8),9),e(n(g,v,y),1735328473,u(l,b+28),14),e(n(g,v,y),2368359562,u(l,b+48),20),e(i(g,v,y),4294588738,u(l,b+20),4),e(i(g,v,y),2272392833,u(l,b+32),11),e(i(g,v,y),1839030562,u(l,b+44),16),e(i(g,v,y),4259657740,u(l,b+56),23),e(i(g,v,y),2763975236,u(l,b+4),4),e(i(g,v,y),1272893353,u(l,b+16),11),e(i(g,v,y),4139469664,u(l,b+28),16),e(i(g,v,y),3200236656,u(l,b+40),23),e(i(g,v,y),681279174,u(l,b+52),4),e(i(g,v,y),3936430074,u(l,b),11),e(i(g,v,y),3572445317,u(l,b+12),16),e(i(g,v,y),76029189,u(l,b+24),23),e(i(g,v,y),3654602809,u(l,b+36),4),e(i(g,v,y),3873151461,u(l,b+48),11),e(i(g,v,y),530742520,u(l,b+60),16),e(i(g,v,y),3299628645,u(l,b+8),23),e(o(g,v,y),4096336452,u(l,b),6),e(o(g,v,y),1126891415,u(l,b+28),10),e(o(g,v,y),2878612391,u(l,b+56),15),e(o(g,v,y),4237533241,u(l,b+20),21),e(o(g,v,y),1700485571,u(l,b+48),6),e(o(g,v,y),2399980690,u(l,b+12),10),e(o(g,v,y),4293915773,u(l,b+40),15),e(o(g,v,y),2240044497,u(l,b+4),21),e(o(g,v,y),1873313359,u(l,b+32),6),e(o(g,v,y),4264355552,u(l,b+60),10),e(o(g,v,y),2734768916,u(l,b+24),15),e(o(g,v,y),1309151649,u(l,b+52),21),e(o(g,v,y),4149444226,u(l,b+16),6),e(o(g,v,y),3174756917,u(l,b+44),10),e(o(g,v,y),718787259,u(l,b+8),15),e(o(g,v,y),3951481745,u(l,b+36),21),c=p(c,h),d=p(d,g),m=p(m,v),_=p(_,y)}return function(e,r,n,a){for(var i="",o=0,u=0,s=3;s>=0;s--)o=255&(u=arguments[s]),o<<=8,o|=255&(u>>>=8),o<<=8,o|=255&(u>>>=8),o<<=8,i+=t(o|=u>>>=8);return i}(_,m,d,c).toUpperCase()}()};t.default=function(e){return i.MD5(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(0);t.default=function(){var e,t,r,a,i,o,u,s,f,l,c,p,d,m,_,h=!1,g=0;function v(){v.prototype.setIsFirstFrame(!1)}return v.prototype={init:function(){n.debug.log("H264 Decoder init")},setOutputSize:function(e){if(i!==2*e){i=2*e;var t=Module._malloc(1),r=new Uint8Array(Module.HEAPU8.buffer,t,1);Module._DECODE_GetFreePort(r.byteOffset),g=r[0],r=null,Module._free(t),Module._DECODE_Init(g),o=Module._malloc(5242880),u=new Uint8Array(Module.HEAPU8.buffer,o,5242880);var n=2*e;s=Module._malloc(n),f=new Uint8Array(Module.HEAPU8.buffer,s,n),l=Module._malloc(4),c=new Uint8Array(Module.HEAPU8.buffer,l,4),p=Module._malloc(40),d=new Uint8Array(Module.HEAPU8.buffer,p,40)}},decode:function(n,i){e=Date.now(),u.set(n),Module._DECODE_InputOneFrame(g,u.byteOffset,n.length,f.byteOffset,c.byteOffset,d.byteOffset),a=d[16]+(d[17]<<8),r=d[18]+(d[19]<<8);var o=a*r*3/2;return _=null,m=null,_=new ArrayBuffer(o),(m=new Uint8Array(_)).set(Module.HEAPU8.subarray(f.byteOffset,f.byteOffset+o)),t=Date.now()-e,v.prototype.isFirstFrame()?a>0&&r>0?(e=Date.now(),{data:m,option:{ylen:a,height:r,beforeDecoding:e},width:a,height:r,codecType:"h264",decodingTime:t,frameType:i}):void 0:(v.prototype.setIsFirstFrame(!0),{firstFrame:!0})},setIsFirstFrame:function(e){h=e},isFirstFrame:function(){return h},free:function(){Module._DECODE_Stop(g),u=null,Module._free(o),f=null,Module._free(s),c=null,Module._free(l),d=null,Module._free(p),_=null,m=null}},new v}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(0);t.default=new function(){var e=[],t={};function r(){for(var r in e)e[r]=[r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2),r.charCodeAt(3)];t.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),t.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),t.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSC=t.STCO=t.STTS,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),t.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}e={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var a=function(e){for(var t=8,r=Array.prototype.slice.call(arguments,1),n=0;n<r.length;n++)t+=r[n].byteLength;var a=new Uint8Array(t),i=0;for(a[i++]=t>>>24&255,a[i++]=t>>>16&255,a[i++]=t>>>8&255,a[i++]=255&t,a.set(e,i),i+=4,n=0;n<r.length;n++)a.set(r[n],i),i+=r[n].byteLength;return a},i=function(t){return a(e.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&t.channelcount)>>8,255&t.channelcount,(65280&t.samplesize)>>8,255&t.samplesize,0,0,0,0,(65280&t.samplerate)>>8,255&t.samplerate,0,0]),function(t){var r=t.config,n=r.length,i=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(r).concat([6,1,2]));return a(e.esds,i)}(t))},o=function(r){return"audio"===r.type?a(e.stsd,t.STSD_PREFIX,i(r)):a(e.stsd,t.STSD_PREFIX,function(t){var r=t.sps||[],n=t.pps||[],i=[],o=[],u=0;for(u=0;u<r.length;u++)i.push((65280&r[u].byteLength)>>>8),i.push(255&r[u].byteLength),i=i.concat(Array.prototype.slice.call(r[u]));for(u=0;u<n.length;u++)o.push((65280&n[u].byteLength)>>>8),o.push(255&n[u].byteLength),o=o.concat(Array.prototype.slice.call(n[u]));return a(e.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&t.width)>>8,255&t.width,(65280&t.height)>>8,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a(e.avcC,new Uint8Array([1,t.profileIdc,t.profileCompatibility,t.levelIdc,255].concat([r.length]).concat(i).concat([n.length]).concat(o))))}(r))},u=function(r){var n=null;return n="audio"===r.type?a(e.smhd,t.SMHD):a(e.vmhd,t.VMHD),a(e.minf,n,a(e.dinf,a(e.dref,t.DREF)),function(r){return a(e.stbl,o(r),a(e.stts,t.STTS),a(e.stsc,t.STSC),a(e.stsz,t.STSZ),a(e.stco,t.STCO))}(r))},s=function(r){return a(e.mdia,function(t){var r=t.timescale,n=t.duration;return a(e.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))}(r),function(r){var n=null;return n="audio"===r.type?t.HDLR_AUDIO:t.HDLR_VIDEO,a(e.hdlr,n)}(r),u(r))},f=function(t){return a(e.trak,function(t){var r=t.id,n=t.duration,i=t.width,o=t.height;return a(e.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>>8&255,255&i,0,0,o>>>8&255,255&o,0,0]))}(t),s(t))},l=function(t){return a(e.mvex,function(t){var r=t.id,n=new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return a(e.trex,n)}(t))},c=function(t){var r,i,o=(r=t.timescale,i=t.duration,n.debug.log("mvhd: timescale: "+r+" duration: "+i),a(e.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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]))),u=f(t),s=l(t);return a(e.moov,o,u,s)},p=function(t,r){return"audio"===t.type?audioTrun(t,r):function(t,r){var n,i=null,o=null,u=0,s=r;if(null===(n=t.samples||[])[0].frameDuration)for(s+=24+4*n.length,i=trunHeader(n,s),u=0;u<n.length;u++)o=n[u],i=i.concat([(4278190080&o.size)>>>24,(16711680&o.size)>>>16,(65280&o.size)>>>8,255&o.size]);else for(i=function(e,t){return[0,0,3,5,(4278190080&e.length)>>>24,(16711680&e.length)>>>16,(65280&e.length)>>>8,255&e.length,(4278190080&t)>>>24,(16711680&t)>>>16,(65280&t)>>>8,255&t,0,0,0,0]}(n,s+=24+4*n.length+4*n.length),u=0;u<n.length;u++)o=n[u],i=i.concat([(4278190080&o.frameDuration)>>>24,(16711680&o.frameDuration)>>>16,(65280&o.frameDuration)>>>8,255&o.frameDuration,(4278190080&o.size)>>>24,(16711680&o.size)>>>16,(65280&o.size)>>>8,255&o.size]);return a(e.trun,new Uint8Array(i))}(t,r)},d=function(t,r){return a(e.moof,function(t){var r=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return a(e.mfhd,r)}(t),function(t){var r,n,i;return r=a(e.tfhd,new Uint8Array([0,2,0,0,0,0,0,1])),n=a(e.tfdt,new Uint8Array([0,0,0,0,t.baseMediaDecodeTime>>>24&255,t.baseMediaDecodeTime>>>16&255,t.baseMediaDecodeTime>>>8&255,255&t.baseMediaDecodeTime])),i=p(t,72),a(e.traf,r,n,i)}(r))};return r.prototype={initSegment:function(r){var i=a(e.ftyp,t.FTYP);n.debug.log(r);var o=c(r),u=new Uint8Array(i.byteLength+o.byteLength);return u.set(i,0),u.set(o,i.byteLength),u},mediaSegment:function(t,r,n,i){var o=d(t,r),u=function(t){return a(e.mdat,t)}(n),s=null;return(s=new Uint8Array(o.byteLength+u.byteLength)).set(o),s.set(u,o.byteLength),s}},new r}},function(e,t,r){"use strict";var n=r(1);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=r(0),i=n(r(14)),o=n(r(3));function u(){var e=null,t=null,r=0,n=0,a=0,i=0,u=0;function s(){0,e=new o.default}function f(){return 0==a&&(i=function(){if(n>=r)return 0;var e=t[n++];return 0==e?(u++,n<r&&2==u&&3==t[n]&&(n++,u=0)):u=0,e}(),a=8),i>>--a&1}function l(e,t){for(var r=0;t>0;)r<<=1,r|=f(),t--;return r}function c(e,t){for(var a=0;n<r&&0==f();)a++;return l(0,a)+((1<<a)-1)}return s.prototype={parse:function(t){t,0,e.clear(),e.put("forbidden_zero_bit",l(0,1)),e.put("nal_unit_type",l(0,6)),e.put("nuh_layer_id",l(0,6)),e.put("nuh_temporal_id_plus1",l(0,3)),e.put("sps_video_parameter_set_id",l(0,4)),0===e.get("nuh_layer_id")?e.put("sps_max_sub_layers_minus1",l(0,3)):e.put("sps_ext_or_max_sub_layers_minus1",l(0,3));var r=0!==e.get("nuh_layer_id")&&7===e.get("sps_ext_or_max_sub_layers_minus1");return r||(e.put("sps_max_sub_layers_minus1",l(0,1)),function(t,r){if(t){e.put("general_profile_space",l(0,2)),e.put("general_tier_flag",l(0,1)),e.put("general_profile_idc",l(0,5));for(var n=new Array(32),a=0;a<32;a++)n[a]=l(0,1);e.put("general_progressive_source_flag",l(0,1)),e.put("general_interlaced_source_flag",l(0,1)),e.put("general_non_packed_constraint_flag",l(0,1)),e.put("general_frame_only_constraint_flag",l(0,1));var i=e.get("general_profile_idc");4===i||n[4]||5===i||n[5]||6===i||n[6]||7===i||n[7]||8===i||n[8]||9===i||n[9]||10===i||n[10]?(e.put("general_max_12bit_constraint_flag",l(0,1)),e.put("general_max_10bit_constraint_flag",l(0,1)),e.put("general_max_8bit_constraint_flag",l(0,1)),e.put("general_max_422chroma_constraint_flag",l(0,1)),e.put("general_max_420chroma_constraint_flag",l(0,1)),e.put("general_max_monochrome_constraint_flag",l(0,1)),e.put("general_intra_constraint_flag",l(0,1)),e.put("general_one_picture_only_constraint_flag",l(0,1)),e.put("general_lower_bit_rate_constraint_flag",l(0,1)),5===i||n[5]||9===i||n[9]||10===i||n[10]?(e.put("general_max_14bit_constraint_flag",l(0,1)),e.put("general_reserved_zero_33bits",l(0,33))):e.put("general_reserved_zero_34bits",l(0,34))):e.put("general_reserved_zero_43bits",l(0,43)),i>=1&&i<=5||n[1]||n[2]||n[3]||n[4]||n[5]||n[9]?e.put("general_inbld_flag",l(0,1)):e.put("general_reserved_zero_bit",l(0,1))}e.put("general_level_idc",l(0,8));var o=new Array(r),u=new Array(r);for(_=0;_<r;_++)o[_]=l(0,1),u[_]=l(0,1);var s=new Array(8),f=new Array(r),c=new Array(r),p=new Array(r),d=[],m=new Array(r);if(r>0)for(var _=r;_<8;_++)s[_]=l(0,2);for(_=0;_<r;_++){if(o[_]){for(c[_]=l(0,2),p[_]=l(0,1),f[_]=l(0,5),a=0;a<32;a++)d[_][a]=l(0,1);e.put("sub_layer_progressive_source_flag",l(0,1)),e.put("sub_layer_interlaced_source_flag",l(0,1)),e.put("sub_layer_non_packed_constraint_flag",l(0,1)),e.put("sub_layer_frame_only_constraint_flag",l(0,1)),4===f[_]||d[_][4]||5===f[_]||d[_][5]||6===f[_]||d[_][6]||7===f[_]||d[_][7]||8===f[_]||d[_][8]||9===f[_]||d[_][9]||10===f[_]||d[_][10]?(e.put("sub_layer_max_12bit_constraint_flag",l(0,1)),e.put("sub_layer_max_10bit_constraint_flag",l(0,1)),e.put("sub_layer_max_8bit_constraint_flag",l(0,1)),e.put("sub_layer_max_422chroma_constraint_flag",l(0,1)),e.put("sub_layer_max_420chroma_constraint_flag",l(0,1)),e.put("sub_layer_max_monochrome_constraint_flag",l(0,1)),e.put("sub_layer_intra_constraint_flag",l(0,1)),e.put("sub_layer_one_picture_only_constraint_flag",l(0,1)),e.put("sub_layer_lower_bit_rate_constraint_flag",l(0,1)),5===f[_]||d[_][5]?(e.put("sub_layer_max_14bit_constraint_flag",l(0,1)),e.put("sub_layer_lower_bit_rate_constraint_flag",l(0,1)),m[_]=l(0,33)):m[_]=l(0,34)):e.put("sub_layer_reserved_zero_43bits",l(0,43)),f[_]>=1&&f[_]<=5||9==f[_]||d[1]||d[2]||d[3]||d[4]||d[5]||d[9]?e.put("sub_layer_inbld_flag",l(0,1)):e.put("sub_layer_reserved_zero_bit",l(0,1))}u[_]&&e.put("sub_layer_level_idc",l(0,8))}}(1,e.get("sps_max_sub_layers_minus1"))),l(0,84),e.put("sps_seq_parameter_set_id",c()),r?(e.put("update_rep_format_flag",l(0,1)),e.get("update_rep_format_flag")&&e.put("sps_rep_format_idx",l(0,8))):(e.put("chroma_format_idc",c()),3===e.get("chroma_format_idc")&&e.put("separate_colour_plane_flag",l(0,1)),e.put("pic_width_in_luma_samples",c()),e.put("pic_height_in_luma_samples",c()),e.put("conformance_window_flag",l(0,1)),e.get("conformance_window_flag")&&(e.put("conf_win_left_offset",c()),e.put("conf_win_right_offset",c()),e.put("conf_win_top_offset",c()),e.put("conf_win_bottom_offset",c()))),!0},parse2:function(o){var s=o.length;if(o,t=o,r=o.length,n=0,a=0,i=0,u=0,0,e.clear(),s<20)return!1;l(0,16),l(0,4);var f=l(0,3);if(e.put("sps_max_sub_layers_minus1",f),f>6)return!1;l(0,1),l(0,2),l(0,1);l(0,5);l(0,32),l(0,1),l(0,1),l(0,1),l(0,1),l(0,43),l(0,1),e.put("general_level_idc",l(0,8));for(var p=[],d=[],m=0;m<f;m++)p[m]=l(0,1),d[m]=l(0,1);if(f>0)for(m=f;m<8;m++)l(0,2);for(m=0;m<f;m++)p[m]&&(l(0,2),l(0,1),l(0,5),l(0,32),l(0,1),l(0,1),l(0,1),l(0,1),l(0,44)),d[m]&&l(0,8);var _=c();if(e.put("sps_seq_parameter_set_id",_),_>15)return!1;var h=c();return e.put("chroma_format_idc",h),!(_>3)&&(3==h&&l(0,1),e.put("pic_width_in_luma_samples",c()),e.put("pic_height_in_luma_samples",c()),l(0,1)&&(c(),c(),c(),c()),c()==c())},getSizeInfo:function(){var t=e.get("pic_width_in_luma_samples"),r=e.get("pic_height_in_luma_samples");if(e.get("conformance_window_flag")){var n=e.get("chroma_format_idc"),a=e.get("separate_colour_plane_flag");"undefined"===typeof a&&(a=0);var i=1!==n&&2!==n||0!==a?1:2,o=1===n&&0===a?2:1;t-=i*e.get("conf_win_right_offset")+i*e.get("conf_win_left_offset"),r-=o*e.get("conf_win_bottom_offset")+o*e.get("conf_win_top_offset")}return{width:t,height:r,decodeSize:t*r}},getSpsValue:function(t){return e.get(t)}},new s}t.default=function(){var e,t=0,r=0,n=0,o=0,s=new u,f={frameData:null,timeStamp:null},l={timestamp:null,timezone:null},c=0,p=0,d=null,m=0,_={width:0,height:0},h=0,g=0;function v(){this.decoder=(0,i.default)(),this.firstTime=0,this.lastMSW=0}return v.prototype={setReturnCallback:function(e){this.rtpReturnCallback=e},setBufferfullCallback:function(e){null!==this.videoBufferList&&this.videoBufferList.setBufferFullCallback(e)},getVideoBuffer:function(e){if(null!==this.videoBufferList)return this.videoBufferList.searchNodeAt(e)},clearBuffer:function(){null!==this.videoBufferList&&this.videoBufferList.clear()},findCurrent:function(){null!==this.videoBufferList&&this.videoBufferList.searchTimestamp(this.getTimeStamp())},ntohl:function(e){return(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3]>>>0},appendBuffer:function(e,t,r){if(r+t.length>=e.length){var n=new Uint8Array(e.length+1048576);n.set(e,0),e=n}return e.set(t,r),e},setGovLength:function(e){d=e},getGovLength:function(){return d},setDecodingTime:function(e){this.decodingTime=e},getDropPercent:function(){return 0},getDropCount:function(){return 0},initStartTime:function(){this.firstDiffTime=0,this.calcGov=0},setCheckDelay:function(e){this.checkDelay=e},init:function(){this.decoder.setIsFirstFrame(!1),this.videoBufferList=new a.VideoBufferList,this.firstDiffTime=0,this.checkDelay=!0,this.timeData=null},parseRTPData:function(i,u,d,m,v){var y,b=null,D={},S=(u[19]<<24)+(u[18]<<16)+(u[17]<<8)+u[16]>>>0;y=S>>>26===0?"2000":"20"+(S>>>26);var w=Date.UTC(y,(S>>>22&15)-1,S>>>17&31,S>>>12&31,S>>>6&63,63&S)/1e3;if(w+=(new Date).getTimezoneOffset()/60*3600,0===this.firstTime)this.firstTime=w,this.lastMSW=0,r=(u[21]<<8)+u[20],l={timestamp:this.firstTime,timestamp_usec:0};else{var T,C=(u[21]<<8)+u[20];T=C>r?C-r:C+65535-r,this.lastMSW+=T,w>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=w,l={timestamp:w,timestamp_usec:this.lastMSW},r=C}0!==this.getFramerate()&&"undefined"!==typeof this.getFramerate()||"undefined"===typeof this.getTimeStamp()||(this.setFramerate(Math.round(1e3/((l.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(l.timestamp_usec-this.getTimeStamp().timestamp_usec)))),a.debug.log("setFramerate"+Math.round(1e3/((l.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(l.timestamp_usec-this.getTimeStamp().timestamp_usec))))),this.setTimeStamp(l);var M=u[22];e=u.subarray(24+M,u.length-8),t=(u[21]<<8)+u[20];for(var x=[],I=0;I<=e.length;)if(0==e[I])if(0==e[I+1])if(1==e[I+2]){if(x.push(I),5==(31&e[I+=3])||1==(31&e[I]))break}else 0==e[I+2]?I++:I+=3;else I+=2;else I+=1;var A="P";for(I=0;I<x.length;I++)switch(b=e.subarray(x[I]+3,x[I+1]),e[x[I]+3]>>1&63){default:break;case 33:A="I",s.parse2(b);var F=v;o=s.getSizeInfo().decodeSize,c=F.width,p=F.height,_.width==F.width&&_.height==F.height||(0!=_.width?(_.width=F.width,_.height=F.height,D.resolution=_,D.resolution.decodeMode="canvas",D.resolution.encodeMode="h265"):(_.width=F.width,_.height=F.height,D.decodeStart=_,D.decodeStart.decodeMode="canvas",D.decodeStart.encodeMode="h265"))}var k=1e3*l.timestamp+l.timestamp_usec;0==this.firstDiffTime?(h=0,this.firstDiffTime=Date.now()-k,a.debug.log("firstDiff: 0")):(k-g<0&&(this.firstDiffTime=h+(Date.now()-k).toFixed(0)),(h=Date.now()-k-this.firstDiffTime)<0&&(this.firstDiffTime=0,h=0),h>8e3&&(D.error={errorCode:101},this.rtpReturnCallback(D))),g=k,f.frameData=null,n!==o&&(this.decoder.free(),n=o,this.decoder.setOutputSize(n)),f.frameData=this.decoder.decode(u),f.frameData.frameType=A,f.frameData.frameIndex=v.frameIndex,f.timeStamp=null,l=null===l.timestamp?this.getTimeStamp():l,f.timeStamp=l,d&&(D.backupData={stream:e,frameType:A,width:c,height:p,codecType:"h265"},null!==l.timestamp&&"undefined"!==typeof l.timestamp?D.backupData.timestamp_usec=l.timestamp_usec:D.backupData.timestamp=(t/90).toFixed(0)),D.decodedData=f,this.rtpReturnCallback(D)},findIFrame:function(){if(null!==this.videoBufferList){var e=this.videoBufferList.findIFrame();if(null===e||"undefined"===typeof e)return!1;var t={};return this.setTimeStamp(e.timeStamp),t.frameData=this.decoder.decode(e.buffer),t.timeStamp=e.timeStamp,t}},getFramerate:function(){return m},setFramerate:function(e){0<e&&"undefined"!==typeof e&&(m=e,null!==this.videoBufferList&&(this.videoBufferList.setMaxLength(6*m),this.videoBufferList.setBUFFERING(4*m)))},getTimeStamp:function(){return this.timeData},setTimeStamp:function(e){this.timeData=e}},new v}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(0);t.default=function(){var e,t,r,a,i,o,u,s,f,l,c,p,d,m,_,h=!1,g=0;function v(){v.prototype.setIsFirstFrame(!1)}return v.prototype={init:function(){n.debug.log("H265 Decoder init")},setOutputSize:function(e){if(i!==2*e){i=2*e;var t=Module._malloc(1),r=new Uint8Array(Module.HEAPU8.buffer,t,1);Module._DECODE_GetFreePort(r.byteOffset),g=r[0],r=null,Module._free(t),Module._DECODE_Init(g),o=Module._malloc(5242880),u=new Uint8Array(Module.HEAPU8.buffer,o,5242880);var n=2*e;s=Module._malloc(n),f=new Uint8Array(Module.HEAPU8.buffer,s,n),l=Module._malloc(4),c=new Uint8Array(Module.HEAPU8.buffer,l,4),p=Module._malloc(40),d=new Uint8Array(Module.HEAPU8.buffer,p,40)}},decode:function(n,i){e=Date.now(),u.set(n),Module._DECODE_InputOneFrame(g,u.byteOffset,n.length,f.byteOffset,c.byteOffset,d.byteOffset),a=d[16]+(d[17]<<8),r=d[18]+(d[19]<<8);var o=a*r*3/2;return _=null,m=null,_=new ArrayBuffer(o),(m=new Uint8Array(_)).set(Module.HEAPU8.subarray(f.byteOffset,f.byteOffset+o)),t=Date.now()-e,v.prototype.isFirstFrame()?a>0&&r>0?(e=Date.now(),{data:m,option:{ylen:a,height:r,beforeDecoding:e},width:a,height:r,codecType:"h265",decodingTime:t,frameType:i}):void 0:(v.prototype.setIsFirstFrame(!0),{firstFrame:!0})},setIsFirstFrame:function(e){h=e},isFirstFrame:function(){return h},free:function(){Module._DECODE_Stop(g),u=null,Module._free(o),f=null,Module._free(s),c=null,Module._free(l),d=null,Module._free(p),_=null,m=null}},new v}},function(e,t,r){"use strict";var n=r(1);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=r(0),i=n(r(16));t.default=function(){var e=0,t=0,r={frameData:null,timeStamp:null},n={timestamp:null,timezone:null};var o=0,u=0,s=0,f=0,l=null,c=null,p=null,d=0,m=0,_=0,h={width:0,height:0};function g(){this.decoder=new i.default,this.firstTime=0,this.lastMSW=0}return g.prototype={init:function(){this.decoder.setIsFirstFrame(!1),this.videoBufferList=new a.VideoBufferList,this.timeData=null},parseRTPData:function(i,p,d,g,v){var y,b=new Uint8Array(1048576);e=v.width,t=v.height,l={};var D=p[22],S=p.subarray(24+D,p.length-8);c=S.length;var w=(p[19]<<24)+(p[18]<<16)+(p[17]<<8)+p[16]>>>0;y=w>>26===0?"2000":"20"+(w>>26);var T=Date.UTC(y,(w>>22&15)-1,w>>17&31,w>>12&31,w>>6&63,63&w)/1e3;if(T-=28800,0===this.firstTime)this.firstTime=T,this.lastMSW=0,f=(p[21]<<8)+p[20],n={timestamp:this.firstTime,timestamp_usec:0};else{var C,M=(p[21]<<8)+p[20];C=M>f?M-f:M+65535-f,this.lastMSW+=C,T>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=T,n={timestamp:T,timestamp_usec:this.lastMSW},f=M}0!==this.getFramerate()&&"undefined"!==typeof this.getFramerate()||"undefined"===typeof this.getTimeStamp()||this.setFramerate(Math.round(1e3/((n.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(n.timestamp_usec-this.getTimeStamp().timestamp_usec)))),this.setTimeStamp(n),s=(p[21]<<8)+p[20],u=c,(b=this.appendBuffer(b,S,o))[(o+=c)+u-2]=255,b[o+u-1]=217,h.width==e&&h.height==t||(0!=h.width?(h.width=e,h.height=t,l.resolution=h,l.resolution.decodeMode="canvas",l.resolution.encodeMode="mjpeg"):(h.width=e,h.height=t,l.decodeStart=h,l.decodeStart.decodeMode="canvas",l.decodeStart.encodeMode="mjpeg"));var x=1e3*n.timestamp+n.timestamp_usec;0==this.firstDiffTime?(m=0,this.firstDiffTime=Date.now()-x,a.debug.log("firstDiff: "+this.firstTime)):(x-_<0&&(this.firstDiffTime=m+(Date.now()-x).toFixed(0)),(m=Date.now()-x-this.firstDiffTime)<0&&(this.firstDiffTime=0,m=0),m>8e3&&(l.error={errorCode:101},this.rtpReturnCallback(l))),_=x,r.frameData=null,this.decoder.setResolution(e,t),r.frameData=this.decoder.decode(b.subarray(0,o)),r.timeStamp=null,n=null===n.timestamp?this.getTimeStamp():n,r.timeStamp=n,!0===d&&(l.backupData={stream:b.subarray(0,o),width:e,height:t,codecType:"mjpeg"},null!==n.timestamp&&"undefined"!==typeof n.timestamp?l.backupData.timestamp_usec=n.timestamp_usec:l.backupData.timestamp=(s/90).toFixed(0)),o=0,r.playback=!1,l.decodedData=r,this.rtpReturnCallback(l)},getVideoBuffer:function(e){if(null!==this.videoBufferList)return this.videoBufferList.searchNodeAt(e)},clearBuffer:function(){null!==this.videoBufferList&&this.videoBufferList.clear()},findCurrent:function(){null!==this.videoBufferList&&this.videoBufferList.searchTimestamp(this.getTimeStamp())},findIFrame:function(){null!==this.videoBufferList&&this.videoBufferList.findIFrame()},SetRtpInterlevedID:function(e){this.interleavedID=e},setTimeStamp:function(e){this.timeData=e},getTimeStamp:function(){return this.timeData},getRTPPacket:function(e,t){},calculatePacketTime:function(e){},ntohl:function(e){return(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3]>>>0},appendBuffer:function(e,t,r){if(r+t.length>=e.length){var n=new Uint8Array(e.length+1048576);n.set(e,0),e=n}return e.set(t,r),e},setFramerate:function(e){0<e&&"undefined"!==typeof e&&(d=e,null!==this.videoBufferList&&(this.videoBufferList.setMaxLength(6*d),this.videoBufferList.setBUFFERING(4*d)))},getFramerate:function(){return d},setReturnCallback:function(e){this.rtpReturnCallback=e},setBufferfullCallback:function(e){null!==this.videoBufferList&&this.videoBufferList.setBufferFullCallback(e)},setGovLength:function(e){p=e},getGovLength:function(){return p},setDecodingTime:function(e){this.decodingTime=e},getDropPercent:function(){return 0},getDropCount:function(){return 0},initStartTime:function(){this.firstDiffTime=0,this.calcGov=0},setCheckDelay:function(e){this.checkDelay=e}},new g}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(0);t.default=function(){var e,t,r=!1;function a(){n.debug.log("MJPEG Decoder")}return a.prototype={setIsFirstFrame:function(e){r=e},isFirstFrame:function(){return r},setResolution:function(r,n){e=r,t=n},decode:function(r,n){return a.prototype.isFirstFrame()?{data:r,width:e,height:t,codecType:"mjpeg"}:(a.prototype.setIsFirstFrame(!0),{firstFrame:!0})}},new a}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(0);t.default=function(){var e,t=null,r={0:"",1:"VideoSynopsis",2:"TrafficGate",3:"ElectronicPolice",4:"SinglePtzParking",5:"PtzParking",6:"Traffic",7:"Normal",8:"none",9:"ATM",10:"MetroIVS",11:"FaceDetection",12:"FaceRecognition",13:"NumberStat",14:"HeatMap",15:"VideoDiagnosis",16:"VideoEnhance",17:"SmokeFireDetect",18:"VehicleAnalyse",19:"PersonFeature",20:"SDFaceDetect",21:"HeatMapPlan",22:"ATMFD",23:"SCR",24:"NumberStatPlan",25:"CourseRecord",26:"Highway",27:"City",28:"LeTrack",29:"ObjectStruct",30:"Stereo",31:"StereoPc",32:"HumanDetect",33:"SDPedestrain",34:"FaceAnalysis",35:"FaceAttribute",36:"FacePicAnalyse",37:"SDEP",38:"XRayDetect",39:"ObjectDetect",40:"CrowdDistriMap",41:"StereoBehavior"};function a(){this.firstTime=0,this.lastMSW=0}function i(e){for(var t=[].slice.call(e),r="",n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return decodeURIComponent(escape(r))}function o(e){var t={result:!0,type:0};return t.params=JSON.parse(i(e)),t}function u(e){var t={result:!1},n=0,a=(e[n+1]<<8)+e[n];if(1!==a&&2!==a)return t;t.result=!0,t.type=5,t.params=null;var i=e[n+=2];if(0===i)return t;var o=e[n+=1];n+=1,t.params={},t.params.coordinate=128&o?8192:1024,t.params.isTrack=!!(127&o),t.params.object=[];for(var u=0;u<i;u++){var s={};s.objectId=(e[n+3]<<24)+(e[n+2]<<16)+(e[n+1]<<8)+e[n],n+=4,s.operateType=e[n];var f=e[n+=1];n+=1,s.objectType=e[n];var l=e[n+=1];n+=1,n+=1,n+=1,s.classID=r[e[n]],n+=1,s.subType=e[n],n+=1,l>0&&(s.fatherId=[]);for(var c=0;c<l;c++)s.fatherId.push((e[n+3]<<24)+(e[n+2]<<16)+(e[n+1]<<8)+e[n]),n+=4;f>0&&(s.track=[]);for(var p=0;p<f;p++){var d=(e[n+1]<<8)+e[n],m=(e[(n+=2)+1]<<8)+e[n],_=(e[(n+=2)+1]<<8)+e[n],h=(e[(n+=2)+1]<<8)+e[n];n+=2,s.track.push([d-_,m-h,d+_,m+h])}t.params.object.push(s)}return t}function s(e){for(var t={result:!1,type:20,params:[]},r=(e[0],e.length),n=0,a=e.slice(4),o=function(){var e={};e.objectId=(a[n+3]<<24)+(a[n+2]<<16)+(a[n+1]<<8)+(a[n+0]<<0),n+=4,e.result=!0,e.params={},e.custom=(a[n+1]<<8)+a[n],n+=2,e.objectStatus=a[n];var t=a[n+=1];n+=1,e.params.object=[];for(var r=null,o=0;o<t;o++){switch(a[n]){case 1:r=c(a.slice(n));break;case 2:r=l(a.slice(n));break;case 3:r=f(a.slice(n));break;case 4:r=p(a.slice(n))}e.params.object.push(r.info),n+=r.offset}1!=e.objectStatus&&3!=e.objectStatus||(e.params=null),0==t&&(e.params=null);var u=(a[n+1]<<8)+a[n];n+=2;var s=i(a.slice(n,n+u));return e.appendInfo=String.fromCharCode.apply(null,a.slice(n,n+u)),n+=u,e.appendInfo=s,e};n<r-4;)t.params.push(o());return t}function f(e){var t=0,r={type:e[0]};t+=1,r.pointCount=e[t],t+=1,r.lineWidth=e[t],t+=1,r.strokeStyle=e[t],t+=1,r.borderColor=[e[t+1],e[t+2],e[t+3],e[t]],r.borderColorType="RGBA",t+=4,r.fillColor=[e[t+1],e[t+2],e[t+3],e[t]],r.fillColorType="RGBA",t+=4,r.coordinate=[];for(var n=0;n<r.pointCount;n++){var a=(e[t+1]<<8)+e[t],i=(e[(t+=2)+1]<<8)+e[t];t+=2,r.coordinate.push([a,i])}return{info:r,offset:t}}function l(e){var t=0,r={type:e[0]};t+=1,r.pointCount=e[t],t+=1,r.lineWidth=e[t],t+=1,r.strokeStyle=e[t],t+=1,r.lineColor=[e[t+1],e[t+2],e[t+3],e[t]],r.lineColorType="RGBA",t+=4,r.coordinate=[];for(var n=0;n<r.pointCount;n++){var a=(e[t+1]<<8)+e[t],i=(e[(t+=2)+1]<<8)+e[t];t+=2,r.coordinate.push([a,i])}return{info:r,offset:t}}function c(e){var t=0,r={type:e[0]};t+=1,r.lineWidth=e[t],t+=1,r.strokeStyle=e[t],t+=1,t+=1,r.radius=(e[t+1]<<8)+e[t],t+=2;var n=(e[(t+=2)+1]<<8)+e[t],a=(e[(t+=2)+1]<<8)+e[t];return t+=2,r.coordinate=[n,a],r.borderColor=[e[t+1],e[t+2],e[t+3],e[t]],r.borderColorType="RGBA",t+=4,r.fillColor=[e[t+1],e[t+2],e[t+3],e[t]],r.fillColorType="RGBA",{info:r,offset:t+=4}}function p(e){var t=0,r={type:e[0]};t+=1,r.encodeType=e[t],t+=1;var n=(e[(t+=2)+1]<<8)+e[t],a=(e[(t+=2)+1]<<8)+e[t];t+=2,r.coordinate=[n,a],r.fontColor=[e[t+1],e[t+2],e[t+3],e[t]],t+=4,r.colorType="RGBA",r.fontSize=e[t],t+=1,r.textAlign=e[t],t+=1,r.textBaseline="top",r.textLength=(e[t+1]<<8)+e[t],t+=2;for(var o=e.slice(t,t+r.textLength),u=0;u<r.textLength;u++)if(0===o[u]){o=o.slice(0,u);break}try{r.content=i(o)}catch(e){r.content=""}return{info:r,offset:t+=r.textLength}}function d(e,t){t.hasOwnProperty("attribute80")||(t.attribute80=[]);var r=1,n=e[r];r+=1;var a={color:{}};a.color.valid=e[r],r+=1,a.carModel=e[r],r+=1,a.color.red=e[r],r+=1,a.color.green=e[r],r+=1,a.color.blue=e[r],r+=1,a.color.alpha=e[r],r+=1,a.brand=(e[r+1]<<8)+e[r],r+=2,a.subBrand=(e[r+1]<<8)+e[r],r+=2,a.year=(e[r+1]<<8)+e[r],r+=2,a.reliability=e[r],r+=1;var i=(e[(r+=1)+1]<<8)+e[r],o=(e[(r+=2)+1]<<8)+e[r],u=(e[(r+=2)+1]<<8)+e[r],s=(e[(r+=2)+1]<<8)+e[r];return r+=2,a.windowPosition=[i-u,o-s,i+u,o+s],t.attribute80.push(a),n}function m(e,t){t.hasOwnProperty("attribute81")||(t.attribute81=[]);var r={},n=1,a=e[n],i=(e[(n+=1)+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n],u=(e[(n+=2)+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n];return n+=2,r.mainPosition=[i-u,o-s,i+u,o+s],i=(e[n+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n],u=(e[(n+=2)+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n],n+=2,r.coPosition=[i-u,o-s,i+u,o+s],r.mainSafetyBelt=e[n]>>2&3,r.coSafetyBelt=3&e[n],n+=1,r.mainSunvisor=e[n]>>2&3,r.coSunvisor=3&e[n],n+=1,t.attribute81.push(r),a}function _(e,t){t.hasOwnProperty("attribute82")||(t.attribute82=[]);var r={},n=1,a=e[n];return n+=1,r.plateEncode=e[n],n+=1,r.plateInfoLen=e[n],n+=1,r.plateInfo=e.subarray(n,n+r.plateInfoLen),t.attribute82.push(r),a}function h(e,t){t.hasOwnProperty("attribute83")||(t.attribute83=[]);var r={},n=1,a=e[n];return n+=1,r.color={},r.color.valid=e[n],n+=1,r.color.red=e[n],n+=1,r.color.green=e[n],n+=1,r.color.blue=e[n],n+=1,r.color.alpha=e[n],n+=1,r.country=String.fromCharCode.apply(null,e.subarray(n,n+4)),n+=4,r.plateType=(e[n+1]<<8)+e[n],n+=2,n+=1,r.plateWidth=(e[n+1]<<8)+e[n],t.attribute83.push(r),a}function g(e,t){t.hasOwnProperty("attribute84")||(t.attribute84=[]);var r={},n=1,a=e[n];n+=1,r.fatherCount=e[n],n+=1,r.trackCount=e[n],n+=1,r.trackType=e[n],n+=1,n+=3,r.fatherCount>0&&(r.fatherID=[]);for(var i=0;i<r.fatherCount;i++)r.fatherID.push((e[n+3]<<24)+(e[n+2]<<16)+(e[n+1]<<8)+e[n]),n+=4;r.trackCount>0&&(r.track=[]);for(var o=0;o<r.trackCount;o++){var u=(e[n+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n],f=(e[(n+=2)+1]<<8)+e[n],l=(e[(n+=2)+1]<<8)+e[n];n+=2,r.track.push([u-f,s-l,u+f,s+l])}return t.attribute84.push(r),a}function v(e,t){t.hasOwnProperty("attribute85")||(t.attribute85=[]);var r={},n=1,a=e[n];n+=1,r.colorSpace=e[n],n+=1,r.mainColorCount=e[n],n+=1,r.mainColorCount>0&&(r.mainColorInfo=[]);for(var i=0;i<r.mainColorCount;i++){var o={},u=(e[n+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n],f=(e[(n+=2)+1]<<8)+e[n],l=(e[(n+=2)+1]<<8)+e[n];n+=2,o.rect=[u-f,s-l,u+f,s+l],o.color=(e[n+3]<<24)+(e[n+2]<<16)+(e[n+1]<<8)+e[n],n+=4,r.mainColorInfo.push(o)}return t.attribute85.push(r),a}function y(e,t){t.hasOwnProperty("attribute86")||(t.attribute86=[]);var r={},n=1,a=e[n];return n+=1,n+=1,r.speedType=e[n],n+=1,r.speed=e[n+1]<<8+e[n],n+=2,r.speedX=e[n+1]<<8+e[n],n+=2,r.speedY=(e[n+1]<<8)+e[n],t.attribute86.push(r),a}function b(e,t){t.hasOwnProperty("attribute87")||(t.attribute87=[]);var r={},n=1,a=e[n];n+=1;var i=(e[(n+=2)+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n],u=(e[(n+=2)+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n];return r.track=[[i-u,o-s,i+u,o+s]],t.attribute87.push(r),a}function D(e,t){t.hasOwnProperty("attribute88")||(t.attribute88=[]);var r={},n=1,a=e[n];return n+=1,r.age=e[n],n+=1,r.sex=e[n],n+=1,r.face=e[n],n+=1,r.glass=e[n],n+=1,r.hat=e[n],n+=1,r.call=e[n],n+=1,r.backpack=e[n],n+=1,r.umbrella=e[n],n+=1,r.height=e[n],n+=1,r.mask=e[n]>>2&3,r.beard=3&e[n],t.attribute88.push(r),a}function S(e,t){t.hasOwnProperty("attribute89")||(t.attribute89=[]);var r={},n=1,a=e[n];n+=1,r.yawAngle=parseInt((e[n+1]<<8)+e[n]),n+=2,r.rollAngle=parseInt((e[n+1]<<8)+e[n]),n+=2,r.pitchAngle=parseInt((e[n+1]<<8)+e[n]);var i=(e[(n+=2)+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n];n+=2,r.lEyePos=[i,o],i=(e[n+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n],n+=2,r.rEyePos=[i,o],i=(e[n+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n],n+=2,r.nosePos=[i,o],i=(e[n+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n],n+=2,r.lMouthPos=[i,o],i=(e[n+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n],n+=2,r.rMouthPos=[i,o];var u=e[n];n+=3,u>0&&(r.featurePos=[]);for(var s=0;s<u;s++)i=(e[n+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n],n+=2,r.featurePos.push([i,o]);return t.attribute89.push(r),a}function w(e,t){t.hasOwnProperty("attribute8C")||(t.attribute8C=[]);var r={},n=1,a=e[n];n+=1,r.hangingCount=e[n],n+=1,r.tissueCount=e[n],n+=1,r.sunVisorCount=e[n],n+=1,r.annualInspectionCount=e[n],n+=1,n+=6,r.hangingCount>0&&(r.hangingCount=[]);for(var i=0;i<r.hangingCount;i++){var o=(e[n+1]<<8)+e[n],u=(e[(n+=2)+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n],f=(e[(n+=2)+1]<<8)+e[n];n+=2,r.hangingPos.push([o-s,u-f,o+s,u+f])}for(r.tissueCount>0&&(r.tissueCount=[]),i=0;i<r.tissueCount;i++)o=(e[n+1]<<8)+e[n],u=(e[(n+=2)+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n],f=(e[(n+=2)+1]<<8)+e[n],n+=2,r.tissueCount.push([o-s,u-f,o+s,u+f]);for(r.sunVisorCount>0&&(r.sunVisorCount=[]),i=0;i<r.tissueCount;i++)o=(e[n+1]<<8)+e[n],u=(e[(n+=2)+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n],f=(e[(n+=2)+1]<<8)+e[n],n+=2,r.sunVisorCount.push([o-s,u-f,o+s,u+f]);for(r.annualInspectionCount>0&&(r.annualInspectionCount=[]),i=0;i<r.tissueCount;i++)o=(e[n+1]<<8)+e[n],u=(e[(n+=2)+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n],f=(e[(n+=2)+1]<<8)+e[n],n+=2,r.annualInspectionCount.push([o-s,u-f,o+s,u+f]);return t.attribute8C.push(r),a}function T(e,t){t.hasOwnProperty("attribute8E")||(t.attribute8E=[]);var r={},n=1,a=e[n];n+=1,r.nameCodecFormat=e[n];var i=e[n+=1];return n+=1,r.name=String.fromCharCode.apply(null,e.subarray(n,i)),t.attribute8E.push(r),a}function C(e,t){for(var r={128:d,129:m,130:_,131:h,132:g,133:v,134:y,135:b,136:D,137:S,140:w,142:T},n=0,a=e[n];n<e.length;){var i=e.subarray(n,e.length);n+=r[a].call(null,i,t)}}function M(e,t){t.hasOwnProperty("vehicleObject")||(t.vehicleObject=[]);var r={},n=0;r.type=e[n],n+=1;var a=(e[(n+=1)+1]<<8)+e[n];n+=2,r.objectId=(e[n+3]<<24)+(e[n+2]<<16)+(e[n+1]<<8)+e[n];var i=(e[(n+=4)+1]<<8)+e[n],o=(e[(n+=2)+1]<<8)+e[n],u=(e[(n+=2)+1]<<8)+e[n],s=(e[(n+=2)+1]<<8)+e[n];return n+=2,r.track=[[i-u,o-s,i+u,o+s]],r.valid=e[n],n+=1,r.operateType=e[n],n+=1,n+=2,C(e.subarray(n,a),r),t.vehicleObject.push(r),a}function x(e,t){t.hasOwnProperty("faceObject")||(t.faceObject=[]);var r={},n=0;r.type=e[n],n+=1;var a=(e[(n+=1)+1]<<8)+e[n];return a<12?0:(n+=2,r.objectId=(e[n+3]<<24)+(e[n+2]<<16)+(e[n+1]<<8)+e[n],n+=4,r.version=e[n],n+=1,n+=3,r.faceData=e.subarray(n,a),t.faceObject.push(r),a)}function I(e,t){t.hasOwnProperty("commonObject")||(t.commonObject=[]);var r={},n=0;r.type=e[n],n+=1;var a=(e[(n+=1)+1]<<8)+e[n];return n+=2,r.objectId=(e[n+3]<<24)+(e[n+2]<<16)+(e[n+1]<<8)+e[n],n+=4,r.operateType=e[n],n+=1,n+=3,C(e.subarray(n,a),r),t.commonObject.push(r),a}function A(e,t,r){var n=0,a=(e[n+3]<<24)+(e[n+2]<<16)+(e[n+1]<<8)+e[n],i=e[n+=4];if(n+=1,n+=3,0==i)return n;t.groupId=a,t.object={};for(var o=0;o<i;o++){var u=e[n],s=e.subarray(n,e.length),f=0;switch(u){case 2:case 5:f=M(s,t.object);break;case 15:f=x(s,t.object);break;default:f=I(s,t.object)}if(0==f)return 0;n+=f}return r(t),n}function F(e,t,r){var n={coordinate:8192};if(t.length<32)return!1;var a=4;n.classID=e;var i=t[a];if(0==i)return!0;n.groupCount=i,a+=1,a+=7,n.cameral=[];for(var o=0;o<20;o++)n.cameral.push(t[a+o]);a+=20;for(var u=0;u<n.groupCount;u++){var s=A(t.subarray(a,t.length),JSON.parse(JSON.stringify(n)),r);if(s<=0)break;a+=s}}return a.prototype={init:function(){n.debug.log("init")},parseRTPData:function(n,a,i,f,l,c){var p,d=(a[19]<<24)+(a[18]<<16)+(a[17]<<8)+a[16]>>>0;p=d>>26===0?"2000":"20"+(d>>26);var m=Date.UTC(p,(d>>22&15)-1,d>>17&31,d>>12&31,d>>6&63,63&d)/1e3;if(m-=28800,0===this.firstTime)this.firstTime=m,this.lastMSW=0,t=(a[21]<<8)+a[20],e={timestamp:this.firstTime,timestamp_usec:0};else{var _,h=(a[21]<<8)+a[20];_=h>=t?h-t:h+65535-t,this.lastMSW+=_,m>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=m,e={timestamp:m,timestamp_usec:this.lastMSW},t=h}!function(t,n,a,i){var f=n[22],l=n.subarray(24+f,n.length-8);switch(t){case 0:a({ivsDraw:o(l),timeStamp:e,channel:i});break;case 5:a({ivsDraw:u(l),timeStamp:e,channel:i});break;case 6:break;case 14:var c=[];if(function(e,t){for(var n=e.length,a=0;a+4<n;){var i=e[a],o=(e[a+1],(e[a+3]<<8)+e[a+2]),u=e.subarray(a,o);if(a+=o,161!==i&&!F(r[i-64],u,t))break}}(l,function(e){c.push(e)}),c.length){var p={result:!1,type:14,params:c};a({ivsDraw:p,timeStamp:e,channel:i})}break;case 20:a({ivsDraw:s(l),timeStamp:e,channel:i})}}(a[5],a,this.rtpReturnCallback,c)},setBufferfullCallback:function(){},setReturnCallback:function(e){this.rtpReturnCallback=e}},new a}}]);