trtc-sdk-v5 5.13.0-beta.17 → 5.13.0-beta.18
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/assets/debug-dialog.js +2 -2
- package/index.d.ts +2 -88
- package/package.json +1 -1
- package/plugins/cdn-streaming/cdn-streaming.esm.js +1 -1
- package/plugins/cdn-streaming/cdn-streaming.umd.js +1 -3
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/cross-room/cross-room.esm.js +1 -1
- package/plugins/cross-room/cross-room.umd.js +1 -3
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/custom-encryption.esm.js +1 -1
- package/plugins/custom-encryption/custom-encryption.umd.js +1 -1
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/device-detector.esm.js +27 -15
- package/plugins/device-detector/device-detector.umd.js +14 -4
- package/plugins/device-detector/package.json +1 -1
- package/plugins/small-stream-auto-switcher/package.json +1 -1
- package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.esm.js +1 -1
- package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.umd.js +1 -1
- package/plugins/video-decoder/package.json +1 -1
- package/plugins/video-decoder/video-decoder.esm.js +1 -1
- package/plugins/video-decoder/video-decoder.umd.js +1 -3
- package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.umd.js +1 -3
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/beauty.esm.js +1 -1
- package/plugins/video-effect/beauty/beauty.umd.js +1 -3
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/video-mixer/package.json +1 -1
- package/plugins/video-effect/video-mixer/video-mixer.esm.js +1 -1
- package/plugins/video-effect/video-mixer/video-mixer.umd.js +1 -3
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.esm.js +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.umd.js +1 -3
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/video-effect/watermark/watermark.umd.js +1 -3
- package/plugins/voice-changer/package.json +1 -1
- package/plugins/voice-changer/voice-changer.esm.js +1 -1
- package/plugins/voice-changer/voice-changer.umd.js +1 -3
- package/trtc.esm.js +30 -30
- package/trtc.js +1 -1
- package/plugins/chorus/chorus.esm.d.ts +0 -13
- package/plugins/chorus/chorus.esm.js +0 -1
- package/plugins/chorus/chorus.umd.js +0 -3
- package/plugins/chorus/package.json +0 -29
|
@@ -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: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,3 +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),u=c.value}catch(e){return void t(e)}c.done?r(u):Promise.resolve(u).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,u,"next",e)}function u(e){r(a,i,o,c,u,"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,s(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=f(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(){
|
|
2
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var e,r,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",i=t.toStringTag||"@@toStringTag";function c(t,n,i,o){var c=n&&n.prototype instanceof s?n:s,l=Object.create(c.prototype);return a(l,"_invoke",function(t,n,i){var o,a,c,s=0,l=i||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(r,t){return o=r,a=0,c=e,p.n=t,u}};function d(t,n){for(a=t,c=n,r=0;!f&&s&&!i&&r<l.length;r++){var i,o=l[r],d=p.p,h=o[2];t>3?(i=h===n)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=d&&((i=t<2&&d<o[1])?(a=0,p.v=n,p.n=o[1]):d<h&&(i=t<3||o[0]>n||n>h)&&(o[4]=t,o[5]=n,p.n=h,a=0))}if(i||t>1)return u;throw f=!0,n}return function(i,l,h){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,h),a=l,c=h;(r=a<2?e:c)||!f;){o||(a?a<3?(a>1&&(p.n=-1),d(a,c)):p.n=c:p.v=c);try{if(s=2,o){if(a||(i="next"),r=o[i]){if(!(r=r.call(o,c)))throw TypeError("iterator result is not an object");if(!r.done)return r;c=r.value,a<2&&(a=0)}else 1===a&&(r=o.return)&&r.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+i+"' method"),a=1);o=e}else if((r=(f=p.n<0)?c:t.call(n,p))!==u)break}catch(r){o=e,a=1,c=r}finally{s=1}}return{value:r,done:f}}}(t,i,o),!0),l}var u={};function s(){}function l(){}function f(){}r=Object.getPrototypeOf;var p=[][n]?r(r([][n]())):(a(r={},n,function(){return this}),r),d=f.prototype=s.prototype=Object.create(p);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,a(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=f,a(d,"constructor",f),a(f,"constructor",l),l.displayName="GeneratorFunction",a(f,i,"GeneratorFunction"),a(d),a(d,i,"Generator"),a(d,n,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(o=function(){return{w:c,m:h}})()}function a(e,r,t,n){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}a=function(e,r,t,n){function o(r,t){a(e,r,function(e){return this._invoke(r,t,e)})}r?i?i(e,r,{value:t,enumerable:!n,configurable:!n,writable:!n}):e[r]=t:(o("next",0),o("throw",1),o("return",2))},a(e,r,t,n)}function c(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}throw new TypeError(typeof e+" is not iterable")}function u(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)||f(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 s(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 l(e){return l="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},l(e)}function f(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 p=Object.defineProperty,d=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable,y=function(e,r,t){return r in e?p(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t},v=function(e,r){for(var t in r||(r={}))h.call(r,t)&&y(e,t,r[t]);if(d){var n,o=i(d(r));try{for(o.s();!(n=o.n()).done;){t=n.value;m.call(r,t)&&y(e,t,r[t])}}catch(e){o.e(e)}finally{o.f()}}return e},b=function(e,r,t){return y(e,"symbol"!==l(r)?r+"":r,t)},g={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"}},k=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,u=r.height;if(c&&u&&c*u>8294400)throw new o({code:a.INVALID_PARAMETER,message:"The mix resolution cannot be set higher than 3840 * 2160."})}}}},w=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}})}}},S=function(e){return{type:"object",required:!(arguments.length>1&&void 0!==arguments[1])||arguments[1],properties:v({},g),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})}}}},x=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({},S(e))}}}},T=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({},S(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})}}}},V=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({},S(e))}}}},M=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:v({},S(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({},S(e))}}}};var C=0,O=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,b(this,"seq"),b(this,"log"),b(this,"localMixVideoTrack",null),b(this,"_mixVideoConfig"),b(this,"onScreenShareStop"),C+=1,this.seq=C,this.log=r.log.createChild({id:"".concat(this.getAlias()).concat(C)}),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({},w(r)),canvasInfo:v({},k(r,!0)),camera:v({},x(r)),screen:v({},T(r)),text:v({},V(r)),image:v({},M(r)),video:v({},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 s=e.onScreenShareStop;if(s&&!r.utils.isFunction(s))throw new a({code:c.INVALID_PARAMETER,extraCode:u.INVALID_PARAMETER_TYPE,fnName:n,messageParams:{key:"onScreenShareStop",value:l(s),rule:{type:"Function"}}})}};case"update":return function(e){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{view:v({},w(e)),canvasInfo:v({},k(e)),camera:v({},x(e)),screen:v({},T(e)),text:v({},V(e)),image:v({},M(e)),video:v({},E(e))}}}(this.core);case"stop":return this.core,{name:"StopVideoMixerOptions",required:!1}}var r}},{key:"getGroup",value:function(){return"vmix"}},{key:"start",value:(O=t(o().m(function e(r){var t,n,i,a;return o().w(function(e){for(;;)switch(e.n){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.n=1,this.parseMixOptions(r);case 1:return a=e.v,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.n=2,this.localMixVideoTrack.startMix();case 2:return e.a(2,{track:this.localMixVideoTrack._outputTrack,result:a})}},e,this)})),function(e){return O.apply(this,arguments)})},{key:"update",value:(S=t(o().m(function e(r){var t,n,i,a,c;return o().w(function(e){for(;;)switch(e.n){case 0:if(t=this.core.errorModule,n=t.RtcError,i=t.ErrorCode,this.localMixVideoTrack){e.n=1;break}throw new n({code:i.INVALID_OPERATION,message:"mixTrack doesn't initialize!"});case 1:return r=this.core.utils.deepCloneBasic(r),a=r.view,e.n=2,this.parseMixOptions(r);case 2:return c=e.v,e.n=3,this._updatePreview({view:a,track:this.localMixVideoTrack,prevConfig:this._mixVideoConfig});case 3:return this.core.utils.isUndefined(a)||(this._mixVideoConfig.view=a),e.a(2,{track:this.localMixVideoTrack._outputTrack,result:c})}},e,this)})),function(e){return S.apply(this,arguments)})},{key:"parseMixOptions",value:(g=t(o().m(function e(r){var t,n,i,a,c,s,l,f,p,d,h,m,y,b,g,k,w,S,x,T,V,M,E,C,O,P,_,I,A,q,R,N,j;return o().w(function(e){for(;;)switch(e.n){case 0:if(t={successOptions:{},failedDetails:[]},n=this.core.errorModule,i=n.RtcError,a=n.ErrorCode,n.ErrorCodeDictionary,this.localMixVideoTrack&&this._mixVideoConfig){e.n=1;break}return e.a(2,t);case 1:if(c=[],s=v({},r),l=r.canvasInfo,f=r.camera,p=r.screen,d=r.text,h=r.image,m=r.video,y=0,b=0,l&&(g=l.canvasColor,k=l.width,w=l.height,S=l.frameRate,g&&this.localMixVideoTrack.setMixBackground(g),S&&this.localMixVideoTrack.setFps(S),this.localMixVideoTrack.resizeMixCanvas(k,w),this._mixVideoConfig.canvasInfo=l),!f){e.n=3;break}return y++,e.n=2,this.parseCameraOptions(this.localMixVideoTrack,f,this._mixVideoConfig.camera);case 2:x=e.v,T=x.finalOptions,V=x.errors,this._mixVideoConfig.camera=T,s.camera=T,V.length>0&&(c.push.apply(c,u(V)),V.length===f.length&&b++);case 3:if(!p){e.n=5;break}return y++,e.n=4,this.parseScreenOptions(this.localMixVideoTrack,p,this._mixVideoConfig.screen);case 4:M=e.v,E=M.finalOptions,C=M.errors,this._mixVideoConfig.screen=E,s.screen=E,C.length>0&&(c.push.apply(c,u(C)),C.length===p.length&&b++);case 5:if(!d){e.n=7;break}return y++,e.n=6,this.parseTextOptions(this.localMixVideoTrack,d,this._mixVideoConfig.text);case 6:O=e.v,P=O.finalOptions,_=O.errors,this._mixVideoConfig.text=P,s.text=P,_.length>0&&(c.push.apply(c,u(_)),_.length===d.length&&b++);case 7:if(!h){e.n=9;break}return y++,e.n=8,this.parseImageOptions(this.localMixVideoTrack,h,this._mixVideoConfig.image);case 8:I=e.v,A=I.finalOptions,q=I.errors,this._mixVideoConfig.image=A,s.image=A,q.length>0&&(c.push.apply(c,u(q)),q.length===h.length&&b++);case 9:if(!m){e.n=11;break}return y++,e.n=10,this.parseVideoOptions(this.localMixVideoTrack,m,this._mixVideoConfig.video);case 10:R=e.v,N=R.finalOptions,j=R.errors,this._mixVideoConfig.video=N,s.video=N,j.length>0&&(c.push.apply(c,u(j)),j.length===m.length&&b++);case 11:if(!(b>0&&b===y)){e.n=12;break}throw new i({code:a.INVALID_PARAMETER,message:"all sources mix failed",data:{failedDetails:c}});case 12:return t={successOptions:s,failedDetails:c},e.a(2,t)}},e,this)})),function(e){return g.apply(this,arguments)})},{key:"parseCameraOptions",value:(y=t(o().m(function e(r,t){var n,a,c,u,s,l,f,p,d,h,m,y,v,b,g,k,w,S,x,T,V,M,E,C,O=arguments;return o().w(function(e){for(;;)switch(e.p=e.n){case 0:n=O.length>2&&void 0!==O[2]?O[2]:[],u=new Set(t.map(function(e){return e.id})),s=n.filter(function(e){return!u.has(e.id)}).map(function(e){return e.id}),l=i(s);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=[],m=[],y=i(t),e.p=1,y.s();case 2:if((v=y.n()).done){e.n=12;break}if(b=v.value,g=b.id,k=b.layout,w=b.profile,e.p=3,!r.inputLocalVideoTracks.has(g)){e.n=5;break}return S=null==(a=r.inputLocalVideoTracks.get(g))?void 0:a.mediaTrack,e.n=4,this.updateCameraProfile(b);case 4:x=null==(c=r.inputLocalVideoTracks.get(g))?void 0:c.mediaTrack,T=void 0,w&&(T=this.core.utils.isString(w)?this.core.constants.videoProfileMap[w]:w),x!==S?r.updateCameraSource(g,k,x,T):r.updateCameraSource(g,k,null,T),e.n=9;break;case 5:return e.n=6,this.captureCamera(b);case 6:V=e.v,e.p=7,r.addCameraSource(g,V,k),e.n=9;break;case 8:throw e.p=8,M=e.v,V.close(),M;case 9:h.push(b),e.n=11;break;case 10:e.p=10,E=e.v,m.push({id:g,error:E}),d.has(g)&&h.push(d.get(g));case 11:e.n=2;break;case 12:e.n=14;break;case 13:e.p=13,C=e.v,y.e(C);case 14:return e.p=14,y.f(),e.f(14);case 15:return e.a(2,{finalOptions:h,errors:m})}},e,this,[[7,8],[3,10],[1,13,14,15]])})),function(e,r){return y.apply(this,arguments)})},{key:"parseScreenOptions",value:(m=t(o().m(function e(r,t){var n,a,c,u,s,l,f,p,d,h,m,y,v,b,g,k,w,S,x=arguments;return o().w(function(e){for(;;)switch(e.p=e.n){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}),u=i(c);try{for(u.s();!(s=u.n()).done;)l=s.value,r.removeScreenSource(l)}catch(e){u.e(e)}finally{u.f()}f=new Map(n.map(function(e){return[e.id,e]})),p=[],d=[],h=i(t),e.p=1,h.s();case 2:if((m=h.n()).done){e.n=11;break}if(y=m.value,v=y.id,b=y.layout,e.p=3,!r.inputLocalScreenTracks.has(v)){e.n=4;break}r.updateScreenSource(v,b),e.n=8;break;case 4:return e.n=5,this.captureScreen(y);case 5:g=e.v,e.p=6,r.addScreenSource(v,g,b),e.n=8;break;case 7:throw e.p=7,k=e.v,g.close(),k;case 8:p.push(y),e.n=10;break;case 9:e.p=9,w=e.v,d.push({id:v,error:w}),f.has(v)&&p.push(f.get(v));case 10:e.n=2;break;case 11:e.n=13;break;case 12:e.p=12,S=e.v,h.e(S);case 13:return e.p=13,h.f(),e.f(13);case 14:return e.a(2,{finalOptions:p,errors:d})}},e,this,[[6,7],[3,9],[1,12,13,14]])})),function(e,r){return m.apply(this,arguments)})},{key:"parseTextOptions",value:(h=t(o().m(function e(r,t){var n,a,u,s,l,f,p,d,h,m,y,v,b,g=arguments;return o().w(function(e){for(;;)switch(e.p=e.n){case 0:n=g.length>2&&void 0!==g[2]?g[2]:[],a=new Set(t.map(function(e){return e.id})),u=n.filter(function(e){return!a.has(e.id)}).map(function(e){return e.id}),s=i(u);try{for(s.s();!(l=s.n()).done;)f=l.value,r.removeTextSource(f)}catch(e){s.e(e)}finally{s.f()}p=new Map(n.map(function(e){return[e.id,e]})),d=[],h=[],m=i(t),e.p=1,v=o().m(function e(){var t,i;return o().w(function(e){for(;;)switch(e.n){case 0:t=y.value,i=t.id;try{n.some(function(e){return e.id===i})?r.updateTextSource(t):r.addTextSource(t),d.push(t)}catch(e){h.push({id:i,error:e}),p.has(i)&&d.push(p.get(i))}case 1:return e.a(2)}},e)}),m.s();case 2:if((y=m.n()).done){e.n=4;break}return e.d(c(v()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,b=e.v,m.e(b);case 6:return e.p=6,m.f(),e.f(6);case 7:return e.a(2,{finalOptions:d,errors:h})}},e,null,[[1,5,6,7]])})),function(e,r){return h.apply(this,arguments)})},{key:"parseImageOptions",value:(d=t(o().m(function e(r,t){var n,a,u,s,l,f,p,d,h,m,y,v,b,g=this,k=arguments;return o().w(function(e){for(;;)switch(e.p=e.n){case 0:n=k.length>2&&void 0!==k[2]?k[2]:[],a=new Set(t.map(function(e){return e.id})),u=n.filter(function(e){return!a.has(e.id)}).map(function(e){return e.id}),s=i(u);try{for(s.s();!(l=s.n()).done;)f=l.value,r.removeImageSource(f)}catch(e){s.e(e)}finally{s.f()}p=new Map(n.map(function(e){return[e.id,e]})),d=[],h=[],m=i(t),e.p=1,v=o().m(function e(){var t,i,a,c,u,s,l,f;return o().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=y.value,i=t.id,a=t.url,c=t.layout,e.p=1,!(u=n.find(function(e){return e.id===i}))){e.n=4;break}if(u.url===a){e.n=3;break}return e.n=2,g.core.utils.loadImage(a);case 2:s=e.v;case 3:r.updateImageSource(i,c,s),e.n=6;break;case 4:return e.n=5,g.core.utils.loadImage(a);case 5:l=e.v,r.addImageSource(i,l,c);case 6:d.push(t),e.n=8;break;case 7:e.p=7,f=e.v,h.push({id:i,error:f}),p.has(i)&&d.push(p.get(i));case 8:return e.a(2)}},e,null,[[1,7]])}),m.s();case 2:if((y=m.n()).done){e.n=4;break}return e.d(c(v()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,b=e.v,m.e(b);case 6:return e.p=6,m.f(),e.f(6);case 7:return e.a(2,{finalOptions:d,errors:h})}},e,null,[[1,5,6,7]])})),function(e,r){return d.apply(this,arguments)})},{key:"parseVideoOptions",value:(p=t(o().m(function e(r,t){var n,a,u,s,l,f,p,d,h,m,y,v,b,g=this,k=arguments;return o().w(function(e){for(;;)switch(e.p=e.n){case 0:n=k.length>2&&void 0!==k[2]?k[2]:[],a=new Set(t.map(function(e){return e.id})),u=n.filter(function(e){return!a.has(e.id)}).map(function(e){return e.id}),s=i(u);try{for(s.s();!(l=s.n()).done;)f=l.value,r.removeVideoSource(f)}catch(e){s.e(e)}finally{s.f()}p=new Map(n.map(function(e){return[e.id,e]})),d=[],h=[],m=i(t),e.p=1,v=o().m(function e(){var t,i,a,c,u,s,l,f;return o().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=y.value,i=t.id,a=t.url,c=t.layout,e.p=1,!(u=n.find(function(e){return e.id===i}))){e.n=4;break}if(u.url===a){e.n=3;break}return e.n=2,g.core.utils.loadVideo(a);case 2:s=e.v;case 3:r.updateVideoSource(i,c,s),e.n=6;break;case 4:return e.n=5,g.core.utils.loadVideo(a);case 5:l=e.v,r.addVideoSource(i,l,c);case 6:d.push(t),e.n=8;break;case 7:e.p=7,f=e.v,h.push({id:i,error:f}),p.has(i)&&d.push(p.get(i));case 8:return e.a(2)}},e,null,[[1,7]])}),m.s();case 2:if((y=m.n()).done){e.n=4;break}return e.d(c(v()),3);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,b=e.v,m.e(b);case 6:return e.p=6,m.f(),e.f(6);case 7:return e.a(2,{finalOptions:d,errors:h})}},e,null,[[1,5,6,7]])})),function(e,r){return p.apply(this,arguments)})},{key:"captureCamera",value:(f=t(o().m(function e(r){var t,n,i,a,c,u;return o().w(function(e){for(;;)switch(e.n){case 0:return t=r.id,n=r.cameraId,i=r.videoTrack,a=r.profile,(c=new this.core.LocalVideoTrack).log.id+="-".concat(t),u={},n?u.deviceId=n:this.core.utils.isUndefined(i)||(u.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.n=1,c.capture(u);case 1:return e.a(2,c)}},e,this)})),function(e){return f.apply(this,arguments)})},{key:"updateCameraProfile",value:(s=t(o().m(function e(r){var t,n,i,a,c,u;return o().w(function(e){for(;;)switch(e.n){case 0:if(n=r.id,i=r.cameraId,a=r.videoTrack,c=r.profile,u=null==(t=this.localMixVideoTrack)?void 0:t.inputLocalVideoTracks.get(n)){e.n=1;break}return e.a(2);case 1:if(!i){e.n=3;break}return e.n=2,u.switchDevice(i);case 2:e.n=4;break;case 3:if(this.core.utils.isUndefined(a)){e.n=4;break}return e.n=4,u.setInputMediaStreamTrack(a);case 4:if(this.core.utils.isUndefined(c)){e.n=5;break}if(this.core.utils.isString(c)?this.core.constants.videoProfileMap[c]&&u.setProfile(this.core.constants.videoProfileMap[c]):u.setProfile(c),i&&u.isNeedToSwitchDevice(i)){e.n=5;break}return e.n=5,u.applyProfile();case 5:return e.a(2)}},e,this)})),function(e){return s.apply(this,arguments)})},{key:"captureScreen",value:(a=t(o().m(function e(r){var t,n,i,a,c,u,s=this;return o().w(function(e){for(;;)switch(e.n){case 0:return t=r.id,n=r.profile,i=r.captureElement,a=r.preferDisplaySurface,(c=new this.core.LocalScreenTrack).log.id+="-".concat(t),u={},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&&(u.captureElement=i),a&&(u.preferDisplaySurface=a),e.n=1,c.capture(u);case 1:return c.mediaTrack.addEventListener(this.core.constants.NAME.ENDED,function(){var e,r,n;null==(e=s.localMixVideoTrack)||e.removeScreenSource(t),(null==(r=s._mixVideoConfig)?void 0:r.screen)&&(s._mixVideoConfig.screen=s._mixVideoConfig.screen.filter(function(e){return e.id!==t})),null==(n=s.onScreenShareStop)||n.call(s,t)}),e.a(2,c)}},e,this)})),function(e){return a.apply(this,arguments)})},{key:"_updatePreview",value:(r=t(o().m(function e(r){var t,n,i,a,c;return o().w(function(e){for(;;)switch(e.n){case 0:if(t=r.view,n=r.track,i=r.prevConfig,!(this.core.utils.isUndefined(t)&&i&&i.view)){e.n=1;break}if(!((a=this.core.utils.getViewListFromView(i.view)).length>0)){e.n=1;break}return e.n=1,n.play(a);case 1:if(this.core.utils.isUndefined(t)){e.n=4;break}if(!((c=this.core.utils.getViewListFromView(t)).length>0)){e.n=3;break}return e.n=2,n.play(c);case 2:e.n=4;break;case 3:n.stop();case 4:return e.a(2)}},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,a,s,f,p,d,h,m,y,g,S,O}();return b(O,"Name","VideoMixer"),O});
|
|
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}));
|