(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-5a16a610"],{"0538":function(e,t,r){"use strict";var n=r("e330"),o=r("59ed"),i=r("861d"),a=r("1a2d"),s=r("f36a"),u=r("40d5"),l=Function,c=n([].concat),f=n([].join),d={},h=function(e,t,r){if(!a(d,t)){for(var n=[],o=0;o1?r-1:0),o=1;o0?c:0)]*i+t[s+(d+c)]*a;o+=n,s=Math.floor(o)*d}for(c=0;c0&&s=u)){for(a=0;a0?a:0)]*i;d+=i,i=0;break}for(a=0;a=0?t=213:(t=85,(e=-e-1)<0&&(e=32767)),r=Q(e,K,8),r>=8?127^t:(n=r<<4,n|=r<2?e>>4&15:e>>r+3&15,n^t)}(e)})),t}function Y(e){var t=[];return Array.prototype.slice.call(e).forEach((function(e,r){t[r]=function(e){var t=0;e<0?(e=132-e,t=127):(e+=132,t=255);var r=Q(e,K,8);return r>=8?127^t:(r<<4|e>>r+3&15)^t}(e)})),t}var ee=p((function e(n){h(this,e),this.log=function(e){if(n._opt.debug&&n._opt.debugLevel==t){for(var r,o=n._opt.debugUuid?"[".concat(n._opt.debugUuid,"]"):"",i=arguments.length,a=new Array(i>1?i-1:0),s=1;s1?a-1:0),u=1;u1?o-1:0),a=1;a3&&void 0!==arguments[3]?arguments[3]:{};if(e){if(Array.isArray(t))return t.map((function(t){return n.proxy(e,t,r,o)}));e.addEventListener(t,r,o);var i=function(){"function"==typeof e.removeEventListener&&e.removeEventListener(t,r,o)};return this.destroys.push(i),i}}},{key:"destroy",value:function(){this.master.debug&&this.master.debug.log("Events","destroy"),this.destroys.forEach((function(e){return e()})),this.destroys=[]}}])}(),re=function(e){function t(e){var r;h(this,t);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r=c(this,t),r._opt={},e&&(r.player=e),r.TAG_NAME="talk";var o=V(H);return r._opt=Object.assign({},o,n),r._opt.sampleRate=parseInt(r._opt.sampleRate,10),r._opt.sampleBitsWidth=parseInt(r._opt.sampleBitsWidth,10),r.audioContext=null,r.gainNode=null,r.recorder=null,r.workletRecorder=null,r.biquadFilter=null,r.userMediaStream=null,r.clearWorkletUrlTimeout=null,r.bufferSize=512,r._opt.audioBufferLength=r.calcAudioBufferLength(),r.audioBufferList=[],r.socket=null,r.socketStatus=E,r.mediaStreamSource=null,r.heartInterval=null,r.checkGetUserMediaTimeout=null,r.wsUrl=null,r.startTimestamp=0,r.sequenceId=0,r.tempTimestamp=null,r.tempG711BufferList=[],r.tempRtpBufferList=[],r.tempPcmBufferList=[],r.events=new te(r),r._initTalk(),r.player||(r.debug=new ee(r)),r._opt.encType!==G&&r._opt.encType!==U||8e3===r._opt.sampleRate&&16===r._opt.sampleBitsWidth||r.warn(r.TAG_NAME,"\n encType is ".concat(r._opt.encType," and sampleBitsWidth is ").concat(r._opt.sampleBitsWidth,", set sampleBitsWidth to ").concat(r._opt.sampleBitsWidth,"。\n ").concat(r._opt.encType," only support sampleRate 8000 and sampleBitsWidth 16")),r.log(r.TAG_NAME,"init",JSON.stringify(r._opt)),r}return f(t,e),p(t,[{key:"destroy",value:function(){this.clearWorkletUrlTimeout&&(clearTimeout(this.clearWorkletUrlTimeout),this.clearWorkletUrlTimeout=null),this.userMediaStream&&(this.userMediaStream.getTracks&&this.userMediaStream.getTracks().forEach((function(e){e.stop()})),this.userMediaStream=null),this.mediaStreamSource&&(this.mediaStreamSource.disconnect(),this.mediaStreamSource=null),this.recorder&&(this.recorder.disconnect(),this.recorder.onaudioprocess=null,this.recorder=null),this.biquadFilter&&(this.biquadFilter.disconnect(),this.biquadFilter=null),this.gainNode&&(this.gainNode.disconnect(),this.gainNode=null),this.workletRecorder&&(this.workletRecorder.disconnect(),this.workletRecorder=null),this.socket&&(this.socketStatus===M&&this._sendClose(),this.socket.close(),this.socket=null),this._stopHeartInterval(),this._stopCheckGetUserMediaTimeout(),this.audioContext=null,this.gainNode=null,this.recorder=null,this.audioBufferList=[],this.sequenceId=0,this.wsUrl=null,this.tempTimestamp=null,this.tempRtpBufferList=[],this.tempG711BufferList=[],this.tempPcmBufferList=[],this.startTimestamp=0,this.log(this.TAG_NAME,"destroy")}},{key:"addRtpToBuffer",value:function(e){var t=e.length+this.tempRtpBufferList.length,r=new Uint8Array(t);r.set(this.tempRtpBufferList,0),r.set(e,this.tempRtpBufferList.length),this.tempRtpBufferList=r}},{key:"addG711ToBuffer",value:function(e){var t=e.length+this.tempG711BufferList.length,r=new Uint8Array(t);r.set(this.tempG711BufferList,0),r.set(e,this.tempG711BufferList.length),this.tempG711BufferList=r}},{key:"addPcmToBuffer",value:function(e){var t=e.length+this.tempPcmBufferList.length,r=new Uint8Array(t);r.set(this.tempPcmBufferList,0),r.set(e,this.tempPcmBufferList.length),this.tempG711ButempPcmBufferListfferList=r}},{key:"downloadRtpFile",value:function(){this.debug.log(this.TAG_NAME,"downloadRtpFile");var e=new Blob([this.tempRtpBufferList]);try{var t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+".rtp",t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadRtpFile",e)}}},{key:"downloadG711File",value:function(){this.debug.log(this.TAG_NAME,"downloadG711File");var e=new Blob([this.tempG711BufferList]);try{var t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+"."+this._opt.encType,t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadG711File",e)}}},{key:"downloadPcmFile",value:function(){this.debug.log(this.TAG_NAME,"downloadPcmFile");var e=new Blob([this.tempPcmBufferList]);try{var t=document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=Date.now()+"."+this._opt.encType,t.click(),window.URL.revokeObjectURL(t.href)}catch(e){console.error("downloadRtpFile",e)}}},{key:"downloadFile",value:function(){this._opt.packetType===P?this.downloadRtpFile():this._opt.encType===G||this._opt.encType===U?this.downloadG711File():this.downloadPcmFile()}},{key:"calcAudioBufferLength",value:function(){var e=this._opt,t=e.sampleRate;e.sampleBitsWidth;return 8*t*.02/8}},{key:"socketStatusOpen",get:function(){return this.socketStatus===M}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r1?o-1:0),a=1;a do talk"),e.emit(k),t(),e._doTalk()})),n(e.socket,j,(function(t){e.log(e.TAG_NAME,"websocket message",t.data)})),n(e.socket,I,(function(t){e.socketStatus=A,e.warn(e.TAG_NAME,"websocket close -> reject",t),e.emit(b),r(t)})),n(e.socket,D,(function(t){e.socketStatus=x,e.error(e.TAG_NAME,"websocket error -> reject",t),e.emit(y,t),r(t)}))}))}},{key:"_sendClose",value:function(){}},{key:"_initTalk",value:function(){this._initMethods(),this._opt.engine===z?this._initWorklet():this._opt.engine===q&&this._initScriptProcessor(),this.log(this.TAG_NAME,"audioContext samplerate",this.audioContext.sampleRate)}},{key:"_initMethods",value:function(){this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3}),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.biquadFilter=this.audioContext.createBiquadFilter(),this.biquadFilter.type="lowpass",this.biquadFilter.frequency.value=3e3,this.resampler=new $({fromSampleRate:this.audioContext.sampleRate,toSampleRate:this._opt.sampleRate,channels:this._opt.numberChannels,inputBufferSize:this.bufferSize})}},{key:"_initScriptProcessor",value:function(){var e=this,t=this.audioContext.createScriptProcessor||this.audioContext.createJavaScriptNode;this.recorder=t.apply(this.audioContext,[this.bufferSize,this._opt.numberChannels,this._opt.numberChannels]),this.recorder.onaudioprocess=function(t){return e._onaudioprocess(t)}}},{key:"_initWorklet",value:function(){var e=this,t=function(e){var t=e.toString().trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1],r=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(r)}((function(){var e=function(e){function t(e){var r;return h(this,t),r=c(this,t),r._cursor=0,r._bufferSize=e.processorOptions.bufferSize,r._buffer=new Float32Array(r._bufferSize),r}return f(t,e),p(t,[{key:"process",value:function(e,t,r){if(!e.length||!e[0].length)return!0;for(var n=0;n>8,t[s++]=255&l>>0}t[s++]=128,t[s++]=128+r,t[s++]=n/256,t[s++]=n%256,t[s++]=o/65536/256,t[s++]=o/65536%256,t[s++]=o%65536/256,t[s++]=o%65536%256,t[s++]=i/65536/256,t[s++]=i/65536%256,t[s++]=i%65536/256,t[s++]=i%65536%256;for(var c=t.concat(u(e)),f=new Uint8Array(c.length),d=0;d0&&void 0!==arguments[0]?arguments[0]:{};return e=c(this,t),e.talk=null,e._opt=r,e.LOG_TAG="JbProTalk",e.debug=new ee(i(e)),e.debug.log(e.LOG_TAG,"init",JSON.stringify(r)),e}return f(t,e),p(t,[{key:"destroy",value:function(){this.debug.log(this.LOG_TAG,"destroy()"),this.off(),this.talk&&(this.talk.destroy(),this.talk=null),this.debug.log(this.LOG_TAG,"destroy")}},{key:"_initTalk",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.talk&&(this.debug.log(this.LOG_TAG,"_initTalk this.talk is not null and destroy"),this.talk.destroy(),this.talk=null);var t=Object.assign({},V(this._opt),e);this.talk=new re(null,t),this.debug.log(this.LOG_TAG,"_initTalk",this.talk.getOption()),this._bindTalkEvents()}},{key:"_bindTalkEvents",value:function(){var e=this;Object.keys(T).forEach((function(t){e.talk.on(T[t],(function(r){e.emit(t,r)}))}))}},{key:"startTalk",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,o){t.debug.log(t.LOG_TAG,"startTalk",e,JSON.stringify(r)),t._initTalk(r),t.talk.startTalk(e).then((function(){n(),t.talk.once(b,(function(){t.debug.warn(t.LOG_TAG,"talkStreamClose -> stopTalk"),t.stopTalk().catch((function(e){t.debug.warn(t.LOG_TAG,"talkStreamClose stopTalk",e)})).finally((function(){t.emit(_,b)}))})),t.talk.once(y,(function(e){t.debug.error(t.LOG_TAG,"talkStreamError -> stopTalk"),t.stopTalk().catch((function(e){t.debug.warn(t.LOG_TAG,"talkStreamError stopTalk",e)})).finally((function(){t.emit(_,y)}))})),t.talk.once(w,(function(){t.debug.warn(t.LOG_TAG,"talkStreamInactive -> stopTalk"),t.stopTalk().catch((function(e){t.debug.warn(t.LOG_TAG,"talkStreamInactive stopTalk",e)})).finally((function(){t.emit(_,w)}))})),t.talk.once(g,(function(){t.debug.warn(t.LOG_TAG,"talkGetUserMediaTimeout -> stopTalk"),t.stopTalk().catch((function(e){t.debug.warn(t.LOG_TAG,"talkGetUserMediaTimeout stopTalk",e)})).finally((function(){t.emit(_,g)}))}))})).catch((function(e){o(e)}))}))}},{key:"stopTalk",value:function(){var e=this;return new Promise((function(t,r){e.debug.log(e.LOG_TAG,"stopTalk()"),e.talk||r("talk is not init"),e.talk.destroy(),e.talk=null,t()}))}},{key:"getTalkVolume",value:function(){var e=this;return new Promise((function(t,r){e.talk||r("talk is not init"),t(e.talk.volume)}))}},{key:"setTalkVolume",value:function(e){var t=this;return new Promise((function(r,n){t.debug.log(t.LOG_TAG,"setTalkVolume",e),t.talk||n("talk is not init"),t.talk.setVolume(e/100),r()}))}},{key:"downloadTempRtpFile",value:function(){var e=this;return new Promise((function(t,r){e.talk?(e.talk.downloadRtpFile(),t()):r("talk is not init")}))}},{key:"downloadTempG711File",value:function(){var e=this;return new Promise((function(t,r){e.talk?(e.talk.downloadG711File(),t()):r("talk is not init")}))}},{key:"downloadTempPcmFile",value:function(){var e=this;return new Promise((function(t,r){e.talk?(e.talk.downloadPcmFile(),t()):r("talk is not init")}))}},{key:"downloadTempFile",value:function(){var e=this;return new Promise((function(t,r){e.talk?(e.talk.downloadFile(),t()):r("talk is not init")}))}}])}(e);return ne.EVENTS=T,window.JessibucaProTalk=ne,window.JbProTalk=ne,window.WebPlayerProTalk=ne,ne}))},b17c:function(e,t,r){r("14d9"),r("4ae1");var n=r("6f8f"),o=r("4a4b");function i(e,t,r){if(n())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var a=new(e.bind.apply(e,i));return r&&o(a,r.prototype),a}e.exports=i,e.exports.__esModule=!0,e.exports["default"]=e.exports},c5f7:function(e,t,r){function n(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}r("d3b7"),r("25f0"),e.exports=n,e.exports.__esModule=!0,e.exports["default"]=e.exports},cfc3:function(e,t,r){var n=r("74e8");n("Float32",(function(e){return function(t,r,n){return e(this,t,r,n)}}))},ded3b:function(e,t,r){r("a4d3"),r("4de4"),r("14d9"),r("e439"),r("dbb4"),r("b64b"),r("d3b7"),r("159b");var n=r("9523");function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;te)r[e]=arguments[e++];return r}),o)},ed6d:function(e,t,r){r("d9e2");var n=r("4a4b");function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&n(e,t)}e.exports=o,e.exports.__esModule=!0,e.exports["default"]=e.exports},fd87:function(e,t,r){var n=r("74e8");n("Int8",(function(e){return function(t,r,n){return e(this,t,r,n)}}))}}]);