trtc-sdk-v5 5.7.2-beta.4 → 5.8.1-beta.1
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/index.d.ts +0 -1
- package/package.json +1 -1
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/cross-room/cross-room.esm.js +1 -1
- package/plugins/cross-room/cross-room.iife.js +1 -1
- package/plugins/cross-room/package.json +1 -1
- package/plugins/debug/package.json +1 -1
- package/plugins/device-detector/device-detector.esm.js +1 -1
- package/plugins/device-detector/device-detector.iife.js +1 -1
- package/plugins/device-detector/package.json +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +2 -2
- package/plugins/video-effect/basic-beauty/basic-beauty.iife.js +2 -2
- 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/virtual-background/virtual-background.esm.js +14 -14
- package/plugins/video-effect/virtual-background/virtual-background.iife.js +14 -14
- package/plugins/video-effect/watermark/package.json +1 -1
- package/trtc.esm.js +25 -28
- package/trtc.js +1 -1
- package/plugins/cdn-streaming/cdn-streaming.js +0 -1
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var D=Object.defineProperty,U=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var
|
|
1
|
+
var D=Object.defineProperty,U=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable;var p=(a,e,r)=>e in a?D(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r,m=(a,e)=>{for(var r in e||(e={}))N.call(e,r)&&p(a,r,e[r]);if(T)for(var r of T(e))y.call(e,r)&&p(a,r,e[r]);return a},c=(a,e)=>U(a,C(e));var d=(a,e,r)=>(p(a,typeof e!="symbol"?e+"":e,r),r);var b={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},l={name:"option",required:!0,properties:c(m({},b.properties),{userId:{type:"string"}})},R={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:c(m({},l.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},g={name:"option",properties:m({},b.properties)};var u=class u{constructor(e){this.core=e;d(this,"connectedRoomIdSet",new Set);d(this,"updateSeq",0)}getName(){return u.Name}getAlias(){return"crs-r"}getGroup(e){var o;let r=(e==null?void 0:e.userId)||((o=e==null?void 0:e.updateList)==null?void 0:o[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return l;case"update":return R;case"stop":return g}}async start({roomId:e,strRoomId:r,userId:o}){let{RtcError:t,ErrorCode:s}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:s.ENV_NOT_SUPPORTED});let n=e||r,i=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:n,userId:o,localRoomId:o?void 0:this.core.room.roomId},retries:3});if(i.data.code!==0)throw new t({code:s.SERVER_ERROR,extraCode:i.data.code,message:i.data.message});o||this.connectedRoomIdSet.add(n)}async update({updateList:e}){var n;let{RtcError:r,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:o.ENV_NOT_SUPPORTED});let t=e.find(i=>i.userId)?0:1,s=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:t,updateList:e.map(({roomId:i,strRoomId:E,userId:O,muteAudio:_,muteVideo:I,muteSubStream:A})=>({roomId:i||E,userId:O,muteAudio:_,muteVideo:I,muteSubStream:A}))},retries:3});if(s.data.data.expectSeq)return this.updateSeq=s.data.data.expectSeq,this.update({updateList:e});if(s.data.code!==0)throw new r({code:o.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});if(((n=s.data.data.errorList)==null?void 0:n.length)>0)throw new r({code:o.UNKNOWN_ERROR,message:s.data.data.errorList[0].message})}async stop({roomId:e,strRoomId:r}={}){let o=e||r;if(o)await this.doStop(o);else if(this.connectedRoomIdSet.size>0)for(let t of[...this.connectedRoomIdSet.values()])await this.doStop(t);else await this.doStop()}async doStop(e){let{RtcError:r,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:o.ENV_NOT_SUPPORTED});let t=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(t.data.code!==0)throw new r({code:o.SERVER_ERROR,extraCode:t.data.code,message:t.data.message});this.connectedRoomIdSet.delete(e)}destroy(){}};d(u,"Name","CrossRoom");var S=u;var G=S;export{S as CrossRoom,G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var CrossRoom=(()=>{var m=Object.defineProperty,C=Object.defineProperties,N=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertyNames,b=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var
|
|
1
|
+
"use strict";var CrossRoom=(()=>{var m=Object.defineProperty,C=Object.defineProperties,N=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertyNames,b=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var l=(o,e,r)=>e in o?m(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,u=(o,e)=>{for(var r in e||(e={}))R.call(e,r)&&l(o,r,e[r]);if(b)for(var r of b(e))P.call(e,r)&&l(o,r,e[r]);return o},S=(o,e)=>C(o,y(e));var h=(o,e)=>{for(var r in e)m(o,r,{get:e[r],enumerable:!0})},f=(o,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of x(e))!R.call(o,t)&&t!==r&&m(o,t,{get:()=>e[t],enumerable:!(a=N(e,t))||a.enumerable});return o};var L=o=>f(m({},"__esModule",{value:!0}),o);var d=(o,e,r)=>(l(o,typeof e!="symbol"?e+"":e,r),r);var V={};h(V,{CrossRoom:()=>p,default:()=>k});var g={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},T={name:"option",required:!0,properties:S(u({},g.properties),{userId:{type:"string"}})},E={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:S(u({},T.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},O={name:"option",properties:u({},g.properties)};var c=class c{constructor(e){this.core=e;d(this,"connectedRoomIdSet",new Set);d(this,"updateSeq",0)}getName(){return c.Name}getAlias(){return"crs-r"}getGroup(e){var a;let r=(e==null?void 0:e.userId)||((a=e==null?void 0:e.updateList)==null?void 0:a[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return T;case"update":return E;case"stop":return O}}async start({roomId:e,strRoomId:r,userId:a}){let{RtcError:t,ErrorCode:s}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:s.ENV_NOT_SUPPORTED});let n=e||r,i=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:n,userId:a,localRoomId:a?void 0:this.core.room.roomId},retries:3});if(i.data.code!==0)throw new t({code:s.SERVER_ERROR,extraCode:i.data.code,message:i.data.message});a||this.connectedRoomIdSet.add(n)}async update({updateList:e}){var n;let{RtcError:r,ErrorCode:a}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:a.ENV_NOT_SUPPORTED});let t=e.find(i=>i.userId)?0:1,s=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:t,updateList:e.map(({roomId:i,strRoomId:_,userId:I,muteAudio:A,muteVideo:D,muteSubStream:U})=>({roomId:i||_,userId:I,muteAudio:A,muteVideo:D,muteSubStream:U}))},retries:3});if(s.data.data.expectSeq)return this.updateSeq=s.data.data.expectSeq,this.update({updateList:e});if(s.data.code!==0)throw new r({code:a.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});if(((n=s.data.data.errorList)==null?void 0:n.length)>0)throw new r({code:a.UNKNOWN_ERROR,message:s.data.data.errorList[0].message})}async stop({roomId:e,strRoomId:r}={}){let a=e||r;if(a)await this.doStop(a);else if(this.connectedRoomIdSet.size>0)for(let t of[...this.connectedRoomIdSet.values()])await this.doStop(t);else await this.doStop()}async doStop(e){let{RtcError:r,ErrorCode:a}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:a.ENV_NOT_SUPPORTED});let t=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(t.data.code!==0)throw new r({code:a.SERVER_ERROR,extraCode:t.data.code,message:t.data.message});this.connectedRoomIdSet.delete(e)}destroy(){}};d(c,"Name","CrossRoom");var p=c;var k=p;return L(V);})().default;
|
|
@@ -1212,7 +1212,7 @@ var TV=Object.defineProperty,xV=Object.defineProperties;var vV=Object.getOwnProp
|
|
|
1212
1212
|
</div>
|
|
1213
1213
|
</div>
|
|
1214
1214
|
</div>
|
|
1215
|
-
`:q``}};h(re,"properties",{audioUrl:{type:String},activeDetector:String,handleComplete:Function,constructTime:{type:Number}});customElements.get("trtc-speaker-detector")||customElements.define("trtc-speaker-detector",re);var ne=class extends E{constructor(){super(),this.NETWORK_QUALITY={},this.currentDetector="network",this.detectorInfo={},this.count=15,this.timer=null,this.networkInfo=null,this.testResult={uplinkNetworkQualities:[],downlinkNetworkQualities:[],rttList:[],average:{uplinkNetworkQuality:0,downlinkNetworkQuality:0,rtt:0},result:{rtt:0,quality:0}},this._initializeTRTC(),this.isDownlink=!1,this.networkInfo&&this.networkInfo.downlinkUserId&&this.networkInfo.downlinkUserSig&&(this.isDownlink=!0),this.Enum={0:"0\uFF1A\u7F51\u7EDC\u72B6\u51B5\u672A\u77E5",1:"1\uFF1A\u7F51\u7EDC\u72B6\u51B5\u6781\u4F73",2:"2\uFF1A\u7F51\u7EDC\u72B6\u51B5\u8F83\u597D",3:"3\uFF1A\u7F51\u7EDC\u72B6\u51B5\u4E00\u822C",4:"4\uFF1A\u7F51\u7EDC\u72B6\u51B5\u8F83\u5DEE",5:"5\uFF1A\u7F51\u7EDC\u72B6\u51B5\u6781\u5DEE",6:"6\uFF1A\u7F51\u7EDC\u8FDE\u63A5\u65AD\u5F00"},this.EnumEng={0:"0: unknown",1:"1: excellent",2:"2: good",3:"3: fair",4:"4: poor",5:"5: very poor",6:"6: disconnected"};let e=navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||"en";this.isChinese=e.indexOf("zh")>-1,this.attachShadow({mode:"open"})}_initializeTRTC(){this.networkInfo=S.networkInfo,Object.defineProperty(S,"networkInfo",{set:e=>{this.networkInfo=e},get:()=>this.networkInfo})}firstUpdated(){}updated(e){e.has("activeDetector")&&this.activeDetector===this.currentDetector&&this.count!==0&&(this.count=15,this.getDetectorInfo())}async testUplinkNetworkQuality(){let{sdkAppId:e,uplinkTRTC:t,userId:i,userSig:A,roomId:o}=this.networkInfo;try{await t.exitRoom()}catch(s){}await t.enterRoom({roomId:o||8080,sdkAppId:e,userId:i,userSig:A,scene:"rtc"}),!this.hasStartLocalVideo&&await t.startLocalVideo({option:{profile:"480p"}}),this.setHasStartLocalVideo(),this.hasStartLocalVideo=!0,t.on(g.TRTC.EVENT.NETWORK_QUALITY,s=>{let{uplinkNetworkQuality:n,uplinkRTT:r}=s;this.testResult.uplinkNetworkQualities.push(n),this.testResult.rttList.push(r)})}async testDownlinkNetworkQuality(){let{sdkAppId:e,downlinkUserId:t,downlinkTRTC:i,downlinkUserSig:A,roomId:o}=this.networkInfo;try{await i.exitRoom()}catch(s){}await i.enterRoom({roomId:o||8080,sdkAppId:e,userId:t,userSig:A,scene:"rtc"}),i.on(g.TRTC.EVENT.NETWORK_QUALITY,s=>{let{downlinkNetworkQuality:n}=s;this.testResult.downlinkNetworkQualities.push(n)})}async getDetectorInfo(){let e=S.getSystem(),t=await S.isTRTCSupported(),i=S.getAPISupported();this.detectorInfo={system:e.OS,browser:`${e.browser.name} ${e.browser.version}`,TRTCSupport:t.result?"Yes":"No",screenMediaSupport:i.isScreenCaptureAPISupported?"Yes":"No"},this.timer=setInterval(()=>{this.count=this.count-1,this.requestUpdate(),this.count===0&&clearInterval(this.timer)},1e3),this.testUplinkNetworkQuality(),this.isDownlink&&this.testDownlinkNetworkQuality(),setTimeout(async()=>{this.testResult.uplinkNetworkQualities.length>0&&(this.testResult.average.uplinkNetworkQuality=Math.ceil(this.testResult.uplinkNetworkQualities.reduce((A,o)=>A+o,0)/this.testResult.uplinkNetworkQualities.length)),this.testResult.downlinkNetworkQualities.length>0&&(this.testResult.average.downlinkNetworkQuality=Math.ceil(this.testResult.downlinkNetworkQualities.reduce((A,o)=>A+o,0)/this.testResult.downlinkNetworkQualities.length)),this.testResult.rttList.length>0&&(this.testResult.average.rtt=Math.ceil(this.testResult.rttList.reduce((A,o)=>A+o,0)/this.testResult.rttList.length)),this.testResult.average.uplinkNetworkQuality===0||this.isDownlink&&this.testResult.average.downlinkNetworkQuality===0?this.testResult.result.quality=0:this.testResult.result.quality=Math.max(this.testResult.average.uplinkNetworkQuality,this.testResult.average.downlinkNetworkQuality),this.testResult.result.rtt=this.testResult.average.rtt,this.requestUpdate(),await this.networkInfo.uplinkTRTC.
|
|
1215
|
+
`:q``}};h(re,"properties",{audioUrl:{type:String},activeDetector:String,handleComplete:Function,constructTime:{type:Number}});customElements.get("trtc-speaker-detector")||customElements.define("trtc-speaker-detector",re);var ne=class extends E{constructor(){super(),this.NETWORK_QUALITY={},this.currentDetector="network",this.detectorInfo={},this.count=15,this.timer=null,this.networkInfo=null,this.testResult={uplinkNetworkQualities:[],downlinkNetworkQualities:[],rttList:[],average:{uplinkNetworkQuality:0,downlinkNetworkQuality:0,rtt:0},result:{rtt:0,quality:0}},this._initializeTRTC(),this.isDownlink=!1,this.networkInfo&&this.networkInfo.downlinkUserId&&this.networkInfo.downlinkUserSig&&(this.isDownlink=!0),this.Enum={0:"0\uFF1A\u7F51\u7EDC\u72B6\u51B5\u672A\u77E5",1:"1\uFF1A\u7F51\u7EDC\u72B6\u51B5\u6781\u4F73",2:"2\uFF1A\u7F51\u7EDC\u72B6\u51B5\u8F83\u597D",3:"3\uFF1A\u7F51\u7EDC\u72B6\u51B5\u4E00\u822C",4:"4\uFF1A\u7F51\u7EDC\u72B6\u51B5\u8F83\u5DEE",5:"5\uFF1A\u7F51\u7EDC\u72B6\u51B5\u6781\u5DEE",6:"6\uFF1A\u7F51\u7EDC\u8FDE\u63A5\u65AD\u5F00"},this.EnumEng={0:"0: unknown",1:"1: excellent",2:"2: good",3:"3: fair",4:"4: poor",5:"5: very poor",6:"6: disconnected"};let e=navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||"en";this.isChinese=e.indexOf("zh")>-1,this.attachShadow({mode:"open"})}_initializeTRTC(){this.networkInfo=S.networkInfo,Object.defineProperty(S,"networkInfo",{set:e=>{this.networkInfo=e},get:()=>this.networkInfo})}firstUpdated(){}updated(e){e.has("activeDetector")&&this.activeDetector===this.currentDetector&&this.count!==0&&(this.count=15,this.getDetectorInfo())}async testUplinkNetworkQuality(){let{sdkAppId:e,uplinkTRTC:t,userId:i,userSig:A,roomId:o}=this.networkInfo;try{await t.exitRoom()}catch(s){}await t.enterRoom({roomId:o||8080,sdkAppId:e,userId:i,userSig:A,scene:"rtc"}),!this.hasStartLocalVideo&&await t.startLocalVideo({option:{profile:"480p"}}),this.setHasStartLocalVideo(),this.hasStartLocalVideo=!0,t.on(g.TRTC.EVENT.NETWORK_QUALITY,s=>{let{uplinkNetworkQuality:n,uplinkRTT:r}=s;this.testResult.uplinkNetworkQualities.push(n),this.testResult.rttList.push(r)})}async testDownlinkNetworkQuality(){let{sdkAppId:e,downlinkUserId:t,downlinkTRTC:i,downlinkUserSig:A,roomId:o}=this.networkInfo;try{await i.exitRoom()}catch(s){}await i.enterRoom({roomId:o||8080,sdkAppId:e,userId:t,userSig:A,scene:"rtc"}),i.on(g.TRTC.EVENT.NETWORK_QUALITY,s=>{let{downlinkNetworkQuality:n}=s;this.testResult.downlinkNetworkQualities.push(n)})}async getDetectorInfo(){let e=S.getSystem(),t=await S.isTRTCSupported(),i=S.getAPISupported();this.detectorInfo={system:e.OS,browser:`${e.browser.name} ${e.browser.version}`,TRTCSupport:t.result?"Yes":"No",screenMediaSupport:i.isScreenCaptureAPISupported?"Yes":"No"},this.timer=setInterval(()=>{this.count=this.count-1,this.requestUpdate(),this.count===0&&clearInterval(this.timer)},1e3),this.testUplinkNetworkQuality(),this.isDownlink&&this.testDownlinkNetworkQuality(),setTimeout(async()=>{this.testResult.uplinkNetworkQualities.length>0&&(this.testResult.average.uplinkNetworkQuality=Math.ceil(this.testResult.uplinkNetworkQualities.reduce((A,o)=>A+o,0)/this.testResult.uplinkNetworkQualities.length)),this.testResult.downlinkNetworkQualities.length>0&&(this.testResult.average.downlinkNetworkQuality=Math.ceil(this.testResult.downlinkNetworkQualities.reduce((A,o)=>A+o,0)/this.testResult.downlinkNetworkQualities.length)),this.testResult.rttList.length>0&&(this.testResult.average.rtt=Math.ceil(this.testResult.rttList.reduce((A,o)=>A+o,0)/this.testResult.rttList.length)),this.testResult.average.uplinkNetworkQuality===0||this.isDownlink&&this.testResult.average.downlinkNetworkQuality===0?this.testResult.result.quality=0:this.testResult.result.quality=Math.max(this.testResult.average.uplinkNetworkQuality,this.testResult.average.downlinkNetworkQuality),this.testResult.result.rtt=this.testResult.average.rtt,this.requestUpdate(),await this.networkInfo.uplinkTRTC.stopLocalVideo(),this.networkInfo.uplinkTRTC.exitRoom(),this.isDownlink&&this.networkInfo.downlinkTRTC.exitRoom()},15*1e3)}disconnectedCallback(){this.timer&&clearInterval(this.timer),this.remove()}async handleSuccess(){this.hasStartLocalVideo&&await this.networkInfo.uplinkTRTC.stopLocalVideo(),this.generateReport();let e=new Date().getTime();g&&g.kvStatManager.addSuccessEvent({key:591711,cost:e-this.constructTime}),(this.testResult.result.quality===0||this.testResult.result.rtt===0)&&u&&u.warn("NetworkFail",this.testResult.average),this.handleComplete("success",this.testResult.result,this.testResult.result.quality!==0)}render(){return this.activeDetector===this.currentDetector?q`
|
|
1216
1216
|
<style>${f}</style>
|
|
1217
1217
|
<div class="testing-body">
|
|
1218
1218
|
<div class="testing-list">
|
|
@@ -1212,7 +1212,7 @@
|
|
|
1212
1212
|
</div>
|
|
1213
1213
|
</div>
|
|
1214
1214
|
</div>
|
|
1215
|
-
`:q``}};h(re,"properties",{audioUrl:{type:String},activeDetector:String,handleComplete:Function,constructTime:{type:Number}});customElements.get("trtc-speaker-detector")||customElements.define("trtc-speaker-detector",re);var ne=class extends E{constructor(){super(),this.NETWORK_QUALITY={},this.currentDetector="network",this.detectorInfo={},this.count=15,this.timer=null,this.networkInfo=null,this.testResult={uplinkNetworkQualities:[],downlinkNetworkQualities:[],rttList:[],average:{uplinkNetworkQuality:0,downlinkNetworkQuality:0,rtt:0},result:{rtt:0,quality:0}},this._initializeTRTC(),this.isDownlink=!1,this.networkInfo&&this.networkInfo.downlinkUserId&&this.networkInfo.downlinkUserSig&&(this.isDownlink=!0),this.Enum={0:"0\uFF1A\u7F51\u7EDC\u72B6\u51B5\u672A\u77E5",1:"1\uFF1A\u7F51\u7EDC\u72B6\u51B5\u6781\u4F73",2:"2\uFF1A\u7F51\u7EDC\u72B6\u51B5\u8F83\u597D",3:"3\uFF1A\u7F51\u7EDC\u72B6\u51B5\u4E00\u822C",4:"4\uFF1A\u7F51\u7EDC\u72B6\u51B5\u8F83\u5DEE",5:"5\uFF1A\u7F51\u7EDC\u72B6\u51B5\u6781\u5DEE",6:"6\uFF1A\u7F51\u7EDC\u8FDE\u63A5\u65AD\u5F00"},this.EnumEng={0:"0: unknown",1:"1: excellent",2:"2: good",3:"3: fair",4:"4: poor",5:"5: very poor",6:"6: disconnected"};let e=navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||"en";this.isChinese=e.indexOf("zh")>-1,this.attachShadow({mode:"open"})}_initializeTRTC(){this.networkInfo=S.networkInfo,Object.defineProperty(S,"networkInfo",{set:e=>{this.networkInfo=e},get:()=>this.networkInfo})}firstUpdated(){}updated(e){e.has("activeDetector")&&this.activeDetector===this.currentDetector&&this.count!==0&&(this.count=15,this.getDetectorInfo())}async testUplinkNetworkQuality(){let{sdkAppId:e,uplinkTRTC:t,userId:i,userSig:A,roomId:o}=this.networkInfo;try{await t.exitRoom()}catch(s){}await t.enterRoom({roomId:o||8080,sdkAppId:e,userId:i,userSig:A,scene:"rtc"}),!this.hasStartLocalVideo&&await t.startLocalVideo({option:{profile:"480p"}}),this.setHasStartLocalVideo(),this.hasStartLocalVideo=!0,t.on(g.TRTC.EVENT.NETWORK_QUALITY,s=>{let{uplinkNetworkQuality:n,uplinkRTT:r}=s;this.testResult.uplinkNetworkQualities.push(n),this.testResult.rttList.push(r)})}async testDownlinkNetworkQuality(){let{sdkAppId:e,downlinkUserId:t,downlinkTRTC:i,downlinkUserSig:A,roomId:o}=this.networkInfo;try{await i.exitRoom()}catch(s){}await i.enterRoom({roomId:o||8080,sdkAppId:e,userId:t,userSig:A,scene:"rtc"}),i.on(g.TRTC.EVENT.NETWORK_QUALITY,s=>{let{downlinkNetworkQuality:n}=s;this.testResult.downlinkNetworkQualities.push(n)})}async getDetectorInfo(){let e=S.getSystem(),t=await S.isTRTCSupported(),i=S.getAPISupported();this.detectorInfo={system:e.OS,browser:`${e.browser.name} ${e.browser.version}`,TRTCSupport:t.result?"Yes":"No",screenMediaSupport:i.isScreenCaptureAPISupported?"Yes":"No"},this.timer=setInterval(()=>{this.count=this.count-1,this.requestUpdate(),this.count===0&&clearInterval(this.timer)},1e3),this.testUplinkNetworkQuality(),this.isDownlink&&this.testDownlinkNetworkQuality(),setTimeout(async()=>{this.testResult.uplinkNetworkQualities.length>0&&(this.testResult.average.uplinkNetworkQuality=Math.ceil(this.testResult.uplinkNetworkQualities.reduce((A,o)=>A+o,0)/this.testResult.uplinkNetworkQualities.length)),this.testResult.downlinkNetworkQualities.length>0&&(this.testResult.average.downlinkNetworkQuality=Math.ceil(this.testResult.downlinkNetworkQualities.reduce((A,o)=>A+o,0)/this.testResult.downlinkNetworkQualities.length)),this.testResult.rttList.length>0&&(this.testResult.average.rtt=Math.ceil(this.testResult.rttList.reduce((A,o)=>A+o,0)/this.testResult.rttList.length)),this.testResult.average.uplinkNetworkQuality===0||this.isDownlink&&this.testResult.average.downlinkNetworkQuality===0?this.testResult.result.quality=0:this.testResult.result.quality=Math.max(this.testResult.average.uplinkNetworkQuality,this.testResult.average.downlinkNetworkQuality),this.testResult.result.rtt=this.testResult.average.rtt,this.requestUpdate(),await this.networkInfo.uplinkTRTC.
|
|
1215
|
+
`:q``}};h(re,"properties",{audioUrl:{type:String},activeDetector:String,handleComplete:Function,constructTime:{type:Number}});customElements.get("trtc-speaker-detector")||customElements.define("trtc-speaker-detector",re);var ne=class extends E{constructor(){super(),this.NETWORK_QUALITY={},this.currentDetector="network",this.detectorInfo={},this.count=15,this.timer=null,this.networkInfo=null,this.testResult={uplinkNetworkQualities:[],downlinkNetworkQualities:[],rttList:[],average:{uplinkNetworkQuality:0,downlinkNetworkQuality:0,rtt:0},result:{rtt:0,quality:0}},this._initializeTRTC(),this.isDownlink=!1,this.networkInfo&&this.networkInfo.downlinkUserId&&this.networkInfo.downlinkUserSig&&(this.isDownlink=!0),this.Enum={0:"0\uFF1A\u7F51\u7EDC\u72B6\u51B5\u672A\u77E5",1:"1\uFF1A\u7F51\u7EDC\u72B6\u51B5\u6781\u4F73",2:"2\uFF1A\u7F51\u7EDC\u72B6\u51B5\u8F83\u597D",3:"3\uFF1A\u7F51\u7EDC\u72B6\u51B5\u4E00\u822C",4:"4\uFF1A\u7F51\u7EDC\u72B6\u51B5\u8F83\u5DEE",5:"5\uFF1A\u7F51\u7EDC\u72B6\u51B5\u6781\u5DEE",6:"6\uFF1A\u7F51\u7EDC\u8FDE\u63A5\u65AD\u5F00"},this.EnumEng={0:"0: unknown",1:"1: excellent",2:"2: good",3:"3: fair",4:"4: poor",5:"5: very poor",6:"6: disconnected"};let e=navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||"en";this.isChinese=e.indexOf("zh")>-1,this.attachShadow({mode:"open"})}_initializeTRTC(){this.networkInfo=S.networkInfo,Object.defineProperty(S,"networkInfo",{set:e=>{this.networkInfo=e},get:()=>this.networkInfo})}firstUpdated(){}updated(e){e.has("activeDetector")&&this.activeDetector===this.currentDetector&&this.count!==0&&(this.count=15,this.getDetectorInfo())}async testUplinkNetworkQuality(){let{sdkAppId:e,uplinkTRTC:t,userId:i,userSig:A,roomId:o}=this.networkInfo;try{await t.exitRoom()}catch(s){}await t.enterRoom({roomId:o||8080,sdkAppId:e,userId:i,userSig:A,scene:"rtc"}),!this.hasStartLocalVideo&&await t.startLocalVideo({option:{profile:"480p"}}),this.setHasStartLocalVideo(),this.hasStartLocalVideo=!0,t.on(g.TRTC.EVENT.NETWORK_QUALITY,s=>{let{uplinkNetworkQuality:n,uplinkRTT:r}=s;this.testResult.uplinkNetworkQualities.push(n),this.testResult.rttList.push(r)})}async testDownlinkNetworkQuality(){let{sdkAppId:e,downlinkUserId:t,downlinkTRTC:i,downlinkUserSig:A,roomId:o}=this.networkInfo;try{await i.exitRoom()}catch(s){}await i.enterRoom({roomId:o||8080,sdkAppId:e,userId:t,userSig:A,scene:"rtc"}),i.on(g.TRTC.EVENT.NETWORK_QUALITY,s=>{let{downlinkNetworkQuality:n}=s;this.testResult.downlinkNetworkQualities.push(n)})}async getDetectorInfo(){let e=S.getSystem(),t=await S.isTRTCSupported(),i=S.getAPISupported();this.detectorInfo={system:e.OS,browser:`${e.browser.name} ${e.browser.version}`,TRTCSupport:t.result?"Yes":"No",screenMediaSupport:i.isScreenCaptureAPISupported?"Yes":"No"},this.timer=setInterval(()=>{this.count=this.count-1,this.requestUpdate(),this.count===0&&clearInterval(this.timer)},1e3),this.testUplinkNetworkQuality(),this.isDownlink&&this.testDownlinkNetworkQuality(),setTimeout(async()=>{this.testResult.uplinkNetworkQualities.length>0&&(this.testResult.average.uplinkNetworkQuality=Math.ceil(this.testResult.uplinkNetworkQualities.reduce((A,o)=>A+o,0)/this.testResult.uplinkNetworkQualities.length)),this.testResult.downlinkNetworkQualities.length>0&&(this.testResult.average.downlinkNetworkQuality=Math.ceil(this.testResult.downlinkNetworkQualities.reduce((A,o)=>A+o,0)/this.testResult.downlinkNetworkQualities.length)),this.testResult.rttList.length>0&&(this.testResult.average.rtt=Math.ceil(this.testResult.rttList.reduce((A,o)=>A+o,0)/this.testResult.rttList.length)),this.testResult.average.uplinkNetworkQuality===0||this.isDownlink&&this.testResult.average.downlinkNetworkQuality===0?this.testResult.result.quality=0:this.testResult.result.quality=Math.max(this.testResult.average.uplinkNetworkQuality,this.testResult.average.downlinkNetworkQuality),this.testResult.result.rtt=this.testResult.average.rtt,this.requestUpdate(),await this.networkInfo.uplinkTRTC.stopLocalVideo(),this.networkInfo.uplinkTRTC.exitRoom(),this.isDownlink&&this.networkInfo.downlinkTRTC.exitRoom()},15*1e3)}disconnectedCallback(){this.timer&&clearInterval(this.timer),this.remove()}async handleSuccess(){this.hasStartLocalVideo&&await this.networkInfo.uplinkTRTC.stopLocalVideo(),this.generateReport();let e=new Date().getTime();g&&g.kvStatManager.addSuccessEvent({key:591711,cost:e-this.constructTime}),(this.testResult.result.quality===0||this.testResult.result.rtt===0)&&m&&m.warn("NetworkFail",this.testResult.average),this.handleComplete("success",this.testResult.result,this.testResult.result.quality!==0)}render(){return this.activeDetector===this.currentDetector?q`
|
|
1216
1216
|
<style>${f}</style>
|
|
1217
1217
|
<div class="testing-body">
|
|
1218
1218
|
<div class="testing-list">
|