trtc-cloud-js-sdk 1.0.13 → 2.1.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/package.json +2 -2
- package/trtc-cloud-js-sdk.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trtc-cloud-js-sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Tencent Cloud RTC SDK for Web And Electron",
|
|
5
5
|
"main": "trtc-cloud-js-sdk.js",
|
|
6
6
|
"keywords": [
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"axios": "^0.21.1",
|
|
21
21
|
"rtc-beauty-plugin": "^0.0.5",
|
|
22
|
-
"trtc-
|
|
22
|
+
"trtc-sdk-v5": "^5.0.0"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/trtc-cloud-js-sdk.js
CHANGED
|
@@ -1 +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),a=function(e,t){return a=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])},a(e,t)};function s(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}a(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var n,c,l,u,h,d,m,T,p=function(){return p=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},p.apply(this,arguments)};function v(e,t,i,r){return new(i||(i=Promise))((function(o,a){function s(e){try{c(r.next(e))}catch(t){a(t)}}function n(e){try{c(r.throw(e))}catch(t){a(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(s,n)}c((r=r.apply(e,t||[])).next())}))}function S(e,t){var i,r,o,a,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function n(a){return function(n){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(n){a=[6,n],r=0}finally{i=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,n])}}}function f(e,t,i){if(i||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}e.TRTCVideoResolution=void 0,(n=e.TRTCVideoResolution||(e.TRTCVideoResolution={}))[n.TRTCVideoResolution_120_120=1]="TRTCVideoResolution_120_120",n[n.TRTCVideoResolution_160_160=3]="TRTCVideoResolution_160_160",n[n.TRTCVideoResolution_270_270=5]="TRTCVideoResolution_270_270",n[n.TRTCVideoResolution_480_480=7]="TRTCVideoResolution_480_480",n[n.TRTCVideoResolution_160_120=50]="TRTCVideoResolution_160_120",n[n.TRTCVideoResolution_240_180=52]="TRTCVideoResolution_240_180",n[n.TRTCVideoResolution_280_210=54]="TRTCVideoResolution_280_210",n[n.TRTCVideoResolution_320_240=56]="TRTCVideoResolution_320_240",n[n.TRTCVideoResolution_400_300=58]="TRTCVideoResolution_400_300",n[n.TRTCVideoResolution_480_360=60]="TRTCVideoResolution_480_360",n[n.TRTCVideoResolution_640_480=62]="TRTCVideoResolution_640_480",n[n.TRTCVideoResolution_960_720=64]="TRTCVideoResolution_960_720",n[n.TRTCVideoResolution_160_90=100]="TRTCVideoResolution_160_90",n[n.TRTCVideoResolution_256_144=102]="TRTCVideoResolution_256_144",n[n.TRTCVideoResolution_320_180=104]="TRTCVideoResolution_320_180",n[n.TRTCVideoResolution_480_270=106]="TRTCVideoResolution_480_270",n[n.TRTCVideoResolution_640_360=108]="TRTCVideoResolution_640_360",n[n.TRTCVideoResolution_960_540=110]="TRTCVideoResolution_960_540",n[n.TRTCVideoResolution_1280_720=112]="TRTCVideoResolution_1280_720",n[n.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.TRTCAudioQuality=void 0,(T=e.TRTCAudioQuality||(e.TRTCAudioQuality={}))[T.TRTCAudioQualityDefault=0]="TRTCAudioQualityDefault",T[T.TRTCAudioQualitySpeech=1]="TRTCAudioQualitySpeech",T[T.TRTCAudioQualityMusic=3]="TRTCAudioQualityMusic";var y,R,C=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,(y=e.TRTCDeviceState||(e.TRTCDeviceState={}))[y.TRTCDeviceStateAdd=0]="TRTCDeviceStateAdd",y[y.TRTCDeviceStateRemove=1]="TRTCDeviceStateRemove",y[y.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 g,b=function(t,i,r,o,a,s,n,c,l,u,h){void 0===t&&(t=0),void 0===i&&(i=""),void 0===r&&(r=""),void 0===o&&(o=0),void 0===a&&(a=""),void 0===s&&(s=e.TRTCRoleType.TRTCRoleAnchor),void 0===n&&(n=null),void 0===l&&(l=null),void 0===u&&(u=null),void 0===h&&(h=30),this.sdkAppId=t,this.userId=i,this.userSig=r,this.roomId=o,this.strRoomId=a,this.role=s,this.privateMapKey=n,this.streamId=l,this.userDefineRecordId=u,this.frameWorkType=h},V=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,(g=e.TRTCVideoRotation||(e.TRTCVideoRotation={}))[g.TRTCVideoRotation0=0]="TRTCVideoRotation0",g[g.TRTCVideoRotation90=1]="TRTCVideoRotation90",g[g.TRTCVideoRotation180=2]="TRTCVideoRotation180",g[g.TRTCVideoRotation270=3]="TRTCVideoRotation270";var P,A=function(t,i,r){void 0===t&&(t=e.TRTCVideoRotation.TRTCVideoRotation0),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.TRTCQuality=void 0,(P=e.TRTCQuality||(e.TRTCQuality={}))[P.TRTCQuality_Unknown=0]="TRTCQuality_Unknown",P[P.TRTCQuality_Excellent=1]="TRTCQuality_Excellent",P[P.TRTCQuality_Good=2]="TRTCQuality_Good",P[P.TRTCQuality_Poor=3]="TRTCQuality_Poor",P[P.TRTCQuality_Bad=4]="TRTCQuality_Bad",P[P.TRTCQuality_Vbad=5]="TRTCQuality_Vbad",P[P.TRTCQuality_Down=6]="TRTCQuality_Down";var _,w,M,I=function(t,i){void 0===t&&(t=""),void 0===i&&(i=e.TRTCQuality.TRTCQuality_Unknown),this.userId=t,this.quality=i},D=function(e,t){void 0===e&&(e=""),void 0===t&&(t=0),this.userId=e,this.volume=t},L=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},E=function(t,i,r,o,a,s,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===s&&(s=0),void 0===n&&(n=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig),this.width=t,this.height=i,this.frameRate=r,this.videoBitrate=o,this.audioSampleRate=a,this.audioBitrate=s,this.streamType=n},k=function(e,t,i,r,o,a,s,n,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===a&&(a=0),void 0===s&&(s=0),void 0===n&&(n=[]),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=a,this.sentBytes=s,this.localStatisticsArray=n,this.localStatisticsArraySize=c,this.remoteStatisticsArraySize=l};e.TRTCVideoResolutionMode=void 0,(_=e.TRTCVideoResolutionMode||(e.TRTCVideoResolutionMode={}))[_.TRTCVideoResolutionModeLandscape=0]="TRTCVideoResolutionModeLandscape",_[_.TRTCVideoResolutionModePortrait=1]="TRTCVideoResolutionModePortrait",e.TRTCVideoQosPreference=void 0,(w=e.TRTCVideoQosPreference||(e.TRTCVideoQosPreference={}))[w.TRTCVideoQosPreferenceSmooth=1]="TRTCVideoQosPreferenceSmooth",w[w.TRTCVideoQosPreferenceClear=2]="TRTCVideoQosPreferenceClear",e.TRTCQosControlMode=void 0,(M=e.TRTCQosControlMode||(e.TRTCQosControlMode={}))[M.TRTCQosControlModeClient=0]="TRTCQosControlModeClient",M[M.TRTCQosControlModeServer=1]="TRTCQosControlModeServer";var F,U=function(t,i){void 0===t&&(t=e.TRTCVideoQosPreference.TRTCVideoQosPreferenceClear),void 0===i&&(i=e.TRTCQosControlMode.TRTCQosControlModeServer),this.preference=t,this.controlMode=i},O=function(e,t,i,r){void 0===e&&(e=new ArrayBuffer(0)),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),this.buffer=e,this.length=t,this.width=i,this.height=r};e.TRTCScreenCaptureSourceType=void 0,(F=e.TRTCScreenCaptureSourceType||(e.TRTCScreenCaptureSourceType={}))[F.TRTCScreenCaptureSourceTypeUnknown=-1]="TRTCScreenCaptureSourceTypeUnknown",F[F.TRTCScreenCaptureSourceTypeWindow=0]="TRTCScreenCaptureSourceTypeWindow",F[F.TRTCScreenCaptureSourceTypeScreen=1]="TRTCScreenCaptureSourceTypeScreen",F[F.TRTCScreenCaptureSourceTypeCustom=2]="TRTCScreenCaptureSourceTypeCustom";var Q,B=function(t,i,r,o,a,s){void 0===t&&(t=e.TRTCScreenCaptureSourceType.TRTCScreenCaptureSourceTypeUnknown),void 0===i&&(i=""),void 0===r&&(r=""),void 0===o&&(o=new O),void 0===a&&(a=new O),void 0===s&&(s=!1),this.type=t,this.sourceId=i,this.sourceName=r,this.thumbBGRA=o,this.iconBGRA=a,this.isMinimizeWindow=s},x=function(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),this.left=e,this.top=t,this.right=i,this.bottom=r},N="default",J="video",j="audio",z="onError",W="main",H="rtc",K="live",q="anchor",G="audience",X="auxiliary",Y="share_",Z="number",$="user",ee="environment",te={20:q,21:G},ie={0:H,1:K,2:H,3:K},re={0:"standard",1:"high",2:"standard_stereo",3:"high_stereo"},oe={0:"big",1:"small",2:X};function ae(){return Math.floor(performance.now())}!function(e){e[e.ActiveExitRoom=0]="ActiveExitRoom",e[e.KickedExitRoom=1]="KickedExitRoom"}(Q||(Q={}));var se=function(e){return void 0===e};function ne(e){return"".concat(e,"-").concat(W)}function ce(e){return"".concat(e,"-").concat(X)}function le(){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++)ue(this,new(0,i[t])(this))},r=i.prototype,o=0,a=e;o<a.length;o++){var s=a[o];ue(i,s),ue(r,s.prototype)}return i}function ue(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 a=Object.getOwnPropertyDescriptor(t,o)||"";Object.defineProperty(e,o,a)}}}function he(e,t){return void 0===e&&(e=""),t==="share_".concat(e)}function de(e){return e&&null!==e.getVideoTrack()}function me(e){return e&&null!==e.getAudioTrack()}var Te=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.currentFacingMode="",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.useStringRoomId=!1,i.realRoomId=0,i.mode=H,i.role=q,i.privateMapKey="255",i.streamId="",i.isSmallStreamSupported=!1,i.isStaringLocalPreview=!1,i.isStartedLocalPreview=!1,i.isStaringLocalAudio=!1,i.isStartedLocalAudio=!1,i.isVideoMute_=!1,i.isAudioMute_=!1,i.shareUserId="",i.shareUserSig="",i.isSharing_=!1,i.isShareClientJoined=!1,i.isShareStreamPublished_=!1,i.isShareClientLeaving=!1,i.defaultShareWidth_=1920,i.defaultShareHeight_=1080,i.defaultShareFrameRate_=15,i.defaultShareBitrate_=1500,i.defaultVideoWidth=640,i.defaultVideoHeight=480,i.defaultVideoFps=15,i.defaultVideoBitRate=900,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.TRTCAudioQuality.TRTCAudioQualityDefault,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 s(i,t),i.prototype.promiseRetry=function(e){var t=this,i=e.retryFunction,r=e.settings,o=e.onError,a=e.onRetrying,s=e.context;return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var c=r.retries||5,l=0,u=-1,h=0,d=function(n,m){return v(t,void 0,void 0,(function(){var t,T,p,v,f;return S(this,(function(S){switch(S.label){case 0:return S.trys.push([0,2,,3]),t=s||this,[4,i.apply(t,e)];case 1:return T=S.sent(),l=0,n(T),[3,3];case 2:return p=S.sent(),v=function(){clearTimeout(u),l=0,h=2,m(p)},f=function(){2!==h&&l<c?(l++,h=1,a&&a(l,v),u=window.setTimeout((function(){u=-1,d(n,m)}),void 0===r.timeout?1e3:r.timeout)):v()},o?o(p,f,m):f(),[3,3];case 3:return[2]}}))}))};return new Promise(d)}},i}(t.EventEmitter),pe=-1e3,ve={code:-1001,message:"参数错误, 请检查参数格式、是否非空等"},Se={code:-1002,message:"进房失败:进房中或已进房"},fe={code:-1003,message:"退房失败:未进房或退房中"},ye={code:-1004,message:"调用该函数所需要条件不满足"},Re={code:-1005,message:"not supported"},Ce={code:-1006,message:"not supported before join room"},ge={code:-1007,message:"进房 userId 不能包含前缀 share_"},be={code:-1009,message:"不支持小流推屏幕分享"},Ve=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.prototype.startPublishing=function(e,t){return v(this,void 0,void 0,(function(){var t,i;return S(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:ye,message:"".concat(ye.message," - client = ").concat(this.client)}),[2]):(this.log_.error("(startPublishing) failed - ".concat(this.isPublished)),this.emitError({conditionsError:ye,message:"".concat(ye.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 S(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:ye,message:"".concat(ye.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,a;return S(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),t=e.appId,i=e.bizId,r=e.url,t&&i&&r?(o={appId:t,bizId:i,url:r},[4,this.client.startPublishCDNStream(o)]):[3,2];case 1:return s.sent(),[3,3];case 2:this.log_.error("(startPublishCDNStream) failed - ".concat(JSON.stringify(e))),this.emitError(ve),s.label=3;case 3:return[3,5];case 4:return a=s.sent(),this.callFunctionErrorManage(a,"startPublishCDNStream"),[3,5];case 5:return[2]}}))}))},t.prototype.stopPublishCDNStream=function(){return v(this,void 0,void 0,(function(){var e;return S(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:ye,message:"".concat(ye.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}(le(Te)),Pe=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return s(i,t),i.prototype.startLocalPreview=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v(this,void 0,void 0,(function(){var t,i,r;return S(this,(function(o){return this.log_.info("(startLocalPreview) start - start local preview with params: [".concat(e,"]")),1===f([],e,!0).length?(i=f([],e,!0)[0],this.startLocalPreviewOnPC(i)):2===f([],e,!0).length&&(r=f([],e,!0),t=r[0],i=r[1],this.startLocalPreviewOnMobile(t,i)),[2]}))}))},i.prototype.startLocalPreviewOnPC=function(t){return v(this,void 0,void 0,(function(){var i;return S(this,(function(r){switch(r.label){case 0:this.log_.info("(startLocalPreviewOnPC) start - start local preview, ".concat(t,", ").concat(this.localStream)),r.label=1;case 1:return r.trys.push([1,3,,4]),this.localStreamHasVideoOrAudio(J)?(this.playStream(this.localPlayStream,t,this.localStreamRenderParams),[2]):[4,this.promiseRetry({retryFunction:this.doStartLocalPreview,settings:{retries:6,timeout:1e3}})("pc",t)];case 2:return r.sent(),this.handleOnFirstVideoFrame("",e.TRTCVideoStreamType.TRTCVideoStreamTypeBig,t),[3,4];case 3:return i=r.sent(),this.isStaringLocalPreview=!1,this.callFunctionErrorManage(i,"startLocalPreview"),[3,4];case 4:return[2]}}))}))},i.prototype.startLocalPreviewOnMobile=function(t,i){return v(this,void 0,void 0,(function(){var r,o;return S(this,(function(a){switch(a.label){case 0:this.log_.info("(startLocalPreviewOnMobile) start - start local preview",i),r=t?$:ee,this.currentFacingMode=r,a.label=1;case 1:return a.trys.push([1,10,,11]),this.localStreamHasVideoOrAudio(J)?this.localStream.facingMode_!==r?[3,2]:(this.playStream(this.localPlayStream,i,this.localStreamRenderParams),[3,7]):[3,8];case 2:return de(this.localStream)?[4,this.localStream.switchDevice(J,r)]:[3,4];case 3:a.sent(),a.label=4;case 4:return de(this.localPlayStream)?[4,this.localPlayStream.switchDevice(J,r)]:[3,6];case 5:a.sent(),a.label=6;case 6:this.localRenderParams&&this.localRenderParams.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto&&(r===$?this.localStreamRenderParams.mirror=!0:r===ee&&(this.localStreamRenderParams.mirror=!1)),this.playStream(this.localPlayStream,i,this.localStreamRenderParams),a.label=7;case 7:return[2];case 8:return[4,this.promiseRetry({retryFunction:this.doStartLocalPreview,settings:{retries:6,timeout:1e3}})("mobile",i)];case 9:return a.sent(),this.handleOnFirstVideoFrame("",e.TRTCVideoStreamType.TRTCVideoStreamTypeBig,i),[3,11];case 10:return o=a.sent(),this.isStaringLocalPreview=!1,this.callFunctionErrorManage(o,"startLocalPreview"),[3,11];case 11:return[2]}}))}))},i.prototype.doStartLocalPreview=function(t,i){return v(this,void 0,void 0,(function(){var r,o,a,s,n;return S(this,(function(c){switch(c.label){case 0:if(this.isStaringLocalAudio)throw new Error("startLocalAudio is under implementation.");return this.isStaringLocalPreview=!0,se(i)?[3,16]:null===i?[3,15]:(r={userId:this.client&&"".concat(this.client.getUserId()," video")||"video undefined",video:!0,audio:!1,screenAudio:!1},"pc"===t&&this.currentCameraId?r.cameraId=this.currentCameraId:"mobile"===t&&this.currentFacingMode&&(r.facingMode=this.currentFacingMode),[4,this.generateLocalPlayStream(r)]);case 1:return c.sent(),this.localPlayStream&&(this.localRenderParams&&this.localRenderParams.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto&&(r.facingMode===$?this.localStreamRenderParams.mirror=!0:r.facingMode===ee&&(this.localStreamRenderParams.mirror=!1)),this.playStream(this.localPlayStream,i,this.localStreamRenderParams),this.clearTempAudioContainer("localAudio")),o=this.TRTC.createStream(r),this.videoEncodeParam?[4,o.setVideoProfile(this.videoEncodeParam)]:[3,3];case 2:c.sent(),c.label=3;case 3:return[4,o.initialize()];case 4:if(c.sent(),a=o.getVideoTrack(),!this.localStream)return[3,12];c.label=5;case 5:return c.trys.push([5,10,,11]),(s=this.localStream.getVideoTrack())?[4,this.localStream.replaceTrack(a)]:[3,7];case 6:return c.sent(),s.stop(),[3,9];case 7:return[4,this.localStream.addTrack(a)];case 8:c.sent(),c.label=9;case 9:return[3,11];case 10:throw n=c.sent(),o.close(),n;case 11:return[3,13];case 12:this.localStream=o,c.label=13;case 13:return this.isStartedLocalPreview=!0,[4,this.publishLocalStream()];case 14:c.sent(),this.muteLocalVideo(this.isVideoMute_),this.isStaringLocalPreview=!1,c.label=15;case 15:return[3,17];case 16:this.emitError(ve),this.log_.error("(startLocalPreview) failed - ".concat(ve.message,": ").concat(i)),c.label=17;case 17:return[2]}}))}))},i.prototype.updateLocalView=function(e){this.localPlayStream&&this.playStream(this.localPlayStream,e,this.localStreamRenderParams)},i.prototype.stopLocalPreview=function(){return v(this,void 0,void 0,(function(){var e=this;return S(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;return S(this,(function(o){switch(o.label){case 0:return o.trys.push([0,5,,6]),[4,this.stopLocalPlayStreamTrack(J)];case 1:return o.sent(),this.localStream?this.localStream.getAudioTrack()?((e=this.localStream.getVideoTrack())&&this.localStream.removeTrack(e).then((function(){e.stop(),t(1)})),[3,4]):[3,2]:[3,4];case 2:return[4,this.unPublishStream()];case 3:o.sent(),this.localStream.stop(),this.localStream.close(),this.localStream=null,t(1),o.label=4;case 4:return[3,6];case 5:return r=o.sent(),this.callFunctionErrorManage(r,"stopLocalPreview"),i(r),[3,6];case 6:return[2]}}))}))}))]:(this.log_.info("(stopLocalPreview) stop - local preview has not been started"),[2])}))}))},i.prototype.muteLocalVideo=function(e){void 0===e&&(e=!1),this.isVideoMute_=e;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,a,s,n,c;return S(this,(function(l){switch(l.label){case 0:return l.trys.push([0,7,,8]),t&&!se(i)&&r in e.TRTCVideoStreamType?(o=r,a=ne(t),r===e.TRTCVideoStreamType.TRTCVideoStreamTypeSub?(a=ce("".concat(Y).concat(t)),this.remoteStreamMap.has(a)||(a=ce(t)),o=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig):this.isSmallStreamSupported||(o=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig),s=oe[o],this.remoteStreamMap.has(a)?(n=this.remoteStreamMap.get(a),s===X?[3,3]:this.client?[4,this.client.setRemoteVideoStreamType(n,o)]:[3,2]):[3,6]):(this.emitError(ve),this.log_.error("(startRemoteView) failed - ".concat(ve.message,": ").concat(i)),[2]);case 1:l.sent(),l.label=2;case 2:l.label=3;case 3:return n?[4,this.client.subscribe(n,{audio:!0,video:!0})]:[3,6];case 4:return l.sent(),[4,this.playStream(n,i)];case 5:l.sent(),this.handleOnFirstVideoFrame(t,r,i),this.clearTempAudioContainer("".concat(a,"_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.updateRemoteView=function(t,i,r){return v(this,void 0,void 0,(function(){var o,a;return S(this,(function(s){switch(s.label){case 0:return r===e.TRTCVideoStreamType.TRTCVideoStreamTypeBig?o=ne(t):r===e.TRTCVideoStreamType.TRTCVideoStreamTypeSub&&(o=ce(t)),a=this.remoteStreamMap.get(o),[4,this.playStream(a,i)];case 1:return s.sent(),[2]}}))}))},i.prototype.stopRemoteView=function(t,i){return v(this,void 0,void 0,(function(){var r,o,a,s;return S(this,(function(n){switch(n.label){case 0:return n.trys.push([0,4,,5]),r=ne(t),o=i,se(i)||(o=this.priorRemoteVideoStreamType),console.log("stopRemoteView streamType: ",o),i===e.TRTCVideoStreamType.TRTCVideoStreamTypeSub&&(r=ce("".concat(Y).concat(t)),this.remoteStreamMap.has(r)||(r=ce(t))),this.remoteStreamMap.has(r)?(a=this.remoteStreamMap.get(r),i!==e.TRTCVideoStreamType.TRTCVideoStreamTypeSub?[3,1]:[3,3]):[3,3];case 1:return[4,this.client.subscribe(a,{audio:!0,video:!1})];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:return s=n.sent(),this.callFunctionErrorManage(s,"stopRemoteView"),[3,5];case 5:return[2]}}))}))},i.prototype.muteRemoteVideoStream=function(e,t){void 0===t&&(t=!1);try{if(!e)return this.emitError(ve),void this.log_.error("(muteRemoteVideoStream) failed - ".concat(ve.message,": userId = ").concat(e));var i=this.remoteStreamMap.get(ne(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 S(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){return v(this,void 0,void 0,(function(){var i,r,o,a;return S(this,(function(s){switch(s.label){case 0:this.localRenderParams=t,s.label=1;case 1:return s.trys.push([1,4,,5]),i={},t.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable&&(i.mirror=!0),t.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable&&(i.mirror=!1),t.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto&&this.localStream&&this.localStream.facingMode_&&(this.localStream.facingMode_===$?i.mirror=!0:this.localStream.facingMode_===ee&&(i.mirror=!1)),t.fillMode===e.TRTCVideoFillMode.TRTCVideoFillMode_Fill&&(i.objectFit="cover"),t.fillMode===e.TRTCVideoFillMode.TRTCVideoFillMode_Fit&&(i.objectFit="contain"),this.localStreamRenderParams=i,this.localStream?(r=this.playViewMap.get("".concat(this.localPlayStream.getUserId(),"-").concat(this.localPlayStream.getType())),[4,this.playStream(this.localPlayStream,r,i)]):[3,3];case 2:s.sent(),s.label=3;case 3:return this.testCameraStream&&(o=this.playViewMap.get("".concat(this.testCameraStream.getUserId(),"-").concat(this.testCameraStream.getType())),this.playStream(this.testCameraStream,o,i)),[3,5];case 4:return a=s.sent(),this.callFunctionErrorManage(a,"setLocalRenderParams"),[3,5];case 5:return[2]}}))}))},i.prototype.setRemoteRenderParams=function(t,i,r){return v(this,void 0,void 0,(function(){var o,a,s,n,c;return S(this,(function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),o={},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=ne(t),i===e.TRTCVideoStreamType.TRTCVideoStreamTypeSub&&(a=ce(t)),s=this.playViewMap.get(a),(n=this.remoteStreamMap.get(a))?[4,this.playStream(n,s,o)]:[3,2];case 1:l.sent(),l.label=2;case 2:return[3,4];case 3:return c=l.sent(),this.callFunctionErrorManage(c,"setRemoteRenderParams"),[3,4];case 4:return[2]}}))}))},i.prototype.startCameraDeviceTest=function(e){return v(this,void 0,void 0,(function(){var t;return S(this,(function(i){switch(i.label){case 0:return this.log_.info("(startCameraDeviceTest) start - start test camera Device",e),null===e?[3,2]:(t={userId:"test camera",video:!0,audio:!1,screenAudio:!1},this.currentCameraId&&(t.cameraId=this.currentCameraId),this.testCameraStream=this.TRTC.createStream(t),this.videoEncodeParam&&this.testCameraStream.setVideoProfile(this.videoEncodeParam),[4,this.testCameraStream.initialize()]);case 1:i.sent(),this.playStream(this.testCameraStream,e,this.localStreamRenderParams),i.label=2;case 2:return[2]}}))}))},i.prototype.stopCameraDeviceTest=function(){this.log_.info("(stopCameraDeviceTest) stop - stop test camera Device"),this.testCameraStream&&(this.testCameraStream.stop(),this.testCameraStream.close(),this.testCameraStream=null)},i}(le(Te)),Ae=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return s(i,t),i.prototype.startLocalAudio=function(e){return v(this,void 0,void 0,(function(){var t;return S(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(),this.handleOnMicDidReady(),[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,a,s,n,c,l;return S(this,(function(u){switch(u.label){case 0:if(this.isStaringLocalPreview)throw new Error("startLocalPreview is under implementation.");u.label=1;case 1:return u.trys.push([1,14,,15]),i=t,se(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(re[i||e.TRTCAudioQuality.TRTCAudioQualityDefault]),[4,o.initialize()];case 2:return u.sent(),a=o.getAudioTrack(),[4,this.generateLocalPlayStream(r,t)];case 3:if(u.sent(),!this.localStream)return[3,11];u.label=4;case 4:return u.trys.push([4,9,,10]),(s=this.localStream.getAudioTrack())?[4,this.localStream.replaceTrack(a)]:[3,6];case 5:return u.sent(),s.stop(),[3,8];case 6:return[4,this.localStream.addTrack(a)];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:throw n=u.sent(),o.close(),n;case 10:return[3,12];case 11:this.localStream=o,c=this.generateTempAudioContainer("localAudio"),this.localPlayStream&&this.localPlayStream.play(c),u.label=12;case 12:return this.isStaringLocalAudio||(l=this.generateTempAudioContainer("localPublishAudio"),this.localStream&&this.localStream.play(l)),this.isStartedLocalAudio=!0,[4,this.publishLocalStream()];case 13:return u.sent(),this.muteLocalAudio(this.isAudioMute_),this.isStaringLocalAudio=!1,this.isPublished||this.getLocalStreamAudioLevel(),[3,15];case 14:throw u.sent();case 15: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:"",volume:i}),e.emit("onUserVoiceVolume",t,t.length)}),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 S(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,o;return S(this,(function(a){switch(a.label){case 0:return a.trys.push([0,5,,6]),[4,this.stopLocalPlayStreamTrack(j)];case 1:return a.sent(),this.localStream?(this.enableAudioVolumeTimer&&clearInterval(this.enableAudioVolumeTimer),e=this.localStream.getVideoTrack(),this.clearTempAudioContainer("localPublishAudio"),e?((r=this.localStream.getAudioTrack())&&this.localStream.removeTrack(r).then((function(){r.stop(),t(1)})),[3,4]):[3,2]):[3,4];case 2:return[4,this.unPublishStream()];case 3:a.sent(),this.localStream.stop(),this.localStream.close(),this.clearTempAudioContainer("localAudio"),this.localStream=null,t(1),a.label=4;case 4:return[3,6];case 5:return o=a.sent(),this.callFunctionErrorManage(o,"stopLocalAudio"),i(o),[3,6];case 6:return[2]}}))}))}))]:(this.log_.info("(stopLocalAudio) stop - local audio has not been started"),[2])}))}))},i.prototype.muteLocalAudio=function(e){void 0===e&&(e=!1),this.isAudioMute_=e;try{this.localStream&&(e?(this.localStream.muteAudio(),this.localPlayStream.muteAudio()):(this.localStream.unmuteAudio(),this.localPlayStream.unmuteAudio()))}catch(t){this.callFunctionErrorManage(t,"muteLocalAudio")}},i.prototype.muteRemoteAudio=function(e,t){void 0===t&&(t=!1);try{if(!e)return this.emitError(ve),void this.log_.error("(muteRemoteVideoStream) failed - ".concat(ve.message,": userId = ").concat(e));var i=this.remoteStreamMap.get(ne(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(ve),void this.log_.error("(muteRemoteVideoStream) failed - ".concat(ve.message,": userId = ").concat(e,", volume = ").concat(t));var i=this.remoteStreamMap.get(ne(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.prototype.startMicDeviceTest=function(t){return v(this,void 0,void 0,(function(){var i,r,o=this;return S(this,(function(a){switch(a.label){case 0:return this.log_.info("(startMicDeviceTest) start - start test mic Device",t),i={userId:"test mic",video:!1,audio:!0,screenAudio:!1},this.currentMicId&&(i.microphoneId=this.currentMicId),this.testMicrophoneStream=this.TRTC.createStream(i),this.testMicrophoneStream.setAudioProfile(re[e.TRTCAudioQuality.TRTCAudioQualityDefault]),[4,this.testMicrophoneStream.initialize()];case 1:return a.sent(),r=this.generateTempAudioContainer("testAudio"),this.testMicrophoneStream&&this.testMicrophoneStream.play(r),this.testMicrophoneStream&&t>0&&(this.testAudioVolumeTimer=setInterval((function(){var e=Math.floor(100*o.testMicrophoneStream.getAudioLevel());o.emit("onTestMicVolume",e)}),t)),[2]}}))}))},i.prototype.stopMicDeviceTest=function(){this.log_.info("(stopMicDeviceTest) stop - stop test mic Device"),this.testAudioVolumeTimer&&clearInterval(this.testAudioVolumeTimer),this.testMicrophoneStream&&(this.testMicrophoneStream.stop(),this.testMicrophoneStream.close(),this.testMicrophoneStream=null)},i}(le(Te)),_e=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return s(i,t),i.prototype.getCameraDevicesList=function(){return v(this,void 0,Promise,(function(){var e,t;return S(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 p(p({},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 S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),t?this.currentCameraId===t?[2,Promise.resolve(!0)]:(this.currentCameraId=t||"",de(this.localStream)?[4,this.localStream.switchDevice(J,t)]:[3,2]):[2,Promise.resolve(!1)];case 1:r.sent(),r.label=2;case 2:return de(this.localPlayStream)?[4,this.localPlayStream.switchDevice(J,t)]:[3,4];case 3:r.sent(),r.label=4;case 4:return de(this.testCameraStream)?[4,this.testCameraStream.switchDevice("video",t)]:[3,6];case 5:r.sent(),r.label=6;case 6:return this.emitOnDeviceChange(t,e.TRTCDeviceType.TRTCDeviceTypeCamera,e.TRTCDeviceState.TRTCDeviceStateActive),[2,Promise.resolve(!0)];case 7:return i=r.sent(),this.callFunctionErrorManage(i,"setCurrentCameraDevice"),this.cameraList=[],[2,Promise.resolve(!1)];case 8:return[2]}}))}))},i.prototype.getCurrentCameraDevice=function(){var e=this;return(this.cameraList||[]).filter((function(t){return t.deviceId===e.currentCameraId}))[0]||{}},i.prototype.isFrontCamera=function(){return!!this.localPlayStream&&this.localPlayStream.facingMode_===$},i.prototype.switchCamera=function(t){return v(this,void 0,void 0,(function(){var i,r;return S(this,(function(o){switch(o.label){case 0:return this.localStream&&this.localPlayStream?(i=t?$:ee,this.localStream.facingMode_===i?[2]:de(this.localPlayStream)?[4,this.localPlayStream.switchDevice(J,i)]:[3,2]):[2];case 1:o.sent(),o.label=2;case 2:return de(this.localStream)?[4,this.localStream.switchDevice(J,i)]:[3,4];case 3:o.sent(),o.label=4;case 4:return this.localRenderParams&&this.localRenderParams.mirrorType===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto&&(i===$?this.localStreamRenderParams.mirror=!0:i===ee&&(this.localStreamRenderParams.mirror=!1)),r=this.playViewMap.get("".concat(this.localPlayStream.getUserId(),"-").concat(this.localPlayStream.getType())),[4,this.playStream(this.localPlayStream,r,this.localStreamRenderParams)];case 5:return o.sent(),[2]}}))}))},i}(le(Te)),we=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return s(i,t),i.prototype.getMicDevicesList=function(){return v(this,void 0,Promise,(function(){var e,t;return S(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 p(p({},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 C},i.prototype.setCurrentMicDevice=function(t){return v(this,void 0,Promise,(function(){var i;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,5,,6]),t?this.currentMicId===t?[2,Promise.resolve(!0)]:(this.currentMicId=t||"",me(this.localStream)?[4,this.localStream.switchDevice(j,t)]:[3,2]):[2,Promise.resolve(!1)];case 1:r.sent(),r.label=2;case 2:return me(this.localPlayStream)?[4,this.localPlayStream.switchDevice(j,t)]:[3,4];case 3:r.sent(),r.label=4;case 4:return this.emitOnDeviceChange(t,e.TRTCDeviceType.TRTCDeviceTypeMic,e.TRTCDeviceState.TRTCDeviceStateActive),[2,Promise.resolve(!0)];case 5:return i=r.sent(),this.callFunctionErrorManage(i,"setCurrentMicDevice"),[2,Promise.resolve(!1)];case 6:return[2]}}))}))},i.prototype.getSpeakerDevicesList=function(){return v(this,void 0,Promise,(function(){var e,t;return S(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 p(p({},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 C},i.prototype.setCurrentSpeakerDevice=function(e){return v(this,void 0,Promise,(function(){var t,i,r=this;return S(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 S(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:o.sent(),o.label=2;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}(le(Te)),Me=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return s(i,t),i.prototype.startScreenCapture=function(){this.emitError(Re)},i.prototype.pauseScreenCapture=function(){this.emitError(Re)},i.prototype.resumeScreenCapture=function(){this.emitError(Re)},i.prototype.getScreenCaptureSources=function(){this.emitError(Re)},i.prototype.selectScreenCaptureTarget=function(){this.emitError(Re)},i.prototype.startScreenShare=function(t,i,r){return v(this,void 0,void 0,(function(){var o,a,s,n,c,l,u,h,d;return S(this,(function(m){switch(m.label){case 0:if(!this.isJoined||this.isJoining)return this.emitError(Ce),[2];if(i===e.TRTCVideoStreamType.TRTCVideoStreamTypeSmall)return this.emitError(be),[2];o=i||e.TRTCVideoStreamType.TRTCVideoStreamTypeSub,s=(a=r||{}).videoResolution,n=a.videoFps,c=a.videoBitrate,l=a.screenAudio,u=void 0!==l&&l,s&&(h=this.getResolution(s),this.screenShareParams_.width=h.width,this.screenShareParams_.height=h.height),n&&(this.screenShareParams_.frameRate=n),c&&(this.screenShareParams_.bitrate=c),m.label=1;case 1:return m.trys.push([1,4,,5]),[4,this.initShareStream_(!!u)];case 2:return m.sent(),[4,this.shareStreamPublish_(o)];case 3:return m.sent(),t&&this.shareStream_&&this.playStream(this.shareStream_,t),this.isSharing_=!0,[3,5];case 4:throw d=m.sent(),console.error("Start share screen error:",d),d;case 5:return[2]}}))}))},i.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(a){throw a}},i.prototype.stopScreenShare=function(){return v(this,void 0,void 0,(function(){var e;return S(this,(function(t){switch(t.label){case 0: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.client.unpublish(this.shareStream_)]:[3,3];case 2:t.sent(),this.shareStream_.close(),t.label=3;case 3:return this.isShareStreamPublished_=!1,this.shareStream_=null,this.isSharing_=!1,console.log("Unpublish ShareStream success"),[3,5];case 4:throw e=t.sent(),console.error("unpublish failed",e),e;case 5:return[2]}}))}))},i.prototype.initShareStream_=function(e){return v(this,void 0,void 0,(function(){var t,i=this;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.shareStream_=this.TRTC.createStream({audio:!1,screen:!0,userId:this.userId,screenAudio:e}),this.shareStream_.setScreenProfile(this.screenShareParams_),[4,this.shareStream_.initialize()];case 1:return r.sent(),this.shareStream_.on("screen-sharing-stopped",(function(){console.log("ShareStream video track ended"),i.emit("onWebScreenSharingStopped"),i.stopScreenShare()})),[2,this.shareStream_];case 2:throw t=r.sent(),console.error("ShareStream failed to initialize. Error: ".concat(t)),t;case 3:return[2]}}))}))},i.prototype.shareStreamPublish_=function(t){return v(this,void 0,void 0,(function(){var i;return S(this,(function(r){switch(r.label){case 0:if(this.isShareStreamPublished_)return console.warn("ShareClient duplicate publish() observed"),[2];r.label=1;case 1:return r.trys.push([1,6,,7]),t!==e.TRTCVideoStreamType.TRTCVideoStreamTypeSub?[3,3]:[4,this.client.publish(this.shareStream_,{isAuxiliary:!0})];case 2:return r.sent(),[3,5];case 3:return[4,this.client.publish(this.shareStream_)];case 4:r.sent(),r.label=5;case 5:return console.log("ShareStream is published successfully"),this.isShareStreamPublished_=!0,[3,7];case 6:throw i=r.sent(),console.error("ShareStream is failed to publish. Error: ".concat(i)),i;case 7:return[2]}}))}))},i}(le(Te)),Ie="1.0.13",De=null;o.default.Logger.loggerManager.info("TRTCCloud Version: ".concat(Ie));var Le=function(t){function i(){var e,i,r,o=t.call(this)||this;return o.enableAudioVolumeInterval=0,o.enableAudioVolumeTimer=-1,o.frameWorkType=30,o.component=0,o.VERSION=Ie,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&&navigator.mediaDevices&&navigator.mediaDevices.addEventListener("devicechange",(e=o.handleDeviceChange,i=30,function(){for(var t=this,o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];r>0&&clearTimeout(r),r=window.setTimeout((function(){e.apply(t,o),r=-1}),i)})),o.TRTC.getMicrophones().then((function(e){o.micList=e||[]})).catch((function(e){o.log_.error("getMicrophones error observed ".concat(e))})),o.TRTC.getCameras().then((function(e){o.cameraList=e||[]})).catch((function(e){o.log_.error("getCameras error observed ".concat(e))})),o.TRTC.getSpeakers().then((function(e){o.speakerList=e||[]})).catch((function(e){o.log_.error("getSpeakers error observed ".concat(e))})),o}return s(i,t),i.getTRTCShareInstance=function(){return De||(De=new i),De},i.destroyTRTCShareInstance=function(){De&&(De.destroy(),De=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,a,s,n,c,l,u,h,d,m,T,v;return S(this,(function(S){switch(S.label){case 0:if(i=e.sdkAppId,r=e.userId,o=e.userSig,a=e.roomId,s=e.strRoomId,n=e.role,c=e.privateMapKey,l=e.streamId,u=e.frameWorkType,h=e.component,d=void 0===h?0:h,!(i&&r&&o))return[3,6];if(this.sdkAppId=i,this.userId=r,this.userSig=o,this.roomId=a,this.strRoomId=s,this.useStringRoomId=Boolean(!a&&s),this.realRoomId=a||s,this.mode=ie[t],this.role=te[n],this.remoteUserAvailable=new Map,u&&typeof u===Z&&(this.frameWorkType=u),d&&typeof d===Z&&(this.component=d),this.isSharedStream(r))return this.log_.error("(enterRoom) failed - ".concat(ge.message," userId: ").concat(this.userId)),this.emitError(ge),[2];if(this.isJoining||this.isJoined)return this.log_.error("(enterRoom) failed - ".concat(Se.message," isJoining: ").concat(this.isJoining,", isJoined: ").concat(this.isJoined)),this.emitError(Se),[2];S.label=1;case 1:return S.trys.push([1,4,,5]),this.isJoining=!0,m={sdkAppId:i,userId:r,userSig:o,mode:this.mode,useStringRoomId:this.useStringRoomId,frameWorkType:this.frameWorkType,component:this.component},m=c?p(p({},m),{privateMapKey:c}):m,m=l?p(p({},m),{streamId:l}):m,this.initClient(m),this.startJoinTimestamp=ae(),[4,this.client.join({roomId:this.realRoomId,role:this.role})];case 2:return S.sent(),this.isJoined=!0,this.isJoining=!1,this.joinedTimestamp=ae(),T=this.joinedTimestamp-this.startJoinTimestamp,this.emit("onEnterRoom",T),this.log_.info("(enterRoom) success - enter room"),[4,this.publishLocalStream()];case 3:return S.sent(),[3,5];case 4:return v=S.sent(),this.isJoining=!1,this.emit("onEnterRoom",-1),this.callFunctionErrorManage(v,"enterRoom"),[3,5];case 5:return[3,7];case 6:this.emitError(ve),this.log_.error("(enterRoom) failed - ".concat(ve.message,": ").concat(JSON.stringify(e))),S.label=7;case 7:return[2]}}))}))},i.prototype.exitRoom=function(){return v(this,void 0,void 0,(function(){var e;return S(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(fe.message," isJoined: ").concat(this.isJoined," isExiting: ").concat(this.isExiting)),this.emitError(fe),[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",Q.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 S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),this.mode===H?(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?t===e.TRTCRoleType.TRTCRoleAnchor||t===e.TRTCRoleType.TRTCRoleAudience?[3,1]:(this.handleOnSwitchRole(-1,"please pass valid role parameter, role = ".concat(t,", type = ").concat(typeof t)),[3,5]):[3,6];case 1:return[4,this.client.switchRole(te[t])];case 2:return r.sent(),this.role=te[t],this.isPublished=!1,t===e.TRTCRoleType.TRTCRoleAnchor&&this.localStream?[4,this.publishLocalStream()]:[3,4];case 3:r.sent(),r.label=4;case 4:this.handleOnSwitchRole(0,"switch role success, role = ".concat(t,", ").concat(te[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):e<=0&&this.enableAudioVolumeTimer&&clearInterval(this.enableAudioVolumeTimer),this.enableAudioVolumeInterval=e},i.prototype.callFunctionErrorManage=function(e,t){e&&e.getCode&&e.getCode()?(this.emit(z,e.getCode(),e.message_),this.log_.error("(".concat(t,") failed - ").concat(e.message_))):(this.emit(z,pe,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.isVideoMute_=!1,this.isAudioMute_=!1,this._enableAudioVolumeTimer=-1,this.remoteStreamMap.clear(),this.videoEncodeParam={width:this.defaultVideoWidth,height:this.defaultVideoHeight,frameRate:this.defaultVideoFps,bitrate:this.defaultVideoBitRate},this.screenShareParams_={width:this.defaultShareWidth_,height:this.defaultShareHeight_,frameRate:this.defaultShareFrameRate_,bitrate:this.defaultShareBitrate_}},i.prototype.publishLocalStream=function(){return v(this,void 0,void 0,(function(){var e,t,i,r,o,a,s,n,c;return S(this,(function(l){switch(l.label){case 0:if(t=(e=this).mode,i=e.role,r=e.isJoined,o=e.isPublishing,a=e.isPublished,s=e.localStream,n=e.client,t===K&&i===G)return this.log_.info("(publishLocalStream) failed - mode = ".concat(t,", role = ").concat(i)),[2];if(!r||o||a||!s||!n)return this.log_.info("(publishLocalStream) failed - isJoined = ".concat(r,",\n isPublishing = ").concat(o,", isPublished = ").concat(a,", localStream = ").concat(s,", client.userId = ").concat(n?n.getUserId():null)),[2];if(this.log_.info("(publishLocalStream) start - publish stream"),!r||a)return[3,6];this.isPublishing=!0,l.label=1;case 1:return l.trys.push([1,5,,6]),[4,this.setStreamVideoParam(this.videoEncodeParam)];case 2:return l.sent(),this.localStream?[4,this.client.publish(this.localStream)]:[3,4];case 3:l.sent(),this.isPublished=!0,this.enableAudioVolumeTimer&&clearInterval(this.enableAudioVolumeTimer),this.log_.info("(publishLocalStream) success - publish stream"),l.label=4;case 4:return this.isPublishing=!1,[3,6];case 5:return c=l.sent(),this.isPublishing=!1,this.callFunctionErrorManage(c,"publishLocalStream"),[3,6];case 6:return[2]}}))}))},i.prototype.unPublishStream=function(){return v(this,void 0,void 0,(function(){return S(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 S(this,(function(o){switch(o.label){case 0:return o.trys.push([0,6,,10]),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 this.localPlayStream&&this.localPlayStream.hasVideo()?[4,this.localPlayStream.setVideoProfile(e)]:[3,5];case 4:o.sent(),o.label=5;case 5:return[3,10];case 6:return"OverconstrainedError"!==o.sent().name?[3,8]:(console.error("当前摄像头不支持该 profile"),[4,(r=this.TRTC.createStream({video:!0,audio:!1})).initialize()]);case 7:return o.sent(),this.localStream.replaceTrack(r.getVideoTrack()),[3,9];case 8:console.error("当前浏览器不支持动态调用该接口"),o.label=9;case 9:return[3,10];case 10: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 S(this,(function(t){switch(t.label){case 0:return this.localStream=this.TRTC.createStream(e),this.videoEncodeParam&&this.localStream&&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(ve),!this.localStream)return!1;switch(e){case J:return!!this.localStream.getVideoTrack();case j:return!!this.localStream.getAudioTrack();default:return!1}},i.prototype.playStream=function(e,t,i){return v(this,void 0,void 0,(function(){var r,o,a;return S(this,(function(s){if(!t||!e)return this.log_.error("(playStream) failed - dom = ".concat(t,", stream = ").concat(e)),[2];if(!(r="string"==typeof t?document.getElementById(t):t))return this.log_.error("(playStream) failed - dom = ".concat(t,", stream = ").concat(e)),[2];try{e.play(r,i)}catch(n){}return o=e.getUserId(),o=this.isSharedStream(o)?o.slice(6):o,a=e.getType(),this.playViewMap.set("".concat(o,"-").concat(a),t),[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",Q.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(z,e.code,e.message)},i.prototype.handleError=function(e){this.log_.error("handle error observed ".concat(e)),this.emit(z,e.getCode(),e.message)},i.prototype.handleEnterRoom=function(){},i.prototype.handleExitRoom=function(){},i.prototype.handlePeerJoin=function(e){var t=e.userId;if(!this.isSharedStream(t)||!this.remoteUserAvailable.has(t)){var i=Array.from(this.remoteUserAvailable.keys())||[];this.remoteUserAvailable.set(t,{isAudioAvailable:!1,isVideoAvailable:!1}),he(this.userId,t)||(i.filter((function(e){return he(e,t)}))||[]).length>0||this.isSharedStream(t)||this.emit("onRemoteUserEnterRoom",t)}},i.prototype.handlePeerLeave=function(e){var t=e.userId,i=void 0===t?"":t;this.isSharedStream(i)||this.emit("onRemoteUserLeaveRoom",i,0)},i.prototype.handleOnUserAudioAvailable=function(e,t,i){return v(this,void 0,void 0,(function(){var r;return S(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){try{this.remoteUserAvailable.get(e).isVideoAvailable=t;var i=e;if(this.isSharedStream(e)&&(i=e.slice(6))===this.userId)return;this.emit("onUserSubStreamAvailable",i,t?1:0)}catch(r){this.emitError(ve)}},i.prototype.handleOnSwitchRole=function(e,t){this.emit("onSwitchRole",e,t)},i.prototype.handleAudioVolume=function(e){var t=this,i=e.result||[];i=(i=i.map((function(e){return{userId:e.userId===t.userId?"":e.userId,volume:e.audioVolume}}))||[]).filter((function(e){return!t.isSharedStream(e.userId)})),this.emit("onUserVoiceVolume",i,i.length)},i.prototype.handleOnFirstVideoFrame=function(e,t,i){var r=i.offsetWidth,o=i.offsetHeight;this.emit("onFirstVideoFrame",e,t,r,o)},i.prototype.handleOnMicDidReady=function(){this.emit("onMicDidReady")},i.prototype.handleStreamAdded_=function(e){return v(this,void 0,void 0,(function(){var t,i,r;return S(this,(function(o){switch(o.label){case 0:return t=e.stream,i=t.getUserId(),r=t.getType(),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:t.hasVideo()&&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 S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.client.subscribe(e,{audio:!!se(t.audio)||t.audio,video:!!se(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 S(this,(function(r){switch(r.label){case 0:return t=e.stream.getUserId(),(i=e.stream.getType())!==W?[3,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,o;return S(this,(function(a){switch(a.label){case 0:return t=e.stream,i=t.getUserId(),(r=t.getType())===X?[2]:(o=this.remoteStreamMap.get("".concat(i,"-").concat(r))).hasAudio()||!t.hasAudio()||this.remoteUserAvailable.get(i).isAudioAvailable?[3,2]:[4,this.handleOnUserAudioAvailable(i,!0,r)];case 1:a.sent(),a.label=2;case 2:return o.hasVideo()||!t.hasVideo()||this.remoteUserAvailable.get(i).isVideoAvailable||this.handleOnUserVideoAvailable(i,!0),[2]}}))}))},i.prototype.handleMuteAudio=function(e){return v(this,void 0,void 0,(function(){var t;return S(this,(function(i){switch(i.label){case 0:return t=e.userId,this.isSharedStream(t)?[2]:t?[4,this.handleOnUserAudioAvailable(t,!1,W)]:[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 S(this,(function(i){switch(i.label){case 0:return t=e.userId,this.isSharedStream(t)?[2]:!t||this.remoteUserAvailable.get(t).isAudioAvailable?[3,2]:[4,this.handleOnUserAudioAvailable(t,!0,W)];case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},i.prototype.handleMuteVideo=function(e){var t=e.userId;this.isSharedStream(t)||t&&this.handleOnUserVideoAvailable(t,!1)},i.prototype.handleUnmuteVideo=function(e){var t=e.userId;if(!this.isSharedStream(t)&&t&&!this.remoteUserAvailable.get(t).isVideoAvailable){if(((Array.from(this.remoteUserAvailable.keys())||[]).filter((function(e){return he(e,t)}))||[]).length>0)return void this.handleOnUserSubStreamAvailable(t,!0);if(this.isSharedStream(t)&&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,a=r.framesEncoded-t.prevLocalVideoStats.framesEncoded,s=r.frameWidth,n=r.frameHeight;o<0&&(o=0),a<0&&(a=0),t.prevLocalVideoStats=r;var c=Number((8*o/1e3/2).toFixed()),l=Number((a/2).toFixed()),u=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig;return new E(s,n,l,c,0,0,u)}))},i.prototype.handleNetworkQuality=function(e){return v(this,void 0,void 0,(function(){var t,i,r,o,a,s,n,c,l,u,h;return S(this,(function(d){switch(d.label){case 0:return t=e.uplinkNetworkQuality,i=e.downlinkNetworkQuality,r=e.uplinkRTT,o=e.uplinkLoss,a=e.downlinkLoss,s=this.client?this.client.getUserId():"",n=new I(s,t),this.remoteStreamMap.size>0&&(c=(c=Array.from(this.remoteStreamMap.keys())).map((function(e){return e.includes("-".concat(W))?e.split("-".concat(W))[0]:e.includes("-".concat(X))?e.split("-".concat(X))[0]:""})),c=Array.from(new Set(c.filter((function(e){return e})))),l=c.map((function(e){return{userId:e,quality:i}})),this.emit("onNetworkQuality",n,l)),[4,this.getLocalStatistics()];case 1:return u=d.sent(),h=new k(o,a,0,0,r,0,0,[u]),this.emit("onStatistics",h),[2]}}))}))},i.prototype.handleDeviceChange=function(){return v(this,void 0,void 0,(function(){var t=this;return S(this,(function(i){return this.TRTC.getCameras().then((function(i){return v(t,void 0,void 0,(function(){return S(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 S(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 S(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,a,s,n,c;return S(this,(function(l){switch(l.label){case 0:return t.length===i.length?[3,8]:(o=(i||[]).map((function(e){return e.deviceId})),a=new C,s=e.TRTCDeviceState.TRTCDeviceStateAdd,t.length>i.length&&(a=t.filter((function(e){return!o.includes(e.deviceId)}))[0]||{},s=e.TRTCDeviceState.TRTCDeviceStateRemove),t.length<i.length&&(o=(t||[]).map((function(e){return e.deviceId})),a=i.filter((function(e){return!o.includes(e.deviceId)}))[0]||{}),n=a.deviceId,this.emitOnDeviceChange(n,r,s),s!==e.TRTCDeviceState.TRTCDeviceStateAdd?[3,2]:[4,this.autoChangeDevice(r,s,n)]);case 1:return l.sent(),[3,8];case 2:return s!==e.TRTCDeviceState.TRTCDeviceStateRemove?[3,8]:n!==this.currentSpeakerId&&n!==this.currentMicId?[3,5]:(c=this.getDefaultDeviceInfo(i)).deviceId?[4,this.autoChangeDevice(r,s,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,s,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 o,a=this;return S(this,(function(s){switch(s.label){case 0:return t!==e.TRTCDeviceType.TRTCDeviceTypeCamera||i!==e.TRTCDeviceState.TRTCDeviceStateRemove?[3,5]:(this.currentCameraId=r,de(this.localStream)?[4,this.localStream.switchDevice(J,r)]:[3,2]);case 1:s.sent(),s.label=2;case 2:return de(this.localPlayStream)?[4,this.localPlayStream.switchDevice(J,r)]:[3,4];case 3:s.sent(),s.label=4;case 4:this.emitOnDeviceChange(r,t,e.TRTCDeviceState.TRTCDeviceStateActive),s.label=5;case 5:return t!==e.TRTCDeviceType.TRTCDeviceTypeMic?[3,10]:me(this.localStream)?[4,this.localStream.switchDevice(j,r)]:[3,7];case 6:s.sent(),s.label=7;case 7:return me(this.localPlayStream)?[4,this.localPlayStream.switchDevice(j,r)]:[3,9];case 8:s.sent(),s.label=9;case 9:this.currentMicId=r,this.emitOnDeviceChange(r,t,e.TRTCDeviceState.TRTCDeviceStateActive),s.label=10;case 10:return t!==e.TRTCDeviceType.TRTCDeviceTypeSpeaker?[3,13]:this.remoteStreamMap.size>0?(o=this.getRemoteStreamList(),[4,Promise.all(o.map((function(e){return v(a,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return[4,e.setAudioOutput(r)];case 1:return[2,t.sent()]}}))}))})))]):[3,12];case 11:s.sent(),s.label=12;case 12:this.currentSpeakerId=r,this.emitOnDeviceChange(r,t,e.TRTCDeviceState.TRTCDeviceStateActive),s.label=13;case 13: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 C;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!==N}))[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 this.isSharedStream(t)&&i===W&&(i=X),i},i.prototype.isSharedStream=function(e){return e.slice(0,6)===Y},i.prototype.generateLocalPlayStream=function(t,i){return v(this,void 0,void 0,(function(){var r,o,a,s,n,c,l,u,h;return S(this,(function(d){switch(d.label){case 0:return r=t.audio,o=t.video,this.localPlayStream&&this.localPlayStream.hasVideo()&&o||this.localPlayStream&&this.localPlayStream.hasAudio()&&r?[2]:((a=this.TRTC.createStream(t)).setAudioProfile(re[i||e.TRTCAudioQuality.TRTCAudioQualityDefault]),this.videoEncodeParam?[4,a.setVideoProfile(this.videoEncodeParam)]:[3,2]);case 1:d.sent(),d.label=2;case 2:return[4,a.initialize()];case 3:if(d.sent(),!r)return[3,12];if(s=a.getAudioTrack(),!this.localPlayStream)return[3,11];d.label=4;case 4:return d.trys.push([4,9,,10]),this.localPlayStream.hasAudio()?(n=this.localPlayStream.getAudioTrack(),[4,this.localPlayStream.replaceTrack(s)]):[3,6];case 5:return d.sent(),n.stop(),[3,8];case 6:return[4,this.localPlayStream.addTrack(s)];case 7:d.sent(),d.label=8;case 8:return[3,10];case 9:throw c=d.sent(),a.close(),c;case 10:return[3,12];case 11:this.localPlayStream=a,d.label=12;case 12:if(!o)return[3,21];if(l=a.getVideoTrack(),!this.localPlayStream)return[3,20];d.label=13;case 13:return d.trys.push([13,18,,19]),this.localPlayStream.hasVideo()?(u=this.localPlayStream.getVideoTrack(),[4,this.localPlayStream.replaceTrack(l)]):[3,15];case 14:return d.sent(),u.stop(),[3,17];case 15:return[4,this.localPlayStream.addTrack(l)];case 16:d.sent(),d.label=17;case 17:return[3,19];case 18:throw h=d.sent(),a.close(),h;case 19:return[3,21];case 20:this.localPlayStream=a,d.label=21;case 21:return[2]}}))}))},i.prototype.stopLocalPlayStreamTrack=function(e){return v(this,void 0,void 0,(function(){var t,i;return S(this,(function(r){switch(r.label){case 0:return this.localPlayStream?e!==J?[3,5]:this.localPlayStream.hasAudio()?(t=this.localPlayStream.getVideoTrack())?[4,this.localPlayStream.removeTrack(t)]:[3,2]:[3,3]:[3,10];case 1:r.sent(),t.stop(),r.label=2;case 2:return[3,4];case 3:this.localPlayStream.stop(),this.localPlayStream.close(),this.localPlayStream=null,r.label=4;case 4:this.isStartedLocalPreview=!1,r.label=5;case 5:return e!==j?[3,10]:this.localPlayStream.hasVideo()?(i=this.localPlayStream.getAudioTrack())?[4,this.localPlayStream.removeTrack(i)]:[3,7]:[3,8];case 6:r.sent(),i.stop(),r.label=7;case 7:return[3,9];case 8:this.localPlayStream.stop(),this.localPlayStream.close(),this.localPlayStream=null,r.label=9;case 9:this.isStartedLocalAudio=!1,r.label=10;case 10:return[2]}}))}))},i}(le(t.EventEmitter,Te,Ve,Pe,Ae,_e,we,Me));e.Rect=x,e.TRTCDeviceInfo=C,e.TRTCImageBuffer=O,e.TRTCLocalStatistics=E,e.TRTCNetworkQosParam=U,e.TRTCParams=b,e.TRTCPublishCDNParam=L,e.TRTCQualityInfo=I,e.TRTCRenderParams=A,e.TRTCScreenCaptureSourceInfo=B,e.TRTCStatistics=k,e.TRTCVideoEncParam=V,e.TRTCVolumeInfo=D,e.default=Le,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);
|
|
1
|
+
var global,factory;global=this,factory=function(e,t,i){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r,n,s,a,c,u,T,d,l=o(i),h=function(e,t){return h=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])},h(e,t)},p=function(){return p=Object.assign||function(e){for(var t,i=1,o=arguments.length;i<o;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},p.apply(this,arguments)};function R(e,t,i,o){return new(i||(i=Promise))((function(r,n){function s(e){try{c(o.next(e))}catch(t){n(t)}}function a(e){try{c(o.throw(e))}catch(t){n(t)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function C(e,t){var i,o,r,n,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(n){return function(a){return function(n){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,o&&(r=2&n[0]?o.return:n[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,n[1])).done)return r;switch(o=0,r&&(n=[2&n[0],r.value]),n[0]){case 0:case 1:r=n;break;case 4:return s.label++,{value:n[1],done:!1};case 5:s.label++,o=n[1],n=[0];continue;case 7:n=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==n[0]&&2!==n[0])){s=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]<r[3])){s.label=n[1];break}if(6===n[0]&&s.label<r[1]){s.label=r[1],r=n;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(n);break}r[2]&&s.ops.pop(),s.trys.pop();continue}n=t.call(e,s)}catch(a){n=[6,a],o=0}finally{i=r=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}}function _(e,t,i){if(i||2===arguments.length)for(var o,r=0,n=t.length;r<n;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}e.TRTCVideoResolution=void 0,(r=e.TRTCVideoResolution||(e.TRTCVideoResolution={}))[r.TRTCVideoResolution_120_120=1]="TRTCVideoResolution_120_120",r[r.TRTCVideoResolution_160_160=3]="TRTCVideoResolution_160_160",r[r.TRTCVideoResolution_270_270=5]="TRTCVideoResolution_270_270",r[r.TRTCVideoResolution_480_480=7]="TRTCVideoResolution_480_480",r[r.TRTCVideoResolution_160_120=50]="TRTCVideoResolution_160_120",r[r.TRTCVideoResolution_240_180=52]="TRTCVideoResolution_240_180",r[r.TRTCVideoResolution_280_210=54]="TRTCVideoResolution_280_210",r[r.TRTCVideoResolution_320_240=56]="TRTCVideoResolution_320_240",r[r.TRTCVideoResolution_400_300=58]="TRTCVideoResolution_400_300",r[r.TRTCVideoResolution_480_360=60]="TRTCVideoResolution_480_360",r[r.TRTCVideoResolution_640_480=62]="TRTCVideoResolution_640_480",r[r.TRTCVideoResolution_960_720=64]="TRTCVideoResolution_960_720",r[r.TRTCVideoResolution_160_90=100]="TRTCVideoResolution_160_90",r[r.TRTCVideoResolution_256_144=102]="TRTCVideoResolution_256_144",r[r.TRTCVideoResolution_320_180=104]="TRTCVideoResolution_320_180",r[r.TRTCVideoResolution_480_270=106]="TRTCVideoResolution_480_270",r[r.TRTCVideoResolution_640_360=108]="TRTCVideoResolution_640_360",r[r.TRTCVideoResolution_960_540=110]="TRTCVideoResolution_960_540",r[r.TRTCVideoResolution_1280_720=112]="TRTCVideoResolution_1280_720",r[r.TRTCVideoResolution_1920_1080=114]="TRTCVideoResolution_1920_1080",e.TRTCVideoStreamType=void 0,(n=e.TRTCVideoStreamType||(e.TRTCVideoStreamType={}))[n.TRTCVideoStreamTypeBig=0]="TRTCVideoStreamTypeBig",n[n.TRTCVideoStreamTypeSmall=1]="TRTCVideoStreamTypeSmall",n[n.TRTCVideoStreamTypeSub=2]="TRTCVideoStreamTypeSub",e.TRTCVideoFillMode=void 0,(s=e.TRTCVideoFillMode||(e.TRTCVideoFillMode={}))[s.TRTCVideoFillMode_Fill=0]="TRTCVideoFillMode_Fill",s[s.TRTCVideoFillMode_Fit=1]="TRTCVideoFillMode_Fit",e.TRTCVideoMirrorType=void 0,(a=e.TRTCVideoMirrorType||(e.TRTCVideoMirrorType={}))[a.TRTCVideoMirrorType_Auto=0]="TRTCVideoMirrorType_Auto",a[a.TRTCVideoMirrorType_Enable=1]="TRTCVideoMirrorType_Enable",a[a.TRTCVideoMirrorType_Disable=2]="TRTCVideoMirrorType_Disable",e.TRTCBeautyStyle=void 0,(c=e.TRTCBeautyStyle||(e.TRTCBeautyStyle={}))[c.TRTCBeautyStyleSmooth=0]="TRTCBeautyStyleSmooth",c[c.TRTCBeautyStyleNature=1]="TRTCBeautyStyleNature",e.TRTCAppScene=void 0,(u=e.TRTCAppScene||(e.TRTCAppScene={}))[u.TRTCAppSceneVideoCall=0]="TRTCAppSceneVideoCall",u[u.TRTCAppSceneLIVE=1]="TRTCAppSceneLIVE",u[u.TRTCAppSceneAudioCall=2]="TRTCAppSceneAudioCall",u[u.TRTCAppSceneVoiceChatRoom=3]="TRTCAppSceneVoiceChatRoom",e.TRTCRoleType=void 0,(T=e.TRTCRoleType||(e.TRTCRoleType={}))[T.TRTCRoleAnchor=20]="TRTCRoleAnchor",T[T.TRTCRoleAudience=21]="TRTCRoleAudience",e.TRTCAudioQuality=void 0,(d=e.TRTCAudioQuality||(e.TRTCAudioQuality={}))[d.TRTCAudioQualityDefault=0]="TRTCAudioQualityDefault",d[d.TRTCAudioQualitySpeech=1]="TRTCAudioQualitySpeech",d[d.TRTCAudioQualityMusic=3]="TRTCAudioQualityMusic";var v,f,y=function(e,t,i,o,r){void 0===e&&(e=""),void 0===t&&(t=""),void 0===i&&(i=""),void 0===o&&(o=""),void 0===r&&(r=""),this.deviceId=e,this.deviceName=t,this.kind=i,this.label=o,this.groupId=r};e.TRTCDeviceState=void 0,(v=e.TRTCDeviceState||(e.TRTCDeviceState={}))[v.TRTCDeviceStateAdd=0]="TRTCDeviceStateAdd",v[v.TRTCDeviceStateRemove=1]="TRTCDeviceStateRemove",v[v.TRTCDeviceStateActive=2]="TRTCDeviceStateActive",e.TRTCDeviceType=void 0,(f=e.TRTCDeviceType||(e.TRTCDeviceType={}))[f.TRTCDeviceTypeUnknow=-1]="TRTCDeviceTypeUnknow",f[f.TRTCDeviceTypeMic=0]="TRTCDeviceTypeMic",f[f.TRTCDeviceTypeSpeaker=1]="TRTCDeviceTypeSpeaker",f[f.TRTCDeviceTypeCamera=2]="TRTCDeviceTypeCamera";var m,g=function(t,i,o,r,n,s,a,c,u,T,d){void 0===t&&(t=0),void 0===i&&(i=""),void 0===o&&(o=""),void 0===r&&(r=0),void 0===n&&(n=""),void 0===s&&(s=e.TRTCRoleType.TRTCRoleAnchor),void 0===a&&(a=null),void 0===u&&(u=null),void 0===T&&(T=null),void 0===d&&(d=30),this.sdkAppId=t,this.userId=i,this.userSig=o,this.roomId=r,this.strRoomId=n,this.role=s,this.privateMapKey=a,this.streamId=u,this.userDefineRecordId=T,this.frameWorkType=d},V=function(t,i,o){void 0===t&&(t=e.TRTCVideoResolution.TRTCVideoResolution_640_360),void 0===i&&(i=15),void 0===o&&(o=550),this.videoResolution=t,this.videoFps=i,this.videoBitrate=o};e.TRTCVideoRotation=void 0,(m=e.TRTCVideoRotation||(e.TRTCVideoRotation={}))[m.TRTCVideoRotation0=0]="TRTCVideoRotation0",m[m.TRTCVideoRotation90=1]="TRTCVideoRotation90",m[m.TRTCVideoRotation180=2]="TRTCVideoRotation180",m[m.TRTCVideoRotation270=3]="TRTCVideoRotation270";var S,M=function(t,i,o){void 0===t&&(t=e.TRTCVideoRotation.TRTCVideoRotation0),void 0===i&&(i=e.TRTCVideoFillMode.TRTCVideoFillMode_Fit),void 0===o&&(o=e.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable),this.rotation=t,this.fillMode=i,this.mirrorType=o};e.TRTCQuality=void 0,(S=e.TRTCQuality||(e.TRTCQuality={}))[S.TRTCQuality_Unknown=0]="TRTCQuality_Unknown",S[S.TRTCQuality_Excellent=1]="TRTCQuality_Excellent",S[S.TRTCQuality_Good=2]="TRTCQuality_Good",S[S.TRTCQuality_Poor=3]="TRTCQuality_Poor",S[S.TRTCQuality_Bad=4]="TRTCQuality_Bad",S[S.TRTCQuality_Vbad=5]="TRTCQuality_Vbad",S[S.TRTCQuality_Down=6]="TRTCQuality_Down";var A,I,E,b=function(t,i){void 0===t&&(t=""),void 0===i&&(i=e.TRTCQuality.TRTCQuality_Unknown),this.userId=t,this.quality=i},D=function(e,t){void 0===e&&(e=""),void 0===t&&(t=0),this.userId=e,this.volume=t},w=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},P=function(t,i,o,r,n,s,a){void 0===t&&(t=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===a&&(a=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig),this.width=t,this.height=i,this.frameRate=o,this.videoBitrate=r,this.audioSampleRate=n,this.audioBitrate=s,this.streamType=a},L=function(e,t,i,o,r,n,s,a,c,u){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===a&&(a=[]),void 0===c&&(c=0),void 0===u&&(u=0),this.upLoss=e,this.downLoss=t,this.appCpu=i,this.systemCpu=o,this.rtt=r,this.receivedBytes=n,this.sentBytes=s,this.localStatisticsArray=a,this.localStatisticsArraySize=c,this.remoteStatisticsArraySize=u};e.TRTCVideoResolutionMode=void 0,(A=e.TRTCVideoResolutionMode||(e.TRTCVideoResolutionMode={}))[A.TRTCVideoResolutionModeLandscape=0]="TRTCVideoResolutionModeLandscape",A[A.TRTCVideoResolutionModePortrait=1]="TRTCVideoResolutionModePortrait",e.TRTCVideoQosPreference=void 0,(I=e.TRTCVideoQosPreference||(e.TRTCVideoQosPreference={}))[I.TRTCVideoQosPreferenceSmooth=1]="TRTCVideoQosPreferenceSmooth",I[I.TRTCVideoQosPreferenceClear=2]="TRTCVideoQosPreferenceClear",e.TRTCQosControlMode=void 0,(E=e.TRTCQosControlMode||(e.TRTCQosControlMode={}))[E.TRTCQosControlModeClient=0]="TRTCQosControlModeClient",E[E.TRTCQosControlModeServer=1]="TRTCQosControlModeServer";var O,F=function(t,i){void 0===t&&(t=e.TRTCVideoQosPreference.TRTCVideoQosPreferenceClear),void 0===i&&(i=e.TRTCQosControlMode.TRTCQosControlModeServer),this.preference=t,this.controlMode=i},k=function(e,t,i,o){void 0===e&&(e=new ArrayBuffer(0)),void 0===t&&(t=0),void 0===i&&(i=0),void 0===o&&(o=0),this.buffer=e,this.length=t,this.width=i,this.height=o};e.TRTCScreenCaptureSourceType=void 0,(O=e.TRTCScreenCaptureSourceType||(e.TRTCScreenCaptureSourceType={}))[O.TRTCScreenCaptureSourceTypeUnknown=-1]="TRTCScreenCaptureSourceTypeUnknown",O[O.TRTCScreenCaptureSourceTypeWindow=0]="TRTCScreenCaptureSourceTypeWindow",O[O.TRTCScreenCaptureSourceTypeScreen=1]="TRTCScreenCaptureSourceTypeScreen",O[O.TRTCScreenCaptureSourceTypeCustom=2]="TRTCScreenCaptureSourceTypeCustom";var Q,N=function(t,i,o,r,n,s){void 0===t&&(t=e.TRTCScreenCaptureSourceType.TRTCScreenCaptureSourceTypeUnknown),void 0===i&&(i=""),void 0===o&&(o=""),void 0===r&&(r=new k),void 0===n&&(n=new k),void 0===s&&(s=!1),this.type=t,this.sourceId=i,this.sourceName=o,this.thumbBGRA=r,this.iconBGRA=n,this.isMinimizeWindow=s},B=function(e,t,i,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===o&&(o=0),this.left=e,this.top=t,this.right=i,this.bottom=o},U=function(t,i,o,r,n,s,a,c,u,T,d,l,h,p,R){void 0===t&&(t=e.TRTCTranscodingConfigMode.TRTCTranscodingConfigMode_Unknown),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===a&&(a=15),void 0===c&&(c=2),void 0===u&&(u=0),void 0===T&&(T=""),void 0===d&&(d=64),void 0===l&&(l=48e3),void 0===h&&(h=1),void 0===p&&(p=[]),void 0===R&&(R=""),this.mode=t,this.appId=i,this.bizId=o,this.videoWidth=r,this.videoHeight=n,this.videoBitrate=s,this.videoFramerate=a,this.videoGOP=c,this.backgroundColor=u,this.backgroundImage=T,this.audioSampleRate=d,this.audioBitrate=l,this.audioChannels=h,this.mixUsersArray=p,this.mixUsersArraySize=p.length,this.streamId=R};e.TRTCTranscodingConfigMode=void 0,(Q=e.TRTCTranscodingConfigMode||(e.TRTCTranscodingConfigMode={}))[Q.TRTCTranscodingConfigMode_Unknown=0]="TRTCTranscodingConfigMode_Unknown",Q[Q.TRTCTranscodingConfigMode_Manual=1]="TRTCTranscodingConfigMode_Manual",Q[Q.TRTCTranscodingConfigMode_Template_PureAudio=2]="TRTCTranscodingConfigMode_Template_PureAudio",Q[Q.TRTCTranscodingConfigMode_Template_PresetLayout=3]="TRTCTranscodingConfigMode_Template_PresetLayout",Q[Q.TRTCTranscodingConfigMode_Template_ScreenSharing=4]="TRTCTranscodingConfigMode_Template_ScreenSharing",Q[Q.TRTC_TranscodingConfigMode_Unknown=5]="TRTC_TranscodingConfigMode_Unknown",Q[Q.TRTC_TranscodingConfigMode_Manual=6]="TRTC_TranscodingConfigMode_Manual",Q[Q.TRTC_TranscodingConfigMode_Template_PureAudio=7]="TRTC_TranscodingConfigMode_Template_PureAudio",Q[Q.TRTC_TranscodingConfigMode_Template_PresetLayout=8]="TRTC_TranscodingConfigMode_Template_PresetLayout",Q[Q.TRTC_TranscodingConfigMode_Template_ScreenSharing=9]="TRTC_TranscodingConfigMode_Template_ScreenSharing";var x,j=function(t,i,o,r,n,s,a,c){void 0===t&&(t=""),void 0===i&&(i=""),void 0===o&&(o=null),void 0===r&&(r=0),void 0===n&&(n=!1),void 0===s&&(s=e.TRTCVideoStreamType.TRTCVideoStreamTypeBig),void 0===a&&(a=e.TRTCMixInputType.TRTCMixInputTypeUndefined),void 0===c&&(c=0),this.userId=t,this.roomId=i,this.rect=o,this.zOrder=r,this.pureAudio=n,this.streamType=s,this.inputType=a,this.renderMode=c};e.TRTCMixInputType=void 0,(x=e.TRTCMixInputType||(e.TRTCMixInputType={}))[x.TRTCMixInputTypeUndefined=0]="TRTCMixInputTypeUndefined",x[x.TRTCMixInputTypeAudioVideo=1]="TRTCMixInputTypeAudioVideo",x[x.TRTCMixInputTypePureVideo=2]="TRTCMixInputTypePureVideo",x[x.TRTCMixInputTypePureAudio=3]="TRTCMixInputTypePureAudio";var W,Y="onError",G="rtc",K="live",z={20:"anchor",21:"audience"},H={0:G,1:K,2:G,3:K},J={0:"standard",1:"high",2:"standard_stereo",3:"high_stereo"};function q(){return Math.floor(performance.now())}!function(e){e[e.ActiveExitRoom=0]="ActiveExitRoom",e[e.KickedExitRoom=1]="KickedExitRoom"}(W||(W={}));var X,Z,$=function(e){return void 0===e};function ee(e,t){for(var i=0,o=Reflect.ownKeys(t);i<o.length;i++){var r=o[i];if("constructor"!==r&&"prototype"!==r&&"name"!==r){var n=Object.getOwnPropertyDescriptor(t,r)||"";Object.defineProperty(e,r,n)}}}!function(e){e.LIVE="live",e.RTC="rtc"}(X||(X={})),function(e){e.CONTAIN="contain",e.COVER="cover",e.FILL="fill"}(Z||(Z={}));var te=-1e3,ie={code:-1001,message:"参数错误, 请检查参数格式、是否非空等"},oe={code:-1005,message:"not supported"},re="2.1.0",ne=null,se="【TRTCCloud】";l.default._loggerManager.info("TRTCCloud Version: ".concat(re));var ae=function(t){function i(i){void 0===i&&(i={});var o=t.call(this)||this;o._version="",o._frameWorkType=30,o._component=0,o._localView=null,o._localTestView=null,o._isVideoPublish=!0,o._localRenderParams={rotation:e.TRTCVideoRotation.TRTCVideoRotation0,fillMode:e.TRTCVideoFillMode.TRTCVideoFillMode_Fill,mirrorType:e.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto},o._videoProfile={},o._videoPlayOption={},o._isAudioPublish=!0,o._audioProfile=Object.keys(J)[0],o._isSharingScreen=!1,o._remoteStreamConfig=new Map,o._remoteStreamMap=new Map,o._cameraList=[],o._microphoneList=[],o._speakerList=[],o._currentCamera={},o._currentMicrophone={},o._currentSpeaker={},o._currentCameraId="",o._currentMicrophoneId="",o._currentSpeakerId="",o._screenShareParams={option:{}},o._isMobile=!1,o._isFrontCamera=!1,o._defaultVideoProfile={width:640,height:480,frameRate:15,bitrate:900},o._defaultScreenProfile={width:1920,height:1080,frameRate:15,bitrate:1500},o._version=re;var r,n,s,a=i.frameWorkType,c=void 0===a?30:a,u=i.component,T=void 0===u?0:u;return o._trtc=l.default.create({frameWorkType:c,component:T}),o._testTrtc=l.default.create(),o._log=l.default._loggerManager,o._addTRTCEvents(),o.handleDeviceChange=o.handleDeviceChange.bind(o),navigator&&navigator.mediaDevices&&navigator.mediaDevices.addEventListener("devicechange",(r=o.handleDeviceChange,n=30,function(){for(var e=this,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];s>0&&clearTimeout(s),s=window.setTimeout((function(){r.apply(e,t),s=-1}),n)})),o}return function(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}h(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(i,t),i.getTRTCShareInstance=function(e){return ne||(ne=new i(e)),ne},i.prototype.destroyTRTCShareInstance=function(){ne&&(this._removeTRTCEvents(),ne._destroy(),ne=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 R(this,void 0,Promise,(function(){var i,o,r,n,s,a,c,u,T,d,l,h,R,_,v,f;return C(this,(function(C){switch(C.label){case 0:if(i=e.sdkAppId,o=e.userId,r=e.userSig,n=e.roomId,s=e.strRoomId,a=e.role,c=e.privateMapKey,u=e.businessInfo,T=e.enableAutoPlayDialog,d=e.proxy,l=e.streamId,h=e.userDefineRecordId,!(i&&o&&r))return[3,5];C.label=1;case 1:return C.trys.push([1,3,,4]),R={sdkAppId:i,userId:o,userSig:r,roomId:n||s,role:z[a],scene:H[t],frameWorkType:this._frameWorkType,component:this._component},R=c?p(p({},R),{privateMapKey:c}):R,R=u?p(p({},R),{businessInfo:u}):R,R=T?p(p({},R),{enableAutoPlayDialog:T}):R,R=d?p(p({},R),{proxy:d}):R,R=l?p(p({},R),{streamId:l}):R,R=h?p(p({},R),{userDefineRecordId:h}):R,_=q(),[4,this._trtc.enterRoom(R)];case 2:return C.sent(),v=q()-_,this.emit("onEnterRoom",v),[3,4];case 3:return f=C.sent(),this.emit("onEnterRoom",-1),this._callFunctionErrorManage(f,"enterRoom"),[3,4];case 4:return[3,6];case 5:this._emitError(ie),C.label=6;case 6:return[2]}}))}))},i.prototype.exitRoom=function(){return R(this,void 0,Promise,(function(){var e;return C(this,(function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),console.warn("".concat(se," exitRoom")),this._isSharingScreen?[4,this.stopScreenShare()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[4,this._trtc.exitRoom()];case 3:return t.sent(),[3,5];case 4:return e=t.sent(),this._callFunctionErrorManage(e,"exitRoom"),[3,5];case 5:return[2]}}))}))},i.prototype.switchRole=function(e){return R(this,void 0,void 0,(function(){var t;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._trtc.switchRole(z[e])];case 1:return i.sent(),this.emit("onSwitchRole",0,"switch role success, role = ".concat(e,", ").concat(z[e])),[3,3];case 2:return t=i.sent(),this.emit("onSwitchRole",null==t?void 0:t.getCode(),t.message),[3,3];case 3:return[2]}}))}))},i.prototype._updateLocalVideo=function(){return R(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._trtc.updateLocalVideo(this._generateLocalVideoData())];case 1:return t.sent(),[3,3];case 2:if((e=t.sent()).code===l.default.ERROR_CODE.OPERATION_ABORT)return[2];throw e;case 3:return[2]}}))}))},i.prototype._updateLocalTestVideo=function(){return R(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._testTrtc.updateLocalVideo(this._generateLocalTestVideoData())];case 1:return t.sent(),[3,3];case 2:if((e=t.sent()).code===l.default.ERROR_CODE.OPERATION_ABORT)return[2];throw e;case 3:return[2]}}))}))},i.prototype._updateRemoteVideo=function(e,t){return R(this,void 0,void 0,(function(){var i;return C(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._trtc.updateRemoteVideo(this._generateRemoteVideoData(e,t))];case 1:return o.sent(),[3,3];case 2:if((i=o.sent()).code===l.default.ERROR_CODE.OPERATION_ABORT)return[2];throw i;case 3:return[2]}}))}))},i.prototype.startLocalPreview=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return R(this,void 0,Promise,(function(){var i,o,r,n,s;return C(this,(function(a){switch(a.label){case 0:this._log.info("(startLocalPreview) start - start local preview with params: [".concat(t,"]")),1===_([],t,!0).length?o=_([],t,!0)[0]:2===_([],t,!0).length&&(s=_([],t,!0),i=s[0],o=s[1]),$(i)||(this._setIsMobile(!0),this._setIsFrontCamera(i)),this._setLocalView(o),a.label=1;case 1:a.trys.push([1,8,,9]),a.label=2;case 2:return a.trys.push([2,4,,7]),[4,this._trtc.startLocalVideo(this._generateLocalVideoData())];case 3:return a.sent(),[3,7];case 4:return(r=a.sent()).code!==l.default.ERROR_CODE.OPERATION_ABORT?[3,6]:[4,this._updateLocalVideo()];case 5:return a.sent(),[2];case 6:throw r;case 7:return this.emit("onCameraDidReady"),this.emit("onFirstVideoFrame",{userId:"",streamType:e.TRTCVideoStreamType.TRTCVideoStreamTypeBig,width:this._getVideoProfile().width,height:this._getVideoProfile().height}),[3,9];case 8:return n=a.sent(),this._callFunctionErrorManage(n,"startLocalPreview"),[3,9];case 9:return[2]}}))}))},i.prototype.updateLocalView=function(e){return R(this,void 0,void 0,(function(){return C(this,(function(t){switch(t.label){case 0:return this._setLocalView(e),[4,this._updateLocalVideo()];case 1:return t.sent(),[2]}}))}))},i.prototype.stopLocalPreview=function(){return R(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this._setLocalView(null),[4,this._trtc.stopLocalVideo()];case 1:return t.sent(),[3,3];case 2:return e=t.sent(),console.warn("".concat(se," stopLocalPreview error: ").concat(e)),this._callFunctionErrorManage(e,"stopLocalPreview"),[3,3];case 3:return[2]}}))}))},i.prototype.muteLocalVideo=function(e){return void 0===e&&(e=!1),R(this,void 0,void 0,(function(){var t;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this._setIsVideoPublish(!e),[4,this._updateLocalVideo()];case 1:return i.sent(),[3,3];case 2:return t=i.sent(),this._callFunctionErrorManage(t,"muteLocalVideo"),[3,3];case 3:return[2]}}))}))},i.prototype.startRemoteView=function(e,t,i){return R(this,void 0,void 0,(function(){var o,r;return C(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,7,,8]),this._setRemoteStreamConfig(e,i,{view:t}),!this._remoteStreamMap.get("".concat(e,"_").concat(this._getTRTCStreamType(i))))return[2];n.label=1;case 1:return n.trys.push([1,3,,6]),[4,this._trtc.startRemoteVideo(this._generateRemoteVideoData(e,i))];case 2:return n.sent(),[3,6];case 3:return(o=n.sent()).code!==l.default.ERROR_CODE.OPERATION_ABORT?[3,5]:[4,this._updateRemoteVideo(e,i)];case 4:return n.sent(),[2];case 5:throw o;case 6:return[3,8];case 7:return r=n.sent(),this._callFunctionErrorManage(r,"startRemoteView"),[3,8];case 8:return[2]}}))}))},i.prototype.updateRemoteView=function(e,t,i){return R(this,void 0,void 0,(function(){return C(this,(function(o){switch(o.label){case 0:return this._setRemoteStreamConfig(e,i,{view:t}),[4,this._updateRemoteVideo(e,i)];case 1:return o.sent(),[2]}}))}))},i.prototype.stopRemoteView=function(e,t){return R(this,void 0,void 0,(function(){var i;return C(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this._trtc.stopRemoteVideo({userId:e,streamType:this._getTRTCStreamType(t)})];case 1:return o.sent(),[3,3];case 2:return i=o.sent(),this._callFunctionErrorManage(i,"stopRemoteView"),[3,3];case 3:return[2]}}))}))},i.prototype.stopAllRemoteView=function(){return R(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._trtc.stopRemoteVideo({userId:"*"})];case 1:return t.sent(),[3,3];case 2:return e=t.sent(),this._callFunctionErrorManage(e,"stopAllRemoteView"),[3,3];case 3:return[2]}}))}))},i.prototype.setVideoEncoderParam=function(e){return R(this,void 0,void 0,(function(){var t,i;return C(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),t=this._getTRTCVideoProfile("video",e),this._setVideoProfile(t),[4,this._updateLocalVideo()];case 1:return o.sent(),[4,this._updateLocalTestVideo()];case 2:return o.sent(),[3,4];case 3:return i=o.sent(),this._callFunctionErrorManage(i,"setVideoEncoderParam"),[3,4];case 4:return[2]}}))}))},i.prototype.setLocalRenderParams=function(e){return R(this,void 0,void 0,(function(){var t,i;return C(this,(function(o){switch(o.label){case 0:Object.assign(this._localRenderParams,e),o.label=1;case 1:return o.trys.push([1,4,,5]),t={},e.mirrorType&&(t.mirror=this._getTRTCMirror(e.mirrorType)),e.fillMode&&(t.fillMode=this._getTRTCFillMode(e.fillMode)),this._setVideoPlayOption(t),[4,this._updateLocalVideo()];case 2:return o.sent(),[4,this._updateLocalTestVideo()];case 3:return o.sent(),[3,5];case 4:return i=o.sent(),this._callFunctionErrorManage(i,"setLocalRenderParams"),[3,5];case 5:return[2]}}))}))},i.prototype.setRemoteRenderParams=function(e,t,i){return R(this,void 0,void 0,(function(){var o;return C(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this._setRemoteStreamConfig(e,t,i),[4,this._updateRemoteVideo(e,t)];case 1:return r.sent(),[3,3];case 2:return o=r.sent(),this._callFunctionErrorManage(o,"setRemoteRenderParams"),[3,3];case 3:return[2]}}))}))},i.prototype._updateLocalAudio=function(){return R(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._trtc.updateLocalAudio(this._generateLocalAudioData())];case 1:return t.sent(),[3,3];case 2:if((e=t.sent()).code===l.default.ERROR_CODE.OPERATION_ABORT)return[2];throw e;case 3:return[2]}}))}))},i.prototype.startLocalAudio=function(t){return void 0===t&&(t=e.TRTCAudioQuality.TRTCAudioQualityDefault),R(this,void 0,void 0,(function(){var e,i;return C(this,(function(o){switch(o.label){case 0:o.trys.push([0,7,,8]),this._setAudioProfile(J[t]),o.label=1;case 1:return o.trys.push([1,3,,6]),[4,this._trtc.startLocalAudio(this._generateLocalAudioData())];case 2:return o.sent(),[3,6];case 3:return(e=o.sent()).code!==l.default.ERROR_CODE.OPERATION_ABORT?[3,5]:[4,this._updateLocalAudio()];case 4:return o.sent(),[2];case 5:throw e;case 6:return this.emit("onMicDidReady"),[3,8];case 7:return i=o.sent(),console.warn("".concat(se," startLocalAudio error: ").concat(i)),this._callFunctionErrorManage(i,"startLocalAudio"),[3,8];case 8:return[2]}}))}))},i.prototype.stopLocalAudio=function(){return R(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._trtc.stopLocalAudio()];case 1:return t.sent(),[3,3];case 2:return e=t.sent(),this._callFunctionErrorManage(e,"stopLocalAudio"),[3,3];case 3:return[2]}}))}))},i.prototype.muteLocalAudio=function(e){return void 0===e&&(e=!1),R(this,void 0,void 0,(function(){var t;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this._setIsAudioPublish(!e),[4,this._updateLocalAudio()];case 1:return i.sent(),[3,3];case 2:return t=i.sent(),this._callFunctionErrorManage(t,"muteLocalAudio"),[3,3];case 3:return[2]}}))}))},i.prototype.muteRemoteAudio=function(e,t){return void 0===t&&(t=!1),R(this,void 0,void 0,(function(){var i;return C(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e?[4,this._trtc.muteRemoteAudio(e,t)]:(this._emitError(ie),[2]);case 1:return o.sent(),[3,3];case 2:return i=o.sent(),this._callFunctionErrorManage(i,"muteRemoteAudio"),[3,3];case 3:return[2]}}))}))},i.prototype.muteAllRemoteAudio=function(e){try{this._trtc.muteRemoteAudio("*",e)}catch(t){this._callFunctionErrorManage(t,"muteAllRemoteAudio")}},i.prototype.setRemoteAudioVolume=function(e,t){try{this._trtc.setRemoteAudioVolume(e,t)}catch(i){this._callFunctionErrorManage(i,"setRemoteAudioVolume")}},i.prototype.enableAudioVolumeEvaluation=function(e){try{this._trtc.enableAudioVolumeEvaluation(e)}catch(t){this._callFunctionErrorManage(t,"enableAudioVolumeEvaluation")}},i.prototype.startScreenShare=function(t,i,o){return R(this,void 0,void 0,(function(){var i,r,n,s;return C(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),i=(o||{}).screenAudio,r=void 0!==i&&i,n=this._getTRTCVideoProfile("screen",o),this._setScreenShareParams({view:t,profile:n,systemAudio:r}),[4,this._trtc.startScreenShare(this._getScreenShareParams())];case 1:return a.sent(),this._isSharingScreen=!0,this.emit("onFirstVideoFrame",{userId:"",streamType:e.TRTCVideoStreamType.TRTCVideoStreamTypeSub,width:n.width,height:n.height}),[3,3];case 2:if((s=a.sent()).code===l.default.ERROR_CODE.OPERATION_ABORT)return[2];throw console.error("Start share screen error:",s,s.code,s.name,s.message),s;case 3:return[2]}}))}))},i.prototype.setSubStreamEncoderParam=function(e){return R(this,void 0,void 0,(function(){var t,i;return C(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this._getTRTCVideoProfile("screen",e),this._setScreenShareParams({profile:t}),[4,this._trtc.updateScreenShare(this._getScreenShareParams())];case 1:return o.sent(),[3,3];case 2:return i=o.sent(),this._callFunctionErrorManage(i,"setSubStreamEncoderParam"),[3,3];case 3:return[2]}}))}))},i.prototype.stopScreenShare=function(){return R(this,void 0,Promise,(function(){var e;return C(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._trtc.stopScreenShare()];case 1:return t.sent(),this._isSharingScreen=!1,this.emit("onScreenCaptureStopped",{reason:0}),[3,3];case 2:return e=t.sent(),this._callFunctionErrorManage(e,"stopScreenShare"),[3,3];case 3:return[2]}}))}))},i.prototype.startScreenCapture=function(){this.emitError(oe)},i.prototype.pauseScreenCapture=function(){this.emitError(oe)},i.prototype.resumeScreenCapture=function(){this.emitError(oe)},i.prototype.getScreenCaptureSources=function(){this.emitError(oe)},i.prototype.selectScreenCaptureTarget=function(){this.emitError(oe)},i.prototype.getCameraDevicesList=function(){return R(this,void 0,Promise,(function(){var e,t;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,l.default.getCameraList()];case 1:return e=(e=i.sent()).map((function(e){return p(p({},e),{deviceName:e.label})})),this._cameraList=e,this._currentCamera=this.getDefaultDeviceInfo(e),this._currentCameraId=this._currentCamera.deviceId,[2,Promise.resolve(e)];case 2:return t=i.sent(),this._callFunctionErrorManage(t,"getCameraDevicesList"),[2,Promise.resolve([])];case 3:return[2]}}))}))},i.prototype.setCurrentCameraDevice=function(e){return R(this,void 0,Promise,(function(){var t;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),e?(this._currentCameraId=e,this._currentCamera=this._cameraList.filter((function(t){return t.deviceId===e})),[4,this._updateLocalVideo()]):[2,!1];case 1:return i.sent(),[4,this._updateLocalTestVideo()];case 2:return i.sent(),[2,!0];case 3:return t=i.sent(),this._callFunctionErrorManage(t,"setCurrentCameraDevice"),[2,!1];case 4:return[2]}}))}))},i.prototype.getCurrentCameraDevice=function(){return new y},i.prototype.isFrontCamera=function(){return this._getIsFrontCamera()},i.prototype.switchCamera=function(e){return R(this,void 0,void 0,(function(){var t;return C(this,(function(i){switch(i.label){case 0:return this._setIsFrontCamera(e),(t=this._getVideoPlayOption()).mirror=this._getTRTCMirror(this._localRenderParams.mirrorType),this._setVideoPlayOption(t),[4,this._updateLocalVideo()];case 1:return i.sent(),[2]}}))}))},i.prototype.getMicDevicesList=function(){return R(this,void 0,Promise,(function(){var e,t;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,l.default.getMicrophoneList()];case 1:return e=(e=i.sent()).map((function(e){return p(p({},e),{deviceName:e.label})})),this._microphoneList=e,this._currentMicrophone=this.getDefaultDeviceInfo(e),this._currentMicrophoneId=this._currentMicrophone.deviceId,[2,Promise.resolve(e)];case 2:return t=i.sent(),this._callFunctionErrorManage(t,"getMicDevicesList"),[2,Promise.resolve([])];case 3:return[2]}}))}))},i.prototype.setCurrentMicDevice=function(e){return R(this,void 0,Promise,(function(){var t;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),e?(this._setCurrentMicrophoneId(e),this._currentMicrophone=this._microphoneList.filter((function(t){return t.deviceId===e})),[4,this._trtc.updateLocalAudio(this._generateLocalAudioData())]):[2,!1];case 1:return i.sent(),[2,!0];case 2:return t=i.sent(),this._callFunctionErrorManage(t,"setCurrentMicDevice"),[2,!1];case 3:return[2]}}))}))},i.prototype.getCurrentMicDevice=function(){return new y},i.prototype.getSpeakerDevicesList=function(){return R(this,void 0,Promise,(function(){var e,t;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,l.default.getSpeakerList()];case 1:return e=(e=i.sent()).map((function(e){return p(p({},e),{deviceName:e.label})})),this._speakerList=e,this._currentSpeaker=this.getDefaultDeviceInfo(e),this._currentSpeakerId=this._currentSpeaker.deviceId,[2,Promise.resolve(e)];case 2:return t=i.sent(),this._callFunctionErrorManage(t,"getSpeakerDevicesList"),[2,Promise.resolve([])];case 3:return[2]}}))}))},i.prototype.setCurrentSpeakerDevice=function(e){return R(this,void 0,Promise,(function(){var t;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),e?(this._setCurrentSpeakerId(e),this._currentSpeaker=this._speakerList.filter((function(t){return t.deviceId===e})),[4,l.default.setCurrentSpeaker(e)]):[2,!1];case 1:return i.sent(),[2,!0];case 2:return t=i.sent(),this._callFunctionErrorManage(t,"setCurrentSpeakerDevice"),[2,!1];case 3:return[2]}}))}))},i.prototype.getCurrentSpeakerDevice=function(){return new y},i.prototype.startCameraDeviceTest=function(e){return R(this,void 0,void 0,(function(){return C(this,(function(t){switch(t.label){case 0:return this._log.info("(startCameraDeviceTest) start - start test camera Device",e),e?(this._setLocalTestView(e),[4,this._testTrtc.startLocalVideo(this._generateLocalTestVideoData())]):[2];case 1:return t.sent(),[2]}}))}))},i.prototype.stopCameraDeviceTest=function(){return R(this,void 0,void 0,(function(){return C(this,(function(e){switch(e.label){case 0:return this._setLocalTestView(null),[4,this._testTrtc.stopLocalVideo()];case 1:return e.sent(),[2]}}))}))},i.prototype.startMicDeviceTest=function(t){return R(this,void 0,void 0,(function(){var i=this;return C(this,(function(o){switch(o.label){case 0:return this._log.info("(startMicDeviceTest) start - start test mic Device",t),[4,this._testTrtc.startLocalAudio({publish:!1,option:{microphoneId:this._currentMicrophoneId,profile:J[e.TRTCAudioQuality.TRTCAudioQualityDefault]}})];case 1:return o.sent(),this._testTrtc.on(l.default.EVENT.AUDIO_VOLUME,(function(e){null==e||e.result.forEach((function(e){var t=e.userId,o=e.volume;""===t&&i.emit("onTestMicVolume",o)}))})),[4,this._testTrtc.enableAudioVolumeEvaluation(t)];case 2:return o.sent(),[2]}}))}))},i.prototype.stopMicDeviceTest=function(){this._log.info("(stopMicDeviceTest) stop - stop test mic Device"),this._testTrtc.stopLocalAudio()},i.prototype._unbindEvents=function(){},i.prototype._destroy=function(){this._unbindEvents()},i.prototype._emitError=function(e){e&&this.emit&&this.emit(Y,e.code,e.message)},i.prototype._callFunctionErrorManage=function(e,t){e&&e.code===l.default.ERROR_CODE.OPERATION_ABORT||(e&&e.getCode&&e.getCode()?(this.emit(Y,e.getCode(),e.message),this._log.error("(".concat(t,") failed - ").concat(e.message))):(this.emit(Y,te,e.message),this._log.error("(".concat(t,") failed - ").concat(e.message))))},i.prototype._getTRTCResolution=function(t){var i=(e.TRTCVideoResolution[t]||"").split("_");return{width:+(i.length>1&&i[1]),height:+(i.length>2&&i[2])}},i.prototype._getTRTCVideoProfile=function(e,t){var i=t.videoResolution,o=t.videoFps,r=t.videoBitrate,n="screen"===e?this._defaultScreenProfile:this._defaultVideoProfile;if(i){var s=this._getTRTCResolution(i);n.width=s.width,n.height=s.height}return o&&(n.frameRate=o),r&&(n.bitrate=r),n},i.prototype._getTRTCStreamType=function(t){var i;return((i={})[e.TRTCVideoStreamType.TRTCVideoStreamTypeBig]=l.default.TYPE.STREAM_TYPE_MAIN,i[e.TRTCVideoStreamType.TRTCVideoStreamTypeSmall]=l.default.TYPE.STREAM_TYPE_MAIN,i[e.TRTCVideoStreamType.TRTCVideoStreamTypeSub]=l.default.TYPE.STREAM_TYPE_SUB,i)[t]},i.prototype._getTRTCFillMode=function(t){var i;return((i={})[e.TRTCVideoFillMode.TRTCVideoFillMode_Fill]=Z.COVER,i[e.TRTCVideoFillMode.TRTCVideoFillMode_Fit]=Z.CONTAIN,i)[t]},i.prototype._getTRTCMirror=function(t){var i;return t===e.TRTCVideoMirrorType.TRTCVideoMirrorType_Auto?!this._getIsMobile()||this._getIsFrontCamera():((i={})[e.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable]=!0,i[e.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable]=!1,i)[t]},i.prototype._getTRTCCloudDeviceType=function(t){return{camera:e.TRTCDeviceType.TRTCDeviceTypeCamera,microphone:e.TRTCDeviceType.TRTCDeviceTypeMic,speaker:e.TRTCDeviceType.TRTCDeviceTypeSpeaker}[t]},i.prototype._getTRTCCloudDeviceState=function(t){return{add:e.TRTCDeviceState.TRTCDeviceStateAdd,remove:e.TRTCDeviceState.TRTCDeviceStateRemove,active:e.TRTCDeviceState.TRTCDeviceStateActive}[t]},i.prototype._generateLocalVideoData=function(){var e={view:this._getLocalView(),publish:this._getIsVideoPublish(),option:p({profile:this._getVideoProfile()},this._getVideoPlayOption())};return this._getIsMobile()?e&&Object.assign(e.option,{useFrontCamera:this._getIsFrontCamera()}):e&&Object.assign(e.option,{cameraId:this._getCurrentCameraId()}),e},i.prototype._generateLocalTestVideoData=function(){return{view:this._getLocalTestView(),publish:!1,option:p({cameraId:this._getCurrentCameraId(),profile:this._getVideoProfile()},this._getVideoPlayOption())}},i.prototype._generateLocalAudioData=function(){return{publish:this._getIsAudioPublish(),option:{microphoneId:this._getCurrentMicrophoneId(),profile:this._getAudioProfile()}}},i.prototype._generateRemoteVideoData=function(e,t){return this._remoteStreamConfig.get("".concat(e,"_").concat(this._getTRTCStreamType(t)))},i.prototype._addTRTCEvents=function(){var t=this;this._trtc.on(l.default.EVENT.ERROR,(function(e){var i;e&&t.emit("onError",null===(i=null==e?void 0:e.getCode)||void 0===i?void 0:i.getCode(),e.message)})),this._trtc.on(l.default.EVENT.REMOTE_USER_ENTER,(function(e){(null==e?void 0:e.userId)&&t.emit("onRemoteUserEnterRoom",e.userId)})),this._trtc.on(l.default.EVENT.REMOTE_USER_EXIT,(function(e){(null==e?void 0:e.userId)&&t.emit("onRemoteUserLeaveRoom",e.userId)})),this._trtc.on(l.default.EVENT.REMOTE_AUDIO_AVAILABLE,(function(e){(null==e?void 0:e.userId)&&t.emit("onUserAudioAvailable",e.userId,!0)})),this._trtc.on(l.default.EVENT.REMOTE_AUDIO_UNAVAILABLE,(function(e){(null==e?void 0:e.userId)&&t.emit("onUserAudioAvailable",e.userId,!1)})),this._trtc.on(l.default.EVENT.REMOTE_VIDEO_AVAILABLE,(function(e){t._emitVideoAvailable(e,!0)})),this._trtc.on(l.default.EVENT.REMOTE_VIDEO_UNAVAILABLE,(function(e){t._emitVideoAvailable(e,!1)})),this._trtc.on(l.default.EVENT.AUDIO_VOLUME,(function(e){(null==e?void 0:e.result)&&t.emit("onUserVoiceVolume",null==e?void 0:e.result,((null==e?void 0:e.result)||[]).length)})),this._trtc.on(l.default.EVENT.NETWORK_QUALITY,(function(i){var o=i.uplinkNetworkQuality,r=i.downlinkNetworkQuality,n=t.client?t.client.getUserId():"",s=[e.TRTCQuality.TRTCQuality_Unknown,e.TRTCQuality.TRTCQuality_Excellent,e.TRTCQuality.TRTCQuality_Good,e.TRTCQuality.TRTCQuality_Poor,e.TRTCQuality.TRTCQuality_Bad,e.TRTCQuality.TRTCQuality_Vbad,e.TRTCQuality.TRTCQuality_Down],a=new b(n,s[o]),c=new b("remote",s[r]);t.emit("onNetworkQuality",a,[c])})),this._trtc.on(l.default.EVENT.SCREEN_SHARE_STOPPED,(function(){t.emit("onScreenCaptureStopped",{reason:0}),t._isSharingScreen=!1})),this._trtc.on(l.default.EVENT.PUBLISH_STATE_CHANGED,(function(i){var o=i.mediaType;"started"===i.state&&("audio"===o?t.emit("onSendFirstLocalAudioFrame"):"video"===o?t.emit("onSendFirstLocalVideoFrame",{streamType:e.TRTCVideoStreamType.TRTCVideoStreamTypeBig}):"screen"===o&&t.emit("onSendFirstLocalVideoFrame",{streamType:e.TRTCVideoStreamType.TRTCVideoStreamTypeSub}))}))},i.prototype._removeTRTCEvents=function(){this._trtc.off("*")},i.prototype._emitVideoAvailable=function(e,t){var i=e.userId,o=e.streamType;t?this._remoteStreamMap.set("".concat(i,"_").concat(o),!0):this._remoteStreamMap.delete("".concat(i,"_").concat(o)),o===l.default.TYPE.STREAM_TYPE_SUB?i&&this.emit("onUserSubStreamAvailable",i,t):i&&this.emit("onUserVideoAvailable",i,t)},i.prototype._setLocalView=function(e){this._localView=e},i.prototype._getLocalView=function(){return this._localView},i.prototype._setIsMobile=function(e){this._isMobile=e},i.prototype._getIsMobile=function(){return this._isMobile},i.prototype._setIsFrontCamera=function(e){this._isFrontCamera=e},i.prototype._getIsFrontCamera=function(){return this._isFrontCamera},i.prototype._setIsVideoPublish=function(e){this._isVideoPublish=e},i.prototype._getIsVideoPublish=function(){return this._isVideoPublish},i.prototype._setVideoProfile=function(e){this._videoProfile=e},i.prototype._getVideoProfile=function(){return this._videoProfile},i.prototype._setVideoPlayOption=function(e){this._videoPlayOption=e},i.prototype._getVideoPlayOption=function(){return this._videoPlayOption},i.prototype._setLocalTestView=function(e){this._localTestView=e},i.prototype._getLocalTestView=function(){return this._localTestView},i.prototype._setScreenShareParams=function(e){var t=e.view,i=e.systemAudio,o=e.fillMode,r=e.profile;$(t)||(this._screenShareParams.view=t),$(i)||(this._screenShareParams.option.systemAudio=i),$(o)||(this._screenShareParams.option.fillMode=o),$(r)||(this._screenShareParams.option.profile=r)},i.prototype._getScreenShareParams=function(){return this._screenShareParams},i.prototype._setIsAudioPublish=function(e){this._isAudioPublish=e},i.prototype._getIsAudioPublish=function(){return this._isAudioPublish},i.prototype._setAudioProfile=function(e){this._audioProfile=e},i.prototype._getAudioProfile=function(){return this._audioProfile},i.prototype._setCurrentCameraId=function(e){this._currentCameraId=e},i.prototype._getCurrentCameraId=function(){return this._currentCameraId},i.prototype._setCurrentMicrophoneId=function(e){this._currentMicrophoneId=e},i.prototype._getCurrentMicrophoneId=function(){return this._currentMicrophoneId},i.prototype._setCurrentSpeakerId=function(e){this._currentSpeakerId=e},i.prototype._getCurrentSpeakerId=function(){return this._currentSpeakerId},i.prototype._setRemoteStreamConfig=function(e,t,i){var o={userId:e,streamType:this._getTRTCStreamType(t),option:{}},r=i.view,n=i.mirrorType,s=i.fillMode;$(r)||(o.view=r),$(n)||(o.option.mirror=this._getTRTCMirror(n)),$(s)||(o.option.fillMode=this._getTRTCFillMode(s)),this._remoteStreamConfig.set("".concat(e,"_").concat(this._getTRTCStreamType(t)),o)},i.prototype.handleDeviceChange=function(){return R(this,void 0,void 0,(function(){var t=this;return C(this,(function(i){return l.default.getCameraList().then((function(i){return R(t,void 0,void 0,(function(){return C(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]}}))}))})),l.default.getMicrophoneList().then((function(i){return R(t,void 0,void 0,(function(){return C(this,(function(t){switch(t.label){case 0:return[4,this.deviceChangeManage(this._microphoneList,i,e.TRTCDeviceType.TRTCDeviceTypeMic)];case 1:return t.sent(),this._microphoneList=i,[2]}}))}))})),l.default.getSpeakerList().then((function(i){return R(t,void 0,void 0,(function(){return C(this,(function(t){switch(t.label){case 0:return[4,this.deviceChangeManage(this._speakerList,i,e.TRTCDeviceType.TRTCDeviceTypeSpeaker)];case 1:return t.sent(),this._speakerList=i,[2]}}))}))})),[2]}))}))},i.prototype.isSameDevice=function(e,t){var i=e&&e.deviceId&&e.groupId&&e.label,o=t&&t.deviceId&&t.groupId&&t.label;return!(!i||!o)&&e.deviceId===t.deviceId&&e.groupId===t.groupId&&e.label===t.label},i.prototype.deviceChangeManage=function(t,i,o){return R(this,void 0,void 0,(function(){var r,n,s,a,c;return C(this,(function(u){switch(u.label){case 0:return r=void 0,t.length!==i.length&&(n=(i||[]).map((function(e){return e.deviceId})),s=new y,t.length>i.length?(s=t.filter((function(e){return!n.includes(e.deviceId)}))[0]||{},r=e.TRTCDeviceState.TRTCDeviceStateRemove):(n=(t||[]).map((function(e){return e.deviceId})),s=i.filter((function(e){return!n.includes(e.deviceId)}))[0]||{},r=e.TRTCDeviceState.TRTCDeviceStateAdd),a=s.deviceId,this.emitOnDeviceChange(a,o,r)),c=this.getDefaultDeviceInfo(i),o!==e.TRTCDeviceType.TRTCDeviceTypeCamera||r!==e.TRTCDeviceState.TRTCDeviceStateRemove?[3,3]:this.isSameDevice(this._currentCamera,c)?[2]:c.deviceId?[4,this.autoChangeDevice(o,c)]:[3,2];case 1:u.sent(),u.label=2;case 2:u.label=3;case 3:return o!==e.TRTCDeviceType.TRTCDeviceTypeMic?[3,6]:this.isSameDevice(this._currentMicrophone,c)?[2]:c.deviceId?[4,this.autoChangeDevice(o,c)]:[3,5];case 4:u.sent(),u.label=5;case 5:u.label=6;case 6:return o!==e.TRTCDeviceType.TRTCDeviceTypeSpeaker?[3,9]:this.isSameDevice(this._currentSpeaker,c)?[2]:c.deviceId?[4,this.autoChangeDevice(o,c)]:[3,8];case 7:u.sent(),u.label=8;case 8:u.label=9;case 9:return[2]}}))}))},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}));return t=i.length>0?i[0]:e[0]},i.prototype.autoChangeDevice=function(t,i){return R(this,void 0,void 0,(function(){var o,r,n,s,a;return C(this,(function(c){switch(c.label){case 0:if(o=i.deviceId,t!==e.TRTCDeviceType.TRTCDeviceTypeCamera)return[3,8];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this._trtc.updateLocalVideo({option:{cameraId:o}})];case 2:return c.sent(),[3,4];case 3:return r=c.sent(),console.log("error",JSON.stringify(r)),r.code,l.default.ERROR_CODE.OPERATION_ABORT,[3,4];case 4:return c.trys.push([4,6,,7]),[4,this._testTrtc.updateLocalVideo({option:{cameraId:o}})];case 5:return c.sent(),[3,7];case 6:return n=c.sent(),console.log("testTRTC error",JSON.stringify(n)),n.code,l.default.ERROR_CODE.OPERATION_ABORT,[3,7];case 7:this._currentCameraId=o,this._currentCamera=i,this.emitOnDeviceChange(o,t,e.TRTCDeviceState.TRTCDeviceStateActive),c.label=8;case 8:if(t!==e.TRTCDeviceType.TRTCDeviceTypeMic)return[3,16];c.label=9;case 9:return c.trys.push([9,11,,12]),[4,this._trtc.updateLocalAudio({option:{microphoneId:o}})];case 10:return c.sent(),[3,12];case 11:return s=c.sent(),console.log("error",JSON.stringify(s)),s.code,l.default.ERROR_CODE.OPERATION_ABORT,[3,12];case 12:return c.trys.push([12,14,,15]),[4,this._testTrtc.updateLocalAudio({option:{microphoneId:o}})];case 13:return c.sent(),[3,15];case 14:return a=c.sent(),console.log("testTRTC error",JSON.stringify(a)),a.code,l.default.ERROR_CODE.OPERATION_ABORT,[3,15];case 15:this._currentMicId=o,this._currentMicrophone=i,this.emitOnDeviceChange(o,t,e.TRTCDeviceState.TRTCDeviceStateActive),c.label=16;case 16:return t!==e.TRTCDeviceType.TRTCDeviceTypeSpeaker?[3,18]:[4,l.default.setCurrentSpeaker(o)];case 17:c.sent(),this._currentSpeakerId=o,this._currentSpeaker=i,this.emitOnDeviceChange(o,t,e.TRTCDeviceState.TRTCDeviceStateActive),c.label=18;case 18:return[2]}}))}))},i.prototype.emitOnDeviceChange=function(e,t,i){this.emit("onDeviceChange",e,t,i)},i}(function(){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++)ee(this,new(0,i[t])(this))},o=i.prototype,r=0,n=e;r<n.length;r++){var s=n[r];ee(i,s),ee(o,s.prototype)}return i}(t.EventEmitter));e.Rect=B,e.TRTCDeviceInfo=y,e.TRTCImageBuffer=k,e.TRTCLocalStatistics=P,e.TRTCMixUser=j,e.TRTCNetworkQosParam=F,e.TRTCParams=g,e.TRTCPublishCDNParam=w,e.TRTCQualityInfo=b,e.TRTCRenderParams=M,e.TRTCScreenCaptureSourceInfo=N,e.TRTCStatistics=L,e.TRTCTranscodingConfig=U,e.TRTCVideoEncParam=V,e.TRTCVolumeInfo=D,e.default=ae,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("events"),require("trtc-sdk-v5")):"function"==typeof define&&define.amd?define(["exports","events","trtc-sdk-v5"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).TRTC={},global.events,global.TRTC);
|