@xylink/xy-rtc-sdk 1.4.1-beta.22 → 2.0.1-1

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.
@@ -0,0 +1,138 @@
1
+ /**
2
+ * XYLink WebRTC Layout Manager Lib
3
+ *
4
+ * @summary management custom layout list data
5
+ * @author jinghui-Luo
6
+ * @email luojinghui424@gmail.com
7
+ *
8
+ * Created at : 2021-01-05 17:24:07
9
+ * Last modified : 2021-04-02 17:12:03
10
+ */
11
+ import Logger from '../tools/logger';
12
+ import { ICustomLayoutObj, IVideoRenders, IRoster, ISelfRoster, ILayout, IScreenInfo, IMode, IOutputCustomLayout, ILayoutRoster } from '../type/index';
13
+ import Client from './client';
14
+ export default class LayoutManager {
15
+ logger: Logger;
16
+ client: Client;
17
+ private videoManagers;
18
+ customLayoutList: Map<string, ICustomLayoutObj>;
19
+ layoutList: Map<string, ICustomLayoutObj>;
20
+ private orderRosterList;
21
+ private selfRoster;
22
+ private newLayoutList;
23
+ private initLayout;
24
+ private templateMode;
25
+ private templateModeTemp;
26
+ private templateRate;
27
+ private specifyTemplateMode;
28
+ private content;
29
+ private screenInfo;
30
+ private internelsLayout;
31
+ private forceFullScreenId;
32
+ private chairmanRoster;
33
+ private localContent;
34
+ constructor(client: Client);
35
+ static getCustomLayoutItem(item: any, resolution: any, quality: any): {
36
+ pid: any;
37
+ resolution: any;
38
+ quality: any;
39
+ mediagroupid: number;
40
+ };
41
+ getNewLayout(): ILayout[];
42
+ getOrderRosterList(): IRoster[];
43
+ getLayoutList(): Map<string, ICustomLayoutObj>;
44
+ getCustomLayoutList(): Map<string, ICustomLayoutObj>;
45
+ getTemplateRate(): {
46
+ previous: number;
47
+ next: number;
48
+ };
49
+ getContentRosterItem(): IRoster;
50
+ getSelfRoster(): ISelfRoster;
51
+ getScreenInfo(): IScreenInfo;
52
+ getVideoManagers(): IVideoRenders;
53
+ getForceFullScreenId(): string;
54
+ getTemplateMode(): IMode;
55
+ getChairmanRoster(): IRoster;
56
+ rosterRecvMode(orderRosterListLen: any): {
57
+ tempLayout: any[];
58
+ templateRate: number;
59
+ };
60
+ getInternelsLayout(): IOutputCustomLayout;
61
+ setOrderRosterList(orderRosterList: IRoster[]): void;
62
+ initLayoutManager(): void;
63
+ /**
64
+ * 回调 video 状态
65
+ *
66
+ * @param key endpointId + mediagroupId 组成的id
67
+ * @param data 最新的会议状态
68
+ */
69
+ private onVideoStatusChange;
70
+ /**
71
+ * 使用wrap element元素更新 videoManagers 数据,并绑定视频流信息
72
+ *
73
+ * @param key endpointId + mediagroupId 组成的id
74
+ * @param wrapEleId wrap video element id
75
+ */
76
+ setVideoRenderer(key: any, wrapEleId: any): void;
77
+ /**
78
+ * 使用最新的 videoTrackList 和 layoutResults 数据更新 layout 内容
79
+ */
80
+ updateStreams(isAutoSendLayout?: boolean): void;
81
+ /**
82
+ * 清理失效的 video manager 数据
83
+ */
84
+ clearInvalidVideoManagers(): void;
85
+ createCustomLayout(totalLayoutResultList: ILayoutRoster[]): void;
86
+ /**
87
+ * 根据 reqList 计算最新的 layout 数据
88
+ *
89
+ * @param reqList
90
+ */
91
+ requestLayout(reqList: any): void;
92
+ /**
93
+ * 清理无效的 layout 数据,重置状态
94
+ */
95
+ private clearInvalidLayout;
96
+ private createBaseLayout;
97
+ calculatePosition(): void;
98
+ requestLayoutCalculator(): any[];
99
+ setForceFullScreenId(id: string): void;
100
+ /**
101
+ * 计算 custom layout 数据
102
+ */
103
+ private customLayoutCalculator;
104
+ calculateRotate(): void;
105
+ /**
106
+ * 通过旋转信息获取在layout中的位置
107
+ *
108
+ * @param pid peopleId
109
+ * @param mediagroupid type
110
+ */
111
+ private getLayoutKeyByRotateInfo;
112
+ private localMirrorRotate;
113
+ getVideoStreamByTrackId(videoTrackId: string): {
114
+ videoStream: any;
115
+ track: any;
116
+ };
117
+ calculateNewLayoutList(): any[];
118
+ calculateScreenInfo(): {
119
+ width: number;
120
+ height: number;
121
+ rateHeight: number;
122
+ rateWidth: number;
123
+ };
124
+ requestCustomLayout(): void;
125
+ createLayout(): void;
126
+ calculateOrderRosterList(): any;
127
+ switchLayout(templateMode: IMode): IMode;
128
+ setTemplateMode(templateMode: IMode): void;
129
+ setChairmanRoster(roster: IRoster): void;
130
+ setContentRosterItem(content: IRoster): void;
131
+ /**
132
+ * 【内部方法】停止轮询时,清理无效的 videoManager 数据
133
+ *
134
+ * @param monitoryList callUri list 数据
135
+ */
136
+ clearVideoManagersUseMonitorList(monitoryList: string[]): void;
137
+ private setSelfRoster;
138
+ }
@@ -1,10 +1,10 @@
1
1
  /**
2
- * webRTC PeerConnection lib
2
+ * XYLink WebRTC PeerConnection Manager Lib
3
3
  *
4
4
  * @authors Luo-jinghui (luojinghui424@gmail.com)
5
5
  * @date 2019-10-25 18:53:01
6
6
  */
