@rongcloud/plugin-rtc 5.4.2 → 5.4.4-alpha.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.
- package/dist/async-task-queue.d.ts +9 -0
- package/dist/core/Invoker.d.ts +46 -0
- package/dist/core/PolarisReporter.d.ts +35 -0
- package/dist/core/RCAudienceClient.d.ts +89 -0
- package/dist/core/RCMediaStreamCapture.d.ts +124 -0
- package/dist/core/RCRTCClient.d.ts +126 -0
- package/dist/core/Store.d.ts +80 -0
- package/dist/core/command/BaseCommand.d.ts +22 -0
- package/dist/core/command/EnabelInnerCDNCommand.d.ts +16 -0
- package/dist/core/command/ExchangeCommand.d.ts +18 -0
- package/dist/core/command/ExchangeWithPushOtherRoomCommand.d.ts +22 -0
- package/dist/core/command/JoinRoomCommand.d.ts +26 -0
- package/dist/core/command/LeaveOtherRoomCommand.d.ts +30 -0
- package/dist/core/command/LocalTrackMuteCommand.d.ts +10 -0
- package/dist/core/command/MCUConfigFlushCommand.d.ts +18 -0
- package/dist/core/command/OnRemoteUserUnpubCommand.d.ts +13 -0
- package/dist/core/command/OnSignalReconnectedCommand.d.ts +38 -0
- package/dist/core/command/ParseRemoteResCommand.d.ts +38 -0
- package/dist/core/command/ParseUserStateCommand.d.ts +57 -0
- package/dist/core/command/PubCommand.d.ts +34 -0
- package/dist/core/command/RTCIdentityChangeCommand.d.ts +17 -0
- package/dist/core/command/RetryExchangeCommand.d.ts +18 -0
- package/dist/core/command/SubCommand.d.ts +21 -0
- package/dist/core/command/UnpubCommand.d.ts +20 -0
- package/dist/core/command/UnpubPrevCommand.d.ts +6 -0
- package/dist/core/command/UnsubCommand.d.ts +20 -0
- package/dist/core/command/UpdateSubListCommand.d.ts +28 -0
- package/dist/core/command/helper.d.ts +20 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/enums/BackgroundPictureFillMode.d.ts +14 -0
- package/dist/core/enums/MixLayoutMode.d.ts +18 -0
- package/dist/core/enums/MixVideoRenderMode.d.ts +14 -0
- package/dist/core/enums/RCBitrate.d.ts +48 -0
- package/dist/core/enums/RCFrameRate.d.ts +7 -0
- package/dist/core/enums/RCInnerCDNBroadcast.d.ts +5 -0
- package/dist/core/enums/RCInnerCDNModel.d.ts +5 -0
- package/dist/core/enums/RCInnerCDNPullIsHttps.d.ts +5 -0
- package/dist/core/enums/RCInnerCDNPullKind.d.ts +6 -0
- package/dist/core/enums/RCInnerCDNPushMode.d.ts +5 -0
- package/dist/core/enums/RCKickType.d.ts +11 -0
- package/dist/core/enums/RCLivingType.d.ts +14 -0
- package/dist/core/enums/RCLoggerTag.d.ts +629 -0
- package/dist/core/enums/RCMediaType.d.ts +18 -0
- package/dist/core/enums/RCMixInputFilterMode.d.ts +35 -0
- package/dist/core/enums/RCRTCCode.d.ts +88 -0
- package/dist/core/enums/RCRTCLiveRole.d.ts +14 -0
- package/dist/core/enums/RCRTCPingResult.d.ts +5 -0
- package/dist/core/enums/RCRTCResolution.d.ts +102 -0
- package/dist/core/enums/RCResolution.d.ts +16 -0
- package/dist/core/enums/inner/PolarisRole.d.ts +14 -0
- package/dist/core/enums/inner/R2Action.d.ts +14 -0
- package/dist/core/enums/inner/R2Status.d.ts +11 -0
- package/dist/core/enums/inner/RCRTCMessageType.d.ts +66 -0
- package/dist/core/enums/inner/RCStreamType.d.ts +14 -0
- package/dist/core/enums/inner/TrackState.d.ts +14 -0
- package/dist/core/interfaces.d.ts +912 -0
- package/dist/core/room/Pinger.d.ts +35 -0
- package/dist/core/room/RCAbstractRoom.d.ts +327 -0
- package/dist/core/room/RCAudienceLivingRoom.d.ts +321 -0
- package/dist/core/room/RCAudioLevelReport.d.ts +16 -0
- package/dist/core/room/RCLivingPKHandler.d.ts +164 -0
- package/dist/core/room/RCLivingRoom.d.ts +108 -0
- package/dist/core/room/RCLocalMediaStream.d.ts +8 -0
- package/dist/core/room/RCMCUConfigBuilder.d.ts +211 -0
- package/dist/core/room/RCRTCRoom.d.ts +15 -0
- package/dist/core/service/RCMediaService.d.ts +96 -0
- package/dist/core/service/helper.d.ts +8 -0
- package/dist/core/service/index.d.ts +6 -0
- package/dist/core/service/interface.d.ts +323 -0
- package/dist/core/service/mcu-interface.d.ts +293 -0
- package/dist/core/tracks/RCLocalTrack.d.ts +121 -0
- package/dist/core/tracks/RCRemoteTrack.d.ts +29 -0
- package/dist/core/tracks/RCTrack.d.ts +90 -0
- package/dist/core/webrtc/RCRTCPeerCManager.d.ts +159 -0
- package/dist/core/webrtc/RCRTCPeerConnection.d.ts +112 -0
- package/dist/core/webrtc/helper.d.ts +26 -0
- package/dist/core/webrtc/sdp/ASdpBuilder.d.ts +98 -0
- package/dist/core/webrtc/sdp/ASdpStrategy.d.ts +48 -0
- package/dist/core/webrtc/sdp/PlanBSdpBuilder.d.ts +20 -0
- package/dist/core/webrtc/sdp/PlanBStrategy.d.ts +26 -0
- package/dist/core/webrtc/sdp/UnifiedPlanSdpBuilder.d.ts +11 -0
- package/dist/core/webrtc/sdp/UnifiedPlanStrategy.d.ts +21 -0
- package/dist/core/webrtc/stat-parser/AbstractStatParser.d.ts +117 -0
- package/dist/core/webrtc/stat-parser/ChromeStatParser.d.ts +14 -0
- package/dist/core/webrtc/stat-parser/FirefoxStatParser.d.ts +14 -0
- package/dist/core/webrtc/stat-parser/IStatParser.d.ts +24 -0
- package/dist/core/webrtc/stat-parser/SafariStatParser.d.ts +14 -0
- package/dist/device.d.ts +6 -0
- package/dist/helper.d.ts +189 -0
- package/dist/index.d.ts +205 -158
- package/dist/index.esm.js +18244 -15
- package/dist/index.js +18276 -15
- package/dist/index.umd.js +18280 -15
- package/dist/logger.d.ts +4 -0
- package/package.json +3 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RTCMode, RTCPluginContext } from '@rongcloud/engine';
|
|
2
|
+
import { RCRTCPingResult } from '../enums/RCRTCPingResult';
|
|
3
|
+
/**
|
|
4
|
+
* RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
|
|
5
|
+
*/
|
|
6
|
+
export default class Pinger {
|
|
7
|
+
private readonly _roomId;
|
|
8
|
+
private readonly _roomMode;
|
|
9
|
+
private readonly _context;
|
|
10
|
+
private readonly _gap;
|
|
11
|
+
private readonly _offlineKickTime;
|
|
12
|
+
/**
|
|
13
|
+
* 记录最近一次成功的 Ping 时间戳
|
|
14
|
+
*/
|
|
15
|
+
private _latestTimestamp;
|
|
16
|
+
constructor(_roomId: string, _roomMode: RTCMode, _context: RTCPluginContext, _gap?: number, _offlineKickTime?: number);
|
|
17
|
+
/**
|
|
18
|
+
* Ping 失败回调,当失败次数超出 `MAX_FAILED` 时,该方法将被调用
|
|
19
|
+
*/
|
|
20
|
+
onFailed?(byServer: boolean): void;
|
|
21
|
+
/**
|
|
22
|
+
* 单次 ping 结果
|
|
23
|
+
*/
|
|
24
|
+
onPingResult?(result: RCRTCPingResult): void;
|
|
25
|
+
private _started;
|
|
26
|
+
private _timer;
|
|
27
|
+
/**
|
|
28
|
+
* 启动 Ping
|
|
29
|
+
*/
|
|
30
|
+
start(): void;
|
|
31
|
+
private _sendPing;
|
|
32
|
+
private _checkAlive;
|
|
33
|
+
stop(): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=Pinger.d.ts.map
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { ErrorCode, IJoinRTCRoomData, IReceivedMessage, RTCMode, RTCPluginContext, KVString, IRuntime, RTCJoinType, IRTCUserData, EventEmitter } from '@rongcloud/engine';
|
|
2
|
+
import { RCRTCMessageType } from '../enums/inner/RCRTCMessageType';
|
|
3
|
+
import { IPublishAttrs, IRCRTCReportListener, IRoomEventListener, ISubscribeAttr, IRCRTCInitOptions, IAudioLevelChangeHandler, IPubSuccessRes } from '../interfaces';
|
|
4
|
+
import { IPushOtherRooms, IRTCReqHeader, RCMediaService } from '../service';
|
|
5
|
+
import RCRTCPeerConnection from '../webrtc/RCRTCPeerConnection';
|
|
6
|
+
import PolarisReporter from '../PolarisReporter';
|
|
7
|
+
import { RCLocalTrack } from '../tracks/RCLocalTrack';
|
|
8
|
+
import { RCRemoteTrack } from '../tracks/RCRemoteTrack';
|
|
9
|
+
import { RCRTCCode } from '../enums/RCRTCCode';
|
|
10
|
+
import { RCLivingType } from '../enums/RCLivingType';
|
|
11
|
+
import { IOnRecvPKMsg } from './RCLivingPKHandler';
|
|
12
|
+
import RCRTCPeerCManager from '../webrtc/RCRTCPeerCManager';
|
|
13
|
+
import { Invoker } from '../Invoker';
|
|
14
|
+
import { ReadableStore } from '../Store';
|
|
15
|
+
import { ResourceMsgContent } from '../command/ParseRemoteResCommand';
|
|
16
|
+
export declare const RCAbstractRoomEvent: {
|
|
17
|
+
LEAVE: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 房间抽象基类
|
|
21
|
+
*/
|
|
22
|
+
export default abstract class RCAbstractRoom extends EventEmitter {
|
|
23
|
+
protected readonly _context: RTCPluginContext;
|
|
24
|
+
protected readonly _runtime: IRuntime;
|
|
25
|
+
readonly _roomId: string;
|
|
26
|
+
protected readonly _service: RCMediaService;
|
|
27
|
+
protected readonly _initOptions: IRCRTCInitOptions;
|
|
28
|
+
/**
|
|
29
|
+
* 是否使用多 peerConnection
|
|
30
|
+
*/
|
|
31
|
+
protected readonly _useMutilPeerC?: boolean | undefined;
|
|
32
|
+
protected readonly _clientSessionId: string;
|
|
33
|
+
/**
|
|
34
|
+
* 房间保活 rtcPing
|
|
35
|
+
*/
|
|
36
|
+
private _pinger;
|
|
37
|
+
/**
|
|
38
|
+
* 北极星上报实例
|
|
39
|
+
*/
|
|
40
|
+
protected _polarisReport: PolarisReporter | null;
|
|
41
|
+
/**
|
|
42
|
+
* 音量上报实例
|
|
43
|
+
*/
|
|
44
|
+
private _audioLevelReport;
|
|
45
|
+
/**
|
|
46
|
+
* peerConnection 管理类
|
|
47
|
+
*/
|
|
48
|
+
protected _peerCManager: RCRTCPeerCManager | null;
|
|
49
|
+
protected readonly _invoker: Invoker;
|
|
50
|
+
protected readonly _store: ReadableStore;
|
|
51
|
+
constructor(_context: RTCPluginContext, _runtime: IRuntime, _roomId: string, _roomMode: RTCMode, _service: RCMediaService, _initOptions: IRCRTCInitOptions, isUpgrade?: boolean, isMainRoom?: boolean,
|
|
52
|
+
/**
|
|
53
|
+
* 是否使用多 peerConnection
|
|
54
|
+
*/
|
|
55
|
+
_useMutilPeerC?: boolean | undefined, _clientSessionId?: string);
|
|
56
|
+
__innerInit(mode: RTCMode, joinType?: RTCJoinType, livingType?: RCLivingType, innerUserDatas?: IRTCUserData, outerUserDatas?: IRTCUserData): Promise<{
|
|
57
|
+
code: RCRTCCode | ErrorCode;
|
|
58
|
+
data?: IJoinRTCRoomData;
|
|
59
|
+
}>;
|
|
60
|
+
protected _initWithRoomData(offlineKickTime: number): void;
|
|
61
|
+
private _handlePingResult;
|
|
62
|
+
/**
|
|
63
|
+
* 设置房间上行资源的总码率配置
|
|
64
|
+
* @deprecated use RCLocalTrack.setBitrate instead of setBitrate
|
|
65
|
+
* @description
|
|
66
|
+
* * 自 v5.1.0 版本开始,推荐使用 `RCLocalTrack.setBitrate` 对不同流分别指定码率。
|
|
67
|
+
* * 该方法仅在 SDP `plan-b` 协议下(Chrome 92 与 Safari 11 之前的版本)有效。
|
|
68
|
+
* @param max 音视频发送码率上限,不可小于 200 且不可小于 `min`
|
|
69
|
+
* @param min 音视频发送码率下限,默认值为 1,且不可小于 1,不可大于 `max`
|
|
70
|
+
* @param start 起始码率,默认为码率上限的 70%
|
|
71
|
+
*/
|
|
72
|
+
setBitrate(max: number, min: number, start?: number): void;
|
|
73
|
+
private _onTrackReady;
|
|
74
|
+
protected _callAppListener(eventType: keyof IRoomEventListener, ...attrs: any[]): void;
|
|
75
|
+
private _onTrackUnpublish;
|
|
76
|
+
__parseInnerMessage(message: IReceivedMessage): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* 被踢出房间通知
|
|
79
|
+
* @param byServer
|
|
80
|
+
* * 当值为 false 时,说明本端 rtcPing 超时
|
|
81
|
+
* * 当值为 true 时,说明本端收到被踢出房间通知
|
|
82
|
+
*/
|
|
83
|
+
private _kickoff;
|
|
84
|
+
private _rtcpeerClosed;
|
|
85
|
+
/**
|
|
86
|
+
* 处理资源变更事件
|
|
87
|
+
* @param content
|
|
88
|
+
* @param messageType 消息类型
|
|
89
|
+
* @param userId 消息发送者
|
|
90
|
+
*/
|
|
91
|
+
protected _resourceHandle(content: ResourceMsgContent, messageType: RCRTCMessageType.PUBLISH | RCRTCMessageType.UNPUBLISH | RCRTCMessageType.MODIFY | RCRTCMessageType.TOTAL_CONTENT_RESOURCE, userId: string): Promise<void>;
|
|
92
|
+
private _onTrackPublish;
|
|
93
|
+
/**
|
|
94
|
+
* 处理 `RCRTCMessageType.STATE` 消息
|
|
95
|
+
* @param content
|
|
96
|
+
*/
|
|
97
|
+
private _stateHandle;
|
|
98
|
+
/**
|
|
99
|
+
* 获取房间 Id
|
|
100
|
+
*/
|
|
101
|
+
getRoomId(): string;
|
|
102
|
+
/**
|
|
103
|
+
* 获取当前 userId
|
|
104
|
+
*/
|
|
105
|
+
getCrtUserId(): string;
|
|
106
|
+
/**
|
|
107
|
+
* 获取 _pc 实例
|
|
108
|
+
*/
|
|
109
|
+
__getPC(): RCRTCPeerConnection[];
|
|
110
|
+
/**
|
|
111
|
+
* 获取远程用户列表,不包含当前用户
|
|
112
|
+
*/
|
|
113
|
+
getRemoteUserIds(): string[];
|
|
114
|
+
/**
|
|
115
|
+
* 获取所有房间已发布的远端资源列表
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
getRemoteTracks(): RCRemoteTrack[];
|
|
119
|
+
/**
|
|
120
|
+
* 获取远端用户的资源列表
|
|
121
|
+
* @param userId
|
|
122
|
+
* @returns
|
|
123
|
+
*/
|
|
124
|
+
getRemoteTracksByUserId(userId: string): RCRemoteTrack[];
|
|
125
|
+
/**
|
|
126
|
+
* 获取房间当前会话 Id,当房间内已无成员时房间会回收,重新加入时 sessionId 将更新
|
|
127
|
+
*/
|
|
128
|
+
getSessionId(): string;
|
|
129
|
+
/**
|
|
130
|
+
* 向房间内发消息
|
|
131
|
+
* @param name 消息名称
|
|
132
|
+
* @param content 消息内容
|
|
133
|
+
*/
|
|
134
|
+
sendMessage(name: string, content: any): Promise<{
|
|
135
|
+
code: RCRTCCode;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* 设置房间属性
|
|
139
|
+
* @param key 属性名
|
|
140
|
+
* @param value 属性值
|
|
141
|
+
* @param message 是否在设置属性的时候携带消息内容,传空则不往房间中发送消息
|
|
142
|
+
* @param isInner RTC 业务内部使用参数,用户忽略
|
|
143
|
+
*/
|
|
144
|
+
setRoomAttribute(key: string, value: string, message?: {
|
|
145
|
+
name: string;
|
|
146
|
+
content: string;
|
|
147
|
+
}, isInner?: boolean): Promise<{
|
|
148
|
+
code: RCRTCCode;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* 删除房间属性
|
|
152
|
+
* @param keys 待删除的属性名数组
|
|
153
|
+
* @param message 是否在删除属性的时候携带消息内容,传空则不往房间中发送消息
|
|
154
|
+
* @param isInner RTC 业务内部使用参数,用户忽略
|
|
155
|
+
*/
|
|
156
|
+
deleteRoomAttributes(keys: string[], message?: {
|
|
157
|
+
name: string;
|
|
158
|
+
content: string;
|
|
159
|
+
}, isInner?: boolean): Promise<{
|
|
160
|
+
code: RCRTCCode;
|
|
161
|
+
}>;
|
|
162
|
+
/**
|
|
163
|
+
* 获取房间属性
|
|
164
|
+
* @param keys 要查询的属性名数组,当数组长度为空时,取所有已设置的 kv 值
|
|
165
|
+
* @param isInner RTC 业务内部使用参数,用户忽略
|
|
166
|
+
*/
|
|
167
|
+
getRoomAttributes(keys?: string[], isInner?: boolean): Promise<{
|
|
168
|
+
code: RCRTCCode;
|
|
169
|
+
data?: KVString;
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* 设置当前用户属性(暂不开放)
|
|
173
|
+
* @param key 属性名
|
|
174
|
+
* @param value 属性值
|
|
175
|
+
* @param message 是否在设置属性的时候携带消息内容,传空则不往房间中发送消息
|
|
176
|
+
*/
|
|
177
|
+
private _setUserAttributeValue;
|
|
178
|
+
/**
|
|
179
|
+
* 删除当前用户属性(暂不开放)
|
|
180
|
+
* @param keys 待删除的属性名数组
|
|
181
|
+
* @param message 是否在删除属性的时候携带消息内容,传空则不往房间中发送消息
|
|
182
|
+
*/
|
|
183
|
+
private _deleteUserAttributes;
|
|
184
|
+
/**
|
|
185
|
+
* 获取当前用户属性(暂不开放)
|
|
186
|
+
* @param keys 要查询的属性名数组
|
|
187
|
+
*/
|
|
188
|
+
private _getUserAttributes;
|
|
189
|
+
/**
|
|
190
|
+
* 查询房间是否已销毁
|
|
191
|
+
*/
|
|
192
|
+
isDestroyed(): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* 退出并销毁当前房间实例,退出后该房间的所有方法将不可用
|
|
195
|
+
*/
|
|
196
|
+
__destroy(quitRoom: boolean): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* 退出房间之前禁用所有远端资源,避免退出动作耗时过长,
|
|
199
|
+
* 导致在未完全退出的过程中仍能听到房间内的声音问题
|
|
200
|
+
*/
|
|
201
|
+
private _muteRemoteTracksBeforeQuit;
|
|
202
|
+
private _leaveHandle;
|
|
203
|
+
/**
|
|
204
|
+
* 释放 PCManager 上的资源
|
|
205
|
+
*/
|
|
206
|
+
private _releasePCManager;
|
|
207
|
+
private _onLocalTrackDestroied;
|
|
208
|
+
/**
|
|
209
|
+
* 本端流状态修改,需通知房间内其他成员
|
|
210
|
+
* @param localTrack
|
|
211
|
+
*/
|
|
212
|
+
private _onLocalTrackMuted;
|
|
213
|
+
/**
|
|
214
|
+
* 增量发布资源,若发布的资源 tag 及媒体类型重复,后者将覆盖前者进行发布。
|
|
215
|
+
* @param tracks 待发布的 RCLocalTrack 实例
|
|
216
|
+
* @returns
|
|
217
|
+
*/
|
|
218
|
+
publish(tracks: (RCLocalTrack | IPublishAttrs)[]): Promise<IPubSuccessRes>;
|
|
219
|
+
/**
|
|
220
|
+
* 获取跨房间连麦需携带参数 pushOtherRooms 的值
|
|
221
|
+
*/
|
|
222
|
+
protected _getPushOtherRoomsParams(): IPushOtherRooms[];
|
|
223
|
+
/**
|
|
224
|
+
* ice 断线后,尝试重新走 exchange
|
|
225
|
+
*/
|
|
226
|
+
protected _reTryExchange(pcName: string, isPub: boolean): Promise<void>;
|
|
227
|
+
protected _getRTCReqestHeaders(pcName: string): IRTCReqHeader;
|
|
228
|
+
/**
|
|
229
|
+
* 增量取消资源发布,若相应资源中存在小流资源,则同时取消发布
|
|
230
|
+
* @param tracks 取消发布的 RCLocalTrack 列表
|
|
231
|
+
*/
|
|
232
|
+
unpublish(tracks: RCLocalTrack[]): Promise<IPubSuccessRes>;
|
|
233
|
+
/**
|
|
234
|
+
* 根据资源 Id 获取资源数据
|
|
235
|
+
* @param trackId
|
|
236
|
+
*/
|
|
237
|
+
private _getResourceById;
|
|
238
|
+
/**
|
|
239
|
+
* resourceId 有效性验证
|
|
240
|
+
* @param resourceId
|
|
241
|
+
*/
|
|
242
|
+
protected _isValidResourceId(resourceId: string): boolean;
|
|
243
|
+
private _subhook;
|
|
244
|
+
private _pubhook;
|
|
245
|
+
/**
|
|
246
|
+
* 订阅资源
|
|
247
|
+
* @param tracks
|
|
248
|
+
*/
|
|
249
|
+
subscribe(tracks: (RCRemoteTrack | ISubscribeAttr)[]): Promise<{
|
|
250
|
+
code: RCRTCCode;
|
|
251
|
+
failedList?: ISubscribeAttr[];
|
|
252
|
+
}>;
|
|
253
|
+
/**
|
|
254
|
+
* 取消订阅资源
|
|
255
|
+
* @param tracks 预取消远端资源
|
|
256
|
+
*/
|
|
257
|
+
unsubscribe(tracks: RCRemoteTrack[]): Promise<{
|
|
258
|
+
code: RCRTCCode;
|
|
259
|
+
failedList?: ISubscribeAttr[];
|
|
260
|
+
}>;
|
|
261
|
+
/**
|
|
262
|
+
* 获取已发布的本地资源
|
|
263
|
+
* @param trackId
|
|
264
|
+
* @returns
|
|
265
|
+
*/
|
|
266
|
+
getLocalTrack(trackId: string): RCLocalTrack | null;
|
|
267
|
+
/**
|
|
268
|
+
* 获取所有已发布的资源
|
|
269
|
+
*/
|
|
270
|
+
getLocalTracks(): RCLocalTrack[];
|
|
271
|
+
/**
|
|
272
|
+
* 根据 trackId 获取房间内的远端资源
|
|
273
|
+
* @param trackId
|
|
274
|
+
* @returns
|
|
275
|
+
*/
|
|
276
|
+
getRemoteTrack(trackId: string): RCRemoteTrack | null;
|
|
277
|
+
/**
|
|
278
|
+
* 强制修改订阅列表,仅订阅数组中的资源,取消订阅其他已订阅资源。
|
|
279
|
+
* 当参数为 `[]` 时,意味着不再订阅任何资源
|
|
280
|
+
* @param tracks 变更的资源列表
|
|
281
|
+
*/
|
|
282
|
+
updateSubList(tracks: (RCRemoteTrack | ISubscribeAttr)[]): Promise<{
|
|
283
|
+
code: RCRTCCode;
|
|
284
|
+
failedList?: ISubscribeAttr[];
|
|
285
|
+
}>;
|
|
286
|
+
private _appListener;
|
|
287
|
+
/**
|
|
288
|
+
* 注册事件监听器,多次注册会导致后者覆盖前者,可以通过使用 `registerRoomEventListener(null)` 取消注册
|
|
289
|
+
* @param listener
|
|
290
|
+
*/
|
|
291
|
+
registerRoomEventListener(listener: IRoomEventListener | null): void;
|
|
292
|
+
private _reportListener;
|
|
293
|
+
/**
|
|
294
|
+
* 注册房间数据监控
|
|
295
|
+
* @param listener
|
|
296
|
+
* @description 该方法暂仅支持 Chrome 浏览器
|
|
297
|
+
*/
|
|
298
|
+
registerReportListener(listener: IRCRTCReportListener | null): void;
|
|
299
|
+
/**
|
|
300
|
+
* 音量上报
|
|
301
|
+
* @param handler 业务端传入的音量上报事件
|
|
302
|
+
* @param gap 上报时间间隔
|
|
303
|
+
*/
|
|
304
|
+
onAudioLevelChange(handler: IAudioLevelChangeHandler | null, gap?: number): void;
|
|
305
|
+
/**
|
|
306
|
+
* 断线重连后尝试补发断线过程中的通知信息
|
|
307
|
+
*/
|
|
308
|
+
__onReconnected(livingType?: RCLivingType): Promise<{
|
|
309
|
+
data: IJoinRTCRoomData | undefined;
|
|
310
|
+
} | void>;
|
|
311
|
+
private _onAudioMuteChange;
|
|
312
|
+
private _onVideoMuteChange;
|
|
313
|
+
/**
|
|
314
|
+
* 存储连麦监听事件
|
|
315
|
+
*/
|
|
316
|
+
private _onRecvPKMsg;
|
|
317
|
+
/**
|
|
318
|
+
* 注册 PK 业务监听方法
|
|
319
|
+
*/
|
|
320
|
+
protected _registerPKMsgListener(listener: IOnRecvPKMsg | null): void;
|
|
321
|
+
/**
|
|
322
|
+
* 退出 PK 房间
|
|
323
|
+
*/
|
|
324
|
+
protected _quitAllPKRoom(): void;
|
|
325
|
+
getClientSessionId(): string;
|
|
326
|
+
}
|
|
327
|
+
//# sourceMappingURL=RCAbstractRoom.d.ts.map
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { RTCPluginContext, IRuntime, IServerRTCRoomEntry } from '@rongcloud/engine';
|
|
2
|
+
import { RCRemoteAudioTrack, RCRemoteTrack, RCRemoteVideoTrack } from '../tracks/RCRemoteTrack';
|
|
3
|
+
import { RCRTCCode } from '../enums/RCRTCCode';
|
|
4
|
+
import { IRCRTCInitOptions, IRCRTCReportListener, IRCRTCTrackEventListener, ISubscribeAttr, IAudioLevelChangeHandler } from '../interfaces';
|
|
5
|
+
import PolarisReporter from '../PolarisReporter';
|
|
6
|
+
import { IBroadcastSubReqBody } from '../service';
|
|
7
|
+
import RCLocalMediaStream from './RCLocalMediaStream';
|
|
8
|
+
import { RCResolution } from '../enums/RCResolution';
|
|
9
|
+
import { RCFrameRate } from '../enums/RCFrameRate';
|
|
10
|
+
import { RCLivingType } from '../enums/RCLivingType';
|
|
11
|
+
import RCRTCPeerConnection from '../webrtc/RCRTCPeerConnection';
|
|
12
|
+
export interface IAudienceRoomEventListener extends IRCRTCTrackEventListener {
|
|
13
|
+
/**
|
|
14
|
+
* 主播加入
|
|
15
|
+
* @param userIds 加入主播的 id 列表
|
|
16
|
+
*/
|
|
17
|
+
onAnchorJoin?(userId: string[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* 主播退出
|
|
20
|
+
* @param userIds 退出主播的 id 列表
|
|
21
|
+
*/
|
|
22
|
+
onAnchorLeave?(userId: string[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* 房间内合流发布资源
|
|
25
|
+
* @param tracks 新发布的合流音轨与视轨数据列表,包含新发布的 RCRemoteAudioTrack 与 RCRemoteVideoTrack 实例
|
|
26
|
+
* @description
|
|
27
|
+
* 当房间内某个主播第一次发布资源时触发
|
|
28
|
+
*/
|
|
29
|
+
onTrackPublish?(tracks: RCRemoteTrack[]): void;
|
|
30
|
+
/**
|
|
31
|
+
* 房间内取消合流发布资源
|
|
32
|
+
* @param tracks 被取消发布的合流音轨与视轨数据列表
|
|
33
|
+
* @description
|
|
34
|
+
* 当房间内全部主播退出房间时,SDK 内部会取消对资源的订阅,业务层仅需处理 UI 业务
|
|
35
|
+
*/
|
|
36
|
+
onTrackUnpublish?(tracks: RCRemoteTrack[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* 房间内主播发布资源
|
|
39
|
+
* @param tracks 主播新发布的音轨与视轨数据列表,包含新发布的 RCRemoteAudioTrack 与 RCRemoteVideoTrack 实例
|
|
40
|
+
*/
|
|
41
|
+
onAnchorTrackPublish?(tracks: RCRemoteTrack[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* 房间内主播取消发布资源
|
|
44
|
+
* @param tracks 被主播取消发布的音轨与视轨数据列表
|
|
45
|
+
* @description 当资源被取消发布时,SDK 内部会取消对相关资源的订阅,业务层仅需处理 UI 业务
|
|
46
|
+
*/
|
|
47
|
+
onAnchorTrackUnpublish?(tracks: RCRemoteTrack[]): void;
|
|
48
|
+
/**
|
|
49
|
+
* 房间主播禁用/启用音频
|
|
50
|
+
* @param audioTrack RCRemoteAudioTrack 类实例
|
|
51
|
+
*/
|
|
52
|
+
onAudioMuteChange?(audioTrack: RCRemoteAudioTrack): void;
|
|
53
|
+
/**
|
|
54
|
+
* 房间主播禁用/启用视频
|
|
55
|
+
* @param videoTrack RCRemoteVideoTrack 类实例对象
|
|
56
|
+
*/
|
|
57
|
+
onVideoMuteChange?(videoTrack: RCRemoteVideoTrack): void;
|
|
58
|
+
/**
|
|
59
|
+
* 房间内主播把发布的资源推至 CDN
|
|
60
|
+
*/
|
|
61
|
+
onCDNInfoEnable?(CDNInfo: {
|
|
62
|
+
resolution: RCResolution;
|
|
63
|
+
fps: RCFrameRate;
|
|
64
|
+
}): void;
|
|
65
|
+
/**
|
|
66
|
+
* 主播停止推 CDN
|
|
67
|
+
*/
|
|
68
|
+
onCDNInfoDisable?(): void;
|
|
69
|
+
/**
|
|
70
|
+
* 主播改变推 CDN 的分辨率或帧率
|
|
71
|
+
*/
|
|
72
|
+
onCDNInfoChange?(CDNInfo: {
|
|
73
|
+
resolution: RCResolution;
|
|
74
|
+
fps: RCFrameRate;
|
|
75
|
+
}): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 观众直播房间类
|
|
79
|
+
* 处理:
|
|
80
|
+
* 1、通知观众房间内 人员变更、资源变更
|
|
81
|
+
* 2、观众订阅、取消订阅资源
|
|
82
|
+
*/
|
|
83
|
+
export default class RCAudienceLivingRoom {
|
|
84
|
+
private readonly _context;
|
|
85
|
+
private readonly _runtime;
|
|
86
|
+
private readonly _initOptions;
|
|
87
|
+
private readonly _roomId;
|
|
88
|
+
private readonly _joinResData;
|
|
89
|
+
readonly livingType: RCLivingType;
|
|
90
|
+
private _useMutilPeerC?;
|
|
91
|
+
protected readonly _clientSessionId: string;
|
|
92
|
+
private readonly _service;
|
|
93
|
+
/**
|
|
94
|
+
* 主播列表
|
|
95
|
+
*/
|
|
96
|
+
private _roomAnchorList;
|
|
97
|
+
/**
|
|
98
|
+
* 合流、分流资源
|
|
99
|
+
*/
|
|
100
|
+
private _roomRes;
|
|
101
|
+
/**
|
|
102
|
+
* 主播分流资源
|
|
103
|
+
*/
|
|
104
|
+
private _roomAnchorRes;
|
|
105
|
+
/**
|
|
106
|
+
* 合流、分流 remoteTracks
|
|
107
|
+
*/
|
|
108
|
+
private _remoteTracks;
|
|
109
|
+
private _appListener;
|
|
110
|
+
private _pc;
|
|
111
|
+
private _subscribedList;
|
|
112
|
+
private _sessionId;
|
|
113
|
+
private _destroyed;
|
|
114
|
+
/**
|
|
115
|
+
* 北极星上报实例
|
|
116
|
+
*/
|
|
117
|
+
protected _polarisReport: PolarisReporter | null;
|
|
118
|
+
/**
|
|
119
|
+
* 音量上报实例
|
|
120
|
+
*/
|
|
121
|
+
private _audioLevelReport;
|
|
122
|
+
/**
|
|
123
|
+
* cdn_uris 资源
|
|
124
|
+
*/
|
|
125
|
+
private _CDNUris;
|
|
126
|
+
/**
|
|
127
|
+
* 使用的 peerConnection 对应 id
|
|
128
|
+
*/
|
|
129
|
+
private _pcName;
|
|
130
|
+
/**
|
|
131
|
+
* peerConnection 管理类
|
|
132
|
+
*/
|
|
133
|
+
private _peerCManager;
|
|
134
|
+
constructor(_context: RTCPluginContext, _runtime: IRuntime, _initOptions: IRCRTCInitOptions, _roomId: string, _joinResData: {
|
|
135
|
+
token: string;
|
|
136
|
+
kvEntries: IServerRTCRoomEntry[];
|
|
137
|
+
}, livingType: RCLivingType, _useMutilPeerC?: boolean | undefined, _clientSessionId?: string);
|
|
138
|
+
/**
|
|
139
|
+
* 解析服务端返回的 KV 数据,赋值 room 内数据
|
|
140
|
+
*/
|
|
141
|
+
private _setInitData;
|
|
142
|
+
protected _assertRoomDestroyed(): RCRTCCode | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* @description 信令数据处理
|
|
145
|
+
* @param roomId 数据对应的房间 Id
|
|
146
|
+
* @param singalData 拉取到的数据
|
|
147
|
+
* * key RC_ANCHOR_LIST value: 为主播 ID 集合
|
|
148
|
+
* * key RC_RES_`userId` value: 为主播发布的资源
|
|
149
|
+
* * key RC_RTC_SESSIONID value: sessionId
|
|
150
|
+
* * key RC_CDN value: CDN 资源数据
|
|
151
|
+
*/
|
|
152
|
+
private singalDataChange;
|
|
153
|
+
/**
|
|
154
|
+
* 计算加入离开的主播 ID 列表
|
|
155
|
+
*/
|
|
156
|
+
private _diffAnchorList;
|
|
157
|
+
private _handleNewJoinedAnchor;
|
|
158
|
+
private _handleLeftedAnchor;
|
|
159
|
+
/**
|
|
160
|
+
* 计算新发布和取消发布的合流资源
|
|
161
|
+
*/
|
|
162
|
+
private _diffRoomResource;
|
|
163
|
+
/**
|
|
164
|
+
* 计算主播发布和取消发布的资源,以及资源的状态变更
|
|
165
|
+
*/
|
|
166
|
+
private _diffAnchorResource;
|
|
167
|
+
private _onUserUnpublish;
|
|
168
|
+
private _callAppListener;
|
|
169
|
+
/**
|
|
170
|
+
* ice 断线后,尝试重新走 exchange
|
|
171
|
+
*/
|
|
172
|
+
private _reTryExchange;
|
|
173
|
+
/**
|
|
174
|
+
* 获取 subscribe 接口的请求体数据
|
|
175
|
+
* @param subscribeList 订阅清单
|
|
176
|
+
* @param publishedStreams 已发布流
|
|
177
|
+
* @param iceRestart
|
|
178
|
+
*/
|
|
179
|
+
protected _createSubscribeParams(subscribeList: ISubscribeAttr[], publishedStreams: {
|
|
180
|
+
[msid: string]: RCLocalMediaStream;
|
|
181
|
+
}, iceRestart: boolean): Promise<{
|
|
182
|
+
reqBody: IBroadcastSubReqBody;
|
|
183
|
+
offer: RTCSessionDescriptionInit;
|
|
184
|
+
dynamicBitrate: {
|
|
185
|
+
min: number;
|
|
186
|
+
max: number;
|
|
187
|
+
};
|
|
188
|
+
}>;
|
|
189
|
+
private _subscribeHandle;
|
|
190
|
+
/**
|
|
191
|
+
* 添加 peerConnection 事件
|
|
192
|
+
*/
|
|
193
|
+
private _addPeerCEvent;
|
|
194
|
+
private _getReqHeaders;
|
|
195
|
+
private _exchangeHandle;
|
|
196
|
+
private _updateSubListHandle;
|
|
197
|
+
/**
|
|
198
|
+
* 对比 cdn_uris 资源
|
|
199
|
+
* @param newCDNUris 新的 cdn_uris 数据
|
|
200
|
+
*/
|
|
201
|
+
private _diffCDNUris;
|
|
202
|
+
/**
|
|
203
|
+
* 获取 CDN 资源对应的拉流地址
|
|
204
|
+
* _CDNUris 无 url 时,说明未开启 CDN 推送
|
|
205
|
+
* @returns CDNPlayUrl
|
|
206
|
+
*/
|
|
207
|
+
private _getCDNPlayUrl;
|
|
208
|
+
/**
|
|
209
|
+
* 获取 CDN 资源对应的拉流地址
|
|
210
|
+
* @returns CDNPlayUrl
|
|
211
|
+
*/
|
|
212
|
+
getCDNPlayUrl(resolution?: RCResolution, fps?: RCFrameRate): Promise<{
|
|
213
|
+
code: RCRTCCode;
|
|
214
|
+
CDNPlayUrl?: string;
|
|
215
|
+
}>;
|
|
216
|
+
/**
|
|
217
|
+
* 订阅资源
|
|
218
|
+
* @param tracks
|
|
219
|
+
*/
|
|
220
|
+
subscribe(tracks: (RCRemoteTrack | ISubscribeAttr)[]): Promise<{
|
|
221
|
+
code: RCRTCCode;
|
|
222
|
+
failedList?: ISubscribeAttr[];
|
|
223
|
+
}>;
|
|
224
|
+
private __unsubscribe;
|
|
225
|
+
/**
|
|
226
|
+
* 取消订阅资源
|
|
227
|
+
* @param tracks
|
|
228
|
+
*/
|
|
229
|
+
unsubscribe(tracks: RCRemoteTrack[]): Promise<{
|
|
230
|
+
code: RCRTCCode;
|
|
231
|
+
failedList?: ISubscribeAttr[];
|
|
232
|
+
}>;
|
|
233
|
+
/**
|
|
234
|
+
* 退出房间并销毁当前房间实例,退出后该房间的所有方法将不可用
|
|
235
|
+
*/
|
|
236
|
+
__destroy(quitRoom: boolean): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* 根据 trackId 获取房间内的远端资源
|
|
239
|
+
* @param trackId
|
|
240
|
+
*/
|
|
241
|
+
getRemoteTrack(trackId: string): RCRemoteTrack;
|
|
242
|
+
/**
|
|
243
|
+
* 获取 _pc 实例
|
|
244
|
+
*/
|
|
245
|
+
__getPC(): RCRTCPeerConnection[];
|
|
246
|
+
/**
|
|
247
|
+
* TODO 待优化
|
|
248
|
+
* @param trackId
|
|
249
|
+
*/
|
|
250
|
+
getLocalTrack(trackId: string): RCRemoteTrack;
|
|
251
|
+
/**
|
|
252
|
+
* 断线重连后处理逻辑, SDK 内部处理调用
|
|
253
|
+
*/
|
|
254
|
+
__onReconnected(): Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* 观众房间事件注册
|
|
257
|
+
* @param tag 参数描述
|
|
258
|
+
*/
|
|
259
|
+
registerRoomEventListener(listener: IAudienceRoomEventListener | null): void;
|
|
260
|
+
/**
|
|
261
|
+
* 音量上报
|
|
262
|
+
* @param handler 业务端传入的音量上报事件
|
|
263
|
+
* @param gap 上报时间间隔
|
|
264
|
+
*/
|
|
265
|
+
onAudioLevelChange(handler: IAudioLevelChangeHandler | null, gap?: number): void;
|
|
266
|
+
private _reportListener;
|
|
267
|
+
/**
|
|
268
|
+
* 注册房间数据监控
|
|
269
|
+
* @param listener
|
|
270
|
+
*/
|
|
271
|
+
registerReportListener(listener: IRCRTCReportListener | null): void;
|
|
272
|
+
/**
|
|
273
|
+
* 获取房间 Id
|
|
274
|
+
*/
|
|
275
|
+
getRoomId(): string;
|
|
276
|
+
/**
|
|
277
|
+
* 获取当前 userId
|
|
278
|
+
*/
|
|
279
|
+
getCrtUserId(): string;
|
|
280
|
+
/**
|
|
281
|
+
* 获取房间当前会话 Id,当房间内已无成员时房间会回收,重新加入时 sessionId 将更新
|
|
282
|
+
*/
|
|
283
|
+
getSessionId(): string;
|
|
284
|
+
/**
|
|
285
|
+
* 获取远程主播用户列表
|
|
286
|
+
*/
|
|
287
|
+
getRemoteUserIds(): string[];
|
|
288
|
+
/**
|
|
289
|
+
* 获取远端用户的资源列表
|
|
290
|
+
* @param userId
|
|
291
|
+
* @returns
|
|
292
|
+
*/
|
|
293
|
+
getRemoteTracksByUserId(userId: string): RCRemoteTrack[];
|
|
294
|
+
/**
|
|
295
|
+
* 获取房间内所有已发布的远端资源列表, 包含合流资源
|
|
296
|
+
* @returns
|
|
297
|
+
*/
|
|
298
|
+
getRemoteTracks(): RCRemoteTrack[];
|
|
299
|
+
/**
|
|
300
|
+
* 获取远端 RTC tracks
|
|
301
|
+
*/
|
|
302
|
+
getRemoteRTCTracks(): RCRemoteTrack[];
|
|
303
|
+
/**
|
|
304
|
+
* 获取远端 MCU tracks
|
|
305
|
+
*/
|
|
306
|
+
getRemoteMCUTracks(): RCRemoteTrack[];
|
|
307
|
+
/**
|
|
308
|
+
* 获取房间内 CDN 信息
|
|
309
|
+
*/
|
|
310
|
+
getCDNInfo(): {
|
|
311
|
+
resolution: RCResolution;
|
|
312
|
+
fps: RCFrameRate;
|
|
313
|
+
CDNEnable: boolean | undefined;
|
|
314
|
+
} | {
|
|
315
|
+
CDNEnable: boolean;
|
|
316
|
+
resolution?: undefined;
|
|
317
|
+
fps?: undefined;
|
|
318
|
+
};
|
|
319
|
+
getClientSessionId(): string;
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=RCAudienceLivingRoom.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IAudioLevelChangeHandler } from '../interfaces';
|
|
2
|
+
import RCAbstractRoom from './RCAbstractRoom';
|
|
3
|
+
import RCAudienceLivingRoom from './RCAudienceLivingRoom';
|
|
4
|
+
export default class RCAudioLevelReport {
|
|
5
|
+
private readonly _room;
|
|
6
|
+
private _audioLevelChangeHandler;
|
|
7
|
+
private _timer;
|
|
8
|
+
constructor(_room: RCAbstractRoom | RCAudienceLivingRoom);
|
|
9
|
+
/**
|
|
10
|
+
* 通知业务端音量 > 0 的数据,数组每一项包含 track、audioLevel
|
|
11
|
+
*/
|
|
12
|
+
private _audioLevelReport;
|
|
13
|
+
onAudioLevelChange(handler: IAudioLevelChangeHandler | null, gap: number): void;
|
|
14
|
+
clearAudioLevelReportTimer(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=RCAudioLevelReport.d.ts.map
|