trtc-sdk-v5 5.9.0-wasm.7 → 5.9.0-wasm.8
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/cross-room/package.json +1 -1
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/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/virtual-background/package.json +1 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/trtc.esm.js +2 -2
package/package.json
CHANGED
package/trtc.esm.js
CHANGED
|
@@ -86,12 +86,12 @@ return ret;
|
|
|
86
86
|
`;for(var $=0;$<f-1;++$)I[$+1].deleteObject&&(Ie+=" argType"+$+".deleteObject(arg"+$+`);
|
|
87
87
|
`);C.isVoid||(Ie+=` return retType.toWireType(destructors, rv);
|
|
88
88
|
`),Ie+=`};
|
|
89
|
-
`,W.push(Ie);var Ue=ac(Function,W).apply(null,V);return B=El(Ue),Ic[O]=B,B}var Il=()=>{yi("")},Sc;Sc=()=>performance.now();var Sl=(f,_,I)=>Le.copyWithin(f,_,_+I),yl=f=>{yi("OOM")},Al=f=>{var _=Le.length;f>>>=0,yl(f)},bl=[null,[],[]],Rl=(f,_)=>{var I=bl[f];_===0||_===10?((f===1?Pe:Xe)(Qr(I,0)),I.length=0):I.push(_)},In={varargs:void 0,get(){In.varargs+=4;var f=qt[In.varargs-4>>2];return f},getStr(f){var _=pc(f);return _}},vl=(f,_,I,C)=>{for(var O=0,B=0;B<I;B++){var W=x[_>>2],V=x[_+4>>2];_+=8;for(var ee=0;ee<V;ee++)Rl(f,Le[W+ee]);O+=V}return x[C>>2]=O,0};Ju(),yt=e.BindingError=class extends Error{constructor(_){super(_),this.name="BindingError"}},qr=e.InternalError=class extends Error{constructor(_){super(_),this.name="InternalError"}},eo(),dn(),ro(),sc=e.UnboundTypeError=tl(Error,"UnboundTypeError"),ol(),nl();var Cl={o:sn,r:qu,m:zu,q:rl,p:fn,d:cc,u:al,k:dl,b:ul,a:ll,j:hc,g:fl,n:_l,e:Tc,l:uc,h:Tn,f:Il,c:Sc,t:Sl,s:Al,i:vl},Rh=ja(),Dl=()=>(Dl=je.w)(),mr=f=>(mr=je.x)(f),Sn=f=>(Sn=je.y)(f),yc=f=>(yc=je.A)(f),Nl=e.__embind_initialize_bindings=()=>(Nl=e.__embind_initialize_bindings=je.B)(),wl=()=>(wl=je.__errno_location)(),Ac=f=>(Ac=je.C)(f),yn=e.dynCall_jiji=(f,_,I,C,O)=>(yn=e.dynCall_jiji=je.D)(f,_,I,C,O),is;Gr=function f(){is||bc(),is||(Gr=f)};function bc(){if(Wr>0||(Bu(),Wr>0))return;function f(){is||(is=!0,e.calledRun=!0,!Qs&&($u(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),q()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),f()},1)):f()}if(e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return bc(),t.ready}})(),B_=ES;var nu=class extends Br{constructor(t){super(B_,t!=null&&t.wasmPath?fetch(t.wasmPath).then(e=>e.arrayBuffer()):void 0,t==null?void 0:t.workerMode,t==null?void 0:t.canvas,t==null?void 0:t.yuvMode)}};var au=class au{constructor(t){this.core=t;l(this,"contextMap",new Map);l(this,"decodeProcessorMap",new WeakMap);this.createDecoder=this.createDecoder.bind(this)}getAlias(){return"videoDecoder"}getGroup(t){return t!=null&&t.track?`${t.track.userId}${t.track.streamType}`:"*"}getName(){return au.Name}getValidateRule(t){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(t,e){switch(t){case"wasm":return this.core.rtcDectection.isSIMDSupported()?new nu(pe(J({},e),{wasmPath:`${this.core.assetsPath||"."}/videodec_simd.wasm`})):new su(pe(J({},e),{wasmPath:`${this.core.assetsPath||"."}/videodec.wasm`}));case"webCodecs":return new Ti;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:a})=>{if(a!==t.track||s.type==="empty")return s;if(this.contextMap.has(a))return this.contextMap.get(a).decode(s);let d=this.core.room.videoManager.createDecodeContext(pe(J({},t),{createDecoder:this.createDecoder}));return e(d.trackDoneOB,r(1),o(()=>{this.core.clearStarted(this,this.getGroup(t)),this.stop({track:a})})),this.contextMap.set(a,d),d.decode(s)}}stop(t){if(!(t!=null&&t.track))this.contextMap.forEach((e,r)=>{e.close("stop"),this.contextMap.delete(r)});else{let e=this.contextMap.get(t.track);e&&(e.close("stop"),this.contextMap.delete(t.track))}this.contextMap.size===0&&this.core.room.videoManager.removeDecodeProcessor({type:3})}update(t){let e=this.contextMap.get(t.track);if(e){if(t.type==="mock"){e.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST);return}e.close("update"),this.contextMap.set(t.track,this.core.room.videoManager.createDecodeContext(pe(J({},t),{createDecoder:this.createDecoder})))}}};l(au,"Name","TRTCVideoDecoder");var wa=au;var cg=Ci(ki());function Hp({timesInSecond:i,maxSizeInSecond:t,getSize:e}){return Ae((r,o)=>{let s=new WeakMap;return F.on(P.ROOM_DESTROY,({room:a})=>s.delete(a)),function(...a){let d=s.get(this);if(d||(d={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},s.set(this,d)),d.timestamp===0?d.timestamp=Date.now():Date.now()-d.timestamp>1e3&&(d.timestamp=Date.now(),d.callCountInSecond=0,d.totalSizeInSecond=0),e&&(d.totalSizeInSecond+=e(...a)),d.timestamp!==0&&Date.now()-d.timestamp<1e3&&(d.callCountInSecond>=i||d.totalSizeInSecond>t))throw new ue({code:Y.INVALID_OPERATION,message:st({key:ot.CALL_FREQUENCY_LIMIT,data:{isTimes:d.callCountInSecond>=i,isSize:d.totalSizeInSecond>t,name:o,timesInSecond:i,maxSizeInSecond:t}})});d.callCountInSecond++,r.call(this,...a)}})}var TS="2025-02-13 16:29:40",$_=!0,H_=function(){var i;$_&&($_=!1,U.getLogLevel()!==5&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info(`* API Document: ${Nr}/en/index.html`),console.info(`* Changelog: ${Nr}/en/tutorial-01-info-changelog.html`),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),U.info("TRTC Web SDK Version:",Ke),Tr||U.debug("Build Time:",TS),U.info("UA:",navigator.userAgent),U.info(`URL: ${location.href}${((i=self.frameElement)==null?void 0:i.tagName)==="IFRAME"?" in iframe":""}`),Kn().then(t=>{t&&U.info(fr)}))};var nr={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 ae={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},yr=(w=>(w[w.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",w[w.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",w[w.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",w[w.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",w[w.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",w[w.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",w[w.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",w[w.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",w[w.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",w[w.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",w[w.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",w[w.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",w[w.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",w[w.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",w[w.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",w[w.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",w[w.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",w[w.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",w[w.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",w[w.INVALID_OPERATION=5100]="INVALID_OPERATION",w[w.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",w[w.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",w[w.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",w[w.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",w[w.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",w[w.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",w[w.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",w[w.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",w[w.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",w[w.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",w[w.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",w[w.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",w[w.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",w[w.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",w[w.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",w[w.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",w[w.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",w[w.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",w[w.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",w[w.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",w[w.DEVICE_ERROR=5300]="DEVICE_ERROR",w[w.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",w[w.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",w[w.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",w[w.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",w[w.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",w[w.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",w[w.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",w[w.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",w[w.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",w[w.SERVER_ERROR=5400]="SERVER_ERROR",w[w.NEED_TO_BUY=5401]="NEED_TO_BUY",w[w.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",w[w.OPERATION_FAILED=5500]="OPERATION_FAILED",w[w.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",w[w.REJOIN_FAILED=5502]="REJOIN_FAILED",w[w.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",w[w.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",w[w.VIDEO_DECODE_ERROR=5505]="VIDEO_DECODE_ERROR",w[w.OPERATION_ABORT=5998]="OPERATION_ABORT",w[w.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",w))(yr||{});function G_({code:i,params:t,enableDocLink:e=!1}){let r="",o,s=yr[i];try{o=W_[s]}catch(a){o=W_.UNKNOWN_ERROR}return Fe(o)?r=o(t):Se(o)&&(r=o),t.fnName&&!r.includes(t.fnName)&&(r[r.length-1]!=="."&&(r+="."),r+=` thrown from ${t.fnName}()`),e&&(r+=" doc:"),r}var W_=pe(J({},Wt),{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: ${ut(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: ${ut(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_REQUIED(){return"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required."},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 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=$o(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=$o(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=$o(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=$o(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=$o(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=$o(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=$o(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 $o(i){if(!i)return"camera";let t=i.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var Wp=class i extends Error{constructor({code:e,extraCode:r,message:o="",messageParams:s,fnName:a="",originError:d}){var m;let h;o?h=o:h=G_({code:e===ae.SERVER_ERROR?e:r||e,params:J({fnName:a,error:d},s)});super(h);l(this,"name","RtcError");l(this,"code");l(this,"extraCode");l(this,"functionName");l(this,"message");l(this,"handler");l(this,"originError");this.name=yr[e],this.code=e,this.extraCode=r,this.functionName=a,this.originError=d,this.message=h,this.extraCode===5302&&((m=this.originError)!=null&&m.message.includes("system"))&&(this.handler=()=>{let T={startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"},S={startLocalVideo:"webcam",startLocalAudio:"microphone"},v=document.createElement("a");ho?v.href=`ms-settings:privacy-${S[this.functionName]}`:Er&&(v.href=`x-apple.systempreferences:com.apple.preference.security?Privacy_${T[this.functionName]}`),v.href.length>0&&v.click()})}static convertFrom(e,r,o){let s=e;if(e instanceof ue){let{stack:a}=e,d={code:ae.UNKNOWN_ERROR,fnName:r,originError:e};switch(e.getCode()){case Y.INVALID_PARAMETER:d.code=ae.INVALID_PARAMETER,d.message=e.message;break;case Y.INVALID_OPERATION:d.code=ae.INVALID_OPERATION;break;case Y.NOT_SUPPORTED:case Y.NOT_SUPPORTED_H264:d.code=ae.ENV_NOT_SUPPORTED,e.getCode()===Y.NOT_SUPPORTED_H264&&(d.extraCode=e.message.includes(Wt.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case Y.JOIN_ROOM_FAILED:d.messageParams={fnParams:o};case Y.SERVER_TIMEOUT:case Y.SWITCH_ROLE_FAILED:d.code=ae.SERVER_ERROR,d.extraCode=e.getExtraCode();break;case Y.API_CALL_ABORTED:d.code=ae.OPERATION_ABORT;break;case Y.DEVICE_NOT_FOUND:case Y.DEVICE_AUTO_RECOVER_FAILED:case Y.INITIALIZE_FAILED:d.code=5300,e.name&&(d.extraCode=IS(e.name));break;case Y.UNKNOWN:break;default:d.code=ae.OPERATION_FAILED}s=new i(d),a&&(s.stack+=a.substr(a.indexOf(`
|
|
89
|
+
`,W.push(Ie);var Ue=ac(Function,W).apply(null,V);return B=El(Ue),Ic[O]=B,B}var Il=()=>{yi("")},Sc;Sc=()=>performance.now();var Sl=(f,_,I)=>Le.copyWithin(f,_,_+I),yl=f=>{yi("OOM")},Al=f=>{var _=Le.length;f>>>=0,yl(f)},bl=[null,[],[]],Rl=(f,_)=>{var I=bl[f];_===0||_===10?((f===1?Pe:Xe)(Qr(I,0)),I.length=0):I.push(_)},In={varargs:void 0,get(){In.varargs+=4;var f=qt[In.varargs-4>>2];return f},getStr(f){var _=pc(f);return _}},vl=(f,_,I,C)=>{for(var O=0,B=0;B<I;B++){var W=x[_>>2],V=x[_+4>>2];_+=8;for(var ee=0;ee<V;ee++)Rl(f,Le[W+ee]);O+=V}return x[C>>2]=O,0};Ju(),yt=e.BindingError=class extends Error{constructor(_){super(_),this.name="BindingError"}},qr=e.InternalError=class extends Error{constructor(_){super(_),this.name="InternalError"}},eo(),dn(),ro(),sc=e.UnboundTypeError=tl(Error,"UnboundTypeError"),ol(),nl();var Cl={o:sn,r:qu,m:zu,q:rl,p:fn,d:cc,u:al,k:dl,b:ul,a:ll,j:hc,g:fl,n:_l,e:Tc,l:uc,h:Tn,f:Il,c:Sc,t:Sl,s:Al,i:vl},Rh=ja(),Dl=()=>(Dl=je.w)(),mr=f=>(mr=je.x)(f),Sn=f=>(Sn=je.y)(f),yc=f=>(yc=je.A)(f),Nl=e.__embind_initialize_bindings=()=>(Nl=e.__embind_initialize_bindings=je.B)(),wl=()=>(wl=je.__errno_location)(),Ac=f=>(Ac=je.C)(f),yn=e.dynCall_jiji=(f,_,I,C,O)=>(yn=e.dynCall_jiji=je.D)(f,_,I,C,O),is;Gr=function f(){is||bc(),is||(Gr=f)};function bc(){if(Wr>0||(Bu(),Wr>0))return;function f(){is||(is=!0,e.calledRun=!0,!Qs&&($u(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),q()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),f()},1)):f()}if(e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return bc(),t.ready}})(),B_=ES;var nu=class extends Br{constructor(t){super(B_,t!=null&&t.wasmPath?fetch(t.wasmPath).then(e=>e.arrayBuffer()):void 0,t==null?void 0:t.workerMode,t==null?void 0:t.canvas,t==null?void 0:t.yuvMode)}};var au=class au{constructor(t){this.core=t;l(this,"contextMap",new Map);l(this,"decodeProcessorMap",new WeakMap);this.createDecoder=this.createDecoder.bind(this)}getAlias(){return"videoDecoder"}getGroup(t){return t!=null&&t.track?`${t.track.userId}${t.track.streamType}`:"*"}getName(){return au.Name}getValidateRule(t){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(t,e){switch(t){case"wasm":return this.core.rtcDectection.isSIMDSupported()?new nu(pe(J({},e),{wasmPath:`${this.core.assetsPath||"."}/videodec_simd.wasm`})):new su(pe(J({},e),{wasmPath:`${this.core.assetsPath||"."}/videodec.wasm`}));case"webCodecs":return new Ti;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:a})=>{if(a!==t.track||s.type==="empty")return s;if(this.contextMap.has(a))return this.contextMap.get(a).decode(s);let d=this.core.room.videoManager.createDecodeContext(pe(J({},t),{createDecoder:this.createDecoder}));return e(d.trackDoneOB,r(1),o(()=>{this.core.clearStarted(this,this.getGroup(t)),this.stop({track:a})})),this.contextMap.set(a,d),d.decode(s)}}stop(t){if(!(t!=null&&t.track))this.contextMap.forEach((e,r)=>{e.close("stop"),this.contextMap.delete(r)});else{let e=this.contextMap.get(t.track);e&&(e.close("stop"),this.contextMap.delete(t.track))}this.contextMap.size===0&&this.core.room.videoManager.removeDecodeProcessor({type:3})}update(t){let e=this.contextMap.get(t.track);if(e){if(t.type==="mock"){e.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST);return}e.close("update"),this.contextMap.set(t.track,this.core.room.videoManager.createDecodeContext(pe(J({},t),{createDecoder:this.createDecoder})))}}};l(au,"Name","TRTCVideoDecoder");var wa=au;var cg=Ci(ki());function Hp({timesInSecond:i,maxSizeInSecond:t,getSize:e}){return Ae((r,o)=>{let s=new WeakMap;return F.on(P.ROOM_DESTROY,({room:a})=>s.delete(a)),function(...a){let d=s.get(this);if(d||(d={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},s.set(this,d)),d.timestamp===0?d.timestamp=Date.now():Date.now()-d.timestamp>1e3&&(d.timestamp=Date.now(),d.callCountInSecond=0,d.totalSizeInSecond=0),e&&(d.totalSizeInSecond+=e(...a)),d.timestamp!==0&&Date.now()-d.timestamp<1e3&&(d.callCountInSecond>=i||d.totalSizeInSecond>t))throw new ue({code:Y.INVALID_OPERATION,message:st({key:ot.CALL_FREQUENCY_LIMIT,data:{isTimes:d.callCountInSecond>=i,isSize:d.totalSizeInSecond>t,name:o,timesInSecond:i,maxSizeInSecond:t}})});d.callCountInSecond++,r.call(this,...a)}})}var TS="2025-02-13 18:36:56",$_=!0,H_=function(){var i;$_&&($_=!1,U.getLogLevel()!==5&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info(`* API Document: ${Nr}/en/index.html`),console.info(`* Changelog: ${Nr}/en/tutorial-01-info-changelog.html`),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),U.info("TRTC Web SDK Version:",Ke),Tr||U.debug("Build Time:",TS),U.info("UA:",navigator.userAgent),U.info(`URL: ${location.href}${((i=self.frameElement)==null?void 0:i.tagName)==="IFRAME"?" in iframe":""}`),Kn().then(t=>{t&&U.info(fr)}))};var nr={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 ae={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},yr=(w=>(w[w.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",w[w.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",w[w.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",w[w.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",w[w.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",w[w.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",w[w.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",w[w.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",w[w.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",w[w.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",w[w.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",w[w.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",w[w.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",w[w.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",w[w.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",w[w.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",w[w.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",w[w.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",w[w.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",w[w.INVALID_OPERATION=5100]="INVALID_OPERATION",w[w.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",w[w.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",w[w.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",w[w.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",w[w.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",w[w.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",w[w.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",w[w.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",w[w.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",w[w.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",w[w.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",w[w.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",w[w.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",w[w.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",w[w.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",w[w.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",w[w.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",w[w.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",w[w.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",w[w.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",w[w.DEVICE_ERROR=5300]="DEVICE_ERROR",w[w.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",w[w.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",w[w.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",w[w.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",w[w.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",w[w.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",w[w.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",w[w.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",w[w.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",w[w.SERVER_ERROR=5400]="SERVER_ERROR",w[w.NEED_TO_BUY=5401]="NEED_TO_BUY",w[w.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",w[w.OPERATION_FAILED=5500]="OPERATION_FAILED",w[w.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",w[w.REJOIN_FAILED=5502]="REJOIN_FAILED",w[w.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",w[w.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",w[w.VIDEO_DECODE_ERROR=5505]="VIDEO_DECODE_ERROR",w[w.OPERATION_ABORT=5998]="OPERATION_ABORT",w[w.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",w))(yr||{});function G_({code:i,params:t,enableDocLink:e=!1}){let r="",o,s=yr[i];try{o=W_[s]}catch(a){o=W_.UNKNOWN_ERROR}return Fe(o)?r=o(t):Se(o)&&(r=o),t.fnName&&!r.includes(t.fnName)&&(r[r.length-1]!=="."&&(r+="."),r+=` thrown from ${t.fnName}()`),e&&(r+=" doc:"),r}var W_=pe(J({},Wt),{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: ${ut(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: ${ut(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_REQUIED(){return"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required."},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 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=$o(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=$o(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=$o(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=$o(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=$o(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=$o(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=$o(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 $o(i){if(!i)return"camera";let t=i.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var Wp=class i extends Error{constructor({code:e,extraCode:r,message:o="",messageParams:s,fnName:a="",originError:d}){var m;let h;o?h=o:h=G_({code:e===ae.SERVER_ERROR?e:r||e,params:J({fnName:a,error:d},s)});super(h);l(this,"name","RtcError");l(this,"code");l(this,"extraCode");l(this,"functionName");l(this,"message");l(this,"handler");l(this,"originError");this.name=yr[e],this.code=e,this.extraCode=r,this.functionName=a,this.originError=d,this.message=h,this.extraCode===5302&&((m=this.originError)!=null&&m.message.includes("system"))&&(this.handler=()=>{let T={startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"},S={startLocalVideo:"webcam",startLocalAudio:"microphone"},v=document.createElement("a");ho?v.href=`ms-settings:privacy-${S[this.functionName]}`:Er&&(v.href=`x-apple.systempreferences:com.apple.preference.security?Privacy_${T[this.functionName]}`),v.href.length>0&&v.click()})}static convertFrom(e,r,o){let s=e;if(e instanceof ue){let{stack:a}=e,d={code:ae.UNKNOWN_ERROR,fnName:r,originError:e};switch(e.getCode()){case Y.INVALID_PARAMETER:d.code=ae.INVALID_PARAMETER,d.message=e.message;break;case Y.INVALID_OPERATION:d.code=ae.INVALID_OPERATION;break;case Y.NOT_SUPPORTED:case Y.NOT_SUPPORTED_H264:d.code=ae.ENV_NOT_SUPPORTED,e.getCode()===Y.NOT_SUPPORTED_H264&&(d.extraCode=e.message.includes(Wt.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case Y.JOIN_ROOM_FAILED:d.messageParams={fnParams:o};case Y.SERVER_TIMEOUT:case Y.SWITCH_ROLE_FAILED:d.code=ae.SERVER_ERROR,d.extraCode=e.getExtraCode();break;case Y.API_CALL_ABORTED:d.code=ae.OPERATION_ABORT;break;case Y.DEVICE_NOT_FOUND:case Y.DEVICE_AUTO_RECOVER_FAILED:case Y.INITIALIZE_FAILED:d.code=5300,e.name&&(d.extraCode=IS(e.name));break;case Y.UNKNOWN:break;default:d.code=ae.OPERATION_FAILED}s=new i(d),a&&(s.stack+=a.substr(a.indexOf(`
|
|
90
90
|
`)))}else{if(e instanceof i)return e;s=new i({code:ae.UNKNOWN_ERROR,fnName:r,originError:e})}return s}};function IS(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=Wp;var j_={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:{properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},q_={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}}},Hs={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(i,t,e){if(Se(i)&&!document.getElementById(i))throw new oe({code:ae.INVALID_PARAMETER,extraCode:5009,fnName:e,messageParams:{key:t}})}},J_={name:"userId",required:!0,type:"string"},z_={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[nr.AUDIO_PROFILE_STANDARD,nr.AUDIO_PROFILE_STANDARD_STEREO,nr.AUDIO_PROFILE_HIGH,nr.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function Ma(i,t){if(!i)throw new oe({code:ae.INVALID_OPERATION,extraCode:5101,fnName:t})}function X_(i,t,e){if(!i)throw new oe({code:ae.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:e}})}var NP={type:"number",notLessThanZero:!0},SS={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:ae.INVALID_OPERATION,extraCode:5104,fnName:e});if(i.roomId){if(Se(i.roomId))throw new oe({code:ae.INVALID_PARAMETER,extraCode:5016,fnName:e,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(i.roomId))&&i.roomId<4294967295))throw new oe({code:ae.INVALID_PARAMETER,extraCode:5013,fnName:e,messageParams:{key:t}})}else if(i.strRoomId){if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(i.strRoomId))throw new oe({code:ae.INVALID_PARAMETER,extraCode:5012,fnName:e,messageParams:{key:t}})}else throw new oe({code:ae.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"}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:Hs,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:j_},validate(i){var t;if(!((t=i==null?void 0:i.option)!=null&&t.videoTrack)&&mi())throw new oe({code:ae.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:pe(J({},Hs),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:j_}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:z_},validate(i){var t;if(!((t=i==null?void 0:i.option)!=null&&t.audioTrack)&&mi())throw new oe({code:ae.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:z_}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:Hs,publish:{type:"boolean"},option:q_},validate(i,t,e,r,o){var s;if(!((s=i==null?void 0:i.option)!=null&&s.videoTrack)&&mi())throw new oe({code:ae.ENV_NOT_SUPPORTED,extraCode:5201});if(!da())throw new oe({code:ae.ENV_NOT_SUPPORTED,fnName:e,extraCode:5205})}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:Hs,publish:{type:"boolean"},option:q_}},muteRemoteAudio:[J_,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[J_,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:Hs,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){Ma(this._room.isJoined,e);let r=this._room.remotePublishedUserMap.get(i.userId);if(X_(!!r,e,i),r&&(i.streamType==="main"&&!r.muteState.videoAvailable||i.streamType==="sub"&&!r.muteState.hasAuxiliary))throw new oe({code:ae.INVALID_OPERATION,extraCode:5103,fnName:e,messageParams:{value:i}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:pe(J({},Hs),{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){Ma(this._room.isJoined,e);let r=this._room.remotePublishedUserMap.get(i.userId);if(X_(!!r,e,i),r&&(i.streamType==="main"&&!r.muteState.videoAvailable||i.streamType==="sub"&&!r.muteState.hasAuxiliary))throw new oe({code:ae.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!=="*"&&L(i.streamType))throw new oe({code:ae.INVALID_PARAMETER,extraCode:5014,fnName:e})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(i,t,e){Ma(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(!pa)throw new oe({code:ae.ENV_NOT_SUPPORTED,fnName:e,extraCode:5207});if(!this._room.enableSEI)throw new oe({code:ae.INVALID_OPERATION,fnName:e,extraCode:5108});if(i.byteLength>1e3)throw new oe({code:ae.INVALID_PARAMETER,extraCode:5018,fnName:e});if(i.byteLength===0)throw new oe({code:ae.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:e});Ma(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:ae.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:ae.INVALID_PARAMETER,extraCode:5018,fnName:e});if(i.byteLength===0)throw new oe({code:ae.INVALID_PARAMETER,extraCode:5017,fnName:e,messageParams:{key:t}})}}},validate(i,t,e){if(Ma(this._room.isJoined,e),this._room.scene==="live"&&this._room.role==="audience")throw new oe({code:ae.INVALID_OPERATION,extraCode:5107,fnName:e,messageParams:{key:t}})}}},Et={TRTC:SS};var Dt=class extends Error{};function yS(i,t){let e=lo(i);for(let r=0;r<t.length;r++)Or(e[r],t[r]);return e}function AS(i){this._resolve=Promise.resolve(i)}function bS(i){this._reject=Promise.reject(i)}var Wi=class Wi{constructor(t,e){this.instance=t;this.group=e;l(this,"started",!1);l(this,"ops",[]);l(this,"startSame",()=>!0);l(this,"mergeUpdate",yS);let r=Wi.instances.get(t);r?r.set(e,this):Wi.instances.set(t,new Map([[e,this]]))}static get(t,e){if(!e)return;let r=Wi.instances.get(t);return r&&r.get(e)||new Wi(t,e)}static gets(t,e){let r=Wi.instances.get(t),o=[];return r&&r.forEach((s,a)=>{e.test(a)&&o.push(s)}),o}action(t,e,r){let o=d=>{var h;return t===0?this.started=!0:t===3&&(this.started=!1),this.ops.shift(),(h=this.currentOp)==null||h.action(),d},s=d=>{var h,m;throw this.ops.shift(),t===0&&((h=this.currentOp)==null?void 0:h.type)===2&&this.ops.shift().reject(new Dt("start failed")),(m=this.currentOp)==null||m.action(),d},a={type:t,action:()=>e(...a.args).then(o,s),args:r,resolve:AS,reject:bS};try{switch(this.state){case 1:if(t===0)throw new Dt("already started");break;case 4:if(t===2)throw new Dt("not started");break;default:return this.cacheOp(a)}}catch(d){return Promise.reject(d)}return this.ops.push(a),a.promise=e(...a.args).then(o,s)}cacheOp(t){if(this.ops.length===1)switch(this.state){case 0:case 2:if(t.type===0)throw new Dt("already start");break;case 3:switch(t.type){case 2:throw new Dt("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new Dt("unknown state")}else switch(t.type){case 3:switch(this.lastOpType){case 3:return this.lastOp.promise;default:let r=new Dt("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 Dt("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new Dt("start not allowed after update");case 0:throw new Dt("duplicate start");case 3:if(this.startSame(this.currentOp.args,t.args))throw this.ops.pop().reject(new Dt("keep start")),new Dt("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(Wi,"instances",new WeakMap);var Ii=Wi;var cu=new WeakMap,du=(i,t)=>{if(t instanceof Dt){let{stack:e}=t;t=new oe({code:ae.OPERATION_ABORT,message:`${i} abort: ${t.message}`,fnName:i}),e&&(t.stack+=e.substr(e.indexOf(`
|
|
91
91
|
`)))}throw t};function Gi(i,t){return Ae((e,r)=>function(...o){let s=Ii.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(du.bind(null,r))):e.apply(this,o)})}function Ho(i,t){let{merge:e,debounce:r}=t||{};return Ae((o,s)=>function(...a){let d=Ii.get(this,typeof i=="string"?i:i.call(this,...a));if(!d)return o.apply(this,a);if(e&&(d.mergeUpdate=e.bind(this)),r&&r.isNeedToDebounce.apply(this,a)){let{delay:h,getKey:m}=r;return new Promise((T,S)=>{var j,H;let v=(j=cu.get(this))==null?void 0:j.get(m(...a));if(v){let{timeoutId:z,resolve:Te}=v;clearTimeout(z),Te()}let N=setTimeout(()=>{if(d.state===3||d.state===4)return T();d.action(2,o.bind(this),a).catch(du.bind(null,s)).then(T,S)},h);cu.has(this)?(H=cu.get(this))==null||H.set(m(...a),{timeoutId:N,resolve:T}):cu.set(this,new Map([[m(...a),{timeoutId:N,resolve:T}]]))})}return d.action(2,o.bind(this),a).catch(du.bind(null,s))})}function ji(i){return Ae((t,e)=>function(...r){let o=typeof i=="function"?i.call(this,...r):i;if(o instanceof RegExp)return Promise.all(Ii.gets(this,o).map(a=>a.action(3,()=>Promise.resolve(),r))).then(()=>t.call(this,...r));let s=Ii.get(this,o);return s?s.action(3,t.bind(this),r).catch(du.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"},Q_=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]);function qi(i){return i==="sub"?"auxiliary":i==="auxiliary"?"sub":"main"}function Oa(i){return i===nr.QOS_PREFERENCE_CLEAR?"detail":i===nr.QOS_PREFERENCE_SMOOTH?"motion":""}var jp={};Kr(jp,{bytes2ms:()=>jh,convertObjectNumberToInt:()=>Fn,copyProperties:()=>Gh,deepClone:()=>lo,deepMerge:()=>Or,delay:()=>Bn,fibonacci:()=>mo,formatedTime:()=>Gc,getConstructorName:()=>Un,getContainerFromElement:()=>Kh,getEnv:()=>$h,getInternalVersion:()=>Yh,getLoggerUrl:()=>ii,getMuteStateFromFlag:()=>Vn,getNetworkType:()=>kn,getNumNetworkType:()=>$c,getReconnectionTimeout:()=>Jh,getStringByteLength:()=>ef,getTurnServer:()=>Zh,getUint32Version:()=>Jc,getValueType:()=>ut,getViewListFromView:()=>ls,glog:()=>Ln,ipv4ToUint32:()=>us,isArray:()=>it,isAudioWorkletSupported:()=>Qh,isBoolean:()=>nt,isConstructor:()=>ds,isEmpty:()=>Wc,isFunction:()=>Fe,isLangChinese:()=>hr,isMediaStreamTrack:()=>zh,isNumber:()=>$e,isObject:()=>rr,isOverseaSdkAppId:()=>xn,isPlainObject:()=>Bt,isPortrait:()=>qc,isPromise:()=>Ni,isRemoteTrack:()=>Xh,isString:()=>Se,isUndefined:()=>L,loadImage:()=>ms,ms2bytes:()=>qh,ms2samples:()=>zl,performanceNow:()=>ge,promiseAny:()=>Hc,samples2ms:()=>Jl,setNetworkType:()=>Wh,stringify:()=>ir,stringifyIncludeValue:()=>jc,throttlePromise:()=>zc});var zp={};Kr(zp,{getAbilityConfigUrl:()=>vS,getScheduleDomain:()=>Pa,isNeedToSchedule:()=>uu,scheduleProxy:()=>Ar,sendScheduleRequest:()=>Jp,setIsNeedToSchedule:()=>Wo,setScheduleProxy:()=>lu});var qp=null,uu=!0;typeof document!="undefined"&&document.head.insertAdjacentHTML("beforeend",Object.values(ri).map(i=>`<link rel="dns-prefetch" href="https://${i}">`).join(`\r
|
|
92
92
|
`));function Wo(i){nt(i)&&i!==uu&&(uu=i,U.info(`setIsNeedToSchedule ${i}`))}F.on("28",()=>Wo(!0));F.on("63",()=>Wo(!0));F.on("84",()=>Wo(!0));F.on("201",i=>{i.state==="RECONNECTING"&&Wo(!0)});F.on("202",i=>{i.state==="RECONNECTING"&&Wo(!0)});function RS(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=Ws(i,D.MAIN),a=Ws(i,D.BACKUP);for(let d of o)if(d.startTime>=e&&(d.name===s||d.name===a)&&d.transferSize>0){let h=d.name===s?D.MAIN:D.BACKUP,m=Math.round(d.duration),T=Math.round(d.domainLookupStart-d.startTime),S=d.redirectStart>0?Math.round(d.redirectEnd-d.redirectStart):0,v=d.fetchStart>0?Math.round(d.domainLookupStart-d.fetchStart):0,N=Math.round(d.domainLookupEnd-d.domainLookupStart),j=Math.round(d.requestStart-d.secureConnectionStart),H=Math.round(d.secureConnectionStart-d.connectStart),z=Math.round(d.responseStart-d.requestStart),Te=Math.round(d.responseEnd-d.responseStart),Pe=[N,j,H,z,Te];Ve.uploadEvent({log:`stat-schedule-net:${m}(${T}(${S}->${v})->${Pe.join("->")}) ${h}`,userId:t}),r=pe(J({},r),{totalCost:m,local:T,dns:N,tcp:H,tls:j,request:z,response:Te});break}}catch(o){U.error("getScheduleDetailCost error",o)}return r}function Jp(m){return A(this,arguments,function*({userId:i,sdkAppId:t,useStringRoomId:e,roomId:r,userSig:o,version:s,frameWorkType:a,role:d,latencyLevel:h}){if(!uu&&qp)return{isCached:!0,result:qp};let T={delta:0,count:[1,1],msg:[],detail:[]};try{let S=new FormData;S.append("userId",String(i)),S.append("sdkAppId",String(t)),S.append("isStrGroupId",String(e)),S.append("groupId",String(r)),S.append("sdkVersion",s),S.append("userSig",String(o)),d&&S.append("role",String(d)),h&&S.append("latencyLevel",String(h)),a&&S.append("frameWorkType",String(a));let v=ge(),N=yield DS(S,T,t);N.config&&(N.config.loggerDomain&&no(N.config.loggerDomain),nt(N.config.scheduleCache)&&Wo(!N.config.scheduleCache)),T.delta=ge()-v;let j=RS(Number(t),i,v);return qp=N,{isCached:!1,result:N,detailCost:j}}catch(S){let v=it(S)?S[0]:S,N=$e(v.code)?v.code:0,j=`schedule failed${v.message?`: ${v.message}`:""}`,H=new ue({code:Y.SCHEDULE_FAILED,extraCode:N,message:st({key:ot.JOIN_ROOM_FAILED,data:{error:j,code:N}})});throw U.error(j,N),H}})}var Ar={main:"",backup:""};function lu(i){it(i)?(Ar.main=i[0],Ar.backup=i[1]):Ar.main=i}function Ws(i,t=D.MAIN,e=!1){return`https://${Ar[t]||Pa(i,t,e)}/api/v1/config`}function vS(i,t=D.MAIN){return`https://${Ar[t]||Pa(i,t)}/api/v1/trtcAutoConf`}function Pa(i,t=D.MAIN,e=!1){let r;return xn(i)?e?r=t===D.MAIN?ri.MAIN_OVERSEA_BACKUP:ri.BACKUP_OVERSEA:r=t===D.MAIN?ri.MAIN_OVERSEA:ri.BACKUP_OVERSEA:r=t===D.MAIN?ri.MAIN:ri.BACKUP,r}function CS(i,t,e){return new Promise((r,o)=>{oi({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 Y_=(i,t)=>Mi({retryFunction:CS,settings:{retries:3,timeout:0},onError:t,onRetrying:i});function DS(i,t,e){return new Promise((r,o)=>{let s=null;Hc([Y_(a=>t.count[0]=a+1,({error:a,retry:d,retriedCount:h,retryFuncArgs:m})=>{t.msg[0]=a.message,s||(h>=1&&(m[0]=Ws(e,D.MAIN,!0)),d())})(Ws(e,D.MAIN),i,{get timeout(){return mo(2+t.count[0])*1e3}}),Y_(a=>t.count[1]=a+1,({error:a,retry:d,retriedCount:h,retryFuncArgs:m})=>{t.msg[1]=a.message,s||(h>=2&&(m[0]=Ws(e,D.BACKUP,!0)),d())})(Ws(e,D.BACKUP),i,{get timeout(){return mo(2+t.count[1])*1e3}})]).then(a=>{s=a,r(s)}).catch(o)})}var NS=i=>i.startsWith("data:application/octet-stream;base64,"),wS=i=>i.startsWith("file://"),mu=class{constructor(){l(this,"_log");this._log=U.createLogger({id:"fd"})}download(t,e){return A(this,null,function*(){let{type:r="blob"}=e||{};try{let o=ge(),s;if(Fe(fetch)?s=yield this.downloadWithFetch(t,r):s=yield this.downloadWithXHR(t,r),!s||!s.data)throw new Error("data is empty");let a=ge()-o;return this._log.info(`downloaded: ${t}, return type: ${r}, cost: ${a}ms`),X.addSuccessEvent({key:522700,cost:ge()-o}),s.data}catch(o){throw this._log.error(`failed to download: ${t}, error: ${o}`),X.addFailedEvent({key:522700,error:o}),o}})}downloadWithFetch(t,e){return A(this,null,function*(){this._log.info(`download with fetch: ${t}, return type: ${e}`);try{let r=yield fetch(t);if(!r.ok)throw new Error("network response was not ok");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=()=>{s.status===200||s.status===0&&s.response?r({data:s.response}):o(new Error("XHR failed"))},s.onerror=o,s.send(null)})}loadWasm(t,e){return A(this,null,function*(){this._log.info(`loadWasm ${t}, importObject: ${JSON.stringify(e)}`);let r=ge(),o=null,s=null;if(Fe(WebAssembly.instantiateStreaming)&&!NS(t)&&!wS(t)&&Fe(fetch))try{let a=fetch(t);o=(yield WebAssembly.instantiateStreaming(a,e)).instance}catch(a){s=a}if(!o)try{let a=yield this.download(t,{type:"arraybuffer"});o=(yield WebAssembly.instantiate(a,e)).instance}catch(a){s=a}if(o){let a=ge()-r;return this._log.info(`loadedWasm ${t}, cost: ${a}ms`),X.addSuccessEvent({key:522701,cost:a}),o}throw this._log.error(`failed to loadWasm ${t}, error: ${s}`),X.addFailedEvent({key:522701,error:s}),s})}};G([Ui({settings:{timeout:0,retries:3},onRetrying(t){this._log.warn(`download retrying: ${t}`)}})],mu.prototype,"download",1);var Z_=new mu;function K_({TRTC:i,room:t,errorModule:e,assetsPath:r}){return{TRTC:i,room:t,assetsPath:r,fileDownloader:Z_,innerEmitter:F,constants:ql,environment:bs,utils:jp,eventLogger:Ve,log:this.room.getLogger(),loggerManager:U,errorModule:e,kvStatManager:X,rtcDectection:Li,trtc:this,rx:$p,enums:vm,schedule:zp,clearStarted:(o,s)=>{let a=o.getAlias(),d=Ii.instances.get(this);if(d)if(s){let h=d.get(a+s);if(!h)return;h.started=!1}else d.forEach((h,m)=>{m.startsWith(a)&&(h.started=!1)})},startGetPCM:ba,createAudioNode:Qm}}var eg=(i,t)=>{let{emit:e}=i;return i.emit=(...r)=>{try{return e.apply(i,r)}catch(o){let s=st({key:ot.CATCH_HANDLER_ERROR,data:{name:t,event:r[0]},addDocLink:!1});return U.warn(`${s}
|
|
93
93
|
|
|
94
|
-
${o.stack}`),!1}},i};var Gs=new WeakMap;function tg(i){let t=Gs.get(i);t&&(t.forEach(e=>clearTimeout(e)),Gs.delete(i))}function rg(i,t){return Ae((e,r)=>function(...o){let s=Gs.get(this);s||(s=new Map,Gs.set(this,s));let a=t(...o),d=s.get(a);if(!d||d<=0){e.apply(this,o);let h=setTimeout(()=>{var m;(m=Gs.get(this))==null||m.delete(a)},i);s.set(a,h)}else{clearTimeout(d);let h=window.setTimeout(()=>{var m;e.apply(this,o),(m=Gs.get(this))==null||m.delete(a)},i);s.set(a,h)}})}var ig="5.9.0-wasm.7";function Nt(...i){return Ae((t,e)=>function(...r){try{hu.call(this,i,r,e,this._name)}catch(o){return Promise.reject(o)}return t.apply(this,r)})}function Xp(...i){return Ae((t,e)=>function(...r){try{hu.call(this,i,r,e,this._name)}catch(o){throw o}return t.apply(this,r)})}function hu(i,t,e,r){if(it(i))for(let o=0;o<i.length;o++)pu.call(this,{rule:i[o],value:t[o],key:i[o].name,fnName:e,className:r});else pu.call(this,{rule:i,value:t[0],key:i.name,fnName:e,className:r})}function pu({rule:i,value:t,key:e,fnName:r,className:o}){function s(h){return{code:ae.INVALID_PARAMETER,extraCode:h,fnName:r,messageParams:{key:e,rule:i,value:t}}}if(L(t)){if(i.required)throw new oe(s(5001));if(L(i.defaultValue)){Fe(i.validate)&&i.validate.call(this,t,e,r,o,this);return}t=i.defaultValue}if(Array.isArray(i.type)){let h=!1;for(let m=0;m<i.type.length;m++)i.type[m]===null&&t===null&&(h=!0),Fe(i.type[m])&&t instanceof i.type[m]&&(h=!0),Se(i.type[m])&&ut(t)===i.type[m].toLowerCase()&&(h=!0);if(!h)throw new oe({code:ae.INVALID_PARAMETER,extraCode:5002,fnName:r,messageParams:{key:e,rule:{type:i.type.map(m=>ds(m)?Un(m):Se(m)?m:ut(m))},value:t}})}else if(!L(i.type)&&ut(t)!==i.type)throw new oe(s(5002));if(i.allowEmpty===!1){let h=$e(t)&&(t===0||Number.isNaN(t)),m=Se(t)&&t.trim()==="";if(h||m)throw new oe(s(5003))}if(i.notLessThanZero&&$e(t)&&t<0)throw new oe(s(5006));if(!L(i.min)&&$e(t)&&t<i.min)throw new oe(s(5007));if(!L(i.max)&&$e(t)&&t>i.max)throw new oe(s(5008));if(Se(i.instanceOf)){if(!t||t._name!==i.instanceOf)throw new oe(s(5004))}else if(Fe(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:a}=i;Bt(a)&&rr(t)&&Object.keys(a).forEach(h=>{pu.call(this,{rule:a[h],value:t&&t[h],key:`${h}`,fnName:r,className:o})});let{arrayItem:d}=i;Bt(d)&&it(t)&&t.forEach((h,m)=>{pu.call(this,{rule:d,value:h,key:`${e}[${m}]`,fnName:r,className:o})}),Fe(i.validate)&&i.validate.call(this,t,e,r,o,this)}function qe(i={}){let{getRemoteId:t=()=>"",replaceArg:e,getKVReportKey:r,ignoreLog:o}=i;return Ae((s,a)=>function(...d){var S;function h(v,N,j){if(j&&j.includes(v))return"hided";if(e){let H=e(...d);if(d[H.argIndex]===N)return H.value}if(N===d||v in d)return N;try{return N instanceof HTMLElement?`id: ${N.id} type:${ut(N)}`:(JSON.stringify(N),N)}catch(H){return`type:${ut(N)}`}}let m=this._log||U;if(o!=null&&o(...d))return s.apply(this,d);d.length>0?m.info(`${a}() ${JSON.stringify(d,(v,N)=>h(v,N,["userSig","privateMapKey"]))}`):m.info(`${a}()`);let T=r?r(...d):Sd[a];try{let v=s.apply(this,d),N=ge();return Ni(v)?v.then(j=>(m.info(`${a}() success ${t.call(this,...d)}`),X.addSuccessEvent({key:T,cost:ge()-N}),j)).catch(j=>{var Te;j=oe.convertFrom.call(this,j,a,d.length===1?d[0]:d);let H=j.extraCode||j.code,z=(Te=j.message)!=null&&Te.includes(H)?"":` code:${H}`;throw m.error(`${a}() failed ${t.call(this,...d)} ${j}${z} params: ${JSON.stringify(d,h)}`),X.addFailedEvent({key:T,error:j}),j}):(X.addSuccessEvent({key:T}),v)}catch(v){v=oe.convertFrom.call(this,v,a);let N=v.extraCode||v.code,j=(S=v.message)!=null&&S.includes(N)?"":` code:${N}`;throw m.error(`${a}() failed ${v}${j} params: ${JSON.stringify(d,h)}`),X.addFailedEvent({key:T,error:v}),v}})}var fu=i=>Ae((t,e)=>function(r,o){return A(this,null,function*(){let s=this._plugins.get(r);if(!s)throw this._log.error(`plugin ${String(r)} is not found`),new oe({code:ae.OPERATION_ABORT,message:`plugin ${String(r)} is not found`,fnName:e});if(Fe(s.constructor.isSupported)&&!s.constructor.isSupported())throw this._log.error(`plugin ${String(r)} is not supported`),new oe({code:ae.ENV_NOT_SUPPORTED,message:`plugin ${String(r)} is not supported`,extraCode:5210,fnName:e});return hu.call(this,s.getValidateRule(i),[o],e,"TRTC"),t.call(this,s,o)})});var _u=0,Qp=class{constructor(t,e){l(this,"player");l(this,"publisher");l(this,"mixInput");this.mixInput=new Ps(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&&(L(t.volume)||(this.volume=t.volume),L(t.loop)||(this.loop=t.loop),L(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)}}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(t=this.publisher)==null||t.play(),(e=this.player)==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 js(i,t){if(t&&typeof t!="function")throw new oe({code:ae.INVALID_PARAMETER,message:`start audioMixer plugin: param ${i} should be a function.`})}var $r=class $r{constructor(t){this.core=t;l(this,"log");l(this,"mixedMusicMap",new Map);l(this,"cacheMusicMap",new Map);_u=_u+1,this.log=t.log.createChild({id:`${this.getAlias()}${_u}`}),this.log.info(`[audioMixer] created id=${this.getAlias()}${_u}`),this.core=t}getName(){return $r.Name}getAlias(){return"ax"}getGroup(t){return t==null?void 0:t.id}getValidateRule(t){switch(t){case"start":return $r.startValidateRule;case"update":return $r.updateValidateRule;case"stop":return $r.stopValidateRule}}start(t){return A(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 Qp(t,e.audioManager),this.cacheMusicMap.set(r,s)),s.updateListener(t),s.updateSettings(t),yield s.play(),this.mixedMusicMap.set(r,s),this.log.info(`start mix audio track ${r} success.`),X.addEnum({key:502700,value:3}),this.kvUpload(t)})}update(t){return A(this,null,function*(){let{id:e,operation:r,seekFrom:o,playbackRate:s}=t;this.log.info(`update music source, ${JSON.stringify(t)}`);let a=this.mixedMusicMap.get(e);if(!a){this.log.warn(`update music source failed, music id: ${e} not found.`);return}a.updateSettings(t),a.updateListener(t),L(r)||a.setOperation(r),L(o)||a.seek(o),this.kvUpload(t)})}stop(e){return A(this,arguments,function*({id:t}){var r;this.mixedMusicMap.has(t)&&(this.log.info(`remove music source, music id: ${t}`),(r=this.mixedMusicMap.get(t))==null||r.stop(),this.mixedMusicMap.delete(t)),t==="*"&&this.destroyAllMusic()})}kvUpload(t){let{track:e,loop:r,volume:o,playbackRate:s,operation:a,seekFrom:d,onTimeUpdate:h,onDurationChange:m,onEnded:T}=t;e&&X.addCount({key:502711}),r&&X.addCount({key:502703}),o&&X.addCount({key:502704}),s&&X.addCount({key:502705}),a&&X.addCount({key:502706}),d&&X.addCount({key:502707}),typeof h!="function"&&X.addCount({key:502709}),typeof T!="function"&&X.addCount({key:502710}),typeof m!="function"&&X.addCount({key:502708})}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach((t,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($r,"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"],a=o.split(".").pop(),d=s.indexOf(a)>=0,h=o.startsWith("blob"),m=o.startsWith("data");if(!(d||h||m))throw new oe({code:ae.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:ae.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:r});js("onTimeUpdate",t.onTimeUpdate),js("onEnded",t.onEnded),js("onDurationChange",t.onDurationChange)}}),l($r,"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){js("onTimeUpdate",t.onTimeUpdate),js("onEnded",t.onEnded),js("onDurationChange",t.onDurationChange)}}),l($r,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),l($r,"Name","AudioMixer");var gu=$r;var Eu=0,Yp,Si=class Si{constructor(t){this.core=t;l(this,"log");l(this,"audioContext",lt("denoiser"));l(this,"workletNode");Eu=Eu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Eu}`}),this.log.info(`[audioDenoiser] created id=${this.getAlias()}${Eu}`),t.assetsPath&&this.preload(`${t.assetsPath}/denoiser-wasm.js`)}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}},validate(e,r,o,s){if(!t.room.audioManager.hasAudioTrack)throw new oe({code:ae.INVALID_OPERATION,extraCode:5106,fnName:o})}}}preload(t){return Yp||(Yp=this.doPreload(t)),Yp}doPreload(t){return A(this,null,function*(){let e=yield this.core.fileDownloader.download(t,{type:"blob"}),r=URL.createObjectURL(e);try{yield Ro(this.audioContext,r)}finally{URL.revokeObjectURL(r)}})}getName(){return Si.Name}getAlias(){return"ad"}getGroup(){return`AIDenoiser_${Date.now()}`}getValidateRule(t){switch(t){case"start":return Si.startValidateRule(this.core);case"update":return Si.updateValidateRule;case"stop":return Si.stopValidateRule}}start(t){return A(this,null,function*(){let{room:e}=this.core;if(yield this.preload(`${t.assetsPath}/denoiser-wasm.js`),!this.workletNode){let r=String(Date.now()).slice(0,-3),{auth:o,sign:s,status:a,message:d}=yield PS(pe(J({},t),{timestamp:r}));if(!o)throw this.log.info(`RTCAIDenoiser: ${t.userId} auth result: ${o}. Message: ${d}`),new oe({code:ae.INVALID_PARAMETER,message:d});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:r,sign:s,status:a}}),this.workletNode.port.onmessage=h=>{let{data:m}=h;m.type==="cost"&&this.log.debug(`[RTCAIDenoiser] ${m.value}`)}}this.workletNode.port.postMessage({type:"enable"}),e.audioManager.addDenoiser(this.workletNode),e.sendAbilityStatus({ai_denoise:1})})}update(){return A(this,null,function*(){})}stop(){return A(this,null,function*(){if(!this.workletNode)return;let{room:t}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield t.audioManager.removeDenoiser(this.workletNode)})}destroy(){this.workletNode&&(this.workletNode.port.onmessage=null)}};l(Si,"updateValidateRule",{type:"object"}),l(Si,"stopValidateRule",{type:"object"}),l(Si,"Name","AIDenoiser");var Tu=Si;function OS(i,t=D.MAIN){return`https://${Ar[t]||Pa(i,t)}/api/v1/audioAiAuth`}function PS(o){return A(this,arguments,function*({sdkAppId:i,userId:t,userSig:e,timestamp:r}){let a=`${OS(i)}?sdkAppId=${i}&userId=${t}&userSig=${e}×tamp=${r}`,d=yield fetch(a),{data:{errCode:h,errMsg:m,sign:T,status:S}}=yield d.json();if(S==="1")return{auth:!0,sign:T,status:S,message:m};let v="Init RTCAIDenoiser failed.",N="";switch(h){case 1:N="Please check your params.";break;case 2:N="You need to buy packages. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 3:N="Server is invalid. Please contact our engineer. ";break;case 4:N="Your packages is not active. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 5:N="Your packages is expired. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 6:N="Your version is not supported.";break}return{auth:!1,status:S,message:m?`${v} Reason: ${m}. ${N}`:`${v}, ${N}`}})}var og=Ci(ki(),1);var Zp=class extends og.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 A(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){Ve.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)&&U.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){Ve.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:r})}}},xS=new Zp,Kp=xS;function kS([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 d=0;d<r;d++)s.push(255);s.push(o);let a=new DataView(t);return s.push(...new Uint8Array(a.buffer)),s.push(128),new Do(new DataView(new Uint8Array(s).buffer),!0)}function LS(i){return i.type==="empty"||i.data.byteLength===0}function US(i){return i.getInt32(0)===1&&i.getInt8(4)===6}function VS(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 eh({frame:i,seiMessageList:t}){if(!t||t.length===0||i.data.byteLength===0)return i;let r=9-VS(i.data);if(r<=0)return i;let o=t.splice(0,r).reverse().map(kS),s=o.reduce((T,S)=>T+S.dataView.byteLength,0),a=new ArrayBuffer(s+i.data.byteLength),d=new DataView(a),h=new DataView(i.data),m=0;for(let T=0;T<o.length;T++)for(let S=0;S<o[T].dataView.byteLength;S++)d.setInt8(m++,o[T].dataView.getInt8(S));for(let T=0;T<i.data.byteLength;T++)d.setInt8(m++,h.getInt8(T));return i.data=a,i}function th({frame:i,onSEI:t}){try{let e=new DataView(i.data);if(LS(i)||!US(e))return i;let r=[],o=0,s=-1,a=-1;for(let d=0;d<i.data.byteLength;d++){let h=e.getUint8(d);if(h===0)o++;else if(h===1){if(o===2||o===3){let m=d-o;if(s===-1?s=m:a===-1&&(a=m,r.push(new Do(new DataView(e.buffer.slice(s,a)))),s=m,a=-1),!(e.getUint8(d+1)===6)){i.data=e.buffer.slice(m);break}}o=0}else o=0}t==null||t(r.reverse())}catch(e){}return i}var rh=0,xa=class xa{constructor(t){this.core=t;l(this,"log");l(this,"_seiMessageList",[]);l(this,"_smallSeiMessageList",[]);l(this,"_subStreamSeiMessageList",[]);rh++,this.log=t.log.createChild({id:`${this.getAlias()}${rh}`}),this.log.info(`[sei] created id=${this.getAlias()}${rh}`),this.core=t,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 eh({frame:t,seiMessageList:r})}catch(r){this.log.warn(r)}return t}decode({frame:t,track:e}){return th({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:ma?this.encode:eh,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:ma?this.decode:th,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 xa.Name}getAlias(){return"sei"}getGroup(){return"sei"}};l(xa,"autoStart",!0),l(xa,"Name","SEI");var Iu=xa;function ih({frame:i,onDump:t}){return t==null||t(),i}function oh({frame:i,onDump:t}){return t==null||t(),i}var sg={"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:
|
|
94
|
+
${o.stack}`),!1}},i};var Gs=new WeakMap;function tg(i){let t=Gs.get(i);t&&(t.forEach(e=>clearTimeout(e)),Gs.delete(i))}function rg(i,t){return Ae((e,r)=>function(...o){let s=Gs.get(this);s||(s=new Map,Gs.set(this,s));let a=t(...o),d=s.get(a);if(!d||d<=0){e.apply(this,o);let h=setTimeout(()=>{var m;(m=Gs.get(this))==null||m.delete(a)},i);s.set(a,h)}else{clearTimeout(d);let h=window.setTimeout(()=>{var m;e.apply(this,o),(m=Gs.get(this))==null||m.delete(a)},i);s.set(a,h)}})}var ig="5.9.0-wasm.8";function Nt(...i){return Ae((t,e)=>function(...r){try{hu.call(this,i,r,e,this._name)}catch(o){return Promise.reject(o)}return t.apply(this,r)})}function Xp(...i){return Ae((t,e)=>function(...r){try{hu.call(this,i,r,e,this._name)}catch(o){throw o}return t.apply(this,r)})}function hu(i,t,e,r){if(it(i))for(let o=0;o<i.length;o++)pu.call(this,{rule:i[o],value:t[o],key:i[o].name,fnName:e,className:r});else pu.call(this,{rule:i,value:t[0],key:i.name,fnName:e,className:r})}function pu({rule:i,value:t,key:e,fnName:r,className:o}){function s(h){return{code:ae.INVALID_PARAMETER,extraCode:h,fnName:r,messageParams:{key:e,rule:i,value:t}}}if(L(t)){if(i.required)throw new oe(s(5001));if(L(i.defaultValue)){Fe(i.validate)&&i.validate.call(this,t,e,r,o,this);return}t=i.defaultValue}if(Array.isArray(i.type)){let h=!1;for(let m=0;m<i.type.length;m++)i.type[m]===null&&t===null&&(h=!0),Fe(i.type[m])&&t instanceof i.type[m]&&(h=!0),Se(i.type[m])&&ut(t)===i.type[m].toLowerCase()&&(h=!0);if(!h)throw new oe({code:ae.INVALID_PARAMETER,extraCode:5002,fnName:r,messageParams:{key:e,rule:{type:i.type.map(m=>ds(m)?Un(m):Se(m)?m:ut(m))},value:t}})}else if(!L(i.type)&&ut(t)!==i.type)throw new oe(s(5002));if(i.allowEmpty===!1){let h=$e(t)&&(t===0||Number.isNaN(t)),m=Se(t)&&t.trim()==="";if(h||m)throw new oe(s(5003))}if(i.notLessThanZero&&$e(t)&&t<0)throw new oe(s(5006));if(!L(i.min)&&$e(t)&&t<i.min)throw new oe(s(5007));if(!L(i.max)&&$e(t)&&t>i.max)throw new oe(s(5008));if(Se(i.instanceOf)){if(!t||t._name!==i.instanceOf)throw new oe(s(5004))}else if(Fe(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:a}=i;Bt(a)&&rr(t)&&Object.keys(a).forEach(h=>{pu.call(this,{rule:a[h],value:t&&t[h],key:`${h}`,fnName:r,className:o})});let{arrayItem:d}=i;Bt(d)&&it(t)&&t.forEach((h,m)=>{pu.call(this,{rule:d,value:h,key:`${e}[${m}]`,fnName:r,className:o})}),Fe(i.validate)&&i.validate.call(this,t,e,r,o,this)}function qe(i={}){let{getRemoteId:t=()=>"",replaceArg:e,getKVReportKey:r,ignoreLog:o}=i;return Ae((s,a)=>function(...d){var S;function h(v,N,j){if(j&&j.includes(v))return"hided";if(e){let H=e(...d);if(d[H.argIndex]===N)return H.value}if(N===d||v in d)return N;try{return N instanceof HTMLElement?`id: ${N.id} type:${ut(N)}`:(JSON.stringify(N),N)}catch(H){return`type:${ut(N)}`}}let m=this._log||U;if(o!=null&&o(...d))return s.apply(this,d);d.length>0?m.info(`${a}() ${JSON.stringify(d,(v,N)=>h(v,N,["userSig","privateMapKey"]))}`):m.info(`${a}()`);let T=r?r(...d):Sd[a];try{let v=s.apply(this,d),N=ge();return Ni(v)?v.then(j=>(m.info(`${a}() success ${t.call(this,...d)}`),X.addSuccessEvent({key:T,cost:ge()-N}),j)).catch(j=>{var Te;j=oe.convertFrom.call(this,j,a,d.length===1?d[0]:d);let H=j.extraCode||j.code,z=(Te=j.message)!=null&&Te.includes(H)?"":` code:${H}`;throw m.error(`${a}() failed ${t.call(this,...d)} ${j}${z} params: ${JSON.stringify(d,h)}`),X.addFailedEvent({key:T,error:j}),j}):(X.addSuccessEvent({key:T}),v)}catch(v){v=oe.convertFrom.call(this,v,a);let N=v.extraCode||v.code,j=(S=v.message)!=null&&S.includes(N)?"":` code:${N}`;throw m.error(`${a}() failed ${v}${j} params: ${JSON.stringify(d,h)}`),X.addFailedEvent({key:T,error:v}),v}})}var fu=i=>Ae((t,e)=>function(r,o){return A(this,null,function*(){let s=this._plugins.get(r);if(!s)throw this._log.error(`plugin ${String(r)} is not found`),new oe({code:ae.OPERATION_ABORT,message:`plugin ${String(r)} is not found`,fnName:e});if(Fe(s.constructor.isSupported)&&!s.constructor.isSupported())throw this._log.error(`plugin ${String(r)} is not supported`),new oe({code:ae.ENV_NOT_SUPPORTED,message:`plugin ${String(r)} is not supported`,extraCode:5210,fnName:e});return hu.call(this,s.getValidateRule(i),[o],e,"TRTC"),t.call(this,s,o)})});var _u=0,Qp=class{constructor(t,e){l(this,"player");l(this,"publisher");l(this,"mixInput");this.mixInput=new Ps(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&&(L(t.volume)||(this.volume=t.volume),L(t.loop)||(this.loop=t.loop),L(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)}}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(t=this.publisher)==null||t.play(),(e=this.player)==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 js(i,t){if(t&&typeof t!="function")throw new oe({code:ae.INVALID_PARAMETER,message:`start audioMixer plugin: param ${i} should be a function.`})}var $r=class $r{constructor(t){this.core=t;l(this,"log");l(this,"mixedMusicMap",new Map);l(this,"cacheMusicMap",new Map);_u=_u+1,this.log=t.log.createChild({id:`${this.getAlias()}${_u}`}),this.log.info(`[audioMixer] created id=${this.getAlias()}${_u}`),this.core=t}getName(){return $r.Name}getAlias(){return"ax"}getGroup(t){return t==null?void 0:t.id}getValidateRule(t){switch(t){case"start":return $r.startValidateRule;case"update":return $r.updateValidateRule;case"stop":return $r.stopValidateRule}}start(t){return A(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 Qp(t,e.audioManager),this.cacheMusicMap.set(r,s)),s.updateListener(t),s.updateSettings(t),yield s.play(),this.mixedMusicMap.set(r,s),this.log.info(`start mix audio track ${r} success.`),X.addEnum({key:502700,value:3}),this.kvUpload(t)})}update(t){return A(this,null,function*(){let{id:e,operation:r,seekFrom:o,playbackRate:s}=t;this.log.info(`update music source, ${JSON.stringify(t)}`);let a=this.mixedMusicMap.get(e);if(!a){this.log.warn(`update music source failed, music id: ${e} not found.`);return}a.updateSettings(t),a.updateListener(t),L(r)||a.setOperation(r),L(o)||a.seek(o),this.kvUpload(t)})}stop(e){return A(this,arguments,function*({id:t}){var r;this.mixedMusicMap.has(t)&&(this.log.info(`remove music source, music id: ${t}`),(r=this.mixedMusicMap.get(t))==null||r.stop(),this.mixedMusicMap.delete(t)),t==="*"&&this.destroyAllMusic()})}kvUpload(t){let{track:e,loop:r,volume:o,playbackRate:s,operation:a,seekFrom:d,onTimeUpdate:h,onDurationChange:m,onEnded:T}=t;e&&X.addCount({key:502711}),r&&X.addCount({key:502703}),o&&X.addCount({key:502704}),s&&X.addCount({key:502705}),a&&X.addCount({key:502706}),d&&X.addCount({key:502707}),typeof h!="function"&&X.addCount({key:502709}),typeof T!="function"&&X.addCount({key:502710}),typeof m!="function"&&X.addCount({key:502708})}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach((t,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($r,"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"],a=o.split(".").pop(),d=s.indexOf(a)>=0,h=o.startsWith("blob"),m=o.startsWith("data");if(!(d||h||m))throw new oe({code:ae.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:ae.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:r});js("onTimeUpdate",t.onTimeUpdate),js("onEnded",t.onEnded),js("onDurationChange",t.onDurationChange)}}),l($r,"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){js("onTimeUpdate",t.onTimeUpdate),js("onEnded",t.onEnded),js("onDurationChange",t.onDurationChange)}}),l($r,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),l($r,"Name","AudioMixer");var gu=$r;var Eu=0,Yp,Si=class Si{constructor(t){this.core=t;l(this,"log");l(this,"audioContext",lt("denoiser"));l(this,"workletNode");Eu=Eu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Eu}`}),this.log.info(`[audioDenoiser] created id=${this.getAlias()}${Eu}`),t.assetsPath&&this.preload(`${t.assetsPath}/denoiser-wasm.js`)}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}},validate(e,r,o,s){if(!t.room.audioManager.hasAudioTrack)throw new oe({code:ae.INVALID_OPERATION,extraCode:5106,fnName:o})}}}preload(t){return Yp||(Yp=this.doPreload(t)),Yp}doPreload(t){return A(this,null,function*(){let e=yield this.core.fileDownloader.download(t,{type:"blob"}),r=URL.createObjectURL(e);try{yield Ro(this.audioContext,r)}finally{URL.revokeObjectURL(r)}})}getName(){return Si.Name}getAlias(){return"ad"}getGroup(){return`AIDenoiser_${Date.now()}`}getValidateRule(t){switch(t){case"start":return Si.startValidateRule(this.core);case"update":return Si.updateValidateRule;case"stop":return Si.stopValidateRule}}start(t){return A(this,null,function*(){let{room:e}=this.core;if(yield this.preload(`${t.assetsPath}/denoiser-wasm.js`),!this.workletNode){let r=String(Date.now()).slice(0,-3),{auth:o,sign:s,status:a,message:d}=yield PS(pe(J({},t),{timestamp:r}));if(!o)throw this.log.info(`RTCAIDenoiser: ${t.userId} auth result: ${o}. Message: ${d}`),new oe({code:ae.INVALID_PARAMETER,message:d});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:r,sign:s,status:a}}),this.workletNode.port.onmessage=h=>{let{data:m}=h;m.type==="cost"&&this.log.debug(`[RTCAIDenoiser] ${m.value}`)}}this.workletNode.port.postMessage({type:"enable"}),e.audioManager.addDenoiser(this.workletNode),e.sendAbilityStatus({ai_denoise:1})})}update(){return A(this,null,function*(){})}stop(){return A(this,null,function*(){if(!this.workletNode)return;let{room:t}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield t.audioManager.removeDenoiser(this.workletNode)})}destroy(){this.workletNode&&(this.workletNode.port.onmessage=null)}};l(Si,"updateValidateRule",{type:"object"}),l(Si,"stopValidateRule",{type:"object"}),l(Si,"Name","AIDenoiser");var Tu=Si;function OS(i,t=D.MAIN){return`https://${Ar[t]||Pa(i,t)}/api/v1/audioAiAuth`}function PS(o){return A(this,arguments,function*({sdkAppId:i,userId:t,userSig:e,timestamp:r}){let a=`${OS(i)}?sdkAppId=${i}&userId=${t}&userSig=${e}×tamp=${r}`,d=yield fetch(a),{data:{errCode:h,errMsg:m,sign:T,status:S}}=yield d.json();if(S==="1")return{auth:!0,sign:T,status:S,message:m};let v="Init RTCAIDenoiser failed.",N="";switch(h){case 1:N="Please check your params.";break;case 2:N="You need to buy packages. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 3:N="Server is invalid. Please contact our engineer. ";break;case 4:N="Your packages is not active. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 5:N="Your packages is expired. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 6:N="Your version is not supported.";break}return{auth:!1,status:S,message:m?`${v} Reason: ${m}. ${N}`:`${v}, ${N}`}})}var og=Ci(ki(),1);var Zp=class extends og.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 A(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){Ve.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)&&U.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){Ve.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:r})}}},xS=new Zp,Kp=xS;function kS([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 d=0;d<r;d++)s.push(255);s.push(o);let a=new DataView(t);return s.push(...new Uint8Array(a.buffer)),s.push(128),new Do(new DataView(new Uint8Array(s).buffer),!0)}function LS(i){return i.type==="empty"||i.data.byteLength===0}function US(i){return i.getInt32(0)===1&&i.getInt8(4)===6}function VS(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 eh({frame:i,seiMessageList:t}){if(!t||t.length===0||i.data.byteLength===0)return i;let r=9-VS(i.data);if(r<=0)return i;let o=t.splice(0,r).reverse().map(kS),s=o.reduce((T,S)=>T+S.dataView.byteLength,0),a=new ArrayBuffer(s+i.data.byteLength),d=new DataView(a),h=new DataView(i.data),m=0;for(let T=0;T<o.length;T++)for(let S=0;S<o[T].dataView.byteLength;S++)d.setInt8(m++,o[T].dataView.getInt8(S));for(let T=0;T<i.data.byteLength;T++)d.setInt8(m++,h.getInt8(T));return i.data=a,i}function th({frame:i,onSEI:t}){try{let e=new DataView(i.data);if(LS(i)||!US(e))return i;let r=[],o=0,s=-1,a=-1;for(let d=0;d<i.data.byteLength;d++){let h=e.getUint8(d);if(h===0)o++;else if(h===1){if(o===2||o===3){let m=d-o;if(s===-1?s=m:a===-1&&(a=m,r.push(new Do(new DataView(e.buffer.slice(s,a)))),s=m,a=-1),!(e.getUint8(d+1)===6)){i.data=e.buffer.slice(m);break}}o=0}else o=0}t==null||t(r.reverse())}catch(e){}return i}var rh=0,xa=class xa{constructor(t){this.core=t;l(this,"log");l(this,"_seiMessageList",[]);l(this,"_smallSeiMessageList",[]);l(this,"_subStreamSeiMessageList",[]);rh++,this.log=t.log.createChild({id:`${this.getAlias()}${rh}`}),this.log.info(`[sei] created id=${this.getAlias()}${rh}`),this.core=t,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 eh({frame:t,seiMessageList:r})}catch(r){this.log.warn(r)}return t}decode({frame:t,track:e}){return th({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:ma?this.encode:eh,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:ma?this.decode:th,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 xa.Name}getAlias(){return"sei"}getGroup(){return"sei"}};l(xa,"autoStart",!0),l(xa,"Name","SEI");var Iu=xa;function ih({frame:i,onDump:t}){return t==null||t(),i}function oh({frame:i,onDump:t}){return t==null||t(),i}var sg={"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:
|
|
95
95
|
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.
|
|
96
96
|
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:
|
|
97
97
|
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.
|