7
- import { IInvite, IStreamSender } from '../type';
7
+ import { IInvite, IStreamObj, IStreamSender, IPushType } from '../type';
8
8
  import Client from './client';
9
9
  import Logger from '../tools/logger';
10
10
  import Stream from './stream';
@@ -69,7 +69,7 @@ export default class Peer {
69
69
  * @param stream Local stream
70
70
  * @param pushType 推送类型,all全推送,video只推送video,audio只推送audio, content只推送content video流
71
71
  */
72
- publish(stream: Stream, pushType?: string): void;
72
+ publish(stream: Stream, pushType?: IPushType): void;
73
73
  replacePeopleVideoTrack(stream: Stream, kind?: string): void;
74
74
  /**
75
75
  * people and content sender status
@@ -83,6 +83,12 @@ export default class Peer {
83
83
  * Get peerconnection status
84
84
  */
85
85
  getPeerStatus(): boolean;
86
+ /**
87
+ * 无流切换至有流,需向transceiver重新setStream/replaceTrack
88
+ * @param streamList
89
+ * @returns
90
+ */
91
+ setStream(streamList: IStreamObj[], kind: 'video' | 'audio'): void;
86
92
  private calcMeetingStats;
87
93
  /**
88
94
  * Addtrack
@@ -91,6 +97,7 @@ export default class Peer {
91
97
  */
92
98
  private addTransceiver;
93
99
  private addStreamRenders;
100
+ private setStreamSenders;
94
101
  /**
95
102
  * Replace Track
96
103
  *
@@ -1,11 +1,12 @@
1
1
  /**
2
- * Webrtc stream lib
2
+ * XYLink WebRTC Stream Manager Lib
3
3
  *
4
4
  * @authors Luo-jinghui (luojinghui424@gmail.com)
5
5
  * @date 2019-10-27 23:12:45
6
6
  */
7
+ import Logger from 'src/tools/logger';
7
8
  import Emmitter from '../tools/emmitter';
8
- import { IStreamChangeType, IStreamObj, IGetMediaStreams, ISource, IStreamInitConfog, IStreamCurrent } from '../type';
9
+ import { IStreamChangeType, IStreamObj, IGetMediaStreams, ISource, IStreamInitConfog, IStreamCurrent, IStreamChange } from '../type';
9
10
  import Peer from './peer';
10
11
  import Client from './client';
11
12
  export default class Stream extends Emmitter {
@@ -22,18 +23,19 @@ export default class Stream extends Emmitter {
22
23
  private isShareContent;
23
24
  private audioDeviceId;
24
25
  private videoDeviceId;
25
- constructor({ logger }: {
26
- logger: any;
26
+ constructor(params: {
27
+ logger: Logger;
28
+ client?: Client;
27
29
  });
28
30
  static instance: Stream;
29
- static getStreamInstance(params: any): Stream;
30
- static getContraints(video?: boolean, audio?: boolean, config?: any): {
31
- audio: {};
32
- video: {};
33
- };
31
+ static getStreamInstance(params: {
32
+ logger: Logger;
33
+ client?: Client;
34
+ }): Stream;
35
+ static getContraints(video?: boolean, audio?: boolean, config?: any): any;
34
36
  static getSupportConstraints(): any;
35
37
  getLocalStream(): IStreamObj[];
36
- getIndexFromStreamChange(stream: MediaStream, streamChangeInfo: any): any;
38
+ getIndexFromStreamChange(stream: MediaStream, streamChangeInfo: IStreamChange[]): number;
37
39
  /**
38
40
  * stream 取消监听事件
39
41
  *
@@ -43,17 +45,22 @@ export default class Stream extends Emmitter {
43
45
  off(key: any): void;
44
46
  /**
45
47
  * 媒体网关发给WEB JS的视频流的分辨率、带宽信息、帧率
46
- * WEB JS收到消息后推送视频流
48
+ * WEB收到消息后推送相应视频流/调整带宽
47
49
  *
48
- * @param body
50
+ * @param { IStreamChangeType } body StreamChange消息内容
51
+ * @param { Peer } peer Peer模块
52
+ * @param { number } mediaGroupId 当前stream是否是content画面
49
53
  */
50
54
  handleChangeStream(body: IStreamChangeType, peer: Peer, mediaGroupId: number): Promise<void>;
51
- setAudioOutput(deviceId: string): Promise<unknown>;
52
- switchDevice(type: 'audio' | 'video', deviceId: string): Promise<{
53
- code: number;
54
- msg: string;
55
- detai: {};
55
+ /**
56
+ * 切换扬声器
57
+ *
58
+ * @param deviceId string 设备id
59
+ */
60
+ setAudioOutput(deviceId: string): Promise<{
61
+ deviceId: string;
56
62
  }>;
63
+ switchDevice(type: 'audio' | 'video', deviceId: string): Promise<boolean>;
57
64
  sendStreamStatus(): void;
58
65
  private replaceAudioTrack;
59
66
  private replaceVideoTrack;
@@ -70,15 +77,44 @@ export default class Stream extends Emmitter {
70
77
  close(): void;
71
78
  private closeStreams;
72
79
  getMediaStreams(): IGetMediaStreams;
73
- init(config?: IStreamInitConfog): Promise<{
74
- code: number;
75
- msg: string;
76
- detail: IStreamObj[];
77
- } | {
80
+ init(config?: IStreamInitConfog, params?: {
81
+ muteVideo?: boolean;
82
+ muteAudio?: boolean;
83
+ }): Promise<{
78
84
  code: number;
79
85
  msg: string;
80
- detail: IStreamCurrent;
86
+ detail: {};
81
87
  }>;
88
+ updatePermission(video: boolean, audio: boolean): void;
89
+ /**
90
+ *
91
+ * @param { boolean } video 是否开启摄像头
92
+ * @param { boolean } audio 是否开启麦克风
93
+ * @param { string } videoId 摄像头设备ID
94
+ * @param { string } audioId 麦克风设备ID
95
+ * @param { boolean } isReduceResolution 是否降低分辨率采集, 默认采集720P,降低分辨率则采集360P
96
+ * @returns
97
+ */
98
+ private getStream;
99
+ /**
100
+ * 无流入会
101
+ *
102
+ * @private
103
+ * @param status
104
+ * @returns
105
+ */
106
+ private dealWithoutStreams;
107
+ /**
108
+ * 获取约束设置
109
+ *
110
+ * @private
111
+ * @param { boolean } video 是否采集视频流
112
+ * @param { boolean } audio 是否采集音频流
113
+ * @param { string } videoDeviceId 摄像头设备ID
114
+ * @param { string } audioDeviceId 麦克风设备ID
115
+ * @param { boolean } isReduceResolution 是否降低分辨率采集, 默认采集720P,降低分辨率则采集360P
116
+ * @returns
117
+ */
82
118
  private getInitContraints;
83
119
  private initStreams;
84
120
  /**
@@ -98,7 +134,7 @@ export default class Stream extends Emmitter {
98
134
  /**
99
135
  * 获取当前时刻音量大小,范围:0-100
100
136
  */
101
- getAudioLevel(stream?: MediaStream): Promise<unknown>;
137
+ getAudioLevel(stream?: MediaStream): Promise<Number>;
102
138
  /**
103
139
  * clear audio object
104
140
  */
@@ -115,7 +151,7 @@ export default class Stream extends Emmitter {
115
151
  *
116
152
  * @param selectedSourceId content stream source id
117
153
  */
118
- createElectronContentStream(selectedSourceId: any): Promise<any>;
154
+ createElectronContentStream(selectedSourceId: any): Promise<IStreamObj[]>;
119
155
  getPreviewStream(isVideo?: boolean, isAudio?: boolean, params?: {
120
156
  video: {};
121
157
  audio: {};
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Video Manager
2
+ * XYLink WebRTC Video Manager Lib
3
3
  *
4
4
  * @summary render video stream
5
5
  * @author jinghui-Luo
6
6
  *
7
7
  * Created at : 2020-12-18 16:54:15
8
- * Last modified : 2021-01-05 14:08:44
8
+ * Last modified : 2022-01-05 17:57:39
9
9
  */
10
10
  import Logger from '../tools/logger';
11
11
  declare class VideoManager {
@@ -29,7 +29,7 @@ declare class VideoManager {
29
29
  * @param key endpoinId + mediagroupId => pid
30
30
  * @param stream MediaStream or null
31
31
  */
32
- initVideoStreamById(key: string, stream: MediaStream | null): Promise<never>;
32
+ initVideoStreamById(key: string, stream: MediaStream | null): void;
33
33
  getVideoTracks(): MediaStreamTrack[];
34
34
  updateLocalTrack(): void;
35
35
  private initVideoSource;
@@ -38,9 +38,9 @@ declare class VideoManager {
38
38
  private removeEventListener;
39
39
  private initStreamTrackEventListener;
40
40
  private removeStreamTrackEventListener;
41
- isHaveSrcObject(): MediaStream | MediaSource | Blob;
42
- setSource(key: string, wrapEleId: string): Promise<never>;
43
- destory(): void;
41
+ isHaveSrcObject(): MediaProvider;
42
+ setSource(key: string, wrapEleId: string): void;
43
+ destroy(): void;
44
44
  setVideoStatusChange(cb: any): void;
45
45
  private onEnded;
46
46
  /**
@@ -4,7 +4,7 @@
4
4
  * @authors Luo-jinghui (luojinghui424@gmail.com)
5
5
  * @date 2019-10-24 14:06:05
6
6
  */
7
- export declare const version = "1.4.1-beta.22 - build on 2021-01-20 20:06";
7
+ export declare const version = "2.0.1-1 - build on 2022-01-27 10:37";
8
8
  export declare const proxy: {
9
9
  wssHost: string;
10
10
  restHost: string;
@@ -24,6 +24,7 @@ export declare const STR_MEETING_DISCONNECT_ENT_CONF_SESSION_EXCEED = "\u6B64\u4
24
24
  export declare const STR_NO_AUTHORITY = "\u6CA1\u6709\u547C\u53EB\u6743\u9650";
25
25
  export declare const STR_KickoutTipContent = "\u60A8\u7684\u8D26\u53F7\u5728\u53E6\u4E00\u5730\u70B9\u767B\u5F55\uFF0C\u60A8\u88AB\u8FEB\u4E0B\u7EBF";
26
26
  export declare const STR_UNSUPPORT_CALL = "\u60A8\u7684\u7EC8\u7AEF\u76EE\u524D\u65E0\u6CD5\u652F\u6301\u6B64\u7C7B\u547C\u53EB";
27
+ export declare const STR_SHARE_CONTENT_FAILED = "\u5206\u4EAB\u5C4F\u5E55\u5931\u8D25";
27
28
  export declare const FailEnumMap: {
28
29
  LOCAL_NET_DISCONNECT: string;
29
30
  SIGNAL_TIMEOUT: string;
@@ -47,6 +48,7 @@ export declare const FailEnumMap: {
47
48
  BUSY: string;
48
49
  PEER_NOT_FOUND: string;
49
50
  STATUS_OK: string;
51
+ OK: string;
50
52
  EXCEPTION_PARAM_ERROR: string;
51
53
  MEETING_DISCONNECT_USER_CONF_SESSION_EXCEED: string;
52
54
  MEETING_DISCONNECT_DEP_CONF_SESSION_EXCEED: string;
@@ -54,4 +56,5 @@ export declare const FailEnumMap: {
54
56
  NO_AUTHORITY: string;
55
57
  KickoutTipContent: string;
56
58
  UNSUPPORT_CALL: string;
59
+ SHARE_CONTENT_FAILED: string;
57
60
  };
@@ -9,4 +9,6 @@ export declare const RATE = 0.5625;
9
9
  export declare const HIDE_POSITION: number[];
10
10
  export declare const SPEAKER_TEMPLATE: ITypeTemplate;
11
11
  export declare const GALLERY_TEMPLATE: ITypeTemplate;
12
+ export declare const COMMON_TEMPLATE: ITemplate;
13
+ export declare const CONTENT_TEMPLATE: ITemplate;
12
14
  export declare const TEMPLATE: ITemplate;
@@ -43,16 +43,10 @@ export declare const getMillTime: () => string;
43
43
  * @param format
44
44
  */
45
45
  export declare const diffTime: (time1: number, time2: number, format?: string) => number;
46
- /**
47
- * Get video real display size and roatate of transform infos
48
- * @param width video real width of reslution
49
- * @param height video real height of reslution
50
- * @param containerHeight display video container size
51
- * @param containerWidth display video container size
52
- * @param rotate video real ratio
53
- */
54
- export declare const getVideoInfoByRotaion: (width: number, height: number, containerHeight: number, containerWidth: number, rotate: number) => {
55
- realWidth: any;
56
- realHeight: any;
57
- realRotate: number;
46
+ export declare const mapToObj: (data: any) => {};
47
+ export declare const getStatus: (code: number, msg: string, detail?: {}) => {
48
+ code: number;
49
+ msg: string;
50
+ detail: {};
58
51
  };
52
+ export declare const getErrorMsg: (err: any) => string;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * WebRTC权限状态
3
+ *
4
+ * @value granted 已授权
5
+ * @value denied 已拒绝
6
+ * @value prompt 询问中
7
+ * @value unknow 未知
8
+ * @value '' 默认
9
+ */
10
+ export declare type TPermissionType = 'granted' | 'denied' | 'prompt' | 'unknow' | 'failed' | '';
11
+ /**
12
+ * 获取设备信息
13
+ *
14
+ * @property { string } deviceId 设备id
15
+ * @property { string } label 设备名称
16
+ * @property { string } groupId 设备分组
17
+ * @property { 'output' | 'input' } direction 设备方向
18
+ * @value output 输出设备
19
+ * @value input 输入设备
20
+ * @property { 'audioinput' | 'audiooutput' | 'videoinput' } kind 设备种类
21
+ * @value audioinput 音频输入
22
+ * @value audiooutput 音频输出
23
+ * @value videoinput 摄像头输入
24
+ * @property { string } type 设备采集流类型:video/audio
25
+ */
26
+ export declare type IDeviceInfo = {
27
+ deviceId: string;
28
+ label: string;
29
+ groupId?: string;
30
+ direction?: 'output' | 'input';
31
+ kind?: 'audioinput' | 'audiooutput' | 'videoinput';
32
+ type?: 'video' | 'audio';
33
+ };
34
+ /**
35
+ * 设备列表:麦克风、扬声器、摄像头
36
+ *
37
+ * @property { IDeviceInfo[] } audioInputList 麦克风列表
38
+ * @property { IDeviceInfo[] } audioOutputList 扬声器列表
39
+ * @property { IDeviceInfo[] } videoInList 摄像头列表
40
+ */
41
+ export declare type IDeviceList = {
42
+ audioInputList: IDeviceInfo[];
43
+ audioOutputList: IDeviceInfo[];
44
+ videoInList: IDeviceInfo[];
45
+ };
46
+ /**
47
+ * 当前已选择设备信息
48
+ *
49
+ * @property { IDeviceInfo | undefined } audioInput 麦克风设备
50
+ * @property { IDeviceInfo | undefined } audioOutput 扬声器设备
51
+ * @property { IDeviceInfo | undefined } videoInput 摄像头设备
52
+ */
53
+ export declare type ISelectedDevice = {
54
+ audioInput: IDeviceInfo | undefined;
55
+ videoInput: IDeviceInfo | undefined;
56
+ audioOutput: IDeviceInfo | undefined;
57
+ };
58
+ /**
59
+ * 设备变化事件
60
+ *
61
+ * @property { ISelectedDevice } nextDevice 最新的设备
62
+ * @property { IDeviceList } detail 最新设备详细信息
63
+ */
64
+ export declare type IDeviceManagerChangeValue = {
65
+ nextDevice: ISelectedDevice;
66
+ detail: IDeviceList;
67
+ };
68
+ /**
69
+ * 当前麦克风/摄像头权限
70
+ *
71
+ * @property { TPermissionType } microphone 麦克风权限
72
+ * @property { TPermissionType } camera 摄像头权限
73
+ */
74
+ export interface ICurrentPermission {
75
+ microphone: TPermissionType;
76
+ camera: TPermissionType;
77
+ }