trtc-sdk-v5 5.15.0-beta.3 → 5.15.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-sdk-v5",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "Tencent Cloud RTC SDK for Web",
5
5
  "main": "trtc.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cdn-streaming",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x CDN streaming plugin",
5
5
  "main": "./cdn-streaming.esm.js",
6
6
  "module": "./cdn-streaming.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/chorus",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x Chorus plugin",
5
5
  "main": "./chorus.esm.js",
6
6
  "module": "./chorus.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cross-room",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x Cross Room plugin",
5
5
  "main": "./cross-room.esm.js",
6
6
  "module": "./cross-room.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/custom-encryption",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "main": "./custom-encryption.esm.js",
5
5
  "module": "./custom-encryption.esm.js",
6
6
  "types": "./custom-encryption.esm.d.ts"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/device-detector",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x device detector plugin",
5
5
  "main": "./device-detector.esm.js",
6
6
  "module": "./device-detector.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/lebplayer",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x LEBPlayer plugin",
5
5
  "main": "./lebplayer.esm.js",
6
6
  "module": "./lebplayer.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/small-stream-auto-switcher",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "",
5
5
  "main": "./small-stream-auto-switcher.esm.js",
6
6
  "keywords": [],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/video-decoder",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "Video decoder plugin for TRTC",
5
5
  "main": "./video-decoder.esm.js",
6
6
  "module": "./video-decoder.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/basic-beauty",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x basic-beauty plugin",
5
5
  "main": "./basic-beauty.esm.js",
6
6
  "module": "./basic-beauty.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/beauty",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x beauty plugin",
5
5
  "main": "./beauty.esm.js",
6
6
  "module": "./beauty.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/video-mixer",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x videoMixer plugin",
5
5
  "main": "./video-mixer.esm.js",
6
6
  "module": "./video-mixer.esm.js",
@@ -43,6 +43,7 @@ export interface ScreenSource {
43
43
  captureElement?: HTMLElement;
44
44
  preferDisplaySurface?: 'current-tab' | 'tab' | 'window' | 'monitor';
45
45
  layout: LayerOption;
46
+ systemAudio?: boolean;
46
47
  }
