trtc-cloud-js-sdk 1.0.0
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/README.md +1 -0
- package/package.json +22 -0
- package/trtc-cloud-js-sdk.js +1 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
- [接口使用](https://web.sdk.qcloud.com/trtc/webrtc/trtcCloud/doc/TRTCCloud.html)
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "trtc-cloud-js-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Tencent Cloud RTC SDK for Web And Electron",
|
|
5
|
+
"main": "trtc-cloud-js-sdk.js",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"实时音视频",
|
|
8
|
+
"视频通话",
|
|
9
|
+
"音频通话",
|
|
10
|
+
"WEBRTC",
|
|
11
|
+
"直播"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git"
|
|
15
|
+
},
|
|
16
|
+
"author": "Tencent Cloud Client R&D Center",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"axios": "^0.21.1",
|
|
20
|
+
"trtc-js-sdk": "^4.12.7"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var global,factory;global=this,factory=function(e,t,i){function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(i),n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)};function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var s,c,l,u,h,d,m,p,T=function(){return T=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},T.apply(this,arguments)};function v(e,t,i,r){return new(i||(i=Promise))((function(o,n){function a(e){try{c(r.next(e))}catch(t){n(t)}}function s(e){try{c(r.throw(e))}catch(t){n(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function f(e,t){var i,r,o,n,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return n={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function s(n){return function(s){return function(n){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,r&&(o=2&n[0]?r.return:n[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,n[1])).done)return o;switch(r=0,o&&(n=[2&n[0],o.value]),n[0]){case 0:case 1:o=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,r=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==n[0]&&2!==n[0])){a=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]<o[3])){a.label=n[1];break}if(6===n[0]&&a.label<o[1]){a.label=o[1],o=n;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(n);break}o[2]&&a.ops.pop(),a.trys.pop();continue}n=t.call(e,a)}catch(s){n=[6,s],r=0}finally{i=o=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,s])}}}e.TRTCVideoResolution=void 0,(s=e.TRTCVideoResolution||(e.TRTCVideoResolution={}))[s.TRTCVideoResolution_120_120=1]="TRTCVideoResolution_120_120",s[s.TRTCVideoResolution_160_160=3]="TRTCVideoResolution_160_160",s[s.TRTCVideoResolution_270_270=5]="TRTCVideoResolution_270_270",s[s.TRTCVideoResolution_480_480=7]="TRTCVideoResolution_480_480",s[s.TRTCVideoResolution_160_120=50]="TRTCVideoResolution_160_120",s[s.TRTCVideoResolution_240_180=52]="TRTCVideoResolution_240_180",s[s.TRTCVideoResolution_280_210=54]="TRTCVideoResolution_280_210",s[s.TRTCVideoResolution_320_240=56]="TRTCVideoResolution_320_240",s[s.TRTCVideoResolution_400_300=58]="TRTCVideoResolution_400_300",s[s.TRTCVideoResolution_480_360=60]="TRTCVideoResolution_480_360",s[s.TRTCVideoResolution_640_480=62]="TRTCVideoResolution_640_480",s[s.TRTCVideoResolution_960_720=64]="TRTCVideoResolution_960_720",s[s.TRTCVideoResolution_160_90=100]="TRTCVideoResolution_160_90",s[s.TRTCVideoResolution_256_144=102]="TRTCVideoResolution_256_144",s[s.TRTCVideoResolution_320_180=104]="TRTCVideoResolution_320_180",s[s.TRTCVideoResolution_480_270=106]="TRTCVideoResolution_480_270",s[s.TRTCVideoResolution_640_360=108]="TRTCVideoResolution_640_360",s[s.TRTCVideoResolution_960_540=110]="TRTCVideoResolution_960_540",s[s.TRTCVideoResolution_1280_720=112]="TRTCVideoResolution_1280_720",s[s.TRTCVideoResolution_1920_1080=114]="TRTCVideoResolution_1920_1080",e.TRTCVideoStreamType=void 0,(c=e.TRTCVideoStreamType||(e.TRTCVideoStreamType={}))[c.TRTCVideoStreamTypeBig=0]="TRTCVideoStreamTypeBig",c[c.TRTCVideoStreamTypeSmall=1]="TRTCVideoStreamTypeSmall",c[c.TRTCVideoStreamTypeSub=2]="TRTCVideoStreamTypeSub",e.TRTCVideoFillMode=void 0,(l=e.TRTCVideoFillMode||(e.TRTCVideoFillMode={}))[l.TRTCVideoFillMode_Fill=0]="TRTCVideoFillMode_Fill",l[l.TRTCVideoFillMode_Fit=1]="TRTCVideoFillMode_Fit",e.TRTCVideoMirrorType=void 0,(u=e.TRTCVideoMirrorType||(e.TRTCVideoMirrorType={}))[u.TRTCVideoMirrorType_Auto=0]="TRTCVideoMirrorType_Auto",u[u.TRTCVideoMirrorType_Enable=1]="TRTCVideoMirrorType_Enable",u[u.TRTCVideoMirrorType_Disable=2]="TRTCVideoMirrorType_Disable",e.TRTCBeautyStyle=void 0,(h=e.TRTCBeautyStyle||(e.TRTCBeautyStyle={}))[h.TRTCBeautyStyleSmooth=0]="TRTCBeautyStyleSmooth",h[h.TRTCBeautyStyleNature=1]="TRTCBeautyStyleNature",e.TRTCAppScene=void 0,(d=e.TRTCAppScene||(e.TRTCAppScene={}))[d.TRTCAppSceneVideoCall=0]="TRTCAppSceneVideoCall",d[d.TRTCAppSceneLIVE=1]="TRTCAppSceneLIVE",d[d.TRTCAppSceneAudioCall=2]="TRTCAppSceneAudioCall",d[d.TRTCAppSceneVoiceChatRoom=3]="TRTCAppSceneVoiceChatRoom",e.TRTCRoleType=void 0,(m=e.TRTCRoleType||(e.TRTCRoleType={}))[m.TRTCRoleAnchor=20]="TRTCRoleAnchor",m[m.TRTCRoleAudience=21]="TRTCRoleAudience",e.WebRTCAudioQuality=void 0,(p=e.WebRTCAudioQuality||(e.WebRTCAudioQuality={}))[p.WebRTCAudioQualityStandard=0]="WebRTCAudioQualityStandard",p[p.WebRTCAudioQualityHigh=1]="WebRTCAudioQualityHigh",p[p.WebRTCAudioQualityStandardStereo=2]="WebRTCAudioQualityStandardStereo",p[p.WebRTCAudioQualityHighStereo=3]="WebRTCAudioQualityHighStereo";var S,R,y=function(e,t,i,r,o){void 0===e&&(e=""),void 0===t&&(t=""),void 0===i&&(i=""),void 0===r&&(r=""),void 0===o&&(o=""),this.deviceId=e,this.deviceName=t,this.kind=i,this.label=r,this.groupId=o};e.TRTCDeviceState=void 0,(S=e.TRTCDeviceState||(e.TRTCDeviceState={}))[S.TRTCDeviceStateAdd=0]="TRTCDeviceStateAdd",S[S.TRTCDeviceStateRemove=1]="TRTCDeviceStateRemove",S[S.TRTCDeviceStateActive=2]="TRTCDeviceStateActive",e.TRTCDeviceType=void 0,(R=e.TRTCDeviceType||(e.TRTCDeviceType={}))[R.TRTCDeviceTypeUnknow=-1]="TRTCDeviceTypeUnknow",R[R.TRTCDeviceTypeMic=0]="TRTCDeviceTypeMic",R[R.TRTCDeviceTypeSpeaker=1]="TRTCDeviceTypeSpeaker",R[R.TRTCDeviceTypeCamera=2]="TRTCDeviceTypeCamera";var C,b=function(t,i,r,o,n,a,s,c,l,u){void 0===t&&(t=0),void 0===i&&(i=""),void 0===r&&(r=""),void 0===o&&(o=0),void 0===n&&(n=""),void 0===a&&(a=e.TRTCRoleType.TRTCRoleAnchor),void 0===s&&(s=null),void 0===l&&(l=null),void 0===u&&(u=null),this.sdkAppId=t,this.userId=i,this.userSig=r,this.roomId=o,this.strRoomId=n,this.role=a,this.privateMapKey=s,this.streamId=l,this.userDefineRecordId=u},g=function(t,i,r){void 0===t&&(t=e.TRTCVideoResolution.TRTCVideoResolution_640_360),void 0===i&&(i=15),void 0===r&&(r=550),this.videoResolution=t,this.videoFps=i,this.videoBitrate=r};e.TRTCVideoRotation=void 0,(C=e.TRTCVideoRotation||(e.TRTCVideoRotation={}))[C.TRTCVideoRotation_0=0]="TRTCVideoRotation_0",C[C.TRTCVideoRotation_90=1]="TRTCVideoRotation_90",C[C.TRTCVideoRotation_180=2]="TRTCVideoRotation_180",C[C.TRTCVideoRotation_270=3]="TRTCVideoRotation_270";var V,A=function(t,i,r){void 0===t&&(t=e.TRTCVideoRotation.TRTCVideoRotation_0),void 0===i&&(i=e.TRTCVideoFillMode.TRTCVideoFillMode_Fit),void 0===r&&(r=e.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable),this.rotation=t,this.fillMode=i,this.mirrorType=r};e.TRTCNetQuality=void 0,(V=e.TRTCNetQuality||(e.TRTCNetQuality={}))[V.TRTCNetQuality_Unknown=0]="TRTCNetQuality_Unknown",V[V.TRTCNetQuality_Excellent=1]="TRTCNetQuality_Excellent",V[V.TRTCNetQuality_Good=2]="TRTCNetQuality_Good",V[V.TRTCNetQuality_Poor=3]="TRTCNetQuality_Poor",V[V.TRTCNetQuality_Bad=4]="TRTCNetQuality_Bad",V[V.TRTCNetQuality_Vbad=5]="TRTCNetQuality_Vbad",V[V.TRTCNetQuality_Down=6]="TRTCNetQuality_Down";var w,_=function(t,i,r,o,n,a,s){void 0===t&&(t=""),void 0===i&&(i=e.TRTCNetQuality.TRTCNetQuality_Unknown),this.userId=t,this.quality=i,this.uplinkNetworkQuality=r,this.uplinkRTT=o,this.uplinkLoss=n,this.downlinkRTT=a,this.downlinkLoss=s},P=function(e,t){void 0===e&&(e=""),void 0===t&&(t=0),this.userId=e,this.volume=t},I=function(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=null),this.appId=e,this.bizId=t,this.url=i},M=function(t,i,r,o,n,a,s){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=0),void 0===n&&(n=0),void 0===a&&(a=0),void 0===s&&(s=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig),this.width=t,this.height=i,this.frameRate=r,this.videoBitrate=o,this.audioSampleRate=n,this.audioBitrate=a,this.streamType=s},E=function(e,t,i,r,o,n,a,s,c,l){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=0),void 0===n&&(n=0),void 0===a&&(a=0),void 0===s&&(s=[]),void 0===c&&(c=0),void 0===l&&(l=0),this.upLoss=e,this.downLoss=t,this.appCpu=i,this.systemCpu=r,this.rtt=o,this.receivedBytes=n,this.sentBytes=a,this.localStatisticsArray=s,this.localStatisticsArraySize=c,this.remoteStatisticsArraySize=l},L="default",D="video",k="audio",U="onError",F="main",O="rtc",N="live",Q="anchor",J="audience",x="auxiliary",B="share_",j={20:Q,21:J},W={0:O,1:N,2:O,3:N},z={0:"standard",1:"high",2:"standard_stereo",3:"high_stereo"},H={0:"big",1:"small",2:x};function K(){return Math.floor(performance.now())}!function(e){e[e.ActiveExitRoom=0]="ActiveExitRoom",e[e.KickedExitRoom=1]="KickedExitRoom"}(w||(w={}));var q=function(e){return void 0===e};function G(e){return"".concat(e,"-main")}function X(e){return"".concat(e,"-").concat(x)}function Y(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var i=function(){for(var t=0,i=e;t<i.length;t++)Z(this,new(0,i[t])(this))},r=i.prototype,o=0,n=e;o<n.length;o++){var a=n[o];Z(i,a),Z(r,a.prototype)}return i}function Z(e,t){for(var i=0,r=Reflect.ownKeys(t);i<r.length;i++){var o=r[i];if("constructor"!==o&&"prototype"!==o&&"name"!==o){var n=Object.getOwnPropertyDescriptor(t,o)||"";Object.defineProperty(e,o,n)}}}function $(e,t){return void 0===e&&(e=""),t==="share_".concat(e)}var ee=function(t){function i(){var i=t.call(this)||this;return i.startJoinTimestamp=0,i.joinedTimestamp=0,i.playViewMap=new Map,i.cameraList=[],i.micList=[],i.speakerList=[],i.currentCameraId="",i.currentMicId="",i.currentSpeakerId="",i.isJoining=!1,i.isJoined=!1,i.isExiting=!1,i.isPublishing=!1,i.isPublished=!1,i.isSubscribed=!1,i.userId="",i.userSig="",i.roomId=0,i.strRoomId="",i.mode=O,i.role=Q,i.privateMapKey="255",i.streamId="",i.isSmallStreamSupported=!1,i.shareUserId="",i.shareUserSig="",i.isSharing=!1,i.isShareClientJoined=!1,i.isShareStreamPublished=!1,i.isShareClientLeaving=!1,i.isStaringLocalPreview=!1,i.isStartedLocalPreview=!1,i.isStaringLocalAudio=!1,i.isStartedLocalAudio=!1,i.defaultVideoWidth=640,i.defaultVideoHeight=480,i.defaultVideoFps=15,i.defaultVideoBitRate=900,i.defaultShareWidth=1920,i.defaultShareHeight=1080,i.defaultShareFrameRate=15,i.defaultShareBitrate=1500,i.prevLocalVideoStats={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},i.beautyDefaultBeauty=.5,i.beautyDefaultBrightness=.5,i.beautyDefaultRuddy=.5,i.TRTC=o.default,i.audioQuality=e.WebRTCAudioQuality.WebRTCAudioQualityStandard,i.priorRemoteVideoStreamType=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig,i.remoteStreamMap=new Map,i.isSmallStreamSupported=o.default&&o.default.isSmallStreamSupported()||!1,i.videoEncodeParam={width:i.defaultVideoWidth,height:i.defaultVideoHeight,frameRate:i.defaultVideoFps,bitrate:i.defaultVideoBitRate},i.screenShareParams={width:i.defaultShareWidth,height:i.defaultShareHeight,frameRate:i.defaultShareFrameRate,bitrate:i.defaultShareBitrate},i}return a(i,t),i.prototype.promiseRetry=function(e){var t=this,i=e.retryFunction,r=e.settings,o=e.onError,n=e.onRetrying,a=e.context;return function(){for(var e=[],s=0;s<arguments.length;s++)e[s]=arguments[s];var c=r.retries||5,l=0,u=-1,h=0,d=function(s,m){return v(t,void 0,void 0,(function(){var t,p,T,v,S;return f(this,(function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),t=a||this,[4,i.apply(t,e)];case 1:return p=f.sent(),l=0,s(p),[3,3];case 2:return T=f.sent(),v=function(){clearTimeout(u),l=0,h=2,m(T)},S=function(){2!==h&&l<c?(l++,h=1,n&&n(l,v),u=window.setTimeout((function(){u=-1,d(s,m)}),void 0===r.timeout?1e3:r.timeout)):v()},o?o(T,S,m):S(),[3,3];case 3:return[2]}}))}))};return new Promise(d)}},i}(t.EventEmitter),te=-1e3,ie={code:-1001,message:"参数错误, 请检查参数格式、是否非空等"},re={code:-1002,message:"进房失败:进房中或已进房"},oe={code:-1003,message:"退房失败:未进房或退房中"},ne={code:-1004,message:"调用该函数所需要条件不满足"},ae={code:-1005,message:"not supported"},se={code:-1006,message:"not supported before join room"},ce=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t.prototype.startPublishing=function(e,t){return v(this,void 0,void 0,(function(){var t,i;return f(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.isPublished?this.client?(t={streamId:e},[4,this.client.startPublishCDNStream(t)]):(this.log_.error("(startPublishing) failed - ".concat(this.client)),this.emitError({conditionsError:ne,message:"".concat(ne.message," - client = ").concat(this.client)}),[2]):(this.log_.error("(startPublishing) failed - ".concat(this.isPublished)),this.emitError({conditionsError:ne,message:"".concat(ne.message," - isPublished = ").concat(this.isPublished)}),[2]);case 1:return r.sent(),[3,3];case 2:return i=r.sent(),this.callFunctionErrorManage(i,"startPublishing"),[3,3];case 3:return[2]}}))}))},t.prototype.stopPublishing=function(){return v(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.client?[4,this.client.stopPublishCDNStream()]:(this.log_.error("(stopPublishing) failed - ".concat(this.client)),this.emitError({conditionsError:ne,message:"".concat(ne.message," - client = ").concat(this.client)}),[2]);case 1:return t.sent(),[3,3];case 2:return e=t.sent(),this.callFunctionErrorManage(e,"stopPublishing"),[3,3];case 3:return[2]}}))}))},t.prototype.startPublishCDNStream=function(e){return v(this,void 0,void 0,(function(){var t,i,r,o,n;return f(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),e instanceof I?(t=e.appId,i=e.bizId,r=e.url,o={appId:t,bizId:i,url:r},[4,this.client.startPublishCDNStream(o)]):[3,2];case 1:return a.sent(),[3,3];case 2:this.log_.error("(startPublishCDNStream) failed - ".concat(JSON.stringify(e))),this.emitError(ie),a.label=3;case 3:return[3,5];case 4:return n=a.sent(),this.callFunctionErrorManage(n,"startPublishCDNStream"),[3,5];case 5:return[2]}}))}))},t.prototype.stopPublishCDNStream=function(){return v(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.client?[4,this.client.stopPublishCDNStream()]:(this.log_.error("(stopPublishCDNStream) failed - ".concat(this.client)),this.emitError({conditionsError:ne,message:"".concat(ne.message," - client = ").concat(this.client)}),[2]);case 1:return t.sent(),[3,3];case 2:return e=t.sent(),this.callFunctionErrorManage(e,"stopPublishCDNStream"),[3,3];case 3:return[2]}}))}))},t}(Y(ee)),le=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return a(i,t),i.prototype.startLocalPreview=function(e){return v(this,void 0,void 0,(function(){var t;return f(this,(function(i){switch(i.label){case 0:this.log_.info("(startLocalPreview) start - start local preview",e),i.label=1;case 1:return i.trys.push([1,3,,4]),this.localStreamHasVideoOrAudio(D)?(this.playStream(this.localStream,e),[2]):[4,this.promiseRetry({retryFunction:this.doStartLocalPreview,settings:{retries:6,timeout:1e3}})(e)];case 2:return i.sent(),[3,4];case 3:return t=i.sent(),this.isStaringLocalPreview=!1,this.callFunctionErrorManage(t,"startLocalPreview"),[3,4];case 4:return[2]}}))}))},i.prototype.doStartLocalPreview=function(e){return v(this,void 0,void 0,(function(){var t,i,r;return f(this,(function(o){switch(o.label){case 0:if(this.isStaringLocalAudio)throw new Error("startLocalAudio is under implementation.");return this.isStaringLocalPreview=!0,q(e)?[3,10]:null===e?[3,9]:(t={userId:this.client&&"".concat(this.client.getUserId()," video")||"video undefined",video:!0,audio:!1,screenAudio:!1},this.currentCameraId&&(t.cameraId=this.currentCameraId),this.localStream?(i=this.TRTC.createStream(t),this.videoEncodeParam?[4,i.setVideoProfile(this.videoEncodeParam)]:[3,2]):[3,5]);case 1:o.sent(),o.label=2;case 2:return[4,i.initialize()];case 3:return o.sent(),r=i.getVideoTrack(),[4,this.localStream.addTrack(r)];case 4:return o.sent(),[3,7];case 5:return[4,this.initStream(t)];case 6:o.sent(),o.label=7;case 7:return this.isStartedLocalPreview=!0,this.localStream&&(this.playStream(this.localStream,e,this.localStreamRenderParams),this.clearTempAudioContainer("localAudio")),[4,this.publishLocalStream()];case 8:o.sent(),this.isStaringLocalPreview=!1,o.label=9;case 9:return[3,11];case 10:this.emitError(ie),this.log_.error("(startLocalPreview) failed - ".concat(ie.message,": ").concat(e)),o.label=11;case 11:return[2]}}))}))},i.prototype.stopLocalPreview=function(){return v(this,void 0,void 0,(function(){var e=this;return f(this,(function(t){return this.log_.info("(stopLocalPreview) stop - stop local preview"),this.isStartedLocalPreview?[2,new Promise((function(t,i){return v(e,void 0,void 0,(function(){var e,r,o=this;return f(this,(function(n){switch(n.label){case 0:return n.trys.push([0,4,,5]),this.localStream?this.localStream.getAudioTrack()?((e=this.localStream.getVideoTrack())&&this.localStream.removeTrack(e).then((function(){e.stop(),o.isStartedLocalPreview=!1,t(1)})),[3,3]):[3,1]:[3,3];case 1:return[4,this.unPublishStream()];case 2:n.sent(),this.localStream.stop(),this.localStream.close(),this.localStream=null,this.isStartedLocalPreview=!1,t(1),n.label=3;case 3:return[3,5];case 4:return r=n.sent(),this.callFunctionErrorManage(r,"stopLocalPreview"),i(r),[3,5];case 5:return[2]}}))}))}))]:(this.log_.info("(stopLocalPreview) stop - local preview has not been started"),[2])}))}))},i.prototype.muteLocalVideo=function(e){void 0===e&&(e=!1);try{this.localStream&&(e?this.localStream.muteVideo():this.localStream.unmuteVideo())}catch(t){this.callFunctionErrorManage(t,"muteLocalVideo")}},i.prototype.startRemoteView=function(t,i,r){return v(this,void 0,void 0,(function(){var o,n,a,s,c;return f(this,(function(l){switch(l.label){case 0:return l.trys.push([0,7,,8]),t&&!q(i)&&r in e.TRTCVideoStreamType?(o=r,n=G(t),r===e.TRTCVideoStreamType.TRTCVideoStreamTypeSub?(n=X("".concat(B).concat(t)),this.remoteStreamMap.has(n)||(n=X(t)),o=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig):this.isSmallStreamSupported||(o=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig),a=H[o],this.remoteStreamMap.has(n)?(s=this.remoteStreamMap.get(n),a===x?[3,3]:this.client?[4,this.client.setRemoteVideoStreamType(s,o)]:[3,2]):[3,6]):(this.emitError(ie),this.log_.error("(startRemoteView) failed - ".concat(ie.message,": ").concat(i)),[2]);case 1:l.sent(),l.label=2;case 2:l.label=3;case 3:return s?[4,this.client.subscribe(s,{audio:!0,video:!0})]:[3,6];case 4:return l.sent(),[4,this.playStream(s,i)];case 5:l.sent(),this.clearTempAudioContainer("".concat(n,"_dom")),l.label=6;case 6:return[3,8];case 7:return c=l.sent(),this.callFunctionErrorManage(c,"startRemoteView"),[3,8];case 8:return[2]}}))}))},i.prototype.stopRemoteView=function(t,i){return v(this,void 0,void 0,(function(){var r,o,n,a;return f(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),r=G(t),o=i,q(i)||(o=this.priorRemoteVideoStreamType),console.log("stopRemoteView streamType: ",o),i===e.TRTCVideoStreamType.TRTCVideoStreamTypeSub&&(r=X("".concat(B).concat(t)),this.remoteStreamMap.has(r)||(r=X(t))),this.remoteStreamMap.has(r)?(n=this.remoteStreamMap.get(r),i!==e.TRTCVideoStreamType.TRTCVideoStreamTypeSub?[3,1]:[3,3]):[3,3];case 1:return[4,this.client.subscribe(n,{audio:!0,video:!1})];case 2:s.sent(),s.label=3;case 3:return[3,5];case 4:return a=s.sent(),this.callFunctionErrorManage(a,"stopRemoteView"),[3,5];case 5:return[2]}}))}))},i.prototype.muteRemoteVideoStream=function(e,t){void 0===t&&(t=!1);try{if(!e)return this.emitError(ie),void this.log_.error("(muteRemoteVideoStream) failed - ".concat(ie.message,": userId = ").concat(e));var i=this.remoteStreamMap.get(G(e));i&&(t?i.muteVideo():i.unmuteVideo())}catch(r){this.callFunctionErrorManage(r,"stopRemoteView")}},i.prototype.setVideoEncoderParam=function(e){return v(this,void 0,void 0,(function(){var t,i,r;return f(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this.videoEncodeParam,e.videoResolution&&(i=this.getResolution(e.videoResolution),t.width=i.width,t.height=i.height),e.videoFps&&(t.frameRate=e.videoFps),e.videoBitrate&&(t.bitrate=e.videoBitrate),this.videoEncodeParam=t,[4,this.setStreamVideoParam(this.videoEncodeParam)];case 1:return o.sent(),[3,3];case 2:return r=o.sent(),this.callFunctionErrorManage(r,"setVideoEncoderParam"),[3,3];case 3:return[2]}}))}))},i.prototype.setLocalRenderParams=function(t){try{var i={};t.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable&&(i.mirror=!0),t.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable&&(i.mirror=!1),t.fillMode===e.TRTCVideoFillMode.TRTCVideoFillMode_Fill&&(i.objectFit="cover"),t.fillMode===e.TRTCVideoFillMode.TRTCVideoFillMode_Fit&&(i.objectFit="contain"),this.localStreamRenderParams=i;var r=this.playViewMap.get("".concat(this.localStream.getUserId(),"_").concat(this.localStream.getType()));this.playStream(this.localStream,r,i)}catch(o){this.callFunctionErrorManage(o,"setLocalRenderParams")}},i.prototype.setRemoteRenderParams=function(t,i,r){return v(this,void 0,void 0,(function(){var o,n,a,s,c;return f(this,(function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),o={},n=H[i||e.TRTCVideoStreamType.TRTCVideoStreamTypeBig],r.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable&&(o.mirror=!0),r.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable&&(o.mirror=!1),r.fillMode===e.TRTCVideoFillMode.TRTCVideoFillMode_Fill&&(o.objectFit="cover"),r.fillMode===e.TRTCVideoFillMode.TRTCVideoFillMode_Fit&&(o.objectFit="contain"),a=this.playViewMap.get("".concat(t,"_").concat(n)),s=this.remoteStreamMap.get("".concat(t,"-").concat(n)),[4,this.playStream(s,a,o)];case 1:return l.sent(),[3,3];case 2:return c=l.sent(),this.callFunctionErrorManage(c,"setRemoteRenderParams"),[3,3];case 3:return[2]}}))}))},i}(Y(ee)),ue=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return a(i,t),i.prototype.startLocalAudio=function(e){return v(this,void 0,void 0,(function(){var t;return f(this,(function(i){switch(i.label){case 0:this.log_.info("(startLocalAudio) start - start local audio"),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.promiseRetry({retryFunction:this.doStartLocalAudio,settings:{retries:6,timeout:1e3}})(e)];case 2:return i.sent(),[3,4];case 3:return t=i.sent(),this.callFunctionErrorManage(t,"startLocalAudio"),[3,4];case 4:return[2]}}))}))},i.prototype.doStartLocalAudio=function(t){return v(this,void 0,void 0,(function(){var i,r,o,n,a;return f(this,(function(s){switch(s.label){case 0:if(this.isStaringLocalPreview)throw new Error("startLocalPreview is under implementation.");s.label=1;case 1:return s.trys.push([1,10,,11]),this.isStaringLocalAudio=!0,i=t,q(t)||(i=this.audioQuality),r={userId:this.client&&"".concat(this.client.getUserId()," audio")||"audio undefined",video:!1,audio:!0,screenAudio:!1},this.currentMicId&&(r.microphoneId=this.currentMicId),(o=this.TRTC.createStream(r)).setAudioProfile(z[i||e.WebRTCAudioQuality.WebRTCAudioQualityStandard]),[4,o.initialize()];case 2:return s.sent(),n=o.getAudioTrack(),this.localStream?(this.muteLocalAudio(!1),this.localStream.getAudioTrack()?[4,this.localStream.replaceTrack(n)]:[3,4]):[3,7];case 3:return s.sent(),[3,6];case 4:return[4,this.localStream.addTrack(n)];case 5:s.sent(),s.label=6;case 6:return[3,8];case 7:this.localStream=o,a=this.generateTempAudioContainer("localAudio"),this.localStream.play(a),s.label=8;case 8:return this.isStartedLocalAudio=!0,[4,this.publishLocalStream()];case 9:return s.sent(),this.isStaringLocalAudio=!1,this.isPublished||this.getLocalStreamAudioLevel(),[3,11];case 10:throw s.sent();case 11:return[2]}}))}))},i.prototype.getLocalStreamAudioLevel=function(){var e=this;this.enableAudioVolumeInterval&&(this.enableAudioVolumeTimer=setInterval((function(){var t=[],i=Math.floor(100*e.localStream.getAudioLevel());t.push({userId:"local",audioVolume:i,stream:e.localStream}),e.emit("onUserVoiceVolume",t)}),this.enableAudioVolumeInterval))},i.prototype.generateTempAudioContainer=function(e){var t=document.createElement("div");return t.id=e,t.style.width="0",t.style.height="0",document.getElementsByTagName("body")[0].appendChild(t),t},i.prototype.clearTempAudioContainer=function(e){var t=document.getElementById(e);t&&document.getElementsByTagName("body")[0].removeChild(t)},i.prototype.stopLocalAudio=function(){return v(this,void 0,void 0,(function(){var e=this;return f(this,(function(t){return this.log_.info("(stopLocalAudio) stop - stop local audio"),this.isStartedLocalAudio?[2,new Promise((function(t,i){return v(e,void 0,void 0,(function(){var e,r;return f(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),this.localStream?(this.enableAudioVolumeTimer&&clearInterval(this.enableAudioVolumeTimer),this.localStream.getVideoTrack()?((e=this.localStream.getAudioTrack())&&(this.muteLocalAudio(!0),e.stop(),this.isStartedLocalAudio=!1,t(1)),[3,3]):[3,1]):[3,3];case 1:return[4,this.unPublishStream()];case 2:o.sent(),this.localStream.stop(),this.localStream.close(),this.clearTempAudioContainer("localAudio"),this.localStream=null,this.isStartedLocalAudio=!1,t(1),o.label=3;case 3:return[3,5];case 4:return r=o.sent(),this.callFunctionErrorManage(r,"stopLocalAudio"),i(r),[3,5];case 5:return[2]}}))}))}))]:(this.log_.info("(stopLocalAudio) stop - local audio has not been started"),[2])}))}))},i.prototype.muteLocalAudio=function(e){void 0===e&&(e=!1);try{this.localStream&&(e?this.localStream.muteAudio():this.localStream.unmuteAudio())}catch(t){this.callFunctionErrorManage(t,"muteLocalAudio")}},i.prototype.muteRemoteAudio=function(e,t){void 0===t&&(t=!1);try{if(!e)return this.emitError(ie),void this.log_.error("(muteRemoteVideoStream) failed - ".concat(ie.message,": userId = ").concat(e));var i=this.remoteStreamMap.get(G(e));i&&(t?i.muteAudio():i.unmuteAudio())}catch(r){this.callFunctionErrorManage(r,"muteRemoteAudio")}},i.prototype.muteAllRemoteAudio=function(e){try{this.remoteStreamMap.size>0&&Array.from(this.remoteStreamMap,(function(e){return e[1]})).forEach((function(t){t&&(e?t.muteAudio():t.unmuteAudio())}))}catch(t){this.callFunctionErrorManage(t,"muteAllRemoteAudio")}},i.prototype.setRemoteAudioVolume=function(e,t){try{if(!e||t<0)return this.emitError(ie),void this.log_.error("(muteRemoteVideoStream) failed - ".concat(ie.message,": userId = ").concat(e,", volume = ").concat(t));var i=this.remoteStreamMap.get(G(e));if(i){var r=t>100?1:t/100;i.setAudioVolume(r)}}catch(o){this.callFunctionErrorManage(o,"setRemoteAudioVolume")}},i.prototype.getAudioCaptureVolume=function(){try{return this.localStream?100*this.localStream.getAudioLevel():(this.log_.warn("(getAudioCaptureVolume) failed - localStream = ".concat(this.localStream)),0)}catch(e){return this.callFunctionErrorManage(e,"getAudioCaptureVolume"),0}},i}(Y(ee)),he=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return a(i,t),i.prototype.getCameraDevicesList=function(){return v(this,void 0,Promise,(function(){var e,t;return f(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.TRTC.getCameras()];case 1:return e=i.sent(),this.cameraList=e.map((function(e){return T(T({},e),{deviceName:e.label})})),[2,Promise.resolve(this.cameraList)];case 2:return t=i.sent(),this.callFunctionErrorManage(t,"getCameraDevicesList"),this.cameraList=[],[2,Promise.resolve([])];case 3:return[2]}}))}))},i.prototype.setCurrentCameraDevice=function(t){return v(this,void 0,Promise,(function(){var i;return f(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),t?(this.currentCameraId=t||"",this.localStream?[4,this.localStream.switchDevice(D,t)]:[3,2]):[2,Promise.resolve(!1)];case 1:r.sent(),this.emitOnDeviceChange(t,e.TRTCDeviceType.TRTCDeviceTypeCamera,e.TRTCDeviceState.TRTCDeviceStateActive),r.label=2;case 2:return[2,Promise.resolve(!0)];case 3:return i=r.sent(),this.callFunctionErrorManage(i,"setCurrentCameraDevice"),this.cameraList=[],[2,Promise.resolve(!1)];case 4:return[2]}}))}))},i.prototype.getCurrentCameraDevice=function(){var e=this;return(this.cameraList||[]).filter((function(t){return t.deviceId===e.currentCameraId}))[0]||{}},i}(Y(ee)),de=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return a(i,t),i.prototype.getMicDevicesList=function(){return v(this,void 0,Promise,(function(){var e,t;return f(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.TRTC.getMicrophones()];case 1:return e=i.sent(),this.micList=e.map((function(e){return T(T({},e),{deviceName:e.label})})),[2,Promise.resolve(this.micList)];case 2:return t=i.sent(),this.callFunctionErrorManage(t,"getMicDevicesList"),[2,Promise.resolve([])];case 3:return[2]}}))}))},i.prototype.getCurrentMicDevice=function(){var e=this;return this.currentMicId?(this.micList||[]).filter((function(t){return t.deviceId===e.currentMicId}))[0]||{}:new y},i.prototype.setCurrentMicDevice=function(t){return v(this,void 0,Promise,(function(){var i;return f(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),t?this.localStream?this.localStream&&this.currentMicId!==t?[4,this.localStream.switchDevice(k,t)]:[3,2]:[2,Promise.resolve(!0)]:[2,Promise.resolve(!1)];case 1:return r.sent(),this.currentMicId=t||"",this.emitOnDeviceChange(t,e.TRTCDeviceType.TRTCDeviceTypeMic,e.TRTCDeviceState.TRTCDeviceStateActive),[2,Promise.resolve(!0)];case 2:return[2,Promise.resolve(!0)];case 3:return i=r.sent(),this.callFunctionErrorManage(i,"setCurrentMicDevice"),[2,Promise.resolve(!1)];case 4:return[2]}}))}))},i.prototype.getSpeakerDevicesList=function(){return v(this,void 0,Promise,(function(){var e,t;return f(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.TRTC.getSpeakers()];case 1:return e=i.sent(),this.speakerList=e.map((function(e){return T(T({},e),{deviceName:e.label})})),[2,Promise.resolve(this.speakerList)];case 2:return t=i.sent(),this.callFunctionErrorManage(t,"getSpeakerDevicesList"),[2,Promise.resolve([])];case 3:return[2]}}))}))},i.prototype.getCurrentSpeakerDevice=function(){var e=this;return this.currentSpeakerId?(this.speakerList||[]).filter((function(t){return t.deviceId===e.currentSpeakerId}))[0]||{}:new y},i.prototype.setCurrentSpeakerDevice=function(e){return v(this,void 0,Promise,(function(){var t,i,r=this;return f(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),e?(this.currentSpeakerId=e||"",this.remoteStreamMap.size>0?(t=this.getRemoteStreamList(),[4,Promise.all(t.map((function(e){return v(r,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,e.setAudioOutput(this.currentSpeakerId)];case 1:return[2,t.sent()]}}))}))})))]):[3,2]):[2,Promise.resolve(!1)];case 1:return o.sent(),[2,Promise.resolve(!0)];case 2:return[2,Promise.resolve(!0)];case 3:return i=o.sent(),this.callFunctionErrorManage(i,"setCurrentSpeakerDevice"),[2,Promise.resolve(!1)];case 4:return[2]}}))}))},i}(Y(ee)),me=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t.prototype.startScreenCapture=function(){this.emitError(ae)},t.prototype.pauseScreenCapture=function(){this.emitError(ae)},t.prototype.resumeScreenCapture=function(){this.emitError(ae)},t.prototype.getScreenCaptureSources=function(){this.emitError(ae)},t.prototype.selectScreenCaptureTarget=function(){this.emitError(ae)},t.prototype.initShareClient=function(e,t){return v(this,void 0,void 0,(function(){var i,r;return f(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),i=this,[4,this.TRTC.createClient({mode:"rtc",sdkAppId:this.sdkAppId,userId:e,userSig:t,autoSubscribe:!1})];case 1:return i.shareClient=o.sent(),console.log("ShareClient [".concat(e,"] created.")),this.installShareClientEventHandlers(),[3,3];case 2:throw r=o.sent(),console.error("Failed to create Client [".concat(e,"].")),r;case 3:return[2]}}))}))},t.prototype.installShareClientEventHandlers=function(){this.shareClient.on("error",this.handleShareClientError.bind(this)),this.shareClient.on("client-banned",this.handleShareClientBanned.bind(this)),this.shareClient.on("stream-subscribed",this.handleShareClientStreamSubscribed.bind(this))},t.prototype.handleShareClientError=function(e){console.error("ShareClient error:",e)},t.prototype.handleShareClientBanned=function(e){console.error("ShareClient has been banned for:",e)},t.prototype.handleShareClientStreamSubscribed=function(e){var t=e.stream,i=t.getId(),r=t.getUserId();console.log("remote stream received and unsubscribed: [".concat(r,"] ID: ").concat(i," type: ").concat(t.getType())),this.shareClient.unsubscribe(t)},t.prototype.initShareStream=function(){return v(this,void 0,void 0,(function(){var e,t=this;return f(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.shareStream=this.TRTC.createStream({audio:!1,screen:!0,userId:this.shareUserId}),this.shareStream.setScreenProfile(this.screenShareParams),[4,this.shareStream.initialize()];case 1:return i.sent(),this.shareStream.on("screen-sharing-stopped",(function(){console.log("ShareStream video track ended"),t.emit("onWebScreenSharingStopped"),t.shareClientLeave()})),[2,this.shareStream];case 2:throw e=i.sent(),console.error("ShareStream failed to initialize. Error: ".concat(e)),e;case 3:return[2]}}))}))},t.prototype.shareClientJoin=function(e,t){return v(this,void 0,void 0,(function(){var i;return f(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),this.shareClient?[3,2]:[4,this.initShareClient(e,t)];case 1:r.sent(),r.label=2;case 2:return[4,this.shareClient.join({roomId:this.roomId})];case 3:return r.sent(),this.isShareClientJoined=!0,[3,5];case 4:throw i=r.sent(),console.error("ShareClient join room failed:",i),i;case 5:return[2]}}))}))},t.prototype.shareClientPublish=function(){return v(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:if(!this.isShareClientJoined)return console.warn("ShareClient cannot publish() - please join() firstly"),[2];if(this.isShareStreamPublished)return console.warn("ShareClient duplicate publish() observed"),[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.shareClient.publish(this.shareStream)];case 2:return t.sent(),console.log("ShareStream is published successfully"),this.isShareStreamPublished=!0,[3,4];case 3:throw e=t.sent(),console.error("ShareStream is failed to publish. Error: ".concat(e)),e;case 4:return[2]}}))}))},t.prototype.shareClientUnpublish=function(){return v(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:if(!this.isShareClientJoined)return console.warn("ShareClient cannot unpublish() - please join() firstly"),[2];if(!this.isShareStreamPublished)return console.warn("ShareClient cannot unpublish() - you have not published yet"),[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.shareStream?[4,this.shareClient.unpublish(this.shareStream)]:[3,3];case 2:t.sent(),t.label=3;case 3:return this.isShareStreamPublished=!1,console.log("Unpublish ShareStream success"),[3,5];case 4:throw e=t.sent(),console.error("unpublish failed",e),e;case 5:return[2]}}))}))},t.prototype.shareClientLeave=function(){return v(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this.isShareClientJoined?this.isShareClientLeaving?(console.warn("ShareClient duplicate leave() observed"),[2]):this.isShareStreamPublished?[4,this.shareClientUnpublish()]:[3,2]:(console.warn("ShareClient cannot leave() - please join() firstly"),[2]);case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),this.isShareClientLeaving=!0,[4,this.shareClient.leave()];case 3:return t.sent(),this.isShareClientJoined=!1,console.log("ShareClient leave room success"),this.shareStream&&(this.shareStream.stop(),this.shareStream.close(),this.shareStream=null),this.isShareClientLeaving=!1,[3,5];case 4:throw e=t.sent(),console.error("ShareClient leave failed:",e),e;case 5:return[2]}}))}))},t.prototype.startScreenShare=function(e){return v(this,void 0,void 0,(function(){var t,i,r,o,n;return f(this,(function(a){switch(a.label){case 0:if(!this.isJoined||this.isJoining)return this.emitError(se),[2];if(t=e.shareUserId,i=void 0===t?"":t,r=e.shareUserSig,o=void 0===r?"":r,!i||!o||i.slice(0,6)!==B)return this.emitError(ie),[2];this.shareUserId=i,this.shareUserSig=o,a.label=1;case 1:return a.trys.push([1,5,,6]),[4,this.initShareStream()];case 2:return a.sent(),[4,this.shareClientJoin(i,o)];case 3:return a.sent(),[4,this.shareClientPublish()];case 4:return a.sent(),console.log("Start share screen success"),this.isSharing=!0,[3,6];case 5:throw n=a.sent(),console.error("Start share screen error:",n),n;case 6:return[2]}}))}))},t.prototype.setSubStreamEncoderParam=function(e){var t=e.videoResolution,i=e.videoFps,r=e.videoBitrate;try{var o=this.getResolution(t);this.screenShareParams={width:o.width,height:o.height,frameRate:i,bitrate:r}}catch(n){throw n}},t.prototype.stopScreenShare=function(){return v(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),[4,this.shareClientUnpublish()];case 1:return t.sent(),[4,this.shareClientLeave()];case 2:return t.sent(),this.isSharing=!1,[3,4];case 3:throw e=t.sent(),console.error("Stop screen share error:",e),e;case 4:return[2]}}))}))},t}(Y(ee)),pe=null,Te=function(t){function i(){var e,i,r,o=t.call(this)||this;return o.logPrefix="universal",o.enableAudioVolumeInterval=0,o.enableAudioVolumeTimer=-1,o.VERSION="1.0.0",o.log_=o.TRTC.Logger.loggerManager,o.handleError=o.handleError.bind(o),o.handlePeerJoin=o.handlePeerJoin.bind(o),o.handlePeerLeave=o.handlePeerLeave.bind(o),o.handleStreamAdded=o.handleStreamAdded.bind(o),o.handleStreamSubscribed=o.handleStreamSubscribed.bind(o),o.handleStreamRemoved=o.handleStreamRemoved.bind(o),o.handleStreamUpdated=o.handleStreamUpdated.bind(o),o.handleMuteAudio=o.handleMuteAudio.bind(o),o.handleUnmuteAudio=o.handleUnmuteAudio.bind(o),o.handleMuteVideo=o.handleMuteVideo.bind(o),o.handleUnmuteVideo=o.handleUnmuteVideo.bind(o),o.handleAudioVolume=o.handleAudioVolume.bind(o),o.handleNetworkQuality=o.handleNetworkQuality.bind(o),o.handleDeviceChange=o.handleDeviceChange.bind(o),navigator.mediaDevices.addEventListener("devicechange",(e=o.handleDeviceChange,i=30,function(){for(var t=this,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];r>0&&clearTimeout(r),r=window.setTimeout((function(){e.apply(t,o),r=-1}),i)})),o.TRTC.getMicrophones().then((function(e){o.micList=e||[];var t=o.getDefaultDeviceInfo(e);o.currentMicId=t.deviceId||""})).catch((function(e){o.log_.error("getMicrophones error observed ".concat(e))})),o.TRTC.getCameras().then((function(e){o.cameraList=e||[];var t=o.getDefaultDeviceInfo(e);o.currentCameraId=t.deviceId||""})).catch((function(e){o.log_.error("getCameras error observed ".concat(e))})),o.TRTC.getSpeakers().then((function(e){o.speakerList=e||[];var t=o.getDefaultDeviceInfo(e);o.currentSpeakerId=t.deviceId||""})).catch((function(e){o.log_.error("getSpeakers error observed ".concat(e))})),o}return a(i,t),i.getTRTCShareInstance=function(){return pe||(pe=new i),pe},i.destroyTRTCShareInstance=function(){pe&&(pe.destroy(),pe=null)},i.prototype.getSDKVersion=function(){return this.VERSION||""},i.prototype.off=function(e,t){void 0===t&&(t=function(){});try{"*"===e?this.removeAllListeners():this.removeListener(e,t)}catch(i){console.log("off error ",i)}},i.prototype.enterRoom=function(e,t){return v(this,void 0,void 0,(function(){var i,r,o,n,a,s,c,l,u,h,d,m,p;return f(this,(function(v){switch(v.label){case 0:if(!(e instanceof b))return[3,6];if(i=e.sdkAppId,r=e.userId,o=e.userSig,n=e.roomId,a=e.strRoomId,s=e.role,c=e.privateMapKey,l=e.streamId,this.sdkAppId=i,this.userId=r,this.userSig=o,this.roomId=n,this.strRoomId=a,this.mode=W[t],this.role=j[s],this.remoteUserAvailable=new Map,u=n,h=!1,!n&&a&&(u=a,h=!0),this.isJoining||this.isJoined)return this.log_.error("(enterRoom) failed - ".concat(re.message," isJoining: ").concat(this.isJoining,", isJoined: ").concat(this.isJoined)),this.emitError(re),[2];v.label=1;case 1:return v.trys.push([1,4,,5]),this.isJoining=!0,d={sdkAppId:i,userId:r,userSig:o,mode:this.mode,useStringRoomId:h,frameWorkType:40},d=c?T(T({},d),{privateMapKey:c}):d,d=l?T(T({},d),{streamId:l}):d,this.initClient(d),this.startJoinTimestamp=K(),[4,this.client.join({roomId:u,role:this.role})];case 2:return v.sent(),this.isJoined=!0,this.isJoining=!1,this.joinedTimestamp=K(),m=this.joinedTimestamp-this.startJoinTimestamp,this.emit("onEnterRoom",m),this.log_.info("(enterRoom) success - enter room"),[4,this.publishLocalStream()];case 3:return v.sent(),[3,5];case 4:return p=v.sent(),this.isJoining=!1,this.emit("onEnterRoom",-1),this.callFunctionErrorManage(p,"enterRoom"),[3,5];case 5:return[3,7];case 6:this.emitError(ie),this.log_.error("(enterRoom) failed - ".concat(ie.message,": ").concat(JSON.stringify(e))),v.label=7;case 7:return[2]}}))}))},i.prototype.exitRoom=function(){return v(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:this.log_.info("(exitRoom) exitRoom, isJoined: ".concat(this.isJoined,"; isPublished: ").concat(this.isPublished)),t.label=1;case 1:return t.trys.push([1,7,,8]),!this.isJoined||this.isExiting?(this.log_.error("(exitRoom) failed - ".concat(oe.message," isJoined: ").concat(this.isJoined," isExiting: ").concat(this.isExiting)),this.emitError(oe),[2]):(this.isExiting=!0,this.isSharing?[4,this.stopScreenShare()]:[3,3]);case 2:t.sent(),t.label=3;case 3:return this.isPublished?[4,this.unPublishStream()]:[3,5];case 4:t.sent(),this.destroyLocalStream(),t.label=5;case 5:return this.emit("onExitRoom",w.ActiveExitRoom),[4,this.client.leave()];case 6:return t.sent(),this.resetStatus(),this.destroy(),this.log_.info("(exitRoom) success - exit room"),[3,8];case 7:return e=t.sent(),this.isExiting=!1,this.callFunctionErrorManage(e,"exitRoom"),[3,8];case 8:return[2]}}))}))},i.prototype.switchRole=function(t){return v(this,void 0,void 0,(function(){var i;return f(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),this.mode===O?(this.log_.info("(publishLocalStream) failed - mode = ".concat(this.mode,", role = ").concat(t)),this.handleOnSwitchRole(-1,"(publishLocalStream) failed - mode = ".concat(this.mode,", role = ").concat(t)),[2]):this.client?j[t]?[3,1]:(this.handleOnSwitchRole(-1,"please pass valid role parameter, role = ".concat(t)),[3,5]):[3,6];case 1:return[4,this.client.switchRole(j[t])];case 2:return r.sent(),this.role=j[t],t===e.TRTCRoleType.TRTCRoleAnchor?[4,this.client.publish(this.localStream)]:[3,4];case 3:r.sent(),r.label=4;case 4:this.handleOnSwitchRole(0,"switch role success, role = ".concat(t,", ").concat(j[t])),r.label=5;case 5:return[3,7];case 6:this.handleOnSwitchRole(-1,"switch role failed, client = ".concat(this.client)),r.label=7;case 7:return[3,9];case 8:return i=r.sent(),this.handleOnSwitchRole(-1,JSON.stringify(i)),[3,9];case 9:return[2]}}))}))},i.prototype.enableAudioVolumeEvaluation=function(e){this.client&&this.client.enableAudioVolumeEvaluation(e),this.enableAudioVolumeInterval=e},i.prototype.callFunctionErrorManage=function(e,t){e&&e.getCode&&e.getCode()?(this.emit(U,e.getCode(),e.message_),this.log_.error("(".concat(t,") failed - ").concat(e.message_))):(this.emit(U,te,e.message),this.log_.error("(".concat(t,") failed - ").concat(e.message)))},i.prototype.resetStatus=function(){this.isExiting=!1,this.isJoining=!1,this.isJoined=!1,this.isPublishing=!1,this.isPublished=!1,this.isSubscribed=!1,this.remoteStreamMap.clear()},i.prototype.publishLocalStream=function(){return v(this,void 0,void 0,(function(){var e,t,i,r,o,n,a,s,c;return f(this,(function(l){switch(l.label){case 0:if(t=(e=this).mode,i=e.role,r=e.isJoined,o=e.isPublishing,n=e.isPublished,a=e.localStream,s=e.client,t===N&&i===J)return this.log_.info("(publishLocalStream) failed - mode = ".concat(t,", role = ").concat(i)),[2];if(!r||o||n||!a||!s)return this.log_.info("(publishLocalStream) failed - isJoined = ".concat(r,",\n isPublishing = ").concat(o,", isPublished = ").concat(n,", localStream = ").concat(a,", client.userId = ").concat(s.getUserId())),[2];if(this.log_.info("(publishLocalStream) start - publish stream"),!r||n)return[3,5];this.isPublishing=!0,l.label=1;case 1:return l.trys.push([1,4,,5]),[4,this.setStreamVideoParam(this.videoEncodeParam)];case 2:return l.sent(),[4,this.client.publish(this.localStream)];case 3:return l.sent(),this.isPublishing=!1,this.isPublished=!0,this.enableAudioVolumeTimer&&clearInterval(this.enableAudioVolumeTimer),this.log_.info("(publishLocalStream) success - publish stream"),[3,5];case 4:return c=l.sent(),this.isPublishing=!1,this.callFunctionErrorManage(c,"publishLocalStream"),[3,5];case 5:return[2]}}))}))},i.prototype.unPublishStream=function(){return v(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return this.log_.info("(unPublishStream) unPublishStream",this.localStream),this.isPublished&&this.localStream?[4,this.client.unpublish(this.localStream)]:[3,2];case 1:e.sent(),this.isPublished=!1,e.label=2;case 2:return[2]}}))}))},i.prototype.setStreamVideoParam=function(e){return v(this,void 0,void 0,(function(){var t,i,r;return f(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,8]),this.localStream?(t=this.localStream.getVideoTrack())?[4,this.localStream.setVideoProfile(e)]:[2]:[3,2];case 1:return o.sent(),(t=this.localStream.getVideoTrack())&&(i=t.getSettings(),console.log("分辨率:".concat(i.width," * ").concat(i.height,", 帧率:").concat(i.frameRate))),[3,3];case 2:this.videoEncodeParam=e,o.label=3;case 3:return[3,8];case 4:return"OverconstrainedError"!==o.sent().name?[3,6]:(console.error("当前摄像头不支持该 profile"),[4,(r=this.TRTC.createStream({video:!0,audio:!1})).initialize()]);case 5:return o.sent(),this.localStream.replaceTrack(r.getVideoTrack()),[3,7];case 6:console.error("当前浏览器不支持动态调用该接口"),o.label=7;case 7:return[3,8];case 8:return[2]}}))}))},i.prototype.destroyLocalStream=function(){this.localStream&&(this.localStream.stop(),this.localStream&&this.localStream.close(),this.localStream=null)},i.prototype.destroy=function(){this.unbindEvents(),this.client&&(this.client=null)},i.prototype.initStream=function(e){return v(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return this.localStream=this.TRTC.createStream(e),this.videoEncodeParam&&this.localStream.setVideoProfile(this.videoEncodeParam),[4,this.localStream.initialize()];case 1:return t.sent(),[2]}}))}))},i.prototype.localStreamHasVideoOrAudio=function(e){if(e&&"string"==typeof e||this.emitError(ie),!this.localStream)return!1;switch(e){case D:return!!this.localStream.getVideoTrack();case k:return!!this.localStream.getAudioTrack();default:return!1}},i.prototype.playStream=function(e,t,i){return v(this,void 0,void 0,(function(){return f(this,(function(r){return t&&e?(e.play(t,i),this.playViewMap.set("".concat(e.getUserId(),"_").concat(this.getStreamType(e)),t),[2]):(this.log_.error("(playStream) failed - dom = ".concat(t,", stream = ").concat(e)),[2])}))}))},i.prototype.initClient=function(e){this.client=this.TRTC.createClient(e),this.enableAudioVolumeInterval&&this.client.enableAudioVolumeEvaluation(this.enableAudioVolumeInterval),this.bindEvents()},i.prototype.bindEvents=function(){var e=this;this.client.on("error",this.handleError),this.client.on("peer-join",this.handlePeerJoin),this.client.on("peer-leave",this.handlePeerLeave),this.client.on("stream-added",this.handleStreamAdded),this.client.on("stream-subscribed",this.handleStreamSubscribed),this.client.on("stream-removed",this.handleStreamRemoved),this.client.on("stream-updated",this.handleStreamUpdated),this.client.on("mute-audio",this.handleMuteAudio),this.client.on("unmute-audio",this.handleUnmuteAudio),this.client.on("mute-video",this.handleMuteVideo),this.client.on("unmute-video",this.handleUnmuteVideo),this.client.on("client-banned",(function(t){e.log_.error("client has been banned for ".concat(t)),e.emit("onExitRoom",w.KickedExitRoom)})),this.client.on("audio-volume",this.handleAudioVolume),this.client.on("network-quality",this.handleNetworkQuality)},i.prototype.unbindEvents=function(){this.client&&this.client.off("*")},i.prototype.emitError=function(e){e&&this.emit&&this.emit(U,e.code,e.message)},i.prototype.handleError=function(e){this.log_.error("handle error observed ".concat(e)),this.emit(U,e.getCode(),e.message)},i.prototype.handleEnterRoom=function(){},i.prototype.handleExitRoom=function(){},i.prototype.handlePeerJoin=function(e){var t=e.userId,i=Array.from(this.remoteUserAvailable.keys())||[];this.remoteUserAvailable.set(t,{isAudioAvailable:!1,isVideoAvailable:!1}),$(this.userId,t)||(i.filter((function(e){return $(e,t)}))||[]).length>0||t.slice(0,6)!==B&&this.emit("onRemoteUserEnterRoom",t)},i.prototype.handlePeerLeave=function(e){var t=e.userId,i=void 0===t?"":t;this.emit("onRemoteUserLeaveRoom",i,0)},i.prototype.handleOnUserAudioAvailable=function(e,t,i){return v(this,void 0,void 0,(function(){var r;return f(this,(function(o){switch(o.label){case 0:return this.remoteUserAvailable.get(e).isAudioAvailable=t,this.emit("onUserAudioAvailable",e,t?1:0),t?this.remoteStreamMap.get("".concat(e,"-").concat(i)).isPlaying()?[3,3]:(r=this.generateTempAudioContainer("".concat(e,"-").concat(i,"_dom")),[4,this.remoteStreamMap.get("".concat(e,"-").concat(i)).play(r)]):[3,4];case 1:return o.sent(),[4,this.remoteStreamMap.get("".concat(e,"-").concat(i)).setAudioOutput(this.currentSpeakerId)];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:this.clearTempAudioContainer("".concat(e,"-").concat(i,"_dom")),o.label=5;case 5:return[2]}}))}))},i.prototype.handleOnUserVideoAvailable=function(e,t){this.remoteUserAvailable.get(e).isVideoAvailable=t,this.emit("onUserVideoAvailable",e,t?1:0)},i.prototype.handleOnUserSubStreamAvailable=function(e,t){this.remoteUserAvailable.get(e).isVideoAvailable=t;var i=e;e.slice(0,6)===B&&(i=e.slice(6))===this.userId||this.emit("onUserSubStreamAvailable",i,t?1:0)},i.prototype.handleOnSwitchRole=function(e,t){this.emit("onSwitchRole",e,t)},i.prototype.handleAudioVolume=function(e){var t=this,i=e.result||[];i=i.map((function(e){return{userId:e.userId===t.userId?"":e.userId,volume:e.audioVolume}}))||[],this.emit("onUserVoiceVolume",i,i.length)},i.prototype.handleStreamAdded=function(e){return v(this,void 0,void 0,(function(){var t,i,r;return f(this,(function(o){switch(o.label){case 0:return t=e.stream,i=t.getUserId(),r=this.getStreamType(t),this.remoteStreamMap.set("".concat(i,"-").concat(r),e.stream),r!==x?[3,1]:(this.handleOnUserSubStreamAvailable(i,!0),[3,4]);case 1:return t.hasAudio()?[4,this.handleOnUserAudioAvailable(i,!0,r)]:[3,3];case 2:o.sent(),o.label=3;case 3:if(t.hasVideo()){if(((Array.from(this.remoteUserAvailable.keys())||[]).filter((function(e){return $(e,i)}))||[]).length>0)return this.handleOnUserSubStreamAvailable(i,!0),[2];if(i.slice(0,6)===B&&i.slice(6)===this.userId)return[2];this.handleOnUserVideoAvailable(i,!0)}o.label=4;case 4:return this.handleSubscribe(e.stream),[2]}}))}))},i.prototype.handleSubscribe=function(e,t){return void 0===t&&(t={audio:!0,video:!0}),v(this,void 0,void 0,(function(){var i;return f(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.client.subscribe(e,{audio:!!q(t.audio)||t.audio,video:!!q(t.video)||t.video})];case 1:return r.sent(),[3,3];case 2:return i=r.sent(),console.error("subscribe ".concat(e.getUserId()," with audio: ").concat(t.audio," video: ").concat(t.video," error"),i),[3,3];case 3:return[2]}}))}))},i.prototype.handleStreamSubscribed=function(){this.isSubscribed=!0},i.prototype.handleStreamRemoved=function(e){return v(this,void 0,void 0,(function(){var t,i;return f(this,(function(r){switch(r.label){case 0:return t=e.stream.getUserId(),(i=this.getStreamType(e.stream))!==F?[3,2]:((Array.from(this.remoteUserAvailable.keys())||[]).filter((function(e){return $(e,t)}))||[]).length>0?(this.handleOnUserSubStreamAvailable(t,!1),[2]):[4,this.handleOnUserAudioAvailable(t,!1,i)];case 1:return r.sent(),this.handleOnUserVideoAvailable(t,!1),[3,3];case 2:i===x&&this.handleOnUserSubStreamAvailable(t,!1),r.label=3;case 3:return this.remoteStreamMap.delete("".concat(t,"-").concat(i)),[2]}}))}))},i.prototype.handleStreamUpdated=function(e){return v(this,void 0,void 0,(function(){var t,i,r;return f(this,(function(o){switch(o.label){case 0:return t=e.stream,i=t.getUserId(),r=this.getStreamType(t),!t.hasAudio()||this.remoteUserAvailable.get(i).isAudioAvailable?[3,2]:[4,this.handleOnUserAudioAvailable(i,!0,r)];case 1:o.sent(),o.label=2;case 2:if(t.hasVideo()&&!this.remoteUserAvailable.get(i).isVideoAvailable){if(((Array.from(this.remoteUserAvailable.keys())||[]).filter((function(e){return $(e,i)}))||[]).length>0)return this.handleOnUserSubStreamAvailable(i,!0),[2];if(i.slice(0,6)===B&&i.slice(6)===this.userId)return[2];this.handleOnUserVideoAvailable(i,!0)}return[2]}}))}))},i.prototype.handleMuteAudio=function(e){return v(this,void 0,void 0,(function(){var t;return f(this,(function(i){switch(i.label){case 0:return(t=e.userId)?[4,this.handleOnUserAudioAvailable(t,!1,F)]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},i.prototype.handleUnmuteAudio=function(e){return v(this,void 0,void 0,(function(){var t;return f(this,(function(i){switch(i.label){case 0:return!(t=e.userId)||this.remoteUserAvailable.get(t).isAudioAvailable?[3,2]:[4,this.handleOnUserAudioAvailable(t,!0,F)];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},i.prototype.handleMuteVideo=function(e){var t=e.userId;t&&this.handleOnUserVideoAvailable(t,!1)},i.prototype.handleUnmuteVideo=function(e){var t=e.userId;if(t&&!this.remoteUserAvailable.get(t).isVideoAvailable){if(((Array.from(this.remoteUserAvailable.keys())||[]).filter((function(e){return $(e,t)}))||[]).length>0)return void this.handleOnUserSubStreamAvailable(t,!0);if(t.slice(0,6)===B&&t.slice(6)===this.userId)return;this.handleOnUserVideoAvailable(t,!0)}},i.prototype.getLocalStatistics=function(){var t=this;return this.client.getLocalVideoStats().then((function(i){var r=i[t.client.getUserId()],o=r.bytesSent-t.prevLocalVideoStats.bytesSent,n=r.framesEncoded-t.prevLocalVideoStats.framesEncoded,a=r.frameWidth,s=r.frameHeight;o<0&&(o=0),n<0&&(n=0),t.prevLocalVideoStats=r;var c=Number((8*o/1e3/2).toFixed()),l=Number((n/2).toFixed()),u=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig;return new M(a,s,l,c,0,0,u)}))},i.prototype.handleNetworkQuality=function(e){return v(this,void 0,void 0,(function(){var t,i,r,o,n,a,s,c,l;return f(this,(function(u){switch(u.label){case 0:return t=e.uplinkNetworkQuality,i=e.uplinkRTT,r=e.uplinkLoss,o=e.downlinkRTT,n=e.downlinkLoss,a=this.client?this.client.getUserId():"",s=new _(a,t,t,i,r,o,n),this.emit("onNetworkQuality",s),[4,this.getLocalStatistics()];case 1:return c=u.sent(),l=new E(r,n,0,0,i,0,0,[c]),this.emit("onStatistics",l),[2]}}))}))},i.prototype.handleDeviceChange=function(){return v(this,void 0,void 0,(function(){var t=this;return f(this,(function(i){return this.TRTC.getCameras().then((function(i){return v(t,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return this.cameraList.length===i.length?[2]:[4,this.deviceChangeManage(this.cameraList,i,e.TRTCDeviceType.TRTCDeviceTypeCamera)];case 1:return t.sent(),this.cameraList=i,[2]}}))}))})),this.TRTC.getMicrophones().then((function(i){return v(t,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return this.micList.length===i.length?[2]:[4,this.deviceChangeManage(this.micList,i,e.TRTCDeviceType.TRTCDeviceTypeMic)];case 1:return t.sent(),this.micList=i,[2]}}))}))})),this.TRTC.getSpeakers().then((function(i){return v(t,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return this.speakerList.length===i.length?[2]:[4,this.deviceChangeManage(this.speakerList,i,e.TRTCDeviceType.TRTCDeviceTypeSpeaker)];case 1:return t.sent(),this.speakerList=i,[2]}}))}))})),[2]}))}))},i.prototype.emitOnDeviceChange=function(e,t,i){this.emit("onDeviceChange",e,t,i)},i.prototype.deviceChangeManage=function(t,i,r){return v(this,void 0,void 0,(function(){var o,n,a,s,c;return f(this,(function(l){switch(l.label){case 0:return t.length===i.length?[3,8]:(o=(i||[]).map((function(e){return e.deviceId})),n=new y,a=e.TRTCDeviceState.TRTCDeviceStateAdd,t.length>i.length&&(n=t.filter((function(e){return!o.includes(e.deviceId)}))[0]||{},a=e.TRTCDeviceState.TRTCDeviceStateRemove),t.length<i.length&&(o=(t||[]).map((function(e){return e.deviceId})),n=i.filter((function(e){return!o.includes(e.deviceId)}))[0]||{}),s=n.deviceId,this.emitOnDeviceChange(s,r,a),a!==e.TRTCDeviceState.TRTCDeviceStateAdd?[3,2]:[4,this.autoChangeDevice(r,a,s)]);case 1:return l.sent(),[3,8];case 2:return a!==e.TRTCDeviceState.TRTCDeviceStateRemove?[3,8]:s!==this.currentSpeakerId&&s!==this.currentMicId?[3,5]:(c=this.getDefaultDeviceInfo(i)).deviceId?[4,this.autoChangeDevice(r,a,c.deviceId)]:[3,4];case 3:l.sent(),l.label=4;case 4:l.label=5;case 5:return r!==e.TRTCDeviceType.TRTCDeviceTypeCamera?[3,8]:(c=this.getDefaultDeviceInfo(i)).deviceId?[4,this.autoChangeDevice(r,a,c.deviceId)]:[3,7];case 6:l.sent(),l.label=7;case 7:l.label=8;case 8:return[2]}}))}))},i.prototype.autoChangeDevice=function(t,i,r){return v(this,void 0,void 0,(function(){var i,o=this;return f(this,(function(n){switch(n.label){case 0:return t===e.TRTCDeviceType.TRTCDeviceTypeCamera&&(this.currentCameraId=r,this.emitOnDeviceChange(r,t,e.TRTCDeviceState.TRTCDeviceStateActive)),t!==e.TRTCDeviceType.TRTCDeviceTypeMic?[3,3]:this.localStream?[4,this.localStream.switchDevice(k,r)]:[3,2];case 1:n.sent(),n.label=2;case 2:this.currentMicId=r,this.emitOnDeviceChange(r,t,e.TRTCDeviceState.TRTCDeviceStateActive),n.label=3;case 3:return t!==e.TRTCDeviceType.TRTCDeviceTypeSpeaker?[3,6]:this.remoteStreamMap.size>0?(i=this.getRemoteStreamList(),[4,Promise.all(i.map((function(e){return v(o,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,e.setAudioOutput(r)];case 1:return[2,t.sent()]}}))}))})))]):[3,5];case 4:n.sent(),n.label=5;case 5:this.currentSpeakerId=r,this.emitOnDeviceChange(r,t,e.TRTCDeviceState.TRTCDeviceStateActive),n.label=6;case 6:return[2]}}))}))},i.prototype.getRemoteStreamList=function(){var e=[];return this.remoteStreamMap.size>0&&Array.from(this.remoteStreamMap,(function(e){return e[1]})).forEach((function(t){t&&e.push(t)})),e},i.prototype.getDefaultDeviceInfo=function(e){var t=new y;if(0===e.length)return t;var i=e.filter((function(e){return"default"===e.deviceId}));if(i.length>0){var r=i[0].groupId;t=e.filter((function(e){return e.groupId===r})).filter((function(e){return e.deviceId!==L}))[0]}else t=e[0];return t},i.prototype.getResolution=function(t){var i=(e.TRTCVideoResolution[t]||"").split("_");return{width:i.length>1&&i[1],height:i.length>2&&i[2]}},i.prototype.getStreamType=function(e){if(!e)return"";var t=e.getUserId(),i=e&&e.getType();return t.slice(0,6)===B&&i===F&&(i=x),i},i}(Y(t.EventEmitter,ee,ce,le,ue,he,de,me));e.TRTCDeviceInfo=y,e.TRTCLocalStatistics=M,e.TRTCNetQualityInfo=_,e.TRTCParams=b,e.TRTCPublishCDNParam=I,e.TRTCRenderParams=A,e.TRTCStatistics=E,e.TRTCVideoEncParam=g,e.TRTCVolumeInfo=P,e.default=Te,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("events"),require("trtc-js-sdk")):"function"==typeof define&&define.amd?define(["exports","events","trtc-js-sdk"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).TRTC={},global.events,global.TRTC);
|