trtc-sdk-v5 5.13.1-wasm.3 → 5.13.1-wasm.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/chorus/package.json +1 -1
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/package.json +1 -1
- package/plugins/small-stream-auto-switcher/package.json +1 -1
- package/plugins/video-decoder/package.json +1 -1
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/video-mixer/package.json +1 -1
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/voice-changer/package.json +1 -1
- package/trtc.esm.js +2 -2
- package/trtc.js +1 -1
package/package.json
CHANGED
package/trtc.esm.js
CHANGED
|
@@ -89,13 +89,13 @@ return ret;
|
|
|
89
89
|
`,G=0;G<S-1;++G)w[G+1].deleteObject&&(he+=" argType"+G+".deleteObject(arg"+G+`);
|
|
90
90
|
`);P.isVoid||(he+=` return retType.toWireType(destructors, rv);
|
|
91
91
|
`),he+=`};
|
|
92
|
-
`,z.push(he);var ve,fe,we=wc(Function,z).apply(null,Y);return ve=we,fe=Ms.length,Ms.push(ve),W=fe,Os[B]=W,W},f:()=>{cr("")},c:Hn,t:(S,T,w)=>D.copyWithin(S,T,T+w),s:S=>{D.length,cr("OOM")},i:(S,T,w,P)=>{for(var B,W,z,Y=0,re=0;re<w;re++){var G=Se[T>>2],he=Se[T+4>>2];T+=8;for(var De=0;De<he;De++)B=S,W=D[G+De],z=void 0,z=Vc[B],W===0||W===10?((B===1?g:E)(Vo(z,0)),z.length=0):z.push(W);Y+=he}return Se[P>>2]=Y,0}},br=(function(){var S,T,w,P,B={a:Fc};function W(z,Y){var re,G,he=z.exports;return A=(C=he).v,re=A.buffer,o.HEAP8=N=new Int8Array(re),o.HEAP16=x=new Int16Array(re),o.HEAP32=ue=new Int32Array(re),o.HEAPU8=D=new Uint8Array(re),o.HEAPU16=Z=new Uint16Array(re),o.HEAPU32=Se=new Uint32Array(re),o.HEAPF32=Ye=new Float32Array(re),o.HEAPF64=H=new Float64Array(re),Pe=C.z,G=C.w,kn.unshift(G),function(){if(Br--,o.monitorRunDependencies&&o.monitorRunDependencies(Br),Br==0&&(Rs!==null&&(clearInterval(Rs),Rs=null),Bi)){var De=Bi;Bi=null,De()}}(),he}if(Br++,o.monitorRunDependencies&&o.monitorRunDependencies(Br),o.instantiateWasm)try{return o.instantiateWasm(B,W)}catch(z){E("Module.instantiateWasm callback failed with error: "+z),r(z)}(S=p,T=ci,w=B,P=function(z){W(z.instance)},S||typeof WebAssembly.instantiateStreaming!="function"||ie(T)||typeof fetch!="function"?Hr(T,w,P):fetch(T,{credentials:"same-origin"}).then(z=>WebAssembly.instantiateStreaming(z,w).then(P,function(Y){return E("wasm streaming compile failed: "+Y),E("falling back to ArrayBuffer instantiation"),Hr(T,w,P)}))).catch(r)}(),S=>(br=C.x)(S)),Zi=S=>(Zi=C.y)(S),xs=S=>(xs=C.A)(S),$c=(o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=C.B)(),S=>($c=C.C)(S));o.dynCall_jiji=(S,T,w,P,B)=>(o.dynCall_jiji=C.D)(S,T,w,P,B);function Bc(){function S(){Ft||(Ft=!0,o.calledRun=!0,xn||(ui(kn),e(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)T=o.postRun.shift(),Ln.unshift(T);var T;ui(Ln)}()))}Br>0||(function(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)T=o.preRun.shift(),Pn.unshift(T);var T;ui(Pn)}(),Br>0||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),S()},1)):S()))}if(Bi=function S(){Ft||Bc(),Ft||(Bi=S)},o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Bc(),t.ready}})();var My="web.sdk.qcloud.com",Oy=`https://${My}/trtc/webrtc/v5/doc`,sP=`${Oy}/zh-cn/`,EE=(i=>(i[i.TRACE=0]="TRACE",i[i.DEBUG=1]="DEBUG",i[i.INFO=2]="INFO",i[i.WARN=3]="WARN",i[i.ERROR=4]="ERROR",i[i.NONE=5]="NONE",i))(EE||{});var _E={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},nP=_E["480p_2"],aP=_E["120p_2"],Ou={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture",RESIZE:"resize",TIME_UPDATE:"timeupdate"},cP=Ou.MAIN,dP=Ou.AUXILIARY,uP=Ou.BIG,lP=Ou.SMALL;var mP=Object.keys(EE);var xy=function(i,t,e,r){return new(e||(e=Promise))(function(o,s){function n(m){try{u(r.next(m))}catch(p){s(p)}}function a(m){try{u(r.throw(m))}catch(p){s(p)}}function u(m){var p;m.done?o(m.value):(p=m.value,p instanceof e?p:new e(function(g){g(p)})).then(n,a)}u((r=r.apply(i,t||[])).next())})},np=Symbol(32),ap=Symbol(16),cp=Symbol(8),op=class{constructor(i){this.g=i,this.consumed=0,i&&(this.need=i.next().value)}setG(i){this.g=i,this.demand(i.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(i,t){return t&&this.consume(),this.need=i,this.flush()}read(i){return xy(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((t,e)=>{var r;this.reject=e,this.resolve=o=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(o)},this.demand(i,!0)||(r=this.pull)===null||r===void 0||r.call(this,i)})})}readU32(){return this.read(np)}readU16(){return this.read(ap)}readU8(){return this.read(cp)}close(){var i;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),(i=this.reject)===null||i===void 0||i.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let i=null,t=this.buffer.subarray(this.consumed),e=0,r=o=>t.length<(e=o);if(typeof this.need=="number"){if(r(this.need))return;i=t.subarray(0,e)}else if(this.need===np){if(r(4))return;i=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===ap){if(r(2))return;i=t[0]<<8|t[1]}else if(this.need===cp){if(r(1))return;i=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(r(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,e)),i=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(r(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,e)),i=this.need}return this.consumed+=e,this.g?this.demand(this.g.next(i).value,!0):this.resolve&&this.resolve(i),i}write(i){if(i instanceof Uint8Array?this.malloc(i.length).set(i):"buffer"in i?this.malloc(i.byteLength).set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)):this.malloc(i.byteLength).set(new Uint8Array(i)),!this.g&&!this.resolve)return new Promise(t=>this.pull=t);this.flush()}writeU32(i){this.malloc(4).set([i>>24&255,i>>16&255,i>>8&255,255&i]),this.flush()}writeU16(i){this.malloc(2).set([i>>8&255,255&i]),this.flush()}writeU8(i){this.malloc(1)[0]=i,this.flush()}malloc(i){if(this.buffer){let t=this.buffer.length,e=t+i;if(e<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,e);else{let r=new Uint8Array(e);r.set(this.buffer),this.buffer=r}return this.buffer.subarray(t,e)}return this.buffer=new Uint8Array(i),this.buffer}};op.U32=np,op.U16=ap,op.U8=cp;var Py=127,hP=~Py,pP=Math.pow(2,31),fP=typeof window!="undefined"&&typeof window.glog=="function"?window.glog:()=>{},gP=typeof HTMLMediaElement!="undefined"&&"setSinkId"in HTMLMediaElement.prototype;function hE(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var{toString:EP}=Object.prototype,TE=class IE{constructor(t){this.core=t,$r(this,"contextMap",new Map),$r(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}getAlias(){return"videoDecoder"}getGroup(t){return t!=null&&t.track?`${t.track.userId}${t.track.streamType}`:"*"}getName(){return IE.Name}getValidateRule(t){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(t,e){var r;switch(t){case"wasm":let s=((r=this.core.assetsPath)==null?void 0:r.replace(/\/+$/,""))||".";return new wy(Du(Nu({},e),{wasmPath:`${s}/videodec.wasm`}));case"webCodecs":return new vn;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(t){this.decodeProcessorMap.set(t.track,this.decode(t)),this.core.room.videoManager.addDecodeProcessor({processor:({frame:e,track:r})=>{var o;return((o=this.decodeProcessorMap.get(r))==null?void 0:o({frame:e,track:r}))||e},type:3})}decode(t){let{pipe:e,take:r,subscribe:o}=this.core.rx;return({frame:s,track:n})=>{if(n!==t.track||s.type==="empty")return s;if(this.contextMap.has(n))return this.contextMap.get(n).decode(s);let a=this.core.room.videoManager.createDecodeContext(Du(Nu({},t),{createDecoder:this.createDecoder}));return e(a.trackDoneOB,r(1),o(()=>{this.core.clearStarted(this,this.getGroup(t)),this.stop({track:n})})),this.contextMap.set(n,a),a.decode(s)}}stop(t){if(t!=null&&t.track){let e=this.contextMap.get(t.track);e&&(e.close("stop"),this.report(e,t.track),this.contextMap.delete(t.track))}else this.contextMap.forEach((e,r)=>{e.close("stop"),this.contextMap.delete(r)});this.contextMap.size===0&&this.core.room.videoManager.removeDecodeProcessor({type:3})}report(t,e){if(t.isReported)return;t.isReported=!0;let r=hE()-t.startPerformanceTime,{renderFreezeTotal:o,dataFreezeTotal:s}=this.getRemoteTrackFreezeDuration(e,t),n=`report health data: ${t.track.userId} ${t.track.streamType} ${t.type}+${t.renderer} goodType\uFF1A${t.goodType} ${t.failedReason?`failedReason: ${t.failedReason}`:""}`;r&&(this.core.kvStatManager.addNumber({key:514850,value:Math.floor(o/r*100),split:1,max:100}),n+=` RENDER_FREEZE_RATE: ${Math.floor(o/r*100)}%`),r&&(this.core.kvStatManager.addNumber({key:514851,value:Math.floor(s/r*100),split:1,max:100}),n+=` DATA_FREEZE_RATE: ${Math.floor(s/r*100)}%`),t.inputFrameCount&&(this.core.kvStatManager.addNumber({key:514852,value:Math.floor(t.decodedFrameCount/t.inputFrameCount*100),split:1,max:100}),n+=` VIDEO_CONSUME_RENDER_RATE: ${Math.floor(t.decodedFrameCount/t.inputFrameCount*100)}%`),this.core.log.info(n)}addKVReportBeforeExitRoom({room:t}){t===this.core.room&&this.contextMap.forEach((e,r)=>{this.report(e,r)})}update(t){let e=this.contextMap.get(t.track);e&&(t.type!=="mock"?(e.close("update"),this.contextMap.set(t.track,this.core.room.videoManager.createDecodeContext(Du(Nu({},t),{createDecoder:this.createDecoder})))):e.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}getRemoteTrackFreezeDuration(t,e){let r=this.core.room.badCaseDetector.getRenderFreezeMap().get(`${t.userId}_${t.streamType}`),o=this.core.room.badCaseDetector.getDataFreezeMap().get(`${t.userId}_${t.streamType}`),s=0;r&&r.freezeTimeline.forEach(({startTime:a,endTime:u})=>{a>e.startPerformanceTime&&(s+=u===0?hE()-a:u-a)});let n=0;return o&&o.durationItemList.forEach(a=>{a.startTime>e.startPerformanceTime&&(n+=a.getDuration())}),{renderFreezeTotal:s,dataFreezeTotal:n}}destroy(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}};$r(TE,"Name","TRTCVideoDecoder");var dp=TE;var XE=pi(bi());function up({timesInSecond:i,maxSizeInSecond:t,getSize:e}){return Me((r,o)=>{let s=new WeakMap;return U.on(F.ROOM_DESTROY,({room:n})=>s.delete(n)),function(...n){let a=s.get(this);if(a||(a={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},s.set(this,a)),a.timestamp===0?a.timestamp=Date.now():Date.now()-a.timestamp>1e3&&(a.timestamp=Date.now(),a.callCountInSecond=0,a.totalSizeInSecond=0),e&&(a.totalSizeInSecond+=e(...n)),a.timestamp!==0&&Date.now()-a.timestamp<1e3&&(a.callCountInSecond>=i||a.totalSizeInSecond>t))throw new de({code:q.INVALID_OPERATION,message:$e({key:Fe.CALL_FREQUENCY_LIMIT,data:{isTimes:a.callCountInSecond>=i,isSize:a.totalSizeInSecond>t,name:o,timesInSecond:i,maxSizeInSecond:t}})});a.callCountInSecond++,r.call(this,...n)}})}var ky="2025-09-26 11:09:10",SE=!0,yE=function(){var i;if(SE){SE=!1,$.getLogLevel()!==5&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info(`* API Document: ${qr}/en/index.html`),console.info(`* Changelog: ${qr}/en/tutorial-01-info-changelog.html`),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),$.info("TRTC Web SDK Version:",at),Pr||$.debug("Build Time:",ky);let t=`UA: ${navigator.userAgent}
|
|
92
|
+
`,z.push(he);var ve,fe,we=wc(Function,z).apply(null,Y);return ve=we,fe=Ms.length,Ms.push(ve),W=fe,Os[B]=W,W},f:()=>{cr("")},c:Hn,t:(S,T,w)=>D.copyWithin(S,T,T+w),s:S=>{D.length,cr("OOM")},i:(S,T,w,P)=>{for(var B,W,z,Y=0,re=0;re<w;re++){var G=Se[T>>2],he=Se[T+4>>2];T+=8;for(var De=0;De<he;De++)B=S,W=D[G+De],z=void 0,z=Vc[B],W===0||W===10?((B===1?g:E)(Vo(z,0)),z.length=0):z.push(W);Y+=he}return Se[P>>2]=Y,0}},br=(function(){var S,T,w,P,B={a:Fc};function W(z,Y){var re,G,he=z.exports;return A=(C=he).v,re=A.buffer,o.HEAP8=N=new Int8Array(re),o.HEAP16=x=new Int16Array(re),o.HEAP32=ue=new Int32Array(re),o.HEAPU8=D=new Uint8Array(re),o.HEAPU16=Z=new Uint16Array(re),o.HEAPU32=Se=new Uint32Array(re),o.HEAPF32=Ye=new Float32Array(re),o.HEAPF64=H=new Float64Array(re),Pe=C.z,G=C.w,kn.unshift(G),function(){if(Br--,o.monitorRunDependencies&&o.monitorRunDependencies(Br),Br==0&&(Rs!==null&&(clearInterval(Rs),Rs=null),Bi)){var De=Bi;Bi=null,De()}}(),he}if(Br++,o.monitorRunDependencies&&o.monitorRunDependencies(Br),o.instantiateWasm)try{return o.instantiateWasm(B,W)}catch(z){E("Module.instantiateWasm callback failed with error: "+z),r(z)}(S=p,T=ci,w=B,P=function(z){W(z.instance)},S||typeof WebAssembly.instantiateStreaming!="function"||ie(T)||typeof fetch!="function"?Hr(T,w,P):fetch(T,{credentials:"same-origin"}).then(z=>WebAssembly.instantiateStreaming(z,w).then(P,function(Y){return E("wasm streaming compile failed: "+Y),E("falling back to ArrayBuffer instantiation"),Hr(T,w,P)}))).catch(r)}(),S=>(br=C.x)(S)),Zi=S=>(Zi=C.y)(S),xs=S=>(xs=C.A)(S),$c=(o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=C.B)(),S=>($c=C.C)(S));o.dynCall_jiji=(S,T,w,P,B)=>(o.dynCall_jiji=C.D)(S,T,w,P,B);function Bc(){function S(){Ft||(Ft=!0,o.calledRun=!0,xn||(ui(kn),e(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)T=o.postRun.shift(),Ln.unshift(T);var T;ui(Ln)}()))}Br>0||(function(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)T=o.preRun.shift(),Pn.unshift(T);var T;ui(Pn)}(),Br>0||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),S()},1)):S()))}if(Bi=function S(){Ft||Bc(),Ft||(Bi=S)},o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Bc(),t.ready}})();var My="web.sdk.qcloud.com",Oy=`https://${My}/trtc/webrtc/v5/doc`,sP=`${Oy}/zh-cn/`,EE=(i=>(i[i.TRACE=0]="TRACE",i[i.DEBUG=1]="DEBUG",i[i.INFO=2]="INFO",i[i.WARN=3]="WARN",i[i.ERROR=4]="ERROR",i[i.NONE=5]="NONE",i))(EE||{});var _E={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},nP=_E["480p_2"],aP=_E["120p_2"],Ou={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture",RESIZE:"resize",TIME_UPDATE:"timeupdate"},cP=Ou.MAIN,dP=Ou.AUXILIARY,uP=Ou.BIG,lP=Ou.SMALL;var mP=Object.keys(EE);var xy=function(i,t,e,r){return new(e||(e=Promise))(function(o,s){function n(m){try{u(r.next(m))}catch(p){s(p)}}function a(m){try{u(r.throw(m))}catch(p){s(p)}}function u(m){var p;m.done?o(m.value):(p=m.value,p instanceof e?p:new e(function(g){g(p)})).then(n,a)}u((r=r.apply(i,t||[])).next())})},np=Symbol(32),ap=Symbol(16),cp=Symbol(8),op=class{constructor(i){this.g=i,this.consumed=0,i&&(this.need=i.next().value)}setG(i){this.g=i,this.demand(i.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(i,t){return t&&this.consume(),this.need=i,this.flush()}read(i){return xy(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((t,e)=>{var r;this.reject=e,this.resolve=o=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(o)},this.demand(i,!0)||(r=this.pull)===null||r===void 0||r.call(this,i)})})}readU32(){return this.read(np)}readU16(){return this.read(ap)}readU8(){return this.read(cp)}close(){var i;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),(i=this.reject)===null||i===void 0||i.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let i=null,t=this.buffer.subarray(this.consumed),e=0,r=o=>t.length<(e=o);if(typeof this.need=="number"){if(r(this.need))return;i=t.subarray(0,e)}else if(this.need===np){if(r(4))return;i=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===ap){if(r(2))return;i=t[0]<<8|t[1]}else if(this.need===cp){if(r(1))return;i=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(r(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,e)),i=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(r(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,e)),i=this.need}return this.consumed+=e,this.g?this.demand(this.g.next(i).value,!0):this.resolve&&this.resolve(i),i}write(i){if(i instanceof Uint8Array?this.malloc(i.length).set(i):"buffer"in i?this.malloc(i.byteLength).set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)):this.malloc(i.byteLength).set(new Uint8Array(i)),!this.g&&!this.resolve)return new Promise(t=>this.pull=t);this.flush()}writeU32(i){this.malloc(4).set([i>>24&255,i>>16&255,i>>8&255,255&i]),this.flush()}writeU16(i){this.malloc(2).set([i>>8&255,255&i]),this.flush()}writeU8(i){this.malloc(1)[0]=i,this.flush()}malloc(i){if(this.buffer){let t=this.buffer.length,e=t+i;if(e<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,e);else{let r=new Uint8Array(e);r.set(this.buffer),this.buffer=r}return this.buffer.subarray(t,e)}return this.buffer=new Uint8Array(i),this.buffer}};op.U32=np,op.U16=ap,op.U8=cp;var Py=127,hP=~Py,pP=Math.pow(2,31),fP=typeof window!="undefined"&&typeof window.glog=="function"?window.glog:()=>{},gP=typeof HTMLMediaElement!="undefined"&&"setSinkId"in HTMLMediaElement.prototype;function hE(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var{toString:EP}=Object.prototype,TE=class IE{constructor(t){this.core=t,$r(this,"contextMap",new Map),$r(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}getAlias(){return"videoDecoder"}getGroup(t){return t!=null&&t.track?`${t.track.userId}${t.track.streamType}`:"*"}getName(){return IE.Name}getValidateRule(t){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(t,e){var r;switch(t){case"wasm":let s=((r=this.core.assetsPath)==null?void 0:r.replace(/\/+$/,""))||".";return new wy(Du(Nu({},e),{wasmPath:`${s}/videodec.wasm`}));case"webCodecs":return new vn;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(t){this.decodeProcessorMap.set(t.track,this.decode(t)),this.core.room.videoManager.addDecodeProcessor({processor:({frame:e,track:r})=>{var o;return((o=this.decodeProcessorMap.get(r))==null?void 0:o({frame:e,track:r}))||e},type:3})}decode(t){let{pipe:e,take:r,subscribe:o}=this.core.rx;return({frame:s,track:n})=>{if(n!==t.track||s.type==="empty")return s;if(this.contextMap.has(n))return this.contextMap.get(n).decode(s);let a=this.core.room.videoManager.createDecodeContext(Du(Nu({},t),{createDecoder:this.createDecoder}));return e(a.trackDoneOB,r(1),o(()=>{this.core.clearStarted(this,this.getGroup(t)),this.stop({track:n})})),this.contextMap.set(n,a),a.decode(s)}}stop(t){if(t!=null&&t.track){let e=this.contextMap.get(t.track);e&&(e.close("stop"),this.report(e,t.track),this.contextMap.delete(t.track))}else this.contextMap.forEach((e,r)=>{e.close("stop"),this.contextMap.delete(r)});this.contextMap.size===0&&this.core.room.videoManager.removeDecodeProcessor({type:3})}report(t,e){if(t.isReported)return;t.isReported=!0;let r=hE()-t.startPerformanceTime,{renderFreezeTotal:o,dataFreezeTotal:s}=this.getRemoteTrackFreezeDuration(e,t),n=`report health data: ${t.track.userId} ${t.track.streamType} ${t.type}+${t.renderer} goodType\uFF1A${t.goodType} ${t.failedReason?`failedReason: ${t.failedReason}`:""}`;r&&(this.core.kvStatManager.addNumber({key:514850,value:Math.floor(o/r*100),split:1,max:100}),n+=` RENDER_FREEZE_RATE: ${Math.floor(o/r*100)}%`),r&&(this.core.kvStatManager.addNumber({key:514851,value:Math.floor(s/r*100),split:1,max:100}),n+=` DATA_FREEZE_RATE: ${Math.floor(s/r*100)}%`),t.inputFrameCount&&(this.core.kvStatManager.addNumber({key:514852,value:Math.floor(t.decodedFrameCount/t.inputFrameCount*100),split:1,max:100}),n+=` VIDEO_CONSUME_RENDER_RATE: ${Math.floor(t.decodedFrameCount/t.inputFrameCount*100)}%`),this.core.log.info(n)}addKVReportBeforeExitRoom({room:t}){t===this.core.room&&this.contextMap.forEach((e,r)=>{this.report(e,r)})}update(t){let e=this.contextMap.get(t.track);e&&(t.type!=="mock"?(e.close("update"),this.contextMap.set(t.track,this.core.room.videoManager.createDecodeContext(Du(Nu({},t),{createDecoder:this.createDecoder})))):e.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}getRemoteTrackFreezeDuration(t,e){let r=this.core.room.badCaseDetector.getRenderFreezeMap().get(`${t.userId}_${t.streamType}`),o=this.core.room.badCaseDetector.getDataFreezeMap().get(`${t.userId}_${t.streamType}`),s=0;r&&r.freezeTimeline.forEach(({startTime:a,endTime:u})=>{a>e.startPerformanceTime&&(s+=u===0?hE()-a:u-a)});let n=0;return o&&o.durationItemList.forEach(a=>{a.startTime>e.startPerformanceTime&&(n+=a.getDuration())}),{renderFreezeTotal:s,dataFreezeTotal:n}}destroy(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}};$r(TE,"Name","TRTCVideoDecoder");var dp=TE;var XE=pi(bi());function up({timesInSecond:i,maxSizeInSecond:t,getSize:e}){return Me((r,o)=>{let s=new WeakMap;return U.on(F.ROOM_DESTROY,({room:n})=>s.delete(n)),function(...n){let a=s.get(this);if(a||(a={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},s.set(this,a)),a.timestamp===0?a.timestamp=Date.now():Date.now()-a.timestamp>1e3&&(a.timestamp=Date.now(),a.callCountInSecond=0,a.totalSizeInSecond=0),e&&(a.totalSizeInSecond+=e(...n)),a.timestamp!==0&&Date.now()-a.timestamp<1e3&&(a.callCountInSecond>=i||a.totalSizeInSecond>t))throw new de({code:q.INVALID_OPERATION,message:$e({key:Fe.CALL_FREQUENCY_LIMIT,data:{isTimes:a.callCountInSecond>=i,isSize:a.totalSizeInSecond>t,name:o,timesInSecond:i,maxSizeInSecond:t}})});a.callCountInSecond++,r.call(this,...n)}})}var ky="2025-09-26 17:19:44",SE=!0,yE=function(){var i;if(SE){SE=!1,$.getLogLevel()!==5&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info(`* API Document: ${qr}/en/index.html`),console.info(`* Changelog: ${qr}/en/tutorial-01-info-changelog.html`),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),$.info("TRTC Web SDK Version:",at),Pr||$.debug("Build Time:",ky);let t=`UA: ${navigator.userAgent}
|
|
93
93
|
CPU core: ${navigator.hardwareConcurrency}, GPU: ${lm()}`,e=navigator.deviceMemory;e&&(t+=`, minRAM: ${e}GB`),$.info(t),$.info(`URL: ${location.href}${((i=self.frameElement)==null?void 0:i.tagName)==="IFRAME"?" in iframe":""}`),Yo().then(r=>{r&&$.info(wr)})}};var Ts={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear",SPEAKER:"Speakerphone",HEADSET:"Headset earpiece"};var se={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},Ir=(k=>(k[k.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",k[k.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",k[k.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",k[k.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",k[k.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",k[k.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",k[k.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",k[k.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",k[k.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",k[k.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",k[k.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",k[k.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",k[k.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",k[k.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",k[k.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",k[k.INVALID_ROOM_ID_REQUIRED=5015]="INVALID_ROOM_ID_REQUIRED",k[k.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",k[k.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",k[k.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",k[k.INVALID_ROOM_ID_TYPE_MISMATCH=5019]="INVALID_ROOM_ID_TYPE_MISMATCH",k[k.INVALID_ROOM_ID_DUPLICATE=5020]="INVALID_ROOM_ID_DUPLICATE",k[k.INVALID_OPERATION=5100]="INVALID_OPERATION",k[k.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",k[k.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",k[k.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",k[k.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",k[k.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",k[k.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",k[k.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",k[k.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",k[k.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",k[k.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",k[k.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",k[k.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",k[k.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",k[k.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",k[k.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",k[k.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",k[k.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",k[k.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",k[k.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",k[k.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",k[k.DEVICE_ERROR=5300]="DEVICE_ERROR",k[k.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",k[k.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",k[k.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",k[k.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",k[k.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",k[k.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",k[k.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",k[k.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",k[k.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",k[k.SERVER_ERROR=5400]="SERVER_ERROR",k[k.NEED_TO_BUY=5401]="NEED_TO_BUY",k[k.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",k[k.OPERATION_FAILED=5500]="OPERATION_FAILED",k[k.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",k[k.REJOIN_FAILED=5502]="REJOIN_FAILED",k[k.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",k[k.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",k[k.VIDEO_ENCODE_FAILED=5505]="VIDEO_ENCODE_FAILED",k[k.AUDIO_ENCODE_FAILED=5506]="AUDIO_ENCODE_FAILED",k[k.VIDEO_DECODE_FAILED=5507]="VIDEO_DECODE_FAILED",k[k.AUDIO_DECODE_FAILED=5508]="AUDIO_DECODE_FAILED",k[k.OPERATION_ABORT=5998]="OPERATION_ABORT",k[k.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",k))(Ir||{});function bE({code:i,params:t,enableDocLink:e=!1}){let r="",o,s=Ir[i];try{o=AE[s]}catch(n){o=AE.UNKNOWN_ERROR}return Ge(o)?r=o(t):Ne(o)&&(r=o),t.fnName&&!r.includes(t.fnName)&&(r[r.length-1]!=="."&&(r+="."),r+=` thrown from ${t.fnName}()`),e&&(r+=" doc:"),r}var AE=ge(X({},Zt),{INVALID_PARAMETER({fnName:i}){return`the parameters of the '${i}' you called does not meet the requirements, please check the API documentation.`},INVALID_PARAMETER_REQUIRED({key:i,rule:t,fnName:e,value:r}){return`'${i||t.name}' is a required param when calling ${e}(), received: ${r}.`},INVALID_PARAMETER_TYPE({key:i,rule:t,fnName:e,value:r}){let o=`${i||t.name}`,s="";return Array.isArray(t.type)?s=t.type.join("|"):s=t.type,`'${o}' must be type of ${s} when calling ${e}(), received type: ${ct(r)}.`},INVALID_PARAMETER_EMPTY({key:i,rule:t,fnName:e,value:r}){return`'${i||t.name}' cannot be '${r}' when calling ${e}().`},INVALID_PARAMETER_INSTANCE({key:i,rule:t,fnName:e,value:r}){let o=`${i||t.name}`,s=`${t.instanceOf.name||t.instanceOf}`;return`'${o}' must be instanceof ${s} when calling ${e}(), received type: ${ct(r)}.`},INVALID_PARAMETER_RANGE({key:i,rule:t,fnName:e,value:r}){return`'${i||t.name}' must be one of ${t.values.join("|")} when calling ${e}(), received: ${r}.`},INVALID_PARAMETER_LESS_THAN_ZERO({key:i,rule:t,fnName:e}){return`'${i||t.name}' cannot be less than 0 when calling ${e}().`},INVALID_PARAMETER_MIN({key:i,rule:t,value:e}){return`the min value of ${i||t.name} is ${t.min}, received: ${e}.`},INVALID_PARAMETER_MAX({key:i,rule:t,value:e}){return`the max value of ${i||t.name} is ${t.max}, received: ${e}.`},INVALID_ELEMENT_ID({key:i,fnName:t}){return`'${i}' is not found in the document object when calling ${t}().`},INVALID_ELEMENT_ID_TYPE({key:i,fnName:t,type:e}){return`the element corresponding to '${i}' must be instanceof HTMLElement when calling ${t}(), received: ${e}.`},INVALID_STREAM_ID({key:i}){return`'${i}' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.`},INVALID_ROOM_ID_STRING({key:i}){return`'${i}' must be a valid string.`},INVALID_ROOM_ID_INTEGER({key:i}){return`'${i}' must be an integer between [1, 4294967294].`},INVALID_ROOM_ID_INTEGER_STRING({key:i}){return`'${i}' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.`},INVALID_ROOM_ID_REQUIRED(){return"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required."},INVALID_ROOM_ID_TYPE_MISMATCH({key:i}){return`The type of target roomId must match the current roomId. Current room is using '${i}', but received '${i==="strRoomId"?"roomId":"strRoomId"}'.`},INVALID_ROOM_ID_DUPLICATE({key:i}){return`the target '${i}' must not be the same as the current '${i}'.`},INVALID_STREAM_TYPE:({fnName:i})=>`'streamType' is required when 'userId' is not '*', calling ${i}()`,INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION({fnName:i}){return`the API '${i}' you called does not meet the requirements, please check the API documentation.`},INVALID_OPERATION_NOT_JOINED({fnName:i}){return`cannot ${i} because you are not enter room yet.`},INVALID_OPERATION_REMOTE_USER_NOT_EXIST({fnName:i,value:t}){return`cannot ${i} because remote user(userId: ${t.userId}) does not publishing stream.`},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST({fnName:i,value:t}){return`cannot ${i} because remote user(userId: ${t.userId}) does not publishing ${t.streamType} video.`},INVALID_OPERATION_REPEAT_CALL({fnName:i}){return`you are already ${i}(), cannot repeated call '${i}'.`},INVALID_OPERATION_NEED_VIDEO({fnName:i}){return`cannot call '${i}' because the camera is not turned on.`},INVALID_OPERATION_NEED_AUDIO({fnName:i}){return`cannot call '${i}' because the microphone or screen share is not turned on.`},INVALID_BUFFER_EMPTY:({key:i})=>`the buffer size of paramerter '${i}' cannot be empty`,INVALID_BUFFER_OVERSIZE:()=>"buffer size is over 1000 Bytes",INVALID_ROLE_AUDIENCE:()=>"role: 'audience' cannot call this api.",INVALID_NOT_ENABLE_SEI:()=>"you need to enable SEI in TRTC.create({ enableSEI: true })",INVALID_NEED_CALL_PUBLISHED:({fnName:i})=>`you need to call ${i}() after publish stream.`,ENV_NOT_SUPPORTED({fnName:i}){return`the current browser does not support the capability of the function '${i}' you are calling, please check the API documentation.`},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION({fnName:i}){return`cannot call ${i} because the browser version is too low, please upgrade to the latest version`},DEVICE_ERROR({fnName:i,error:t}){return`'${i}' got device exception${t?`, error: ${t.toString()}.`:"."}`},DEVICE_NOT_FOUND_ERROR({fnName:i,deviceType:t=Is(i),error:e}){return`NotFoundError, no ${t} detected, please check your device and the configuration on '${i}'${e?`, error: ${e.toString()}.`:"."}`},DEVICE_NOT_ALLOWED_ERROR({fnName:i,deviceType:t=Is(i),error:e}){return`NotAllowedError, you have disabled ${t} access, please allow the current application to use the ${t}${e?`, error: ${e.toString()}.`:"."}`},DEVICE_NOT_READABLE_ERROR({fnName:i,deviceType:t=Is(i),error:e}){return`NotReadableError, the ${t} maybe in use by another APP, please check if the device is pre-occupied by another APP.`},DEVICE_OVERCONSTRAINED_ERROR({fnName:i,deviceType:t=Is(i),error:e}){return`OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct${e?`, error: ${e.toString()}.`:"."}`},DEVICE_INVALID_STATE_ERROR({fnName:i,deviceType:t=Is(i),error:e}){return`InvalidStateError, after the user clicks and interacts with the page, turn on the ${t}${e?`, error: ${e.toString()}.`:"."}`},DEVICE_SECURITY_ERROR({fnName:i,deviceType:t=Is(i),error:e}){return`SecurityError, check whether the system security policy restricts the use of the ${t}, and it is recommended to turn on the ${t} after the user interacts with the page${e?`, error: ${e.toString()}.`:"."}`},DEVICE_ABORT_ERROR({fnName:i,deviceType:t=Is(i),error:e}){return`AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal${e?` error: ${e.toString()}.`:"."}`},CAMERA_RECOVER_FAILED({error:i}){return`camera recover capture failed ${(i==null?void 0:i.name)||""}: ${(i==null?void 0:i.originMessage)||(i==null?void 0:i.message)}`},MICROPHONE_RECOVER_FAILED({error:i}){return`microphone recover capture failed ${(i==null?void 0:i.name)||""}: ${(i==null?void 0:i.originMessage)||(i==null?void 0:i.message)}`},OPERATION_FAILED({fnName:i,error:t}){return`'${i}' failed, reason: ${t==null?void 0:t.toString()}`},FIREWALL_RESTRICTION(){return"media connection failure due to firewall restrictions, please try to change your network."},EVENT_HANDLER_ERROR({eventName:i}){return`an error was caught on trtc.on('${i}', handler), please check your code on 'handler'.`},VIDEO_CONTEXT_ERROR({reason:i,error:t}){return`video context error ${i} ${(t==null?void 0:t.name)||""} ${(t==null?void 0:t.message)||""}`},SERVER_ERROR({fnName:i,error:t}){return`'${i}' got server error: ${t==null?void 0:t.toString()}, please check the SDK documentation.`},NEED_TO_BUY({value:i,url:t}){return`You need to buy packages for ${i}. Refer to: ${t}`},ACCOUNT_NO_MONEY:({fnParams:i})=>`your TRTC account run out of credit, please recharge.${i.sdkAppId?` SDKAppId: ${i.sdkAppId}`:""}`,OPERATION_ABORT({fnName:i}){return`'${i}' abort`},UNKNOWN_ERROR({fnName:i,error:t}){return`'${i}' throw unknown exception${t?`, error: ${t.toString()}.`:"."}`}});function Is(i){if(!i)return"camera";let t=i.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var lp=class i extends Error{constructor({code:e,extraCode:r,message:o="",messageParams:s,fnName:n="",originError:a,data:u}){var p;let m;o?m=o:m=bE({code:e===se.SERVER_ERROR?e:r||e,params:X({fnName:n,error:a},s)});super(m);l(this,"name","RtcError");l(this,"code");l(this,"extraCode");l(this,"functionName");l(this,"message");l(this,"data");l(this,"handler");l(this,"originError");this.name=Ir[e],this.code=e,this.extraCode=r,this.functionName=n,this.originError=a,this.message=m,this.data=u,this.extraCode===5302&&((p=this.originError)!=null&&p.message.includes("system"))&&(this.handler=()=>{let g={startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"},E={startLocalVideo:"webcam",startLocalAudio:"microphone"},A=document.createElement("a");Qo?A.href=`ms-settings:privacy-${E[this.functionName]}`:Or&&(A.href=`x-apple.systempreferences:com.apple.preference.security?Privacy_${g[this.functionName]}`),A.href.length>0&&A.click()})}static convertFrom(e,r,o){let s=e;if(e instanceof de){let{stack:n}=e,a={code:se.UNKNOWN_ERROR,fnName:r,originError:e};switch(e.getCode()){case q.INVALID_PARAMETER:a.code=se.INVALID_PARAMETER,a.message=e.message;break;case q.INVALID_OPERATION:a.code=se.INVALID_OPERATION;break;case q.NOT_SUPPORTED:case q.NOT_SUPPORTED_H264:a.code=se.ENV_NOT_SUPPORTED,e.getCode()===q.NOT_SUPPORTED_H264&&(a.extraCode=e.message.includes(Zt.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case q.JOIN_ROOM_FAILED:a.messageParams={fnParams:o};case q.SERVER_TIMEOUT:case q.SWITCH_ROLE_FAILED:case q.SWITCH_ROOM_FAILED:a.code=se.SERVER_ERROR,a.extraCode=e.getExtraCode();break;case q.API_CALL_ABORTED:a.code=se.OPERATION_ABORT;break;case q.DEVICE_NOT_FOUND:case q.DEVICE_AUTO_RECOVER_FAILED:case q.INITIALIZE_FAILED:a.code=5300,e.name&&(a.extraCode=Ly(e.name));break;case q.VIDEO_ENCODE_FAILED:a.extraCode=5505;case q.AUDIO_ENCODE_FAILED:a.extraCode=5506,a.code=se.OPERATION_FAILED;break;case q.UNKNOWN:break;default:a.code=se.OPERATION_FAILED}s=new i(a),n&&(s.stack+=n.substr(n.indexOf(`
|
|
94
94
|
`)))}else{if(e instanceof i)return e;s=new i({code:se.UNKNOWN_ERROR,fnName:r,originError:e})}return s}};function Ly(i){let t;switch(i){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}var oe=lp;function oi(i){return i==="sub"?"auxiliary":i==="auxiliary"?"sub":"main"}function cc(i){return i===Ts.QOS_PREFERENCE_CLEAR?"detail":i===Ts.QOS_PREFERENCE_SMOOTH?"motion":""}function Cn(i,t){let e=t?Ml:Yn;return Yl(i)?X(X({},e),i):Cr[i]?Cr[i]:e}var RE={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{type:["string","object","boolean"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},vE={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},Nn={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(i,t,e){if(Ne(i)&&!document.getElementById(i))throw new oe({code:se.INVALID_PARAMETER,extraCode:5009,fnName:e,messageParams:{key:t}})}},CE={name:"userId",required:!0,type:"string"},NE={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{type:["string","object"],properties:{bitrate:{type:"number"},channelCount:{type:"number"}}},echoCancellation:{values:[!0,!1,"remote-only","all"]},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function Dn(i,t){if(!i)throw new oe({code:se.INVALID_OPERATION,extraCode:5101,fnName:t})}function DE(i,t,e){if(!i)throw new oe({code:se.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:e}})}function wE(i,t,e){if(!(/^[1-9]\d*$/.test(String(i))&&i<4294967295))throw new oe({code:se.INVALID_PARAMETER,extraCode:5013,fnName:t,messageParams:{key:e}})}function ME(i,t,e){if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(i))throw new oe({code:se.INVALID_PARAMETER,extraCode:5012,fnName:t,messageParams:{key:e}})}var Bk={type:"number",notLessThanZero:!0},Uy=(i,t)=>i.width*i.height>=t.width*t.height&&i.frameRate>=t.frameRate&&i.bitrate>=t.bitrate;function OE(i){var r;if(!((r=i==null?void 0:i.option)!=null&&r.small))return;if(!Wd()){$.warn("small stream is not supported"),delete i.option.small;return}let t=Cn(i.option.profile),e=Cn(i.option.small,!0);if(!Uy(t,e)){$.warn(`small stream profile must be less than big stream profile. Big: ${JSON.stringify(t)}, Small: ${JSON.stringify(e)}`),delete i.option.small;return}}var Vy={create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate(i,t,e){if(this._room.isJoined)throw new oe({code:se.INVALID_OPERATION,extraCode:5104,fnName:e});if(i.roomId){if(Ne(i.roomId))throw new oe({code:se.INVALID_PARAMETER,extraCode:5016,fnName:e,messageParams:{key:t}});wE(i.roomId,e,t)}else if(i.strRoomId)ME(i.strRoomId,e,t);else throw new oe({code:se.INVALID_PARAMETER,extraCode:5015,fnName:e})},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"},latencyLevel:{type:"number"},playoutDelay:{type:"object",properties:{min:{type:"number",min:0,max:1e3},max:{type:"number",min:0,max:1e4}}}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:Nn,mute:{type:["boolean","string"]},publish:{type:"boolean"},capture:{required:!1,type:"boolean"},option:RE},validate(i){var t,e;if(!((t=i==null?void 0:i.option)!=null&&t.videoTrack)&&wi())throw new oe({code:se.ENV_NOT_SUPPORTED,extraCode:5201});(e=i==null?void 0:i.option)!=null&&e.small&&OE(i)}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:ge(X({},Nn),{required:!1}),publish:{type:"boolean"},capture:{required:!1,type:"boolean"},mute:{type:["boolean","string"]},option:RE},validate(i){var t;(t=i==null?void 0:i.option)!=null&&t.small&&OE(i)}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:NE},validate(i){var t;if(!((t=i==null?void 0:i.option)!=null&&t.audioTrack)&&wi())throw new oe({code:se.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:NE}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:Nn,publish:{type:"boolean"},option:vE},validate(i,t,e,r,o){var s;if(!((s=i==null?void 0:i.option)!=null&&s.videoTrack)){if(wi())throw new oe({code:se.ENV_NOT_SUPPORTED,extraCode:5201});if(!xa())throw new oe({code:se.ENV_NOT_SUPPORTED,fnName:e,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:Nn,publish:{type:"boolean"},option:vE}},muteRemoteAudio:[CE,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[CE,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:Nn,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(i,t,e){Dn(this._room.isJoined,e);let r=this._room.remotePublishedUserMap.get(i.userId);if(DE(!!r,e,i),r&&(i.streamType==="main"&&!r.muteState.videoAvailable||i.streamType==="sub"&&!r.muteState.hasAuxiliary))throw new oe({code:se.INVALID_OPERATION,extraCode:5103,fnName:e,messageParams:{value:i}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:ge(X({},Nn),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(i,t,e){Dn(this._room.isJoined,e);let r=this._room.remotePublishedUserMap.get(i.userId);if(DE(!!r,e,i),r&&(i.streamType==="main"&&!r.muteState.videoAvailable||i.streamType==="sub"&&!r.muteState.hasAuxiliary))throw new oe({code:se.INVALID_OPERATION,extraCode:5103,fnName:e,messageParams:{value:i}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate(i,t,e){if(i.userId!=="*"&&M(i.streamType))throw new oe({code:se.INVALID_PARAMETER,extraCode:5014,fnName:e})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(i,t,e){Dn(this._room.isJoining||this._room.isJoined,e)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate(i,t,e,r){if(!ka)throw new oe({code:se.ENV_NOT_SUPPORTED,fnName:e,extraCode:5207});if(!this._room.enableSEI)throw new oe({code:se.INVALID_OPERATION,fnName:e,extraCode:5108});if(i.byteLength>1e3)throw new oe({code:se.INVALID_PARAMETER,extraCode:5018,fnName:e});if(i.byteLength===0)throw new oe({code:se.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:e});Dn(this._room.isJoined,e)}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]},toSubStream:{type:"boolean",validate(i,t,e){if(!i&&!this._room.isMainStreamPublished||i&&!this._room.isAuxStreamPublished)throw new oe({code:se.INVALID_OPERATION,extraCode:5109,messageParams:{key:t},fnName:e})}}}}],sendCustomMessage:{name:"message",required:!0,type:"object",properties:{cmdId:{type:"number",required:!0,min:1,max:10},data:{instanceOf:ArrayBuffer,required:!0,validate(i,t,e,r){if(i.byteLength>1e3)throw new oe({code:se.INVALID_PARAMETER,extraCode:5018,fnName:e});if(i.byteLength===0)throw new oe({code:se.INVALID_PARAMETER,extraCode:5017,fnName:e,messageParams:{key:t}})}}},validate(i,t,e){if(Dn(this._room.isJoined,e),this._room.scene==="live"&&this._room.role==="audience")throw new oe({code:se.INVALID_OPERATION,extraCode:5107,fnName:e,messageParams:{key:t}})}},switchRoom:{name:"switchRoomConfig",type:"object",required:!0,validate(i,t,e){if(Dn(this._room.isJoined,e),this._room.useStringRoomId&&i.strRoomId===this._room.roomId||!this._room.useStringRoomId&&i.roomId===Number(this._room.roomId))throw new oe({code:se.INVALID_PARAMETER,extraCode:5020,fnName:e,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(i.roomId&&this._room.useStringRoomId||!i.roomId&&i.strRoomId&&!this._room.useStringRoomId)throw new oe({code:se.INVALID_PARAMETER,extraCode:5019,fnName:e,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(i.roomId)wE(i.roomId,e,t);else if(i.strRoomId)ME(i.strRoomId,e,t);else throw new oe({code:se.INVALID_PARAMETER,extraCode:5015,fnName:e})},properties:{roomId:{type:"number"},strRoomId:{type:"string"},privateMapKey:{type:"string"},userSig:{type:"string",required:!0},autoSubscribeCount:{type:"number",min:0,max:50}}}},Ct={TRTC:Vy};var Gt=class extends Error{};function Fy(i,t){let e=Go(i);for(let r=0;r<t.length;r++)Dr(e[r],t[r]);return e}function $y(i){this._resolve=Promise.resolve(i)}function By(i){this._reject=Promise.reject(i)}var yo=class yo{constructor(t,e){this.instance=t;this.group=e;l(this,"started",!1);l(this,"ops",[]);l(this,"startSame",()=>!0);l(this,"mergeUpdate",Fy);let r=yo.instances.get(t);r?r.set(e,this):yo.instances.set(t,new Map([[e,this]]))}static get(t,e){if(!e)return;let r=yo.instances.get(t);return r&&r.get(e)||new yo(t,e)}static gets(t,e){let r=yo.instances.get(t),o=[];return r&&r.forEach((s,n)=>{e.test(n)&&o.push(s)}),o}action(t,e,r){let o=a=>{var u;return t===0?this.started=!0:t===3&&(this.started=!1),this.ops.shift(),(u=this.currentOp)==null||u.action(),a},s=a=>{var u,m;throw this.ops.shift(),t===0&&((u=this.currentOp)==null?void 0:u.type)===2&&this.ops.shift().reject(new Gt("start failed")),(m=this.currentOp)==null||m.action(),a},n={type:t,action:()=>e(...n.args).then(o,s),args:r,resolve:$y,reject:By};try{switch(this.state){case 1:if(t===0)throw new Gt("already started");break;case 4:if(t===2)throw new Gt("not started");break;default:return this.cacheOp(n)}}catch(a){return Promise.reject(a)}return this.ops.push(n),n.promise=e(...n.args).then(o,s)}cacheOp(t){if(this.ops.length===1)switch(this.state){case 0:case 2:if(t.type===0)throw new Gt("already start");break;case 3:switch(t.type){case 2:throw new Gt("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new Gt("unknown state")}else switch(t.type){case 3:switch(this.lastOpType){case 3:return this.lastOp.promise;default:let r=new Gt("keep stop");if(this.ops.slice(1).forEach(o=>o.reject(r)),this.ops=this.ops.slice(0,1),this.state===3)return this.currentOp.promise}break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,t.args),this.lastOp.promise;case 3:throw new Gt("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new Gt("start not allowed after update");case 0:throw new Gt("duplicate start");case 3:if(this.startSame(this.currentOp.args,t.args))throw this.ops.pop().reject(new Gt("keep start")),new Gt("already start")}}t.promise=new Promise((r,o)=>{t._resolve?t._resolve.then(r):t.resolve=r,t._reject?t._reject.catch(o):t.reject=o});let{action:e}=t;return t.action=()=>e().then(t.resolve,t.reject),this.ops.push(t),t.promise}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}get currentOp(){return this.ops[0]}get state(){return this.currentOp?this.currentOp.type:this.started?1:4}};l(yo,"instances",new WeakMap);var Vi=yo;var xu=new WeakMap,Pu=(i,t)=>{if(t instanceof Gt){let{stack:e}=t;t=new oe({code:se.OPERATION_ABORT,message:`${i} abort: ${t.message}`,fnName:i}),e&&(t.stack+=e.substr(e.indexOf(`
|
|
95
95
|
`)))}throw t};function Ao(i,t){return Me((e,r)=>function(...o){let s=Vi.get(this,typeof i=="string"?i:i.call(this,...o));return s?(t&&(s.startSame=t.bind(this)),s.action(0,e.bind(this),o).catch(Pu.bind(null,r))):e.apply(this,o)})}function Ss(i,t){let{merge:e,debounce:r}=t||{};return Me((o,s)=>function(...n){let a=Vi.get(this,typeof i=="string"?i:i.call(this,...n));if(!a)return o.apply(this,n);if(e&&(a.mergeUpdate=e.bind(this)),r&&r.isNeedToDebounce.apply(this,n)){let{delay:u,getKey:m}=r;return new Promise((p,g)=>{var C,N;let E=(C=xu.get(this))==null?void 0:C.get(m(...n));if(E){let{timeoutId:D,resolve:x}=E;clearTimeout(D),x()}let A=setTimeout(()=>{if(a.state===3||a.state===4)return p();a.action(2,o.bind(this),n).catch(Pu.bind(null,s)).then(p,g)},u);xu.has(this)?(N=xu.get(this))==null||N.set(m(...n),{timeoutId:A,resolve:p}):xu.set(this,new Map([[m(...n),{timeoutId:A,resolve:p}]]))})}return a.action(2,o.bind(this),n).catch(Pu.bind(null,s))})}function bo(i){return Me((t,e)=>function(...r){let o=typeof i=="function"?i.call(this,...r):i;if(o instanceof RegExp)return Promise.all(Vi.gets(this,o).map(n=>n.action(3,()=>Promise.resolve(),r))).then(()=>t.call(this,...r));let s=Vi.get(this,o);return s?s.action(3,t.bind(this),r).catch(Pu.bind(null,e)):t.apply(this,r)})}var K={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",AUDIO_FRAME:"audio-frame",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",TRACK:"track",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",CUSTOM_MESSAGE:"custom-message",VIDEO_DECODE_DOWNGRADE_STATE_CHANGED:"video-decode-downgrade-state-changed",LAYER_DATA:"layerData",FIRST_VIDEO_FRAME:"first-video-frame",PERMISSION_STATE_CHANGE:"permission-state-change",VIDEO_SIZE_CHANGED:"video-size-changed"},xE=new Set([K.ERROR,K.AUTOPLAY_FAILED,K.KICKED_OUT,K.REMOTE_USER_ENTER,K.REMOTE_USER_EXIT,K.REMOTE_AUDIO_AVAILABLE,K.REMOTE_AUDIO_UNAVAILABLE,K.REMOTE_VIDEO_AVAILABLE,K.REMOTE_VIDEO_UNAVAILABLE,K.CONNECTION_STATE_CHANGED,K.PUBLISH_STATE_CHANGED,K.SCREEN_SHARE_STOPPED,K.DEVICE_CHANGED,K.FIRST_VIDEO_FRAME,K.PERMISSION_STATE_CHANGE,K.VIDEO_SIZE_CHANGED]);var fp={};hi(fp,{ScheduleRequestType:()=>kE,getAbilityConfig:()=>Wy,getScheduleDomain:()=>Uu,isNeedToSchedule:()=>ku,scheduleProxy:()=>si,sendScheduleRequest:()=>pp,setIsNeedToSchedule:()=>ys,setScheduleProxy:()=>Lu});var hp=null,ku=!0;typeof document!="undefined"&&document.head.insertAdjacentHTML("beforeend",Object.values(Ei).map(i=>`<link rel="dns-prefetch" href="https://${i}">`).join(`\r
|
|
96
96
|
`));function ys(i){Qe(i)&&i!==ku&&(ku=i,$.info(`setIsNeedToSchedule ${i}`))}U.on("28",()=>ys(!0));U.on("63",()=>ys(!0));U.on("84",()=>ys(!0));U.on("201",i=>{i.state==="RECONNECTING"&&ys(!0)});U.on("202",i=>{i.state==="RECONNECTING"&&ys(!0)});function Hy(i,t,e){let r={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};try{let o=performance.getEntriesByType("resource"),s=Ro(i,"config",O.MAIN),n=Ro(i,"config",O.BACKUP);for(let a of o)if(a.startTime>=e&&(a.name===s||a.name===n)&&a.transferSize>0){let u=a.name===s?O.MAIN:O.BACKUP,m=Math.round(a.duration),p=Math.round(a.domainLookupStart-a.startTime),g=a.redirectStart>0?Math.round(a.redirectEnd-a.redirectStart):0,E=a.fetchStart>0?Math.round(a.domainLookupStart-a.fetchStart):0,A=Math.round(a.domainLookupEnd-a.domainLookupStart),C=Math.round(a.requestStart-a.secureConnectionStart),N=Math.round(a.secureConnectionStart-a.connectStart),D=Math.round(a.responseStart-a.requestStart),x=Math.round(a.responseEnd-a.responseStart),Z=[A,C,N,D,x];He.uploadEvent({log:`stat-schedule-net:${m}(${p}(${g}->${E})->${Z.join("->")}) ${u}`,userId:t}),r=ge(X({},r),{totalCost:m,local:p,dns:A,tcp:N,tls:C,request:D,response:x});break}}catch(o){$.error("getScheduleDetailCost error",o)}return r}function pp(m){return y(this,arguments,function*({userId:i,sdkAppId:t,useStringRoomId:e,roomId:r,userSig:o,version:s,frameWorkType:n,role:a,latencyLevel:u}){var g;if(!ku&&hp)return{isCached:!0,result:hp};let p={delta:0,count:[1,1],msg:[],detail:[]};try{let E=new FormData;E.append("userId",String(i)),E.append("sdkAppId",String(t)),E.append("isStrGroupId",String(e)),E.append("groupId",String(r)),E.append("sdkVersion",s),E.append("userSig",String(o));let A=((g=yield Yo())==null?void 0:g.model)||Cd();A&&E.append("model",A),a&&E.append("role",String(a)),u&&E.append("latencyLevel",String(u)),n&&E.append("frameWorkType",String(n));let C=_e(),N=yield jy(E,p,t);N.config&&(N.config.loggerDomain&&$o(N.config.loggerDomain),Qe(N.config.scheduleCache)&&ys(!N.config.scheduleCache)),p.delta=_e()-C;let D=Hy(Number(t),i,C);return hp=N,{isCached:!1,result:N,detailCost:D}}catch(E){let A=st(E)?E[0]:E,C=ke(A.code)?A.code:0,N=`schedule failed${A.message?`: ${A.message}`:""}`,D=new de({code:q.SCHEDULE_FAILED,extraCode:C,message:$e({key:Fe.JOIN_ROOM_FAILED,data:{error:N,code:C}})});throw $.error(N,C),D}})}var si={main:"",backup:""};function Lu(i){st(i)?(si.main=i[0],si.backup=i[1]):si.main=i}var kE=(r=>(r.CONFIG="config",r.TRTC_AUTO_CONF="trtcAutoConf",r.AUDIO_AI_AUTH="audioAiAuth",r))(kE||{});function Ro(i,t,e=O.MAIN,r=!1){return`https://${si[e]||Uu(i,e,r)}/api/v1/${t}`}function Wy(i,t,e){let r=Ro(i,t),o=Ro(i,t,O.BACKUP),s=new URLSearchParams(e).toString(),n=fetch(`${r}?${s}`).then(u=>u.json()),a=fetch(`${o}?${s}`).then(u=>u.json());return sa([n,a])}function Uu(i,t=O.MAIN,e=!1){let r;return _i(i)?e?r=t===O.MAIN?Ei.MAIN_OVERSEA_BACKUP:Ei.BACKUP_OVERSEA:r=t===O.MAIN?Ei.MAIN_OVERSEA:Ei.BACKUP_OVERSEA:r=t===O.MAIN?Ei.MAIN:Ei.BACKUP,r}function Gy(i,t,e){return new Promise((r,o)=>{Si({url:i,body:t,timeout:e.timeout,priority:"high"}).then(s=>{s.data.code===0?r(s.data.data):o({code:s.data.code,message:s.data.msg})}).catch(o)})}var PE=(i,t)=>so({retryFunction:Gy,settings:{retries:3,timeout:0},onError:t,onRetrying:i});function jy(i,t,e){return new Promise((r,o)=>{let s=null;sa([PE(n=>t.count[0]=n+1,({error:n,retry:a,retriedCount:u,retryFuncArgs:m})=>{t.msg[0]=n.message,s||(u>=1&&(m[0]=Ro(e,"config",O.MAIN,!0)),a())})(Ro(e,"config",O.MAIN),i,{get timeout(){return jo(2+t.count[0])*1e3}}),PE(n=>t.count[1]=n+1,({error:n,retry:a,retriedCount:u,retryFuncArgs:m})=>{t.msg[1]=n.message,s||(u>=2&&(m[0]=Ro(e,"config",O.BACKUP,!0)),a())})(Ro(e,"config",O.BACKUP),i,{get timeout(){return jo(2+t.count[1])*1e3}})]).then(n=>{s=n,r(s)}).catch(o)})}var qy=i=>i.startsWith("data:application/octet-stream;base64,"),zy=i=>i.startsWith("file://"),dc=class{constructor(){l(this,"_log");this._log=$.createLogger({id:"fd"})}download(t,e){return y(this,null,function*(){let{type:r="blob"}=e||{};t=Jo(t);try{let o=_e(),s;if(Ge(fetch)?s=yield this.downloadWithFetch(t,r):s=yield this.downloadWithXHR(t,r),!s||!s.data)throw new Error("data is empty");let n=_e()-o;return this._log.info(`downloaded: ${t}, return type: ${r}, cost: ${n}ms`),Q.addSuccessEvent({key:522700,cost:_e()-o}),s.data}catch(o){throw this._log.error(`failed to download: ${t}, error: ${o}`),Q.addFailedEvent({key:522700,error:o}),o}})}downloadWithFetch(t,e){return y(this,null,function*(){this._log.info(`download with fetch: ${t}, return type: ${e}`);try{let r=yield fetch(t);if(!r.ok){let s=new Error(`network response was not ok: ${r.status}`);throw s.status=r.status,s}let o;return e==="arraybuffer"?o=yield r.arrayBuffer():o=yield r.blob(),{data:o}}catch(r){throw r}})}downloadWithXHR(t,e){return this._log.info(`download with xhr: ${t}, return type: ${e}`),new Promise((r,o)=>{let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType=e,s.onload=()=>{if(s.status===200||s.status===0&&s.response)r({data:s.response});else{let n=new Error(`XHR failed, status: ${s.status}`);n.status=s.status,o(n)}},s.onerror=o,s.send(null)})}loadWasm(t,e){return y(this,null,function*(){this._log.info(`loadWasm ${t}, importObject: ${JSON.stringify(e)}`);let r=_e(),o=null,s=null;if(Ge(WebAssembly.instantiateStreaming)&&!qy(t)&&!zy(t)&&Ge(fetch))try{let n=fetch(t);o=(yield WebAssembly.instantiateStreaming(n,e)).instance}catch(n){s=n}if(!o)try{let n=yield this.download(t,{type:"arraybuffer"});o=(yield WebAssembly.instantiate(n,e)).instance}catch(n){s=n}if(o){let n=_e()-r;return this._log.info(`loadedWasm ${t}, cost: ${n}ms`),Q.addSuccessEvent({key:522701,cost:n}),o}throw this._log.error(`failed to loadWasm ${t}, error: ${s}`),Q.addFailedEvent({key:522701,error:s}),s})}loadScript(t){this._log.info(`loadScript ${t}`);let e=_e();return new Promise((r,o)=>{let s=document.createElement("script");s.type="text/javascript",s.onload=()=>{this._log.info(`loadedScript ${t}, cost: ${_e()-e}ms`),Q.addSuccessEvent({key:522702,cost:_e()-e,split:1e3}),r(s)},s.onerror=n=>{this._log.error(`failed to loadScript ${t}, error: ${(n==null?void 0:n.message)||JSON.stringify(n)}`),Q.addFailedEvent({key:522702}),o(n)},s.crossOrigin="anonymous",s.src=t,document.head.append?document.head.append(s):document.getElementsByTagName("head")[0].appendChild(s)})}};te([as({settings:{timeout:0,retries:3},onError(t,e,r){var o;(t==null?void 0:t.status)===404||(o=t==null?void 0:t.message)!=null&&o.includes("404")?(this._log.warn("download 404, stop retry"),r(t)):e()},onRetrying(t){this._log.warn(`download retrying: ${t}`)}})],dc.prototype,"download",1),te([as({settings:{timeout:3e3,retries:3},onRetrying(t){this._log.warn(`loadScript retrying: ${t}`)}})],dc.prototype,"loadScript",1);var uc=new dc;function LE({TRTC:i,room:t,errorModule:e,assetsPath:r}){return{TRTC:i,LocalMixVideoTrack:Es,LocalVideoTrack:ar,LocalScreenTrack:ri,room:t,assetsPath:r,fileDownloader:uc,innerEmitter:U,INNER_EVENT:F,constants:kl,environment:an,utils:Kh,eventLogger:He,log:this.room.getLogger(),loggerManager:$,errorModule:e,kvStatManager:Q,rtcDectection:lo,trtc:this,rx:Qh,enums:Om,schedule:fp,getDevices:fn,initVisionTaskRegistry:(o,s="/mediapipe/vision.js")=>y(this,null,function*(){window.VisionTaskRegistry||(yield uc.loadScript(`${o}/${s}`.replace(/([^:]\/)\/+/g,"$1"))),yield(yield window.VisionTaskRegistry.getInstance(o)).preloadModels([window.VisionTaskType.ImageSegmenter])}),audioContext:We(),deviceDetector:rt,AudioPlayer:En,AutoPlayDialog:mn,Timer:dt,clearStarted:(o,s)=>{let n=o.getAlias(),a=Vi.instances.get(this);if(a)if(s){let u=a.get(n+s);if(!u)return;u.started=!1}else a.forEach((u,m)=>{m.startsWith(n)&&(u.started=!1)})},startGetPCM:oc,createAudioNode:ja,getNetworkTimeOffset:Yp}}var UE=(i,t)=>{let{emit:e}=i;return i.emit=(...r)=>{try{return e.apply(i,r)}catch(o){let s=$e({key:Fe.CATCH_HANDLER_ERROR,data:{name:t,event:r[0]},addDocLink:!1});return $.warn(`${s}
|
|
97
97
|
|
|
98
|
-
${o.stack}`),!1}},i};var wn=new WeakMap;function VE(i){let t=wn.get(i);t&&(t.forEach(e=>clearTimeout(e)),wn.delete(i))}function FE(i,t){return Me((e,r)=>function(...o){let s=wn.get(this);s||(s=new Map,wn.set(this,s));let n=t(...o),a=s.get(n);if(!a||a<=0){e.apply(this,o);let u=setTimeout(()=>{var m;(m=wn.get(this))==null||m.delete(n)},i);s.set(n,u)}else{clearTimeout(a);let u=window.setTimeout(()=>{var m;e.apply(this,o),(m=wn.get(this))==null||m.delete(n)},i);s.set(n,u)}})}var BE="trtc-sdk-v5",gp="5.13.1-wasm.3";function Pt(...i){return Me((t,e)=>function(...r){try{Fu.call(this,i,r,e,this._name)}catch(o){return Promise.reject(o)}return t.apply(this,r)})}function Ep(...i){return Me((t,e)=>function(...r){try{Fu.call(this,i,r,e,this._name)}catch(o){throw o}return t.apply(this,r)})}function Fu(i,t,e,r){if(st(i))for(let o=0;o<i.length;o++)Vu.call(this,{rule:i[o],value:t[o],key:i[o].name,fnName:e,className:r});else Vu.call(this,{rule:i,value:t[0],key:i.name,fnName:e,className:r})}function Vu({rule:i,value:t,key:e,fnName:r,className:o}){function s(u){return{code:se.INVALID_PARAMETER,extraCode:u,fnName:r,messageParams:{key:e,rule:i,value:t}}}if(M(t)){if(i.required)throw new oe(s(5001));if(M(i.defaultValue)){Ge(i.validate)&&i.validate.call(this,t,e,r,o,this);return}t=i.defaultValue}if(Array.isArray(i.type)){let u=!1;for(let m=0;m<i.type.length;m++)i.type[m]===null&&t===null&&(u=!0),Ge(i.type[m])&&t instanceof i.type[m]&&(u=!0),Ne(i.type[m])&&ct(t)===i.type[m].toLowerCase()&&(u=!0);if(!u)throw new oe({code:se.INVALID_PARAMETER,extraCode:5002,fnName:r,messageParams:{key:e,rule:{type:i.type.map(m=>qo(m)?Ws(m):Ne(m)?m:ct(m))},value:t}})}else if(!M(i.type)&&ct(t)!==i.type)throw new oe(s(5002));if(i.allowEmpty===!1){let u=ke(t)&&(t===0||Number.isNaN(t)),m=Ne(t)&&t.trim()==="";if(u||m)throw new oe(s(5003))}if(i.notLessThanZero&&ke(t)&&t<0)throw new oe(s(5006));if(!M(i.min)&&ke(t)&&t<i.min)throw new oe(s(5007));if(!M(i.max)&&ke(t)&&t>i.max)throw new oe(s(5008));if(Ne(i.instanceOf)){if(!t||t._name!==i.instanceOf)throw new oe(s(5004))}else if(Ge(i.instanceOf)&&!(t instanceof i.instanceOf))throw new oe(s(5004));if(Array.isArray(i.values)&&!i.values.includes(t))throw new oe(s(5005));let{properties:n}=i;Bt(n)&&or(t)&&Object.keys(n).forEach(u=>{Vu.call(this,{rule:n[u],value:t&&t[u],key:`${u}`,fnName:r,className:o})});let{arrayItem:a}=i;Bt(a)&&st(t)&&t.forEach((u,m)=>{Vu.call(this,{rule:a,value:u,key:`${e}[${m}]`,fnName:r,className:o})}),Ge(i.validate)&&i.validate.call(this,t,e,r,o,this)}function tt(i={}){let{getRemoteId:t=()=>"",replaceArg:e,getKVReportKey:r,ignoreLog:o,ignoreErrorLog:s}=i;return Me((n,a)=>function(...u){var A,C,N;function m(D,x,Z){if(Z&&Z.includes(D))return"hided";if(e){let ue=e(...u);if(u[ue.argIndex]===x)return ue.value}if(x===u||D in u)return x;try{return x instanceof HTMLElement?`id: ${x.id} type:${ct(x)}`:x instanceof MediaStreamTrack?sd(x):(JSON.stringify(x),x)}catch(ue){return`type:${ct(x)}`}}let p=this._log||$;if(o!=null&&o(...u))return n.apply(this,u);u.length>0?p.info(`${a}() ${JSON.stringify(u,(D,x)=>m(D,x,["userSig","privateMapKey"]))}`):p.info(`${a}()`);let g=r?r(...u):Ud[a],E=(s==null?void 0:s(...u))||!1;try{let D=n.apply(this,u),x=_e();if(io(D)){let Z=`${a.includes("Plugin")?`${((C=(A=u[0]).getName)==null?void 0:C.call(A))||""} `:" "}`;return D.then(ue=>(p.info(`${a}() success ${Z}${t.call(this,...u)}`),Q.addSuccessEvent({key:g,cost:_e()-x}),ue)).catch(ue=>{var H;ue=oe.convertFrom.call(this,ue,a,u.length===1?u[0]:u);let Se=ue.extraCode||ue.code,Ye=(H=ue.message)!=null&&H.includes(Se)?"":` code:${Se}`;throw E||p.error(`${a}() failed ${Z}${t.call(this,...u)} ${ue}${Ye} params: ${JSON.stringify(u,m)}`),Q.addFailedEvent({key:g,error:ue}),ue})}return Q.addSuccessEvent({key:g}),D}catch(D){D=oe.convertFrom.call(this,D,a);let x=D.extraCode||D.code,Z=(N=D.message)!=null&&N.includes(x)?"":` code:${x}`;throw E||p.error(`${a}() failed ${D}${Z} params: ${JSON.stringify(u,m)}`),Q.addFailedEvent({key:g,error:D}),D}})}var $u=i=>Me((t,e)=>function(r,o){return y(this,null,function*(){let s=this._plugins.get(r);if(!s)throw this._log.error(`plugin ${String(r)} is not found`),new oe({code:se.OPERATION_ABORT,message:`plugin ${String(r)} is not found`,fnName:e});if(Ge(s.constructor.isSupported)&&!s.constructor.isSupported())throw this._log.error(`plugin ${String(r)} is not supported`),new oe({code:se.ENV_NOT_SUPPORTED,message:`plugin ${String(r)} is not supported`,extraCode:5210,fnName:e});return Fu.call(this,s.getValidateRule(i),[o],e,"TRTC"),t.call(this,s,o)})});var Bu=0,_p,Fi=class Fi{constructor(t){this.core=t;l(this,"log");l(this,"customAudioReferenceMap",new Map);l(this,"audioRefId",0);l(this,"audioContext",We());l(this,"localAudioWorkletNode");l(this,"screenAudioWorkletNode");l(this,"mixNode");l(this,"silentNode");Bu=Bu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Bu}`}),this.log.info(`created id=${this.getAlias()}${Bu}`),this.installEvent()}static getStartValidateRule(t){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate(e,r,o,s){if(!t.room.audioManager.hasAudioTrack&&!t.room.audioManager.hasScreenAudioTrack)throw new oe({code:se.INVALID_OPERATION,extraCode:5106,fnName:o})}}}preload(t){return _p||(_p=this.doPreload(t)),_p}doPreload(t){return y(this,null,function*(){let e=yield this.core.fileDownloader.download(t,{type:"blob"}),r=URL.createObjectURL(e);try{yield xi(this.audioContext,r)}catch(o){this.log.error(`preload audioProcessor failed. ${o}`)}finally{URL.revokeObjectURL(r)}})}getName(){return Fi.Name}getAlias(){return"ap"}getGroup(){return"ap"}getValidateRule(t){switch(t){case"start":return Fi.getStartValidateRule(this.core);case"update":return Fi.updateValidateRule;case"stop":return Fi.stopValidateRule}}start(t){return y(this,null,function*(){var E,A,C,N;let{room:e}=this.core,{sdkAppId:r,userId:o,userSig:s,assetsPath:n=this.core.assetsPath,audioReference:a,processLevel:u,enableDump:m,isLocalAudioNeedAudioProcess:p=!0,isScreenAudioNeedAudioProcess:g=!1}=t;if(this.core.room.audioManager.isLocalAudioNeedAudioProcess=p,this.core.room.audioManager.isScreenAudioNeedAudioProcess=g,!n)throw new oe({code:se.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(yield this.preload(`${n}/audioProcessor-wasm.js`),p&&!this.localAudioWorkletNode){let{sign:D,status:x,timestamp:Z}=yield this.getAuthData(r,o,s);this.localAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.localAudioWorkletNode,"localAudio",r,o,Z,D,x,e)}if(g&&!this.screenAudioWorkletNode){let{sign:D,status:x,timestamp:Z}=yield this.getAuthData(r,o,s);this.screenAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.screenAudioWorkletNode,"screenAudio",r,o,Z,D,x,e)}this.mixNode||(this.mixNode=this.audioContext.createGain(),this.mixNode.gain.value=1),this.silentNode||(this.silentNode=this.audioContext.createConstantSource(),this.silentNode.offset.setValueAtTime(0,this.audioContext.currentTime),this.silentNode.start()),(E=this.localAudioWorkletNode)==null||E.port.postMessage({type:"enable"}),(A=this.screenAudioWorkletNode)==null||A.port.postMessage({type:"enable"}),e.audioManager.addAudioProcessor(this.mixNode,this.silentNode,this.localAudioWorkletNode,this.screenAudioWorkletNode),M(a)||a.forEach(D=>{this.customAudioReferenceMap.set(D,`o-${this.audioRefId++}`),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:D,refId:`o-${this.audioRefId++}`})}),M(u)||(C=this.localAudioWorkletNode)==null||C.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:u}}),M(m)||(N=this.localAudioWorkletNode)==null||N.port.postMessage({type:"dump",data:{enable:m}})})}update(t){return y(this,null,function*(){var s,n,a;let{audioReference:e,enableDump:r,processLevel:o}=t;M(e)||(this.customAudioReferenceMap.forEach((u,m)=>{this.customAudioReferenceMap.delete(m),this.core.room.audioManager.updateAudioReference({type:"remove",refId:u})}),e.forEach(u=>{this.customAudioReferenceMap.set(u,`o-${this.audioRefId++}`),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:u,refId:`o-${this.audioRefId++}`})})),M(o)||(s=this.localAudioWorkletNode)==null||s.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:o}}),M(r)||((n=this.localAudioWorkletNode)==null||n.port.postMessage({type:"dump",data:{enable:r}}),(a=this.screenAudioWorkletNode)==null||a.port.postMessage({type:"dump",data:{enable:r}}))})}stop(){return y(this,null,function*(){var e,r;let{room:t}=this.core;(e=this.localAudioWorkletNode)==null||e.port.postMessage({type:"disable"}),(r=this.screenAudioWorkletNode)==null||r.port.postMessage({type:"disable"}),yield t.audioManager.removeAudioProcessor(this.localAudioWorkletNode,this.screenAudioWorkletNode)})}destroy(){this.localAudioWorkletNode&&(this.localAudioWorkletNode.port.onmessage=null),this.screenAudioWorkletNode&&(this.screenAudioWorkletNode.port.onmessage=null),this.uninstallEvent()}getAuthData(t,e,r){return y(this,null,function*(){let o=String(Date.now()).slice(0,-3),{auth:s,sign:n,status:a,message:u}=yield Xy({sdkAppId:t,userSig:r,userId:e,timestamp:o});if(!s)throw this.log.info(`audioProcessor: ${e} auth result: ${s}. Message: ${u}`),new oe({code:se.INVALID_PARAMETER,message:u});return{sign:n,status:a,timestamp:o}})}initWorkletNode(t,e,r,o,s,n,a,u){t.port.postMessage({type:"init",data:{sdkAppId:String(r),userId:o,timestamp:s,sign:n,status:a}}),t.port.onmessage=m=>{var g;let{data:p}=m;switch(p.type){case"cost":let E=(p==null?void 0:p.value)>10?"info":"debug";this.log[E](`${e==="localAudio"?"":`[${e}] `}avg cost: ${p.value} max: ${p==null?void 0:p.max}(${ks(new Date(p==null?void 0:p.maxCostTimestamp))}) hist: ${(g=p==null?void 0:p.hist)==null?void 0:g.join(" ")}`);return;case"log":this.log[p.logLevel](`${e==="localAudio"?"":`[${e}] `}${p.value}`);return;case"dump":U.emit("265",{room:u,data:p.value,type:e==="localAudio"?"dump":"dump-screen-audio"});return}}}handleLocalAudioStarted(t){return y(this,null,function*(){var e;if(!(!this.hitTest(t.room)||((e=this.core.room.scheduleResult.config)==null?void 0:e.audioProcessor)!==!0))try{yield this.core.trtc.startPlugin("AudioProcessor",{sdkAppId:this.core.room.sdkAppId,userId:this.core.room.userId,userSig:this.core.room.userSig}),this.log.warn("audio processor auto start success")}catch(r){this.log.warn(`audio processor auto start failed, error: ${r}`)}})}handleLocalAudioStopped(t){return y(this,null,function*(){var e;!this.hitTest(t.room)||((e=this.core.room.scheduleResult.config)==null?void 0:e.audioProcessor)!==!0||(yield this.core.trtc.stopPlugin("AudioProcessor"))})}installEvent(){this.core.innerEmitter.on("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.on("114",this.handleLocalAudioStopped,this)}uninstallEvent(){this.core.innerEmitter.off("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.off("114",this.handleLocalAudioStopped,this)}hitTest(t){return t===this.core.room}};l(Fi,"updateValidateRule",{type:"object"}),l(Fi,"stopValidateRule",{type:"object"}),l(Fi,"Name","AudioProcessor");var Hu=Fi;function Jy(i,t=O.MAIN){return`https://${si[t]||Uu(i,t)}/api/v1/audioAiAuth`}function Xy(o){return y(this,arguments,function*({sdkAppId:i,userId:t,userSig:e,timestamp:r}){let n=`${Jy(i)}?sdkAppId=${i}&userId=${t}&userSig=${e}×tamp=${r}`,a=yield fetch(n),{data:{errCode:u,errMsg:m,sign:p,status:g}}=yield a.json();if(g==="1")return{auth:!0,sign:p,status:g,message:m};let E=_i(i)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",A="Init RTCAudioProcessor failed.",C="";switch(u){case 1:C="Please check your params.";break;case 2:C=`You need to buy packages. Refer to: ${E}`;break;case 3:C="Server is invalid. Please contact our engineer. ";break;case 4:C=`Your packages is not active. Refer to: ${E}`;break;case 5:C=`Your packages is expired. Refer to: ${E}`;break;case 6:C="Your version is not supported.";break}return{auth:!1,status:g,message:m?`${A} Reason: ${m}. ${C}`:`${A}, ${C}`}})}var Wu=0,Tp=class{constructor(t,e){l(this,"audioObjectURL");l(this,"player");l(this,"publisher");l(this,"mixInput");this.mixInput=new pn(e),t.url?(this.player=new Audio(t.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(t.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(t.track),this.mixInput.connect()}updateSettings(t){this.player&&(M(t.volume)||(this.volume=t.volume),M(t.loop)||(this.loop=t.loop),M(t.playbackRate)||(this.playbackRate=t.playbackRate))}updateListener(t){if(this.player){if(t.onDurationChange){let{onDurationChange:e}=t;this.player.ondurationchange=r=>{e(r.target.duration)}}if(t.onTimeUpdate){let e=t.onTimeUpdate,{player:r}=this;r.ontimeupdate=()=>{e(r.currentTime,r.duration)}}t.onEnded&&(this.player.onended=t.onEnded)}}reload(t){return y(this,null,function*(){if(t.url){let e=yield uc.download(t.url,{retries:3,type:"blob"});this.audioObjectURL&&URL.revokeObjectURL(this.audioObjectURL),this.audioObjectURL=URL.createObjectURL(e),this.player&&this.publisher?(this.player.src=this.audioObjectURL,this.publisher.src=this.audioObjectURL):(this.player=new Audio(this.audioObjectURL),this.player.crossOrigin="anonymous",this.publisher=new Audio(this.audioObjectURL),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher),this.updateListener(t),this.updateSettings(t))}else this.mixInput.replaceSource(t.track)})}reset(){this.seek(0),this.mixInput.connect()}seek(t){this.player&&(t<0&&t>this.player.duration||(this.player.currentTime=t,this.publisher.currentTime=t))}play(){var t,e;return Promise.all([(t=this.player)==null?void 0:t.play(),(e=this.publisher)==null?void 0:e.play()])}pause(){var t,e;(t=this.player)==null||t.pause(),(e=this.publisher)==null||e.pause()}stop(){var t;(t=this.player)==null||t.pause(),this.mixInput.disconnect()}setOperation(t){t==="pause"&&this.pause(),t==="resume"&&(this.pause(),this.play()),t==="stop"&&(this.pause(),this.seek(0))}set volume(t){!this.player||!this.publisher||(this.player.volume=t,this.publisher.volume=t)}set loop(t){!this.player||!this.publisher||(this.player.loop=t,this.publisher.loop=t)}set playbackRate(t){!this.player||!this.publisher||(this.player.playbackRate=t,this.publisher.playbackRate=t)}};function Mn(i,t){if(t&&typeof t!="function")throw new oe({code:se.INVALID_PARAMETER,message:`start audioMixer plugin: param ${i} should be a function.`})}var ni=class ni{constructor(t){this.core=t;l(this,"log");l(this,"mixedMusicMap",new Map);l(this,"cacheMusicMap",new Map);Wu=Wu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Wu}`}),this.log.info(`created id=${this.getAlias()}${Wu}`)}getName(){return ni.Name}getAlias(){return"ax"}getGroup(t){return t==null?void 0:t.id}getValidateRule(t){switch(t){case"start":return ni.startValidateRule;case"update":return ni.updateValidateRule;case"stop":return ni.stopValidateRule}}start(t){return y(this,null,function*(){let{room:e}=this.core;this.log.info(`add music source, id: ${t.id} url: ${t.url}, track: ${t.track}`);let{id:r,url:o}=t;if(this.mixedMusicMap.has(r))return;let s=this.cacheMusicMap.get(r);s?t.url?s.reset():(s.mixInput.replaceSource(t.track),s.mixInput.connect()):(s=new Tp(t,e.audioManager),this.cacheMusicMap.set(r,s)),s.updateListener(t),s.updateSettings(t);try{yield s.play()}catch(n){yield this.handleAutoPlayFailed(s,t,n)}this.mixedMusicMap.set(r,s),s.mixInput.source.node&&this.core.room.audioManager.updateAudioReference({type:"add",audioReference:s.mixInput.source.node,refId:`ax-${r}`}),this.log.info(`start mix audio track ${r} success.`),Q.addEnum({key:502700,value:3}),this.kvUpload(t)})}handleAutoPlayFailed(t,e,r){return y(this,null,function*(){if(r.name==="NotSupportedError")this.log.error(`play failed, try to reload source. error: ${r}`),yield t.reload(e),yield t.play();else if(r.name==="NotAllowedError")if(this.core.room.enableAutoPlayDialog){let o=()=>{var s;(s=t.play())==null||s.finally(()=>{U.off("154",o,this)})};U.on("154",o,this),new mn}else this.core.trtc.emit(K.AUTOPLAY_FAILED,{userId:"",mediaType:"audio",resume:()=>y(this,null,function*(){return t.play()})});else throw r})}update(t){return y(this,null,function*(){let{id:e,operation:r,seekFrom:o,playbackRate:s}=t;this.log.info(`update music source, ${JSON.stringify(t)}`);let n=this.mixedMusicMap.get(e);if(!n){this.log.warn(`update music source failed, music id: ${e} not found.`);return}n.updateSettings(t),n.updateListener(t),M(r)||n.setOperation(r),M(o)||n.seek(o),this.kvUpload(t)})}stop(e){return y(this,arguments,function*({id:t}){if(this.mixedMusicMap.has(t)){this.log.info(`remove music source, music id: ${t}`);let r=this.mixedMusicMap.get(t);r!=null&&r.mixInput.source.node&&this.core.room.audioManager.updateAudioReference({type:"remove",audioReference:r.mixInput.source.node,refId:`ax-${t}`}),r==null||r.stop(),this.mixedMusicMap.delete(t)}t==="*"&&this.destroyAllMusic()})}kvUpload(t){let{track:e,loop:r,volume:o,playbackRate:s,operation:n,seekFrom:a,onTimeUpdate:u,onDurationChange:m,onEnded:p}=t;e&&Q.addCount({key:502009}),r&&Q.addCount({key:502001}),o&&Q.addCount({key:502002}),s&&Q.addCount({key:502003}),n&&Q.addCount({key:502004}),a&&Q.addCount({key:502005}),typeof u!="function"&&Q.addCount({key:502007}),typeof p!="function"&&Q.addCount({key:502008}),typeof m!="function"&&Q.addCount({key:502006})}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach((t,e)=>{t!=null&&t.mixInput.track&&this.core.room.audioManager.updateAudioReference({type:"remove",audioReference:t.mixInput.track,refId:e}),this.stop({id:e})})}destroyAllCache(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}destroy(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}};l(ni,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate(t,e,r){if(t.url&&t.url!=="*"){let o=t.url.split("?")[0],s=["mp3","ogg","wav","flac"],n=o.split(".").pop(),a=s.indexOf(n)>=0,u=o.startsWith("blob"),m=o.startsWith("data");if(!(a||u||m))throw new oe({code:se.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:r})}if(!t.url&&!t.track)throw new oe({code:se.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:r});Mn("onTimeUpdate",t.onTimeUpdate),Mn("onEnded",t.onEnded),Mn("onDurationChange",t.onDurationChange)}}),l(ni,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate(t,e,r){Mn("onTimeUpdate",t.onTimeUpdate),Mn("onEnded",t.onEnded),Mn("onDurationChange",t.onDurationChange)}}),l(ni,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),l(ni,"Name","AudioMixer");var Gu=ni;var ju=0,Ip,$i=class $i{constructor(t){this.core=t;l(this,"log");l(this,"audioContext",We("denoiser"));l(this,"workletNode");l(this,"config",{enableFarFieldReduce:!1,farFieldReduceThreshold:.5});ju=ju+1,this.log=t.log.createChild({id:`${this.getAlias()}${ju}`}),this.log.info(`created id=${this.getAlias()}${ju}`)}static startValidateRule(t){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0},mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}},validate(e,r,o,s){if(!t.room.audioManager.hasAudioTrack)throw new oe({code:se.INVALID_OPERATION,extraCode:5106,fnName:o})}}}preload(t){return Ip||(Ip=this.doPreload(t)),Ip}doPreload(t){return y(this,null,function*(){let e=yield this.core.fileDownloader.download(t,{type:"blob"}),r=URL.createObjectURL(e);try{yield xi(this.audioContext,r)}catch(o){throw this.log.error("load worklet failed",o),o}finally{URL.revokeObjectURL(r)}})}getName(){return $i.Name}getAlias(){return"ad"}getGroup(){return"AIDenoiser"}getValidateRule(t){switch(t){case"start":return $i.startValidateRule(this.core);case"update":return $i.updateValidateRule;case"stop":return $i.stopValidateRule}}start(t){return y(this,null,function*(){let{room:e,schedule:r}=this.core,{assetsPath:o=this.core.assetsPath}=t;if(!o)throw new oe({code:se.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(yield this.preload(`${o}/denoiser-wasm${jm()?"":"-nosimd"}.js`),!this.workletNode){let s=String(Date.now()).slice(0,-3),{auth:n,sign:a,status:u,message:m}=yield Yy(r,ge(X({},t),{timestamp:s}));if(!n)throw this.log.info(`RTCAIDenoiser: ${t.userId} auth result: ${n}. Message: ${m}`),new oe({code:se.INVALID_PARAMETER,message:m});this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(t.sdkAppId),userId:t.userId,timestamp:s,sign:a,status:u}}),this.workletNode.port.onmessage=p=>{var E;let{data:g}=p;if(g.type==="cost"){let A=(g==null?void 0:g.max)>20?"warn":(g==null?void 0:g.max)>10?"info":"debug";this.log[A](`avg cost: ${g.value} max: ${g==null?void 0:g.max}(${ks(new Date(g==null?void 0:g.maxCostTimestamp))}) hist: ${(E=g==null?void 0:g.hist)==null?void 0:E.join(" ")}`)}else g.type==="log"&&this.log[g.logLevel](`${g.value}`)}}this.updateConfig(t),this.workletNode.port.postMessage({type:"enable"}),e.audioManager.addDenoiser(this.workletNode),e.sendAbilityStatus({ai_denoise:1})})}update(t){return y(this,null,function*(){this.updateConfig(t)})}stop(){return y(this,null,function*(){if(!this.workletNode)return;let{room:t}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield t.audioManager.removeDenoiser(this.workletNode)})}updateConfig(t){if(!this.workletNode)return;let e=!1;M(t.mode)||(t.mode===0?this.config.enableFarFieldReduce=!1:t.mode===1&&(this.config.enableFarFieldReduce=!0),e=!0),M(t.farFieldReduceThreshold)||(this.config.farFieldReduceThreshold=t.farFieldReduceThreshold,e=!0),e&&this.workletNode.port.postMessage({type:"setConfig",data:this.config})}destroy(){this.workletNode&&(this.workletNode.port.onmessage=null)}};l($i,"updateValidateRule",{type:"object",properties:{mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}}}),l($i,"stopValidateRule",{type:"object"}),l($i,"Name","AIDenoiser");var qu=$i;function Yy(s,n){return y(this,arguments,function*(i,{sdkAppId:t,userId:e,userSig:r,timestamp:o}){try{let{data:{errCode:a,errMsg:u,sign:m,status:p}}=yield i.getAbilityConfig(t,i.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:t,userId:e,userSig:r,timestamp:o});if(p==="1")return{auth:!0,sign:m,status:p,message:u};let g=_i(t)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",E="Init RTCAIDenoiser failed.",A="";switch(a){case 1:A="Please check your params.";break;case 2:A=`You need to buy packages. Refer to: ${g}`;break;case 3:A="Server is invalid. Please contact our engineer. ";break;case 4:A=`Your packages is not active. Refer to: ${g}`;break;case 5:A=`Your packages is expired. Refer to: ${g}`;break;case 6:A="Your version is not supported.";break}return{auth:!1,status:p,message:u?`${E} Reason: ${u}. ${A}`:`${E}, ${A}`}}catch(a){return{auth:!1,status:"0",message:`Init RTCAIDenoiser failed. All requests failed. ${a}`}}})}var WE=pi(bi(),1);var Sp=class extends WE.EventEmitter{constructor(){super();l(this,"observer");l(this,"state","nominal");this.onPressureChange=this.onPressureChange.bind(this)}get stateNum(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}start(){return y(this,null,function*(){if(!this.observer)try{"PressureObserver"in window&&!pt&&(this.observer=new PressureObserver(this.onPressureChange),yield this.observer.observe("cpu",{sampleInterval:2e3}))}catch(e){He.uploadEvent({log:"stat-pressure-detector-start-failed",error:e})}})}onPressureChange(e){let r=this.stateNum,o=e[e.length-1];this.state=o.state,(this.stateNum>3||r>3)&&$.info(`${o.source}: ${o.state}`),this.emit("state-changed",{type:o.source,state:this.state})}destroy(){var e;try{(e=this.observer)==null||e.disconnect(),this.observer=null}catch(r){He.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:r})}}},Zy=new Sp,yp=Zy;function Ky([i,t]){let e=t.byteLength,r=parseInt(String(e/255),10),o=e%255,s=[];s.push(0,0,0,1,6,i);for(let a=0;a<r;a++)s.push(255);s.push(o);let n=new DataView(t);return s.push(...new Uint8Array(n.buffer)),s.push(128),new ps(new DataView(new Uint8Array(s).buffer),!0)}function eA(i){return i.type==="empty"||i.data.byteLength===0}function tA(i){return i.getInt32(0)===1&&i.getInt8(4)===6}function rA(i){let t=0,e=0,r=new DataView(i);for(let o=0;o<i.byteLength;o++)switch(r.getUint8(o)){case 0:t++;break;case 1:(t===2||t===3)&&e++,t=0;break;default:t=0;break}return e}function Ap({frame:i,seiMessageList:t}){if(!t||t.length===0||i.data.byteLength===0)return i;let r=9-rA(i.data);if(r<=0)return i;let o=t.splice(0,r).reverse().map(Ky),s=o.reduce((p,g)=>p+g.dataView.byteLength,0),n=new ArrayBuffer(s+i.data.byteLength),a=new DataView(n),u=new DataView(i.data),m=0;for(let p=0;p<o.length;p++)for(let g=0;g<o[p].dataView.byteLength;g++)a.setInt8(m++,o[p].dataView.getInt8(g));for(let p=0;p<i.data.byteLength;p++)a.setInt8(m++,u.getInt8(p));return i.data=n,i}function bp({frame:i,onSEI:t}){try{let e=new DataView(i.data);if(eA(i)||!tA(e))return i;let r=[],o=0,s=-1,n=-1;for(let a=0;a<i.data.byteLength;a++){let u=e.getUint8(a);if(u===0)o++;else if(u===1){if(o===2||o===3){let m=a-o;if(s===-1?s=m:n===-1&&(n=m,r.push(new ps(new DataView(e.buffer.slice(s,n)))),s=m,n=-1),!(e.getUint8(a+1)===6)){i.data=e.buffer.slice(m);break}}o=0}else o=0}t==null||t(r.reverse())}catch(e){}return i}var Rp=0,lc=class lc{constructor(t){this.core=t;l(this,"log");l(this,"_seiMessageList",[]);l(this,"_smallSeiMessageList",[]);l(this,"_subStreamSeiMessageList",[]);Rp++,this.log=t.log.createChild({id:`${this.getAlias()}${Rp}`}),this.log.info(`[sei] created id=${this.getAlias()}${Rp}`),this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}encode({frame:t,mediaType:e}){try{let r=e===8?this._smallSeiMessageList:e===2?this._subStreamSeiMessageList:this._seiMessageList;return Ap({frame:t,seiMessageList:r})}catch(r){this.log.warn(r)}return t}decode({frame:t,track:e}){return bp({frame:t,onSEI:r=>{r.forEach(o=>{this.core.trtc.emit(K.SEI_MESSAGE,{seiPayloadType:o.seiPayloadType,data:o.seiPayload.buffer,userId:e.userId,streamType:e.mediaType===2?"sub":"main"})})}})}destroy(){this.log.debug("destory"),this.stop(),delete this.core}getValidateRule(t){switch(t){case"start":return{type:"object"};case"update":return{type:"object"};case"stop":return{type:"object"}}}start(){this.core.room.videoManager.addEncodeProcessor({processor:ss?this.encode:Ap,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:ss?this.decode:bp,type:2})}stop(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}update({buffer:t,options:e}){var s;let r=[e.seiPayloadType,t],o=!!e.small;e.toSubStream?this._subStreamSeiMessageList.push(r):(this._seiMessageList.push(r),o&&this._smallSeiMessageList.push(r)),(s=this.core.room.scriptTransformWorker)==null||s.postMessage({type:"sei",data:r,isMain:!e.toSubStream,small:o})}getName(){return lc.Name}getAlias(){return"sei"}getGroup(){return"sei"}};l(lc,"autoStart",!0),l(lc,"Name","SEI");var zu=lc;function vp({frame:i,onDump:t}){return t==null||t(),i}function Cp({frame:i,onDump:t}){return t==null||t(),i}var GE={"play() error: NotAllowedError:":{tips:i=>i.includes("main <video>")||i.includes("main <audio>")?"Remote stream auto play is restricted and playback fails":"Local stream playback failure, generally only occurs in Android WeChat devices, no need to handle",color:"red",class:"red"},"updateStream() try to recover local stream":{tips:"Device acquisition exception, automatic recovery is in progress"},"updateStream() recover local stream successfully":{tips:"Device acquisition exception, automatic recovery is successful"},"updateStream() failed to recover local stream":{tips:"Device acquisition exception, automatic recovery failed"},"main stream - video track is muted":{tips:"Indicates that the received video data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - audio track is muted":{tips:"Indicates that the received audio data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"auxiliary stream - video track is muted":{tips:"Indicates that the received screen sharing data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - video track is unable to provide media output":{tips:"Indicates that the received video data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - audio track is unable to provide media output":{tips:"Indicates that the received audio data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"auxiliary stream - video track is unable to provide media output":{tips:"Indicates that the received screen sharing data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - video track is unmuted":{tips:"Received enough playback video data"},"main stream - audio track is unmuted":{tips:"Received enough playback audio data"},"auxiliary stream - video track is unmuted":{tips:"Received enough playback screen sharing data"},"main stream - audio player track is ended":{tips:"Remote audio track stopped"},"main stream - video player track is ended":{tips:"Remote video track stopped"},"auxiliary stream - video player track is ended":{tips:"Received enough playback screen sharing data"},"stream - video track is muted":{tips:"Camera capture is paused, usually due to the device being occupied by other applications or the browser media permission being revoked. The client needs to re-capture.",color:"orange"},"stream - video track is unable to provide media output":{tips:"The camera acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked, and the customer needs to re-acquire. SDK v4.11.4+ will automatically resume acquisition without customer intervention",color:"orange"},"video track is unable to provide media output":{tips:i=>i.includes("\u2193")?"The remote track is temporarily unable to decode data, which may be caused by network fluctuations":"The camera acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - video player track is ended":{tips:"The camera acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"video player track is ended":{tips:"The camera acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"stream - audio track is muted":{tips:"Microphone capture is paused, usually due to the device being occupied by other applications or the browser media permission being revoked. The client needs to re-capture.",color:"orange"},"audio track is unable to provide media output":{tips:i=>i.includes("\u2193")?"The remote track is temporarily unable to decode data, which may be caused by network fluctuations":"Microphone acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - audio track is unable to provide media output":{tips:"The microphone acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - audio player track is ended":{tips:"The microphone acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"audio player track is ended":{tips:"The microphone acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"is adding audio track to current published local stream":{tips:"add audio track",color:"orange"},"is removing audio track from current published local stream":{tips:"remove audio track",color:"orange"},"is removing video track from current published local stream":{tips:"remove video track",color:"orange"},"is adding video track to current published local stream":{tips:"add video track",color:"orange"},"is replacing audio track to current published local main stream":{tips:"replace audio track",color:"orange"},"is replacing video track to current published local main stream":{tips:"replace video track",color:"orange"},"downlink network quality change":{tips:"Downstream network quality change: 1: excellent, 2: good, 3: average, 4: poor, 5: extremely poor"},"uplink network quality change":{tips:"Upstream network quality change: 1: excellent, 2: good, 3: average, 4: poor, 5: extremely poor"},"localStream mute video":{tips:"mute upstream video stream",color:"orange"},"localStream unmute video":{tips:"unmute upstream video stream",color:"orange"},"localStream mute audio":{tips:"mute upstream audio stream",color:"orange"},"localStream unmute audio":{tips:"unmute upstream audio stream",color:"orange"},"black detected":{tips:"Detect black screen, which means fps = 0. It is usually caused by network, and the network will be recovered after a while. If the network is normal but has not been restored, it is an abnormal situation."},'main stream start to play with options: {"muted":true}':{tips:"Play the remote stream in silent mode. Generally, the remote stream does not need to be played in silent mode. You need to confirm whether the parameters passed in the client stream.play API call are correct.",color:"orange"},"main stream - audio player is starting playing":{tips:"Remote stream audio playback success",color:"#0dd90d",class:"success"},"main stream - video player is starting playing":{tips:"Remote stream video playback success",color:"#0dd90d",class:"success"},"video player is playing":{tips:"Local video playback success",color:"#0dd90d",class:"success"},"audio player is playing":{tips:"Local audio playback success",color:"#0dd90d",class:"success"},"stream - video player is starting playing":{tips:"Local video playback success",color:"#0dd90d",class:"success"},"stream - audio player is starting playing":{tips:"Local audio playback success",color:"#0dd90d",class:"success"},"switch camera success":{tips:"Switch camera success",color:"#0dd90d",class:"success"},"switch microphone success":{tips:"Switch microphone success",color:"#0dd90d",class:"success"},gotStream:{tips:"Local stream capture success"},"local stream is published successfully":{tips:"Publish success",color:"#0dd90d",class:"success"},"encoderImplementation change to OpenH264":{tips:"Use software encoding"},"encoderImplementation change to ExternalEncoder":{tips:"Use hardware encoding"},"getUserMedia with constraints":{tips:"Start media (camera/microphone) capture"},"getDisplayMedia with constraints":{tips:"Start screen sharing capture"},"client-banned":{tips:"Kicked out of the room",color:"red",class:"red",textColor:"#fff"},user_timeout:{tips:"The backend is too long without receiving SDK heartbeat, which is usually caused by the JS thread being blocked for a long time. If the reproduction probability is high, the application browser Performance tool analyzes where the JS thread is blocked.",color:"red",class:"red",textColor:"#fff"},"schedule failed":{tips:"Signaling request failed, does not affect the normal room entry process, SDK will connect to the default signaling domain."},"updateStream() video flag is true, but no camera detected, set video to false":{tips:"When trying to resume camera acquisition, the camera acquisition is not resumed because it is detected that there is no camera.",color:"orange",class:"orange",textColor:"#fff"},"qualityLimitationReason change to bandwidth":{tips:"bandwidth estimation is not enough to limit the quality of the encoding, which may cause the code rate, frame rate, and resolution to be lowered.",color:"orange",class:"orange",textColor:"#fff"},"qualityLimitationReason change to cpu":{tips:"cpu load is too high to limit the quality of the encoding, which may cause the code rate, frame rate, and resolution to be lowered.",color:"orange",class:"orange",textColor:"#fff"},"visibility change: hidden":{tips:"User page switched to backend, in mobile devices, this will cause the device to pause the capture, and it will be restored when the user switches backend to the frontend.",color:"orange",class:"orange",textColor:"#fff"},"visibility change: visible":{tips:"User page switched to frontend",color:"orange",class:"orange",textColor:"#fff"},"main stream - audio player is paused":{tips:`The remote stream audio playback is paused, which usually has two possibilities:
|
|
98
|
+
${o.stack}`),!1}},i};var wn=new WeakMap;function VE(i){let t=wn.get(i);t&&(t.forEach(e=>clearTimeout(e)),wn.delete(i))}function FE(i,t){return Me((e,r)=>function(...o){let s=wn.get(this);s||(s=new Map,wn.set(this,s));let n=t(...o),a=s.get(n);if(!a||a<=0){e.apply(this,o);let u=setTimeout(()=>{var m;(m=wn.get(this))==null||m.delete(n)},i);s.set(n,u)}else{clearTimeout(a);let u=window.setTimeout(()=>{var m;e.apply(this,o),(m=wn.get(this))==null||m.delete(n)},i);s.set(n,u)}})}var BE="trtc-sdk-v5",gp="5.13.1-wasm.4";function Pt(...i){return Me((t,e)=>function(...r){try{Fu.call(this,i,r,e,this._name)}catch(o){return Promise.reject(o)}return t.apply(this,r)})}function Ep(...i){return Me((t,e)=>function(...r){try{Fu.call(this,i,r,e,this._name)}catch(o){throw o}return t.apply(this,r)})}function Fu(i,t,e,r){if(st(i))for(let o=0;o<i.length;o++)Vu.call(this,{rule:i[o],value:t[o],key:i[o].name,fnName:e,className:r});else Vu.call(this,{rule:i,value:t[0],key:i.name,fnName:e,className:r})}function Vu({rule:i,value:t,key:e,fnName:r,className:o}){function s(u){return{code:se.INVALID_PARAMETER,extraCode:u,fnName:r,messageParams:{key:e,rule:i,value:t}}}if(M(t)){if(i.required)throw new oe(s(5001));if(M(i.defaultValue)){Ge(i.validate)&&i.validate.call(this,t,e,r,o,this);return}t=i.defaultValue}if(Array.isArray(i.type)){let u=!1;for(let m=0;m<i.type.length;m++)i.type[m]===null&&t===null&&(u=!0),Ge(i.type[m])&&t instanceof i.type[m]&&(u=!0),Ne(i.type[m])&&ct(t)===i.type[m].toLowerCase()&&(u=!0);if(!u)throw new oe({code:se.INVALID_PARAMETER,extraCode:5002,fnName:r,messageParams:{key:e,rule:{type:i.type.map(m=>qo(m)?Ws(m):Ne(m)?m:ct(m))},value:t}})}else if(!M(i.type)&&ct(t)!==i.type)throw new oe(s(5002));if(i.allowEmpty===!1){let u=ke(t)&&(t===0||Number.isNaN(t)),m=Ne(t)&&t.trim()==="";if(u||m)throw new oe(s(5003))}if(i.notLessThanZero&&ke(t)&&t<0)throw new oe(s(5006));if(!M(i.min)&&ke(t)&&t<i.min)throw new oe(s(5007));if(!M(i.max)&&ke(t)&&t>i.max)throw new oe(s(5008));if(Ne(i.instanceOf)){if(!t||t._name!==i.instanceOf)throw new oe(s(5004))}else if(Ge(i.instanceOf)&&!(t instanceof i.instanceOf))throw new oe(s(5004));if(Array.isArray(i.values)&&!i.values.includes(t))throw new oe(s(5005));let{properties:n}=i;Bt(n)&&or(t)&&Object.keys(n).forEach(u=>{Vu.call(this,{rule:n[u],value:t&&t[u],key:`${u}`,fnName:r,className:o})});let{arrayItem:a}=i;Bt(a)&&st(t)&&t.forEach((u,m)=>{Vu.call(this,{rule:a,value:u,key:`${e}[${m}]`,fnName:r,className:o})}),Ge(i.validate)&&i.validate.call(this,t,e,r,o,this)}function tt(i={}){let{getRemoteId:t=()=>"",replaceArg:e,getKVReportKey:r,ignoreLog:o,ignoreErrorLog:s}=i;return Me((n,a)=>function(...u){var A,C,N;function m(D,x,Z){if(Z&&Z.includes(D))return"hided";if(e){let ue=e(...u);if(u[ue.argIndex]===x)return ue.value}if(x===u||D in u)return x;try{return x instanceof HTMLElement?`id: ${x.id} type:${ct(x)}`:x instanceof MediaStreamTrack?sd(x):(JSON.stringify(x),x)}catch(ue){return`type:${ct(x)}`}}let p=this._log||$;if(o!=null&&o(...u))return n.apply(this,u);u.length>0?p.info(`${a}() ${JSON.stringify(u,(D,x)=>m(D,x,["userSig","privateMapKey"]))}`):p.info(`${a}()`);let g=r?r(...u):Ud[a],E=(s==null?void 0:s(...u))||!1;try{let D=n.apply(this,u),x=_e();if(io(D)){let Z=`${a.includes("Plugin")?`${((C=(A=u[0]).getName)==null?void 0:C.call(A))||""} `:" "}`;return D.then(ue=>(p.info(`${a}() success ${Z}${t.call(this,...u)}`),Q.addSuccessEvent({key:g,cost:_e()-x}),ue)).catch(ue=>{var H;ue=oe.convertFrom.call(this,ue,a,u.length===1?u[0]:u);let Se=ue.extraCode||ue.code,Ye=(H=ue.message)!=null&&H.includes(Se)?"":` code:${Se}`;throw E||p.error(`${a}() failed ${Z}${t.call(this,...u)} ${ue}${Ye} params: ${JSON.stringify(u,m)}`),Q.addFailedEvent({key:g,error:ue}),ue})}return Q.addSuccessEvent({key:g}),D}catch(D){D=oe.convertFrom.call(this,D,a);let x=D.extraCode||D.code,Z=(N=D.message)!=null&&N.includes(x)?"":` code:${x}`;throw E||p.error(`${a}() failed ${D}${Z} params: ${JSON.stringify(u,m)}`),Q.addFailedEvent({key:g,error:D}),D}})}var $u=i=>Me((t,e)=>function(r,o){return y(this,null,function*(){let s=this._plugins.get(r);if(!s)throw this._log.error(`plugin ${String(r)} is not found`),new oe({code:se.OPERATION_ABORT,message:`plugin ${String(r)} is not found`,fnName:e});if(Ge(s.constructor.isSupported)&&!s.constructor.isSupported())throw this._log.error(`plugin ${String(r)} is not supported`),new oe({code:se.ENV_NOT_SUPPORTED,message:`plugin ${String(r)} is not supported`,extraCode:5210,fnName:e});return Fu.call(this,s.getValidateRule(i),[o],e,"TRTC"),t.call(this,s,o)})});var Bu=0,_p,Fi=class Fi{constructor(t){this.core=t;l(this,"log");l(this,"customAudioReferenceMap",new Map);l(this,"audioRefId",0);l(this,"audioContext",We());l(this,"localAudioWorkletNode");l(this,"screenAudioWorkletNode");l(this,"mixNode");l(this,"silentNode");Bu=Bu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Bu}`}),this.log.info(`created id=${this.getAlias()}${Bu}`),this.installEvent()}static getStartValidateRule(t){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate(e,r,o,s){if(!t.room.audioManager.hasAudioTrack&&!t.room.audioManager.hasScreenAudioTrack)throw new oe({code:se.INVALID_OPERATION,extraCode:5106,fnName:o})}}}preload(t){return _p||(_p=this.doPreload(t)),_p}doPreload(t){return y(this,null,function*(){let e=yield this.core.fileDownloader.download(t,{type:"blob"}),r=URL.createObjectURL(e);try{yield xi(this.audioContext,r)}catch(o){this.log.error(`preload audioProcessor failed. ${o}`)}finally{URL.revokeObjectURL(r)}})}getName(){return Fi.Name}getAlias(){return"ap"}getGroup(){return"ap"}getValidateRule(t){switch(t){case"start":return Fi.getStartValidateRule(this.core);case"update":return Fi.updateValidateRule;case"stop":return Fi.stopValidateRule}}start(t){return y(this,null,function*(){var E,A,C,N;let{room:e}=this.core,{sdkAppId:r,userId:o,userSig:s,assetsPath:n=this.core.assetsPath,audioReference:a,processLevel:u,enableDump:m,isLocalAudioNeedAudioProcess:p=!0,isScreenAudioNeedAudioProcess:g=!1}=t;if(this.core.room.audioManager.isLocalAudioNeedAudioProcess=p,this.core.room.audioManager.isScreenAudioNeedAudioProcess=g,!n)throw new oe({code:se.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(yield this.preload(`${n}/audioProcessor-wasm.js`),p&&!this.localAudioWorkletNode){let{sign:D,status:x,timestamp:Z}=yield this.getAuthData(r,o,s);this.localAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.localAudioWorkletNode,"localAudio",r,o,Z,D,x,e)}if(g&&!this.screenAudioWorkletNode){let{sign:D,status:x,timestamp:Z}=yield this.getAuthData(r,o,s);this.screenAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.screenAudioWorkletNode,"screenAudio",r,o,Z,D,x,e)}this.mixNode||(this.mixNode=this.audioContext.createGain(),this.mixNode.gain.value=1),this.silentNode||(this.silentNode=this.audioContext.createConstantSource(),this.silentNode.offset.setValueAtTime(0,this.audioContext.currentTime),this.silentNode.start()),(E=this.localAudioWorkletNode)==null||E.port.postMessage({type:"enable"}),(A=this.screenAudioWorkletNode)==null||A.port.postMessage({type:"enable"}),e.audioManager.addAudioProcessor(this.mixNode,this.silentNode,this.localAudioWorkletNode,this.screenAudioWorkletNode),M(a)||a.forEach(D=>{this.customAudioReferenceMap.set(D,`o-${this.audioRefId++}`),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:D,refId:`o-${this.audioRefId++}`})}),M(u)||(C=this.localAudioWorkletNode)==null||C.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:u}}),M(m)||(N=this.localAudioWorkletNode)==null||N.port.postMessage({type:"dump",data:{enable:m}})})}update(t){return y(this,null,function*(){var s,n,a;let{audioReference:e,enableDump:r,processLevel:o}=t;M(e)||(this.customAudioReferenceMap.forEach((u,m)=>{this.customAudioReferenceMap.delete(m),this.core.room.audioManager.updateAudioReference({type:"remove",refId:u})}),e.forEach(u=>{this.customAudioReferenceMap.set(u,`o-${this.audioRefId++}`),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:u,refId:`o-${this.audioRefId++}`})})),M(o)||(s=this.localAudioWorkletNode)==null||s.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:o}}),M(r)||((n=this.localAudioWorkletNode)==null||n.port.postMessage({type:"dump",data:{enable:r}}),(a=this.screenAudioWorkletNode)==null||a.port.postMessage({type:"dump",data:{enable:r}}))})}stop(){return y(this,null,function*(){var e,r;let{room:t}=this.core;(e=this.localAudioWorkletNode)==null||e.port.postMessage({type:"disable"}),(r=this.screenAudioWorkletNode)==null||r.port.postMessage({type:"disable"}),yield t.audioManager.removeAudioProcessor(this.localAudioWorkletNode,this.screenAudioWorkletNode)})}destroy(){this.localAudioWorkletNode&&(this.localAudioWorkletNode.port.onmessage=null),this.screenAudioWorkletNode&&(this.screenAudioWorkletNode.port.onmessage=null),this.uninstallEvent()}getAuthData(t,e,r){return y(this,null,function*(){let o=String(Date.now()).slice(0,-3),{auth:s,sign:n,status:a,message:u}=yield Xy({sdkAppId:t,userSig:r,userId:e,timestamp:o});if(!s)throw this.log.info(`audioProcessor: ${e} auth result: ${s}. Message: ${u}`),new oe({code:se.INVALID_PARAMETER,message:u});return{sign:n,status:a,timestamp:o}})}initWorkletNode(t,e,r,o,s,n,a,u){t.port.postMessage({type:"init",data:{sdkAppId:String(r),userId:o,timestamp:s,sign:n,status:a}}),t.port.onmessage=m=>{var g;let{data:p}=m;switch(p.type){case"cost":let E=(p==null?void 0:p.value)>10?"info":"debug";this.log[E](`${e==="localAudio"?"":`[${e}] `}avg cost: ${p.value} max: ${p==null?void 0:p.max}(${ks(new Date(p==null?void 0:p.maxCostTimestamp))}) hist: ${(g=p==null?void 0:p.hist)==null?void 0:g.join(" ")}`);return;case"log":this.log[p.logLevel](`${e==="localAudio"?"":`[${e}] `}${p.value}`);return;case"dump":U.emit("265",{room:u,data:p.value,type:e==="localAudio"?"dump":"dump-screen-audio"});return}}}handleLocalAudioStarted(t){return y(this,null,function*(){var e;if(!(!this.hitTest(t.room)||((e=this.core.room.scheduleResult.config)==null?void 0:e.audioProcessor)!==!0))try{yield this.core.trtc.startPlugin("AudioProcessor",{sdkAppId:this.core.room.sdkAppId,userId:this.core.room.userId,userSig:this.core.room.userSig}),this.log.warn("audio processor auto start success")}catch(r){this.log.warn(`audio processor auto start failed, error: ${r}`)}})}handleLocalAudioStopped(t){return y(this,null,function*(){var e;!this.hitTest(t.room)||((e=this.core.room.scheduleResult.config)==null?void 0:e.audioProcessor)!==!0||(yield this.core.trtc.stopPlugin("AudioProcessor"))})}installEvent(){this.core.innerEmitter.on("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.on("114",this.handleLocalAudioStopped,this)}uninstallEvent(){this.core.innerEmitter.off("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.off("114",this.handleLocalAudioStopped,this)}hitTest(t){return t===this.core.room}};l(Fi,"updateValidateRule",{type:"object"}),l(Fi,"stopValidateRule",{type:"object"}),l(Fi,"Name","AudioProcessor");var Hu=Fi;function Jy(i,t=O.MAIN){return`https://${si[t]||Uu(i,t)}/api/v1/audioAiAuth`}function Xy(o){return y(this,arguments,function*({sdkAppId:i,userId:t,userSig:e,timestamp:r}){let n=`${Jy(i)}?sdkAppId=${i}&userId=${t}&userSig=${e}×tamp=${r}`,a=yield fetch(n),{data:{errCode:u,errMsg:m,sign:p,status:g}}=yield a.json();if(g==="1")return{auth:!0,sign:p,status:g,message:m};let E=_i(i)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",A="Init RTCAudioProcessor failed.",C="";switch(u){case 1:C="Please check your params.";break;case 2:C=`You need to buy packages. Refer to: ${E}`;break;case 3:C="Server is invalid. Please contact our engineer. ";break;case 4:C=`Your packages is not active. Refer to: ${E}`;break;case 5:C=`Your packages is expired. Refer to: ${E}`;break;case 6:C="Your version is not supported.";break}return{auth:!1,status:g,message:m?`${A} Reason: ${m}. ${C}`:`${A}, ${C}`}})}var Wu=0,Tp=class{constructor(t,e){l(this,"audioObjectURL");l(this,"player");l(this,"publisher");l(this,"mixInput");this.mixInput=new pn(e),t.url?(this.player=new Audio(t.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(t.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(t.track),this.mixInput.connect()}updateSettings(t){this.player&&(M(t.volume)||(this.volume=t.volume),M(t.loop)||(this.loop=t.loop),M(t.playbackRate)||(this.playbackRate=t.playbackRate))}updateListener(t){if(this.player){if(t.onDurationChange){let{onDurationChange:e}=t;this.player.ondurationchange=r=>{e(r.target.duration)}}if(t.onTimeUpdate){let e=t.onTimeUpdate,{player:r}=this;r.ontimeupdate=()=>{e(r.currentTime,r.duration)}}t.onEnded&&(this.player.onended=t.onEnded)}}reload(t){return y(this,null,function*(){if(t.url){let e=yield uc.download(t.url,{retries:3,type:"blob"});this.audioObjectURL&&URL.revokeObjectURL(this.audioObjectURL),this.audioObjectURL=URL.createObjectURL(e),this.player&&this.publisher?(this.player.src=this.audioObjectURL,this.publisher.src=this.audioObjectURL):(this.player=new Audio(this.audioObjectURL),this.player.crossOrigin="anonymous",this.publisher=new Audio(this.audioObjectURL),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher),this.updateListener(t),this.updateSettings(t))}else this.mixInput.replaceSource(t.track)})}reset(){this.seek(0),this.mixInput.connect()}seek(t){this.player&&(t<0&&t>this.player.duration||(this.player.currentTime=t,this.publisher.currentTime=t))}play(){var t,e;return Promise.all([(t=this.player)==null?void 0:t.play(),(e=this.publisher)==null?void 0:e.play()])}pause(){var t,e;(t=this.player)==null||t.pause(),(e=this.publisher)==null||e.pause()}stop(){var t;(t=this.player)==null||t.pause(),this.mixInput.disconnect()}setOperation(t){t==="pause"&&this.pause(),t==="resume"&&(this.pause(),this.play()),t==="stop"&&(this.pause(),this.seek(0))}set volume(t){!this.player||!this.publisher||(this.player.volume=t,this.publisher.volume=t)}set loop(t){!this.player||!this.publisher||(this.player.loop=t,this.publisher.loop=t)}set playbackRate(t){!this.player||!this.publisher||(this.player.playbackRate=t,this.publisher.playbackRate=t)}};function Mn(i,t){if(t&&typeof t!="function")throw new oe({code:se.INVALID_PARAMETER,message:`start audioMixer plugin: param ${i} should be a function.`})}var ni=class ni{constructor(t){this.core=t;l(this,"log");l(this,"mixedMusicMap",new Map);l(this,"cacheMusicMap",new Map);Wu=Wu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Wu}`}),this.log.info(`created id=${this.getAlias()}${Wu}`)}getName(){return ni.Name}getAlias(){return"ax"}getGroup(t){return t==null?void 0:t.id}getValidateRule(t){switch(t){case"start":return ni.startValidateRule;case"update":return ni.updateValidateRule;case"stop":return ni.stopValidateRule}}start(t){return y(this,null,function*(){let{room:e}=this.core;this.log.info(`add music source, id: ${t.id} url: ${t.url}, track: ${t.track}`);let{id:r,url:o}=t;if(this.mixedMusicMap.has(r))return;let s=this.cacheMusicMap.get(r);s?t.url?s.reset():(s.mixInput.replaceSource(t.track),s.mixInput.connect()):(s=new Tp(t,e.audioManager),this.cacheMusicMap.set(r,s)),s.updateListener(t),s.updateSettings(t);try{yield s.play()}catch(n){yield this.handleAutoPlayFailed(s,t,n)}this.mixedMusicMap.set(r,s),s.mixInput.source.node&&this.core.room.audioManager.updateAudioReference({type:"add",audioReference:s.mixInput.source.node,refId:`ax-${r}`}),this.log.info(`start mix audio track ${r} success.`),Q.addEnum({key:502700,value:3}),this.kvUpload(t)})}handleAutoPlayFailed(t,e,r){return y(this,null,function*(){if(r.name==="NotSupportedError")this.log.error(`play failed, try to reload source. error: ${r}`),yield t.reload(e),yield t.play();else if(r.name==="NotAllowedError")if(this.core.room.enableAutoPlayDialog){let o=()=>{var s;(s=t.play())==null||s.finally(()=>{U.off("154",o,this)})};U.on("154",o,this),new mn}else this.core.trtc.emit(K.AUTOPLAY_FAILED,{userId:"",mediaType:"audio",resume:()=>y(this,null,function*(){return t.play()})});else throw r})}update(t){return y(this,null,function*(){let{id:e,operation:r,seekFrom:o,playbackRate:s}=t;this.log.info(`update music source, ${JSON.stringify(t)}`);let n=this.mixedMusicMap.get(e);if(!n){this.log.warn(`update music source failed, music id: ${e} not found.`);return}n.updateSettings(t),n.updateListener(t),M(r)||n.setOperation(r),M(o)||n.seek(o),this.kvUpload(t)})}stop(e){return y(this,arguments,function*({id:t}){if(this.mixedMusicMap.has(t)){this.log.info(`remove music source, music id: ${t}`);let r=this.mixedMusicMap.get(t);r!=null&&r.mixInput.source.node&&this.core.room.audioManager.updateAudioReference({type:"remove",audioReference:r.mixInput.source.node,refId:`ax-${t}`}),r==null||r.stop(),this.mixedMusicMap.delete(t)}t==="*"&&this.destroyAllMusic()})}kvUpload(t){let{track:e,loop:r,volume:o,playbackRate:s,operation:n,seekFrom:a,onTimeUpdate:u,onDurationChange:m,onEnded:p}=t;e&&Q.addCount({key:502009}),r&&Q.addCount({key:502001}),o&&Q.addCount({key:502002}),s&&Q.addCount({key:502003}),n&&Q.addCount({key:502004}),a&&Q.addCount({key:502005}),typeof u!="function"&&Q.addCount({key:502007}),typeof p!="function"&&Q.addCount({key:502008}),typeof m!="function"&&Q.addCount({key:502006})}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach((t,e)=>{t!=null&&t.mixInput.track&&this.core.room.audioManager.updateAudioReference({type:"remove",audioReference:t.mixInput.track,refId:e}),this.stop({id:e})})}destroyAllCache(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}destroy(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}};l(ni,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate(t,e,r){if(t.url&&t.url!=="*"){let o=t.url.split("?")[0],s=["mp3","ogg","wav","flac"],n=o.split(".").pop(),a=s.indexOf(n)>=0,u=o.startsWith("blob"),m=o.startsWith("data");if(!(a||u||m))throw new oe({code:se.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:r})}if(!t.url&&!t.track)throw new oe({code:se.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:r});Mn("onTimeUpdate",t.onTimeUpdate),Mn("onEnded",t.onEnded),Mn("onDurationChange",t.onDurationChange)}}),l(ni,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate(t,e,r){Mn("onTimeUpdate",t.onTimeUpdate),Mn("onEnded",t.onEnded),Mn("onDurationChange",t.onDurationChange)}}),l(ni,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),l(ni,"Name","AudioMixer");var Gu=ni;var ju=0,Ip,$i=class $i{constructor(t){this.core=t;l(this,"log");l(this,"audioContext",We("denoiser"));l(this,"workletNode");l(this,"config",{enableFarFieldReduce:!1,farFieldReduceThreshold:.5});ju=ju+1,this.log=t.log.createChild({id:`${this.getAlias()}${ju}`}),this.log.info(`created id=${this.getAlias()}${ju}`)}static startValidateRule(t){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0},mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}},validate(e,r,o,s){if(!t.room.audioManager.hasAudioTrack)throw new oe({code:se.INVALID_OPERATION,extraCode:5106,fnName:o})}}}preload(t){return Ip||(Ip=this.doPreload(t)),Ip}doPreload(t){return y(this,null,function*(){let e=yield this.core.fileDownloader.download(t,{type:"blob"}),r=URL.createObjectURL(e);try{yield xi(this.audioContext,r)}catch(o){throw this.log.error("load worklet failed",o),o}finally{URL.revokeObjectURL(r)}})}getName(){return $i.Name}getAlias(){return"ad"}getGroup(){return"AIDenoiser"}getValidateRule(t){switch(t){case"start":return $i.startValidateRule(this.core);case"update":return $i.updateValidateRule;case"stop":return $i.stopValidateRule}}start(t){return y(this,null,function*(){let{room:e,schedule:r}=this.core,{assetsPath:o=this.core.assetsPath}=t;if(!o)throw new oe({code:se.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(yield this.preload(`${o}/denoiser-wasm${jm()?"":"-nosimd"}.js`),!this.workletNode){let s=String(Date.now()).slice(0,-3),{auth:n,sign:a,status:u,message:m}=yield Yy(r,ge(X({},t),{timestamp:s}));if(!n)throw this.log.info(`RTCAIDenoiser: ${t.userId} auth result: ${n}. Message: ${m}`),new oe({code:se.INVALID_PARAMETER,message:m});this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(t.sdkAppId),userId:t.userId,timestamp:s,sign:a,status:u}}),this.workletNode.port.onmessage=p=>{var E;let{data:g}=p;if(g.type==="cost"){let A=(g==null?void 0:g.max)>20?"warn":(g==null?void 0:g.max)>10?"info":"debug";this.log[A](`avg cost: ${g.value} max: ${g==null?void 0:g.max}(${ks(new Date(g==null?void 0:g.maxCostTimestamp))}) hist: ${(E=g==null?void 0:g.hist)==null?void 0:E.join(" ")}`)}else g.type==="log"&&this.log[g.logLevel](`${g.value}`)}}this.updateConfig(t),this.workletNode.port.postMessage({type:"enable"}),e.audioManager.addDenoiser(this.workletNode),e.sendAbilityStatus({ai_denoise:1})})}update(t){return y(this,null,function*(){this.updateConfig(t)})}stop(){return y(this,null,function*(){if(!this.workletNode)return;let{room:t}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield t.audioManager.removeDenoiser(this.workletNode)})}updateConfig(t){if(!this.workletNode)return;let e=!1;M(t.mode)||(t.mode===0?this.config.enableFarFieldReduce=!1:t.mode===1&&(this.config.enableFarFieldReduce=!0),e=!0),M(t.farFieldReduceThreshold)||(this.config.farFieldReduceThreshold=t.farFieldReduceThreshold,e=!0),e&&this.workletNode.port.postMessage({type:"setConfig",data:this.config})}destroy(){this.workletNode&&(this.workletNode.port.onmessage=null)}};l($i,"updateValidateRule",{type:"object",properties:{mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}}}),l($i,"stopValidateRule",{type:"object"}),l($i,"Name","AIDenoiser");var qu=$i;function Yy(s,n){return y(this,arguments,function*(i,{sdkAppId:t,userId:e,userSig:r,timestamp:o}){try{let{data:{errCode:a,errMsg:u,sign:m,status:p}}=yield i.getAbilityConfig(t,i.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:t,userId:e,userSig:r,timestamp:o});if(p==="1")return{auth:!0,sign:m,status:p,message:u};let g=_i(t)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",E="Init RTCAIDenoiser failed.",A="";switch(a){case 1:A="Please check your params.";break;case 2:A=`You need to buy packages. Refer to: ${g}`;break;case 3:A="Server is invalid. Please contact our engineer. ";break;case 4:A=`Your packages is not active. Refer to: ${g}`;break;case 5:A=`Your packages is expired. Refer to: ${g}`;break;case 6:A="Your version is not supported.";break}return{auth:!1,status:p,message:u?`${E} Reason: ${u}. ${A}`:`${E}, ${A}`}}catch(a){return{auth:!1,status:"0",message:`Init RTCAIDenoiser failed. All requests failed. ${a}`}}})}var WE=pi(bi(),1);var Sp=class extends WE.EventEmitter{constructor(){super();l(this,"observer");l(this,"state","nominal");this.onPressureChange=this.onPressureChange.bind(this)}get stateNum(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}start(){return y(this,null,function*(){if(!this.observer)try{"PressureObserver"in window&&!pt&&(this.observer=new PressureObserver(this.onPressureChange),yield this.observer.observe("cpu",{sampleInterval:2e3}))}catch(e){He.uploadEvent({log:"stat-pressure-detector-start-failed",error:e})}})}onPressureChange(e){let r=this.stateNum,o=e[e.length-1];this.state=o.state,(this.stateNum>3||r>3)&&$.info(`${o.source}: ${o.state}`),this.emit("state-changed",{type:o.source,state:this.state})}destroy(){var e;try{(e=this.observer)==null||e.disconnect(),this.observer=null}catch(r){He.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:r})}}},Zy=new Sp,yp=Zy;function Ky([i,t]){let e=t.byteLength,r=parseInt(String(e/255),10),o=e%255,s=[];s.push(0,0,0,1,6,i);for(let a=0;a<r;a++)s.push(255);s.push(o);let n=new DataView(t);return s.push(...new Uint8Array(n.buffer)),s.push(128),new ps(new DataView(new Uint8Array(s).buffer),!0)}function eA(i){return i.type==="empty"||i.data.byteLength===0}function tA(i){return i.getInt32(0)===1&&i.getInt8(4)===6}function rA(i){let t=0,e=0,r=new DataView(i);for(let o=0;o<i.byteLength;o++)switch(r.getUint8(o)){case 0:t++;break;case 1:(t===2||t===3)&&e++,t=0;break;default:t=0;break}return e}function Ap({frame:i,seiMessageList:t}){if(!t||t.length===0||i.data.byteLength===0)return i;let r=9-rA(i.data);if(r<=0)return i;let o=t.splice(0,r).reverse().map(Ky),s=o.reduce((p,g)=>p+g.dataView.byteLength,0),n=new ArrayBuffer(s+i.data.byteLength),a=new DataView(n),u=new DataView(i.data),m=0;for(let p=0;p<o.length;p++)for(let g=0;g<o[p].dataView.byteLength;g++)a.setInt8(m++,o[p].dataView.getInt8(g));for(let p=0;p<i.data.byteLength;p++)a.setInt8(m++,u.getInt8(p));return i.data=n,i}function bp({frame:i,onSEI:t}){try{let e=new DataView(i.data);if(eA(i)||!tA(e))return i;let r=[],o=0,s=-1,n=-1;for(let a=0;a<i.data.byteLength;a++){let u=e.getUint8(a);if(u===0)o++;else if(u===1){if(o===2||o===3){let m=a-o;if(s===-1?s=m:n===-1&&(n=m,r.push(new ps(new DataView(e.buffer.slice(s,n)))),s=m,n=-1),!(e.getUint8(a+1)===6)){i.data=e.buffer.slice(m);break}}o=0}else o=0}t==null||t(r.reverse())}catch(e){}return i}var Rp=0,lc=class lc{constructor(t){this.core=t;l(this,"log");l(this,"_seiMessageList",[]);l(this,"_smallSeiMessageList",[]);l(this,"_subStreamSeiMessageList",[]);Rp++,this.log=t.log.createChild({id:`${this.getAlias()}${Rp}`}),this.log.info(`[sei] created id=${this.getAlias()}${Rp}`),this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}encode({frame:t,mediaType:e}){try{let r=e===8?this._smallSeiMessageList:e===2?this._subStreamSeiMessageList:this._seiMessageList;return Ap({frame:t,seiMessageList:r})}catch(r){this.log.warn(r)}return t}decode({frame:t,track:e}){return bp({frame:t,onSEI:r=>{r.forEach(o=>{this.core.trtc.emit(K.SEI_MESSAGE,{seiPayloadType:o.seiPayloadType,data:o.seiPayload.buffer,userId:e.userId,streamType:e.mediaType===2?"sub":"main"})})}})}destroy(){this.log.debug("destory"),this.stop(),delete this.core}getValidateRule(t){switch(t){case"start":return{type:"object"};case"update":return{type:"object"};case"stop":return{type:"object"}}}start(){this.core.room.videoManager.addEncodeProcessor({processor:ss?this.encode:Ap,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:ss?this.decode:bp,type:2})}stop(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}update({buffer:t,options:e}){var s;let r=[e.seiPayloadType,t],o=!!e.small;e.toSubStream?this._subStreamSeiMessageList.push(r):(this._seiMessageList.push(r),o&&this._smallSeiMessageList.push(r)),(s=this.core.room.scriptTransformWorker)==null||s.postMessage({type:"sei",data:r,isMain:!e.toSubStream,small:o})}getName(){return lc.Name}getAlias(){return"sei"}getGroup(){return"sei"}};l(lc,"autoStart",!0),l(lc,"Name","SEI");var zu=lc;function vp({frame:i,onDump:t}){return t==null||t(),i}function Cp({frame:i,onDump:t}){return t==null||t(),i}var GE={"play() error: NotAllowedError:":{tips:i=>i.includes("main <video>")||i.includes("main <audio>")?"Remote stream auto play is restricted and playback fails":"Local stream playback failure, generally only occurs in Android WeChat devices, no need to handle",color:"red",class:"red"},"updateStream() try to recover local stream":{tips:"Device acquisition exception, automatic recovery is in progress"},"updateStream() recover local stream successfully":{tips:"Device acquisition exception, automatic recovery is successful"},"updateStream() failed to recover local stream":{tips:"Device acquisition exception, automatic recovery failed"},"main stream - video track is muted":{tips:"Indicates that the received video data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - audio track is muted":{tips:"Indicates that the received audio data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"auxiliary stream - video track is muted":{tips:"Indicates that the received screen sharing data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - video track is unable to provide media output":{tips:"Indicates that the received video data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - audio track is unable to provide media output":{tips:"Indicates that the received audio data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"auxiliary stream - video track is unable to provide media output":{tips:"Indicates that the received screen sharing data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - video track is unmuted":{tips:"Received enough playback video data"},"main stream - audio track is unmuted":{tips:"Received enough playback audio data"},"auxiliary stream - video track is unmuted":{tips:"Received enough playback screen sharing data"},"main stream - audio player track is ended":{tips:"Remote audio track stopped"},"main stream - video player track is ended":{tips:"Remote video track stopped"},"auxiliary stream - video player track is ended":{tips:"Received enough playback screen sharing data"},"stream - video track is muted":{tips:"Camera capture is paused, usually due to the device being occupied by other applications or the browser media permission being revoked. The client needs to re-capture.",color:"orange"},"stream - video track is unable to provide media output":{tips:"The camera acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked, and the customer needs to re-acquire. SDK v4.11.4+ will automatically resume acquisition without customer intervention",color:"orange"},"video track is unable to provide media output":{tips:i=>i.includes("\u2193")?"The remote track is temporarily unable to decode data, which may be caused by network fluctuations":"The camera acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - video player track is ended":{tips:"The camera acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"video player track is ended":{tips:"The camera acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"stream - audio track is muted":{tips:"Microphone capture is paused, usually due to the device being occupied by other applications or the browser media permission being revoked. The client needs to re-capture.",color:"orange"},"audio track is unable to provide media output":{tips:i=>i.includes("\u2193")?"The remote track is temporarily unable to decode data, which may be caused by network fluctuations":"Microphone acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - audio track is unable to provide media output":{tips:"The microphone acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - audio player track is ended":{tips:"The microphone acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"audio player track is ended":{tips:"The microphone acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"is adding audio track to current published local stream":{tips:"add audio track",color:"orange"},"is removing audio track from current published local stream":{tips:"remove audio track",color:"orange"},"is removing video track from current published local stream":{tips:"remove video track",color:"orange"},"is adding video track to current published local stream":{tips:"add video track",color:"orange"},"is replacing audio track to current published local main stream":{tips:"replace audio track",color:"orange"},"is replacing video track to current published local main stream":{tips:"replace video track",color:"orange"},"downlink network quality change":{tips:"Downstream network quality change: 1: excellent, 2: good, 3: average, 4: poor, 5: extremely poor"},"uplink network quality change":{tips:"Upstream network quality change: 1: excellent, 2: good, 3: average, 4: poor, 5: extremely poor"},"localStream mute video":{tips:"mute upstream video stream",color:"orange"},"localStream unmute video":{tips:"unmute upstream video stream",color:"orange"},"localStream mute audio":{tips:"mute upstream audio stream",color:"orange"},"localStream unmute audio":{tips:"unmute upstream audio stream",color:"orange"},"black detected":{tips:"Detect black screen, which means fps = 0. It is usually caused by network, and the network will be recovered after a while. If the network is normal but has not been restored, it is an abnormal situation."},'main stream start to play with options: {"muted":true}':{tips:"Play the remote stream in silent mode. Generally, the remote stream does not need to be played in silent mode. You need to confirm whether the parameters passed in the client stream.play API call are correct.",color:"orange"},"main stream - audio player is starting playing":{tips:"Remote stream audio playback success",color:"#0dd90d",class:"success"},"main stream - video player is starting playing":{tips:"Remote stream video playback success",color:"#0dd90d",class:"success"},"video player is playing":{tips:"Local video playback success",color:"#0dd90d",class:"success"},"audio player is playing":{tips:"Local audio playback success",color:"#0dd90d",class:"success"},"stream - video player is starting playing":{tips:"Local video playback success",color:"#0dd90d",class:"success"},"stream - audio player is starting playing":{tips:"Local audio playback success",color:"#0dd90d",class:"success"},"switch camera success":{tips:"Switch camera success",color:"#0dd90d",class:"success"},"switch microphone success":{tips:"Switch microphone success",color:"#0dd90d",class:"success"},gotStream:{tips:"Local stream capture success"},"local stream is published successfully":{tips:"Publish success",color:"#0dd90d",class:"success"},"encoderImplementation change to OpenH264":{tips:"Use software encoding"},"encoderImplementation change to ExternalEncoder":{tips:"Use hardware encoding"},"getUserMedia with constraints":{tips:"Start media (camera/microphone) capture"},"getDisplayMedia with constraints":{tips:"Start screen sharing capture"},"client-banned":{tips:"Kicked out of the room",color:"red",class:"red",textColor:"#fff"},user_timeout:{tips:"The backend is too long without receiving SDK heartbeat, which is usually caused by the JS thread being blocked for a long time. If the reproduction probability is high, the application browser Performance tool analyzes where the JS thread is blocked.",color:"red",class:"red",textColor:"#fff"},"schedule failed":{tips:"Signaling request failed, does not affect the normal room entry process, SDK will connect to the default signaling domain."},"updateStream() video flag is true, but no camera detected, set video to false":{tips:"When trying to resume camera acquisition, the camera acquisition is not resumed because it is detected that there is no camera.",color:"orange",class:"orange",textColor:"#fff"},"qualityLimitationReason change to bandwidth":{tips:"bandwidth estimation is not enough to limit the quality of the encoding, which may cause the code rate, frame rate, and resolution to be lowered.",color:"orange",class:"orange",textColor:"#fff"},"qualityLimitationReason change to cpu":{tips:"cpu load is too high to limit the quality of the encoding, which may cause the code rate, frame rate, and resolution to be lowered.",color:"orange",class:"orange",textColor:"#fff"},"visibility change: hidden":{tips:"User page switched to backend, in mobile devices, this will cause the device to pause the capture, and it will be restored when the user switches backend to the frontend.",color:"orange",class:"orange",textColor:"#fff"},"visibility change: visible":{tips:"User page switched to frontend",color:"orange",class:"orange",textColor:"#fff"},"main stream - audio player is paused":{tips:`The remote stream audio playback is paused, which usually has two possibilities:
|
|
99
99
|
1. The business side passes in the div tag container for playing audio and video to be removed by the business side from the DOM.
|
|
100
100
|
2. If the user is in Chrome 70 and below, when the div container is moved, the playback will be paused.`,color:"orange",class:"orange",textColor:"#fff"},"main stream - video player is paused":{tips:`The remote stream video playback is paused, which usually has two possibilities:
|
|
101
101
|
1. The business side passes in the div tag container for playing audio and video to be removed by the business side from the DOM.
|