trtc-sdk-v5 5.9.0-wasm.3 → 5.9.0-wasm.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -6
- 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
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trtc-sdk-v5",
|
|
3
|
-
"version": "5.9.0-wasm.
|
|
3
|
+
"version": "5.9.0-wasm.4",
|
|
4
4
|
"description": "Tencent Cloud RTC SDK for Web",
|
|
5
|
-
"
|
|
5
|
+
"module": "trtc.esm.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"types": "index.d.ts",
|
|
7
|
-
"dependencies": {
|
|
8
|
-
"webrtc-adapter": "^8.2.3"
|
|
9
|
-
},
|
|
10
8
|
"keywords": [
|
|
11
9
|
"webrtc",
|
|
12
10
|
"TRTC",
|
|
@@ -29,4 +27,4 @@
|
|
|
29
27
|
},
|
|
30
28
|
"author": "Tencent Cloud Client R&D Center",
|
|
31
29
|
"license": "ISC"
|
|
32
|
-
}
|
|
30
|
+
}
|
package/trtc.esm.js
CHANGED
|
@@ -86,12 +86,12 @@ return ret;
|
|
|
86
86
|
`;for(var H=0;H<f-1;++H)I[H+1].deleteObject&&(ye+=" argType"+H+".deleteObject(arg"+H+`);
|
|
87
87
|
`);C.isVoid||(ye+=` return retType.toWireType(destructors, rv);
|
|
88
88
|
`),ye+=`};
|
|
89
|
-
`,G.push(ye);var ke=vc(Function,G).apply(null,U);return $=Vl(ke),Vc[M]=$,$}var Fl=()=>{Ni("")},Bc;Bc=()=>performance.now();var $l=(f,_,I)=>Pe.copyWithin(f,_,_+I),Hl=f=>{Ni("OOM")},Wl=f=>{var _=Pe.length;f>>>=0,Hl(f)},Gl=[null,[],[]],jl=(f,_)=>{var I=Gl[f];_===0||_===10?((f===1?Vt:Xe)(ci(I,0)),I.length=0):I.push(_)},Bn={varargs:void 0,get(){Bn.varargs+=4;var f=Yt[Bn.varargs-4>>2];return f},getStr(f){var _=xc(f);return _}},ql=(f,_,I,C)=>{for(var M=0,$=0;$<I;$++){var G=P[_>>2],U=P[_+4>>2];_+=8;for(var ee=0;ee<U;ee++)jl(f,Pe[G+ee]);M+=U}return P[C>>2]=M,0};ml(),yt=e.BindingError=class extends Error{constructor(_){super(_),this.name="BindingError"}},oi=e.InternalError=class extends Error{constructor(_){super(_),this.name="InternalError"}},uo(),Dn(),po(),Ac=e.UnboundTypeError=Sl(Error,"UnboundTypeError"),bl(),Rl();var zl={o:bn,r:pl,m:hl,q:yl,p:Pn,d:Rc,u:Cl,k:Nl,b:wl,a:xl,j:Mc,g:kl,n:Ll,e:Uc,l:Dc,h:Vn,f:Fl,c:Bc,t:$l,s:Wl,i:ql},xf=dc(),Jl=()=>(Jl=Ge.w)(),Ar=f=>(Ar=Ge.x)(f),Fn=f=>(Fn=Ge.y)(f),Fc=f=>(Fc=Ge.A)(f),Xl=e.__embind_initialize_bindings=()=>(Xl=e.__embind_initialize_bindings=Ge.B)(),Ql=()=>(Ql=Ge.__errno_location)(),$c=f=>($c=Ge.C)(f),$n=e.dynCall_jiji=(f,_,I,C,M)=>($n=e.dynCall_jiji=Ge.D)(f,_,I,C,M),hs;ri=function f(){hs||Hc(),hs||(ri=f)};function Hc(){if(ti>0||(nl(),ti>0))return;function f(){hs||(hs=!0,e.calledRun=!0,!_n&&(al(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),z()))}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 Hc(),t.ready}})(),Wg=Dy;var bu=class extends Qr{constructor(t){super(Wg,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 dh=class{constructor(t){this.core=t;this.contextMap=new Map;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 dh.Name}getValidateRule(t){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(t,e){switch(t){case"wasm":return this.core.rtcDectection.isSIMDSupported()?new bu(me(J({},e),{wasmPath:`${this.core.assetsPath}videodec_simd.wasm`})):new Au(me(J({},e),{wasmPath:`${this.core.assetsPath}videodec.wasm`}));case"webCodecs":return new Di;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(me(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(me(J({},t),{createDecoder:this.createDecoder})))}}},Xa=dh;Xa.Name="TRTCVideoDecoder";function Oe(...i){}var Ny=i=>i();function lh(){this.dispose()}var wy=()=>typeof __FASTRX_DEVTOOLS__!="undefined",xy=1,Yr=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new uh(t,this,this.streamId++);return ut.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},Ks=class{constructor(){this.defers=new Set,this.disposed=!1}next(t){}complete(){this.dispose()}error(t){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=Oe,this.error=Oe,this.next=Oe,this.dispose=Oe,this.subscribe=Oe,this.doDefer()}subscribe(t){return t instanceof Yr?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(Ny),this.defers.clear()}defer(t){this.defers.add(t)}removeDefer(t){this.defers.delete(t)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},pe=class extends Ks{constructor(t){super(),this.sink=t,t.defer(this.bindDispose)}next(t){this.sink.next(t)}complete(){this.sink.complete()}error(t){this.sink.error(t)}},vu=class extends Ks{constructor(t,e=Oe,r=Oe,o=Oe){if(super(),this._next=e,this._error=r,this._complete=o,this.then=Oe,t instanceof Yr){let s={toString:()=>"subscribe",id:0,source:t};this.defer(()=>{ut.defer(s,0)}),ut.create(s),ut.pipe(s),this.sourceId=s.id,this.subscribe(t),ut.subscribe({id:s.id,end:!0}),e==Oe?this._next=a=>ut.next(s,0,a):this.next=a=>{ut.next(s,0,a),e(a)},o==Oe?this._complete=()=>ut.complete(s,0):this.complete=()=>{this.dispose(),ut.complete(s,0),o()},r==Oe?this._error=a=>ut.complete(s,0,a):this.error=a=>{this.dispose(),ut.complete(s,0,a),r()}}else this.subscribe(t)}next(t){this._next(t)}complete(){this.dispose(),this._complete()}error(t){this.dispose(),this._error(t)}};function Jt(i,...t){return t.reduce((e,r)=>r(e),i)}function Mr(i,t,e){if(wy()){let r=Object.defineProperties(Object.setPrototypeOf(i,Yr.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:e,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});ut.create(r);for(let o=0;o<e.length;o++){let s=e[o];typeof s=="function"&&s instanceof Yr&&ut.addSource(r,s)}return r}return i}function Te(i,t){return function(...e){return r=>{if(r instanceof Yr){let o=Mr(s=>{let a=new i(s,...e);a.sourceId=o.id,a.subscribe(r)},t,arguments);return o.source=r,ut.pipe(o),o}else return o=>r(new i(o,...e))}}}function Zi(i,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:i,payload:t}})}var uh=class extends pe{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{ut.defer(this.source,this.id)})}next(t){ut.next(this.source,this.id,t),this.sink.next(t)}complete(){ut.complete(this.source,this.id),this.sink.complete()}error(t){ut.complete(this.source,this.id,t),this.sink.error(t)}},ut={addSource(i,t){Zi("addSource",{id:i.id,name:i.toString(),source:{id:t.id,name:t.toString()}})},next(i,t,e){Zi("next",{id:i.id,streamId:t,data:e&&e.toString()})},subscribe({id:i,end:t},e){Zi("subscribe",{id:i,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(i,t,e){Zi("complete",{id:i.id,streamId:t,err:e?e.toString():null})},defer(i,t){Zi("defer",{id:i.id,streamId:t})},pipe(i){Zi("pipe",{name:i.toString(),id:i.id,source:{id:i.source.id,name:i.source.toString()}})},update(i){Zi("update",{id:i.id,name:i.toString()})},create(i){i.id||(i.id=xy++),Zi("create",{name:i.toString(),id:i.id})}},Ru=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var ph=class extends Ks{constructor(t){super(),this.source=t,this.sinks=new Set}add(t){t.defer(()=>this.remove(t)),this.sinks.add(t).size===1&&(this.reset(),this.subscribe(this.source))}remove(t){this.sinks.delete(t),this.sinks.size===0&&this.dispose()}next(t){this.sinks.forEach(e=>e.next(t))}complete(){this.sinks.forEach(t=>t.complete()),this.sinks.clear()}error(t){this.sinks.forEach(e=>e.error(t)),this.sinks.clear()}};function Gg(){return i=>{let t=new ph(i);if(i instanceof Yr){let e=Mr(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=i,ut.pipe(e),e}return Mr(t.add.bind(t),"share",arguments)}}function My(...i){return Mr(t=>{let e=i.length,r=e,o=e,s=new Array(e),a=()=>{--o===0&&t.complete()},d=(h,p)=>{let T=new pe(t);T.next=y=>{--r===0?(T.next=R=>{s[p]=R,t.next(s)},T.next(y)):s[p]=y},T.complete=a,T.subscribe(h)};i.forEach(d)},"combineLatest",arguments)}var mh=class extends pe{constructor(t,...e){super(t);let r=new pe(this.sink);r.next=o=>this.buffer=o,r.complete=Oe,r.subscribe(My(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},tO=Te(mh,"withLatestFrom"),hh=class extends pe{constructor(t,e,r){super(t),this.bufferSize=e,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(t){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach(e=>{e.push(t)}),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(t),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach(t=>this.sink.next(t)),super.complete()}},rO=Te(hh,"bufferCount"),fh=class extends pe{constructor(t,e){super(t),this.buffer=[];let r=new pe(t);r.next=o=>{t.next(this.buffer),this.buffer=[]},r.complete=Oe,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},iO=Te(fh,"buffer");function en(i){let t=arguments,e=Gg()(Mr(r=>{e.next=o=>r.next(o),e.complete=()=>r.complete(),e.error=o=>r.error(o),i&&r.subscribe(i)},"subject",t));return e.next=Oe,e.complete=Oe,e.error=Oe,e}function _h(i,t){return e=>{let r=o=>e.next(o);e.defer(()=>t(r)),i(r)}}function Xt(i,t){if("on"in i)return Mr(_h(e=>i.on(t,e),e=>i.off(t,e)),"fromEvent",arguments);if("addListener"in i)return Mr(_h(e=>i.addListener(t,e),e=>i.removeListener(t,e)),"fromEvent",arguments);if("addEventListener"in i)return Mr(_h(e=>i.addEventListener(t,e),e=>i.removeEventListener(t,e)),"fromEvent",arguments);throw"target is not a EventDispachter"}var gh=class extends pe{constructor(t,e,r){super(t),this.f=e;let o=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=s=>{this.acc=s,this.complete=o,this.resetNext()}:(this.acc=r,this.complete=o)}next(t){this.acc=this.f(this.acc,t)}},Oy=Te(gh,"reduce");var Eh=class extends pe{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},hO=Te(Eh,"filter"),Th=class extends pe{next(t){}},fO=Te(Th,"ignoreElements"),Ih=class extends pe{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&this.complete()}},jg=Te(Ih,"take"),Sh=class extends pe{constructor(t,e){super(t);let r=new pe(t);r.next=()=>t.complete(),r.complete=lh,r.subscribe(e)}},Ki=Te(Sh,"takeUntil"),yh=class extends pe{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):this.complete()}},_O=Te(yh,"takeWhile");var Ah=class extends pe{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},gO=Te(Ah,"skip"),bh=class extends pe{constructor(t,e){super(t),t.next=Oe;let r=new pe(t);r.next=()=>{r.dispose(),t.resetNext()},r.complete=lh,r.subscribe(e)}},EO=Te(bh,"skipUntil"),vh=class extends pe{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},TO=Te(vh,"skipWhile"),Py={leading:!0,trailing:!1},Rh=class extends pe{constructor(t,e,r){super(t),this.durationSelector=e,this.trailing=r}cacheValue(t){this.last=t,this.disposed&&this.throttle(t)}send(t){this.sink.next(t),this.throttle(t)}throttle(t){this.reset(),this.subscribe(this.durationSelector(t))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},Ch=class extends pe{constructor(t,e,r=Py){super(t),this.durationSelector=e,this.config=r,this._throttle=new Rh(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(t){this._throttle.disposed&&this.config.leading?this._throttle.send(t):this._throttle.cacheValue(t)}complete(){this._throttle.throttle=Oe,this._throttle.complete(),super.complete()}},IO=Te(Ch,"throttle");var Dh=class extends pe{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},Nh=class extends pe{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new Dh(this.sink),this._debounce.dispose()}next(t){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=t,this._debounce.subscribe(this.durationSelector(t))}complete(){this._debounce.complete(),super.complete()}},SO=Te(Nh,"debounce");var wh=class extends pe{constructor(t,e,r){super(t),this.count=e,this.defaultValue=r}next(t){this.count--===0&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("not enough elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},yO=Te(wh,"elementAt");var xh=class extends pe{constructor(t,e){super(t),this.f=e,this.i=0}next(t){this.f(t)?(this.sink.next(this.i++),this.complete()):++this.i}},AO=Te(xh,"findIndex"),Mh=class extends pe{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},bO=Te(Mh,"first"),Oh=class extends pe{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t)}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},vO=Te(Oh,"last"),Ph=class extends pe{constructor(t,e){super(t),this.predicate=e,this.index=0}next(t){this.predicate(t,this.index++)?this.result=!0:(this.result=!1,this.complete())}complete(){if(this.result===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.result);super.complete()}},RO=Te(Ph,"every");var kh=class extends pe{constructor(t,e,r){super(t),this.f=e,typeof r=="undefined"?this.next=o=>{this.acc=o,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(t){this.sink.next(this.acc=this.f(this.acc,t))}},wO=Te(kh,"scan"),Lh=class extends pe{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},xO=Te(Lh,"pairwise"),Uh=class extends pe{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},qg=Te(Uh,"map");var tn=class extends pe{constructor(t,e,r){super(t),this.data=e,this.context=r}next(t){let e=this.context.combineResults;e?this.sink.next(e(this.data,t)):this.sink.next(t)}tryComplete(){this.context.resetComplete(),this.dispose()}},rn=class extends pe{constructor(t,e,r){super(t),this.makeSource=e,this.combineResults=r,this.index=0}subInner(t,e){let r=this.currentSink=new e(this.sink,t,this);this.complete=this.tryComplete,r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},Cu=class extends tn{},Du=class extends rn{next(t){this.subInner(t,Cu),this.next=e=>{this.currentSink.dispose(),this.subInner(e,Cu)}}},zg=Te(Du,"switchMap");function Mu(i){return(t,e)=>i(()=>t,e)}var Jg=Mu(Te(Du,"switchMapTo")),Vh=class extends tn{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Nu=class extends rn{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(t){this.next2(t),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),Vh),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},MO=Te(Nu,"concatMap"),OO=Mu(Te(Nu,"concatMapTo")),Bh=class extends tn{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},wu=class extends rn{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Bh),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},PO=Te(wu,"mergeMap"),kO=Mu(Te(wu,"mergeMapTo")),Fh=class extends tn{dispose(){this.context.resetNext(),super.dispose()}},xu=class extends rn{next(t){this.next=Oe,this.subInner(t,Fh)}},LO=Te(xu,"exhaustMap"),UO=Mu(Te(xu,"exhaustMapTo")),$h=class extends pe{constructor(t,e){super(t),this.f=e,this.groups=new Map}next(t){let e=this.f(t),r=this.groups.get(e);typeof r=="undefined"&&(r=en(),r.key=e,this.groups.set(e,r),super.next(r)),r.next(t)}complete(){this.groups.forEach(t=>t.complete()),super.complete()}error(t){this.groups.forEach(e=>e.error(t)),super.error(t)}},VO=Te($h,"groupBy"),Hh=class extends pe{constructor(){super(...arguments),this.start=new Date}next(t){this.sink.next({value:t,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},BO=Te(Hh,"timeInterval"),Wh=class extends pe{constructor(t,e){super(t),this.miniseconds=e,this.buffer=[],this.id=setInterval(()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0},this.miniseconds)}next(t){this.buffer.push(t)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},FO=Te(Wh,"bufferTime"),Gh=class extends pe{constructor(t,e){super(t),this.buffer=[],this.delayTime=e}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(t){this.timeoutId=setTimeout(()=>{let e=this.buffer.shift();if(e){let{time:r,data:o}=e;super.next(o),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(r))}},t)}next(t){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:t})}complete(){this.timeoutId=setTimeout(()=>super.complete(),this.delayTime)}},$O=Te(Gh,"delay"),jh=class extends pe{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},HO=Te(jh,"catchError");var ar=(i=Oe,t=Oe,e=Oe)=>r=>new vu(r,i,t,e),qh=class extends pe{constructor(t,e){super(t),e instanceof Function?this.next=r=>{e(r),t.next(r)}:(e.next&&(this.next=r=>{e.next(r),t.next(r)}),e.complete&&(this.complete=()=>{e.complete(),t.complete()}),e.error&&(this.error=r=>{e.error(r),t.error(r)}))}},Xg=Te(qh,"tap"),zh=class extends pe{constructor(t,e){super(t),this.timeout=e,this.id=setTimeout(()=>this.error(new Ru(this.timeout)),this.timeout)}next(t){super.next(t),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},jO=Te(zh,"timeout");function Yg(i,t=!1){let e=Object.defineProperties(en(),{postMessage:{value:i.postMessage.bind(i)},port:{get(){return i},set(o){i.onmessage=Oe,i.onmessageerror=Oe,i=o,r()}}});function r(){i.onmessage=o=>{o.data?o.ports.length||t?e.next(o):e.next(o.data):(e.complete(),i.close())},i.onmessageerror=o=>{e.error(o),i.close()}}return r(),e}var Jh=class extends pe{constructor(t,e){super(t);let r=new pe(t);r.next=Oe,e(r)}},aP=Te(Jh,"takeUntilComplete");var cr={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},Qh="__INLINE__WORKER__",Qg="__INLINE__WASM__",{debug:Zg}=console;cr.debug||(console.debug=()=>{});var Kg=cr.assetsPath?`${cr.assetsPath}/`:"",Xh=!Qh.startsWith("__"),on=`${Kg}worker.js`,eE=Xh||on.startsWith("http")?URL.createObjectURL(new Blob([Xh?atob(Qh):`importScripts('${on}')`])):on,Qa=Xh?URL.createObjectURL(new Blob([atob(Qh)],{type:"application/javascript"})):on.startsWith("http")?fetch(on).then(i=>i.blob().then(t=>URL.createObjectURL(t))):on,Ou=Qg.startsWith("__")?`${Kg}av_processing.wasm`:`data:application/octet-stream;base64,${Qg}`;var Yh=class{constructor(){this.playPortSent=!1;Jt(Xt(document,"mousedown"),jg(1),ar(()=>this.resume().catch(t=>{console.error("audio worklet init failed:",t)}))),this.workletPromise=this.init()}resume(){return v(this,null,function*(){if(this.audioCtx){this.audioCtx.resume();return}})}init(){return v(this,null,function*(){this.audioCtx=new AudioContext({sampleRate:48e3}),V.info("AudioContext Created:",this.audioCtx,Qa),yield this.audioCtx.audioWorklet.addModule(typeof Qa=="string"?Qa:yield Qa);let t=yield fetch(Ou).then(e=>e.arrayBuffer());return this.worklet=new AudioWorkletNode(this.audioCtx,"global-audio-player",{processorOptions:{wasm:t,flag:cr},numberOfInputs:2}),V.info("worklet created",this.audioCtx.state),this.worklet.connect(this.audioCtx.destination),this.playPort=this.worklet.port,this.playPort})}playAudio(t){return v(this,null,function*(){this.playPortSent||(this.playPortSent=!0,t(yield this.workletPromise))})}},eo=new Yh;var yE=Pi(Hi());function Zh({timesInSecond:i,maxSizeInSecond:t,getSize:e}){return Ce((r,o)=>{let s=new WeakMap;return B.on(O.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 de({code:Y.INVALID_OPERATION,message:ot({key:it.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 ky="2025-02-11 15:50:53",tE=!0,rE=function(){var i;tE&&(tE=!1,V.getLogLevel()!==5&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info(`* API Document: ${Fr}/en/index.html`),console.info(`* Changelog: ${Fr}/en/tutorial-01-info-changelog.html`),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),V.info("TRTC Web SDK Version:",Ke),wr||V.debug("Build Time:",ky),V.info("UA:",navigator.userAgent),V.info(`URL: ${location.href}${((i=self.frameElement)==null?void 0:i.tagName)==="IFRAME"?" in iframe":""}`),Ea().then(t=>{t&&V.info(Rr)}))};var gr={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 ne={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},Or=(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))(Or||{});function oE({code:i,params:t,enableDocLink:e=!1}){let r="",o,s=Or[i];try{o=iE[s]}catch(a){o=iE.UNKNOWN_ERROR}return Ve(o)?r=o(t):Ae(o)&&(r=o),t.fnName&&!r.includes(t.fnName)&&(r[r.length-1]!=="."&&(r+="."),r+=` thrown from ${t.fnName}()`),e&&(r+=" doc:"),r}var iE=me(J({},Gt),{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: ${mt(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: ${mt(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=zo(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=zo(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=zo(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=zo(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=zo(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=zo(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=zo(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 zo(i){if(!i)return"camera";let t=i.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var Jo=class extends Error{constructor({code:e,extraCode:r,message:o="",messageParams:s,fnName:a="",originError:d}){var p;let h;o?h=o:h=oE({code:e===ne.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=Or[e],this.code=e,this.extraCode=r,this.functionName=a,this.originError=d,this.message=h,this.extraCode===5302&&((p=this.originError)==null?void 0:p.message.includes("system"))&&(this.handler=()=>{let T={startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"},y={startLocalVideo:"webcam",startLocalAudio:"microphone"},R=document.createElement("a");Ao?R.href=`ms-settings:privacy-${y[this.functionName]}`:Nr&&(R.href=`x-apple.systempreferences:com.apple.preference.security?Privacy_${T[this.functionName]}`),R.href.length>0&&R.click()})}static convertFrom(e,r,o){let s=e;if(e instanceof de){let{stack:a}=e,d={code:ne.UNKNOWN_ERROR,fnName:r,originError:e};switch(e.getCode()){case Y.INVALID_PARAMETER:d.code=ne.INVALID_PARAMETER,d.message=e.message;break;case Y.INVALID_OPERATION:d.code=ne.INVALID_OPERATION;break;case Y.NOT_SUPPORTED:case Y.NOT_SUPPORTED_H264:d.code=ne.ENV_NOT_SUPPORTED,e.getCode()===Y.NOT_SUPPORTED_H264&&(d.extraCode=e.message.includes(Gt.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=ne.SERVER_ERROR,d.extraCode=e.getExtraCode();break;case Y.API_CALL_ABORTED:d.code=ne.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=Ly(e.name));break;case Y.UNKNOWN:break;default:d.code=ne.OPERATION_FAILED}s=new Jo(d),a&&(s.stack+=a.substr(a.indexOf(`
|
|
89
|
+
`,G.push(ye);var ke=vc(Function,G).apply(null,U);return $=Vl(ke),Vc[M]=$,$}var Fl=()=>{Ni("")},Bc;Bc=()=>performance.now();var $l=(f,_,I)=>Pe.copyWithin(f,_,_+I),Hl=f=>{Ni("OOM")},Wl=f=>{var _=Pe.length;f>>>=0,Hl(f)},Gl=[null,[],[]],jl=(f,_)=>{var I=Gl[f];_===0||_===10?((f===1?Vt:Xe)(ci(I,0)),I.length=0):I.push(_)},Bn={varargs:void 0,get(){Bn.varargs+=4;var f=Yt[Bn.varargs-4>>2];return f},getStr(f){var _=xc(f);return _}},ql=(f,_,I,C)=>{for(var M=0,$=0;$<I;$++){var G=P[_>>2],U=P[_+4>>2];_+=8;for(var ee=0;ee<U;ee++)jl(f,Pe[G+ee]);M+=U}return P[C>>2]=M,0};ml(),yt=e.BindingError=class extends Error{constructor(_){super(_),this.name="BindingError"}},oi=e.InternalError=class extends Error{constructor(_){super(_),this.name="InternalError"}},uo(),Dn(),po(),Ac=e.UnboundTypeError=Sl(Error,"UnboundTypeError"),bl(),Rl();var zl={o:bn,r:pl,m:hl,q:yl,p:Pn,d:Rc,u:Cl,k:Nl,b:wl,a:xl,j:Mc,g:kl,n:Ll,e:Uc,l:Dc,h:Vn,f:Fl,c:Bc,t:$l,s:Wl,i:ql},xf=dc(),Jl=()=>(Jl=Ge.w)(),Ar=f=>(Ar=Ge.x)(f),Fn=f=>(Fn=Ge.y)(f),Fc=f=>(Fc=Ge.A)(f),Xl=e.__embind_initialize_bindings=()=>(Xl=e.__embind_initialize_bindings=Ge.B)(),Ql=()=>(Ql=Ge.__errno_location)(),$c=f=>($c=Ge.C)(f),$n=e.dynCall_jiji=(f,_,I,C,M)=>($n=e.dynCall_jiji=Ge.D)(f,_,I,C,M),hs;ri=function f(){hs||Hc(),hs||(ri=f)};function Hc(){if(ti>0||(nl(),ti>0))return;function f(){hs||(hs=!0,e.calledRun=!0,!_n&&(al(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),z()))}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 Hc(),t.ready}})(),Wg=Dy;var bu=class extends Qr{constructor(t){super(Wg,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 dh=class{constructor(t){this.core=t;this.contextMap=new Map;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 dh.Name}getValidateRule(t){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(t,e){switch(t){case"wasm":return this.core.rtcDectection.isSIMDSupported()?new bu(me(J({},e),{wasmPath:`${this.core.assetsPath}videodec_simd.wasm`})):new Au(me(J({},e),{wasmPath:`${this.core.assetsPath}videodec.wasm`}));case"webCodecs":return new Di;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(me(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(me(J({},t),{createDecoder:this.createDecoder})))}}},Xa=dh;Xa.Name="TRTCVideoDecoder";function Oe(...i){}var Ny=i=>i();function lh(){this.dispose()}var wy=()=>typeof __FASTRX_DEVTOOLS__!="undefined",xy=1,Yr=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new uh(t,this,this.streamId++);return ut.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},Ks=class{constructor(){this.defers=new Set,this.disposed=!1}next(t){}complete(){this.dispose()}error(t){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=Oe,this.error=Oe,this.next=Oe,this.dispose=Oe,this.subscribe=Oe,this.doDefer()}subscribe(t){return t instanceof Yr?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(Ny),this.defers.clear()}defer(t){this.defers.add(t)}removeDefer(t){this.defers.delete(t)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},pe=class extends Ks{constructor(t){super(),this.sink=t,t.defer(this.bindDispose)}next(t){this.sink.next(t)}complete(){this.sink.complete()}error(t){this.sink.error(t)}},vu=class extends Ks{constructor(t,e=Oe,r=Oe,o=Oe){if(super(),this._next=e,this._error=r,this._complete=o,this.then=Oe,t instanceof Yr){let s={toString:()=>"subscribe",id:0,source:t};this.defer(()=>{ut.defer(s,0)}),ut.create(s),ut.pipe(s),this.sourceId=s.id,this.subscribe(t),ut.subscribe({id:s.id,end:!0}),e==Oe?this._next=a=>ut.next(s,0,a):this.next=a=>{ut.next(s,0,a),e(a)},o==Oe?this._complete=()=>ut.complete(s,0):this.complete=()=>{this.dispose(),ut.complete(s,0),o()},r==Oe?this._error=a=>ut.complete(s,0,a):this.error=a=>{this.dispose(),ut.complete(s,0,a),r()}}else this.subscribe(t)}next(t){this._next(t)}complete(){this.dispose(),this._complete()}error(t){this.dispose(),this._error(t)}};function Jt(i,...t){return t.reduce((e,r)=>r(e),i)}function Mr(i,t,e){if(wy()){let r=Object.defineProperties(Object.setPrototypeOf(i,Yr.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:e,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});ut.create(r);for(let o=0;o<e.length;o++){let s=e[o];typeof s=="function"&&s instanceof Yr&&ut.addSource(r,s)}return r}return i}function Te(i,t){return function(...e){return r=>{if(r instanceof Yr){let o=Mr(s=>{let a=new i(s,...e);a.sourceId=o.id,a.subscribe(r)},t,arguments);return o.source=r,ut.pipe(o),o}else return o=>r(new i(o,...e))}}}function Zi(i,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:i,payload:t}})}var uh=class extends pe{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{ut.defer(this.source,this.id)})}next(t){ut.next(this.source,this.id,t),this.sink.next(t)}complete(){ut.complete(this.source,this.id),this.sink.complete()}error(t){ut.complete(this.source,this.id,t),this.sink.error(t)}},ut={addSource(i,t){Zi("addSource",{id:i.id,name:i.toString(),source:{id:t.id,name:t.toString()}})},next(i,t,e){Zi("next",{id:i.id,streamId:t,data:e&&e.toString()})},subscribe({id:i,end:t},e){Zi("subscribe",{id:i,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(i,t,e){Zi("complete",{id:i.id,streamId:t,err:e?e.toString():null})},defer(i,t){Zi("defer",{id:i.id,streamId:t})},pipe(i){Zi("pipe",{name:i.toString(),id:i.id,source:{id:i.source.id,name:i.source.toString()}})},update(i){Zi("update",{id:i.id,name:i.toString()})},create(i){i.id||(i.id=xy++),Zi("create",{name:i.toString(),id:i.id})}},Ru=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var ph=class extends Ks{constructor(t){super(),this.source=t,this.sinks=new Set}add(t){t.defer(()=>this.remove(t)),this.sinks.add(t).size===1&&(this.reset(),this.subscribe(this.source))}remove(t){this.sinks.delete(t),this.sinks.size===0&&this.dispose()}next(t){this.sinks.forEach(e=>e.next(t))}complete(){this.sinks.forEach(t=>t.complete()),this.sinks.clear()}error(t){this.sinks.forEach(e=>e.error(t)),this.sinks.clear()}};function Gg(){return i=>{let t=new ph(i);if(i instanceof Yr){let e=Mr(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=i,ut.pipe(e),e}return Mr(t.add.bind(t),"share",arguments)}}function My(...i){return Mr(t=>{let e=i.length,r=e,o=e,s=new Array(e),a=()=>{--o===0&&t.complete()},d=(h,p)=>{let T=new pe(t);T.next=y=>{--r===0?(T.next=R=>{s[p]=R,t.next(s)},T.next(y)):s[p]=y},T.complete=a,T.subscribe(h)};i.forEach(d)},"combineLatest",arguments)}var mh=class extends pe{constructor(t,...e){super(t);let r=new pe(this.sink);r.next=o=>this.buffer=o,r.complete=Oe,r.subscribe(My(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},tO=Te(mh,"withLatestFrom"),hh=class extends pe{constructor(t,e,r){super(t),this.bufferSize=e,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(t){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach(e=>{e.push(t)}),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(t),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach(t=>this.sink.next(t)),super.complete()}},rO=Te(hh,"bufferCount"),fh=class extends pe{constructor(t,e){super(t),this.buffer=[];let r=new pe(t);r.next=o=>{t.next(this.buffer),this.buffer=[]},r.complete=Oe,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},iO=Te(fh,"buffer");function en(i){let t=arguments,e=Gg()(Mr(r=>{e.next=o=>r.next(o),e.complete=()=>r.complete(),e.error=o=>r.error(o),i&&r.subscribe(i)},"subject",t));return e.next=Oe,e.complete=Oe,e.error=Oe,e}function _h(i,t){return e=>{let r=o=>e.next(o);e.defer(()=>t(r)),i(r)}}function Xt(i,t){if("on"in i)return Mr(_h(e=>i.on(t,e),e=>i.off(t,e)),"fromEvent",arguments);if("addListener"in i)return Mr(_h(e=>i.addListener(t,e),e=>i.removeListener(t,e)),"fromEvent",arguments);if("addEventListener"in i)return Mr(_h(e=>i.addEventListener(t,e),e=>i.removeEventListener(t,e)),"fromEvent",arguments);throw"target is not a EventDispachter"}var gh=class extends pe{constructor(t,e,r){super(t),this.f=e;let o=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=s=>{this.acc=s,this.complete=o,this.resetNext()}:(this.acc=r,this.complete=o)}next(t){this.acc=this.f(this.acc,t)}},Oy=Te(gh,"reduce");var Eh=class extends pe{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},hO=Te(Eh,"filter"),Th=class extends pe{next(t){}},fO=Te(Th,"ignoreElements"),Ih=class extends pe{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&this.complete()}},jg=Te(Ih,"take"),Sh=class extends pe{constructor(t,e){super(t);let r=new pe(t);r.next=()=>t.complete(),r.complete=lh,r.subscribe(e)}},Ki=Te(Sh,"takeUntil"),yh=class extends pe{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):this.complete()}},_O=Te(yh,"takeWhile");var Ah=class extends pe{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},gO=Te(Ah,"skip"),bh=class extends pe{constructor(t,e){super(t),t.next=Oe;let r=new pe(t);r.next=()=>{r.dispose(),t.resetNext()},r.complete=lh,r.subscribe(e)}},EO=Te(bh,"skipUntil"),vh=class extends pe{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},TO=Te(vh,"skipWhile"),Py={leading:!0,trailing:!1},Rh=class extends pe{constructor(t,e,r){super(t),this.durationSelector=e,this.trailing=r}cacheValue(t){this.last=t,this.disposed&&this.throttle(t)}send(t){this.sink.next(t),this.throttle(t)}throttle(t){this.reset(),this.subscribe(this.durationSelector(t))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},Ch=class extends pe{constructor(t,e,r=Py){super(t),this.durationSelector=e,this.config=r,this._throttle=new Rh(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(t){this._throttle.disposed&&this.config.leading?this._throttle.send(t):this._throttle.cacheValue(t)}complete(){this._throttle.throttle=Oe,this._throttle.complete(),super.complete()}},IO=Te(Ch,"throttle");var Dh=class extends pe{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},Nh=class extends pe{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new Dh(this.sink),this._debounce.dispose()}next(t){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=t,this._debounce.subscribe(this.durationSelector(t))}complete(){this._debounce.complete(),super.complete()}},SO=Te(Nh,"debounce");var wh=class extends pe{constructor(t,e,r){super(t),this.count=e,this.defaultValue=r}next(t){this.count--===0&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("not enough elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},yO=Te(wh,"elementAt");var xh=class extends pe{constructor(t,e){super(t),this.f=e,this.i=0}next(t){this.f(t)?(this.sink.next(this.i++),this.complete()):++this.i}},AO=Te(xh,"findIndex"),Mh=class extends pe{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t,this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},bO=Te(Mh,"first"),Oh=class extends pe{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t)}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},vO=Te(Oh,"last"),Ph=class extends pe{constructor(t,e){super(t),this.predicate=e,this.index=0}next(t){this.predicate(t,this.index++)?this.result=!0:(this.result=!1,this.complete())}complete(){if(this.result===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.result);super.complete()}},RO=Te(Ph,"every");var kh=class extends pe{constructor(t,e,r){super(t),this.f=e,typeof r=="undefined"?this.next=o=>{this.acc=o,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(t){this.sink.next(this.acc=this.f(this.acc,t))}},wO=Te(kh,"scan"),Lh=class extends pe{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},xO=Te(Lh,"pairwise"),Uh=class extends pe{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},qg=Te(Uh,"map");var tn=class extends pe{constructor(t,e,r){super(t),this.data=e,this.context=r}next(t){let e=this.context.combineResults;e?this.sink.next(e(this.data,t)):this.sink.next(t)}tryComplete(){this.context.resetComplete(),this.dispose()}},rn=class extends pe{constructor(t,e,r){super(t),this.makeSource=e,this.combineResults=r,this.index=0}subInner(t,e){let r=this.currentSink=new e(this.sink,t,this);this.complete=this.tryComplete,r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},Cu=class extends tn{},Du=class extends rn{next(t){this.subInner(t,Cu),this.next=e=>{this.currentSink.dispose(),this.subInner(e,Cu)}}},zg=Te(Du,"switchMap");function Mu(i){return(t,e)=>i(()=>t,e)}var Jg=Mu(Te(Du,"switchMapTo")),Vh=class extends tn{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Nu=class extends rn{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(t){this.next2(t),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),Vh),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},MO=Te(Nu,"concatMap"),OO=Mu(Te(Nu,"concatMapTo")),Bh=class extends tn{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},wu=class extends rn{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Bh),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},PO=Te(wu,"mergeMap"),kO=Mu(Te(wu,"mergeMapTo")),Fh=class extends tn{dispose(){this.context.resetNext(),super.dispose()}},xu=class extends rn{next(t){this.next=Oe,this.subInner(t,Fh)}},LO=Te(xu,"exhaustMap"),UO=Mu(Te(xu,"exhaustMapTo")),$h=class extends pe{constructor(t,e){super(t),this.f=e,this.groups=new Map}next(t){let e=this.f(t),r=this.groups.get(e);typeof r=="undefined"&&(r=en(),r.key=e,this.groups.set(e,r),super.next(r)),r.next(t)}complete(){this.groups.forEach(t=>t.complete()),super.complete()}error(t){this.groups.forEach(e=>e.error(t)),super.error(t)}},VO=Te($h,"groupBy"),Hh=class extends pe{constructor(){super(...arguments),this.start=new Date}next(t){this.sink.next({value:t,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},BO=Te(Hh,"timeInterval"),Wh=class extends pe{constructor(t,e){super(t),this.miniseconds=e,this.buffer=[],this.id=setInterval(()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0},this.miniseconds)}next(t){this.buffer.push(t)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},FO=Te(Wh,"bufferTime"),Gh=class extends pe{constructor(t,e){super(t),this.buffer=[],this.delayTime=e}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(t){this.timeoutId=setTimeout(()=>{let e=this.buffer.shift();if(e){let{time:r,data:o}=e;super.next(o),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(r))}},t)}next(t){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:t})}complete(){this.timeoutId=setTimeout(()=>super.complete(),this.delayTime)}},$O=Te(Gh,"delay"),jh=class extends pe{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},HO=Te(jh,"catchError");var ar=(i=Oe,t=Oe,e=Oe)=>r=>new vu(r,i,t,e),qh=class extends pe{constructor(t,e){super(t),e instanceof Function?this.next=r=>{e(r),t.next(r)}:(e.next&&(this.next=r=>{e.next(r),t.next(r)}),e.complete&&(this.complete=()=>{e.complete(),t.complete()}),e.error&&(this.error=r=>{e.error(r),t.error(r)}))}},Xg=Te(qh,"tap"),zh=class extends pe{constructor(t,e){super(t),this.timeout=e,this.id=setTimeout(()=>this.error(new Ru(this.timeout)),this.timeout)}next(t){super.next(t),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},jO=Te(zh,"timeout");function Yg(i,t=!1){let e=Object.defineProperties(en(),{postMessage:{value:i.postMessage.bind(i)},port:{get(){return i},set(o){i.onmessage=Oe,i.onmessageerror=Oe,i=o,r()}}});function r(){i.onmessage=o=>{o.data?o.ports.length||t?e.next(o):e.next(o.data):(e.complete(),i.close())},i.onmessageerror=o=>{e.error(o),i.close()}}return r(),e}var Jh=class extends pe{constructor(t,e){super(t);let r=new pe(t);r.next=Oe,e(r)}},aP=Te(Jh,"takeUntilComplete");var cr={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},Qh="__INLINE__WORKER__",Qg="__INLINE__WASM__",{debug:Zg}=console;cr.debug||(console.debug=()=>{});var Kg=cr.assetsPath?`${cr.assetsPath}/`:"",Xh=!Qh.startsWith("__"),on=`${Kg}worker.js`,eE=Xh||on.startsWith("http")?URL.createObjectURL(new Blob([Xh?atob(Qh):`importScripts('${on}')`])):on,Qa=Xh?URL.createObjectURL(new Blob([atob(Qh)],{type:"application/javascript"})):on.startsWith("http")?fetch(on).then(i=>i.blob().then(t=>URL.createObjectURL(t))):on,Ou=Qg.startsWith("__")?`${Kg}av_processing.wasm`:`data:application/octet-stream;base64,${Qg}`;var Yh=class{constructor(){this.playPortSent=!1;Jt(Xt(document,"mousedown"),jg(1),ar(()=>this.resume().catch(t=>{console.error("audio worklet init failed:",t)}))),this.workletPromise=this.init()}resume(){return v(this,null,function*(){if(this.audioCtx){this.audioCtx.resume();return}})}init(){return v(this,null,function*(){this.audioCtx=new AudioContext({sampleRate:48e3}),V.info("AudioContext Created:",this.audioCtx,Qa),yield this.audioCtx.audioWorklet.addModule(typeof Qa=="string"?Qa:yield Qa);let t=yield fetch(Ou).then(e=>e.arrayBuffer());return this.worklet=new AudioWorkletNode(this.audioCtx,"global-audio-player",{processorOptions:{wasm:t,flag:cr},numberOfInputs:2}),V.info("worklet created",this.audioCtx.state),this.worklet.connect(this.audioCtx.destination),this.playPort=this.worklet.port,this.playPort})}playAudio(t){return v(this,null,function*(){this.playPortSent||(this.playPortSent=!0,t(yield this.workletPromise))})}},eo=new Yh;var yE=Pi(Hi());function Zh({timesInSecond:i,maxSizeInSecond:t,getSize:e}){return Ce((r,o)=>{let s=new WeakMap;return B.on(O.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 de({code:Y.INVALID_OPERATION,message:ot({key:it.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 ky="2025-02-12 09:04:57",tE=!0,rE=function(){var i;tE&&(tE=!1,V.getLogLevel()!==5&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info(`* API Document: ${Fr}/en/index.html`),console.info(`* Changelog: ${Fr}/en/tutorial-01-info-changelog.html`),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),V.info("TRTC Web SDK Version:",Ke),wr||V.debug("Build Time:",ky),V.info("UA:",navigator.userAgent),V.info(`URL: ${location.href}${((i=self.frameElement)==null?void 0:i.tagName)==="IFRAME"?" in iframe":""}`),Ea().then(t=>{t&&V.info(Rr)}))};var gr={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 ne={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},Or=(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))(Or||{});function oE({code:i,params:t,enableDocLink:e=!1}){let r="",o,s=Or[i];try{o=iE[s]}catch(a){o=iE.UNKNOWN_ERROR}return Ve(o)?r=o(t):Ae(o)&&(r=o),t.fnName&&!r.includes(t.fnName)&&(r[r.length-1]!=="."&&(r+="."),r+=` thrown from ${t.fnName}()`),e&&(r+=" doc:"),r}var iE=me(J({},Gt),{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: ${mt(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: ${mt(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=zo(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=zo(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=zo(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=zo(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=zo(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=zo(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=zo(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 zo(i){if(!i)return"camera";let t=i.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var Jo=class extends Error{constructor({code:e,extraCode:r,message:o="",messageParams:s,fnName:a="",originError:d}){var p;let h;o?h=o:h=oE({code:e===ne.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=Or[e],this.code=e,this.extraCode=r,this.functionName=a,this.originError=d,this.message=h,this.extraCode===5302&&((p=this.originError)==null?void 0:p.message.includes("system"))&&(this.handler=()=>{let T={startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"},y={startLocalVideo:"webcam",startLocalAudio:"microphone"},R=document.createElement("a");Ao?R.href=`ms-settings:privacy-${y[this.functionName]}`:Nr&&(R.href=`x-apple.systempreferences:com.apple.preference.security?Privacy_${T[this.functionName]}`),R.href.length>0&&R.click()})}static convertFrom(e,r,o){let s=e;if(e instanceof de){let{stack:a}=e,d={code:ne.UNKNOWN_ERROR,fnName:r,originError:e};switch(e.getCode()){case Y.INVALID_PARAMETER:d.code=ne.INVALID_PARAMETER,d.message=e.message;break;case Y.INVALID_OPERATION:d.code=ne.INVALID_OPERATION;break;case Y.NOT_SUPPORTED:case Y.NOT_SUPPORTED_H264:d.code=ne.ENV_NOT_SUPPORTED,e.getCode()===Y.NOT_SUPPORTED_H264&&(d.extraCode=e.message.includes(Gt.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=ne.SERVER_ERROR,d.extraCode=e.getExtraCode();break;case Y.API_CALL_ABORTED:d.code=ne.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=Ly(e.name));break;case Y.UNKNOWN:break;default:d.code=ne.OPERATION_FAILED}s=new Jo(d),a&&(s.stack+=a.substr(a.indexOf(`
|
|
90
90
|
`)))}else{if(e instanceof Jo)return e;s=new Jo({code:ne.UNKNOWN_ERROR,fnName:r,originError:e})}return s}};function Ly(i){let t;switch(i){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}var oe=Jo;var sE={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}}},nE={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}}},sn={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(i,t,e){if(Ae(i)&&!document.getElementById(i))throw new oe({code:ne.INVALID_PARAMETER,extraCode:5009,fnName:e,messageParams:{key:t}})}},aE={name:"userId",required:!0,type:"string"},cE={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[gr.AUDIO_PROFILE_STANDARD,gr.AUDIO_PROFILE_STANDARD_STEREO,gr.AUDIO_PROFILE_HIGH,gr.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function Ya(i,t){if(!i)throw new oe({code:ne.INVALID_OPERATION,extraCode:5101,fnName:t})}function dE(i,t,e){if(!i)throw new oe({code:ne.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:e}})}var nk={type:"number",notLessThanZero:!0},Uy={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:ne.INVALID_OPERATION,extraCode:5104,fnName:e});if(i.roomId){if(Ae(i.roomId))throw new oe({code:ne.INVALID_PARAMETER,extraCode:5016,fnName:e,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(i.roomId))&&i.roomId<4294967295))throw new oe({code:ne.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:ne.INVALID_PARAMETER,extraCode:5012,fnName:e,messageParams:{key:t}})}else throw new oe({code:ne.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:sn,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:sE},validate(i){var t;if(!((t=i==null?void 0:i.option)!=null&&t.videoTrack)&&Ai())throw new oe({code:ne.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:me(J({},sn),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:sE}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:cE},validate(i){var t;if(!((t=i==null?void 0:i.option)!=null&&t.audioTrack)&&Ai())throw new oe({code:ne.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:cE}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:sn,publish:{type:"boolean"},option:nE},validate(i,t,e,r,o){var s;if(!((s=i==null?void 0:i.option)!=null&&s.videoTrack)&&Ai())throw new oe({code:ne.ENV_NOT_SUPPORTED,extraCode:5201});if(!Da())throw new oe({code:ne.ENV_NOT_SUPPORTED,fnName:e,extraCode:5205})}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:sn,publish:{type:"boolean"},option:nE}},muteRemoteAudio:[aE,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[aE,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:sn,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){Ya(this._room.isJoined,e);let r=this._room.remotePublishedUserMap.get(i.userId);if(dE(!!r,e,i),r&&(i.streamType==="main"&&!r.muteState.videoAvailable||i.streamType==="sub"&&!r.muteState.hasAuxiliary))throw new oe({code:ne.INVALID_OPERATION,extraCode:5103,fnName:e,messageParams:{value:i}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:me(J({},sn),{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){Ya(this._room.isJoined,e);let r=this._room.remotePublishedUserMap.get(i.userId);if(dE(!!r,e,i),r&&(i.streamType==="main"&&!r.muteState.videoAvailable||i.streamType==="sub"&&!r.muteState.hasAuxiliary))throw new oe({code:ne.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:ne.INVALID_PARAMETER,extraCode:5014,fnName:e})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(i,t,e){Ya(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(!Ma)throw new oe({code:ne.ENV_NOT_SUPPORTED,fnName:e,extraCode:5207});if(!this._room.enableSEI)throw new oe({code:ne.INVALID_OPERATION,fnName:e,extraCode:5108});if(i.byteLength>1e3)throw new oe({code:ne.INVALID_PARAMETER,extraCode:5018,fnName:e});if(i.byteLength===0)throw new oe({code:ne.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:e});Ya(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:ne.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:ne.INVALID_PARAMETER,extraCode:5018,fnName:e});if(i.byteLength===0)throw new oe({code:ne.INVALID_PARAMETER,extraCode:5017,fnName:e,messageParams:{key:t}})}}},validate(i,t,e){if(Ya(this._room.isJoined,e),this._room.scene==="live"&&this._room.role==="audience")throw new oe({code:ne.INVALID_OPERATION,extraCode:5107,fnName:e,messageParams:{key:t}})}}},Tt={TRTC:Uy};var Ct=class extends Error{};function Vy(i,t){let e=Io(i);for(let r=0;r<t.length;r++)Wr(e[r],t[r]);return e}function By(i){this._resolve=Promise.resolve(i)}function Fy(i){this._reject=Promise.reject(i)}var Xo=class{constructor(t,e){this.instance=t;this.group=e;this.started=!1;this.ops=[];this.startSame=()=>!0;this.mergeUpdate=Vy;let r=Xo.instances.get(t);r?r.set(e,this):Xo.instances.set(t,new Map([[e,this]]))}static get(t,e){if(!e)return;let r=Xo.instances.get(t);return r&&r.get(e)||new Xo(t,e)}static gets(t,e){let r=Xo.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,p;throw this.ops.shift(),t===0&&((h=this.currentOp)==null?void 0:h.type)===2&&this.ops.shift().reject(new Ct("start failed")),(p=this.currentOp)==null||p.action(),d},a={type:t,action:()=>e(...a.args).then(o,s),args:r,resolve:By,reject:Fy};try{switch(this.state){case 1:if(t===0)throw new Ct("already started");break;case 4:if(t===2)throw new Ct("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 Ct("already start");break;case 3:switch(t.type){case 2:throw new Ct("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new Ct("unknown state")}else switch(t.type){case 3:switch(this.lastOpType){case 3:return this.lastOp.promise;default:let r=new Ct("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 Ct("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new Ct("start not allowed after update");case 0:throw new Ct("duplicate start");case 3:if(this.startSame(this.currentOp.args,t.args))throw this.ops.pop().reject(new Ct("keep start")),new Ct("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}},Zr=Xo;Zr.instances=new WeakMap;var Pu=new WeakMap,ku=(i,t)=>{if(t instanceof Ct){let{stack:e}=t;t=new oe({code:ne.OPERATION_ABORT,message:`${i} abort: ${t.message}`,fnName:i}),e&&(t.stack+=e.substr(e.indexOf(`
|
|
91
91
|
`)))}throw t};function to(i,t){return Ce((e,r)=>function(...o){let s=Zr.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(ku.bind(null,r))):e.apply(this,o)})}function Qo(i,t){let{merge:e,debounce:r}=t||{};return Ce((o,s)=>function(...a){let d=Zr.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:p}=r;return new Promise((T,y)=>{var j,W;let R=(j=Pu.get(this))==null?void 0:j.get(p(...a));if(R){let{timeoutId:F,resolve:Ie}=R;clearTimeout(F),Ie()}let N=setTimeout(()=>{if(d.state===3||d.state===4)return T();d.action(2,o.bind(this),a).catch(ku.bind(null,s)).then(T,y)},h);Pu.has(this)?(W=Pu.get(this))==null||W.set(p(...a),{timeoutId:N,resolve:T}):Pu.set(this,new Map([[p(...a),{timeoutId:N,resolve:T}]]))})}return d.action(2,o.bind(this),a).catch(ku.bind(null,s))})}function ro(i){return Ce((t,e)=>function(...r){let o=typeof i=="function"?i.call(this,...r):i;if(o instanceof RegExp)return Promise.all(Zr.gets(this,o).map(a=>a.action(3,()=>Promise.resolve(),r))).then(()=>t.call(this,...r));let s=Zr.get(this,o);return s?s.action(3,t.bind(this),r).catch(ku.bind(null,e)):t.apply(this,r)})}var re={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"},uE=new Set([re.ERROR,re.AUTOPLAY_FAILED,re.KICKED_OUT,re.REMOTE_USER_ENTER,re.REMOTE_USER_EXIT,re.REMOTE_AUDIO_AVAILABLE,re.REMOTE_AUDIO_UNAVAILABLE,re.REMOTE_VIDEO_AVAILABLE,re.REMOTE_VIDEO_UNAVAILABLE,re.CONNECTION_STATE_CHANGED,re.PUBLISH_STATE_CHANGED,re.SCREEN_SHARE_STOPPED,re.DEVICE_CHANGED]);function Za(i){return i==="sub"?"auxiliary":i==="auxiliary"?"sub":"main"}function Ka(i){return i===gr.QOS_PREFERENCE_CLEAR?"detail":i===gr.QOS_PREFERENCE_SMOOTH?"motion":""}var ef={};li(ef,{bytes2ms:()=>Yf,convertObjectNumberToInt:()=>oa,copyProperties:()=>Qf,deepClone:()=>Io,deepMerge:()=>Wr,delay:()=>sa,fibonacci:()=>So,formatedTime:()=>cd,getConstructorName:()=>ra,getContainerFromElement:()=>s_,getEnv:()=>zf,getInternalVersion:()=>i_,getLoggerUrl:()=>fi,getMuteStateFromFlag:()=>ia,getNetworkType:()=>ea,getNumNetworkType:()=>sd,getReconnectionTimeout:()=>Kf,getStringByteLength:()=>n_,getTurnServer:()=>o_,getUint32Version:()=>ld,getValueType:()=>mt,getViewListFromView:()=>ys,glog:()=>ta,ipv4ToUint32:()=>Ss,isArray:()=>rt,isAudioWorkletSupported:()=>r_,isBoolean:()=>nt,isConstructor:()=>Is,isEmpty:()=>ad,isFunction:()=>Ve,isLangChinese:()=>vr,isMediaStreamTrack:()=>e_,isNumber:()=>Fe,isObject:()=>lr,isOverseaSdkAppId:()=>Kn,isPlainObject:()=>Ft,isPortrait:()=>ud,isPromise:()=>Li,isRemoteTrack:()=>t_,isString:()=>Ae,isUndefined:()=>L,loadImage:()=>As,ms2bytes:()=>Zf,ms2samples:()=>hp,performanceNow:()=>ge,promiseAny:()=>nd,samples2ms:()=>mp,setNetworkType:()=>Xf,stringify:()=>pr,stringifyIncludeValue:()=>dd,throttlePromise:()=>pd});var of={};li(of,{getAbilityConfigUrl:()=>Hy,getScheduleDomain:()=>ec,isNeedToSchedule:()=>Lu,scheduleProxy:()=>Pr,sendScheduleRequest:()=>rf,setIsNeedToSchedule:()=>Yo,setScheduleProxy:()=>Uu});var tf=null,Lu=!0;typeof document!="undefined"&&document.head.insertAdjacentHTML("beforeend",Object.values(hi).map(i=>`<link rel="dns-prefetch" href="https://${i}">`).join(`\r
|
|
92
92
|
`));function Yo(i){nt(i)&&i!==Lu&&(Lu=i,V.info(`setIsNeedToSchedule ${i}`))}B.on("28",()=>Yo(!0));B.on("63",()=>Yo(!0));B.on("84",()=>Yo(!0));B.on("201",i=>{i.state==="RECONNECTING"&&Yo(!0)});B.on("202",i=>{i.state==="RECONNECTING"&&Yo(!0)});function $y(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=nn(i,D.MAIN),a=nn(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,p=Math.round(d.duration),T=Math.round(d.domainLookupStart-d.startTime),y=d.redirectStart>0?Math.round(d.redirectEnd-d.redirectStart):0,R=d.fetchStart>0?Math.round(d.domainLookupStart-d.fetchStart):0,N=Math.round(d.domainLookupEnd-d.domainLookupStart),j=Math.round(d.requestStart-d.secureConnectionStart),W=Math.round(d.secureConnectionStart-d.connectStart),F=Math.round(d.responseStart-d.requestStart),Ie=Math.round(d.responseEnd-d.responseStart),Vt=[N,j,W,F,Ie];Le.uploadEvent({log:`stat-schedule-net:${p}(${T}(${y}->${R})->${Vt.join("->")}) ${h}`,userId:t}),r=me(J({},r),{totalCost:p,local:T,dns:N,tcp:W,tls:j,request:F,response:Ie});break}}catch(o){V.error("getScheduleDetailCost error",o)}return r}function rf(p){return v(this,arguments,function*({userId:i,sdkAppId:t,useStringRoomId:e,roomId:r,userSig:o,version:s,frameWorkType:a,role:d,latencyLevel:h}){if(!Lu&&tf)return{isCached:!0,result:tf};let T={delta:0,count:[1,1],msg:[],detail:[]};try{let y=new FormData;y.append("userId",String(i)),y.append("sdkAppId",String(t)),y.append("isStrGroupId",String(e)),y.append("groupId",String(r)),y.append("sdkVersion",s),y.append("userSig",String(o)),d&&y.append("role",String(d)),h&&y.append("latencyLevel",String(h)),a&&y.append("frameWorkType",String(a));let R=ge(),N=yield Gy(y,T,t);N.config&&(N.config.loggerDomain&&_o(N.config.loggerDomain),nt(N.config.scheduleCache)&&Yo(!N.config.scheduleCache)),T.delta=ge()-R;let j=$y(Number(t),i,R);return tf=N,{isCached:!1,result:N,detailCost:j}}catch(y){let R=rt(y)?y[0]:y,N=Fe(R.code)?R.code:0,j=`schedule failed${R.message?`: ${R.message}`:""}`,W=new de({code:Y.SCHEDULE_FAILED,extraCode:N,message:ot({key:it.JOIN_ROOM_FAILED,data:{error:j,code:N}})});throw V.error(j,N),W}})}var Pr={main:"",backup:""};function Uu(i){rt(i)?(Pr.main=i[0],Pr.backup=i[1]):Pr.main=i}function nn(i,t=D.MAIN,e=!1){return`https://${Pr[t]||ec(i,t,e)}/api/v1/config`}function Hy(i,t=D.MAIN){return`https://${Pr[t]||ec(i,t)}/api/v1/trtcAutoConf`}function ec(i,t=D.MAIN,e=!1){let r;return Kn(i)?e?r=t===D.MAIN?hi.MAIN_OVERSEA_BACKUP:hi.BACKUP_OVERSEA:r=t===D.MAIN?hi.MAIN_OVERSEA:hi.BACKUP_OVERSEA:r=t===D.MAIN?hi.MAIN:hi.BACKUP,r}function Wy(i,t,e){return new Promise((r,o)=>{_i({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 lE=(i,t)=>Vi({retryFunction:Wy,settings:{retries:3,timeout:0},onError:t,onRetrying:i});function Gy(i,t,e){return new Promise((r,o)=>{let s=null;nd([lE(a=>t.count[0]=a+1,({error:a,retry:d,retriedCount:h,retryFuncArgs:p})=>{t.msg[0]=a.message,s||(h>=1&&(p[0]=nn(e,D.MAIN,!0)),d())})(nn(e,D.MAIN),i,{get timeout(){return So(2+t.count[0])*1e3}}),lE(a=>t.count[1]=a+1,({error:a,retry:d,retriedCount:h,retryFuncArgs:p})=>{t.msg[1]=a.message,s||(h>=2&&(p[0]=nn(e,D.BACKUP,!0)),d())})(nn(e,D.BACKUP),i,{get timeout(){return So(2+t.count[1])*1e3}})]).then(a=>{s=a,r(s)}).catch(o)})}var jy=i=>i.startsWith("data:application/octet-stream;base64,"),qy=i=>i.startsWith("file://"),Vu=class{constructor(){l(this,"_log");this._log=V.createLogger({id:"fd"})}download(t,e){return v(this,null,function*(){let{type:r="blob"}=e||{};try{let o=ge(),s;if(Ve(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 v(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 v(this,null,function*(){this._log.info(`loadWasm ${t}, importObject: ${JSON.stringify(e)}`);let r=ge(),o=null,s=null;if(Ve(WebAssembly.instantiateStreaming)&&!jy(t)&&!qy(t)&&Ve(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})}};q([ji({settings:{timeout:0,retries:3},onRetrying(i){this._log.warn(`download retrying: ${i}`)}})],Vu.prototype,"download",1);var pE=new Vu;function mE({TRTC:i,room:t,errorModule:e,assetsPath:r}){return{TRTC:i,room:t,assetsPath:r,fileDownloader:pE,innerEmitter:B,constants:pp,environment:ks,utils:ef,eventLogger:Le,log:this.room.getLogger(),loggerManager:V,errorModule:e,kvStatManager:X,rtcDectection:Gi,trtc:this,rx:ch,enums:qp,schedule:of,clearStarted:(o,s)=>{let a=o.getAlias(),d=Zr.instances.get(this);if(!!d)if(s){let h=d.get(a+s);if(!h)return;h.started=!1}else d.forEach((h,p)=>{p.startsWith(a)&&(h.started=!1)})},startGetPCM:Wa,createAudioNode:fm}}var hE=(i,t)=>{let{emit:e}=i;return i.emit=(...r)=>{try{return e.apply(i,r)}catch(o){let s=ot({key:it.CATCH_HANDLER_ERROR,data:{name:t,event:r[0]},addDocLink:!1});return V.warn(`${s}
|
|
93
93
|
|
|
94
|
-
${o.stack}`),!1}},i};var an=new WeakMap;function fE(i){let t=an.get(i);t&&(t.forEach(e=>clearTimeout(e)),an.delete(i))}function _E(i,t){return Ce((e,r)=>function(...o){let s=an.get(this);s||(s=new Map,an.set(this,s));let a=t(...o),d=s.get(a);if(!d||d<=0){e.apply(this,o);let h=setTimeout(()=>{var p;(p=an.get(this))==null||p.delete(a)},i);s.set(a,h)}else{clearTimeout(d);let h=window.setTimeout(()=>{var p;e.apply(this,o),(p=an.get(this))==null||p.delete(a)},i);s.set(a,h)}})}var gE="5.9.0-wasm.3";function Dt(...i){return Ce((t,e)=>function(...r){try{Fu.call(this,i,r,e,this._name)}catch(o){return Promise.reject(o)}return t.apply(this,r)})}function sf(...i){return Ce((t,e)=>function(...r){try{Fu.call(this,i,r,e,this._name)}catch(o){throw o}return t.apply(this,r)})}function Fu(i,t,e,r){if(rt(i))for(let o=0;o<i.length;o++)Bu.call(this,{rule:i[o],value:t[o],key:i[o].name,fnName:e,className:r});else Bu.call(this,{rule:i,value:t[0],key:i.name,fnName:e,className:r})}function Bu({rule:i,value:t,key:e,fnName:r,className:o}){function s(h){return{code:ne.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)){Ve(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 p=0;p<i.type.length;p++)i.type[p]===null&&t===null&&(h=!0),Ve(i.type[p])&&t instanceof i.type[p]&&(h=!0),Ae(i.type[p])&&mt(t)===i.type[p].toLowerCase()&&(h=!0);if(!h)throw new oe({code:ne.INVALID_PARAMETER,extraCode:5002,fnName:r,messageParams:{key:e,rule:{type:i.type.map(p=>Is(p)?ra(p):Ae(p)?p:mt(p))},value:t}})}else if(!L(i.type)&&mt(t)!==i.type)throw new oe(s(5002));if(i.allowEmpty===!1){let h=Fe(t)&&(t===0||Number.isNaN(t)),p=Ae(t)&&t.trim()==="";if(h||p)throw new oe(s(5003))}if(i.notLessThanZero&&Fe(t)&&t<0)throw new oe(s(5006));if(!L(i.min)&&Fe(t)&&t<i.min)throw new oe(s(5007));if(!L(i.max)&&Fe(t)&&t>i.max)throw new oe(s(5008));if(Ae(i.instanceOf)){if(!t||t._name!==i.instanceOf)throw new oe(s(5004))}else if(Ve(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;Ft(a)&&lr(t)&&Object.keys(a).forEach(h=>{Bu.call(this,{rule:a[h],value:t&&t[h],key:`${h}`,fnName:r,className:o})});let{arrayItem:d}=i;Ft(d)&&rt(t)&&t.forEach((h,p)=>{Bu.call(this,{rule:d,value:h,key:`${e}[${p}]`,fnName:r,className:o})}),Ve(i.validate)&&i.validate.call(this,t,e,r,o,this)}function je(i={}){let{getRemoteId:t=()=>"",replaceArg:e,getKVReportKey:r,ignoreLog:o}=i;return Ce((s,a)=>function(...d){var y;function h(R,N,j){if(j&&j.includes(R))return"hided";if(e){let W=e(...d);if(d[W.argIndex]===N)return W.value}if(N===d||R in d)return N;try{return N instanceof HTMLElement?`id: ${N.id} type:${mt(N)}`:(JSON.stringify(N),N)}catch(W){return`type:${mt(N)}`}}let p=this._log||V;if(o!=null&&o(...d))return s.apply(this,d);d.length>0?p.info(`${a}() ${JSON.stringify(d,(R,N)=>h(R,N,["userSig","privateMapKey"]))}`):p.info(`${a}()`);let T=r?r(...d):Bd[a];try{let R=s.apply(this,d),N=ge();return Li(R)?R.then(j=>(p.info(`${a}() success ${t.call(this,...d)}`),X.addSuccessEvent({key:T,cost:ge()-N}),j)).catch(j=>{var Ie;j=oe.convertFrom.call(this,j,a,d.length===1?d[0]:d);let W=j.extraCode||j.code,F=(Ie=j.message)!=null&&Ie.includes(W)?"":` code:${W}`;throw p.error(`${a}() failed ${t.call(this,...d)} ${j}${F} params: ${JSON.stringify(d,h)}`),X.addFailedEvent({key:T,error:j}),j}):(X.addSuccessEvent({key:T}),R)}catch(R){R=oe.convertFrom.call(this,R,a);let N=R.extraCode||R.code,j=(y=R.message)!=null&&y.includes(N)?"":` code:${N}`;throw p.error(`${a}() failed ${R}${j} params: ${JSON.stringify(d,h)}`),X.addFailedEvent({key:T,error:R}),R}})}var $u=i=>Ce((t,e)=>function(r,o){return v(this,null,function*(){let s=this._plugins.get(r);if(!s)throw this._log.error(`plugin ${String(r)} is not found`),new oe({code:ne.OPERATION_ABORT,message:`plugin ${String(r)} is not found`,fnName:e});if(Ve(s.constructor.isSupported)&&!s.constructor.isSupported())throw this._log.error(`plugin ${String(r)} is not supported`),new oe({code:ne.ENV_NOT_SUPPORTED,message:`plugin ${String(r)} is not supported`,extraCode:5210,fnName:e});return Fu.call(this,s.getValidateRule(i),[o],e,"TRTC"),t.call(this,s,o)})});var Hu=0,nf=class{constructor(t,e){l(this,"player");l(this,"publisher");l(this,"mixInput");this.mixInput=new Gs(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 cn(i,t){if(t&&typeof t!="function")throw new oe({code:ne.INVALID_PARAMETER,message:`start audioMixer plugin: param ${i} should be a function.`})}var dn=class{constructor(t){this.core=t;l(this,"log");l(this,"mixedMusicMap",new Map);l(this,"cacheMusicMap",new Map);Hu=Hu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Hu}`}),this.log.info(`[audioMixer] created id=${this.getAlias()}${Hu}`),this.core=t}getName(){return dn.Name}getAlias(){return"ax"}getGroup(t){return t==null?void 0:t.id}getValidateRule(t){switch(t){case"start":return dn.startValidateRule;case"update":return dn.updateValidateRule;case"stop":return dn.stopValidateRule}}start(t){return v(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 nf(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 v(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 v(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:p,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 p!="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()}},io=dn;l(io,"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"),p=o.startsWith("data");if(!(d||h||p))throw new oe({code:ne.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:ne.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:r});cn("onTimeUpdate",t.onTimeUpdate),cn("onEnded",t.onEnded),cn("onDurationChange",t.onDurationChange)}}),l(io,"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){cn("onTimeUpdate",t.onTimeUpdate),cn("onEnded",t.onEnded),cn("onDurationChange",t.onDurationChange)}}),l(io,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),l(io,"Name","AudioMixer");var Wu=0,af,un=class{constructor(t){this.core=t;l(this,"log");l(this,"audioContext",jt("denoiser"));l(this,"workletNode");Wu=Wu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Wu}`}),this.log.info(`[audioDenoiser] created id=${this.getAlias()}${Wu}`),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:ne.INVALID_OPERATION,extraCode:5106,fnName:o})}}}preload(t){return af||(af=this.doPreload(t)),af}doPreload(t){return v(this,null,function*(){let e=yield this.core.fileDownloader.download(t,{type:"blob"}),r=URL.createObjectURL(e);try{yield Po(this.audioContext,r)}finally{URL.revokeObjectURL(r)}})}getName(){return un.Name}getAlias(){return"ad"}getGroup(){return`AIDenoiser_${Date.now()}`}getValidateRule(t){switch(t){case"start":return un.startValidateRule(this.core);case"update":return un.updateValidateRule;case"stop":return un.stopValidateRule}}start(t){return v(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 Xy(me(J({},t),{timestamp:r}));if(!o)throw this.log.info(`RTCAIDenoiser: ${t.userId} auth result: ${o}. Message: ${d}`),new oe({code:ne.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:p}=h;p.type==="cost"&&this.log.debug(`[RTCAIDenoiser] ${p.value}`)}}this.workletNode.port.postMessage({type:"enable"}),e.audioManager.addDenoiser(this.workletNode),e.sendAbilityStatus({ai_denoise:1})})}update(){return v(this,null,function*(){})}stop(){return v(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)}},Zo=un;l(Zo,"updateValidateRule",{type:"object"}),l(Zo,"stopValidateRule",{type:"object"}),l(Zo,"Name","AIDenoiser");function Jy(i,t=D.MAIN){return`https://${Pr[t]||ec(i,t)}/api/v1/audioAiAuth`}function Xy(o){return v(this,arguments,function*({sdkAppId:i,userId:t,userSig:e,timestamp:r}){let a=`${Jy(i)}?sdkAppId=${i}&userId=${t}&userSig=${e}×tamp=${r}`,d=yield fetch(a),{data:{errCode:h,errMsg:p,sign:T,status:y}}=yield d.json();if(y==="1")return{auth:!0,sign:T,status:y,message:p};let R="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:y,message:p?`${R} Reason: ${p}. ${N}`:`${R}, ${N}`}})}var EE=Pi(Hi(),1);var cf=class extends EE.EventEmitter{constructor(){super();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 v(this,null,function*(){if(!this.observer)try{"PressureObserver"in window&&!ft&&(this.observer=new PressureObserver(this.onPressureChange),yield this.observer.observe("cpu",{sampleInterval:2e3}))}catch(e){Le.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)&&V.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){Le.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:r})}}},Qy=new cf,df=Qy;function Yy([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 Lo(new DataView(new Uint8Array(s).buffer),!0)}function Zy(i){return i.type==="empty"||i.data.byteLength===0}function Ky(i){return i.getInt32(0)===1&&i.getInt8(4)===6}function eA(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 uf({frame:i,seiMessageList:t}){if(!t||t.length===0||i.data.byteLength===0)return i;let e=eA(i.data),r=9-e;if(r<=0)return i;let o=t.splice(0,r).reverse().map(Yy),s=o.reduce((T,y)=>T+y.dataView.byteLength,0),a=new ArrayBuffer(s+i.data.byteLength),d=new DataView(a),h=new DataView(i.data),p=0;for(let T=0;T<o.length;T++)for(let y=0;y<o[T].dataView.byteLength;y++)d.setInt8(p++,o[T].dataView.getInt8(y));for(let T=0;T<i.data.byteLength;T++)d.setInt8(p++,h.getInt8(T));return i.data=a,i}function lf({frame:i,onSEI:t}){try{let e=new DataView(i.data);if(Zy(i)||!Ky(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 p=d-o;if(s===-1?s=p:a===-1&&(a=p,r.push(new Lo(new DataView(e.buffer.slice(s,a)))),s=p,a=-1),!(e.getUint8(d+1)===6)){i.data=e.buffer.slice(p);break}}o=0}else o=0}t==null||t(r.reverse())}catch(e){}return i}var pf=0,mf=class{constructor(t){this.core=t;l(this,"log");l(this,"_seiMessageList",[]);l(this,"_smallSeiMessageList",[]);l(this,"_subStreamSeiMessageList",[]);pf++,this.log=t.log.createChild({id:`${this.getAlias()}${pf}`}),this.log.info(`[sei] created id=${this.getAlias()}${pf}`),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 uf({frame:t,seiMessageList:r})}catch(r){this.log.warn(r)}return t}decode({frame:t,track:e}){return lf({frame:t,onSEI:r=>{r.forEach(o=>{this.core.trtc.emit(re.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:xa?this.encode:uf,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:xa?this.decode:lf,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 mf.Name}getAlias(){return"sei"}getGroup(){return"sei"}},ln=mf;l(ln,"autoStart",!0),l(ln,"Name","SEI");function hf({frame:i,onDump:t}){return t==null||t(),i}function ff({frame:i,onDump:t}){return t==null||t(),i}var TE={"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 an=new WeakMap;function fE(i){let t=an.get(i);t&&(t.forEach(e=>clearTimeout(e)),an.delete(i))}function _E(i,t){return Ce((e,r)=>function(...o){let s=an.get(this);s||(s=new Map,an.set(this,s));let a=t(...o),d=s.get(a);if(!d||d<=0){e.apply(this,o);let h=setTimeout(()=>{var p;(p=an.get(this))==null||p.delete(a)},i);s.set(a,h)}else{clearTimeout(d);let h=window.setTimeout(()=>{var p;e.apply(this,o),(p=an.get(this))==null||p.delete(a)},i);s.set(a,h)}})}var gE="5.9.0-wasm.4";function Dt(...i){return Ce((t,e)=>function(...r){try{Fu.call(this,i,r,e,this._name)}catch(o){return Promise.reject(o)}return t.apply(this,r)})}function sf(...i){return Ce((t,e)=>function(...r){try{Fu.call(this,i,r,e,this._name)}catch(o){throw o}return t.apply(this,r)})}function Fu(i,t,e,r){if(rt(i))for(let o=0;o<i.length;o++)Bu.call(this,{rule:i[o],value:t[o],key:i[o].name,fnName:e,className:r});else Bu.call(this,{rule:i,value:t[0],key:i.name,fnName:e,className:r})}function Bu({rule:i,value:t,key:e,fnName:r,className:o}){function s(h){return{code:ne.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)){Ve(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 p=0;p<i.type.length;p++)i.type[p]===null&&t===null&&(h=!0),Ve(i.type[p])&&t instanceof i.type[p]&&(h=!0),Ae(i.type[p])&&mt(t)===i.type[p].toLowerCase()&&(h=!0);if(!h)throw new oe({code:ne.INVALID_PARAMETER,extraCode:5002,fnName:r,messageParams:{key:e,rule:{type:i.type.map(p=>Is(p)?ra(p):Ae(p)?p:mt(p))},value:t}})}else if(!L(i.type)&&mt(t)!==i.type)throw new oe(s(5002));if(i.allowEmpty===!1){let h=Fe(t)&&(t===0||Number.isNaN(t)),p=Ae(t)&&t.trim()==="";if(h||p)throw new oe(s(5003))}if(i.notLessThanZero&&Fe(t)&&t<0)throw new oe(s(5006));if(!L(i.min)&&Fe(t)&&t<i.min)throw new oe(s(5007));if(!L(i.max)&&Fe(t)&&t>i.max)throw new oe(s(5008));if(Ae(i.instanceOf)){if(!t||t._name!==i.instanceOf)throw new oe(s(5004))}else if(Ve(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;Ft(a)&&lr(t)&&Object.keys(a).forEach(h=>{Bu.call(this,{rule:a[h],value:t&&t[h],key:`${h}`,fnName:r,className:o})});let{arrayItem:d}=i;Ft(d)&&rt(t)&&t.forEach((h,p)=>{Bu.call(this,{rule:d,value:h,key:`${e}[${p}]`,fnName:r,className:o})}),Ve(i.validate)&&i.validate.call(this,t,e,r,o,this)}function je(i={}){let{getRemoteId:t=()=>"",replaceArg:e,getKVReportKey:r,ignoreLog:o}=i;return Ce((s,a)=>function(...d){var y;function h(R,N,j){if(j&&j.includes(R))return"hided";if(e){let W=e(...d);if(d[W.argIndex]===N)return W.value}if(N===d||R in d)return N;try{return N instanceof HTMLElement?`id: ${N.id} type:${mt(N)}`:(JSON.stringify(N),N)}catch(W){return`type:${mt(N)}`}}let p=this._log||V;if(o!=null&&o(...d))return s.apply(this,d);d.length>0?p.info(`${a}() ${JSON.stringify(d,(R,N)=>h(R,N,["userSig","privateMapKey"]))}`):p.info(`${a}()`);let T=r?r(...d):Bd[a];try{let R=s.apply(this,d),N=ge();return Li(R)?R.then(j=>(p.info(`${a}() success ${t.call(this,...d)}`),X.addSuccessEvent({key:T,cost:ge()-N}),j)).catch(j=>{var Ie;j=oe.convertFrom.call(this,j,a,d.length===1?d[0]:d);let W=j.extraCode||j.code,F=(Ie=j.message)!=null&&Ie.includes(W)?"":` code:${W}`;throw p.error(`${a}() failed ${t.call(this,...d)} ${j}${F} params: ${JSON.stringify(d,h)}`),X.addFailedEvent({key:T,error:j}),j}):(X.addSuccessEvent({key:T}),R)}catch(R){R=oe.convertFrom.call(this,R,a);let N=R.extraCode||R.code,j=(y=R.message)!=null&&y.includes(N)?"":` code:${N}`;throw p.error(`${a}() failed ${R}${j} params: ${JSON.stringify(d,h)}`),X.addFailedEvent({key:T,error:R}),R}})}var $u=i=>Ce((t,e)=>function(r,o){return v(this,null,function*(){let s=this._plugins.get(r);if(!s)throw this._log.error(`plugin ${String(r)} is not found`),new oe({code:ne.OPERATION_ABORT,message:`plugin ${String(r)} is not found`,fnName:e});if(Ve(s.constructor.isSupported)&&!s.constructor.isSupported())throw this._log.error(`plugin ${String(r)} is not supported`),new oe({code:ne.ENV_NOT_SUPPORTED,message:`plugin ${String(r)} is not supported`,extraCode:5210,fnName:e});return Fu.call(this,s.getValidateRule(i),[o],e,"TRTC"),t.call(this,s,o)})});var Hu=0,nf=class{constructor(t,e){l(this,"player");l(this,"publisher");l(this,"mixInput");this.mixInput=new Gs(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 cn(i,t){if(t&&typeof t!="function")throw new oe({code:ne.INVALID_PARAMETER,message:`start audioMixer plugin: param ${i} should be a function.`})}var dn=class{constructor(t){this.core=t;l(this,"log");l(this,"mixedMusicMap",new Map);l(this,"cacheMusicMap",new Map);Hu=Hu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Hu}`}),this.log.info(`[audioMixer] created id=${this.getAlias()}${Hu}`),this.core=t}getName(){return dn.Name}getAlias(){return"ax"}getGroup(t){return t==null?void 0:t.id}getValidateRule(t){switch(t){case"start":return dn.startValidateRule;case"update":return dn.updateValidateRule;case"stop":return dn.stopValidateRule}}start(t){return v(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 nf(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 v(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 v(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:p,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 p!="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()}},io=dn;l(io,"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"),p=o.startsWith("data");if(!(d||h||p))throw new oe({code:ne.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:ne.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:r});cn("onTimeUpdate",t.onTimeUpdate),cn("onEnded",t.onEnded),cn("onDurationChange",t.onDurationChange)}}),l(io,"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){cn("onTimeUpdate",t.onTimeUpdate),cn("onEnded",t.onEnded),cn("onDurationChange",t.onDurationChange)}}),l(io,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),l(io,"Name","AudioMixer");var Wu=0,af,un=class{constructor(t){this.core=t;l(this,"log");l(this,"audioContext",jt("denoiser"));l(this,"workletNode");Wu=Wu+1,this.log=t.log.createChild({id:`${this.getAlias()}${Wu}`}),this.log.info(`[audioDenoiser] created id=${this.getAlias()}${Wu}`),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:ne.INVALID_OPERATION,extraCode:5106,fnName:o})}}}preload(t){return af||(af=this.doPreload(t)),af}doPreload(t){return v(this,null,function*(){let e=yield this.core.fileDownloader.download(t,{type:"blob"}),r=URL.createObjectURL(e);try{yield Po(this.audioContext,r)}finally{URL.revokeObjectURL(r)}})}getName(){return un.Name}getAlias(){return"ad"}getGroup(){return`AIDenoiser_${Date.now()}`}getValidateRule(t){switch(t){case"start":return un.startValidateRule(this.core);case"update":return un.updateValidateRule;case"stop":return un.stopValidateRule}}start(t){return v(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 Xy(me(J({},t),{timestamp:r}));if(!o)throw this.log.info(`RTCAIDenoiser: ${t.userId} auth result: ${o}. Message: ${d}`),new oe({code:ne.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:p}=h;p.type==="cost"&&this.log.debug(`[RTCAIDenoiser] ${p.value}`)}}this.workletNode.port.postMessage({type:"enable"}),e.audioManager.addDenoiser(this.workletNode),e.sendAbilityStatus({ai_denoise:1})})}update(){return v(this,null,function*(){})}stop(){return v(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)}},Zo=un;l(Zo,"updateValidateRule",{type:"object"}),l(Zo,"stopValidateRule",{type:"object"}),l(Zo,"Name","AIDenoiser");function Jy(i,t=D.MAIN){return`https://${Pr[t]||ec(i,t)}/api/v1/audioAiAuth`}function Xy(o){return v(this,arguments,function*({sdkAppId:i,userId:t,userSig:e,timestamp:r}){let a=`${Jy(i)}?sdkAppId=${i}&userId=${t}&userSig=${e}×tamp=${r}`,d=yield fetch(a),{data:{errCode:h,errMsg:p,sign:T,status:y}}=yield d.json();if(y==="1")return{auth:!0,sign:T,status:y,message:p};let R="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:y,message:p?`${R} Reason: ${p}. ${N}`:`${R}, ${N}`}})}var EE=Pi(Hi(),1);var cf=class extends EE.EventEmitter{constructor(){super();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 v(this,null,function*(){if(!this.observer)try{"PressureObserver"in window&&!ft&&(this.observer=new PressureObserver(this.onPressureChange),yield this.observer.observe("cpu",{sampleInterval:2e3}))}catch(e){Le.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)&&V.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){Le.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:r})}}},Qy=new cf,df=Qy;function Yy([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 Lo(new DataView(new Uint8Array(s).buffer),!0)}function Zy(i){return i.type==="empty"||i.data.byteLength===0}function Ky(i){return i.getInt32(0)===1&&i.getInt8(4)===6}function eA(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 uf({frame:i,seiMessageList:t}){if(!t||t.length===0||i.data.byteLength===0)return i;let e=eA(i.data),r=9-e;if(r<=0)return i;let o=t.splice(0,r).reverse().map(Yy),s=o.reduce((T,y)=>T+y.dataView.byteLength,0),a=new ArrayBuffer(s+i.data.byteLength),d=new DataView(a),h=new DataView(i.data),p=0;for(let T=0;T<o.length;T++)for(let y=0;y<o[T].dataView.byteLength;y++)d.setInt8(p++,o[T].dataView.getInt8(y));for(let T=0;T<i.data.byteLength;T++)d.setInt8(p++,h.getInt8(T));return i.data=a,i}function lf({frame:i,onSEI:t}){try{let e=new DataView(i.data);if(Zy(i)||!Ky(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 p=d-o;if(s===-1?s=p:a===-1&&(a=p,r.push(new Lo(new DataView(e.buffer.slice(s,a)))),s=p,a=-1),!(e.getUint8(d+1)===6)){i.data=e.buffer.slice(p);break}}o=0}else o=0}t==null||t(r.reverse())}catch(e){}return i}var pf=0,mf=class{constructor(t){this.core=t;l(this,"log");l(this,"_seiMessageList",[]);l(this,"_smallSeiMessageList",[]);l(this,"_subStreamSeiMessageList",[]);pf++,this.log=t.log.createChild({id:`${this.getAlias()}${pf}`}),this.log.info(`[sei] created id=${this.getAlias()}${pf}`),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 uf({frame:t,seiMessageList:r})}catch(r){this.log.warn(r)}return t}decode({frame:t,track:e}){return lf({frame:t,onSEI:r=>{r.forEach(o=>{this.core.trtc.emit(re.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:xa?this.encode:uf,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:xa?this.decode:lf,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 mf.Name}getAlias(){return"sei"}getGroup(){return"sei"}},ln=mf;l(ln,"autoStart",!0),l(ln,"Name","SEI");function hf({frame:i,onDump:t}){return t==null||t(),i}function ff({frame:i,onDump:t}){return t==null||t(),i}var TE={"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.
|