47
48
  export interface TextSource {
48
49
  id: string;
@@ -81,6 +82,7 @@ export interface MixFailedDetail {
81
82
 
82
83
  export interface MixParseResult {
83
84
  track: MediaStreamVideoTrack;
85
+ systemAudioTrack?: MediaStreamAudioTrack;
84
86
  result: {
85
87
  successOptions: VideoMixerOptions | UpdateVideoMixerOptions;
86
88
  failedDetails: MixFailedDetail[];
@@ -1 +1 @@
1
- var __defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,i,r)=>i in e?__defProp(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,__spreadValues=(e,i)=>{for(var r in i||(i={}))__hasOwnProp.call(i,r)&&__defNormalProp(e,r,i[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(i))__propIsEnum.call(i,r)&&__defNormalProp(e,r,i[r]);return e},__publicField=(e,i,r)=>__defNormalProp(e,"symbol"!=typeof i?i+"":i,r),layoutProperty={x:{required:!0,type:"number"},y:{required:!0,type:"number"},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},zIndex:{required:!0,type:"number"},fillMode:{required:!1,type:"string"},mirror:{required:!1,type:"boolean"},rotation:{required:!1,type:"number"},hidden:{required:!1,type:"boolean"}},canvasValidateRule=(e,i=!1)=>({type:"object",required:i,properties:{canvasColor:{required:!1,type:["string",CanvasGradient,CanvasPattern]},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},frameRate:{required:!1,type:"number",notLessThanZero:!0,min:1,max:60}},validate(i,r,t){const{RtcError:a,ErrorCode:o,ErrorCodeDictionary:s}=e.errorModule;if(!i)return;const{width:n,height:l}=i;if(n&&l&&n*l>8294400)throw new a({code:o.INVALID_PARAMETER,message:"The mix resolution cannot be set higher than 3840 * 2160."})}}),viewValidateRule=e=>({required:!1,type:["string",HTMLElement,null],validate(i,r,t){const{RtcError:a,ErrorCode:o,ErrorCodeDictionary:s}=e.errorModule;if(e.utils.isString(i)){if(!document.getElementById(i))throw new a({code:o.INVALID_PARAMETER,extraCode:s.INVALID_ELEMENT_ID,fnName:t,messageParams:{key:r}})}}}),layoutValidateRule=(e,i=!0)=>({type:"object",required:i,properties:__spreadValues({},layoutProperty),validate(i,r,t){const{RtcError:a,ErrorCode:o,ErrorCodeDictionary:s}=e.errorModule;if(i){if(i.fillMode&&!["contain","cover","fill"].includes(i.fillMode))throw new a({code:o.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_TYPE,message:"The fillMode parameter must be 'contain', 'cover' or 'fill'",fnName:t});if(i.rotation&&![0,90,180,270].includes(i.rotation))throw new a({code:o.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_TYPE,message:"The rotation parameter must be 0, 90, 180 or 270",fnName:t})}}}),cameraValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},cameraId:{required:!1,type:"string"},videoTrack:{required:!1,instanceof:MediaStreamTrack},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},layout:__spreadValues({},layoutValidateRule(e))}}}),screenValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},captureElement:{required:!1,type:HTMLElement},preferDisplaySurface:{required:!1,type:"string"},layout:__spreadValues({},layoutValidateRule(e))},validate(i,r,t){const{RtcError:a,ErrorCode:o,ErrorCodeDictionary:s}=e.errorModule;if(!e.rtcDectection.isScreenCaptureApiAvailable())throw new a({code:o.ENV_NOT_SUPPORTED,fnName:t,extraCode:s.NOT_SUPPORTED_SCREEN_SHARE})}}}),textValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},content:{required:!0,type:"string"},font:{required:!1,type:"string"},color:{required:!1,type:["string",CanvasGradient,CanvasPattern]},layout:__spreadValues({},layoutValidateRule(e))}}}),imageValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:__spreadValues({},layoutValidateRule(e))}}}),videoValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:__spreadValues({},layoutValidateRule(e))}}});function startValidateRule(e){return{name:"VideoMixerOptions",type:"object",required:!0,allowEmpty:!1,properties:{view:__spreadValues({},viewValidateRule(e)),canvasInfo:__spreadValues({},canvasValidateRule(e,!0)),camera:__spreadValues({},cameraValidateRule(e)),screen:__spreadValues({},screenValidateRule(e)),text:__spreadValues({},textValidateRule(e)),image:__spreadValues({},imageValidateRule(e)),video:__spreadValues({},videoValidateRule(e))},validate(i,r,t,a){const{RtcError:o,ErrorCode:s,ErrorCodeDictionary:n}=e.errorModule;if(e.environment.isMobile())throw new o({code:s.ENV_NOT_SUPPORTED,message:"VideoMixer is not supported on mobile devices currently"});const{onScreenShareStop:l}=i;if(l&&!e.utils.isFunction(l))throw new o({code:s.INVALID_PARAMETER,extraCode:n.INVALID_PARAMETER_TYPE,fnName:t,messageParams:{key:"onScreenShareStop",value:typeof l,rule:{type:"Function"}}})}}}function updateValidateRule(e){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{view:__spreadValues({},viewValidateRule(e)),canvasInfo:__spreadValues({},canvasValidateRule(e)),camera:__spreadValues({},cameraValidateRule(e)),screen:__spreadValues({},screenValidateRule(e)),text:__spreadValues({},textValidateRule(e)),image:__spreadValues({},imageValidateRule(e)),video:__spreadValues({},videoValidateRule(e))}}}function stopValidateRule(e){return{name:"StopVideoMixerOptions",required:!1}}var videoMixSeq=0,_VideoMixer=class e{constructor(e){this.core=e,__publicField(this,"seq"),__publicField(this,"log"),__publicField(this,"localMixVideoTrack",null),__publicField(this,"_mixVideoConfig"),__publicField(this,"onScreenShareStop"),videoMixSeq+=1,this.seq=videoMixSeq,this.log=e.log.createChild({id:`${this.getAlias()}${videoMixSeq}`}),this.log.info("created")}getName(){return e.Name}getAlias(){return"vmix"}getValidateRule(e){switch(e){case"start":return startValidateRule(this.core);case"update":return updateValidateRule(this.core);case"stop":return stopValidateRule(this.core)}}getGroup(){return"vmix"}async start(e){this.localMixVideoTrack||(this.localMixVideoTrack=new this.core.LocalMixVideoTrack(this.core.room.videoManager)),this._mixVideoConfig={canvasInfo:{width:1920,height:1080}},e=this.core.utils.deepCloneBasic(e);const{view:i,onScreenShareStop:r}=e,t=await this.parseMixOptions(e);return r&&(this.onScreenShareStop=r,this._mixVideoConfig.onScreenShareStop=r),this._updatePreview({view:i,track:this.localMixVideoTrack}),this.core.utils.isUndefined(i)||(this._mixVideoConfig.view=i),await this.localMixVideoTrack.startMix(),{track:this.localMixVideoTrack._outputTrack,result:t}}async update(e){const{RtcError:i,ErrorCode:r}=this.core.errorModule;if(!this.localMixVideoTrack)throw new i({code:r.INVALID_OPERATION,message:"mixTrack doesn't initialize!"});e=this.core.utils.deepCloneBasic(e);const{view:t}=e,a=await this.parseMixOptions(e);return await this._updatePreview({view:t,track:this.localMixVideoTrack,prevConfig:this._mixVideoConfig}),this.core.utils.isUndefined(t)||(this._mixVideoConfig.view=t),{track:this.localMixVideoTrack._outputTrack,result:a}}async parseMixOptions(e){let i={successOptions:{},failedDetails:[]};const{RtcError:r,ErrorCode:t,ErrorCodeDictionary:a}=this.core.errorModule;if(!this.localMixVideoTrack||!this._mixVideoConfig)return i;const o=[],s=__spreadValues({},e),{canvasInfo:n,camera:l,screen:d,text:c,image:u,video:p}=e;let h=0,m=0;if(n){const{canvasColor:e,width:i,height:r,frameRate:t}=n;e&&this.localMixVideoTrack.setMixBackground(e),t&&this.localMixVideoTrack.setFps(t),this.localMixVideoTrack.resizeMixCanvas(i,r),this._mixVideoConfig.canvasInfo=n}if(l){h++;const{finalOptions:e,errors:i}=await this.parseCameraOptions(this.localMixVideoTrack,l,this._mixVideoConfig.camera);this._mixVideoConfig.camera=e,s.camera=e,i.length>0&&(o.push(...i),i.length===l.length&&m++)}if(d){h++;const{finalOptions:e,errors:i}=await this.parseScreenOptions(this.localMixVideoTrack,d,this._mixVideoConfig.screen);this._mixVideoConfig.screen=e,s.screen=e,i.length>0&&(o.push(...i),i.length===d.length&&m++)}if(c){h++;const{finalOptions:e,errors:i}=await this.parseTextOptions(this.localMixVideoTrack,c,this._mixVideoConfig.text);this._mixVideoConfig.text=e,s.text=e,i.length>0&&(o.push(...i),i.length===c.length&&m++)}if(u){h++;const{finalOptions:e,errors:i}=await this.parseImageOptions(this.localMixVideoTrack,u,this._mixVideoConfig.image);this._mixVideoConfig.image=e,s.image=e,i.length>0&&(o.push(...i),i.length===u.length&&m++)}if(p){h++;const{finalOptions:e,errors:i}=await this.parseVideoOptions(this.localMixVideoTrack,p,this._mixVideoConfig.video);this._mixVideoConfig.video=e,s.video=e,i.length>0&&(o.push(...i),i.length===p.length&&m++)}if(m>0&&m===h)throw new r({code:t.INVALID_PARAMETER,message:"all sources mix failed",data:{failedDetails:o}});return i={successOptions:s,failedDetails:o},i}async parseCameraOptions(e,i,r=[]){var t,a;const o=new Set(i.map((e=>e.id))),s=r.filter((e=>!o.has(e.id))).map((e=>e.id));for(const i of s)e.removeCameraSource(i);const n=new Map(r.map((e=>[e.id,e]))),l=[],d=[];for(const r of i){const{id:i,layout:o,profile:s}=r;try{if(e.inputLocalVideoTracks.has(i)){const n=null==(t=e.inputLocalVideoTracks.get(i))?void 0:t.mediaTrack;await this.updateCameraProfile(r);const l=null==(a=e.inputLocalVideoTracks.get(i))?void 0:a.mediaTrack;let d;s&&(d=this.core.utils.isString(s)?this.core.constants.videoProfileMap[s]:s),l!==n?e.updateCameraSource(i,o,l,d):e.updateCameraSource(i,o,null,d)}else{const t=await this.captureCamera(r);try{e.addCameraSource(i,t,o)}catch(e){throw t.close(),e}}l.push(r)}catch(e){d.push({id:i,error:e}),n.has(i)&&l.push(n.get(i))}}return{finalOptions:l,errors:d}}async parseScreenOptions(e,i,r=[]){const t=new Set(i.map((e=>e.id))),a=r.filter((e=>!t.has(e.id))).map((e=>e.id));for(const i of a)e.removeScreenSource(i);const o=new Map(r.map((e=>[e.id,e]))),s=[],n=[];for(const r of i){const{id:i,layout:t}=r;try{if(e.inputLocalScreenTracks.has(i))e.updateScreenSource(i,t);else{const a=await this.captureScreen(r);try{e.addScreenSource(i,a,t)}catch(e){throw a.close(),e}}s.push(r)}catch(e){n.push({id:i,error:e}),o.has(i)&&s.push(o.get(i))}}return{finalOptions:s,errors:n}}async parseTextOptions(e,i,r=[]){const t=new Set(i.map((e=>e.id))),a=r.filter((e=>!t.has(e.id))).map((e=>e.id));for(const i of a)e.removeTextSource(i);const o=new Map(r.map((e=>[e.id,e]))),s=[],n=[];for(const t of i){const{id:i}=t;try{r.some((e=>e.id===i))?e.updateTextSource(t):e.addTextSource(t),s.push(t)}catch(e){n.push({id:i,error:e}),o.has(i)&&s.push(o.get(i))}}return{finalOptions:s,errors:n}}async parseImageOptions(e,i,r=[]){const t=new Set(i.map((e=>e.id))),a=r.filter((e=>!t.has(e.id))).map((e=>e.id));for(const i of a)e.removeImageSource(i);const o=new Map(r.map((e=>[e.id,e]))),s=[],n=[];for(const t of i){const{id:i,url:a,layout:l}=t;try{const o=r.find((e=>e.id===i));if(o){let r;o.url!==a&&(r=await this.core.utils.loadImage(a)),e.updateImageSource(i,l,r)}else{const r=await this.core.utils.loadImage(a);e.addImageSource(i,r,l)}s.push(t)}catch(e){n.push({id:i,error:e}),o.has(i)&&s.push(o.get(i))}}return{finalOptions:s,errors:n}}async parseVideoOptions(e,i,r=[]){const t=new Set(i.map((e=>e.id))),a=r.filter((e=>!t.has(e.id))).map((e=>e.id));for(const i of a)e.removeVideoSource(i);const o=new Map(r.map((e=>[e.id,e]))),s=[],n=[];for(const t of i){const{id:i,url:a,layout:l}=t;try{const o=r.find((e=>e.id===i));let n;if(o)o.url!==a&&(n=await this.core.utils.loadVideo(a)),e.updateVideoSource(i,l,n);else{const r=await this.core.utils.loadVideo(a);e.addVideoSource(i,r,l)}s.push(t)}catch(e){n.push({id:i,error:e}),o.has(i)&&s.push(o.get(i))}}return{finalOptions:s,errors:n}}async captureCamera(e){const{id:i,cameraId:r,videoTrack:t,profile:a}=e,o=new this.core.LocalVideoTrack;o.log.id+=`-${i}`;const s={};return r?s.deviceId=r:this.core.utils.isUndefined(t)||(s.customSource=t),this.core.utils.isUndefined(a)||(this.core.utils.isString(a)?this.core.constants.videoProfileMap[a]&&o.setProfile(this.core.constants.videoProfileMap[a]):o.setProfile(a)),await o.capture(s),o}async updateCameraProfile(e){var i;const{id:r,cameraId:t,videoTrack:a,profile:o}=e,s=null==(i=this.localMixVideoTrack)?void 0:i.inputLocalVideoTracks.get(r);s&&(t?await s.switchDevice(t):this.core.utils.isUndefined(a)||await s.setInputMediaStreamTrack(a),this.core.utils.isUndefined(o)||(this.core.utils.isString(o)?this.core.constants.videoProfileMap[o]&&s.setProfile(this.core.constants.videoProfileMap[o]):s.setProfile(o),t&&s.isNeedToSwitchDevice(t)||await s.applyProfile()))}async captureScreen(e){const{id:i,profile:r,captureElement:t,preferDisplaySurface:a}=e,o=new this.core.LocalScreenTrack;o.log.id+=`-${i}`;const s={};return this.core.utils.isUndefined(r)||(this.core.utils.isString(r)?this.core.constants.screenProfileMap[r]&&o.setProfile(this.core.constants.screenProfileMap[r]):o.setProfile(r)),t&&(s.captureElement=t),a&&(s.preferDisplaySurface=a),await o.capture(s),o.mediaTrack.addEventListener(this.core.constants.NAME.ENDED,(()=>{var e,r,t;null==(e=this.localMixVideoTrack)||e.removeScreenSource(i),(null==(r=this._mixVideoConfig)?void 0:r.screen)&&(this._mixVideoConfig.screen=this._mixVideoConfig.screen.filter((e=>e.id!==i))),null==(t=this.onScreenShareStop)||t.call(this,i)})),o}async _updatePreview({view:e,track:i,prevConfig:r}){if(this.core.utils.isUndefined(e)&&r&&r.view){const e=this.core.utils.getViewListFromView(r.view);e.length>0&&await i.play(e)}if(!this.core.utils.isUndefined(e)){const r=this.core.utils.getViewListFromView(e);r.length>0?await i.play(r):i.stop()}}stop(){var e;null==(e=this.localMixVideoTrack)||e.close(),this.localMixVideoTrack=null,delete this.onScreenShareStop,delete this._mixVideoConfig}};__publicField(_VideoMixer,"Name","VideoMixer");var VideoMixer=_VideoMixer,index_default=VideoMixer;export{index_default as default};export{VideoMixer};
1
+ var __defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,i,r)=>i in e?__defProp(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,__spreadValues=(e,i)=>{for(var r in i||(i={}))__hasOwnProp.call(i,r)&&__defNormalProp(e,r,i[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(i))__propIsEnum.call(i,r)&&__defNormalProp(e,r,i[r]);return e},__publicField=(e,i,r)=>__defNormalProp(e,"symbol"!=typeof i?i+"":i,r),layoutProperty={x:{required:!0,type:"number"},y:{required:!0,type:"number"},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},zIndex:{required:!0,type:"number"},fillMode:{required:!1,type:"string"},mirror:{required:!1,type:"boolean"},rotation:{required:!1,type:"number"},hidden:{required:!1,type:"boolean"}},canvasValidateRule=(e,i=!1)=>({type:"object",required:i,properties:{canvasColor:{required:!1,type:["string",CanvasGradient,CanvasPattern]},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},frameRate:{required:!1,type:"number",notLessThanZero:!0,min:1,max:60}},validate(i,r,t){const{RtcError:a,ErrorCode:o,ErrorCodeDictionary:s}=e.errorModule;if(!i)return;const{width:n,height:d}=i;if(n&&d&&n*d>8294400)throw new a({code:o.INVALID_PARAMETER,message:"The mix resolution cannot be set higher than 3840 * 2160."})}}),viewValidateRule=e=>({required:!1,type:["string",HTMLElement,null],validate(i,r,t){const{RtcError:a,ErrorCode:o,ErrorCodeDictionary:s}=e.errorModule;if(e.utils.isString(i)){if(!document.getElementById(i))throw new a({code:o.INVALID_PARAMETER,extraCode:s.INVALID_ELEMENT_ID,fnName:t,messageParams:{key:r}})}}}),layoutValidateRule=(e,i=!0)=>({type:"object",required:i,properties:__spreadValues({},layoutProperty),validate(i,r,t){const{RtcError:a,ErrorCode:o,ErrorCodeDictionary:s}=e.errorModule;if(i){if(i.fillMode&&!["contain","cover","fill"].includes(i.fillMode))throw new a({code:o.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_TYPE,message:"The fillMode parameter must be 'contain', 'cover' or 'fill'",fnName:t});if(i.rotation&&![0,90,180,270].includes(i.rotation))throw new a({code:o.INVALID_PARAMETER,extraCode:s.INVALID_PARAMETER_TYPE,message:"The rotation parameter must be 0, 90, 180 or 270",fnName:t})}}}),cameraValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},cameraId:{required:!1,type:"string"},videoTrack:{required:!1,instanceof:MediaStreamTrack},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},layout:__spreadValues({},layoutValidateRule(e))}}}),screenValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},captureElement:{required:!1,type:HTMLElement},preferDisplaySurface:{required:!1,type:"string"},layout:__spreadValues({},layoutValidateRule(e))},validate(i,r,t){const{RtcError:a,ErrorCode:o,ErrorCodeDictionary:s}=e.errorModule;if(!e.rtcDectection.isScreenCaptureApiAvailable())throw new a({code:o.ENV_NOT_SUPPORTED,fnName:t,extraCode:s.NOT_SUPPORTED_SCREEN_SHARE})}}}),textValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},content:{required:!0,type:"string"},font:{required:!1,type:"string"},color:{required:!1,type:["string",CanvasGradient,CanvasPattern]},layout:__spreadValues({},layoutValidateRule(e))}}}),imageValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:__spreadValues({},layoutValidateRule(e))}}}),videoValidateRule=e=>({type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:__spreadValues({},layoutValidateRule(e))}}});function startValidateRule(e){return{name:"VideoMixerOptions",type:"object",required:!0,allowEmpty:!1,properties:{view:__spreadValues({},viewValidateRule(e)),canvasInfo:__spreadValues({},canvasValidateRule(e,!0)),camera:__spreadValues({},cameraValidateRule(e)),screen:__spreadValues({},screenValidateRule(e)),text:__spreadValues({},textValidateRule(e)),image:__spreadValues({},imageValidateRule(e)),video:__spreadValues({},videoValidateRule(e))},validate(i,r,t,a){const{RtcError:o,ErrorCode:s,ErrorCodeDictionary:n}=e.errorModule;if(e.environment.isMobile())throw new o({code:s.ENV_NOT_SUPPORTED,message:"VideoMixer is not supported on mobile devices currently"});const{onScreenShareStop:d}=i;if(d&&!e.utils.isFunction(d))throw new o({code:s.INVALID_PARAMETER,extraCode:n.INVALID_PARAMETER_TYPE,fnName:t,messageParams:{key:"onScreenShareStop",value:typeof d,rule:{type:"Function"}}})}}}function updateValidateRule(e){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{view:__spreadValues({},viewValidateRule(e)),canvasInfo:__spreadValues({},canvasValidateRule(e)),camera:__spreadValues({},cameraValidateRule(e)),screen:__spreadValues({},screenValidateRule(e)),text:__spreadValues({},textValidateRule(e)),image:__spreadValues({},imageValidateRule(e)),video:__spreadValues({},videoValidateRule(e))}}}function stopValidateRule(e){return{name:"StopVideoMixerOptions",required:!1}}var videoMixSeq=0,_VideoMixer=class e{constructor(e){this.core=e,__publicField(this,"seq"),__publicField(this,"log"),__publicField(this,"localMixVideoTrack",null),__publicField(this,"systemAudioTrack"),__publicField(this,"_mixVideoConfig"),__publicField(this,"onScreenShareStop"),videoMixSeq+=1,this.seq=videoMixSeq,this.log=e.log.createChild({id:`${this.getAlias()}${videoMixSeq}`}),this.log.info("created")}getName(){return e.Name}getAlias(){return"vmix"}getValidateRule(e){switch(e){case"start":return startValidateRule(this.core);case"update":return updateValidateRule(this.core);case"stop":return stopValidateRule(this.core)}}getGroup(){return"vmix"}async start(e){this.localMixVideoTrack||(this.localMixVideoTrack=new this.core.LocalMixVideoTrack(this.core.room.videoManager)),this._mixVideoConfig={canvasInfo:{width:1920,height:1080}},e=this.core.utils.deepCloneBasic(e);const{view:i,onScreenShareStop:r}=e,t=await this.parseMixOptions(e);return r&&(this.onScreenShareStop=r,this._mixVideoConfig.onScreenShareStop=r),this._updatePreview({view:i,track:this.localMixVideoTrack}),this.core.utils.isUndefined(i)||(this._mixVideoConfig.view=i),await this.localMixVideoTrack.startMix(),{track:this.localMixVideoTrack._outputTrack,systemAudioTrack:this.systemAudioTrack,result:t}}async update(e){const{RtcError:i,ErrorCode:r}=this.core.errorModule;if(!this.localMixVideoTrack)throw new i({code:r.INVALID_OPERATION,message:"mixTrack doesn't initialize!"});e=this.core.utils.deepCloneBasic(e);const{view:t}=e,a=await this.parseMixOptions(e);return await this._updatePreview({view:t,track:this.localMixVideoTrack,prevConfig:this._mixVideoConfig}),this.core.utils.isUndefined(t)||(this._mixVideoConfig.view=t),{track:this.localMixVideoTrack._outputTrack,systemAudioTrack:this.systemAudioTrack,result:a}}async parseMixOptions(e){let i={successOptions:{},failedDetails:[]};const{RtcError:r,ErrorCode:t,ErrorCodeDictionary:a}=this.core.errorModule;if(!this.localMixVideoTrack||!this._mixVideoConfig)return i;const o=[],s=__spreadValues({},e),{canvasInfo:n,camera:d,screen:l,text:c,image:u,video:p}=e;let h=0,m=0;if(n){const{canvasColor:e,width:i,height:r,frameRate:t}=n;e&&this.localMixVideoTrack.setMixBackground(e),t&&this.localMixVideoTrack.setFps(t),this.localMixVideoTrack.resizeMixCanvas(i,r),this._mixVideoConfig.canvasInfo=n}if(d){h++;const{finalOptions:e,errors:i}=await this.parseCameraOptions(this.localMixVideoTrack,d,this._mixVideoConfig.camera);this._mixVideoConfig.camera=e,s.camera=e,i.length>0&&(o.push(...i),i.length===d.length&&m++)}if(l){h++;const{finalOptions:e,errors:i}=await this.parseScreenOptions(this.localMixVideoTrack,l,this._mixVideoConfig.screen);this._mixVideoConfig.screen=e,s.screen=e,i.length>0&&(o.push(...i),i.length===l.length&&m++)}if(c){h++;const{finalOptions:e,errors:i}=await this.parseTextOptions(this.localMixVideoTrack,c,this._mixVideoConfig.text);this._mixVideoConfig.text=e,s.text=e,i.length>0&&(o.push(...i),i.length===c.length&&m++)}if(u){h++;const{finalOptions:e,errors:i}=await this.parseImageOptions(this.localMixVideoTrack,u,this._mixVideoConfig.image);this._mixVideoConfig.image=e,s.image=e,i.length>0&&(o.push(...i),i.length===u.length&&m++)}if(p){h++;const{finalOptions:e,errors:i}=await this.parseVideoOptions(this.localMixVideoTrack,p,this._mixVideoConfig.video);this._mixVideoConfig.video=e,s.video=e,i.length>0&&(o.push(...i),i.length===p.length&&m++)}if(m>0&&m===h)throw new r({code:t.INVALID_PARAMETER,message:"all sources mix failed",data:{failedDetails:o}});return i={successOptions:s,failedDetails:o},i}async parseCameraOptions(e,i,r=[]){var t,a;const o=new Set(i.map((e=>e.id))),s=r.filter((e=>!o.has(e.id))).map((e=>e.id));for(const i of s)e.removeCameraSource(i);const n=new Map(r.map((e=>[e.id,e]))),d=[],l=[];for(const r of i){const{id:i,layout:o,profile:s}=r;try{if(e.inputLocalVideoTracks.has(i)){const n=null==(t=e.inputLocalVideoTracks.get(i))?void 0:t.mediaTrack;await this.updateCameraProfile(r);const d=null==(a=e.inputLocalVideoTracks.get(i))?void 0:a.mediaTrack;let l;s&&(l=this.core.utils.isString(s)?this.core.constants.videoProfileMap[s]:s),d!==n?e.updateCameraSource(i,o,d,l):e.updateCameraSource(i,o,null,l)}else{const t=await this.captureCamera(r);try{e.addCameraSource(i,t,o)}catch(e){throw t.close(),e}}d.push(r)}catch(e){l.push({id:i,error:e}),n.has(i)&&d.push(n.get(i))}}return{finalOptions:d,errors:l}}async parseScreenOptions(e,i,r=[]){const t=new Set(i.map((e=>e.id))),a=r.filter((e=>!t.has(e.id))).map((e=>e.id));for(const i of a)e.removeScreenSource(i);const o=new Map(r.map((e=>[e.id,e]))),s=[],n=[];for(const r of i){const{id:i,layout:t}=r;try{if(e.inputLocalScreenTracks.has(i))e.updateScreenSource(i,t);else{const a=await this.captureScreen(r);try{e.addScreenSource(i,a,t)}catch(e){throw a.close(),e}}s.push(r)}catch(e){n.push({id:i,error:e}),o.has(i)&&s.push(o.get(i))}}return{finalOptions:s,errors:n}}async parseTextOptions(e,i,r=[]){const t=new Set(i.map((e=>e.id))),a=r.filter((e=>!t.has(e.id))).map((e=>e.id));for(const i of a)e.removeTextSource(i);const o=new Map(r.map((e=>[e.id,e]))),s=[],n=[];for(const t of i){const{id:i}=t;try{r.some((e=>e.id===i))?e.updateTextSource(t):e.addTextSource(t),s.push(t)}catch(e){n.push({id:i,error:e}),o.has(i)&&s.push(o.get(i))}}return{finalOptions:s,errors:n}}async parseImageOptions(e,i,r=[]){const t=new Set(i.map((e=>e.id))),a=r.filter((e=>!t.has(e.id))).map((e=>e.id));for(const i of a)e.removeImageSource(i);const o=new Map(r.map((e=>[e.id,e]))),s=[],n=[];for(const t of i){const{id:i,url:a,layout:d}=t;try{const o=r.find((e=>e.id===i));if(o){let r;o.url!==a&&(r=await this.core.utils.loadImage(a)),e.updateImageSource(i,d,r)}else{const r=await this.core.utils.loadImage(a);e.addImageSource(i,r,d)}s.push(t)}catch(e){n.push({id:i,error:e}),o.has(i)&&s.push(o.get(i))}}return{finalOptions:s,errors:n}}async parseVideoOptions(e,i,r=[]){const t=new Set(i.map((e=>e.id))),a=r.filter((e=>!t.has(e.id))).map((e=>e.id));for(const i of a)e.removeVideoSource(i);const o=new Map(r.map((e=>[e.id,e]))),s=[],n=[];for(const t of i){const{id:i,url:a,layout:d}=t;try{const o=r.find((e=>e.id===i));let n;if(o)o.url!==a&&(n=await this.core.utils.loadVideo(a)),e.updateVideoSource(i,d,n);else{const r=await this.core.utils.loadVideo(a);e.addVideoSource(i,r,d)}s.push(t)}catch(e){n.push({id:i,error:e}),o.has(i)&&s.push(o.get(i))}}return{finalOptions:s,errors:n}}async captureCamera(e){const{id:i,cameraId:r,videoTrack:t,profile:a}=e,o=new this.core.LocalVideoTrack;o.log.id+=`-${i}`;const s={};return r?s.deviceId=r:this.core.utils.isUndefined(t)||(s.customSource=t),this.core.utils.isUndefined(a)||(this.core.utils.isString(a)?this.core.constants.videoProfileMap[a]&&o.setProfile(this.core.constants.videoProfileMap[a]):o.setProfile(a)),await o.capture(s),o}async updateCameraProfile(e){var i;const{id:r,cameraId:t,videoTrack:a,profile:o}=e,s=null==(i=this.localMixVideoTrack)?void 0:i.inputLocalVideoTracks.get(r);s&&(t?await s.switchDevice(t):this.core.utils.isUndefined(a)||await s.setInputMediaStreamTrack(a),this.core.utils.isUndefined(o)||(this.core.utils.isString(o)?this.core.constants.videoProfileMap[o]&&s.setProfile(this.core.constants.videoProfileMap[o]):s.setProfile(o),t&&s.isNeedToSwitchDevice(t)||await s.applyProfile()))}async captureScreen(e){const{id:i,profile:r,captureElement:t,preferDisplaySurface:a}=e,o=new this.core.LocalScreenTrack;o.log.id+=`-${i}`;const s={};this.core.utils.isUndefined(r)||(this.core.utils.isString(r)?this.core.constants.screenProfileMap[r]&&o.setProfile(this.core.constants.screenProfileMap[r]):o.setProfile(r)),t&&(s.captureElement=t),a&&(s.preferDisplaySurface=a),s.systemAudio=e.systemAudio;const n=await o.capture(s);return s.systemAudio&&n.getAudioTracks().length>0&&(this.systemAudioTrack=n.getAudioTracks()[0]),o.mediaTrack.addEventListener(this.core.constants.NAME.ENDED,(()=>{var e,r,t;null==(e=this.localMixVideoTrack)||e.removeScreenSource(i),(null==(r=this._mixVideoConfig)?void 0:r.screen)&&(this._mixVideoConfig.screen=this._mixVideoConfig.screen.filter((e=>e.id!==i))),null==(t=this.onScreenShareStop)||t.call(this,i)})),o}async _updatePreview({view:e,track:i,prevConfig:r}){if(this.core.utils.isUndefined(e)&&r&&r.view){const e=this.core.utils.getViewListFromView(r.view);e.length>0&&await i.play(e)}if(!this.core.utils.isUndefined(e)){const r=this.core.utils.getViewListFromView(e);r.length>0?await i.play(r):i.stop()}}stop(){var e;null==(e=this.localMixVideoTrack)||e.close(),this.localMixVideoTrack=null,delete this.onScreenShareStop,delete this._mixVideoConfig}};__publicField(_VideoMixer,"Name","VideoMixer");var VideoMixer=_VideoMixer,index_default=VideoMixer;export{index_default as default};export{VideoMixer};
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).VideoMixer=r()}(this,(function(){"use strict";function e(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function r(e,r,t,n,i,o,a){try{var c=e[o](a),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,i)}function t(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function c(e){r(a,i,o,c,s,"next",e)}function s(e){r(a,i,o,c,s,"throw",e)}c(void 0)}))}}function n(e,r,t){return r&&function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=u(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,o=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw o}}}}function o(){o=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function l(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{l({},"")}catch(e){l=function(e,r,t){return e[r]=t}}function f(e,r,t,n){var o=r&&r.prototype instanceof x?r:x,a=Object.create(o.prototype),c=new L(n||[]);return i(a,"_invoke",{value:M(e,t,c)}),a}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=f;var d="suspendedStart",h="suspendedYield",v="executing",y="completed",m={};function x(){}function g(){}function b(){}var w={};l(w,c,(function(){return this}));var k=Object.getPrototypeOf,S=k&&k(k(P([])));S&&S!==t&&n.call(S,c)&&(w=S);var E=b.prototype=x.prototype=Object.create(w);function T(e){["next","throw","return"].forEach((function(r){l(e,r,(function(e){return this._invoke(r,e)}))}))}function V(e,r){function t(i,o,a,c){var s=p(e[i],e,o);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,a,c)}),(function(e){t("throw",e,a,c)})):r.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return t("throw",e,a,c)}))}c(s.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new r((function(r,i){t(e,n,r,i)}))}return o=o?o.then(i,i):i()}})}function M(r,t,n){var i=d;return function(o,a){if(i===v)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:e,done:!0}}for(n.method=o,n.arg=a;;){var c=n.delegate;if(c){var s=C(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===d)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var u=p(r,t,n);if("normal"===u.type){if(i=n.done?y:h,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function C(r,t){var n=t.method,i=r.iterator[n];if(i===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,C(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var o=p(i,r.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,m;var a=o.arg;return a?a.done?(t[r.resultName]=a.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,m):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function _(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function O(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function P(r){if(r||""===r){var t=r[c];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var i=-1,o=function t(){for(;++i<r.length;)if(n.call(r,i))return t.value=r[i],t.done=!1,t;return t.value=e,t.done=!0,t};return o.next=o}}throw new TypeError(typeof r+" is not iterable")}return g.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=l(b,u,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,l(e,u,"GeneratorFunction")),e.prototype=Object.create(E),e},r.awrap=function(e){return{__await:e}},T(V.prototype),l(V.prototype,s,(function(){return this})),r.AsyncIterator=V,r.async=function(e,t,n,i,o){void 0===o&&(o=Promise);var a=new V(f(e,t,n,i),o);return r.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},T(E),l(E,u,"Generator"),l(E,c,(function(){return this})),l(E,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=P,L.prototype={constructor:L,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function i(n,i){return c.type="throw",c.arg=r,t.next=n,i&&(t.method="next",t.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),O(t),m}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var i=n.arg;O(t)}return i}}throw Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:P(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),m}},r}function a(r){return function(r){if(Array.isArray(r))return e(r)}(r)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||u(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){var r=function(e,r){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof r?r:r+""}function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function u(r,t){if(r){if("string"==typeof r)return e(r,t);var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(r,t):void 0}}var l=Object.defineProperty,f=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,h=function(e,r,t){return r in e?l(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t},v=function(e,r){for(var t in r||(r={}))p.call(r,t)&&h(e,t,r[t]);if(f){var n,o=i(f(r));try{for(o.s();!(n=o.n()).done;){t=n.value;d.call(r,t)&&h(e,t,r[t])}}catch(e){o.e(e)}finally{o.f()}}return e},y=function(e,r,t){return h(e,"symbol"!==s(r)?r+"":r,t)},m={x:{required:!0,type:"number"},y:{required:!0,type:"number"},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},zIndex:{required:!0,type:"number"},fillMode:{required:!1,type:"string"},mirror:{required:!1,type:"boolean"},rotation:{required:!1,type:"number"},hidden:{required:!1,type:"boolean"}},x=function(e){return{type:"object",required:arguments.length>1&&void 0!==arguments[1]&&arguments[1],properties:{canvasColor:{required:!1,type:["string",CanvasGradient,CanvasPattern]},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},frameRate:{required:!1,type:"number",notLessThanZero:!0,min:1,max:60}},validate:function(r,t,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode;if(i.ErrorCodeDictionary,r){var c=r.width,s=r.height;if(c&&s&&c*s>8294400)throw new o({code:a.INVALID_PARAMETER,message:"The mix resolution cannot be set higher than 3840 * 2160."})}}}},g=function(e){return{required:!1,type:["string",HTMLElement,null],validate:function(r,t,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode,c=i.ErrorCodeDictionary;if(e.utils.isString(r)&&!document.getElementById(r))throw new o({code:a.INVALID_PARAMETER,extraCode:c.INVALID_ELEMENT_ID,fnName:n,messageParams:{key:t}})}}},b=function(e){return{type:"object",required:!(arguments.length>1&&void 0!==arguments[1])||arguments[1],properties:v({},m),validate:function(r,t,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode,c=i.ErrorCodeDictionary;if(r){if(r.fillMode&&!["contain","cover","fill"].includes(r.fillMode))throw new o({code:a.INVALID_PARAMETER,extraCode:c.INVALID_PARAMETER_TYPE,message:"The fillMode parameter must be 'contain', 'cover' or 'fill'",fnName:n});if(r.rotation&&![0,90,180,270].includes(r.rotation))throw new o({code:a.INVALID_PARAMETER,extraCode:c.INVALID_PARAMETER_TYPE,message:"The rotation parameter must be 0, 90, 180 or 270",fnName:n})}}}},w=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},cameraId:{required:!1,type:"string"},videoTrack:{required:!1,instanceof:MediaStreamTrack},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},layout:v({},b(e))}}}},k=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},captureElement:{required:!1,type:HTMLElement},preferDisplaySurface:{required:!1,type:"string"},layout:v({},b(e))},validate:function(r,t,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode,c=i.ErrorCodeDictionary;if(!e.rtcDectection.isScreenCaptureApiAvailable())throw new o({code:a.ENV_NOT_SUPPORTED,fnName:n,extraCode:c.NOT_SUPPORTED_SCREEN_SHARE})}}}},S=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},content:{required:!0,type:"string"},font:{required:!1,type:"string"},color:{required:!1,type:["string",CanvasGradient,CanvasPattern]},layout:v({},b(e))}}}},E=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:v({},b(e))}}}},T=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:v({},b(e))}}}};var V=0,M=function(){function e(r){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.core=r,y(this,"seq"),y(this,"log"),y(this,"localMixVideoTrack",null),y(this,"_mixVideoConfig"),y(this,"onScreenShareStop"),V+=1,this.seq=V,this.log=r.log.createChild({id:"".concat(this.getAlias()).concat(V)}),this.log.info("created")}return n(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"vmix"}},{key:"getValidateRule",value:function(e){switch(e){case"start":return r=this.core,{name:"VideoMixerOptions",type:"object",required:!0,allowEmpty:!1,properties:{view:v({},g(r)),canvasInfo:v({},x(r,!0)),camera:v({},w(r)),screen:v({},k(r)),text:v({},S(r)),image:v({},E(r)),video:v({},T(r))},validate:function(e,t,n,i){var o=r.errorModule,a=o.RtcError,c=o.ErrorCode,u=o.ErrorCodeDictionary;if(r.environment.isMobile())throw new a({code:c.ENV_NOT_SUPPORTED,message:"VideoMixer is not supported on mobile devices currently"});var l=e.onScreenShareStop;if(l&&!r.utils.isFunction(l))throw new a({code:c.INVALID_PARAMETER,extraCode:u.INVALID_PARAMETER_TYPE,fnName:n,messageParams:{key:"onScreenShareStop",value:s(l),rule:{type:"Function"}}})}};case"update":return function(e){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{view:v({},g(e)),canvasInfo:v({},x(e)),camera:v({},w(e)),screen:v({},k(e)),text:v({},S(e)),image:v({},E(e)),video:v({},T(e))}}}(this.core);case"stop":return this.core,{name:"StopVideoMixerOptions",required:!1}}var r}},{key:"getGroup",value:function(){return"vmix"}},{key:"start",value:(C=t(o().mark((function e(r){var t,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.localMixVideoTrack||(this.localMixVideoTrack=new this.core.LocalMixVideoTrack(this.core.room.videoManager)),this._mixVideoConfig={canvasInfo:{width:1920,height:1080}},r=this.core.utils.deepCloneBasic(r),n=(t=r).view,i=t.onScreenShareStop,e.next=6,this.parseMixOptions(r);case 6:return a=e.sent,i&&(this.onScreenShareStop=i,this._mixVideoConfig.onScreenShareStop=i),this._updatePreview({view:n,track:this.localMixVideoTrack}),this.core.utils.isUndefined(n)||(this._mixVideoConfig.view=n),e.next=12,this.localMixVideoTrack.startMix();case 12:return e.abrupt("return",{track:this.localMixVideoTrack._outputTrack,result:a});case 13:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"update",value:(M=t(o().mark((function e(r){var t,n,i,a,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.core.errorModule,n=t.RtcError,i=t.ErrorCode,this.localMixVideoTrack){e.next=3;break}throw new n({code:i.INVALID_OPERATION,message:"mixTrack doesn't initialize!"});case 3:return r=this.core.utils.deepCloneBasic(r),a=r.view,e.next=7,this.parseMixOptions(r);case 7:return c=e.sent,e.next=10,this._updatePreview({view:a,track:this.localMixVideoTrack,prevConfig:this._mixVideoConfig});case 10:return this.core.utils.isUndefined(a)||(this._mixVideoConfig.view=a),e.abrupt("return",{track:this.localMixVideoTrack._outputTrack,result:c});case 12:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"parseMixOptions",value:(b=t(o().mark((function e(r){var t,n,i,c,s,u,l,f,p,d,h,y,m,x,g,b,w,k,S,E,T,V,M,C,_,O,L,P,I,A,q,N,j;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={successOptions:{},failedDetails:[]},n=this.core.errorModule,i=n.RtcError,c=n.ErrorCode,n.ErrorCodeDictionary,this.localMixVideoTrack&&this._mixVideoConfig){e.next=4;break}return e.abrupt("return",t);case 4:if(s=[],u=v({},r),l=r.canvasInfo,f=r.camera,p=r.screen,d=r.text,h=r.image,y=r.video,m=0,x=0,l&&(g=l.canvasColor,b=l.width,w=l.height,k=l.frameRate,g&&this.localMixVideoTrack.setMixBackground(g),k&&this.localMixVideoTrack.setFps(k),this.localMixVideoTrack.resizeMixCanvas(b,w),this._mixVideoConfig.canvasInfo=l),!f){e.next=20;break}return m++,e.next=14,this.parseCameraOptions(this.localMixVideoTrack,f,this._mixVideoConfig.camera);case 14:S=e.sent,E=S.finalOptions,T=S.errors,this._mixVideoConfig.camera=E,u.camera=E,T.length>0&&(s.push.apply(s,a(T)),T.length===f.length&&x++);case 20:if(!p){e.next=30;break}return m++,e.next=24,this.parseScreenOptions(this.localMixVideoTrack,p,this._mixVideoConfig.screen);case 24:V=e.sent,M=V.finalOptions,C=V.errors,this._mixVideoConfig.screen=M,u.screen=M,C.length>0&&(s.push.apply(s,a(C)),C.length===p.length&&x++);case 30:if(!d){e.next=40;break}return m++,e.next=34,this.parseTextOptions(this.localMixVideoTrack,d,this._mixVideoConfig.text);case 34:_=e.sent,O=_.finalOptions,L=_.errors,this._mixVideoConfig.text=O,u.text=O,L.length>0&&(s.push.apply(s,a(L)),L.length===d.length&&x++);case 40:if(!h){e.next=50;break}return m++,e.next=44,this.parseImageOptions(this.localMixVideoTrack,h,this._mixVideoConfig.image);case 44:P=e.sent,I=P.finalOptions,A=P.errors,this._mixVideoConfig.image=I,u.image=I,A.length>0&&(s.push.apply(s,a(A)),A.length===h.length&&x++);case 50:if(!y){e.next=60;break}return m++,e.next=54,this.parseVideoOptions(this.localMixVideoTrack,y,this._mixVideoConfig.video);case 54:q=e.sent,N=q.finalOptions,j=q.errors,this._mixVideoConfig.video=N,u.video=N,j.length>0&&(s.push.apply(s,a(j)),j.length===y.length&&x++);case 60:if(!(x>0&&x===m)){e.next=62;break}throw new i({code:c.INVALID_PARAMETER,message:"all sources mix failed",data:{failedDetails:s}});case 62:return t={successOptions:u,failedDetails:s},e.abrupt("return",t);case 64:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"parseCameraOptions",value:(m=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,v,y,m,x,g,b,w,k,S,E,T,V=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=V.length>2&&void 0!==V[2]?V[2]:[],s=new Set(t.map((function(e){return e.id}))),u=n.filter((function(e){return!s.has(e.id)})).map((function(e){return e.id})),l=i(u);try{for(l.s();!(f=l.n()).done;)p=f.value,r.removeCameraSource(p)}catch(e){l.e(e)}finally{l.f()}d=new Map(n.map((function(e){return[e.id,e]}))),h=[],v=[],y=i(t),e.prev=9,y.s();case 11:if((m=y.n()).done){e.next=45;break}if(x=m.value,g=x.id,b=x.layout,w=x.profile,e.prev=14,!r.inputLocalVideoTracks.has(g)){e.next=25;break}return k=null==(a=r.inputLocalVideoTracks.get(g))?void 0:a.mediaTrack,e.next=19,this.updateCameraProfile(x);case 19:S=null==(c=r.inputLocalVideoTracks.get(g))?void 0:c.mediaTrack,E=void 0,w&&(E=this.core.utils.isString(w)?this.core.constants.videoProfileMap[w]:w),S!==k?r.updateCameraSource(g,b,S,E):r.updateCameraSource(g,b,null,E),e.next=36;break;case 25:return e.next=27,this.captureCamera(x);case 27:T=e.sent,e.prev=28,r.addCameraSource(g,T,b),e.next=36;break;case 32:throw e.prev=32,e.t0=e.catch(28),T.close(),e.t0;case 36:h.push(x),e.next=43;break;case 39:e.prev=39,e.t1=e.catch(14),v.push({id:g,error:e.t1}),d.has(g)&&h.push(d.get(g));case 43:e.next=11;break;case 45:e.next=50;break;case 47:e.prev=47,e.t2=e.catch(9),y.e(e.t2);case 50:return e.prev=50,y.f(),e.finish(50);case 53:return e.abrupt("return",{finalOptions:h,errors:v});case 54:case"end":return e.stop()}}),e,this,[[9,47,50,53],[14,39],[28,32]])}))),function(e,r){return m.apply(this,arguments)})},{key:"parseScreenOptions",value:(h=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,v,y,m,x,g,b=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=b.length>2&&void 0!==b[2]?b[2]:[],a=new Set(t.map((function(e){return e.id}))),c=n.filter((function(e){return!a.has(e.id)})).map((function(e){return e.id})),s=i(c);try{for(s.s();!(u=s.n()).done;)l=u.value,r.removeScreenSource(l)}catch(e){s.e(e)}finally{s.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=[],h=i(t),e.prev=9,h.s();case 11:if((v=h.n()).done){e.next=39;break}if(y=v.value,m=y.id,x=y.layout,e.prev=14,!r.inputLocalScreenTracks.has(m)){e.next=19;break}r.updateScreenSource(m,x),e.next=30;break;case 19:return e.next=21,this.captureScreen(y);case 21:g=e.sent,e.prev=22,r.addScreenSource(m,g,x),e.next=30;break;case 26:throw e.prev=26,e.t0=e.catch(22),g.close(),e.t0;case 30:p.push(y),e.next=37;break;case 33:e.prev=33,e.t1=e.catch(14),d.push({id:m,error:e.t1}),f.has(m)&&p.push(f.get(m));case 37:e.next=11;break;case 39:e.next=44;break;case 41:e.prev=41,e.t2=e.catch(9),h.e(e.t2);case 44:return e.prev=44,h.f(),e.finish(44);case 47:return e.abrupt("return",{finalOptions:p,errors:d});case 48:case"end":return e.stop()}}),e,this,[[9,41,44,47],[14,33],[22,26]])}))),function(e,r){return h.apply(this,arguments)})},{key:"parseTextOptions",value:(d=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,v,y,m=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=m.length>2&&void 0!==m[2]?m[2]:[],a=new Set(t.map((function(e){return e.id}))),c=n.filter((function(e){return!a.has(e.id)})).map((function(e){return e.id})),s=i(c);try{for(s.s();!(u=s.n()).done;)l=u.value,r.removeTextSource(l)}catch(e){s.e(e)}finally{s.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=[],h=i(t),e.prev=9,y=o().mark((function e(){var t,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=v.value,i=t.id;try{n.some((function(e){return e.id===i}))?r.updateTextSource(t):r.addTextSource(t),p.push(t)}catch(e){d.push({id:i,error:e}),f.has(i)&&p.push(f.get(i))}case 3:case"end":return e.stop()}}),e)})),h.s();case 12:if((v=h.n()).done){e.next=16;break}return e.delegateYield(y(),"t0",14);case 14:e.next=12;break;case 16:e.next=21;break;case 18:e.prev=18,e.t1=e.catch(9),h.e(e.t1);case 21:return e.prev=21,h.f(),e.finish(21);case 24:return e.abrupt("return",{finalOptions:p,errors:d});case 25:case"end":return e.stop()}}),e,null,[[9,18,21,24]])}))),function(e,r){return d.apply(this,arguments)})},{key:"parseImageOptions",value:(p=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,v,y,m=this,x=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=x.length>2&&void 0!==x[2]?x[2]:[],a=new Set(t.map((function(e){return e.id}))),c=n.filter((function(e){return!a.has(e.id)})).map((function(e){return e.id})),s=i(c);try{for(s.s();!(u=s.n()).done;)l=u.value,r.removeImageSource(l)}catch(e){s.e(e)}finally{s.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=[],h=i(t),e.prev=9,y=o().mark((function e(){var t,i,a,c,s,u,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=v.value,i=t.id,a=t.url,c=t.layout,e.prev=2,!(s=n.find((function(e){return e.id===i})))){e.next=12;break}if(s.url===a){e.next=9;break}return e.next=8,m.core.utils.loadImage(a);case 8:u=e.sent;case 9:r.updateImageSource(i,c,u),e.next=16;break;case 12:return e.next=14,m.core.utils.loadImage(a);case 14:l=e.sent,r.addImageSource(i,l,c);case 16:p.push(t),e.next=23;break;case 19:e.prev=19,e.t0=e.catch(2),d.push({id:i,error:e.t0}),f.has(i)&&p.push(f.get(i));case 23:case"end":return e.stop()}}),e,null,[[2,19]])})),h.s();case 12:if((v=h.n()).done){e.next=16;break}return e.delegateYield(y(),"t0",14);case 14:e.next=12;break;case 16:e.next=21;break;case 18:e.prev=18,e.t1=e.catch(9),h.e(e.t1);case 21:return e.prev=21,h.f(),e.finish(21);case 24:return e.abrupt("return",{finalOptions:p,errors:d});case 25:case"end":return e.stop()}}),e,null,[[9,18,21,24]])}))),function(e,r){return p.apply(this,arguments)})},{key:"parseVideoOptions",value:(f=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,v,y,m=this,x=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=x.length>2&&void 0!==x[2]?x[2]:[],a=new Set(t.map((function(e){return e.id}))),c=n.filter((function(e){return!a.has(e.id)})).map((function(e){return e.id})),s=i(c);try{for(s.s();!(u=s.n()).done;)l=u.value,r.removeVideoSource(l)}catch(e){s.e(e)}finally{s.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=[],h=i(t),e.prev=9,y=o().mark((function e(){var t,i,a,c,s,u,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=v.value,i=t.id,a=t.url,c=t.layout,e.prev=2,!(s=n.find((function(e){return e.id===i})))){e.next=12;break}if(s.url===a){e.next=9;break}return e.next=8,m.core.utils.loadVideo(a);case 8:u=e.sent;case 9:r.updateVideoSource(i,c,u),e.next=16;break;case 12:return e.next=14,m.core.utils.loadVideo(a);case 14:l=e.sent,r.addVideoSource(i,l,c);case 16:p.push(t),e.next=23;break;case 19:e.prev=19,e.t0=e.catch(2),d.push({id:i,error:e.t0}),f.has(i)&&p.push(f.get(i));case 23:case"end":return e.stop()}}),e,null,[[2,19]])})),h.s();case 12:if((v=h.n()).done){e.next=16;break}return e.delegateYield(y(),"t0",14);case 14:e.next=12;break;case 16:e.next=21;break;case 18:e.prev=18,e.t1=e.catch(9),h.e(e.t1);case 21:return e.prev=21,h.f(),e.finish(21);case 24:return e.abrupt("return",{finalOptions:p,errors:d});case 25:case"end":return e.stop()}}),e,null,[[9,18,21,24]])}))),function(e,r){return f.apply(this,arguments)})},{key:"captureCamera",value:(l=t(o().mark((function e(r){var t,n,i,a,c,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.id,n=r.cameraId,i=r.videoTrack,a=r.profile,(c=new this.core.LocalVideoTrack).log.id+="-".concat(t),s={},n?s.deviceId=n:this.core.utils.isUndefined(i)||(s.customSource=i),this.core.utils.isUndefined(a)||(this.core.utils.isString(a)?this.core.constants.videoProfileMap[a]&&c.setProfile(this.core.constants.videoProfileMap[a]):c.setProfile(a)),e.next=8,c.capture(s);case 8:return e.abrupt("return",c);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateCameraProfile",value:(u=t(o().mark((function e(r){var t,n,i,a,c,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.id,i=r.cameraId,a=r.videoTrack,c=r.profile,s=null==(t=this.localMixVideoTrack)?void 0:t.inputLocalVideoTracks.get(n)){e.next=4;break}return e.abrupt("return");case 4:if(!i){e.next=9;break}return e.next=7,s.switchDevice(i);case 7:e.next=12;break;case 9:if(this.core.utils.isUndefined(a)){e.next=12;break}return e.next=12,s.setInputMediaStreamTrack(a);case 12:if(this.core.utils.isUndefined(c)){e.next=17;break}if(this.core.utils.isString(c)?this.core.constants.videoProfileMap[c]&&s.setProfile(this.core.constants.videoProfileMap[c]):s.setProfile(c),i&&s.isNeedToSwitchDevice(i)){e.next=17;break}return e.next=17,s.applyProfile();case 17:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"captureScreen",value:(c=t(o().mark((function e(r){var t,n,i,a,c,s,u=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.id,n=r.profile,i=r.captureElement,a=r.preferDisplaySurface,(c=new this.core.LocalScreenTrack).log.id+="-".concat(t),s={},this.core.utils.isUndefined(n)||(this.core.utils.isString(n)?this.core.constants.screenProfileMap[n]&&c.setProfile(this.core.constants.screenProfileMap[n]):c.setProfile(n)),i&&(s.captureElement=i),a&&(s.preferDisplaySurface=a),e.next=9,c.capture(s);case 9:return c.mediaTrack.addEventListener(this.core.constants.NAME.ENDED,(function(){var e,r,n;null==(e=u.localMixVideoTrack)||e.removeScreenSource(t),(null==(r=u._mixVideoConfig)?void 0:r.screen)&&(u._mixVideoConfig.screen=u._mixVideoConfig.screen.filter((function(e){return e.id!==t}))),null==(n=u.onScreenShareStop)||n.call(u,t)})),e.abrupt("return",c);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"_updatePreview",value:(r=t(o().mark((function e(r){var t,n,i,a,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.view,n=r.track,i=r.prevConfig,!(this.core.utils.isUndefined(t)&&i&&i.view)){e.next=6;break}if(!((a=this.core.utils.getViewListFromView(i.view)).length>0)){e.next=6;break}return e.next=6,n.play(a);case 6:if(this.core.utils.isUndefined(t)){e.next=14;break}if(!((c=this.core.utils.getViewListFromView(t)).length>0)){e.next=13;break}return e.next=11,n.play(c);case 11:e.next=14;break;case 13:n.stop();case 14:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e;null==(e=this.localMixVideoTrack)||e.close(),this.localMixVideoTrack=null,delete this.onScreenShareStop,delete this._mixVideoConfig}}]);var r,c,u,l,f,p,d,h,m,b,M,C}();return y(M,"Name","VideoMixer"),M}));
1
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).VideoMixer=r()}(this,(function(){"use strict";function e(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function r(e,r,t,n,i,o,a){try{var c=e[o](a),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,i)}function t(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function c(e){r(a,i,o,c,s,"next",e)}function s(e){r(a,i,o,c,s,"throw",e)}c(void 0)}))}}function n(e,r,t){return r&&function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=u(e))||r){t&&(e=t);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,o=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw o}}}}function o(){o=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function l(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{l({},"")}catch(e){l=function(e,r,t){return e[r]=t}}function f(e,r,t,n){var o=r&&r.prototype instanceof g?r:g,a=Object.create(o.prototype),c=new A(n||[]);return i(a,"_invoke",{value:M(e,t,c)}),a}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=f;var d="suspendedStart",h="suspendedYield",y="executing",v="completed",m={};function g(){}function x(){}function b(){}var w={};l(w,c,(function(){return this}));var k=Object.getPrototypeOf,S=k&&k(k(L([])));S&&S!==t&&n.call(S,c)&&(w=S);var T=b.prototype=g.prototype=Object.create(w);function E(e){["next","throw","return"].forEach((function(r){l(e,r,(function(e){return this._invoke(r,e)}))}))}function V(e,r){function t(i,o,a,c){var s=p(e[i],e,o);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,a,c)}),(function(e){t("throw",e,a,c)})):r.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return t("throw",e,a,c)}))}c(s.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new r((function(r,i){t(e,n,r,i)}))}return o=o?o.then(i,i):i()}})}function M(r,t,n){var i=d;return function(o,a){if(i===y)throw Error("Generator is already running");if(i===v){if("throw"===o)throw a;return{value:e,done:!0}}for(n.method=o,n.arg=a;;){var c=n.delegate;if(c){var s=C(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===d)throw i=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var u=p(r,t,n);if("normal"===u.type){if(i=n.done?v:h,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=v,n.method="throw",n.arg=u.arg)}}}function C(r,t){var n=t.method,i=r.iterator[n];if(i===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,C(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var o=p(i,r.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,m;var a=o.arg;return a?a.done?(t[r.resultName]=a.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,m):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function _(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function O(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function L(r){if(r||""===r){var t=r[c];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var i=-1,o=function t(){for(;++i<r.length;)if(n.call(r,i))return t.value=r[i],t.done=!1,t;return t.value=e,t.done=!0,t};return o.next=o}}throw new TypeError(typeof r+" is not iterable")}return x.prototype=b,i(T,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:x,configurable:!0}),x.displayName=l(b,u,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===x||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,l(e,u,"GeneratorFunction")),e.prototype=Object.create(T),e},r.awrap=function(e){return{__await:e}},E(V.prototype),l(V.prototype,s,(function(){return this})),r.AsyncIterator=V,r.async=function(e,t,n,i,o){void 0===o&&(o=Promise);var a=new V(f(e,t,n,i),o);return r.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},E(T),l(T,u,"Generator"),l(T,c,(function(){return this})),l(T,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=L,A.prototype={constructor:A,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function i(n,i){return c.type="throw",c.arg=r,t.next=n,i&&(t.method="next",t.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),O(t),m}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var i=n.arg;O(t)}return i}}throw Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:L(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),m}},r}function a(r){return function(r){if(Array.isArray(r))return e(r)}(r)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||u(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){var r=function(e,r){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof r?r:r+""}function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function u(r,t){if(r){if("string"==typeof r)return e(r,t);var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(r,t):void 0}}var l=Object.defineProperty,f=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,h=function(e,r,t){return r in e?l(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t},y=function(e,r){for(var t in r||(r={}))p.call(r,t)&&h(e,t,r[t]);if(f){var n,o=i(f(r));try{for(o.s();!(n=o.n()).done;){t=n.value;d.call(r,t)&&h(e,t,r[t])}}catch(e){o.e(e)}finally{o.f()}}return e},v=function(e,r,t){return h(e,"symbol"!==s(r)?r+"":r,t)},m={x:{required:!0,type:"number"},y:{required:!0,type:"number"},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},zIndex:{required:!0,type:"number"},fillMode:{required:!1,type:"string"},mirror:{required:!1,type:"boolean"},rotation:{required:!1,type:"number"},hidden:{required:!1,type:"boolean"}},g=function(e){return{type:"object",required:arguments.length>1&&void 0!==arguments[1]&&arguments[1],properties:{canvasColor:{required:!1,type:["string",CanvasGradient,CanvasPattern]},width:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},height:{required:!0,type:"number",notLessThanZero:!0,min:1,max:3840},frameRate:{required:!1,type:"number",notLessThanZero:!0,min:1,max:60}},validate:function(r,t,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode;if(i.ErrorCodeDictionary,r){var c=r.width,s=r.height;if(c&&s&&c*s>8294400)throw new o({code:a.INVALID_PARAMETER,message:"The mix resolution cannot be set higher than 3840 * 2160."})}}}},x=function(e){return{required:!1,type:["string",HTMLElement,null],validate:function(r,t,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode,c=i.ErrorCodeDictionary;if(e.utils.isString(r)&&!document.getElementById(r))throw new o({code:a.INVALID_PARAMETER,extraCode:c.INVALID_ELEMENT_ID,fnName:n,messageParams:{key:t}})}}},b=function(e){return{type:"object",required:!(arguments.length>1&&void 0!==arguments[1])||arguments[1],properties:y({},m),validate:function(r,t,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode,c=i.ErrorCodeDictionary;if(r){if(r.fillMode&&!["contain","cover","fill"].includes(r.fillMode))throw new o({code:a.INVALID_PARAMETER,extraCode:c.INVALID_PARAMETER_TYPE,message:"The fillMode parameter must be 'contain', 'cover' or 'fill'",fnName:n});if(r.rotation&&![0,90,180,270].includes(r.rotation))throw new o({code:a.INVALID_PARAMETER,extraCode:c.INVALID_PARAMETER_TYPE,message:"The rotation parameter must be 0, 90, 180 or 270",fnName:n})}}}},w=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},cameraId:{required:!1,type:"string"},videoTrack:{required:!1,instanceof:MediaStreamTrack},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},layout:y({},b(e))}}}},k=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},captureElement:{required:!1,type:HTMLElement},preferDisplaySurface:{required:!1,type:"string"},layout:y({},b(e))},validate:function(r,t,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode,c=i.ErrorCodeDictionary;if(!e.rtcDectection.isScreenCaptureApiAvailable())throw new o({code:a.ENV_NOT_SUPPORTED,fnName:n,extraCode:c.NOT_SUPPORTED_SCREEN_SHARE})}}}},S=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},content:{required:!0,type:"string"},font:{required:!1,type:"string"},color:{required:!1,type:["string",CanvasGradient,CanvasPattern]},layout:y({},b(e))}}}},T=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:y({},b(e))}}}},E=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:y({},b(e))}}}};var V=0,M=function(){function e(r){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.core=r,v(this,"seq"),v(this,"log"),v(this,"localMixVideoTrack",null),v(this,"systemAudioTrack"),v(this,"_mixVideoConfig"),v(this,"onScreenShareStop"),V+=1,this.seq=V,this.log=r.log.createChild({id:"".concat(this.getAlias()).concat(V)}),this.log.info("created")}return n(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"vmix"}},{key:"getValidateRule",value:function(e){switch(e){case"start":return r=this.core,{name:"VideoMixerOptions",type:"object",required:!0,allowEmpty:!1,properties:{view:y({},x(r)),canvasInfo:y({},g(r,!0)),camera:y({},w(r)),screen:y({},k(r)),text:y({},S(r)),image:y({},T(r)),video:y({},E(r))},validate:function(e,t,n,i){var o=r.errorModule,a=o.RtcError,c=o.ErrorCode,u=o.ErrorCodeDictionary;if(r.environment.isMobile())throw new a({code:c.ENV_NOT_SUPPORTED,message:"VideoMixer is not supported on mobile devices currently"});var l=e.onScreenShareStop;if(l&&!r.utils.isFunction(l))throw new a({code:c.INVALID_PARAMETER,extraCode:u.INVALID_PARAMETER_TYPE,fnName:n,messageParams:{key:"onScreenShareStop",value:s(l),rule:{type:"Function"}}})}};case"update":return function(e){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{view:y({},x(e)),canvasInfo:y({},g(e)),camera:y({},w(e)),screen:y({},k(e)),text:y({},S(e)),image:y({},T(e)),video:y({},E(e))}}}(this.core);case"stop":return this.core,{name:"StopVideoMixerOptions",required:!1}}var r}},{key:"getGroup",value:function(){return"vmix"}},{key:"start",value:(C=t(o().mark((function e(r){var t,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.localMixVideoTrack||(this.localMixVideoTrack=new this.core.LocalMixVideoTrack(this.core.room.videoManager)),this._mixVideoConfig={canvasInfo:{width:1920,height:1080}},r=this.core.utils.deepCloneBasic(r),n=(t=r).view,i=t.onScreenShareStop,e.next=6,this.parseMixOptions(r);case 6:return a=e.sent,i&&(this.onScreenShareStop=i,this._mixVideoConfig.onScreenShareStop=i),this._updatePreview({view:n,track:this.localMixVideoTrack}),this.core.utils.isUndefined(n)||(this._mixVideoConfig.view=n),e.next=12,this.localMixVideoTrack.startMix();case 12:return e.abrupt("return",{track:this.localMixVideoTrack._outputTrack,systemAudioTrack:this.systemAudioTrack,result:a});case 13:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"update",value:(M=t(o().mark((function e(r){var t,n,i,a,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.core.errorModule,n=t.RtcError,i=t.ErrorCode,this.localMixVideoTrack){e.next=3;break}throw new n({code:i.INVALID_OPERATION,message:"mixTrack doesn't initialize!"});case 3:return r=this.core.utils.deepCloneBasic(r),a=r.view,e.next=7,this.parseMixOptions(r);case 7:return c=e.sent,e.next=10,this._updatePreview({view:a,track:this.localMixVideoTrack,prevConfig:this._mixVideoConfig});case 10:return this.core.utils.isUndefined(a)||(this._mixVideoConfig.view=a),e.abrupt("return",{track:this.localMixVideoTrack._outputTrack,systemAudioTrack:this.systemAudioTrack,result:c});case 12:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"parseMixOptions",value:(b=t(o().mark((function e(r){var t,n,i,c,s,u,l,f,p,d,h,v,m,g,x,b,w,k,S,T,E,V,M,C,_,O,A,L,P,I,q,N,j;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={successOptions:{},failedDetails:[]},n=this.core.errorModule,i=n.RtcError,c=n.ErrorCode,n.ErrorCodeDictionary,this.localMixVideoTrack&&this._mixVideoConfig){e.next=4;break}return e.abrupt("return",t);case 4:if(s=[],u=y({},r),l=r.canvasInfo,f=r.camera,p=r.screen,d=r.text,h=r.image,v=r.video,m=0,g=0,l&&(x=l.canvasColor,b=l.width,w=l.height,k=l.frameRate,x&&this.localMixVideoTrack.setMixBackground(x),k&&this.localMixVideoTrack.setFps(k),this.localMixVideoTrack.resizeMixCanvas(b,w),this._mixVideoConfig.canvasInfo=l),!f){e.next=20;break}return m++,e.next=14,this.parseCameraOptions(this.localMixVideoTrack,f,this._mixVideoConfig.camera);case 14:S=e.sent,T=S.finalOptions,E=S.errors,this._mixVideoConfig.camera=T,u.camera=T,E.length>0&&(s.push.apply(s,a(E)),E.length===f.length&&g++);case 20:if(!p){e.next=30;break}return m++,e.next=24,this.parseScreenOptions(this.localMixVideoTrack,p,this._mixVideoConfig.screen);case 24:V=e.sent,M=V.finalOptions,C=V.errors,this._mixVideoConfig.screen=M,u.screen=M,C.length>0&&(s.push.apply(s,a(C)),C.length===p.length&&g++);case 30:if(!d){e.next=40;break}return m++,e.next=34,this.parseTextOptions(this.localMixVideoTrack,d,this._mixVideoConfig.text);case 34:_=e.sent,O=_.finalOptions,A=_.errors,this._mixVideoConfig.text=O,u.text=O,A.length>0&&(s.push.apply(s,a(A)),A.length===d.length&&g++);case 40:if(!h){e.next=50;break}return m++,e.next=44,this.parseImageOptions(this.localMixVideoTrack,h,this._mixVideoConfig.image);case 44:L=e.sent,P=L.finalOptions,I=L.errors,this._mixVideoConfig.image=P,u.image=P,I.length>0&&(s.push.apply(s,a(I)),I.length===h.length&&g++);case 50:if(!v){e.next=60;break}return m++,e.next=54,this.parseVideoOptions(this.localMixVideoTrack,v,this._mixVideoConfig.video);case 54:q=e.sent,N=q.finalOptions,j=q.errors,this._mixVideoConfig.video=N,u.video=N,j.length>0&&(s.push.apply(s,a(j)),j.length===v.length&&g++);case 60:if(!(g>0&&g===m)){e.next=62;break}throw new i({code:c.INVALID_PARAMETER,message:"all sources mix failed",data:{failedDetails:s}});case 62:return t={successOptions:u,failedDetails:s},e.abrupt("return",t);case 64:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"parseCameraOptions",value:(m=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,y,v,m,g,x,b,w,k,S,T,E,V=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=V.length>2&&void 0!==V[2]?V[2]:[],s=new Set(t.map((function(e){return e.id}))),u=n.filter((function(e){return!s.has(e.id)})).map((function(e){return e.id})),l=i(u);try{for(l.s();!(f=l.n()).done;)p=f.value,r.removeCameraSource(p)}catch(e){l.e(e)}finally{l.f()}d=new Map(n.map((function(e){return[e.id,e]}))),h=[],y=[],v=i(t),e.prev=9,v.s();case 11:if((m=v.n()).done){e.next=45;break}if(g=m.value,x=g.id,b=g.layout,w=g.profile,e.prev=14,!r.inputLocalVideoTracks.has(x)){e.next=25;break}return k=null==(a=r.inputLocalVideoTracks.get(x))?void 0:a.mediaTrack,e.next=19,this.updateCameraProfile(g);case 19:S=null==(c=r.inputLocalVideoTracks.get(x))?void 0:c.mediaTrack,T=void 0,w&&(T=this.core.utils.isString(w)?this.core.constants.videoProfileMap[w]:w),S!==k?r.updateCameraSource(x,b,S,T):r.updateCameraSource(x,b,null,T),e.next=36;break;case 25:return e.next=27,this.captureCamera(g);case 27:E=e.sent,e.prev=28,r.addCameraSource(x,E,b),e.next=36;break;case 32:throw e.prev=32,e.t0=e.catch(28),E.close(),e.t0;case 36:h.push(g),e.next=43;break;case 39:e.prev=39,e.t1=e.catch(14),y.push({id:x,error:e.t1}),d.has(x)&&h.push(d.get(x));case 43:e.next=11;break;case 45:e.next=50;break;case 47:e.prev=47,e.t2=e.catch(9),v.e(e.t2);case 50:return e.prev=50,v.f(),e.finish(50);case 53:return e.abrupt("return",{finalOptions:h,errors:y});case 54:case"end":return e.stop()}}),e,this,[[9,47,50,53],[14,39],[28,32]])}))),function(e,r){return m.apply(this,arguments)})},{key:"parseScreenOptions",value:(h=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,y,v,m,g,x,b=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=b.length>2&&void 0!==b[2]?b[2]:[],a=new Set(t.map((function(e){return e.id}))),c=n.filter((function(e){return!a.has(e.id)})).map((function(e){return e.id})),s=i(c);try{for(s.s();!(u=s.n()).done;)l=u.value,r.removeScreenSource(l)}catch(e){s.e(e)}finally{s.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=[],h=i(t),e.prev=9,h.s();case 11:if((y=h.n()).done){e.next=39;break}if(v=y.value,m=v.id,g=v.layout,e.prev=14,!r.inputLocalScreenTracks.has(m)){e.next=19;break}r.updateScreenSource(m,g),e.next=30;break;case 19:return e.next=21,this.captureScreen(v);case 21:x=e.sent,e.prev=22,r.addScreenSource(m,x,g),e.next=30;break;case 26:throw e.prev=26,e.t0=e.catch(22),x.close(),e.t0;case 30:p.push(v),e.next=37;break;case 33:e.prev=33,e.t1=e.catch(14),d.push({id:m,error:e.t1}),f.has(m)&&p.push(f.get(m));case 37:e.next=11;break;case 39:e.next=44;break;case 41:e.prev=41,e.t2=e.catch(9),h.e(e.t2);case 44:return e.prev=44,h.f(),e.finish(44);case 47:return e.abrupt("return",{finalOptions:p,errors:d});case 48:case"end":return e.stop()}}),e,this,[[9,41,44,47],[14,33],[22,26]])}))),function(e,r){return h.apply(this,arguments)})},{key:"parseTextOptions",value:(d=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,y,v,m=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=m.length>2&&void 0!==m[2]?m[2]:[],a=new Set(t.map((function(e){return e.id}))),c=n.filter((function(e){return!a.has(e.id)})).map((function(e){return e.id})),s=i(c);try{for(s.s();!(u=s.n()).done;)l=u.value,r.removeTextSource(l)}catch(e){s.e(e)}finally{s.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=[],h=i(t),e.prev=9,v=o().mark((function e(){var t,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=y.value,i=t.id;try{n.some((function(e){return e.id===i}))?r.updateTextSource(t):r.addTextSource(t),p.push(t)}catch(e){d.push({id:i,error:e}),f.has(i)&&p.push(f.get(i))}case 3:case"end":return e.stop()}}),e)})),h.s();case 12:if((y=h.n()).done){e.next=16;break}return e.delegateYield(v(),"t0",14);case 14:e.next=12;break;case 16:e.next=21;break;case 18:e.prev=18,e.t1=e.catch(9),h.e(e.t1);case 21:return e.prev=21,h.f(),e.finish(21);case 24:return e.abrupt("return",{finalOptions:p,errors:d});case 25:case"end":return e.stop()}}),e,null,[[9,18,21,24]])}))),function(e,r){return d.apply(this,arguments)})},{key:"parseImageOptions",value:(p=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,y,v,m=this,g=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=g.length>2&&void 0!==g[2]?g[2]:[],a=new Set(t.map((function(e){return e.id}))),c=n.filter((function(e){return!a.has(e.id)})).map((function(e){return e.id})),s=i(c);try{for(s.s();!(u=s.n()).done;)l=u.value,r.removeImageSource(l)}catch(e){s.e(e)}finally{s.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=[],h=i(t),e.prev=9,v=o().mark((function e(){var t,i,a,c,s,u,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=y.value,i=t.id,a=t.url,c=t.layout,e.prev=2,!(s=n.find((function(e){return e.id===i})))){e.next=12;break}if(s.url===a){e.next=9;break}return e.next=8,m.core.utils.loadImage(a);case 8:u=e.sent;case 9:r.updateImageSource(i,c,u),e.next=16;break;case 12:return e.next=14,m.core.utils.loadImage(a);case 14:l=e.sent,r.addImageSource(i,l,c);case 16:p.push(t),e.next=23;break;case 19:e.prev=19,e.t0=e.catch(2),d.push({id:i,error:e.t0}),f.has(i)&&p.push(f.get(i));case 23:case"end":return e.stop()}}),e,null,[[2,19]])})),h.s();case 12:if((y=h.n()).done){e.next=16;break}return e.delegateYield(v(),"t0",14);case 14:e.next=12;break;case 16:e.next=21;break;case 18:e.prev=18,e.t1=e.catch(9),h.e(e.t1);case 21:return e.prev=21,h.f(),e.finish(21);case 24:return e.abrupt("return",{finalOptions:p,errors:d});case 25:case"end":return e.stop()}}),e,null,[[9,18,21,24]])}))),function(e,r){return p.apply(this,arguments)})},{key:"parseVideoOptions",value:(f=t(o().mark((function e(r,t){var n,a,c,s,u,l,f,p,d,h,y,v,m=this,g=arguments;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=g.length>2&&void 0!==g[2]?g[2]:[],a=new Set(t.map((function(e){return e.id}))),c=n.filter((function(e){return!a.has(e.id)})).map((function(e){return e.id})),s=i(c);try{for(s.s();!(u=s.n()).done;)l=u.value,r.removeVideoSource(l)}catch(e){s.e(e)}finally{s.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=[],h=i(t),e.prev=9,v=o().mark((function e(){var t,i,a,c,s,u,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=y.value,i=t.id,a=t.url,c=t.layout,e.prev=2,!(s=n.find((function(e){return e.id===i})))){e.next=12;break}if(s.url===a){e.next=9;break}return e.next=8,m.core.utils.loadVideo(a);case 8:u=e.sent;case 9:r.updateVideoSource(i,c,u),e.next=16;break;case 12:return e.next=14,m.core.utils.loadVideo(a);case 14:l=e.sent,r.addVideoSource(i,l,c);case 16:p.push(t),e.next=23;break;case 19:e.prev=19,e.t0=e.catch(2),d.push({id:i,error:e.t0}),f.has(i)&&p.push(f.get(i));case 23:case"end":return e.stop()}}),e,null,[[2,19]])})),h.s();case 12:if((y=h.n()).done){e.next=16;break}return e.delegateYield(v(),"t0",14);case 14:e.next=12;break;case 16:e.next=21;break;case 18:e.prev=18,e.t1=e.catch(9),h.e(e.t1);case 21:return e.prev=21,h.f(),e.finish(21);case 24:return e.abrupt("return",{finalOptions:p,errors:d});case 25:case"end":return e.stop()}}),e,null,[[9,18,21,24]])}))),function(e,r){return f.apply(this,arguments)})},{key:"captureCamera",value:(l=t(o().mark((function e(r){var t,n,i,a,c,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.id,n=r.cameraId,i=r.videoTrack,a=r.profile,(c=new this.core.LocalVideoTrack).log.id+="-".concat(t),s={},n?s.deviceId=n:this.core.utils.isUndefined(i)||(s.customSource=i),this.core.utils.isUndefined(a)||(this.core.utils.isString(a)?this.core.constants.videoProfileMap[a]&&c.setProfile(this.core.constants.videoProfileMap[a]):c.setProfile(a)),e.next=8,c.capture(s);case 8:return e.abrupt("return",c);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateCameraProfile",value:(u=t(o().mark((function e(r){var t,n,i,a,c,s;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.id,i=r.cameraId,a=r.videoTrack,c=r.profile,s=null==(t=this.localMixVideoTrack)?void 0:t.inputLocalVideoTracks.get(n)){e.next=4;break}return e.abrupt("return");case 4:if(!i){e.next=9;break}return e.next=7,s.switchDevice(i);case 7:e.next=12;break;case 9:if(this.core.utils.isUndefined(a)){e.next=12;break}return e.next=12,s.setInputMediaStreamTrack(a);case 12:if(this.core.utils.isUndefined(c)){e.next=17;break}if(this.core.utils.isString(c)?this.core.constants.videoProfileMap[c]&&s.setProfile(this.core.constants.videoProfileMap[c]):s.setProfile(c),i&&s.isNeedToSwitchDevice(i)){e.next=17;break}return e.next=17,s.applyProfile();case 17:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"captureScreen",value:(c=t(o().mark((function e(r){var t,n,i,a,c,s,u,l=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.id,n=r.profile,i=r.captureElement,a=r.preferDisplaySurface,(c=new this.core.LocalScreenTrack).log.id+="-".concat(t),s={},this.core.utils.isUndefined(n)||(this.core.utils.isString(n)?this.core.constants.screenProfileMap[n]&&c.setProfile(this.core.constants.screenProfileMap[n]):c.setProfile(n)),i&&(s.captureElement=i),a&&(s.preferDisplaySurface=a),s.systemAudio=r.systemAudio,e.next=10,c.capture(s);case 10:return u=e.sent,s.systemAudio&&u.getAudioTracks().length>0&&(this.systemAudioTrack=u.getAudioTracks()[0]),c.mediaTrack.addEventListener(this.core.constants.NAME.ENDED,(function(){var e,r,n;null==(e=l.localMixVideoTrack)||e.removeScreenSource(t),(null==(r=l._mixVideoConfig)?void 0:r.screen)&&(l._mixVideoConfig.screen=l._mixVideoConfig.screen.filter((function(e){return e.id!==t}))),null==(n=l.onScreenShareStop)||n.call(l,t)})),e.abrupt("return",c);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"_updatePreview",value:(r=t(o().mark((function e(r){var t,n,i,a,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.view,n=r.track,i=r.prevConfig,!(this.core.utils.isUndefined(t)&&i&&i.view)){e.next=6;break}if(!((a=this.core.utils.getViewListFromView(i.view)).length>0)){e.next=6;break}return e.next=6,n.play(a);case 6:if(this.core.utils.isUndefined(t)){e.next=14;break}if(!((c=this.core.utils.getViewListFromView(t)).length>0)){e.next=13;break}return e.next=11,n.play(c);case 11:e.next=14;break;case 13:n.stop();case 14:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e;null==(e=this.localMixVideoTrack)||e.close(),this.localMixVideoTrack=null,delete this.onScreenShareStop,delete this._mixVideoConfig}}]);var r,c,u,l,f,p,d,h,m,b,M,C}();return v(M,"Name","VideoMixer"),M}));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/virtual-background",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x virtual background plugin",
5
5
  "main": "./virtual-background.esm.js",
6
6
  "module": "./virtual-background.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/watermark",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "TRTC Web SDK 5.x watermark plugin",
5
5
  "main": "./watermark.esm.js",
6
6
  "module": "./watermark.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/voice-changer",
3
- "version": "5.15.0-beta.3",
3
+ "version": "5.15.0-beta.4",
4
4
  "description": "",
5
5
  "main": "./voice-changer.esm.js",
6
6
  "keywords": [],