yjz-web-sdk 1.0.8-beta.9 → 1.0.9-beta.2

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.
Files changed (32) hide show
  1. package/lib/components/RemotePlayer/index.vue.d.ts +71 -1
  2. package/lib/components/RemotePlayer/type.d.ts +25 -0
  3. package/lib/composables/useCursorStyle.d.ts +1 -1
  4. package/lib/composables/useKeyboardControl.d.ts +1 -1
  5. package/lib/composables/useMouseTouchControl.d.ts +5 -4
  6. package/lib/composables/useRemoteVideo.d.ts +25 -8
  7. package/lib/composables/useResizeObserver.d.ts +1 -1
  8. package/lib/core/WebRTCSdk.d.ts +15 -11
  9. package/lib/core/data/MessageType.d.ts +36 -2
  10. package/lib/core/data/WebRtcError.d.ts +3 -1
  11. package/lib/core/data/WebrtcDataType.d.ts +56 -40
  12. package/lib/core/groupctrl/GroupCtrlSocketManager.d.ts +18 -0
  13. package/lib/core/groupctrl/SdkController.d.ts +25 -8
  14. package/lib/core/rtc/WebRTCClient.d.ts +12 -5
  15. package/lib/core/rtc/WebRTCConfig.d.ts +18 -8
  16. package/lib/core/rtc/WebRtcNegotiate.d.ts +2 -2
  17. package/lib/core/signal/SignalingClient.d.ts +8 -8
  18. package/lib/core/util/FileTypeUtils.d.ts +1 -0
  19. package/lib/core/util/Logger.d.ts +20 -0
  20. package/lib/core/util/MapCache.d.ts +20 -0
  21. package/lib/core/util/TurnTestUtil.d.ts +2 -2
  22. package/lib/index.d.ts +3 -2
  23. package/lib/render/Canvas2DRenderer.d.ts +10 -0
  24. package/lib/render/WebGLRenderer.d.ts +16 -0
  25. package/lib/render/WebGPURenderer.d.ts +18 -0
  26. package/lib/util/WasmUtil.d.ts +16 -0
  27. package/lib/worker/myWorker.d.ts +1 -0
  28. package/lib/worker/worker.d.ts +1 -0
  29. package/lib/yjz-web-sdk.js +13803 -894
  30. package/lib/yjz-web-sdk.umd.cjs +937 -93
  31. package/package.json +13 -3
  32. package/lib/core/groupctrl/GroupControllerManager.d.ts +0 -29
@@ -1,2 +1,72 @@
1
- declare const _default: any;
1
+ import type { Dimension } from "./type";
2
+ interface Props {
3
+ streamAngle?: number;
4
+ videoAngle?: number;
5
+ cursorType?: number;
6
+ cloudDeviceSize?: Dimension;
7
+ disabled?: boolean;
8
+ bgColor?: string;
9
+ isGroup?: boolean;
10
+ }
11
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
12
+ streamAngle: number;
13
+ videoAngle: number;
14
+ cursorType: number;
15
+ cloudDeviceSize: () => {
16
+ width: number;
17
+ height: number;
18
+ };
19
+ disabled: boolean;
20
+ bgColor: string;
21
+ isGroup: boolean;
22
+ }>>, {
23
+ startDecode: (arrayBuffer: ArrayBuffer) => void;
24
+ stopPlay: () => void;
25
+ remoteVideoElement: import("vue").Ref<HTMLCanvasElement, HTMLCanvasElement>;
26
+ startPlayTrack: (track: MediaStreamTrack) => void;
27
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
28
+ loadedSuccess: (...args: any[]) => void;
29
+ channelEvent: (...args: any[]) => void;
30
+ groupControlEvent: (...args: any[]) => void;
31
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
32
+ streamAngle: number;
33
+ videoAngle: number;
34
+ cursorType: number;
35
+ cloudDeviceSize: () => {
36
+ width: number;
37
+ height: number;
38
+ };
39
+ disabled: boolean;
40
+ bgColor: string;
41
+ isGroup: boolean;
42
+ }>>> & Readonly<{
43
+ onLoadedSuccess?: (...args: any[]) => any;
44
+ onChannelEvent?: (...args: any[]) => any;
45
+ onGroupControlEvent?: (...args: any[]) => any;
46
+ }>, {
47
+ cloudDeviceSize: Dimension;
48
+ streamAngle: number;
49
+ videoAngle: number;
50
+ isGroup: boolean;
51
+ cursorType: number;
52
+ disabled: boolean;
53
+ bgColor: string;
54
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
55
  export default _default;
56
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
57
+ type __VLS_TypePropsToRuntimeProps<T> = {
58
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
59
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
60
+ } : {
61
+ type: import('vue').PropType<T[K]>;
62
+ required: true;
63
+ };
64
+ };
65
+ type __VLS_WithDefaults<P, D> = {
66
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
67
+ default: D[K];
68
+ }> : P[K];
69
+ };
70
+ type __VLS_Prettify<T> = {
71
+ [K in keyof T]: T[K];
72
+ } & {};
@@ -0,0 +1,25 @@
1
+ export interface Dimension {
2
+ width: number;
3
+ height: number;
4
+ }
5
+ export interface TouchEventData {
6
+ clientX: number;
7
+ clientY: number;
8
+ timeStamp: DOMHighResTimeStamp;
9
+ }
10
+ export type FrameId = bigint;
11
+ export interface PendingFrame {
12
+ width: number;
13
+ height: number;
14
+ label: string;
15
+ totalChunks: number;
16
+ receivedChunks: Set<number>;
17
+ chunks: Map<number, Uint8Array>;
18
+ }
19
+ export interface VideoCFrame {
20
+ frameId: FrameId;
21
+ width: number;
22
+ height: number;
23
+ label: string;
24
+ data: Uint8Array;
25
+ }
@@ -1,2 +1,2 @@
1
1
  import type { Ref } from 'vue';
