trtc-sdk-v5 5.12.0-beta.5 → 5.12.0-beta.6
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 +1 -1
- package/assets/{selfie_segmentation/selfie_segmentation_landscape.tflite → mediapipe/selfie_segmenter_landscape.tflite} +0 -0
- package/assets/mediapipe/vision.js +63 -0
- package/assets/mediapipe/vision_wasm_internal.js.gz +0 -0
- package/assets/{face_detection/vision_wasm_internal.gz → mediapipe/vision_wasm_internal.wasm.gz} +0 -0
- package/assets/mediapipe/vision_wasm_nosimd_internal.js.gz +0 -0
- package/assets/{face_detection/vision_wasm_nosimd_internal.gz → mediapipe/vision_wasm_nosimd_internal.wasm.gz} +0 -0
- package/index.d.ts +2 -0
- package/package.json +1 -1
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/device-detector.esm.d.ts +1 -0
- package/plugins/device-detector/device-detector.esm.js +18 -16
- package/plugins/device-detector/device-detector.umd.js +2 -2
- package/plugins/device-detector/package.json +1 -1
- package/plugins/small-stream-auto-switcher/package.json +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 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.umd.js +1 -1
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- 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.d.ts +71 -13
- package/plugins/video-effect/video-mixer/video-mixer.esm.js +1 -1
- package/plugins/video-effect/video-mixer/video-mixer.umd.js +1 -1
- 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 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/voice-changer/package.json +1 -1
- package/trtc.esm.js +36 -35
- package/trtc.js +1 -1
- package/assets/face_detection/vision_wasm_internal.js +0 -20
- package/assets/face_detection/vision_wasm_nosimd_internal.js +0 -20
- package/assets/selfie_segmentation/package.json +0 -27
- package/assets/selfie_segmentation/selfie_segmentation.binarypb +0 -0
- package/assets/selfie_segmentation/selfie_segmentation.tflite +0 -0
- package/assets/selfie_segmentation/selfie_segmentation_solution_simd_wasm_bin.data +0 -0
- package/assets/selfie_segmentation/selfie_segmentation_solution_simd_wasm_bin.wasm +0 -0
- package/assets/selfie_segmentation/selfie_segmentation_solution_wasm_bin.wasm +0 -0
- /package/assets/{face_detection → mediapipe}/blaze_face_short_range.tflite +0 -0
|
@@ -1,23 +1,81 @@
|
|
|
1
|
+
import type { screenProfileMap, VideoProfile, videoProfileMap } from 'trtc-sdk-v5';
|
|
2
|
+
|
|
1
3
|
export interface VideoMixerOptions {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
view?: string | HTMLElement | null;
|
|
5
|
+
canvasInfo: CanvasInfo;
|
|
6
|
+
camera?: CameraSource[];
|
|
7
|
+
screen?: ScreenSource[];
|
|
8
|
+
text?: TextSource[];
|
|
9
|
+
image?: ImageSource[];
|
|
10
|
+
video?: VideoSource[];
|
|
11
|
+
}
|
|
12
|
+
// 更新时画布配置变为可选
|
|
13
|
+
export type UpdateVideoMixerOptions = {
|
|
14
|
+
view?: VideoMixerOptions['view'];
|
|
15
|
+
canvasInfo?: VideoMixerOptions['canvasInfo'];
|
|
16
|
+
camera?: VideoMixerOptions['camera'];
|
|
17
|
+
screen?: VideoMixerOptions['screen'];
|
|
18
|
+
text?: VideoMixerOptions['text'];
|
|
19
|
+
image?: VideoMixerOptions['image'];
|
|
20
|
+
video?: VideoMixerOptions['video'];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export interface CanvasInfo {
|
|
24
|
+
canvasColor?: string | CanvasGradient | CanvasPattern; // 合流背景色
|
|
25
|
+
// 合流画布分辨率
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
frameRate?: number; // 合流帧率
|
|
29
|
+
}
|
|
30
|
+
export interface CameraSource {
|
|
31
|
+
// 参数与 startLocalVideo 对齐
|
|
32
|
+
id: string;
|
|
33
|
+
cameraId?: string;
|
|
34
|
+
videoTrack?: MediaStreamTrack;
|
|
35
|
+
profile?: keyof typeof videoProfileMap | VideoProfile;
|
|
36
|
+
layout: LayerOption;
|
|
37
|
+
}
|
|
38
|
+
export interface ScreenSource {
|
|
39
|
+
// 参数与 startScreenShare 对齐
|
|
40
|
+
id: string;
|
|
41
|
+
profile?: keyof typeof screenProfileMap | VideoProfile;
|
|
42
|
+
captureElement?: HTMLElement;
|
|
43
|
+
preferDisplaySurface?: 'current-tab' | 'tab' | 'window' | 'monitor';
|
|
44
|
+
layout: LayerOption;
|
|
45
|
+
}
|
|
46
|
+
export interface TextSource {
|
|
47
|
+
id: string;
|
|
48
|
+
content: string;
|
|
49
|
+
font?: string;
|
|
50
|
+
color?: string | CanvasGradient | CanvasPattern;
|
|
51
|
+
layout: LayerOption;
|
|
52
|
+
}
|
|
53
|
+
export interface ImageSource {
|
|
54
|
+
id: string;
|
|
55
|
+
url: string;
|
|
56
|
+
layout: LayerOption;
|
|
57
|
+
}
|
|
58
|
+
export interface VideoSource {
|
|
59
|
+
id: string;
|
|
60
|
+
url: string;
|
|
61
|
+
layout: LayerOption;
|
|
8
62
|
}
|
|
9
63
|
|
|
10
64
|
export interface LayerOption {
|
|
11
|
-
x
|
|
12
|
-
y
|
|
13
|
-
width
|
|
14
|
-
height
|
|
15
|
-
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
zIndex: number;
|
|
70
|
+
fillMode?: 'contain' | 'cover' | 'fill';
|
|
71
|
+
mirror?: boolean;
|
|
72
|
+
rotation?: 0 | 90 | 180 | 270;
|
|
73
|
+
hidden?: boolean;
|
|
16
74
|
}
|
|
17
75
|
|
|
18
76
|
export declare class VideoMixer {
|
|
19
|
-
start(options: VideoMixerOptions):
|
|
20
|
-
update(options:
|
|
77
|
+
start(options: VideoMixerOptions): Promise<MediaStreamVideoTrack>;
|
|
78
|
+
update(options: UpdateVideoMixerOptions): Promise<MediaStreamVideoTrack>;
|
|
21
79
|
stop(): void;
|
|
22
80
|
}
|
|
23
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e},__publicField=(e,r,t)=>__defNormalProp(e,"symbol"!=typeof r?r+"":r,t),layerProperty={x:{required:!1,type:"number"},y:{required:!1,type:"number"},width:{required:!1,type:"number",notLessThanZero:!0,min:1},height:{required:!1,type:"number",notLessThanZero:!0,min:1}};function startValidateRule(e){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{container:{type:"object",required:!0,properties:{width:{required:!0,type:"number",notLessThanZero:!0,min:1},height:{required:!0,type:"number",notLessThanZero:!0,min:1}}},camera:{type:"object",required:!1,properties:__spreadValues({},layerProperty)},screen:{type:"object",required:!1,properties:__spreadValues({},layerProperty)}}}}function updateValidateRule(e){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{container:{type:"object",required:!1,properties:{width:{required:!0,type:"number",notLessThanZero:!0,min:1},height:{required:!0,type:"number",notLessThanZero:!0,min:1}}},camera:{type:"object",required:!1,properties:__spreadValues({},layerProperty)},screen:{type:"object",required:!1,properties:__spreadValues({},layerProperty)}}}}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"),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"}get subStream(){return this.core.trtc.getVideoTrack({streamType:this.core.TRTC.TYPE.STREAM_TYPE_SUB})}get mainStream(){return this.core.trtc.getVideoTrack()}start(e={}){return this.subStream&&(this.core.trtc.updateScreenShare({publish:!1}),this.core.trtc.updateLocalVideo({publish:!0})),this.core.trtc.on(this.core.TRTC.EVENT.PUBLISH_STATE_CHANGED,this.stopSubStream,this),this.core.room.videoManager.setVideoMixer(e)}update(e){return this.core.room.videoManager.updateVideoMixer(e)}stop(){return this.core.trtc.off(this.core.TRTC.EVENT.PUBLISH_STATE_CHANGED,this.stopSubStream,this),this.subStream&&this.core.trtc.updateScreenShare({publish:!0}),this.core.room.videoManager.deleteVideoMixer()}stopSubStream(e){const{mediaType:r,state:t,reason:i}=e;"screen"===r&&"started"===t&&(this.core.trtc.updateScreenShare({publish:!1}),this.core.trtc.updateLocalVideo({publish:!0}))}};__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}},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))}}}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"),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),await this.parseMixOptions(e);const{view:i}=e;return this._updatePreview({view:i,track:this.localMixVideoTrack}),await this.localMixVideoTrack.startMix(),this.localMixVideoTrack._outputTrack}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),await this.parseMixOptions(e);const{view:t}=e;return await this._updatePreview({view:t,track:this.localMixVideoTrack,prevConfig:this._mixVideoConfig}),this.localMixVideoTrack._outputTrack}async parseMixOptions(e){if(this.localMixVideoTrack)try{const{canvasInfo:i,camera:r,screen:t,text:a,image:o,video:s}=e;if(i){const{canvasColor:e,width:r,height:t,frameRate:a}=i;e&&this.localMixVideoTrack.setMixBackground(e),a&&this.localMixVideoTrack.setFps(a),this.localMixVideoTrack.resizeMixCanvas(r,t),this._mixVideoConfig.canvasInfo=i}r&&(this._mixVideoConfig.camera=await this.parseCameraOptions(this.localMixVideoTrack,r,this._mixVideoConfig.camera)),t&&(this._mixVideoConfig.screen=await this.parseScreenOptions(this.localMixVideoTrack,t,this._mixVideoConfig.screen)),a&&(this._mixVideoConfig.text=await this.parseTextOptions(this.localMixVideoTrack,a,this._mixVideoConfig.text)),o&&(this._mixVideoConfig.image=await this.parseImageOptions(this.localMixVideoTrack,o,this._mixVideoConfig.image)),s&&(this._mixVideoConfig.video=await this.parseVideoOptions(this.localMixVideoTrack,s,this._mixVideoConfig.video))}catch(e){this.log.error("parse mix options failed",e)}}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=[];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){this.log.error(`${i} mix failed.`,e),n.has(i)&&d.push(n.get(i))}}return 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=[];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){this.log.error(`${i} mix failed.`,e),o.has(i)&&s.push(o.get(i))}}return s}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=[];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){this.log.error(`${i} mix failed.`,e),o.has(i)&&s.push(o.get(i))}}return s}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=[];for(const t of i){const{id:i,url:a,layout:n}=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,n,r)}else{const r=await this.core.utils.loadImage(a);e.addImageSource(i,r,n)}s.push(t)}catch(e){this.log.error(`${i} mix failed.`,e),o.has(i)&&s.push(o.get(i))}}return s}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=[];for(const t of i){const{id:i,url:a,layout:n}=t;try{const o=r.find((e=>e.id===i));let d;if(o)o.url!==a&&(d=await this.core.utils.loadVideo(a)),e.updateVideoSource(i,n,d);else{const r=await this.core.utils.loadVideo(a);e.addVideoSource(i,r,n)}s.push(t)}catch(e){this.log.error(`${i} mix failed.`,e),o.has(i)&&s.push(o.get(i))}}return s}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;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)))})),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._mixVideoConfig}};__publicField(_VideoMixer,"Name","VideoMixer");var VideoMixer=_VideoMixer,index_default=VideoMixer;export{index_default as default};export{VideoMixer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VideoMixer=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function t(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(t,r){var o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!o){if(Array.isArray(t)||(o=function(t,r){if(t){if("string"==typeof t)return e(t,r);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,r):void 0}}(t))||r){o&&(t=o);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[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 u,a=!0,c=!1;return{s:function(){o=o.call(t)},n:function(){var e=o.next();return a=e.done,e},e:function(e){c=!0,u=e},f:function(){try{a||null==o.return||o.return()}finally{if(c)throw u}}}}function o(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function n(e){return n="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},n(e)}var i=Object.defineProperty,u=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,s=function(e,t,r){return t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},p=function(e,t){for(var o in t||(t={}))a.call(t,o)&&s(e,o,t[o]);if(u){var n,i=r(u(t));try{for(i.s();!(n=i.n()).done;){o=n.value;c.call(t,o)&&s(e,o,t[o])}}catch(e){i.e(e)}finally{i.f()}}return e},l=function(e,t,r){return s(e,"symbol"!==n(t)?t+"":t,r)},f={x:{required:!1,type:"number"},y:{required:!1,type:"number"},width:{required:!1,type:"number",notLessThanZero:!0,min:1},height:{required:!1,type:"number",notLessThanZero:!0,min:1}};var y=0,d=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.core=t,l(this,"seq"),l(this,"log"),y+=1,this.seq=y,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(y)}),this.log.info("created")}return t(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"vmix"}},{key:"getValidateRule",value:function(e){switch(e){case"start":return this.core,{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{container:{type:"object",required:!0,properties:{width:{required:!0,type:"number",notLessThanZero:!0,min:1},height:{required:!0,type:"number",notLessThanZero:!0,min:1}}},camera:{type:"object",required:!1,properties:p({},f)},screen:{type:"object",required:!1,properties:p({},f)}}};case"update":return this.core,{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{container:{type:"object",required:!1,properties:{width:{required:!0,type:"number",notLessThanZero:!0,min:1},height:{required:!0,type:"number",notLessThanZero:!0,min:1}}},camera:{type:"object",required:!1,properties:p({},f)},screen:{type:"object",required:!1,properties:p({},f)}}};case"stop":return this.core,{name:"StopVideoMixerOptions",required:!1}}}},{key:"getGroup",value:function(){return"vmix"}},{key:"subStream",get:function(){return this.core.trtc.getVideoTrack({streamType:this.core.TRTC.TYPE.STREAM_TYPE_SUB})}},{key:"mainStream",get:function(){return this.core.trtc.getVideoTrack()}},{key:"start",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.subStream&&(this.core.trtc.updateScreenShare({publish:!1}),this.core.trtc.updateLocalVideo({publish:!0})),this.core.trtc.on(this.core.TRTC.EVENT.PUBLISH_STATE_CHANGED,this.stopSubStream,this),this.core.room.videoManager.setVideoMixer(e)}},{key:"update",value:function(e){return this.core.room.videoManager.updateVideoMixer(e)}},{key:"stop",value:function(){return this.core.trtc.off(this.core.TRTC.EVENT.PUBLISH_STATE_CHANGED,this.stopSubStream,this),this.subStream&&this.core.trtc.updateScreenShare({publish:!0}),this.core.room.videoManager.deleteVideoMixer()}},{key:"stopSubStream",value:function(e){var t=e.mediaType,r=e.state;e.reason,"screen"===t&&"started"===r&&(this.core.trtc.updateScreenShare({publish:!1}),this.core.trtc.updateLocalVideo({publish:!0}))}}])}();return l(d,"Name","VideoMixer"),d}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VideoMixer=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(e,t,r,n,i,o,a){try{var c=e[o](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,i)}function r(e){return function(){var r=this,n=arguments;return new Promise((function(i,o){var a=e.apply(r,n);function c(e){t(a,i,o,c,u,"next",e)}function u(e){t(a,i,o,c,u,"throw",e)}c(void 0)}))}}function n(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t))||r){n&&(t=n);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(e){throw e},f:o}}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 a,c=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var e=n.next();return c=e.done,e},e:function(e){u=!0,a=e},f:function(){try{c||null==n.return||n.return()}finally{if(u)throw a}}}}function o(){o=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var o=t&&t.prototype instanceof x?t:x,a=Object.create(o.prototype),c=new P(n||[]);return i(a,"_invoke",{value:S(e,r,c)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.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,T=k&&k(k(I([])));T&&T!==r&&n.call(T,c)&&(w=T);var E=b.prototype=x.prototype=Object.create(w);function V(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function M(e,t){function r(i,o,a,c){var u=p(e[i],e,o);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,c)}))}c(u.arg)}var o;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return o=o?o.then(i,i):i()}})}function S(t,r,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 u=C(c,n);if(u){if(u===m)continue;return u}}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 s=p(t,r,n);if("normal"===s.type){if(i=n.done?y:h,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(i=y,n.method="throw",n.arg=s.arg)}}}function C(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,C(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var o=p(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,m;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function I(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(typeof t+" 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,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,l(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},V(M.prototype),l(M.prototype,u,(function(){return this})),t.AsyncIterator=M,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new M(f(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},V(E),l(E,s,"Generator"),l(E,c,(function(){return this})),l(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=I,P.prototype={constructor:P,reset:function(t){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(_),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.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 u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(e,t){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&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;_(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function a(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function c(e){return c="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},c(e)}var u=Object.defineProperty,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,p=function(e,t,r){return t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},d=function(e,t){for(var r in t||(t={}))l.call(t,r)&&p(e,r,t[r]);if(s){var n,o=i(s(t));try{for(o.s();!(n=o.n()).done;){r=n.value;f.call(t,r)&&p(e,r,t[r])}}catch(e){o.e(e)}finally{o.f()}}return e},h=function(e,t,r){return p(e,"symbol"!==c(t)?t+"":t,r)},v={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"}},y=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}},validate:function(t,r,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode;if(i.ErrorCodeDictionary,t){var c=t.width,u=t.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."})}}}},m=function(e){return{required:!1,type:["string",HTMLElement,null],validate:function(t,r,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode,c=i.ErrorCodeDictionary;if(e.utils.isString(t)&&!document.getElementById(t))throw new o({code:a.INVALID_PARAMETER,extraCode:c.INVALID_ELEMENT_ID,fnName:n,messageParams:{key:r}})}}},x=function(e){return{type:"object",required:!(arguments.length>1&&void 0!==arguments[1])||arguments[1],properties:d({},v),validate:function(t,r,n){var i=e.errorModule,o=i.RtcError,a=i.ErrorCode,c=i.ErrorCodeDictionary;if(t){if(t.fillMode&&!["contain","cover","fill"].includes(t.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(t.rotation&&![0,90,180,270].includes(t.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})}}}},g=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:d({},x(e))}}}},b=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:d({},x(e))},validate:function(t,r,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})}}}},w=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:d({},x(e))}}}},k=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:d({},x(e))}}}},T=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:d({},x(e))}}}};var E=0,V=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.core=t,h(this,"seq"),h(this,"log"),h(this,"localMixVideoTrack",null),h(this,"_mixVideoConfig"),E+=1,this.seq=E,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(E)}),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 t=this.core,{name:"VideoMixerOptions",type:"object",required:!0,allowEmpty:!1,properties:{view:d({},m(t)),canvasInfo:d({},y(t,!0)),camera:d({},g(t)),screen:d({},b(t)),text:d({},w(t)),image:d({},k(t)),video:d({},T(t))}};case"update":return function(e){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{view:d({},m(e)),canvasInfo:d({},y(e)),camera:d({},g(e)),screen:d({},b(e)),text:d({},w(e)),image:d({},k(e)),video:d({},T(e))}}}(this.core);case"stop":return this.core,{name:"StopVideoMixerOptions",required:!1}}var t}},{key:"getGroup",value:function(){return"vmix"}},{key:"start",value:(M=r(o().mark((function e(t){var r;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}},t=this.core.utils.deepCloneBasic(t),e.next=5,this.parseMixOptions(t);case 5:return r=t.view,this._updatePreview({view:r,track:this.localMixVideoTrack}),e.next=9,this.localMixVideoTrack.startMix();case 9:return e.abrupt("return",this.localMixVideoTrack._outputTrack);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return M.apply(this,arguments)})},{key:"update",value:(V=r(o().mark((function e(t){var r,n,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.core.errorModule,n=r.RtcError,i=r.ErrorCode,this.localMixVideoTrack){e.next=3;break}throw new n({code:i.INVALID_OPERATION,message:"mixTrack doesn't initialize!"});case 3:return t=this.core.utils.deepCloneBasic(t),e.next=6,this.parseMixOptions(t);case 6:return a=t.view,e.next=9,this._updatePreview({view:a,track:this.localMixVideoTrack,prevConfig:this._mixVideoConfig});case 9:return e.abrupt("return",this.localMixVideoTrack._outputTrack);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return V.apply(this,arguments)})},{key:"parseMixOptions",value:(x=r(o().mark((function e(t){var r,n,i,a,c,u,s,l,f,p;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.localMixVideoTrack){e.next=2;break}return e.abrupt("return");case 2:if(e.prev=2,r=t.canvasInfo,n=t.camera,i=t.screen,a=t.text,c=t.image,u=t.video,r&&(s=r.canvasColor,l=r.width,f=r.height,p=r.frameRate,s&&this.localMixVideoTrack.setMixBackground(s),p&&this.localMixVideoTrack.setFps(p),this.localMixVideoTrack.resizeMixCanvas(l,f),this._mixVideoConfig.canvasInfo=r),!n){e.next=9;break}return e.next=8,this.parseCameraOptions(this.localMixVideoTrack,n,this._mixVideoConfig.camera);case 8:this._mixVideoConfig.camera=e.sent;case 9:if(!i){e.next=13;break}return e.next=12,this.parseScreenOptions(this.localMixVideoTrack,i,this._mixVideoConfig.screen);case 12:this._mixVideoConfig.screen=e.sent;case 13:if(!a){e.next=17;break}return e.next=16,this.parseTextOptions(this.localMixVideoTrack,a,this._mixVideoConfig.text);case 16:this._mixVideoConfig.text=e.sent;case 17:if(!c){e.next=21;break}return e.next=20,this.parseImageOptions(this.localMixVideoTrack,c,this._mixVideoConfig.image);case 20:this._mixVideoConfig.image=e.sent;case 21:if(!u){e.next=25;break}return e.next=24,this.parseVideoOptions(this.localMixVideoTrack,u,this._mixVideoConfig.video);case 24:this._mixVideoConfig.video=e.sent;case 25:e.next=30;break;case 27:e.prev=27,e.t0=e.catch(2),this.log.error("parse mix options failed",e.t0);case 30:case"end":return e.stop()}}),e,this,[[2,27]])}))),function(e){return x.apply(this,arguments)})},{key:"parseCameraOptions",value:(v=r(o().mark((function e(t,r){var n,a,c,u,s,l,f,p,d,h,v,y,m,x,g,b,w,k,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]:[],u=new Set(r.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,t.removeCameraSource(p)}catch(e){l.e(e)}finally{l.f()}d=new Map(n.map((function(e){return[e.id,e]}))),h=[],v=i(r),e.prev=8,v.s();case 10:if((y=v.n()).done){e.next=44;break}if(m=y.value,x=m.id,g=m.layout,b=m.profile,e.prev=13,!t.inputLocalVideoTracks.has(x)){e.next=24;break}return w=null==(a=t.inputLocalVideoTracks.get(x))?void 0:a.mediaTrack,e.next=18,this.updateCameraProfile(m);case 18:k=null==(c=t.inputLocalVideoTracks.get(x))?void 0:c.mediaTrack,T=void 0,b&&(T=this.core.utils.isString(b)?this.core.constants.videoProfileMap[b]:b),k!==w?t.updateCameraSource(x,g,k,T):t.updateCameraSource(x,g,null,T),e.next=35;break;case 24:return e.next=26,this.captureCamera(m);case 26:E=e.sent,e.prev=27,t.addCameraSource(x,E,g),e.next=35;break;case 31:throw e.prev=31,e.t0=e.catch(27),E.close(),e.t0;case 35:h.push(m),e.next=42;break;case 38:e.prev=38,e.t1=e.catch(13),this.log.error("".concat(x," mix failed."),e.t1),d.has(x)&&h.push(d.get(x));case 42:e.next=10;break;case 44:e.next=49;break;case 46:e.prev=46,e.t2=e.catch(8),v.e(e.t2);case 49:return e.prev=49,v.f(),e.finish(49);case 52:return e.abrupt("return",h);case 53:case"end":return e.stop()}}),e,this,[[8,46,49,52],[13,38],[27,31]])}))),function(e,t){return v.apply(this,arguments)})},{key:"parseScreenOptions",value:(p=r(o().mark((function e(t,r){var n,a,c,u,s,l,f,p,d,h,v,y,m,x,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(r.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,t.removeScreenSource(l)}catch(e){u.e(e)}finally{u.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=i(r),e.prev=8,d.s();case 10:if((h=d.n()).done){e.next=38;break}if(v=h.value,y=v.id,m=v.layout,e.prev=13,!t.inputLocalScreenTracks.has(y)){e.next=18;break}t.updateScreenSource(y,m),e.next=29;break;case 18:return e.next=20,this.captureScreen(v);case 20:x=e.sent,e.prev=21,t.addScreenSource(y,x,m),e.next=29;break;case 25:throw e.prev=25,e.t0=e.catch(21),x.close(),e.t0;case 29:p.push(v),e.next=36;break;case 32:e.prev=32,e.t1=e.catch(13),this.log.error("".concat(y," mix failed."),e.t1),f.has(y)&&p.push(f.get(y));case 36:e.next=10;break;case 38:e.next=43;break;case 40:e.prev=40,e.t2=e.catch(8),d.e(e.t2);case 43:return e.prev=43,d.f(),e.finish(43);case 46:return e.abrupt("return",p);case 47:case"end":return e.stop()}}),e,this,[[8,40,43,46],[13,32],[21,25]])}))),function(e,t){return p.apply(this,arguments)})},{key:"parseTextOptions",value:(f=r(o().mark((function e(t,r){var n,a,c,u,s,l,f,p,d,h,v,y=this,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(r.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,t.removeTextSource(l)}catch(e){u.e(e)}finally{u.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=i(r),e.prev=8,v=o().mark((function e(){var r,i;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.value,i=r.id;try{n.some((function(e){return e.id===i}))?t.updateTextSource(r):t.addTextSource(r),p.push(r)}catch(e){y.log.error("".concat(i," mix failed."),e),f.has(i)&&p.push(f.get(i))}case 3:case"end":return e.stop()}}),e)})),d.s();case 11:if((h=d.n()).done){e.next=15;break}return e.delegateYield(v(),"t0",13);case 13:e.next=11;break;case 15:e.next=20;break;case 17:e.prev=17,e.t1=e.catch(8),d.e(e.t1);case 20:return e.prev=20,d.f(),e.finish(20);case 23:return e.abrupt("return",p);case 24:case"end":return e.stop()}}),e,null,[[8,17,20,23]])}))),function(e,t){return f.apply(this,arguments)})},{key:"parseImageOptions",value:(l=r(o().mark((function e(t,r){var n,a,c,u,s,l,f,p,d,h,v,y=this,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(r.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,t.removeImageSource(l)}catch(e){u.e(e)}finally{u.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=i(r),e.prev=8,v=o().mark((function e(){var r,i,a,c,u,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=h.value,i=r.id,a=r.url,c=r.layout,e.prev=2,!(u=n.find((function(e){return e.id===i})))){e.next=12;break}if(u.url===a){e.next=9;break}return e.next=8,y.core.utils.loadImage(a);case 8:s=e.sent;case 9:t.updateImageSource(i,c,s),e.next=16;break;case 12:return e.next=14,y.core.utils.loadImage(a);case 14:l=e.sent,t.addImageSource(i,l,c);case 16:p.push(r),e.next=23;break;case 19:e.prev=19,e.t0=e.catch(2),y.log.error("".concat(i," mix failed."),e.t0),f.has(i)&&p.push(f.get(i));case 23:case"end":return e.stop()}}),e,null,[[2,19]])})),d.s();case 11:if((h=d.n()).done){e.next=15;break}return e.delegateYield(v(),"t0",13);case 13:e.next=11;break;case 15:e.next=20;break;case 17:e.prev=17,e.t1=e.catch(8),d.e(e.t1);case 20:return e.prev=20,d.f(),e.finish(20);case 23:return e.abrupt("return",p);case 24:case"end":return e.stop()}}),e,null,[[8,17,20,23]])}))),function(e,t){return l.apply(this,arguments)})},{key:"parseVideoOptions",value:(s=r(o().mark((function e(t,r){var n,a,c,u,s,l,f,p,d,h,v,y=this,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(r.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,t.removeVideoSource(l)}catch(e){u.e(e)}finally{u.f()}f=new Map(n.map((function(e){return[e.id,e]}))),p=[],d=i(r),e.prev=8,v=o().mark((function e(){var r,i,a,c,u,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=h.value,i=r.id,a=r.url,c=r.layout,e.prev=2,!(u=n.find((function(e){return e.id===i})))){e.next=12;break}if(u.url===a){e.next=9;break}return e.next=8,y.core.utils.loadVideo(a);case 8:s=e.sent;case 9:t.updateVideoSource(i,c,s),e.next=16;break;case 12:return e.next=14,y.core.utils.loadVideo(a);case 14:l=e.sent,t.addVideoSource(i,l,c);case 16:p.push(r),e.next=23;break;case 19:e.prev=19,e.t0=e.catch(2),y.log.error("".concat(i," mix failed."),e.t0),f.has(i)&&p.push(f.get(i));case 23:case"end":return e.stop()}}),e,null,[[2,19]])})),d.s();case 11:if((h=d.n()).done){e.next=15;break}return e.delegateYield(v(),"t0",13);case 13:e.next=11;break;case 15:e.next=20;break;case 17:e.prev=17,e.t1=e.catch(8),d.e(e.t1);case 20:return e.prev=20,d.f(),e.finish(20);case 23:return e.abrupt("return",p);case 24:case"end":return e.stop()}}),e,null,[[8,17,20,23]])}))),function(e,t){return s.apply(this,arguments)})},{key:"captureCamera",value:(u=r(o().mark((function e(t){var r,n,i,a,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.id,n=t.cameraId,i=t.videoTrack,a=t.profile,(c=new this.core.LocalVideoTrack).log.id+="-".concat(r),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.next=8,c.capture(u);case 8:return e.abrupt("return",c);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"updateCameraProfile",value:(c=r(o().mark((function e(t){var r,n,i,a,c,u;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.id,i=t.cameraId,a=t.videoTrack,c=t.profile,u=null==(r=this.localMixVideoTrack)?void 0:r.inputLocalVideoTracks.get(n)){e.next=4;break}return e.abrupt("return");case 4:if(!i){e.next=9;break}return e.next=7,u.switchDevice(i);case 7:e.next=12;break;case 9:if(this.core.utils.isUndefined(a)){e.next=12;break}return e.next=12,u.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]&&u.setProfile(this.core.constants.videoProfileMap[c]):u.setProfile(c),i&&u.isNeedToSwitchDevice(i)){e.next=17;break}return e.next=17,u.applyProfile();case 17:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"captureScreen",value:(a=r(o().mark((function e(t){var r,n,i,a,c,u,s=this;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.id,n=t.profile,i=t.captureElement,a=t.preferDisplaySurface,(c=new this.core.LocalScreenTrack).log.id+="-".concat(r),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.next=9,c.capture(u);case 9:return c.mediaTrack.addEventListener(this.core.constants.NAME.ENDED,(function(){var e,t;null==(e=s.localMixVideoTrack)||e.removeScreenSource(r),(null==(t=s._mixVideoConfig)?void 0:t.screen)&&(s._mixVideoConfig.screen=s._mixVideoConfig.screen.filter((function(e){return e.id!==r})))})),e.abrupt("return",c);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_updatePreview",value:(t=r(o().mark((function e(t){var r,n,i,a,c;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.view,n=t.track,i=t.prevConfig,!(this.core.utils.isUndefined(r)&&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(r)){e.next=14;break}if(!((c=this.core.utils.getViewListFromView(r)).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 t.apply(this,arguments)})},{key:"stop",value:function(){var e;null==(e=this.localMixVideoTrack)||e.close(),this.localMixVideoTrack=null,delete this._mixVideoConfig}}]);var t,a,c,u,s,l,f,p,v,x,V,M}();return h(V,"Name","VideoMixer"),V}));
|