@realsee/live 0.7.1 → 0.7.3-alpha.0
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/README.md +5 -3
- package/dist/index.cjs.js +3 -41
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +5 -1336
- package/dist/index.es.js +6169 -0
- package/dist/index.es.js.map +1 -0
- package/dist/live/controller.d.ts +118 -0
- package/dist/live/createLive.d.ts +8 -0
- package/dist/live/createLiveReact.d.ts +54 -0
- package/dist/live/live.d.ts +200 -0
- package/dist/rtc/BrowserRTC.d.ts +39 -0
- package/dist/rtc/BrowserRTC4Chime.d.ts +60 -0
- package/dist/rtc/CoreRTC.d.ts +23 -0
- package/dist/rtc/VRWebViewRTC.d.ts +97 -0
- package/dist/rtc/index.d.ts +5 -0
- package/dist/typings/chime/AttendeeResponse.d.ts +5 -0
- package/dist/typings/chime/MeetingResponse.d.ts +12 -0
- package/dist/typings/chime/MeetingSessionConfigurationOptions.d.ts +16 -0
- package/dist/typings/chime/index.d.ts +3 -0
- package/dist/typings/index.d.ts +4 -0
- package/dist/typings/live/EventType.d.ts +74 -0
- package/dist/typings/live/GetVoiceSign.d.ts +52 -0
- package/dist/typings/live/LiveConnectOptions.d.ts +24 -0
- package/dist/typings/live/LiveErrorType.d.ts +9 -0
- package/dist/typings/live/LiveMsg.d.ts +133 -0
- package/dist/typings/live/LiveOptions.d.ts +79 -0
- package/dist/typings/live/LiveState.d.ts +15 -0
- package/dist/typings/live/RoomInfo.d.ts +13 -0
- package/dist/typings/live/UserInfo.d.ts +103 -0
- package/dist/typings/live/UserVolume.d.ts +7 -0
- package/dist/typings/live/WebSocket.d.ts +82 -0
- package/dist/typings/live/index.d.ts +10 -0
- package/dist/typings/react/RTCActionReactCallback.d.ts +2 -0
- package/dist/typings/react/index.d.ts +1 -0
- package/dist/typings/rtc/VRWebViewRTCOptions.d.ts +6 -0
- package/dist/typings/rtc/eventType.d.ts +44 -0
- package/dist/typings/rtc/index.d.ts +5 -0
- package/dist/typings/rtc/joinedInfo.d.ts +38 -0
- package/dist/typings/rtc/protocol.d.ts +77 -0
- package/dist/typings/rtc/type.d.ts +12 -0
- package/dist/utils/RobustWebSocket.d.ts +160 -0
- package/dist/utils/appendUri.d.ts +1 -0
- package/dist/utils/clientDetector.d.ts +4 -0
- package/dist/utils/equal.d.ts +10 -0
- package/dist/utils/isServer.d.ts +5 -0
- package/dist/utils/logger.d.ts +19 -0
- package/dist/utils/subscribe.d.ts +75 -0
- package/dist/utils/uuid.d.ts +4 -0
- package/docs/README.md +5 -3
- package/docs/classes/BrowserRTC.md +2 -2
- package/docs/classes/BrowserRTC4Chime.md +1 -1
- package/docs/classes/CoreRTC.md +8 -8
- package/docs/classes/Live.md +30 -57
- package/docs/classes/VRWebViewRTC.md +1 -1
- package/docs/functions/clearLiveInstanceIfNeed.md +1 -1
- package/docs/globals.md +0 -6
- package/docs/interfaces/RTCProtocol.md +7 -7
- package/docs/type-aliases/LiveBuiltInData.md +1 -1
- package/package.json +16 -21
- package/dist/index.d.cts +0 -1336
- package/dist/index.esm.js +0 -10
- package/docs/classes/Subscribe.md +0 -211
- package/docs/namespaces/SubscribeMixinType/README.md +0 -17
- package/docs/namespaces/SubscribeMixinType/interfaces/emit.md +0 -31
- package/docs/namespaces/SubscribeMixinType/interfaces/hasListener.md +0 -25
- package/docs/namespaces/SubscribeMixinType/interfaces/off.md +0 -31
- package/docs/namespaces/SubscribeMixinType/interfaces/on.md +0 -37
- package/docs/namespaces/SubscribeMixinType/interfaces/once.md +0 -35
- package/docs/type-aliases/EventMap.md +0 -17
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { LiveMsg } from '../typings';
|
|
2
|
+
import { LiveState } from '../typings/live/LiveState';
|
|
3
|
+
import { RobustWebSocketEventDetail } from '../utils/RobustWebSocket';
|
|
4
|
+
import { Subscribe } from '../utils/subscribe';
|
|
5
|
+
/**
|
|
6
|
+
* 带看控制器事件映射
|
|
7
|
+
*/
|
|
8
|
+
export type LiveControllerEventMap = {
|
|
9
|
+
/**
|
|
10
|
+
* 带看状态变更
|
|
11
|
+
* @param state
|
|
12
|
+
* @param prevState
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
stateChange: (state: LiveState, prevState: LiveState) => void;
|
|
16
|
+
/**
|
|
17
|
+
* 接收到带看消息
|
|
18
|
+
* @param message
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
message: (message: LiveMsg) => void;
|
|
22
|
+
/**
|
|
23
|
+
* 带看重连中
|
|
24
|
+
* @param detail
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
reconnecting: (detail: RobustWebSocketEventDetail) => void;
|
|
28
|
+
/**
|
|
29
|
+
* 带看重连成功
|
|
30
|
+
* @param detail
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
reconnected: (detail: RobustWebSocketEventDetail) => void;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* 带看控制器
|
|
37
|
+
*/
|
|
38
|
+
export declare class LiveController extends Subscribe<LiveControllerEventMap> {
|
|
39
|
+
/**
|
|
40
|
+
* ws代理器
|
|
41
|
+
*/
|
|
42
|
+
private _ws;
|
|
43
|
+
/**
|
|
44
|
+
* 带看连接状态
|
|
45
|
+
*/
|
|
46
|
+
private _state;
|
|
47
|
+
set state(state: LiveState);
|
|
48
|
+
get state(): LiveState;
|
|
49
|
+
constructor();
|
|
50
|
+
/**
|
|
51
|
+
* 添加事件监听
|
|
52
|
+
*/
|
|
53
|
+
private _addWebSocketEventListeners;
|
|
54
|
+
/**
|
|
55
|
+
* 移除事件监听
|
|
56
|
+
*/
|
|
57
|
+
private _removeWebSocketEventListeners;
|
|
58
|
+
/**
|
|
59
|
+
* 处理房间关闭事件
|
|
60
|
+
* @param event
|
|
61
|
+
*/
|
|
62
|
+
private _handleCloseEvent;
|
|
63
|
+
/**
|
|
64
|
+
* 处理房间正在关闭事件(这个时候可能是断网了)
|
|
65
|
+
*/
|
|
66
|
+
private _handleClosingEvent;
|
|
67
|
+
/**
|
|
68
|
+
* 连接中
|
|
69
|
+
* @param event
|
|
70
|
+
*/
|
|
71
|
+
private _handleConnectingEvent;
|
|
72
|
+
/**
|
|
73
|
+
* 连接发送异常
|
|
74
|
+
* @param event
|
|
75
|
+
*/
|
|
76
|
+
private _handleErrorEvent;
|
|
77
|
+
/**
|
|
78
|
+
* 接收到消息
|
|
79
|
+
* @param event
|
|
80
|
+
*/
|
|
81
|
+
private _handleMessageEvent;
|
|
82
|
+
/**
|
|
83
|
+
* 连接建立成功
|
|
84
|
+
* @param event
|
|
85
|
+
*/
|
|
86
|
+
private _handleOpenEvent;
|
|
87
|
+
/**
|
|
88
|
+
* 处理超时
|
|
89
|
+
* @param event
|
|
90
|
+
*/
|
|
91
|
+
private _handleTimeoutEvent;
|
|
92
|
+
/**
|
|
93
|
+
* 释放资源,释放之后需要重新实例化
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
dispose: () => Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* 开启房间链接
|
|
99
|
+
* @param url 房间链接
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
open: (url: string) => void;
|
|
103
|
+
/**
|
|
104
|
+
* 关闭房间
|
|
105
|
+
* @param code
|
|
106
|
+
* @param reason
|
|
107
|
+
*/
|
|
108
|
+
close: (code?: string | number | undefined, reason?: string | undefined) => Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* 发送数据
|
|
111
|
+
* @param data
|
|
112
|
+
*/
|
|
113
|
+
sendMessage: (data?: any) => void | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* 准备关闭带看
|
|
116
|
+
*/
|
|
117
|
+
readyClose: () => void;
|
|
118
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LiveOptions } from '../typings/live/LiveOptions';
|
|
2
|
+
import { Live } from './live';
|
|
3
|
+
/**
|
|
4
|
+
* 创建`Live`实例
|
|
5
|
+
* @param opts
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const createLive: <KeyframesSnapshot extends Record<string, any>>(opts: LiveOptions) => Live<KeyframesSnapshot>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { BuiltinActionType, BuiltinEventType, KeyframeEventType, LiveConnectOptions, LiveEventType, LiveOptions, MicroStatus, RTCEventType, RTCType, UserInfo } from '../typings';
|
|
3
|
+
import { LiveState } from '../typings/live/LiveState';
|
|
4
|
+
import { Live } from './live';
|
|
5
|
+
export type LiveProviderPropTypes<KeyframesSnapshot extends Record<string, any>> = {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
live?: Live<KeyframesSnapshot>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 创建 LiveReact 实例,并提供 `React` 技术栈相关工具链。
|
|
11
|
+
* @param options 带看配置
|
|
12
|
+
* @returns 返回当前的带看上下文实例
|
|
13
|
+
*/
|
|
14
|
+
export declare function createLiveReact<KeyframesSnapshot extends Record<string, any>>(options: LiveOptions): {
|
|
15
|
+
live: Live<KeyframesSnapshot>;
|
|
16
|
+
jsBridge: import('@realsee/jsbridge-x').JSBridgeProtocol;
|
|
17
|
+
LiveProvider: (props: LiveProviderPropTypes<KeyframesSnapshot>) => React.FunctionComponentElement<React.ProviderProps<Live<KeyframesSnapshot> | null>>;
|
|
18
|
+
unsafe__useLiveInstance: () => Live<KeyframesSnapshot>;
|
|
19
|
+
unsafe__useRTCInstance: () => import('../typings').RTCProtocol;
|
|
20
|
+
useConnect: () => (options: LiveConnectOptions) => Promise<true | Error>;
|
|
21
|
+
useKeyframe: <K extends keyof KeyframesSnapshot>(key: K) => (KeyframesSnapshot[K] | ((frame: KeyframesSnapshot[K]) => boolean | Error) | undefined)[];
|
|
22
|
+
useKeyframeUpdateCallback: <KeyOfKeyframe extends keyof KeyframeEventType<KeyframesSnapshot>>(key: KeyOfKeyframe, callback: (...args: Parameters<KeyframeEventType<KeyframesSnapshot>[KeyOfKeyframe]>) => ReturnType<KeyframeEventType<KeyframesSnapshot>[KeyOfKeyframe]>, deps?: React.DependencyList) => () => void;
|
|
23
|
+
useLiveAction: () => {
|
|
24
|
+
connect: (options: LiveConnectOptions) => Promise<void>;
|
|
25
|
+
broadcast: (data: Record<string, any>, toUserIds: string | string[], timeout?: number) => Promise<void>;
|
|
26
|
+
exit: () => Promise<void>;
|
|
27
|
+
kick: (toUserIds: string | string[]) => Promise<void>;
|
|
28
|
+
toggleMicro: (microStatus: boolean) => void;
|
|
29
|
+
forbidMicro: (micro: MicroStatus, toUserIds?: string | string[]) => Promise<void>;
|
|
30
|
+
forbidSync: (sync: boolean, toUserIds?: string | string[]) => void;
|
|
31
|
+
sendKeyframe: (key: keyof KeyframesSnapshot, frame: KeyframesSnapshot[keyof KeyframesSnapshot]) => void;
|
|
32
|
+
getFramesByKey: (key: keyof KeyframesSnapshot) => Partial<KeyframesSnapshot>[keyof KeyframesSnapshot] | undefined;
|
|
33
|
+
setSelfInfo: (userInfo: Partial<UserInfo>) => void;
|
|
34
|
+
updateStatus: (evtType: BuiltinEventType, atnType: BuiltinActionType, status: Record<string, any>, toUserIds?: string | string[]) => void;
|
|
35
|
+
};
|
|
36
|
+
useLiveEventCallback: <K extends keyof LiveEventType<KeyframesSnapshot>>(name: K, callback: (...args: Parameters<LiveEventType<KeyframesSnapshot>[K]>) => ReturnType<LiveEventType<KeyframesSnapshot>[K]>, deps?: React.DependencyList) => () => void;
|
|
37
|
+
useLiveState: () => LiveState;
|
|
38
|
+
useRTCAction: () => {
|
|
39
|
+
join: (options: {
|
|
40
|
+
voiceId: string;
|
|
41
|
+
userId: string;
|
|
42
|
+
roomId: string;
|
|
43
|
+
type: RTCType;
|
|
44
|
+
}) => Promise<boolean>;
|
|
45
|
+
quit: () => Promise<boolean>;
|
|
46
|
+
shock: () => void | undefined;
|
|
47
|
+
toggleMicro: (flag?: boolean | undefined) => Promise<boolean>;
|
|
48
|
+
detectMicro: () => Promise<boolean>;
|
|
49
|
+
};
|
|
50
|
+
useRTCEventCallback: <K extends keyof RTCEventType>(name: K, callback: (...args: Parameters<RTCEventType[K]>) => ReturnType<RTCEventType[K]>, deps?: React.DependencyList) => () => void;
|
|
51
|
+
useSelfInfo: () => (Partial<UserInfo> | ((userInfo: Partial<UserInfo>) => Promise<boolean>))[];
|
|
52
|
+
useKeyframesSnapshot: () => Partial<KeyframesSnapshot>;
|
|
53
|
+
useUserList: () => UserInfo[];
|
|
54
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { JSBridgeProtocol } from '@realsee/jsbridge-x';
|
|
2
|
+
import { RTCProtocol } from '../rtc';
|
|
3
|
+
import { EventType, KeyframeEventType, LiveOptions, RoomInfo, RTCType, UserInfo, BuiltinEventType, BuiltinActionType, MicroStatus, LiveConnectOptions } from '../typings';
|
|
4
|
+
import { LiveState } from '../typings/live/LiveState';
|
|
5
|
+
import { Subscribe } from '../utils/subscribe';
|
|
6
|
+
import * as Y from 'yjs';
|
|
7
|
+
export type LiveBuiltInData<KeyframesSnapshot> = {
|
|
8
|
+
selfInfo?: UserInfo;
|
|
9
|
+
userList?: UserInfo[];
|
|
10
|
+
roomInfo?: RoomInfo;
|
|
11
|
+
rtcInfo?: {
|
|
12
|
+
voiceId: string;
|
|
13
|
+
type: RTCType;
|
|
14
|
+
};
|
|
15
|
+
keyframes: Y.Map<KeyframesSnapshot>;
|
|
16
|
+
};
|
|
17
|
+
export declare const _clearLiveInstanceIfNeed: () => void;
|
|
18
|
+
export declare class Live<KeyframesSnapshot extends Record<string, any>> extends Subscribe<EventType<KeyframesSnapshot>> {
|
|
19
|
+
/**
|
|
20
|
+
* 带看的配置选项
|
|
21
|
+
*/
|
|
22
|
+
private _options;
|
|
23
|
+
get options(): LiveOptions;
|
|
24
|
+
/**
|
|
25
|
+
* 带看状态
|
|
26
|
+
*/
|
|
27
|
+
get state(): LiveState;
|
|
28
|
+
/**
|
|
29
|
+
* 兼容老逻辑
|
|
30
|
+
* @deprecated 请直接读取 state 属性字段,未来将移除该属性
|
|
31
|
+
*/
|
|
32
|
+
get readyState(): LiveState;
|
|
33
|
+
/**
|
|
34
|
+
* 获取当前WebSocket连接的URL。(注意:这个是WebSocket连接的完整连接,附带一些query参数)。
|
|
35
|
+
* @deprecated 带看不需要关注底层ws的相关信息,未来将移除
|
|
36
|
+
*/
|
|
37
|
+
get url(): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* 获取当前live使用的RTC实例
|
|
40
|
+
*/
|
|
41
|
+
get $RTC(): RTCProtocol;
|
|
42
|
+
/**
|
|
43
|
+
* 获取当前live使用的jsBridge实例
|
|
44
|
+
*/
|
|
45
|
+
get jsBridge(): JSBridgeProtocol;
|
|
46
|
+
/**
|
|
47
|
+
* 帧数据监听
|
|
48
|
+
*/
|
|
49
|
+
keyframes: Subscribe<KeyframeEventType<KeyframesSnapshot>>;
|
|
50
|
+
/**
|
|
51
|
+
* 带看的 yDoc
|
|
52
|
+
*/
|
|
53
|
+
private _yDoc;
|
|
54
|
+
/**
|
|
55
|
+
* 内置的一些数据
|
|
56
|
+
*/
|
|
57
|
+
private _buildInData;
|
|
58
|
+
constructor(opts: LiveOptions);
|
|
59
|
+
/**
|
|
60
|
+
* 当前帧数据快照
|
|
61
|
+
*/
|
|
62
|
+
get snapshot(): Partial<KeyframesSnapshot>;
|
|
63
|
+
_initializeKeyframesObservers: () => void;
|
|
64
|
+
_handleKeyframesChange: (event: Y.YMapEvent<KeyframesSnapshot>) => void;
|
|
65
|
+
/**
|
|
66
|
+
* 根据键值取帧数据
|
|
67
|
+
* @param key 帧数据的键值
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
getFramesByKey: <Key extends keyof KeyframesSnapshot>(key: Key) => Partial<KeyframesSnapshot>[Key] | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* 发送帧数据(需要能够被序列化)
|
|
73
|
+
* @param key 帧数据键值
|
|
74
|
+
* @param frame 帧数据本体
|
|
75
|
+
* @returns 发送结果,成功返回true,失败返回false或Error
|
|
76
|
+
*/
|
|
77
|
+
sendKeyframe: <Key extends keyof KeyframesSnapshot>(key: Key, frame: KeyframesSnapshot[Key]) => boolean | Error;
|
|
78
|
+
/**
|
|
79
|
+
* 当前用户信息
|
|
80
|
+
*/
|
|
81
|
+
get selfInfo(): UserInfo | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* 当前用户列表
|
|
84
|
+
*/
|
|
85
|
+
get userList(): UserInfo[];
|
|
86
|
+
/**
|
|
87
|
+
* 当前带看房间信息
|
|
88
|
+
*/
|
|
89
|
+
get roomInfo(): RoomInfo | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* 带看控制器
|
|
92
|
+
*/
|
|
93
|
+
private _controller;
|
|
94
|
+
private _initializeOptions;
|
|
95
|
+
private _initializeJsBridge;
|
|
96
|
+
private _initializeRTC;
|
|
97
|
+
private _createBuiltInRTC;
|
|
98
|
+
private _createVRWebViewRTC;
|
|
99
|
+
private _createBrowserRTC;
|
|
100
|
+
private _createDefaultRTC;
|
|
101
|
+
private _autoConnect;
|
|
102
|
+
private _debugSetup;
|
|
103
|
+
/**
|
|
104
|
+
* 添加带看控制的事件监听
|
|
105
|
+
*/
|
|
106
|
+
private _addLiveControllerEventListeners;
|
|
107
|
+
/**
|
|
108
|
+
* 移除带看控制的事件监听
|
|
109
|
+
*/
|
|
110
|
+
private _removeLiveControllerEventListeners;
|
|
111
|
+
/**
|
|
112
|
+
* 带看状态变化处理
|
|
113
|
+
* @param state 当前状态
|
|
114
|
+
* @param prevState 之前的状态
|
|
115
|
+
*/
|
|
116
|
+
private _handleStateChange;
|
|
117
|
+
/**
|
|
118
|
+
* 消息接收
|
|
119
|
+
* @param liveMsg
|
|
120
|
+
*/
|
|
121
|
+
private _handleMessage;
|
|
122
|
+
/**
|
|
123
|
+
* 清理带看缓存的数据
|
|
124
|
+
*/
|
|
125
|
+
private _clearLiveData;
|
|
126
|
+
/**
|
|
127
|
+
* 连接带看
|
|
128
|
+
* @param options 连接选项
|
|
129
|
+
* @returns 连接结果,成功返回true,失败返回Error
|
|
130
|
+
*/
|
|
131
|
+
connect: (options?: LiveConnectOptions) => Promise<true | Error>;
|
|
132
|
+
/**
|
|
133
|
+
* 退出带看
|
|
134
|
+
* @returns
|
|
135
|
+
*/
|
|
136
|
+
_exit: () => Promise<boolean>;
|
|
137
|
+
/**
|
|
138
|
+
* 退出带看
|
|
139
|
+
* @returns
|
|
140
|
+
*/
|
|
141
|
+
exit: () => Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* 关闭带看房间
|
|
144
|
+
* @returns 关闭结果
|
|
145
|
+
*/
|
|
146
|
+
close: () => Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* 销毁带看
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
dispose: () => Promise<boolean>;
|
|
152
|
+
/**
|
|
153
|
+
* 修改状态
|
|
154
|
+
* @param evtType
|
|
155
|
+
* @param atnType
|
|
156
|
+
* @param status
|
|
157
|
+
* @param toUserIds
|
|
158
|
+
* @returns
|
|
159
|
+
*/
|
|
160
|
+
updateStatus(evtType: BuiltinEventType, atnType: BuiltinActionType, status: Record<string, any>, toUserIds?: string | string[]): Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* 设置自己的用户信息
|
|
163
|
+
* @param userInfo
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
setSelfInfo: (userInfo: Partial<UserInfo>) => Promise<boolean>;
|
|
167
|
+
/**
|
|
168
|
+
* 自定义广播
|
|
169
|
+
* @param request 广播请求的数据
|
|
170
|
+
* @param toUserIds
|
|
171
|
+
* @param timeout
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
broadcast: <Request extends Record<string, any>, Response>(request: Request, toUserIds: string | string[], timeout: number) => Promise<Response> | Error | false;
|
|
175
|
+
toggleMicro: (microStatus: boolean) => Promise<boolean>;
|
|
176
|
+
/**
|
|
177
|
+
* 控制别人的麦
|
|
178
|
+
* @param microStatus
|
|
179
|
+
* @param toUserIds
|
|
180
|
+
* @returns
|
|
181
|
+
*/
|
|
182
|
+
forbidMicro: (microStatus: MicroStatus, toUserIds: string | string[]) => Promise<boolean>;
|
|
183
|
+
/**
|
|
184
|
+
* 控制别人的同步全量帧数据权限
|
|
185
|
+
* @param sync
|
|
186
|
+
* @param toUserIds
|
|
187
|
+
* @returns
|
|
188
|
+
*/
|
|
189
|
+
forbidSync: (sync: boolean, toUserIds: string | string[]) => Promise<boolean>;
|
|
190
|
+
/**
|
|
191
|
+
* 把用户踢出带看
|
|
192
|
+
* @param toUserIds
|
|
193
|
+
* @returns
|
|
194
|
+
*/
|
|
195
|
+
kick: (toUserIds: string | string[]) => Promise<boolean>;
|
|
196
|
+
/**
|
|
197
|
+
* 获取当前某个 keyframe 的数据快照
|
|
198
|
+
*/
|
|
199
|
+
getSnapshotForKey: <Key extends keyof KeyframesSnapshot>(key: Key) => any;
|
|
200
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Client, LocalStream } from 'trtc-js-sdk';
|
|
2
|
+
import { GetVoiceSign } from '../typings/live/GetVoiceSign';
|
|
3
|
+
import { RTCType } from '../typings/rtc/type';
|
|
4
|
+
import { CoreRTC } from './CoreRTC';
|
|
5
|
+
export interface ITrtcInstance {
|
|
6
|
+
client: Client | null;
|
|
7
|
+
stream: LocalStream | null;
|
|
8
|
+
}
|
|
9
|
+
export declare class BrowserRTC extends CoreRTC {
|
|
10
|
+
type: RTCType;
|
|
11
|
+
joined: boolean;
|
|
12
|
+
micro: boolean;
|
|
13
|
+
voiceId: string;
|
|
14
|
+
private _getVoiceSign;
|
|
15
|
+
private _autoPlayConfirm;
|
|
16
|
+
checkRequirement: () => Promise<import('trtc-js-sdk').CheckResult>;
|
|
17
|
+
private $dom;
|
|
18
|
+
private _trtc;
|
|
19
|
+
constructor(options: {
|
|
20
|
+
getVoiceSign: GetVoiceSign;
|
|
21
|
+
autoPlayConfirm?: (opts: {
|
|
22
|
+
onConfirm: () => void;
|
|
23
|
+
}) => void;
|
|
24
|
+
});
|
|
25
|
+
private _initParentDom;
|
|
26
|
+
join: (options: {
|
|
27
|
+
voiceId: string;
|
|
28
|
+
userId: string;
|
|
29
|
+
roomId: string;
|
|
30
|
+
type: RTCType;
|
|
31
|
+
}) => Promise<boolean>;
|
|
32
|
+
quit(): Promise<boolean>;
|
|
33
|
+
detectMicro(): Promise<boolean>;
|
|
34
|
+
toggleMicro(flag?: boolean): Promise<boolean>;
|
|
35
|
+
shock(): void;
|
|
36
|
+
private _registerRtcEvent;
|
|
37
|
+
private _handleStreamAdded;
|
|
38
|
+
private _handleStreamSubscribed;
|
|
39
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AudioMixObserver, AudioVideoObserver, ConsoleLogger, DefaultDeviceController, DefaultMeetingSession, DeviceChangeObserver, LogLevel } from 'amazon-chime-sdk-js';
|
|
2
|
+
import { GetVoiceSign } from '../typings/live/GetVoiceSign';
|
|
3
|
+
import { RTCType } from '../typings/rtc/type';
|
|
4
|
+
import { CoreRTC } from './CoreRTC';
|
|
5
|
+
/**
|
|
6
|
+
* amazon-chime-sdk-js 适配的rtc实现
|
|
7
|
+
*/
|
|
8
|
+
export declare class BrowserRTC4Chime extends CoreRTC {
|
|
9
|
+
type: RTCType;
|
|
10
|
+
joined: boolean;
|
|
11
|
+
micro: boolean;
|
|
12
|
+
voiceId: string;
|
|
13
|
+
userId: string;
|
|
14
|
+
logger: ConsoleLogger;
|
|
15
|
+
deviceController: DefaultDeviceController;
|
|
16
|
+
meetingSession: DefaultMeetingSession | undefined;
|
|
17
|
+
audioInput: MediaDeviceInfo | undefined;
|
|
18
|
+
audioOutput: MediaDeviceInfo | undefined;
|
|
19
|
+
deviceChangeObserver: DeviceChangeObserver;
|
|
20
|
+
audioVideoObserver: AudioVideoObserver;
|
|
21
|
+
audioMixObserver?: AudioMixObserver;
|
|
22
|
+
private _getVoiceSign;
|
|
23
|
+
private _autoPlayConfirm;
|
|
24
|
+
private $dom;
|
|
25
|
+
private $audio;
|
|
26
|
+
constructor(options: {
|
|
27
|
+
getVoiceSign: GetVoiceSign;
|
|
28
|
+
autoPlayConfirm?: (opts: {
|
|
29
|
+
onConfirm: () => void;
|
|
30
|
+
}) => void;
|
|
31
|
+
logLevel?: LogLevel;
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* 对audio标签初始化
|
|
35
|
+
*/
|
|
36
|
+
_initDom: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* 初始化事件监听器
|
|
39
|
+
*/
|
|
40
|
+
initObservers: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* 加入语音会议
|
|
43
|
+
* @param options
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
join(options: {
|
|
47
|
+
voiceId: string;
|
|
48
|
+
userId: string;
|
|
49
|
+
roomId: string | number | undefined;
|
|
50
|
+
type: RTCType;
|
|
51
|
+
}): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* 注册rtc事件
|
|
54
|
+
*/
|
|
55
|
+
_registerRtcEvent: () => void;
|
|
56
|
+
quit(): Promise<boolean>;
|
|
57
|
+
detectMicro(): Promise<boolean>;
|
|
58
|
+
toggleMicro(flag?: boolean): Promise<boolean>;
|
|
59
|
+
shock(): void;
|
|
60
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RTCEventType } from '../typings/rtc/eventType';
|
|
2
|
+
import { RTCProtocol } from '../typings/rtc/protocol';
|
|
3
|
+
import { RTCType } from '../typings/rtc/type';
|
|
4
|
+
import { Subscribe } from '../utils/subscribe';
|
|
5
|
+
/**
|
|
6
|
+
* rtc 基础抽象类
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class CoreRTC extends Subscribe<RTCEventType> implements RTCProtocol {
|
|
9
|
+
abstract joined: boolean;
|
|
10
|
+
abstract micro: boolean;
|
|
11
|
+
abstract voiceId: string;
|
|
12
|
+
abstract type: RTCType;
|
|
13
|
+
abstract join(options: {
|
|
14
|
+
voiceId: string;
|
|
15
|
+
userId: string;
|
|
16
|
+
roomId: string | number | undefined;
|
|
17
|
+
type: RTCType;
|
|
18
|
+
}): Promise<boolean>;
|
|
19
|
+
abstract quit(): Promise<boolean>;
|
|
20
|
+
abstract detectMicro(): Promise<boolean>;
|
|
21
|
+
abstract toggleMicro(flag?: boolean): Promise<boolean>;
|
|
22
|
+
abstract shock(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { RTCType } from '../typings/rtc/type';
|
|
2
|
+
import { VRWebViewRTCOptions } from '../typings/rtc/VRWebViewRTCOptions';
|
|
3
|
+
import { CoreRTC } from './CoreRTC';
|
|
4
|
+
export declare class VRWebViewRTC extends CoreRTC {
|
|
5
|
+
type: RTCType;
|
|
6
|
+
joined: boolean;
|
|
7
|
+
micro: boolean;
|
|
8
|
+
voiceId: string;
|
|
9
|
+
/**
|
|
10
|
+
* 保留加入房间参数,用于重连
|
|
11
|
+
*/
|
|
12
|
+
private _joinOptions;
|
|
13
|
+
private options;
|
|
14
|
+
get jsBridge(): import('@realsee/jsbridge-x').JSBridgeProtocol;
|
|
15
|
+
constructor({ jsBridge, getVoiceSign }: VRWebViewRTCOptions);
|
|
16
|
+
/**
|
|
17
|
+
* 处理用户音量
|
|
18
|
+
* @param userVolumes
|
|
19
|
+
*/
|
|
20
|
+
private handleUserVolumes;
|
|
21
|
+
/**
|
|
22
|
+
* 处理弱网络情况
|
|
23
|
+
* @param weakNetwork
|
|
24
|
+
*/
|
|
25
|
+
private handleWeakNetwork;
|
|
26
|
+
/**
|
|
27
|
+
* 加入语音房间
|
|
28
|
+
* @param options
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
join: (options: {
|
|
32
|
+
voiceId: string;
|
|
33
|
+
userId: string;
|
|
34
|
+
roomId: string;
|
|
35
|
+
type: RTCType;
|
|
36
|
+
}) => Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* 重连
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
reJoin: () => Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* 获取 rtc 签名
|
|
44
|
+
* @param params
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
private getVoiceSignOrEmitError;
|
|
48
|
+
/**
|
|
49
|
+
* 处理小程序的加入房间
|
|
50
|
+
* @param options
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
private handleWxMiniProgramWebViewJoin;
|
|
54
|
+
/**
|
|
55
|
+
* 处理App WebView的加入房间
|
|
56
|
+
* @param options
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
private handleAppWebViewJoin;
|
|
60
|
+
/**
|
|
61
|
+
* 加入语音房间,给小程序使用
|
|
62
|
+
* @param param0
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
private joinRoomOrEmitError;
|
|
66
|
+
/**
|
|
67
|
+
* 处理加入语音房间结果
|
|
68
|
+
* @param res
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
private handleJoinResult;
|
|
72
|
+
/**
|
|
73
|
+
* 将错误信息发送出去,并将 joined 置为 false
|
|
74
|
+
* @param message
|
|
75
|
+
*/
|
|
76
|
+
private emitErrorAndSetJoinedFalse;
|
|
77
|
+
/**
|
|
78
|
+
* 退出房间
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
quit: () => Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* 监测麦克风权限
|
|
84
|
+
* @returns
|
|
85
|
+
*/
|
|
86
|
+
detectMicro: () => Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* 修改麦克风状态
|
|
89
|
+
* @param flag
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
toggleMicro: (flag?: boolean) => Promise<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* 震动
|
|
95
|
+
*/
|
|
96
|
+
shock: () => void;
|
|
97
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface MeetingResponse {
|
|
2
|
+
MediaPlacement: {
|
|
3
|
+
AudioFallbackUrl: string;
|
|
4
|
+
AudioHostUrl: string;
|
|
5
|
+
ScreenDataUrl: string;
|
|
6
|
+
ScreenSharingUrl: string;
|
|
7
|
+
ScreenViewingUrl: string;
|
|
8
|
+
SignalingUrl: string;
|
|
9
|
+
TurnControlUrl: string;
|
|
10
|
+
};
|
|
11
|
+
MeetingId: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AttendeeResponse } from './AttendeeResponse';
|
|
2
|
+
import { MeetingResponse } from './MeetingResponse';
|
|
3
|
+
export interface MeetingSessionConfigurationOptions {
|
|
4
|
+
attendence: AttendeeResponse;
|
|
5
|
+
config: {
|
|
6
|
+
passport: string;
|
|
7
|
+
vendor: string;
|
|
8
|
+
app_id: string;
|
|
9
|
+
bypass: any;
|
|
10
|
+
};
|
|
11
|
+
expire_time: number;
|
|
12
|
+
identifier: string;
|
|
13
|
+
user_id: string;
|
|
14
|
+
user_sig: string;
|
|
15
|
+
vendor_wrapper: MeetingResponse;
|
|
16
|
+
}
|