yjz-web-sdk 1.0.8-beta.1 → 1.0.8-beta.11
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/lib/core/WebRTCSdk.d.ts +34 -13
- package/lib/core/data/MessageType.d.ts +36 -2
- package/lib/core/data/TurnType.d.ts +5 -0
- package/lib/core/data/WebRtcError.d.ts +14 -1
- package/lib/core/data/WebrtcDataType.d.ts +45 -40
- package/lib/core/groupctrl/GroupCtrlSocketManager.d.ts +18 -0
- package/lib/core/groupctrl/SdkController.d.ts +25 -8
- package/lib/core/rtc/WebRTCClient.d.ts +19 -0
- package/lib/core/rtc/WebRTCConfig.d.ts +23 -9
- package/lib/core/rtc/WebRtcNegotiate.d.ts +2 -1
- package/lib/core/signal/SignalingClient.d.ts +11 -8
- package/lib/core/util/FileTypeUtils.d.ts +5 -0
- package/lib/core/util/MapCache.d.ts +20 -0
- package/lib/core/util/TurnTestUtil.d.ts +4 -1
- package/lib/index.d.ts +4 -3
- package/lib/yjz-web-sdk.js +1341 -522
- package/lib/yjz-web-sdk.umd.cjs +92 -82
- package/package.json +1 -1
- package/lib/core/groupctrl/GroupControllerManager.d.ts +0 -29
package/lib/core/WebRTCSdk.d.ts
CHANGED
|
@@ -1,30 +1,50 @@
|
|
|
1
|
-
import { EventEmitter } from
|
|
2
|
-
import { SignalingClient } from
|
|
3
|
-
import { WebRTCClient } from
|
|
4
|
-
import { WebRTCConfig } from
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import { SignalingClient } from './signal/SignalingClient';
|
|
3
|
+
import { WebRTCClient } from './rtc/WebRTCClient';
|
|
4
|
+
import { WebRTCConfig } from './rtc/WebRTCConfig';
|
|
5
5
|
import type { WebRTCConfigOptions } from './rtc/WebRTCConfig';
|
|
6
|
-
import {
|
|
6
|
+
import { ConnectorType } from './data/MessageType';
|
|
7
|
+
import { ChannelDataType } from './data/WebrtcDataType';
|
|
7
8
|
export declare class WebRTCSdk extends EventEmitter {
|
|
8
|
-
config: WebRTCConfig;
|
|
9
|
-
signalingClient: SignalingClient;
|
|
10
|
-
webRTCClient: WebRTCClient;
|
|
9
|
+
config: WebRTCConfig | null;
|
|
10
|
+
signalingClient: SignalingClient | null;
|
|
11
|
+
webRTCClient: WebRTCClient | null;
|
|
12
|
+
options: WebRTCConfigOptions;
|
|
13
|
+
isConnected: boolean;
|
|
14
|
+
isConnecting: boolean;
|
|
15
|
+
private connectCount;
|
|
16
|
+
private MAX_COUNT;
|
|
17
|
+
private timeout;
|
|
18
|
+
private cache;
|
|
11
19
|
constructor(options: WebRTCConfigOptions);
|
|
20
|
+
initConfig(): Promise<void>;
|
|
12
21
|
/** 开始连接 signal 服务 */
|
|
13
22
|
startConnection(): void;
|
|
14
|
-
|
|
23
|
+
private prepareConnection;
|
|
24
|
+
reconnect(): Promise<void>;
|
|
25
|
+
initConnectConfig(initConfig?: boolean): void;
|
|
26
|
+
initSignalingClient(): void;
|
|
27
|
+
switchControl(roomId: string, connectorType: ConnectorType): void;
|
|
28
|
+
updateConfig(options: WebRTCConfigOptions): void;
|
|
29
|
+
switchControlToMain(roomId: string): void;
|
|
30
|
+
resetConfig(): void;
|
|
15
31
|
/** 停止连接,并发送退出信令 */
|
|
16
32
|
stop(): void;
|
|
17
33
|
/** 开始推流:触发媒体采集与轨道添加 */
|
|
18
34
|
startPush(): Promise<void>;
|
|
35
|
+
startPushLocal(file: File): Promise<void>;
|
|
36
|
+
stopPush(): void;
|
|
37
|
+
stopPushLocal(): void;
|
|
19
38
|
/** 发送信道数据 */
|
|
20
39
|
sendChannelData(type: ChannelDataType, data: any): void;
|
|
21
40
|
sendControlEvent(key: number): void;
|
|
22
|
-
|
|
41
|
+
sendGroupAcceptControl(roomIds: string[], acceptControl: boolean): void;
|
|
23
42
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
* 处理 signal 消息,根据不同消息类型分发到 webRTCClient 或直接触发 SDK 事件
|
|
44
|
+
* @param message 信令消息
|
|
45
|
+
*/
|
|
27
46
|
private handleSignaling;
|
|
47
|
+
clearTimer: () => void;
|
|
28
48
|
/** 发送 Offer 信令 */
|
|
29
49
|
sendOffer: (offerSdp: string) => void;
|
|
30
50
|
/** 发送 Answer 信令 */
|
|
@@ -33,4 +53,5 @@ export declare class WebRTCSdk extends EventEmitter {
|
|
|
33
53
|
sendICEMessage: (ice: string) => void;
|
|
34
54
|
sendPong(): void;
|
|
35
55
|
sendSignOut(): void;
|
|
56
|
+
groupSendAction(type: ChannelDataType, data: any): void;
|
|
36
57
|
}
|
|
@@ -9,6 +9,7 @@ export declare enum MessageType {
|
|
|
9
9
|
Pong = "Pong",
|
|
10
10
|
SendScreenshot = "SendScreenshot",
|
|
11
11
|
KickOut = "KickOut",
|
|
12
|
+
GroupPeersMessage = "GroupPeer",
|
|
12
13
|
Error = "Error"
|
|
13
14
|
}
|
|
14
15
|
export declare enum SendType {
|
|
@@ -19,8 +20,41 @@ export declare enum SendType {
|
|
|
19
20
|
IceCandidates = "IceCandidates",
|
|
20
21
|
Pong = "Pong",
|
|
21
22
|
Identity = "Web",
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
SwitchControl = "SwitchControl",
|
|
24
|
+
GroupSignIn = "GroupSignIn",
|
|
25
|
+
GroupSignOut = "GroupSignOut",
|
|
26
|
+
GroupSendAction = "GroupSendAction",
|
|
27
|
+
SwitchControlToMain = "SwitchControlToMain",
|
|
28
|
+
GroupAcceptControl = "GroupAcceptControl"
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 标识自己以什么类型连接云机
|
|
32
|
+
* 内网转发类型中,主从切换由config中mainRoomIdOfGroup, subRoomIdsOfGroup控制
|
|
33
|
+
* 非内网转发类型中,主从切换由config中connectorType控制
|
|
34
|
+
*/
|
|
35
|
+
export declare enum ConnectorType {
|
|
36
|
+
/**
|
|
37
|
+
* 主控类型
|
|
38
|
+
* 页面展示: WebRTC
|
|
39
|
+
* 数据通道: WebRTC dataChannel
|
|
40
|
+
*/
|
|
41
|
+
WebRTC = "webrtc",
|
|
42
|
+
/**
|
|
43
|
+
* 内网转发类型
|
|
44
|
+
* 主控
|
|
45
|
+
* 页面展示: WebRTC
|
|
46
|
+
* 数据通道: WebRTC dataChannel
|
|
47
|
+
* 从控
|
|
48
|
+
* 页面展示: Websocket
|
|
49
|
+
* 数据通道: Websocket
|
|
50
|
+
*/
|
|
51
|
+
LanForwarding = "lanForwarding",
|
|
52
|
+
/**
|
|
53
|
+
* 混合-从控类型
|
|
54
|
+
* 页面展示: Websocket
|
|
55
|
+
* 数据通道: WebRTC dataChannel
|
|
56
|
+
*/
|
|
57
|
+
Hybrid = "hybrid"
|
|
24
58
|
}
|
|
25
59
|
export declare enum IceConnectionState {
|
|
26
60
|
NEW = "new",
|
|
@@ -14,7 +14,9 @@ export declare enum FailCode {
|
|
|
14
14
|
DATACHANNEL_ERR = 10013,
|
|
15
15
|
STREAM_STATE = 10014,
|
|
16
16
|
AUTH_FAILED = 10015,
|
|
17
|
-
KICK_OUT_ERR = 10016
|
|
17
|
+
KICK_OUT_ERR = 10016,
|
|
18
|
+
STATE_ERR = 10017,
|
|
19
|
+
OPTION_ERR = 10018
|
|
18
20
|
}
|
|
19
21
|
export declare const FailInfoMap: Record<FailCode, {
|
|
20
22
|
type: string;
|
|
@@ -26,10 +28,20 @@ export interface WebRtcError {
|
|
|
26
28
|
message: string;
|
|
27
29
|
rawError?: any;
|
|
28
30
|
}
|
|
31
|
+
export declare enum CameraFailCode {
|
|
32
|
+
LOCAL_STREAM_FAIL = 20001,
|
|
33
|
+
CAMERA_STREAM_FAIL = 20002
|
|
34
|
+
}
|
|
29
35
|
export declare function createWebRtcError(code: FailCode, rawError?: any): WebRtcError;
|
|
36
|
+
export declare function createCameraError(code: CameraFailCode, message: string): CameraError;
|
|
37
|
+
export interface CameraError {
|
|
38
|
+
code: CameraFailCode;
|
|
39
|
+
message: string;
|
|
40
|
+
}
|
|
30
41
|
export declare enum EmitType {
|
|
31
42
|
signalMessage = "signalMessage",
|
|
32
43
|
webrtcError = "webrtcError",
|
|
44
|
+
cameraError = "cameraError",
|
|
33
45
|
sendAnswer = "sendAnswer",
|
|
34
46
|
sendOffer = "sendOffer",
|
|
35
47
|
sendICEMessage = "sendICEMessage",
|
|
@@ -39,5 +51,6 @@ export declare enum EmitType {
|
|
|
39
51
|
statisticInfo = "statisticInfo",
|
|
40
52
|
cloudClipData = "cloudClipData",
|
|
41
53
|
screenshot = "screenshot",
|
|
54
|
+
reconnect = "reconnect",
|
|
42
55
|
groupError = "groupError"
|
|
43
56
|
}
|
|
@@ -19,24 +19,24 @@ export declare enum ActionCommandEventValue {
|
|
|
19
19
|
}
|
|
20
20
|
export declare enum ActionCommandType {
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
* 执行云机back
|
|
23
|
+
*/
|
|
24
24
|
ActionBack = "ActionBack",
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
* 执行云机Home
|
|
27
|
+
*/
|
|
28
28
|
ActionHome = "ActionHome",
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
* 执行云机Recent
|
|
31
|
+
*/
|
|
32
32
|
ActionRecent = "ActionRecent",
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
* 切换到虚拟按键模式
|
|
35
|
+
*/
|
|
36
36
|
ActionSwitchNavButtons = "ActionSwitchNavButtons",
|
|
37
37
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
* 切换到手势模式
|
|
39
|
+
*/
|
|
40
40
|
ActionSwitchNavGestural = "ActionSwitchNavGestural"
|
|
41
41
|
}
|
|
42
42
|
export interface ActionCommand {
|
|
@@ -120,54 +120,55 @@ export declare class ClarityData {
|
|
|
120
120
|
export declare class ChannelData {
|
|
121
121
|
type: ChannelDataType;
|
|
122
122
|
data: string | null;
|
|
123
|
-
|
|
123
|
+
myId: string | null;
|
|
124
|
+
constructor(type: ChannelDataType, data?: string | null, myId?: string | null);
|
|
124
125
|
toString(): string;
|
|
125
126
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
* 格式化数据
|
|
128
|
+
* 如果数据已经是字符串,则直接返回;否则使用 JSON.stringify() 转换为字符串
|
|
129
|
+
* @param data 待转换数据
|
|
130
|
+
* @returns 格式化后的字符串
|
|
131
|
+
*/
|
|
131
132
|
private static formatData;
|
|
132
133
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
* 生成点击数据
|
|
135
|
+
* @param touchData 触摸数据,可以是任意类型
|
|
136
|
+
*/
|
|
136
137
|
static click(touchData: any): ChannelData;
|
|
137
138
|
static action(actionData: any): ChannelData;
|
|
138
139
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
* 生成剪贴板数据
|
|
141
|
+
* @param data 剪贴板数据,可以是字符串或其他类型
|
|
142
|
+
*/
|
|
142
143
|
static clipboard(data: any): ChannelData;
|
|
143
144
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
static input(data: any): ChannelData;
|
|
145
|
+
* 生成输入数据
|
|
146
|
+
* @param data 输入数据对象
|
|
147
|
+
*/
|
|
148
|
+
static input(data: any, myId: string): ChannelData;
|
|
148
149
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
* 生成鼠标滚动数据
|
|
151
|
+
* @param data 输入数据对象
|
|
152
|
+
*/
|
|
152
153
|
static wheel(data: any): ChannelData;
|
|
153
154
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
* 切换手势模式数据
|
|
156
|
+
* @param data 输入数据对象
|
|
157
|
+
*/
|
|
157
158
|
static gesture(data: any): ChannelData;
|
|
158
159
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
* 生成中文输入数据
|
|
161
|
+
* @param data 中文输入数据
|
|
162
|
+
*/
|
|
162
163
|
static chinese(data: any): ChannelData;
|
|
163
164
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
* 生成请求云设备信息数据
|
|
166
|
+
*/
|
|
166
167
|
static requestCloudDeviceInfo(): ChannelData;
|
|
167
168
|
/**
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
* 生成清晰度数据(clarity)
|
|
170
|
+
* @param data 清晰度数据
|
|
171
|
+
*/
|
|
171
172
|
static clarity(data: any): ChannelData;
|
|
172
173
|
static switchAudio(data: any): ChannelData;
|
|
173
174
|
static changeSender(data: any): ChannelData;
|
|
@@ -201,3 +202,7 @@ export interface CloudPointer {
|
|
|
201
202
|
action: ActionType;
|
|
202
203
|
offsetTime: number;
|
|
203
204
|
}
|
|
205
|
+
export interface ScreenShotData {
|
|
206
|
+
roomId: string;
|
|
207
|
+
base64: string;
|
|
208
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WebRTCConfigOptions } from '../rtc/WebRTCConfig';
|
|
2
|
+
import type { WebRTCSdk } from '../WebRTCSdk';
|
|
3
|
+
import { ChannelDataType } from '../data/WebrtcDataType';
|
|
4
|
+
export declare class GroupCtrlSocketManager {
|
|
5
|
+
private config?;
|
|
6
|
+
private websocketModeSdkController?;
|
|
7
|
+
private isSynchronous;
|
|
8
|
+
constructor(config: WebRTCConfigOptions);
|
|
9
|
+
getRTCSdk(): WebRTCSdk | undefined;
|
|
10
|
+
startGroupControl(): void;
|
|
11
|
+
stopControl(): void;
|
|
12
|
+
sendData(type: ChannelDataType, data: any): void;
|
|
13
|
+
sendControlEvent(key: number): void;
|
|
14
|
+
switchToMainWebsocketMode(roomId: string): void;
|
|
15
|
+
synchronousOperation(isSynchronous: boolean): void;
|
|
16
|
+
setGroupAcceptControl(roomIds: string[], acceptControl: boolean): void;
|
|
17
|
+
private updateConfig;
|
|
18
|
+
}
|
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
import { EventEmitter } from
|
|
2
|
-
import type { WebRTCConfigOptions } from
|
|
3
|
-
import
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import type { WebRTCConfigOptions } from '../rtc/WebRTCConfig.ts';
|
|
3
|
+
import { WebRTCSdk } from '../WebRTCSdk';
|
|
4
|
+
import type { ChannelDataType } from '../data/WebrtcDataType.ts';
|
|
5
|
+
import type { ConnectorType } from '../data/MessageType';
|
|
4
6
|
export declare class SdkController extends EventEmitter {
|
|
5
|
-
private sdk;
|
|
6
|
-
private config;
|
|
7
|
+
private readonly sdk;
|
|
8
|
+
private readonly config;
|
|
7
9
|
constructor(config: WebRTCConfigOptions);
|
|
8
10
|
private initSdk;
|
|
9
|
-
setIsControl(value: boolean): void;
|
|
10
11
|
start(): void;
|
|
11
12
|
stop(): void;
|
|
12
|
-
switchControl(isControl: boolean): void;
|
|
13
13
|
sendData(type: ChannelDataType, data: any): void;
|
|
14
14
|
sendControlData(key: number): void;
|
|
15
|
-
|
|
15
|
+
groupSendAction(type: ChannelDataType, data: any): void;
|
|
16
|
+
/**
|
|
17
|
+
* rtc群控环境下切换主从, 群控中每个被控者都是一个独立连接(websocket + webrtc)
|
|
18
|
+
* 因此切换主从时每个连接向自己对应的信令服务发送此信令, 信令收到后将switchControl透传给目标roomId的云机.
|
|
19
|
+
*
|
|
20
|
+
* @param roomId 切换目标房间号
|
|
21
|
+
* @param connectorType 切换目标类型
|
|
22
|
+
*/
|
|
23
|
+
switchControl(roomId: string, connectorType: ConnectorType): void;
|
|
24
|
+
updateConfig(options: WebRTCConfigOptions): void;
|
|
25
|
+
/**
|
|
26
|
+
* 内网转发群控环境下切换主从, 群控中主控和所有从控处于同一连接(websocket)
|
|
27
|
+
* 因此切换主从时只需要发送一次此信令, 告诉信令要将哪个房间切换为主控. 信令服务会判断主从关系变化, 然后将switchControl分别发送给本次切换对应的2台云机.
|
|
28
|
+
* @param roomId
|
|
29
|
+
*/
|
|
30
|
+
switchControlToMainMessage(roomId: string): void;
|
|
31
|
+
setGroupAcceptControl(roomIds: string[], acceptControl: boolean): void;
|
|
32
|
+
getRTCSdk(): WebRTCSdk;
|
|
16
33
|
}
|
|
@@ -5,7 +5,9 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
5
5
|
private readonly config;
|
|
6
6
|
private peerConnection;
|
|
7
7
|
private localStream;
|
|
8
|
+
private rotatedStream;
|
|
8
9
|
private isPushingStream;
|
|
10
|
+
private isPushingLocalStream;
|
|
9
11
|
private dataChannel;
|
|
10
12
|
private statsTimer;
|
|
11
13
|
private lastReportTime;
|
|
@@ -15,6 +17,13 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
15
17
|
private lostPacketCount;
|
|
16
18
|
private maxLostRate;
|
|
17
19
|
private lastSecondDecodedCount;
|
|
20
|
+
private fileVideo?;
|
|
21
|
+
private canvas?;
|
|
22
|
+
private canvasStream;
|
|
23
|
+
private rafId;
|
|
24
|
+
private currentMedia;
|
|
25
|
+
private fileImage?;
|
|
26
|
+
private ua;
|
|
18
27
|
constructor(config: WebRTCConfig);
|
|
19
28
|
startPush(): Promise<void>;
|
|
20
29
|
handleOffer(offerSdp: string): void;
|
|
@@ -32,4 +41,14 @@ export declare class WebRTCClient extends EventEmitter {
|
|
|
32
41
|
private checkStats;
|
|
33
42
|
private processStats;
|
|
34
43
|
private getConnectionType;
|
|
44
|
+
/** 获取或创建 video 元素(懒初始化) */
|
|
45
|
+
private getFileVideo;
|
|
46
|
+
/** 获取或创建 canvas 元素(懒初始化) */
|
|
47
|
+
private getCanvas;
|
|
48
|
+
loadMedia(file: File): Promise<void>;
|
|
49
|
+
startPushLocal: (file: File) => Promise<void>;
|
|
50
|
+
startCanvasStream(fps?: number): MediaStream;
|
|
51
|
+
getFileImage(): HTMLImageElement;
|
|
52
|
+
/** 停止推流并释放资源 */
|
|
53
|
+
stopLocal(): void;
|
|
35
54
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConnectorType } from '../data/MessageType';
|
|
1
2
|
export interface WebRTCConfigOptions {
|
|
2
3
|
signalServerUrl: string;
|
|
3
4
|
myId?: string;
|
|
@@ -6,13 +7,9 @@ export interface WebRTCConfigOptions {
|
|
|
6
7
|
stunServerUri?: string;
|
|
7
8
|
stunServerUriAli?: string;
|
|
8
9
|
stunServerUriTel?: string;
|
|
9
|
-
turnServerUri
|
|
10
|
+
turnServerUri?: string;
|
|
10
11
|
turnServerUserName?: string;
|
|
11
12
|
turnServerPassword?: string;
|
|
12
|
-
isControl: boolean;
|
|
13
|
-
screenshotWidth?: number;
|
|
14
|
-
screenshotHeight?: number;
|
|
15
|
-
screenshotQuality?: number;
|
|
16
13
|
canOperate?: boolean;
|
|
17
14
|
screenUrl?: string;
|
|
18
15
|
connectStatus?: number;
|
|
@@ -20,6 +17,19 @@ export interface WebRTCConfigOptions {
|
|
|
20
17
|
token: string;
|
|
21
18
|
isGroup: boolean;
|
|
22
19
|
turnKey?: Array<string>;
|
|
20
|
+
hostTurn?: Array<string>;
|
|
21
|
+
spareTurn?: Array<string>;
|
|
22
|
+
maxRecount?: number;
|
|
23
|
+
isCalculate?: boolean;
|
|
24
|
+
traceId?: string;
|
|
25
|
+
signAgain?: boolean;
|
|
26
|
+
connectorType?: ConnectorType;
|
|
27
|
+
mainRoomIdOfGroup?: string;
|
|
28
|
+
subRoomIdsOfGroup?: string[];
|
|
29
|
+
mainCloudMyId?: string;
|
|
30
|
+
connectorAndRoomId?: Map<string, string>;
|
|
31
|
+
groupId?: string;
|
|
32
|
+
cacheTimeout?: number;
|
|
23
33
|
}
|
|
24
34
|
export declare class WebRTCConfig {
|
|
25
35
|
signalServerUrl: string;
|
|
@@ -32,12 +42,16 @@ export declare class WebRTCConfig {
|
|
|
32
42
|
turnServerUri: string;
|
|
33
43
|
turnServerUserName: string;
|
|
34
44
|
turnServerPassword: string;
|
|
35
|
-
isControl: boolean;
|
|
36
|
-
screenshotWidth: number;
|
|
37
|
-
screenshotHeight: number;
|
|
38
|
-
screenshotQuality: number;
|
|
39
45
|
token: string;
|
|
46
|
+
connectorType: ConnectorType;
|
|
47
|
+
mainRoomIdOfGroup?: string;
|
|
48
|
+
subRoomIdsOfGroup?: string[];
|
|
49
|
+
mainCloudMyId?: string;
|
|
50
|
+
connectorAndRoomId?: Map<string, string>;
|
|
51
|
+
groupId?: string;
|
|
40
52
|
isGroup: boolean;
|
|
41
53
|
turnKey: Array<string>;
|
|
54
|
+
traceId: string;
|
|
55
|
+
signAgain: boolean;
|
|
42
56
|
constructor(options: WebRTCConfigOptions);
|
|
43
57
|
}
|
|
@@ -4,5 +4,6 @@ export declare const setRemoteDescriptionWithHandleOffer: (peerConnection: RTCPe
|
|
|
4
4
|
export declare const createPeerConnection: (config: WebRTCConfig) => RTCPeerConnection;
|
|
5
5
|
export declare const configPeerConnection: (peerConnection: RTCPeerConnection, onICEMessage: (candidate: string) => void, onTrack?: (track: MediaStreamTrack) => void, onConnectState?: (state: RTCIceConnectionState) => void, onError?: (error: WebRtcError) => void) => void;
|
|
6
6
|
export declare const setRemoteDescriptionWithHandleAnswer: (peerConnection: RTCPeerConnection, sdp: string, onError?: (error: WebRtcError) => void) => void;
|
|
7
|
-
export declare const createOffer: (peerConnection: RTCPeerConnection, sendOfferMessage: (sdp: string) => void
|
|
7
|
+
export declare const createOffer: (peerConnection: RTCPeerConnection, sendOfferMessage: (sdp: string) => void) => Promise<void>;
|
|
8
|
+
export declare const setLocalDescriptionWithCreateOffer: (peerConnection: RTCPeerConnection, offer: RTCSessionDescriptionInit, sendOfferMessage: (sdp: string) => void) => Promise<void>;
|
|
8
9
|
export declare const addIceCandidate: (peerConnection: RTCPeerConnection, candidate: RTCIceCandidateInit, onError?: (error: WebRtcError) => void) => void;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { EventEmitter } from
|
|
2
|
-
import type { WebRTCConfig } from
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import type { WebRTCConfig } from '../rtc/WebRTCConfig.ts';
|
|
3
|
+
import { ConnectorType } from '../data/MessageType';
|
|
3
4
|
export declare class SignalingClient extends EventEmitter {
|
|
4
5
|
private config;
|
|
5
6
|
private webSocket;
|
|
7
|
+
private timeout;
|
|
6
8
|
constructor(config: WebRTCConfig);
|
|
7
9
|
/**
|
|
8
10
|
* 启动 WebSocket 连接,并注册各事件处理
|
|
9
11
|
*/
|
|
10
12
|
start(): void;
|
|
13
|
+
timeStart(): void;
|
|
14
|
+
clearTime(): void;
|
|
11
15
|
/**
|
|
12
16
|
* 关闭 WebSocket 连接,并通知外部
|
|
13
17
|
*/
|
|
@@ -18,10 +22,9 @@ export declare class SignalingClient extends EventEmitter {
|
|
|
18
22
|
*/
|
|
19
23
|
sendMessage(message: string): void;
|
|
20
24
|
sendSignInMessage(): void;
|
|
21
|
-
sendSwitchControlMessage(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
sendRequestScreenshot(visible: boolean): void;
|
|
25
|
+
sendSwitchControlMessage(roomId: string, connectorType: ConnectorType): void;
|
|
26
|
+
sendSwitchControlToMainMessage(roomId: string): void;
|
|
27
|
+
sendGroupAcceptControl(roomIds: string[], acceptControl: boolean): void;
|
|
28
|
+
sendGroupAction(action: string): void;
|
|
29
|
+
sendGroupSignInMessage(): void;
|
|
27
30
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class MapCache {
|
|
2
|
+
private key;
|
|
3
|
+
private maxSize;
|
|
4
|
+
private defaultExpire;
|
|
5
|
+
constructor(key: string, maxSize?: number, expireMs?: number);
|
|
6
|
+
/** 从 localStorage 读取 Map(自动清理过期的 item) */
|
|
7
|
+
getMap(): Map<string, any>;
|
|
8
|
+
/** 保存 Map(每个值都有独立的 timestamp/expire) */
|
|
9
|
+
private saveMap;
|
|
10
|
+
/** 设置值(支持单项自定义过期时间) */
|
|
11
|
+
set(key: string, value: any, expireMs?: number): void;
|
|
12
|
+
/** 获取值(单项过期会自动清除) */
|
|
13
|
+
get(key: string): any;
|
|
14
|
+
/** 检查是否存在且未过期 */
|
|
15
|
+
has(key: string): boolean;
|
|
16
|
+
/** 删除 */
|
|
17
|
+
delete(key: string): void;
|
|
18
|
+
/** 清空 */
|
|
19
|
+
clear(): void;
|
|
20
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type { TurnServerConfig, TurnTestResult, TurnTestSummary } from
|
|
1
|
+
import type { TurnSelectionResult, TurnServerConfig, TurnTestResult, TurnTestSummary } from '../data/TurnType.ts';
|
|
2
|
+
import type { WebRTCConfigOptions } from '../rtc/WebRTCConfig.ts';
|
|
2
3
|
export declare const testTurnServer: (turnConfig: TurnServerConfig, timeoutMs?: number) => Promise<TurnTestResult>;
|
|
3
4
|
export declare const testMultipleTurnServers: (servers: string[], timeoutMs?: number) => Promise<TurnTestSummary>;
|
|
5
|
+
export declare const areTurnListsEmpty: (options: WebRTCConfigOptions) => boolean;
|
|
6
|
+
export declare const selectBestTurnServer: (turnList: string[]) => Promise<TurnSelectionResult>;
|
package/lib/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { transformCoordinate, valueToPercentage } from "./core/util/ScreenContro
|
|
|
5
5
|
import { ActionType, ChannelDataType, ContainerDirection, InputData, KeyEventData, TouchData, WheelData, GestureData, type ActionCommand, ActionCommandType, ActionCommandEventType, ActionCommandEventValue, TrackEventData, ClarityData } from "./core/data/WebrtcDataType";
|
|
6
6
|
import { type TurnServerConfig, type TurnTestResult, type TurnTestSummary } from "./core/data/TurnType";
|
|
7
7
|
import type { WebRTCConfigOptions } from './core/rtc/WebRTCConfig';
|
|
8
|
-
import {
|
|
9
|
-
import { EmitType } from "./core/data/WebRtcError";
|
|
8
|
+
import { EmitType, type CameraError, type WebRtcError } from "./core/data/WebRtcError";
|
|
10
9
|
import RemotePlayer from './components/RemotePlayer/index.vue';
|
|
11
|
-
|
|
10
|
+
import { ConnectorType } from './core/data/MessageType';
|
|
11
|
+
import { GroupCtrlSocketManager } from './core/groupctrl/GroupCtrlSocketManager';
|
|
12
|
+
export { WebRTCSdk, getKeyEventData, transformCoordinate, valueToPercentage, ActionType, ChannelDataType, InputData, KeyEventData, TouchData, ContainerDirection, EmitType, WheelData, GestureData, ClarityData, type ActionCommand, ActionCommandType, type WebRTCConfigOptions, ActionCommandEventType, ActionCommandEventValue, RemotePlayer, TrackEventData, type TurnServerConfig, type TurnTestResult, type TurnTestSummary, testMultipleTurnServers, type CameraError, type WebRtcError, ConnectorType, GroupCtrlSocketManager };
|