2
- export default function useCursorStyle(cursorType: Ref<number>): any;
2
+ export default function useCursorStyle(cursorType: Ref<number>): import("vue").ComputedRef<"circle-cursor" | "triangle-cursor" | "default-cursor">;
@@ -1,4 +1,4 @@
1
- import { ChannelDataType } from "../core/data/WebrtcDataType.ts";
1
+ import { ChannelDataType } from "../core/data/WebrtcDataType";
2
2
  import { type Ref } from "vue";
3
3
  export default function useKeyboardControl(disabled: Ref<boolean>, emit: (event: 'channelEvent', payload: ChannelDataType, data: any) => void): {
4
4
  startListening: () => void;
@@ -1,16 +1,17 @@
1
1
  import type { Ref } from 'vue';
2
- import { ChannelDataType } from "../core/data/WebrtcDataType.ts";
3
- import type { Dimension } from "../components/RemotePlayer/index.ts";
2
+ import { ChannelDataType } from "../core/data/WebrtcDataType";
3
+ import type { Dimension } from "../components/RemotePlayer/type";
4
4
  interface MouseTouchControlOptions {
5
- remoteVideoElement: Ref<HTMLVideoElement | null>;
5
+ remoteVideoElement: Ref<HTMLCanvasElement | null>;
6
6
  cloudDeviceSize: Ref<Dimension>;
7
7
  streamAngle: Ref<number>;
8
8
  videoAngle: Ref<number>;
9
9
  widthRadio: Ref<number>;
10
+ isGroup: Ref<boolean>;
10
11
  emit: (event: 'channelEvent', payload: ChannelDataType, data: any) => void;
11
12
  }
12
13
  export default function useMouseTouchControl(options: MouseTouchControlOptions): {
13
- isPointerDown: any;
14
+ isPointerDown: Ref<boolean, boolean>;
14
15
  handleMouseDown: (event: PointerEvent) => void;
15
16
  handleMouseMove: (event: PointerEvent) => void;
16
17
  handleMouseEnter: (event: PointerEvent) => void;
@@ -1,12 +1,29 @@
1
1
  import type { Ref } from 'vue';
2
- export default function useRemoteVideo(videoContainer: Ref<HTMLElement | null>, remoteVideoElement: Ref<HTMLVideoElement | null>, videoAngle: Ref<number>, emit: (event: 'loadedSuccess') => void): {
3
- videoSize: any;
4
- remoteVideo: any;
5
- dimensions: any;
6
- widthRadio: any;
7
- heightRadio: any;
8
- screenStatus: any;
2
+ import { Dimension } from '../components/RemotePlayer/type';
3
+ export default function useRemoteVideo(videoContainer: Ref<HTMLElement | null>, remoteVideoElement: Ref<HTMLCanvasElement | null>, audioElement: Ref<HTMLAudioElement | null>, videoAngle: Ref<number>, emit: (event: 'loadedSuccess') => void): {
4
+ videoSize: import("vue").ComputedRef<{
5
+ width: number;
6
+ height: number;
7
+ }>;
8
+ remoteVideo: Ref<{
9
+ width?: number;
10
+ height?: number;
11
+ }, Partial<Dimension> | {
12
+ width?: number;
13
+ height?: number;
14
+ }>;
15
+ dimensions: Ref<{
16
+ width: number;
17
+ height: number;
18
+ }, Dimension | {
19
+ width: number;
20
+ height: number;
21
+ }>;
22
+ widthRadio: Ref<number, number>;
23
+ heightRadio: Ref<number, number>;
24
+ screenStatus: Ref<boolean, boolean>;
9
25
  initVideoContainer: () => void;
10
- startPlay: (track: MediaStreamTrack) => void;
26
+ startDecode: (arrayBuffer: ArrayBuffer) => void;
11
27
  stopPlay: () => void;
28
+ startPlayTrack: (track: MediaStreamTrack) => void;
12
29
  };
@@ -1,3 +1,3 @@
1
1
  import type { Ref } from 'vue';
2
- import type { Dimension } from "../components/RemotePlayer/index.ts";
2
+ import type { Dimension } from "../components/RemotePlayer/type";
3
3
  export default function useResizeObserver(target: Ref<HTMLElement | null>, dimension: Ref<Dimension>): void;
@@ -1,9 +1,10 @@
1
- import { EventEmitter } from "eventemitter3";
2
- import { SignalingClient } from "./signal/SignalingClient.ts";
3
- import { WebRTCClient } from "./rtc/WebRTCClient.ts";
4
- import { WebRTCConfig } from "./rtc/WebRTCConfig.ts";
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import { SignalingClient } from './signal/SignalingClient';
3
+ import { WebRTCClient } from './rtc/WebRTCClient';
5
4
  import type { WebRTCConfigOptions } from './rtc/WebRTCConfig';
6
- import { ChannelDataType } from "./data/WebrtcDataType.ts";
5
+ import { WebRTCConfig } from './rtc/WebRTCConfig';
6
+ import { ConnectorType } from './data/MessageType';
7
+ import { ChannelDataType } from './data/WebrtcDataType';
7
8
  export declare class WebRTCSdk extends EventEmitter {
8
9
  config: WebRTCConfig | null;
9
10
  signalingClient: SignalingClient | null;
@@ -20,9 +21,11 @@ export declare class WebRTCSdk extends EventEmitter {
20
21
  startConnection(): void;
21
22
  private prepareConnection;
22
23
  reconnect(): Promise<void>;
23
- initConnectConfig(): void;
24
+ initConnectConfig(initConfig?: boolean): void;
24
25
  initSignalingClient(): void;
25
- switchControl(isControl: boolean): void;
26
+ switchControl(roomId: string, connectorType: ConnectorType): void;
27
+ updateConfig(options: WebRTCConfigOptions): void;
28
+ switchControlToMain(roomId: string): void;
26
29
  resetConfig(): void;
27
30
  /** 停止连接,并发送退出信令 */
28
31
  stop(): void;
@@ -34,11 +37,11 @@ export declare class WebRTCSdk extends EventEmitter {
34
37
  /** 发送信道数据 */
35
38
  sendChannelData(type: ChannelDataType, data: any): void;
36
39
  sendControlEvent(key: number): void;
37
- sendRequestScreenshot(visible: boolean): void;
40
+ sendGroupAcceptControl(roomIds: string[], acceptControl: boolean): void;
38
41
  /**
39
- * 处理 signal 消息,根据不同消息类型分发到 webRTCClient 或直接触发 SDK 事件
40
- * @param message 信令消息
41
- */
42
+ * 处理 signal 消息,根据不同消息类型分发到 webRTCClient 或直接触发 SDK 事件
43
+ * @param message 信令消息
44
+ */
42
45
  private handleSignaling;
43
46
  clearTimer: () => void;
44
47
  /** 发送 Offer 信令 */
@@ -49,4 +52,5 @@ export declare class WebRTCSdk extends EventEmitter {
49
52
  sendICEMessage: (ice: string) => void;
50
53
  sendPong(): void;
51
54
  sendSignOut(): void;
55
+ groupSendAction(type: ChannelDataType, data: any): void;
52
56
  }
@@ -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
- RequestScreenshot = "RequestScreenshot",
23
- SwitchControl = "SwitchControl"
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",
@@ -51,6 +51,8 @@ export declare enum EmitType {
51
51
  statisticInfo = "statisticInfo",
52
52
  cloudClipData = "cloudClipData",
53
53
  screenshot = "screenshot",
54
+ reconnect = "reconnect",
54
55
  groupError = "groupError",
55
- reconnect = "reconnect"
56
+ videoFrame = "videoFrame",
57
+ arrayBuffer = "arrayBuffer"
56
58
  }
@@ -11,7 +11,8 @@ export declare enum ChannelDataType {
11
11
  ActionCommandEvent = "ActionCommandEvent",
12
12
  ActionUpdateCloudStatus = "ActionUpdateCloudStatus",
13
13
  ActionGesture = "ActionGesture",
14
- ActionTrack = "ActionTrack"
14
+ ActionTrack = "ActionTrack",
15
+ RequestKeyFrame = "RequestKeyFrame"
15
16
  }
16
17
  export declare enum ActionCommandEventValue {
17
18
  ENABLE = "ENABLE",
@@ -19,24 +20,24 @@ export declare enum ActionCommandEventValue {
19
20
  }
20
21
  export declare enum ActionCommandType {
21
22
  /**
22
- * 执行云机back
23
- */
23
+ * 执行云机back
24
+ */
24
25
  ActionBack = "ActionBack",
25
26
  /**
26
- * 执行云机Home
27
- */
27
+ * 执行云机Home
28
+ */
28
29
  ActionHome = "ActionHome",
29
30
  /**
30
- * 执行云机Recent
31
- */
31
+ * 执行云机Recent
32
+ */
32
33
  ActionRecent = "ActionRecent",
33
34
  /**
34
- * 切换到虚拟按键模式
35
- */
35
+ * 切换到虚拟按键模式
36
+ */
36
37
  ActionSwitchNavButtons = "ActionSwitchNavButtons",
37
38
  /**
38
- * 切换到手势模式
39
- */
39
+ * 切换到手势模式
40
+ */
40
41
  ActionSwitchNavGestural = "ActionSwitchNavGestural"
41
42
  }
42
43
  export interface ActionCommand {
@@ -78,7 +79,9 @@ export declare class TouchData {
78
79
  y: number;
79
80
  offsetTime: number;
80
81
  type: string;
81
- constructor(action: ActionType, p: number, x: number, y: number, offsetTime: number, type?: string);
82
+ index: number;
83
+ groupIndex: number;
84
+ constructor(action: ActionType, p: number, x: number, y: number, offsetTime: number, type?: string, index?: number, groupIndex?: number);
82
85
  }
83
86
  /**
84
87
  * InputData - 文本输入数据类
@@ -124,54 +127,55 @@ export declare class ChannelData {
124
127
  constructor(type: ChannelDataType, data?: string | null, myId?: string | null);
125
128
  toString(): string;
126
129
  /**
127
- * 格式化数据
128
- * 如果数据已经是字符串,则直接返回;否则使用 JSON.stringify() 转换为字符串
129
- * @param data 待转换数据
130
- * @returns 格式化后的字符串
131
- */
130
+ * 格式化数据
131
+ * 如果数据已经是字符串,则直接返回;否则使用 JSON.stringify() 转换为字符串
132
+ * @param data 待转换数据
133
+ * @returns 格式化后的字符串
134
+ */
132
135
  private static formatData;
133
136
  /**
134
- * 生成点击数据
135
- * @param touchData 触摸数据,可以是任意类型
136
- */
137
+ * 生成点击数据
138
+ * @param touchData 触摸数据,可以是任意类型
139
+ */
137
140
  static click(touchData: any): ChannelData;
138
141
  static action(actionData: any): ChannelData;
139
142
  /**
140
- * 生成剪贴板数据
141
- * @param data 剪贴板数据,可以是字符串或其他类型
142
- */
143
+ * 生成剪贴板数据
144
+ * @param data 剪贴板数据,可以是字符串或其他类型
145
+ */
143
146
  static clipboard(data: any): ChannelData;
144
147
  /**
145
- * 生成输入数据
146
- * @param data 输入数据对象
147
- */
148
+ * 生成输入数据
149
+ * @param data 输入数据对象
150
+ */
148
151
  static input(data: any, myId: string): ChannelData;
149
152
  /**
150
- * 生成鼠标滚动数据
151
- * @param data 输入数据对象
152
- */
153
+ * 生成鼠标滚动数据
154
+ * @param data 输入数据对象
155
+ */
153
156
  static wheel(data: any): ChannelData;
154
157
  /**
155
- * 切换手势模式数据
156
- * @param data 输入数据对象
157
- */
158
+ * 切换手势模式数据
159
+ * @param data 输入数据对象
160
+ */
158
161
  static gesture(data: any): ChannelData;
159
162
  /**
160
- * 生成中文输入数据
161
- * @param data 中文输入数据
162
- */
163
+ * 生成中文输入数据
164
+ * @param data 中文输入数据
165
+ */
163
166
  static chinese(data: any): ChannelData;
164
167
  /**
165
- * 生成请求云设备信息数据
166
- */
168
+ * 生成请求云设备信息数据
169
+ */
167
170
  static requestCloudDeviceInfo(): ChannelData;
168
171
  /**
169
- * 生成清晰度数据(clarity)
170
- * @param data 清晰度数据
171
- */
172
+ * 生成清晰度数据(clarity)
173
+ * @param data 清晰度数据
174
+ */
172
175
  static clarity(data: any): ChannelData;
173
176
  static switchAudio(data: any): ChannelData;
174
177
  static changeSender(data: any): ChannelData;
178
+ static requestKeyFrame(data: any): ChannelData;
175
179
  }
176
180
  export interface RTCStatsReportExtended extends RTCStatsReport {
177
181
  get(id: string): RTCStats | undefined;
@@ -202,3 +206,15 @@ export interface CloudPointer {
202
206
  action: ActionType;
203
207
  offsetTime: number;
204
208
  }
209
+ export interface ScreenShotData {
210
+ roomId: string;
211
+ base64: string;
212
+ }
213
+ export declare class BitReader {
214
+ private data;
215
+ private byteOffset;
216
+ private bitOffset;
217
+ constructor(data: Uint8Array);
218
+ readBits(count: number): number;
219
+ readUEG(): number;
220
+ }
@@ -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 "eventemitter3";
2
- import type { WebRTCConfigOptions } from "../rtc/WebRTCConfig.ts";
3
- import type { ChannelDataType } from "../data/WebrtcDataType.ts";
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import type { WebRTCConfigOptions } from '../rtc/WebRTCConfig';
3
+ import { WebRTCSdk } from '../WebRTCSdk';
4
+ import type { ChannelDataType } from '../data/WebrtcDataType';
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
- requestScreenshot(visible: boolean): void;
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
  }
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
- import type { WebRTCConfig } from "./WebRTCConfig.ts";
3
- import { ChannelDataType } from "../data/WebrtcDataType.ts";
2
+ import type { WebRTCConfig } from "./WebRTCConfig";
3
+ import { ChannelDataType } from "../data/WebrtcDataType";
4
4
  export declare class WebRTCClient extends EventEmitter {
5
5
  private readonly config;
6
6
  private peerConnection;
@@ -9,6 +9,7 @@ export declare class WebRTCClient extends EventEmitter {
9
9
  private isPushingStream;
10
10
  private isPushingLocalStream;
11
11
  private dataChannel;
12
+ private videoDataChannel;
12
13
  private statsTimer;
13
14
  private lastReportTime;
14
15
  private lastBytesReceived;
@@ -23,22 +24,28 @@ export declare class WebRTCClient extends EventEmitter {
23
24
  private rafId;
24
25
  private currentMedia;
25
26
  private fileImage?;
27
+ private isFirst;
26
28
  constructor(config: WebRTCConfig);
27
- startPush(): Promise<void>;
29
+ startPush(useBackCamera?: boolean): Promise<void>;
28
30
  handleOffer(offerSdp: string): void;
29
31
  handleAnswer(answerSdp: string): void;
30
32
  handleIceCandidate(candidate: RTCIceCandidateInit): void;
31
33
  sendChannelData(type: ChannelDataType, data: any): void;
32
34
  closeConnection(): void;
33
- readyCapture(): Promise<void>;
35
+ readyCapture(useBackCamera: boolean): Promise<void>;
36
+ /**
37
+ * ✅ 切换前后摄像头(无缝)
38
+ */
39
+ switchCamera(useBackCamera: boolean): Promise<void>;
34
40
  private getRotatedStream;
35
41
  private setVideoParams;
36
42
  stopPush(): void;
37
43
  private resetPeerConnection;
38
44
  private configDataChannel;
45
+ private handleVideoChannelMessage;
39
46
  private handleDataChannelMessage;
40
47
  private checkStats;
41
- private processStats;
48
+ private processStatsOptimized;
42
49
  private getConnectionType;
43
50
  /** 获取或创建 video 元素(懒初始化) */
44
51
  private getFileVideo;
@@ -1,3 +1,5 @@
1
+ import { ConnectorType } from '../data/MessageType';
2
+ import { LogLevel } from "../util/Logger";
1
3
  export interface WebRTCConfigOptions {
2
4
  signalServerUrl: string;
3
5
  myId?: string;
@@ -9,10 +11,6 @@ export interface WebRTCConfigOptions {
9
11
  turnServerUri?: string;
10
12
  turnServerUserName?: string;
11
13
  turnServerPassword?: string;
12
- isControl: boolean;
13
- screenshotWidth?: number;
14
- screenshotHeight?: number;
15
- screenshotQuality?: number;
16
14
  canOperate?: boolean;
17
15
  screenUrl?: string;
18
16
  connectStatus?: number;
@@ -26,6 +24,15 @@ export interface WebRTCConfigOptions {
26
24
  isCalculate?: boolean;
27
25
  traceId?: string;
28
26
  signAgain?: boolean;
27
+ connectorType?: ConnectorType;
28
+ mainRoomIdOfGroup?: string;
29
+ subRoomIdsOfGroup?: string[];
30
+ mainCloudMyId?: string;
31
+ connectorAndRoomId?: Map<string, string>;
32
+ groupId?: string;
33
+ cacheTimeout?: number;
34
+ enableLogger?: boolean;
35
+ loggerLevel?: LogLevel;
29
36
  }
30
37
  export declare class WebRTCConfig {
31
38
  signalServerUrl: string;
@@ -38,13 +45,16 @@ export declare class WebRTCConfig {
38
45
  turnServerUri: string;
39
46
  turnServerUserName: string;
40
47
  turnServerPassword: string;
41
- isControl: boolean;
42
- screenshotWidth: number;
43
- screenshotHeight: number;
44
- screenshotQuality: number;
45
48
  token: string;
49
+ connectorType: ConnectorType;
50
+ mainRoomIdOfGroup?: string;
51
+ subRoomIdsOfGroup?: string[];
52
+ mainCloudMyId?: string;
53
+ connectorAndRoomId?: Map<string, string>;
54
+ groupId?: string;
46
55
  isGroup: boolean;
47
56
  turnKey: Array<string>;
48
57
  traceId: string;
58
+ signAgain: boolean;
49
59
  constructor(options: WebRTCConfigOptions);
50
60
  }
@@ -1,5 +1,5 @@
1
- import { type WebRtcError } from "../data/WebRtcError.ts";
2
- import { WebRTCConfig } from "./WebRTCConfig.ts";
1
+ import { type WebRtcError } from "../data/WebRtcError";
2
+ import { WebRTCConfig } from "./WebRTCConfig";
3
3
  export declare const setRemoteDescriptionWithHandleOffer: (peerConnection: RTCPeerConnection, sdp: string, sendAnswer?: (sdp: string) => void, onError?: (err: WebRtcError) => void) => void;
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;
@@ -1,5 +1,6 @@
1
- import { EventEmitter } from "eventemitter3";
2
- import type { WebRTCConfig } from "../rtc/WebRTCConfig.ts";
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import type { WebRTCConfig } from '../rtc/WebRTCConfig';
3
+ import { ConnectorType } from '../data/MessageType';
3
4
  export declare class SignalingClient extends EventEmitter {
4
5
  private config;
5
6
  private webSocket;
@@ -21,10 +22,9 @@ export declare class SignalingClient extends EventEmitter {
21
22
  */
22
23
  sendMessage(message: string): void;
23
24
  sendSignInMessage(): void;
24
- sendSwitchControlMessage(isCtrl: boolean): void;
25
- /**
26
- * 用于从控请求当前截屏
27
- * @param visible 当前从控page控件是否可见
28
- */
29
- 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;
30
30
  }
@@ -3,3 +3,4 @@ export declare class FileTypeUtils {
3
3
  /** 读取文件头并判断类型 */
4
4
  static detectFileType(file: File): Promise<FileKind>;
5
5
  }
6
+ export declare const formattedTime: (timestamp: number) => string;