@seastart/srtc-web-sdk 0.5.6 → 0.6.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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/srtc.d.mts +276 -1409
- package/srtc.d.ts +276 -1409
- package/srtc.js +1 -1
- package/srtc.mjs +1 -1
package/srtc.d.ts
CHANGED
|
@@ -1,302 +1,5 @@
|
|
|
1
|
-
import Bowser$1 from 'bowser';
|
|
2
1
|
import EventEmitter from 'events';
|
|
3
|
-
import { ClientRequestArgs } from 'http';
|
|
4
|
-
import { IAuthPacket, IConnackPacket, IConnectPacket, IDisconnectPacket, IPacket, IPingreqPacket, IPingrespPacket, IPubackPacket, IPubcompPacket, IPublishPacket, IPubrecPacket, IPubrelPacket, ISubackPacket, ISubscribePacket, ISubscription, IUnsubackPacket, IUnsubscribePacket, Packet, PacketCmd, QoS, UserProperties } from 'mqtt-packet';
|
|
5
|
-
import { ClientOptions } from 'ws';
|
|
6
2
|
|
|
7
|
-
declare abstract class BaseChannel extends EventEmitter {
|
|
8
|
-
/** 加入频道选项 */
|
|
9
|
-
protected options: JoinOptions;
|
|
10
|
-
/** 加入频道api返回的数据 */
|
|
11
|
-
protected joinRsp: ChannelJoinRsp;
|
|
12
|
-
/** 我自己 */
|
|
13
|
-
protected me?: BaseUser;
|
|
14
|
-
/** 频道成员 */
|
|
15
|
-
protected users: UserContainer;
|
|
16
|
-
/** 频道信息 */
|
|
17
|
-
protected info?: BaseChannelInfo;
|
|
18
|
-
/** 心跳定时器id */
|
|
19
|
-
protected heartbeatIntervalID?: number;
|
|
20
|
-
/** 频道连接状态 */
|
|
21
|
-
protected connectState: ChannelConnectState;
|
|
22
|
-
/** rtc http api */
|
|
23
|
-
protected rtcApi: BaseRtcApi;
|
|
24
|
-
/** rtc socket*/
|
|
25
|
-
protected rtcSocket: BaseRtcSocket;
|
|
26
|
-
/**
|
|
27
|
-
* 当前的媒体引擎
|
|
28
|
-
*/
|
|
29
|
-
protected rtcStreamEngine: BaseStreamEngine;
|
|
30
|
-
/** 混音流 */
|
|
31
|
-
protected audioMixTrack?: BaseTrack & (IMockRemoteAudioMixTrack | IRemoteAudioMixTrack);
|
|
32
|
-
/** 视频合成流 */
|
|
33
|
-
protected videoMcuTrack?: BaseTrack;
|
|
34
|
-
/** 兼容回调方式的事件响应 */
|
|
35
|
-
protected eventCB: ((evt: ChannelEvent) => void) | null;
|
|
36
|
-
/**
|
|
37
|
-
* 根据userinfo实例化user
|
|
38
|
-
* @param info
|
|
39
|
-
*/
|
|
40
|
-
protected abstract newUser(info: BaseUserInfo): BaseUser;
|
|
41
|
-
/**
|
|
42
|
-
* 进行中的流订阅/取消订阅等互斥操作mutex
|
|
43
|
-
*/
|
|
44
|
-
private trackMutex;
|
|
45
|
-
/**
|
|
46
|
-
* 流订阅/取消订阅防抖动
|
|
47
|
-
*/
|
|
48
|
-
private trackDebounce;
|
|
49
|
-
constructor(options: JoinOptions, rsp: ChannelJoinRsp, api: BaseRtcApi, streamEngine: BaseStreamEngine, socket: BaseRtcSocket, eventCB?: ((evt: ChannelEvent) => void) | null);
|
|
50
|
-
/**
|
|
51
|
-
* 刷新频道详情
|
|
52
|
-
*/
|
|
53
|
-
protected refresh(isReconnected: boolean): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* 入会时对已有远端轨道进行自动订阅
|
|
56
|
-
*/
|
|
57
|
-
private autoSubscribeExistingTracks;
|
|
58
|
-
/**
|
|
59
|
-
* 检查频道是否是已连接状态,不是则抛出错误
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
|
-
protected checkConnected(): void;
|
|
63
|
-
/**
|
|
64
|
-
* 监听socket
|
|
65
|
-
*/
|
|
66
|
-
private addSocketListeners;
|
|
67
|
-
/**
|
|
68
|
-
* 取消监听socket
|
|
69
|
-
*/
|
|
70
|
-
private removeSocketListeners;
|
|
71
|
-
/**
|
|
72
|
-
* 触发频道事件。
|
|
73
|
-
*
|
|
74
|
-
* 用 rest-tuple 技巧把 data 是否必填和 map 绑定起来:
|
|
75
|
-
* - 当 `ChannelEventDataMap[K]` 是 `undefined`(如 RECONNECTING):调用处省略第二个参数;
|
|
76
|
-
* - 其余情况:调用处**必须**传入与 map 对应的 data 类型。
|
|
77
|
-
* 这样新增事件类型时 TS 会卡在对应 emit 位置,避免 data 漂移。
|
|
78
|
-
*
|
|
79
|
-
* @param type 事件类型
|
|
80
|
-
* @param args 事件 data(类型由 map 决定)
|
|
81
|
-
*/
|
|
82
|
-
protected triggerEvent<K extends keyof ChannelEventDataMap>(type: K, ...args: ChannelEventDataMap[K] extends undefined ? [
|
|
83
|
-
] : [
|
|
84
|
-
data: ChannelEventDataMap[K]
|
|
85
|
-
]): void;
|
|
86
|
-
/**
|
|
87
|
-
* 心跳
|
|
88
|
-
*/
|
|
89
|
-
private heartbeat;
|
|
90
|
-
/**
|
|
91
|
-
* socket连接成功
|
|
92
|
-
*/
|
|
93
|
-
private onConnected;
|
|
94
|
-
/**
|
|
95
|
-
* socket开始重连
|
|
96
|
-
*/
|
|
97
|
-
private onStartReconnect;
|
|
98
|
-
/**
|
|
99
|
-
* 收到频道内消息
|
|
100
|
-
* @param pkt 消息体
|
|
101
|
-
*/
|
|
102
|
-
private onChannelMessage;
|
|
103
|
-
/**
|
|
104
|
-
* 获取自己
|
|
105
|
-
* @returns
|
|
106
|
-
*/
|
|
107
|
-
getMe(): BaseUser;
|
|
108
|
-
/**
|
|
109
|
-
* 获取某用户
|
|
110
|
-
* @param uid 用户id
|
|
111
|
-
*/
|
|
112
|
-
getUser(uid: string): BaseUser;
|
|
113
|
-
/**
|
|
114
|
-
* 获取用户信息列表
|
|
115
|
-
*/
|
|
116
|
-
getUsersInfo(map: boolean): BaseUserInfo[] | Record<string, BaseUserInfo>;
|
|
117
|
-
/**
|
|
118
|
-
* 离开频道
|
|
119
|
-
*/
|
|
120
|
-
leave(reason: DisconnectReason, error?: any): Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* 获取对sdk外部展现的频道信息
|
|
123
|
-
* @returns
|
|
124
|
-
*/
|
|
125
|
-
getInfo(): BaseChannelInfo;
|
|
126
|
-
/**
|
|
127
|
-
* 监听流媒体引擎事件(如质量/active speakers 等)。
|
|
128
|
-
* 基类默认空实现;具体引擎的 Channel 子类 override 注册自己的事件转发。
|
|
129
|
-
*/
|
|
130
|
-
protected addStreamEngineListeners(): void;
|
|
131
|
-
/**
|
|
132
|
-
* 获取流媒体引擎供应商
|
|
133
|
-
*/
|
|
134
|
-
getStreamEngineVendor(): string;
|
|
135
|
-
/**
|
|
136
|
-
* 获取轨道发布额外参数
|
|
137
|
-
*/
|
|
138
|
-
protected getPublishExOption(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): Promise<Record<string, any>>;
|
|
139
|
-
/**
|
|
140
|
-
* 获取发布后新增的tracks
|
|
141
|
-
* 之所以是数组是因为自研引擎支持发布流时自动simucast
|
|
142
|
-
*/
|
|
143
|
-
protected getAddedTracksAfterPublish(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): BaseTrack[];
|
|
144
|
-
/**
|
|
145
|
-
* 获取取消发布后删除的tracks
|
|
146
|
-
*/
|
|
147
|
-
protected getDeletedTracksAfterUnpublish(track: BaseTrack): BaseTrack[];
|
|
148
|
-
/**
|
|
149
|
-
* 发布本地流轨道
|
|
150
|
-
* @param track
|
|
151
|
-
* @returns
|
|
152
|
-
*/
|
|
153
|
-
publishLocalTrack(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* 取消发布本地流
|
|
156
|
-
* @param track
|
|
157
|
-
*/
|
|
158
|
-
unpublishLocalTrack(track: BaseTrack): Promise<void>;
|
|
159
|
-
/**
|
|
160
|
-
* 获取轨道订阅额外参数
|
|
161
|
-
*/
|
|
162
|
-
protected getSubscribeExOption(track: BaseTrack): Promise<Record<string, any>>;
|
|
163
|
-
/**
|
|
164
|
-
* 生成远端频道混音流
|
|
165
|
-
*/
|
|
166
|
-
protected abstract newRemoteAudioMixTrack(filter?: ((track: BaseTrack) => boolean) | string[]): BaseTrack & (IMockRemoteAudioMixTrack | IRemoteAudioMixTrack);
|
|
167
|
-
/**
|
|
168
|
-
* 生成远端视频合成流
|
|
169
|
-
*/
|
|
170
|
-
protected abstract newRemoteVideoMcuTrack(): BaseTrack;
|
|
171
|
-
/**
|
|
172
|
-
* 获取远端频道混音流
|
|
173
|
-
* @param filter 音频轨道过滤器,传递string[]时,根据uid过滤
|
|
174
|
-
*/
|
|
175
|
-
subscribeRemoteAudioMixTrack(filter?: ((track: BaseTrack) => boolean) | string[]): Promise<BaseTrack & (IMockRemoteAudioMixTrack | IRemoteAudioMixTrack)>;
|
|
176
|
-
/**
|
|
177
|
-
* 订阅远端用户音频流
|
|
178
|
-
* @param uid 用户id
|
|
179
|
-
* @param id 流轨道id
|
|
180
|
-
*/
|
|
181
|
-
subscribeRemoteAudioTrack(uid: string, id: string): Promise<BaseTrack>;
|
|
182
|
-
/**
|
|
183
|
-
* 订阅远端视频合成流
|
|
184
|
-
*/
|
|
185
|
-
subscribeRemoteVideoMcuTrack(): Promise<BaseTrack>;
|
|
186
|
-
/**
|
|
187
|
-
* 订阅远端用户视频流
|
|
188
|
-
* @param uid 用户id
|
|
189
|
-
* @param id 流轨道id
|
|
190
|
-
*/
|
|
191
|
-
subscribeRemoteVideoTrack(uid: string, id: string): Promise<BaseTrack>;
|
|
192
|
-
/**
|
|
193
|
-
* 取消订阅远端流
|
|
194
|
-
* @param track 流轨道
|
|
195
|
-
* @param debounceWaitMs 防取消订阅/订阅抖动ms数
|
|
196
|
-
*/
|
|
197
|
-
unsubscribeRemoteTrack(track: BaseTrack, debounceWaitMs?: number): Promise<void>;
|
|
198
|
-
}
|
|
199
|
-
declare abstract class BaseRtcApi {
|
|
200
|
-
/** rtc AppID */
|
|
201
|
-
protected appID: string;
|
|
202
|
-
/** rtc sid */
|
|
203
|
-
protected sid: string;
|
|
204
|
-
/** 客户端密钥 */
|
|
205
|
-
protected clientKey: string;
|
|
206
|
-
/** 服务器地址头部 */
|
|
207
|
-
protected serverPrefix?: string;
|
|
208
|
-
/**
|
|
209
|
-
* 发起rtc api http请求
|
|
210
|
-
*/
|
|
211
|
-
protected abstract http(api: string, params: Record<string, any>, headers: Record<string, string>): Promise<any>;
|
|
212
|
-
constructor(appID: string, sid: string, clientKey: string, serverPrefix: string);
|
|
213
|
-
/**
|
|
214
|
-
* 加入频道
|
|
215
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=51c6ed8
|
|
216
|
-
*/
|
|
217
|
-
join(params: {
|
|
218
|
-
deviceType: DeviceType;
|
|
219
|
-
deviceID: string;
|
|
220
|
-
version: string;
|
|
221
|
-
}): Promise<ChannelJoinRsp>;
|
|
222
|
-
/**
|
|
223
|
-
* 频道详情
|
|
224
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=520ba1f
|
|
225
|
-
* @param listuser 是否包括在线用户列表,true则返回所有在线用户
|
|
226
|
-
* @returns
|
|
227
|
-
*/
|
|
228
|
-
detail(listuser: boolean): Promise<{
|
|
229
|
-
channelinfo: BaseChannelInfo;
|
|
230
|
-
userinfos: BaseUserInfo[] | null;
|
|
231
|
-
}>;
|
|
232
|
-
/**
|
|
233
|
-
* 离开频道
|
|
234
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=51d732b
|
|
235
|
-
* @returns
|
|
236
|
-
*/
|
|
237
|
-
leave(): Promise<void>;
|
|
238
|
-
/**
|
|
239
|
-
* 发送心跳
|
|
240
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=51d38e3
|
|
241
|
-
* @returns
|
|
242
|
-
*/
|
|
243
|
-
heartbeat(): Promise<void>;
|
|
244
|
-
/**
|
|
245
|
-
* 断线重连
|
|
246
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=52602cf
|
|
247
|
-
* @returns
|
|
248
|
-
*/
|
|
249
|
-
reconnect(params: {
|
|
250
|
-
type: number;
|
|
251
|
-
}): Promise<ReconnectRsp>;
|
|
252
|
-
/**
|
|
253
|
-
* 更新流信息
|
|
254
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=51c6eae
|
|
255
|
-
* @returns
|
|
256
|
-
*/
|
|
257
|
-
updateStream(trackinfos: BaseTrackInfo[]): Promise<void>;
|
|
258
|
-
/**
|
|
259
|
-
* im连接
|
|
260
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=25c1132f700054
|
|
261
|
-
* @returns
|
|
262
|
-
*/
|
|
263
|
-
imConnect(params: {
|
|
264
|
-
deviceType: DeviceType;
|
|
265
|
-
deviceID: string;
|
|
266
|
-
version: string;
|
|
267
|
-
}): Promise<ImConnectRsp>;
|
|
268
|
-
/**
|
|
269
|
-
* im重连
|
|
270
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=25c2a79e70007f
|
|
271
|
-
* @returns
|
|
272
|
-
*/
|
|
273
|
-
imReconnect(): Promise<ImConnectRsp>;
|
|
274
|
-
/**
|
|
275
|
-
* im发送心跳
|
|
276
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=25c2da5cb00081
|
|
277
|
-
* @returns
|
|
278
|
-
*/
|
|
279
|
-
imHeartbeat(): Promise<void>;
|
|
280
|
-
/**
|
|
281
|
-
* im断开连接
|
|
282
|
-
* @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=25c356d2300092
|
|
283
|
-
* @returns
|
|
284
|
-
*/
|
|
285
|
-
imDisconnect(): Promise<void>;
|
|
286
|
-
/**
|
|
287
|
-
* 发送rtc sdk api请求
|
|
288
|
-
* @param api api接口
|
|
289
|
-
* @param params 数据
|
|
290
|
-
* @param headers 额外http头
|
|
291
|
-
*/
|
|
292
|
-
protected req(api: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<any>;
|
|
293
|
-
/**
|
|
294
|
-
* 签名
|
|
295
|
-
* @param params
|
|
296
|
-
* @returns
|
|
297
|
-
*/
|
|
298
|
-
private signature;
|
|
299
|
-
}
|
|
300
3
|
declare abstract class BaseSRTC {
|
|
301
4
|
/**
|
|
302
5
|
* 获取sdk编译信息
|
|
@@ -317,17 +20,20 @@ declare abstract class BaseSRTC {
|
|
|
317
20
|
onNotifyImEvent?: ((event: ImEvent) => void) | null;
|
|
318
21
|
constructor(initParams: SdkInitParams);
|
|
319
22
|
/**
|
|
320
|
-
*
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
*
|
|
23
|
+
* 加入频道,返回该频道的 Channel 对象。
|
|
24
|
+
*
|
|
25
|
+
* 频道级操作(发布/订阅/成员/事件/离会)都在返回的 Channel 上进行;SRTC 门面
|
|
26
|
+
* 的同名便捷方法等价于操作**默认频道**(最早加入且仍存活的那个)。
|
|
27
|
+
* web 端可多次 join 同时加入多个频道;小程序端受 live-pusher 独占限制仍是单频道。
|
|
28
|
+
*
|
|
325
29
|
* @param token 加入频道token
|
|
326
30
|
* @param options 加入频道选项
|
|
31
|
+
* @returns 频道对象;原先 join 返回的频道信息改用 `channel.getInfo()` 获取
|
|
327
32
|
*/
|
|
328
|
-
join(token: string, options?: JoinOptions): Promise<
|
|
33
|
+
join(token: string, options?: JoinOptions): Promise<BaseChannel>;
|
|
329
34
|
/**
|
|
330
|
-
*
|
|
35
|
+
* 离开默认频道(最早加入且仍存活的频道)。
|
|
36
|
+
* 多频道场景建议直接用 `channel.leave()` 精确指定要离开的频道。
|
|
331
37
|
*/
|
|
332
38
|
leave(): Promise<void>;
|
|
333
39
|
/**
|
|
@@ -335,6 +41,15 @@ declare abstract class BaseSRTC {
|
|
|
335
41
|
* @returns
|
|
336
42
|
*/
|
|
337
43
|
getChannelInfo(): BaseChannelInfo | null;
|
|
44
|
+
/**
|
|
45
|
+
* 获取某本地轨在本实例所在频道内的轨道描述。
|
|
46
|
+
*
|
|
47
|
+
* 一般直接用 `track.getInfo()` 即可。仅当同一条采集轨被发布到多个频道(多个 SRTC 实例
|
|
48
|
+
* 各进一个频道)时才需要本方法:那种情况下一份 info 表达不了多个频道各自的描述
|
|
49
|
+
* (服务端分配的 id、归属 uid、联播分层等),`track.getInfo()` 会回落到采集轨自身描述,
|
|
50
|
+
* 用本方法可精确取到它在本实例这个频道里的那一份。未在本频道发布则返回 undefined。
|
|
51
|
+
*/
|
|
52
|
+
getPublishInfo(track: BaseLocalTrack): BaseTrackInfo | undefined;
|
|
338
53
|
/**
|
|
339
54
|
* 获取某用户信息
|
|
340
55
|
* @returns
|
|
@@ -388,175 +103,36 @@ declare abstract class BaseSRTC {
|
|
|
388
103
|
* 关闭频道外消息
|
|
389
104
|
*/
|
|
390
105
|
disableIm(): Promise<void>;
|
|
391
|
-
}
|
|
392
|
-
declare abstract class BaseStreamEngine extends EventEmitter {
|
|
393
|
-
/** 加入频道api返回的数据 */
|
|
394
|
-
protected joinRsp: ChannelJoinRsp;
|
|
395
|
-
/** 已发布轨道 */
|
|
396
|
-
protected published: Record<string, BaseTrackEx>;
|
|
397
|
-
/** 已订阅轨道 */
|
|
398
|
-
protected subscribed: Record<string, BaseTrackEx>;
|
|
399
|
-
/** 能力 */
|
|
400
|
-
protected ability?: StreamEngineAbility;
|
|
401
|
-
/** 采集metric指标定时器(用于日志上报) */
|
|
402
|
-
protected monitorInterval?: number;
|
|
403
|
-
constructor(rsp: ChannelJoinRsp, ability?: Partial<StreamEngineAbility>);
|
|
404
|
-
/**
|
|
405
|
-
* 流媒体服务商名
|
|
406
|
-
*/
|
|
407
|
-
abstract vendor(): string;
|
|
408
|
-
/**
|
|
409
|
-
* 连接流媒体服务(如果需要,程博webrtc流媒体就需要)
|
|
410
|
-
*/
|
|
411
|
-
connect(): Promise<void>;
|
|
412
|
-
/**
|
|
413
|
-
* 发布本地流
|
|
414
|
-
* @param track
|
|
415
|
-
* @param opt 通用发布参数
|
|
416
|
-
* @param exopt 该引擎特有的发布参数
|
|
417
|
-
*/
|
|
418
|
-
publish(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions, exopt: Record<string, any>): Promise<void>;
|
|
419
|
-
/**
|
|
420
|
-
* 取消发布本地流
|
|
421
|
-
* @param track
|
|
422
|
-
*/
|
|
423
|
-
abstract unpublish(track: BaseTrack): Promise<void>;
|
|
424
106
|
/**
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
* @param exopt 该引擎特有的订阅参数
|
|
428
|
-
*/
|
|
429
|
-
subscribe(track: BaseTrack, exopt: Record<string, any>): Promise<void>;
|
|
430
|
-
/**
|
|
431
|
-
* 是否已订阅某轨道
|
|
432
|
-
* @param track
|
|
433
|
-
* @returns
|
|
434
|
-
*/
|
|
435
|
-
haveSubscribed(track: BaseTrack): boolean;
|
|
436
|
-
/**
|
|
437
|
-
* 取消订阅远端流
|
|
438
|
-
* @param track
|
|
439
|
-
* @param exopt 该引擎特有的取消订阅参数
|
|
440
|
-
*/
|
|
441
|
-
abstract unsubscribe(track: BaseTrack): Promise<void>;
|
|
442
|
-
/**
|
|
443
|
-
* 断开流媒体服务
|
|
444
|
-
*/
|
|
445
|
-
disconnect(): Promise<void>;
|
|
446
|
-
/**
|
|
447
|
-
* 获取当前metric快照
|
|
448
|
-
*/
|
|
449
|
-
getMetricSnapshot(): Record<string, any> | undefined;
|
|
450
|
-
/**
|
|
451
|
-
* 开始metric采集
|
|
107
|
+
* 彻底释放整个 SRTC 引擎:离开所有频道、关闭 im,并解除构造时注册的进程级监听
|
|
108
|
+
* (设备插拔、页面可见性等,由各端子类通过 releaseGlobalListeners 提供)。
|
|
452
109
|
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* 获取metric数据
|
|
459
|
-
* @returns
|
|
460
|
-
*/
|
|
461
|
-
protected abstract getMetric(): Promise<Record<string, any>>;
|
|
462
|
-
/**
|
|
463
|
-
* 结束metric采集
|
|
110
|
+
* 不调用 destroy() 则引擎注册的浏览器事件监听会一直持有它的引用、永远不会被回收,
|
|
111
|
+
* SPA 路由切换、组件卸载时务必调用。
|
|
112
|
+
*
|
|
113
|
+
* 各离会/关闭步骤互不依赖,即使某一步报错也会继续做完剩下的清理,最后统一抛出汇总错误。
|
|
464
114
|
*/
|
|
465
|
-
|
|
115
|
+
destroy(): Promise<void>;
|
|
466
116
|
}
|
|
467
|
-
declare abstract class
|
|
468
|
-
constructor(info: BaseTrackInfo, uid: string);
|
|
117
|
+
declare abstract class BaseWebrtcLocalTrack extends BaseWebrtcTrack implements BaseLocalTrack {
|
|
469
118
|
/**
|
|
470
|
-
* 轨道id
|
|
119
|
+
* 轨道id。发布后引擎可能把 id 改写为服务端分配值(如 seastart 联播副轨),
|
|
120
|
+
* 单发布时代理到发布记录,保证与上报给会控的 id 一致
|
|
471
121
|
*/
|
|
472
122
|
get id(): string;
|
|
473
|
-
/**
|
|
474
|
-
* 轨道类型
|
|
475
|
-
*/
|
|
476
|
-
get kind(): TrackKind;
|
|
477
|
-
/**
|
|
478
|
-
* 轨道描述
|
|
479
|
-
*/
|
|
123
|
+
/** 轨道描述(单发布时代理到发布记录) */
|
|
480
124
|
get desc(): string;
|
|
481
|
-
/**
|
|
482
|
-
* 是否为 simulcast 副层
|
|
483
|
-
*/
|
|
125
|
+
/** 是否为 simulcast 副层(单发布时代理到发布记录) */
|
|
484
126
|
get variant(): boolean | undefined;
|
|
127
|
+
/** 视频角度(单发布时代理到发布记录) */
|
|
128
|
+
get angle(): number;
|
|
485
129
|
/**
|
|
486
|
-
*
|
|
487
|
-
*
|
|
130
|
+
* 获取流轨道信息:单发布 → 该次发布在频道内的描述(与旧版行为一致);
|
|
131
|
+
* 未发布 → 采集轨自身描述;发布到多个频道 → 抛错,请改用 channel.getPublishInfo(track)
|
|
488
132
|
*/
|
|
489
133
|
getInfo(): BaseTrackInfo;
|
|
490
|
-
/**
|
|
491
|
-
* 轨道所属用户
|
|
492
|
-
* @returns
|
|
493
|
-
*/
|
|
134
|
+
/** 轨道归属 uid:发布登记到 me 名下时由频道回填到发布记录,单发布时代理过去 */
|
|
494
135
|
getUid(): string;
|
|
495
|
-
toString(): string;
|
|
496
|
-
}
|
|
497
|
-
declare abstract class BaseUser {
|
|
498
|
-
/** track 数组 */
|
|
499
|
-
protected tracks: Record<string, BaseTrack>;
|
|
500
|
-
/** 对外输出的info */
|
|
501
|
-
protected info: BaseUserInfo;
|
|
502
|
-
/**
|
|
503
|
-
* 根据trackinfo实例化track
|
|
504
|
-
* @param trackinfo
|
|
505
|
-
*/
|
|
506
|
-
protected abstract newTrack(info: BaseTrackInfo): BaseTrack;
|
|
507
|
-
constructor(info: BaseUserInfo);
|
|
508
|
-
/**
|
|
509
|
-
* 获取某轨道
|
|
510
|
-
*/
|
|
511
|
-
getTrack(id: string): BaseTrack | undefined;
|
|
512
|
-
/**
|
|
513
|
-
* 根据desc获取某轨道
|
|
514
|
-
*/
|
|
515
|
-
getTrackByDesc(desc: string): BaseTrack | undefined;
|
|
516
|
-
/**
|
|
517
|
-
* 获取所有轨道
|
|
518
|
-
* @returns
|
|
519
|
-
*/
|
|
520
|
-
getTracks(): Record<string, BaseTrack>;
|
|
521
|
-
/**
|
|
522
|
-
* 全量更新tracks,目前会控只有全量更新某用户的所有track
|
|
523
|
-
* @param trackinfos 新的全量trackinfos
|
|
524
|
-
*/
|
|
525
|
-
updateTracks(trackinfos: BaseTrackInfo[]): {
|
|
526
|
-
added: BaseTrack[];
|
|
527
|
-
updated: BaseTrack[];
|
|
528
|
-
deleted: BaseTrack[];
|
|
529
|
-
};
|
|
530
|
-
/**
|
|
531
|
-
* 第三方用户id
|
|
532
|
-
*/
|
|
533
|
-
get uid(): string;
|
|
534
|
-
/**
|
|
535
|
-
* 会话id
|
|
536
|
-
*/
|
|
537
|
-
get sid(): string;
|
|
538
|
-
/**
|
|
539
|
-
* 设备类型
|
|
540
|
-
*/
|
|
541
|
-
get device_type(): number;
|
|
542
|
-
/**
|
|
543
|
-
* 设备id
|
|
544
|
-
*/
|
|
545
|
-
get device_id(): string;
|
|
546
|
-
/**
|
|
547
|
-
* 流媒体连接id
|
|
548
|
-
*/
|
|
549
|
-
get link_id(): number;
|
|
550
|
-
/**
|
|
551
|
-
* 获取对sdk外部展现的用户信息
|
|
552
|
-
* @returns
|
|
553
|
-
*/
|
|
554
|
-
getInfo(): BaseUserInfo;
|
|
555
|
-
/**
|
|
556
|
-
* 更新描述信息
|
|
557
|
-
* @param info
|
|
558
|
-
*/
|
|
559
|
-
updateInfo(info: Partial<BaseUserInfo>): void;
|
|
560
136
|
}
|
|
561
137
|
declare abstract class BaseWebrtcTrack extends BaseTrack {
|
|
562
138
|
constructor(info: BaseTrackInfo, uid: string);
|
|
@@ -564,105 +140,6 @@ declare abstract class BaseWebrtcTrack extends BaseTrack {
|
|
|
564
140
|
getMediaStreamTrack(): MediaStreamTrack | undefined;
|
|
565
141
|
getMediaStream(): MediaStream;
|
|
566
142
|
}
|
|
567
|
-
declare class BaseRtcSocket extends EventEmitter {
|
|
568
|
-
/** mqtt客户端 */
|
|
569
|
-
private client;
|
|
570
|
-
/** 会控协议版本头 */
|
|
571
|
-
private version;
|
|
572
|
-
/** 已订阅topics:qos */
|
|
573
|
-
private ssTopics;
|
|
574
|
-
/** 重连时刷新auth */
|
|
575
|
-
protected authReconnect?: AuthReconnect;
|
|
576
|
-
/** 是否首次连接 */
|
|
577
|
-
private isFirstConnect;
|
|
578
|
-
/** 消息解析 */
|
|
579
|
-
private unpacker;
|
|
580
|
-
constructor(authReconnect?: AuthReconnect);
|
|
581
|
-
/**
|
|
582
|
-
* 初始化mqtt客户端
|
|
583
|
-
* @param server
|
|
584
|
-
*/
|
|
585
|
-
private initClient;
|
|
586
|
-
/**
|
|
587
|
-
* 转换websocket地址,主要小程序需要用wxs前缀
|
|
588
|
-
* @param ws
|
|
589
|
-
* @returns
|
|
590
|
-
*/
|
|
591
|
-
protected getBrokerUrl(ws: string): string;
|
|
592
|
-
/**
|
|
593
|
-
* 连接mqtt服务器
|
|
594
|
-
* @param server
|
|
595
|
-
*/
|
|
596
|
-
connect(server: MqttServer): Promise<void>;
|
|
597
|
-
/**
|
|
598
|
-
* 添加socket常驻监听
|
|
599
|
-
*/
|
|
600
|
-
private addListeners;
|
|
601
|
-
/**
|
|
602
|
-
* 封装mqtt的subscribe为promise
|
|
603
|
-
* @param topic 话题或者话题数组
|
|
604
|
-
*/
|
|
605
|
-
subscribe(topic: string | string[], qos?: QoS): Promise<void>;
|
|
606
|
-
/**
|
|
607
|
-
* 封装mqtt的unsubscribe为promise
|
|
608
|
-
* @param topic 话题或者话题数组
|
|
609
|
-
*/
|
|
610
|
-
unsubscribe(topic: string | string[]): Promise<void>;
|
|
611
|
-
/**
|
|
612
|
-
* 关闭socket
|
|
613
|
-
* @param force 是否强制退出(不等待ack),对应mqttclient的end里的force
|
|
614
|
-
* @returns
|
|
615
|
-
*/
|
|
616
|
-
close(force?: boolean): Promise<void>;
|
|
617
|
-
/**
|
|
618
|
-
* 发送消息
|
|
619
|
-
* @param data 数据
|
|
620
|
-
* @param type 消息类型
|
|
621
|
-
*/
|
|
622
|
-
sendMsg(msg: string | Buffer, topic: string, qos?: QoS): Promise<void>;
|
|
623
|
-
/**
|
|
624
|
-
* 收到mqtt消息响应
|
|
625
|
-
* @param topic mqtt主题
|
|
626
|
-
* @param payload 消息载荷
|
|
627
|
-
* @param packet
|
|
628
|
-
* @returns
|
|
629
|
-
*/
|
|
630
|
-
private onMsg;
|
|
631
|
-
}
|
|
632
|
-
declare class Channel extends BaseChannel {
|
|
633
|
-
/**
|
|
634
|
-
* override:注册 webrtc 引擎特有的质量 / active speakers 事件转发。
|
|
635
|
-
*/
|
|
636
|
-
protected addStreamEngineListeners(): void;
|
|
637
|
-
/**
|
|
638
|
-
* 获取流媒体引擎的metric快照(全量,包含每条轨道的统计)
|
|
639
|
-
*/
|
|
640
|
-
getStreamMetric(): StreamMetric | undefined;
|
|
641
|
-
/**
|
|
642
|
-
* 获取当前网络总体统计,轻量接口,只关心网络整体指标时使用
|
|
643
|
-
*/
|
|
644
|
-
getNetworkStats(): NetworkStats | undefined;
|
|
645
|
-
/**
|
|
646
|
-
* 获取当前连接质量评估结果(等级、MOS、原因等)
|
|
647
|
-
*/
|
|
648
|
-
getConnectionQuality(): QualityEvaluation | undefined;
|
|
649
|
-
protected getPublishExOption(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): Promise<Record<string, any>>;
|
|
650
|
-
protected getAddedTracksAfterPublish(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): BaseTrack[];
|
|
651
|
-
protected getDeletedTracksAfterUnpublish(track: BaseTrack): BaseTrack[];
|
|
652
|
-
protected getSubscribeExOption(track: BaseTrack): Promise<Record<string, any>>;
|
|
653
|
-
protected newRemoteAudioMixTrack(filter?: ((track: BaseTrack) => boolean) | string[]): RemoteAudioMixTrack | MockRemoteAudioMixTrack;
|
|
654
|
-
protected newRemoteVideoMcuTrack(): RemoteVideoMcuTrack;
|
|
655
|
-
subscribeRemoteVideoTrack(uid: string, id: string): Promise<BaseTrack>;
|
|
656
|
-
unsubscribeRemoteTrack(track: BaseTrack, debounceWaitMs?: number): Promise<void>;
|
|
657
|
-
/** 自适应流管理器。懒初始化,避免父类构造期还未准备好 rtcStreamEngine/options 的问题。 */
|
|
658
|
-
private adaptiveStream?;
|
|
659
|
-
private getAdaptiveStream;
|
|
660
|
-
/**
|
|
661
|
-
* 解析某路远端视频订阅的完整候选层,顺序"高到低"。
|
|
662
|
-
* 这一步依赖 user 结构,所以留在 Channel 里作为解析器喂给 Manager。
|
|
663
|
-
*/
|
|
664
|
-
private getAdaptiveVideoCandidates;
|
|
665
|
-
}
|
|
666
143
|
declare class CommonChannelEventType {
|
|
667
144
|
/** 频道自定义props更新 */
|
|
668
145
|
static readonly CHANNEL_UPDATE = "channel_update";
|
|
@@ -720,337 +197,193 @@ declare class CommonTrackEventType {
|
|
|
720
197
|
/** playback or streaming has stopped because the end of the media was reached or because no further data is available */
|
|
721
198
|
static readonly ENDED = "ended";
|
|
722
199
|
}
|
|
723
|
-
declare class
|
|
724
|
-
constructor(
|
|
725
|
-
setTarget(target: LogTarget): void;
|
|
726
|
-
setLevel(level: LogLevel): void;
|
|
727
|
-
debug(...args: any[]): void;
|
|
728
|
-
info(...args: any[]): void;
|
|
729
|
-
warn(...args: any[]): void;
|
|
730
|
-
error(...args: any[]): void;
|
|
200
|
+
declare class RemoteVideoMcuTrack extends RemoteVideoTrack {
|
|
201
|
+
constructor();
|
|
731
202
|
}
|
|
732
|
-
declare class
|
|
733
|
-
|
|
203
|
+
declare class TrackEventType extends CommonTrackEventType {
|
|
204
|
+
/** 轨道自动播放失败,对应data为BaseTrack */
|
|
205
|
+
static readonly AUTOPLAY_FAIL = "autoplay_fail";
|
|
206
|
+
/** mediastreamtrack轨道被替换,对应data为BaseTrack,oldMsTrack为旧的MediaStreamTrack */
|
|
207
|
+
static readonly MSTRACK_REPLACED = "mstrack_replaced";
|
|
208
|
+
/** 轨道流媒体开始断线自动重连,对应data为BaseTrack*/
|
|
209
|
+
static readonly RECONNECTING = "reconnecting";
|
|
210
|
+
/** 轨道流媒体重连成功,对应data为BaseTrack */
|
|
211
|
+
static readonly RECONNECTED = "reconnected";
|
|
212
|
+
/** 进入画中画模式,对应data为BaseTrack */
|
|
213
|
+
static readonly PIP_ENTER = "pip_enter";
|
|
214
|
+
/** 退出画中画模式,对应data为BaseTrack */
|
|
215
|
+
static readonly PIP_EXIT = "pip_exit";
|
|
216
|
+
/** 弹出独立窗口,对应data为BaseTrack */
|
|
217
|
+
static readonly POPOUT_OPEN = "popout_open";
|
|
218
|
+
/** 关闭独立窗口,对应data为BaseTrack */
|
|
219
|
+
static readonly POPOUT_CLOSE = "popout_close";
|
|
220
|
+
}
|
|
221
|
+
export declare abstract class BaseChannel extends EventEmitter {
|
|
734
222
|
/**
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
223
|
+
* 本频道事件的回调式入口,交给 SDK 使用者设置。
|
|
224
|
+
* 与 `channel.on()/once()` 的类型化监听等价,二选一即可;多频道场景下各频道
|
|
225
|
+
* 各自设置,事件天然按频道隔离(`srtc.onNotifyChannelEvent` 只收默认频道的)。
|
|
738
226
|
*/
|
|
739
|
-
|
|
227
|
+
onNotifyEvent: ((evt: ChannelEvent) => void) | null;
|
|
740
228
|
/**
|
|
741
|
-
*
|
|
742
|
-
*
|
|
229
|
+
* Channel 由 `srtc.join()` 创建并返回,不允许外部直接 new。
|
|
230
|
+
*
|
|
231
|
+
* 这条重载签名是唯一进 d.ts 的构造签名:protected 挡住外部 new,参数刻意
|
|
232
|
+
* 不透明(真实参数类型都是内部类,写在这里会把它们连同 mqtt/ws 等依赖类型
|
|
233
|
+
* 一起拖进公开声明)。真实签名见下面的实现,SRTC 经各平台 Channel 的
|
|
234
|
+
* 内部静态工厂 create 实例化。
|
|
743
235
|
*/
|
|
744
|
-
|
|
236
|
+
protected constructor(...args: unknown[]);
|
|
745
237
|
/**
|
|
746
|
-
*
|
|
747
|
-
* @param track
|
|
238
|
+
* 获取用户信息列表
|
|
748
239
|
*/
|
|
749
|
-
|
|
240
|
+
getUsersInfo(map: boolean): BaseUserInfo[] | Record<string, BaseUserInfo>;
|
|
750
241
|
/**
|
|
751
|
-
*
|
|
242
|
+
* 离开频道。SDK 使用者直接 `channel.leave()` 即可(原因默认为主动离开)。
|
|
752
243
|
*/
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
public disconnecting: boolean;
|
|
758
|
-
public disconnected: boolean;
|
|
759
|
-
public reconnecting: boolean;
|
|
760
|
-
public incomingStore: Store;
|
|
761
|
-
public outgoingStore: Store;
|
|
762
|
-
public options: IClientOptions;
|
|
763
|
-
public queueQoSZero: boolean;
|
|
764
|
-
constructor(streamBuilder: (client: MqttClient) => IStream, options: IClientOptions);
|
|
765
|
-
public on(event: "connect", cb: OnConnectCallback): this;
|
|
766
|
-
public on(event: "message", cb: OnMessageCallback): this;
|
|
767
|
-
public on(event: "packetsend" | "packetreceive", cb: OnPacketCallback): this;
|
|
768
|
-
public on(event: "disconnect", cb: OnDisconnectCallback): this;
|
|
769
|
-
public on(event: "error", cb: OnErrorCallback): this;
|
|
770
|
-
public on(event: "close", cb: OnCloseCallback): this;
|
|
771
|
-
public on(event: "end" | "reconnect" | "offline" | "outgoingEmpty", cb: () => void): this;
|
|
772
|
-
public on(event: string, cb: Function): this;
|
|
773
|
-
public once(event: "connect", cb: OnConnectCallback): this;
|
|
774
|
-
public once(event: "message", cb: OnMessageCallback): this;
|
|
775
|
-
public once(event: "packetsend" | "packetreceive", cb: OnPacketCallback): this;
|
|
776
|
-
public once(event: "disconnect", cb: OnDisconnectCallback): this;
|
|
777
|
-
public once(event: "error", cb: OnErrorCallback): this;
|
|
778
|
-
public once(event: "close", cb: OnCloseCallback): this;
|
|
779
|
-
public once(event: "end" | "reconnect" | "offline" | "outgoingEmpty", cb: () => void): this;
|
|
780
|
-
public once(event: string, cb: Function): this;
|
|
781
|
-
/**
|
|
782
|
-
* publish - publish <message> to <topic>
|
|
783
|
-
*
|
|
784
|
-
* @param {String} topic - topic to publish to
|
|
785
|
-
* @param {(String|Buffer)} message - message to publish
|
|
786
|
-
*
|
|
787
|
-
* @param {Object} [opts] - publish options, includes:
|
|
788
|
-
* @param {Number} [opts.qos] - qos level to publish on
|
|
789
|
-
* @param {Boolean} [opts.retain] - whether or not to retain the message
|
|
790
|
-
* @param {Function}[opts.cbStorePut] - function(){}
|
|
791
|
-
* called when message is put into `outgoingStore`
|
|
792
|
-
*
|
|
793
|
-
* @param {Function} [callback] - function(err){}
|
|
794
|
-
* called when publish succeeds or fails
|
|
795
|
-
*
|
|
796
|
-
* @returns {Client} this - for chaining
|
|
797
|
-
* @api public
|
|
798
|
-
*
|
|
799
|
-
* @example client.publish('topic', 'message')
|
|
800
|
-
* @example
|
|
801
|
-
* client.publish('topic', 'message', {qos: 1, retain: true})
|
|
802
|
-
* @example client.publish('topic', 'message', console.log)
|
|
244
|
+
leave(reason?: DisconnectReason, error?: any): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* 获取对sdk外部展现的频道信息
|
|
247
|
+
* @returns
|
|
803
248
|
*/
|
|
804
|
-
|
|
805
|
-
public publish(topic: string, message: string | Buffer, callback?: PacketCallback): this;
|
|
249
|
+
getInfo(): BaseChannelInfo;
|
|
806
250
|
/**
|
|
807
|
-
*
|
|
808
|
-
*
|
|
809
|
-
* @param {String, Array, Object} topic - topic(s) to subscribe to, supports objects in the form {'topic': qos}
|
|
810
|
-
* @param {Object} [opts] - optional subscription options, includes:
|
|
811
|
-
* @param {Number} [opts.qos] - subscribe qos level
|
|
812
|
-
* @param {Function} [callback] - function(err, granted){} where:
|
|
813
|
-
* {Error} err - subscription error (none at the moment!)
|
|
814
|
-
* {Array} granted - array of {topic: 't', qos: 0}
|
|
815
|
-
* @returns {MqttClient} this - for chaining
|
|
816
|
-
* @api public
|
|
817
|
-
* @example client.subscribe('topic')
|
|
818
|
-
* @example client.subscribe('topic', {qos: 1})
|
|
819
|
-
* @example client.subscribe({'topic': 0, 'topic2': 1}, console.log)
|
|
820
|
-
* @example client.subscribe('topic', console.log)
|
|
821
|
-
*/
|
|
822
|
-
public subscribe(topic: string | string[], opts: IClientSubscribeOptions, callback?: ClientSubscribeCallback): this;
|
|
823
|
-
public subscribe(topic: string | string[] | ISubscriptionMap, callback?: ClientSubscribeCallback): this;
|
|
824
|
-
/**
|
|
825
|
-
* unsubscribe - unsubscribe from topic(s)
|
|
826
|
-
*
|
|
827
|
-
* @param {String, Array} topic - topics to unsubscribe from
|
|
828
|
-
* @param {Object} opts - opts of unsubscribe
|
|
829
|
-
* @param {Function} [callback] - callback fired on unsuback
|
|
830
|
-
* @returns {MqttClient} this - for chaining
|
|
831
|
-
* @api public
|
|
832
|
-
* @example client.unsubscribe('topic')
|
|
833
|
-
* @example client.unsubscribe('topic', console.log)
|
|
834
|
-
* @example client.unsubscribe('topic', opts, console.log)
|
|
835
|
-
*/
|
|
836
|
-
public unsubscribe(topic: string | string[], opts?: Object, callback?: PacketCallback): this;
|
|
837
|
-
/**
|
|
838
|
-
* end - close connection
|
|
839
|
-
*
|
|
840
|
-
* @returns {MqttClient} this - for chaining
|
|
841
|
-
* @param {Boolean} force - do not wait for all in-flight messages to be acked
|
|
842
|
-
* @param {Object} opts - opts disconnect
|
|
843
|
-
* @param {Function} cb - called when the client has been closed
|
|
844
|
-
*
|
|
845
|
-
* @api public
|
|
251
|
+
* 获取流媒体引擎供应商
|
|
846
252
|
*/
|
|
847
|
-
|
|
253
|
+
getStreamEngineVendor(): string;
|
|
848
254
|
/**
|
|
849
|
-
*
|
|
850
|
-
* the outgoing callback will be called withe Error('Message removed') if the message is removed
|
|
255
|
+
* 取某本地轨在本频道内的轨道描述。
|
|
851
256
|
*
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
*
|
|
257
|
+
* 同一条采集轨发布到多个频道时,各频道的描述(服务端分配的 id、归属 uid、联播分层等)
|
|
258
|
+
* 各不相同,`track.getInfo()` 在这种情况下只能回落到采集轨自身描述,用本方法可精确
|
|
259
|
+
* 取到它在本频道的那一份。未在本频道发布则返回 undefined。
|
|
855
260
|
*
|
|
856
|
-
* @example client.removeOutgoingMessage(client.getLastMessageId());
|
|
857
261
|
*/
|
|
858
|
-
|
|
262
|
+
getPublishInfo(track: BaseLocalTrack): BaseTrackInfo | undefined;
|
|
859
263
|
/**
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
* @param
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
* if opts is not given, current stores are used
|
|
866
|
-
*
|
|
867
|
-
* @returns {MqttClient} this - for chaining
|
|
868
|
-
*
|
|
869
|
-
* @api public
|
|
264
|
+
* 发布本地流轨道
|
|
265
|
+
* @param track
|
|
266
|
+
* @param opt 发布参数,不传则用 track 的默认发布参数(由 createLocalXxxTrack 依预设写入)
|
|
267
|
+
* @returns 本次发布在本频道内的轨道描述快照。后续引擎可能回写实际编码参数等,
|
|
268
|
+
* 要拿最新的请用 getPublishInfo(track)。
|
|
870
269
|
*/
|
|
871
|
-
|
|
270
|
+
publishLocalTrack(track: BaseLocalTrack, opt?: Partial<AudioPublishOptions> | Partial<VideoPublishOptions>): Promise<BaseTrackInfo>;
|
|
872
271
|
/**
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
* @param packet packet the packet
|
|
877
|
-
* @param callback callback call when finished
|
|
878
|
-
* @api public
|
|
272
|
+
* 取消发布本地流
|
|
273
|
+
* @param track
|
|
879
274
|
*/
|
|
880
|
-
|
|
275
|
+
unpublishLocalTrack(track: BaseLocalTrack): Promise<void>;
|
|
881
276
|
/**
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
* Challenge-response authentication flow would look something like this:
|
|
886
|
-
*
|
|
887
|
-
* --> CONNECT | authMethod = "mathChallenge" -->
|
|
888
|
-
* <-- AUTH | authMethod = "mathChallenge", authData = "12 + 34" <--
|
|
889
|
-
* --> AUTH | authMethod = "mathChallenge", authData = "46" -->
|
|
890
|
-
* <-- CONNACK | reasonCode = SUCCESS <--
|
|
891
|
-
*
|
|
892
|
-
* This form of authentication has several advantages over traditional
|
|
893
|
-
* credential-based approaches. For instance authentication without the direct
|
|
894
|
-
* exchange of authentication secrets.
|
|
895
|
-
*
|
|
896
|
-
* @param packet the auth packet to handle
|
|
897
|
-
* @param callback call when finished
|
|
898
|
-
* @api public
|
|
277
|
+
* 获取远端频道混音流
|
|
278
|
+
* @param filter 音频轨道过滤器,传递string[]时,根据uid过滤
|
|
899
279
|
*/
|
|
900
|
-
|
|
280
|
+
subscribeRemoteAudioMixTrack(filter?: ((track: BaseTrack) => boolean) | string[]): Promise<BaseTrack & (IMockRemoteAudioMixTrack | IRemoteAudioMixTrack)>;
|
|
901
281
|
/**
|
|
902
|
-
*
|
|
282
|
+
* 订阅远端用户音频流
|
|
283
|
+
* @param uid 用户id
|
|
284
|
+
* @param id 流轨道id
|
|
903
285
|
*/
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
constructor(info: BaseTrackInfo);
|
|
908
|
-
}
|
|
909
|
-
declare class SdkError {
|
|
910
|
-
/** 错误码 */
|
|
911
|
-
code: number;
|
|
912
|
-
/** 错误详情 */
|
|
913
|
-
msg: string;
|
|
914
|
-
/** 获取前缀错误码 */
|
|
915
|
-
protected prefixCode(): string;
|
|
916
|
-
constructor(msg: string, code?: number);
|
|
917
|
-
/**
|
|
918
|
-
* 从err转化为sdkError
|
|
919
|
-
* @param err 原始error
|
|
920
|
-
* @returns
|
|
286
|
+
subscribeRemoteAudioTrack(uid: string, id: string): Promise<BaseTrack>;
|
|
287
|
+
/**
|
|
288
|
+
* 订阅远端视频合成流
|
|
921
289
|
*/
|
|
922
|
-
|
|
923
|
-
toString(): string;
|
|
924
|
-
toJSON(): {
|
|
925
|
-
code: number;
|
|
926
|
-
msg: string;
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
declare class Store {
|
|
290
|
+
subscribeRemoteVideoMcuTrack(): Promise<BaseTrack>;
|
|
930
291
|
/**
|
|
931
|
-
*
|
|
292
|
+
* 订阅服务端统一合成的混音(program,含所有人,所有订阅者收到的一致)。
|
|
293
|
+
* 给不发声的观众/录制/旁路用,与 subscribeRemoteVideoMcuTrack 对应;不做 vendor 降级。
|
|
932
294
|
*
|
|
933
|
-
*
|
|
295
|
+
* 该流含全场(包括你自己):会发声的参与者订它会听到自己的回声——
|
|
296
|
+
* 参与者请改用 subscribeRemoteAudioMixTrack(本地 mix-minus,除自己)。
|
|
297
|
+
*/
|
|
298
|
+
subscribeRemoteAudioMcuTrack(): Promise<BaseTrack>;
|
|
299
|
+
/**
|
|
300
|
+
* 订阅远端用户视频流
|
|
301
|
+
* @param uid 用户id
|
|
302
|
+
* @param id 流轨道id
|
|
934
303
|
*/
|
|
935
|
-
|
|
304
|
+
subscribeRemoteVideoTrack(uid: string, id: string): Promise<BaseTrack>;
|
|
936
305
|
/**
|
|
937
|
-
*
|
|
938
|
-
*
|
|
939
|
-
*
|
|
306
|
+
* 取消订阅远端流
|
|
307
|
+
* @param track 流轨道
|
|
308
|
+
* @param debounceWaitMs 防取消订阅/订阅抖动ms数
|
|
940
309
|
*/
|
|
941
|
-
|
|
310
|
+
unsubscribeRemoteTrack(track: BaseTrack, debounceWaitMs?: number): Promise<void>;
|
|
311
|
+
}
|
|
312
|
+
export declare abstract class BaseTrack extends EventEmitter {
|
|
313
|
+
constructor(info: BaseTrackInfo, uid: string);
|
|
942
314
|
/**
|
|
943
|
-
*
|
|
315
|
+
* 轨道id
|
|
944
316
|
*
|
|
317
|
+
* 本地轨发布后,id 可能被改写为服务端分配值——那属于「一次发布」,由本地轨基类
|
|
318
|
+
* override 代理到发布记录(见 BaseLocalTrack);远端轨直读自身描述。
|
|
945
319
|
*/
|
|
946
|
-
|
|
320
|
+
get id(): string;
|
|
947
321
|
/**
|
|
948
|
-
*
|
|
322
|
+
* 轨道类型
|
|
949
323
|
*/
|
|
950
|
-
|
|
324
|
+
get kind(): TrackKind;
|
|
951
325
|
/**
|
|
952
|
-
*
|
|
326
|
+
* 轨道描述
|
|
953
327
|
*/
|
|
954
|
-
|
|
328
|
+
get desc(): string;
|
|
955
329
|
/**
|
|
956
|
-
*
|
|
330
|
+
* 是否为 simulcast 副层
|
|
957
331
|
*/
|
|
958
|
-
|
|
959
|
-
}
|
|
960
|
-
declare class TrackEventType extends CommonTrackEventType {
|
|
961
|
-
/** 轨道自动播放失败,对应data为BaseTrack */
|
|
962
|
-
static readonly AUTOPLAY_FAIL = "autoplay_fail";
|
|
963
|
-
/** mediastreamtrack轨道被替换,对应data为BaseTrack,oldMsTrack为旧的MediaStreamTrack */
|
|
964
|
-
static readonly MSTRACK_REPLACED = "mstrack_replaced";
|
|
965
|
-
/** 轨道流媒体开始断线自动重连,对应data为BaseTrack*/
|
|
966
|
-
static readonly RECONNECTING = "reconnecting";
|
|
967
|
-
/** 轨道流媒体重连成功,对应data为BaseTrack */
|
|
968
|
-
static readonly RECONNECTED = "reconnected";
|
|
969
|
-
/** 进入画中画模式,对应data为BaseTrack */
|
|
970
|
-
static readonly PIP_ENTER = "pip_enter";
|
|
971
|
-
/** 退出画中画模式,对应data为BaseTrack */
|
|
972
|
-
static readonly PIP_EXIT = "pip_exit";
|
|
973
|
-
/** 弹出独立窗口,对应data为BaseTrack */
|
|
974
|
-
static readonly POPOUT_OPEN = "popout_open";
|
|
975
|
-
/** 关闭独立窗口,对应data为BaseTrack */
|
|
976
|
-
static readonly POPOUT_CLOSE = "popout_close";
|
|
977
|
-
}
|
|
978
|
-
declare class UserContainer implements Iterable<[
|
|
979
|
-
string,
|
|
980
|
-
BaseUser
|
|
981
|
-
]> {
|
|
982
|
-
/** uid为key的user Map */
|
|
983
|
-
private ctn;
|
|
984
|
-
/** linkid为key,与uid的映射 */
|
|
985
|
-
private linkids;
|
|
332
|
+
get variant(): boolean | undefined;
|
|
986
333
|
/**
|
|
987
|
-
*
|
|
988
|
-
*
|
|
334
|
+
* 视频角度(视频轨才有,手机端旋转时变化)。
|
|
335
|
+
* 渲染路径用本 getter 而非 getInfo().angle——本地轨 getInfo 在多频道发布时会抛错,
|
|
336
|
+
* 字段糖则始终可用。
|
|
989
337
|
*/
|
|
990
|
-
|
|
991
|
-
string,
|
|
992
|
-
BaseUser
|
|
993
|
-
]>;
|
|
338
|
+
get angle(): number;
|
|
994
339
|
/**
|
|
995
|
-
*
|
|
996
|
-
*
|
|
997
|
-
*
|
|
340
|
+
* 获取流轨道信息
|
|
341
|
+
*
|
|
342
|
+
* 远端轨直接返回自身描述的**拷贝**。本地轨由基类 override 代理到发布记录:
|
|
343
|
+
* 单发布时与「info 记在 track 上」时代完全一致;发布到多个频道时**抛错**,
|
|
344
|
+
* 请改用 channel.getPublishInfo(track)(见 BaseLocalTrack / TrackPublishState)。
|
|
345
|
+
* @returns
|
|
998
346
|
*/
|
|
999
|
-
|
|
347
|
+
getInfo(): BaseTrackInfo;
|
|
1000
348
|
/**
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
349
|
+
* 轨道所属用户
|
|
350
|
+
*
|
|
351
|
+
* 远端轨道在 new 时就由所属 user 传入 uid(见各端 user.ts 的 newTrack),直读即可。
|
|
352
|
+
* 本地轨道的归属 uid 是「一次发布」的属性(同一条采集发布到不同频道可以是不同 uid),
|
|
353
|
+
* 记在发布记录里,由本地轨基类 override 做单发布代理(见 BaseLocalTrack)。
|
|
1003
354
|
* @returns
|
|
1004
355
|
*/
|
|
1005
|
-
|
|
356
|
+
getUid(): string;
|
|
357
|
+
toString(): string;
|
|
358
|
+
}
|
|
359
|
+
export declare class Channel extends BaseChannel {
|
|
1006
360
|
/**
|
|
1007
|
-
*
|
|
1008
|
-
|
|
1009
|
-
|
|
361
|
+
* 获取流媒体引擎的metric快照(全量,包含每条轨道的统计)
|
|
362
|
+
*/
|
|
363
|
+
getStreamMetric(): StreamMetric | undefined;
|
|
364
|
+
/**
|
|
365
|
+
* 获取当前网络总体统计,轻量接口,只关心网络整体指标时使用
|
|
1010
366
|
*/
|
|
1011
|
-
|
|
367
|
+
getNetworkStats(): NetworkStats | undefined;
|
|
1012
368
|
/**
|
|
1013
|
-
*
|
|
1014
|
-
* @param uid
|
|
369
|
+
* 获取当前连接质量评估结果(等级、MOS、原因等)
|
|
1015
370
|
*/
|
|
1016
|
-
|
|
371
|
+
getConnectionQuality(): QualityEvaluation | undefined;
|
|
1017
372
|
/**
|
|
1018
|
-
*
|
|
373
|
+
* override:webrtc 端的发布编排收口在这里,SRTC 门面只做纯委托。
|
|
374
|
+
* - 共享屏幕音频轨随屏幕轨一起发布;
|
|
375
|
+
* - ook/wangsu 的联播副轨需先各自完整发布,主轨建记录时从副轨记录反查
|
|
376
|
+
* variant/fallback_ids(见 createPublishRecords);seastart 走 webrtc 原生
|
|
377
|
+
* rid simulcast,副轨不单独推流,fallback_ids 由引擎发布后回写。
|
|
1019
378
|
*/
|
|
1020
|
-
|
|
379
|
+
publishLocalTrack(track: BaseLocalTrack, opt?: Partial<AudioPublishOptions> | Partial<VideoPublishOptions>): Promise<BaseTrackInfo>;
|
|
1021
380
|
/**
|
|
1022
|
-
*
|
|
1023
|
-
* @returns
|
|
381
|
+
* override:与 publishLocalTrack 对称,收尾共享屏幕音频轨与联播副轨。
|
|
1024
382
|
*/
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
INIT = "init",
|
|
1030
|
-
/** 已连接 */
|
|
1031
|
-
CONNECTED = "connected",
|
|
1032
|
-
/** 重连中 */
|
|
1033
|
-
RECONNECTING = "reconnecting",
|
|
1034
|
-
/** 已离会 */
|
|
1035
|
-
LEAVED = "leaved"
|
|
1036
|
-
}
|
|
1037
|
-
declare function dateFormat(format: string, date?: Date): string;
|
|
1038
|
-
declare function dct(t: string): any;
|
|
1039
|
-
declare function genNonce(len?: number): string;
|
|
1040
|
-
declare function getHostnameFromUrl(url: string): string;
|
|
1041
|
-
declare function isObject(value: any): boolean;
|
|
1042
|
-
declare function isString(value: any): boolean;
|
|
1043
|
-
declare function isWxxcx(): boolean;
|
|
1044
|
-
declare function propAssign<T>(target: T, income: T, assigner?: Record<keyof T, (value: any, old: any) => void>): PropChangeItem<keyof T>[];
|
|
1045
|
-
declare function retry<T>(f: () => Promise<T>, opt: {
|
|
1046
|
-
/** 首次执行失败后的最大重试次数,默认10次,<=0代表不限制次数 */
|
|
1047
|
-
maxRetries?: number;
|
|
1048
|
-
/** 第一次重试间隔(ms),默认500ms,之后会以 initialDelay * 2^n 进行重试 */
|
|
1049
|
-
initialDelay?: number;
|
|
1050
|
-
/** 每次重试前的回调,e为上次失败catch到的错误,返回false则代表放弃重试,会返回canceled */
|
|
1051
|
-
onRetry?: (attempt: number, e?: any) => boolean | void;
|
|
1052
|
-
}): retryCallback<T>;
|
|
1053
|
-
declare function sleep(ms: number): Promise<void>;
|
|
383
|
+
unpublishLocalTrack(track: BaseLocalTrack): Promise<void>;
|
|
384
|
+
subscribeRemoteVideoTrack(uid: string, id: string): Promise<BaseTrack>;
|
|
385
|
+
unsubscribeRemoteTrack(track: BaseTrack, debounceWaitMs?: number): Promise<void>;
|
|
386
|
+
}
|
|
1054
387
|
/** 扩展的频道事件 */
|
|
1055
388
|
export declare class ChannelEventType extends CommonChannelEventType {
|
|
1056
389
|
/** 外设插入,对应data为MediaDeviceInfo */
|
|
@@ -1085,7 +418,7 @@ export declare class ChannelEventType extends CommonChannelEventType {
|
|
|
1085
418
|
/**
|
|
1086
419
|
* 本地音频流轨道
|
|
1087
420
|
*/
|
|
1088
|
-
export declare class LocalAudioTrack extends
|
|
421
|
+
export declare class LocalAudioTrack extends BaseWebrtcLocalTrack {
|
|
1089
422
|
constructor();
|
|
1090
423
|
/**
|
|
1091
424
|
* 挂载音频处理器(如 RNN 降噪、变声)。传入数组时按顺序串联。
|
|
@@ -1163,26 +496,6 @@ export declare class LocalCameraTrack extends LocalVideoTrack {
|
|
|
1163
496
|
* 调用方需要把当前要录制的视频 track、音频 track 以及每个视频在画布上的位置传进来。
|
|
1164
497
|
*/
|
|
1165
498
|
export declare class LocalCompositeRecorder {
|
|
1166
|
-
private canvas?;
|
|
1167
|
-
private canvasContext?;
|
|
1168
|
-
private canvasStream?;
|
|
1169
|
-
private recordStream?;
|
|
1170
|
-
private mediaRecorder?;
|
|
1171
|
-
private audioContext?;
|
|
1172
|
-
private audioDestination?;
|
|
1173
|
-
private audioSources;
|
|
1174
|
-
private audioInputTracks;
|
|
1175
|
-
private trackedTrackListeners;
|
|
1176
|
-
private videoElements;
|
|
1177
|
-
private chunks;
|
|
1178
|
-
private videoItems;
|
|
1179
|
-
private width;
|
|
1180
|
-
private height;
|
|
1181
|
-
private fps;
|
|
1182
|
-
private background;
|
|
1183
|
-
private labelBackground;
|
|
1184
|
-
private animationFrameId;
|
|
1185
|
-
private onDataAvailable?;
|
|
1186
499
|
/**
|
|
1187
500
|
* 获取当前录制状态。
|
|
1188
501
|
*
|
|
@@ -1233,82 +546,6 @@ export declare class LocalCompositeRecorder {
|
|
|
1233
546
|
* 适用于页面卸载或调用方不再需要输出 Blob 的异常清理场景。
|
|
1234
547
|
*/
|
|
1235
548
|
destroy(): void;
|
|
1236
|
-
/**
|
|
1237
|
-
* 初始化混音管线。
|
|
1238
|
-
*
|
|
1239
|
-
* 通过 MediaStreamAudioDestinationNode 生成一条稳定的输出音频轨,供 MediaRecorder 持有。
|
|
1240
|
-
*/
|
|
1241
|
-
private initAudio;
|
|
1242
|
-
/**
|
|
1243
|
-
* 重新连接输入音频轨道。
|
|
1244
|
-
*
|
|
1245
|
-
* 只替换 Web Audio 的 source 节点,不替换 destination 输出轨,保证录制过程不中断。
|
|
1246
|
-
*/
|
|
1247
|
-
private setAudioTracks;
|
|
1248
|
-
/**
|
|
1249
|
-
* 断开并清空所有输入音频 source。
|
|
1250
|
-
*/
|
|
1251
|
-
private clearAudioSources;
|
|
1252
|
-
/**
|
|
1253
|
-
* 从原生 MediaStreamTrack 或 SDK Track 中取出当前实际媒体轨。
|
|
1254
|
-
*/
|
|
1255
|
-
private resolveMediaStreamTrack;
|
|
1256
|
-
/**
|
|
1257
|
-
* 读取 SDK Track 的视频旋转角度(FourCC)。
|
|
1258
|
-
*
|
|
1259
|
-
* 原生 MediaStreamTrack 不携带旋转信息,按未旋转(ANGLE_UP)处理。
|
|
1260
|
-
* 用于让录制 canvas 与正常播放路径(CSS transform)的旋转表现保持一致。
|
|
1261
|
-
*/
|
|
1262
|
-
private resolveTrackAngle;
|
|
1263
|
-
/**
|
|
1264
|
-
* 判断是否为可监听 MSTRACK_REPLACED 的 SDK Track。
|
|
1265
|
-
*/
|
|
1266
|
-
private isTrackLike;
|
|
1267
|
-
/**
|
|
1268
|
-
* 同步 SDK Track 的替换监听。
|
|
1269
|
-
*
|
|
1270
|
-
* 调用方传 SDK Track 时,录制器会监听 MSTRACK_REPLACED,自动把隐藏 video 或混音 source 切到新轨。
|
|
1271
|
-
*/
|
|
1272
|
-
private syncTrackedTrackListeners;
|
|
1273
|
-
/**
|
|
1274
|
-
* 解绑所有 SDK Track 替换监听。
|
|
1275
|
-
*/
|
|
1276
|
-
private clearTrackedTrackListeners;
|
|
1277
|
-
/**
|
|
1278
|
-
* 同步视频解码元素。
|
|
1279
|
-
*
|
|
1280
|
-
* 每个视频 track 都需要一个隐藏 HTMLVideoElement 作为 canvas.drawImage 的帧来源。
|
|
1281
|
-
* 这里以底层 MediaStreamTrack「对象引用」为 key 做复用:同一个 track 即使被多个槽位
|
|
1282
|
-
* 引用(例如大小窗布局下同一成员同时出现在大窗和小窗),也只创建一个解码 video 共享。
|
|
1283
|
-
* 否则同一个远端 track 被多个独立 video 同时播放会产生竞态,偶发其中一个 video
|
|
1284
|
-
* 取不到帧(videoWidth=0)导致对应槽位黑屏。
|
|
1285
|
-
*
|
|
1286
|
-
* 注意:不能用 track.id 字符串做 key——远端 track 的 id 全局不保证唯一,
|
|
1287
|
-
* 不同用户可能碰撞,会导致多个槽位错误共享同一路画面(“都变成同一个人”)。
|
|
1288
|
-
*/
|
|
1289
|
-
private syncVideoElements;
|
|
1290
|
-
/**
|
|
1291
|
-
* 渲染循环。
|
|
1292
|
-
*
|
|
1293
|
-
* 每帧按最新 videoItems 重绘整张画布,canvas.captureStream 会把这些帧输出给 MediaRecorder。
|
|
1294
|
-
*/
|
|
1295
|
-
private render;
|
|
1296
|
-
/**
|
|
1297
|
-
* 绘制单个视频槽位。
|
|
1298
|
-
*
|
|
1299
|
-
* contain 会完整显示视频,cover 会填满槽位并裁剪溢出区域。
|
|
1300
|
-
* 移动端竖屏采集的视频携带旋转角度,这里会按角度对 canvas 做等价旋转/镜像,
|
|
1301
|
-
* 与正常播放路径(PlayView.freshTransform 的 CSS transform)保持一致,避免录像横屏。
|
|
1302
|
-
*/
|
|
1303
|
-
private drawVideo;
|
|
1304
|
-
/**
|
|
1305
|
-
* 绘制视频标签。
|
|
1306
|
-
*/
|
|
1307
|
-
private drawLabel;
|
|
1308
|
-
/**
|
|
1309
|
-
* 释放内部资源并重置状态。
|
|
1310
|
-
*/
|
|
1311
|
-
private cleanup;
|
|
1312
549
|
}
|
|
1313
550
|
/**
|
|
1314
551
|
* 本地麦克风流轨道
|
|
@@ -1363,7 +600,7 @@ export declare class LocalScreenTrack extends LocalVideoTrack {
|
|
|
1363
600
|
/**
|
|
1364
601
|
* 本地视频流轨道
|
|
1365
602
|
*/
|
|
1366
|
-
export declare class LocalVideoTrack extends
|
|
603
|
+
export declare class LocalVideoTrack extends BaseWebrtcLocalTrack {
|
|
1367
604
|
constructor();
|
|
1368
605
|
/**
|
|
1369
606
|
* 挂载视频处理器(如美颜、虚化背景)。传入数组时按顺序串联。
|
|
@@ -1441,17 +678,16 @@ export declare class LocalVideoTrack extends BaseWebrtcTrack {
|
|
|
1441
678
|
export declare class ProcessorPipeline implements TrackProcessor {
|
|
1442
679
|
readonly name: string;
|
|
1443
680
|
processedTrack?: MediaStreamTrack;
|
|
1444
|
-
private processors;
|
|
1445
|
-
/** 仅当本组合器自建共享上下文时持有,destroy 时负责关闭 */
|
|
1446
|
-
private ownedAudioContext?;
|
|
1447
681
|
constructor(processors: TrackProcessor[]);
|
|
1448
682
|
init(options: ProcessorOptions): Promise<void>;
|
|
1449
683
|
destroy(): Promise<void>;
|
|
1450
684
|
}
|
|
1451
685
|
/**
|
|
1452
686
|
* 远端混音流
|
|
687
|
+
* 参与者视角,服务端 mix-minus,排除自己以外
|
|
1453
688
|
*/
|
|
1454
689
|
export declare class RemoteAudioMixTrack extends RemoteAudioTrack implements IRemoteAudioMixTrack {
|
|
690
|
+
readonly __type: "RemoteAudioMixTrack";
|
|
1455
691
|
constructor(info: BaseTrackInfo, filterUids?: string[]);
|
|
1456
692
|
/**
|
|
1457
693
|
* 混音流中过滤的uid
|
|
@@ -1481,10 +717,6 @@ export declare class RemoteAudioTrack extends BaseWebrtcTrack {
|
|
|
1481
717
|
* 远端视频流轨道
|
|
1482
718
|
*/
|
|
1483
719
|
export declare class RemoteVideoTrack extends BaseWebrtcTrack {
|
|
1484
|
-
/**
|
|
1485
|
-
* 业务期望的抖动缓冲目标延迟(ms)。undefined 表示使用浏览器默认自适应策略。
|
|
1486
|
-
*/
|
|
1487
|
-
private jitterBufferTargetMs?;
|
|
1488
720
|
constructor(info: BaseTrackInfo, uid: string);
|
|
1489
721
|
/**
|
|
1490
722
|
* 添加播放窗口
|
|
@@ -1547,16 +779,8 @@ export declare class RemoteVideoTrack extends BaseWebrtcTrack {
|
|
|
1547
779
|
* 获取业务当前设定的抖动缓冲目标延迟(ms);undefined 表示未设置。
|
|
1548
780
|
*/
|
|
1549
781
|
getJitterBufferTarget(): number | undefined;
|
|
1550
|
-
/**
|
|
1551
|
-
* 同时写 jitterBufferTarget(W3C 标准,Chrome 113+)和 playoutDelayHint
|
|
1552
|
-
* (Chrome 私有扩展,Chrome 70+),让新老浏览器都能生效。
|
|
1553
|
-
* 浏览器只支持其中一个时另一个不存在,'in' 判断后静默跳过。
|
|
1554
|
-
*/
|
|
1555
|
-
private applyJitterBufferTarget;
|
|
1556
782
|
}
|
|
1557
783
|
export declare class SRTC extends BaseSRTC {
|
|
1558
|
-
/** 窄化父类的 channel 类型到 webrtc Channel,便于访问 webrtc 特有方法 */
|
|
1559
|
-
protected channel?: Channel | null;
|
|
1560
784
|
/**
|
|
1561
785
|
* 获取流媒体引擎的metric快照(全量,含每条轨道的统计)
|
|
1562
786
|
*/
|
|
@@ -1584,6 +808,11 @@ export declare class SRTC extends BaseSRTC {
|
|
|
1584
808
|
*/
|
|
1585
809
|
createLocalCompositeRecorder(): LocalCompositeRecorder;
|
|
1586
810
|
constructor(initParams: SdkInitParams);
|
|
811
|
+
/**
|
|
812
|
+
* 加入频道,返回该频道的 Channel 对象(见 BaseSRTC.join 说明)。
|
|
813
|
+
* web 端可多次 join 同时加入多个频道。
|
|
814
|
+
*/
|
|
815
|
+
join(token: string, options?: JoinOptions): Promise<Channel>;
|
|
1587
816
|
/**
|
|
1588
817
|
* 获取设备列表
|
|
1589
818
|
* @param kind
|
|
@@ -1625,13 +854,14 @@ export declare class SRTC extends BaseSRTC {
|
|
|
1625
854
|
*/
|
|
1626
855
|
disableLocalTrack(track: LocalAudioTrack | LocalVideoTrack): void;
|
|
1627
856
|
/**
|
|
1628
|
-
*
|
|
857
|
+
* 发布本地流轨道(委托默认频道;发布编排——预设合并/屏幕音频/联播副轨——收口在 Channel)
|
|
1629
858
|
* @param track
|
|
1630
|
-
* @
|
|
859
|
+
* @param opt 发布参数,不传则用 track 的默认发布参数(由 createLocalXxxTrack 依预设写入)
|
|
860
|
+
* @returns 本次发布在本频道内的轨道描述快照,后续引擎回写的最新值请用 srtc.getPublishInfo(track)
|
|
1631
861
|
*/
|
|
1632
|
-
publishLocalTrack(track: LocalAudioTrack | LocalVideoTrack, opt?: Partial<AudioPublishOptions> | Partial<VideoPublishOptions>): Promise<
|
|
862
|
+
publishLocalTrack(track: LocalAudioTrack | LocalVideoTrack, opt?: Partial<AudioPublishOptions> | Partial<VideoPublishOptions>): Promise<BaseTrackInfo>;
|
|
1633
863
|
/**
|
|
1634
|
-
*
|
|
864
|
+
* 取消发布本地流(委托默认频道)
|
|
1635
865
|
* @param track
|
|
1636
866
|
*/
|
|
1637
867
|
unpublishLocalTrack(track: LocalAudioTrack | LocalVideoTrack): Promise<void>;
|
|
@@ -1840,67 +1070,6 @@ export declare function codec2str(codec: Codec): string;
|
|
|
1840
1070
|
* 创建混音后的音频轨
|
|
1841
1071
|
*/
|
|
1842
1072
|
export declare function createMixedAudioMediaStreamTrack(canvasContext?: CanvasRenderingContext2D): MixedAudioMediaStreamTrack;
|
|
1843
|
-
/**
|
|
1844
|
-
* MessageIdProvider
|
|
1845
|
-
*/
|
|
1846
|
-
export declare interface IMessageIdProvider {
|
|
1847
|
-
/**
|
|
1848
|
-
* Allocate the first vacant messageId. The messageId become occupied status.
|
|
1849
|
-
* @return {Number} - The first vacant messageId. If all messageIds are occupied, return null.
|
|
1850
|
-
*/
|
|
1851
|
-
allocate(): Number | null;
|
|
1852
|
-
/**
|
|
1853
|
-
* Get the last allocated messageId.
|
|
1854
|
-
* @return {Number} - messageId.
|
|
1855
|
-
*/
|
|
1856
|
-
getLastAllocated(): Number | null;
|
|
1857
|
-
/**
|
|
1858
|
-
* Register the messageId. The messageId become occupied status.
|
|
1859
|
-
* If the messageId has already been occupied, then return false.
|
|
1860
|
-
* @param {Number} num - The messageId to request use.
|
|
1861
|
-
* @return {Boolean} - If `num` was not occupied, then return true, otherwise return false.
|
|
1862
|
-
*/
|
|
1863
|
-
register(num: Number): Boolean;
|
|
1864
|
-
/**
|
|
1865
|
-
* Deallocate the messageId. The messageId become vacant status.
|
|
1866
|
-
* @param {Number} num - The messageId to deallocate. The messageId must be occupied status.
|
|
1867
|
-
* In other words, the messageId must be allocated by allocate() or
|
|
1868
|
-
* occupied by register().
|
|
1869
|
-
*/
|
|
1870
|
-
deallocate(num: Number): void;
|
|
1871
|
-
/**
|
|
1872
|
-
* Clear all occupied messageIds.
|
|
1873
|
-
* The all messageIds are set to vacant status.
|
|
1874
|
-
*/
|
|
1875
|
-
clear(): void;
|
|
1876
|
-
}
|
|
1877
|
-
export declare namespace __INNER__ {
|
|
1878
|
-
const BaseSRTC_I: typeof BaseSRTC;
|
|
1879
|
-
const CommonChannelEventType_I: typeof CommonChannelEventType;
|
|
1880
|
-
const isWxxcx_I: typeof isWxxcx;
|
|
1881
|
-
const Logger_I: typeof Logger;
|
|
1882
|
-
const SdkError_I: typeof SdkError;
|
|
1883
|
-
const propAssign_I: typeof propAssign;
|
|
1884
|
-
const isObject_I: typeof isObject;
|
|
1885
|
-
const isString_I: typeof isString;
|
|
1886
|
-
const sleep_I: typeof sleep;
|
|
1887
|
-
const retry_I: typeof retry;
|
|
1888
|
-
const dateFormat_I: typeof dateFormat;
|
|
1889
|
-
const genNonce_I: typeof genNonce;
|
|
1890
|
-
const getHostnameFromUrl_I: typeof getHostnameFromUrl;
|
|
1891
|
-
const dct_I: typeof dct;
|
|
1892
|
-
function hmac_I(msg: string, key: string): string;
|
|
1893
|
-
}
|
|
1894
|
-
export declare type ClientSubscribeCallback = (err: Error, granted: ISubscriptionGrant[]) => void;
|
|
1895
|
-
export declare type CloseCallback = (error?: Error) => void;
|
|
1896
|
-
export declare type OnCloseCallback = () => void;
|
|
1897
|
-
export declare type OnConnectCallback = (packet: IConnackPacket) => void;
|
|
1898
|
-
export declare type OnDisconnectCallback = (packet: IDisconnectPacket) => void;
|
|
1899
|
-
export declare type OnErrorCallback = (error: Error) => void;
|
|
1900
|
-
export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: IPublishPacket) => void;
|
|
1901
|
-
export declare type OnPacketCallback = (packet: Packet) => void;
|
|
1902
|
-
export declare type PacketCallback = (error?: Error, packet?: Packet) => any;
|
|
1903
|
-
export declare type StorePutCallback = () => void;
|
|
1904
1073
|
/**
|
|
1905
1074
|
* Active speaker(说话中的用户)相关类型 / 事件枚举。
|
|
1906
1075
|
*
|
|
@@ -2033,18 +1202,14 @@ export interface AudioSenderStats extends SenderStats {
|
|
|
2033
1202
|
/** 音频电平 */
|
|
2034
1203
|
audioLevel?: number;
|
|
2035
1204
|
}
|
|
2036
|
-
/** 重连时刷新auth */
|
|
2037
|
-
export interface AuthReconnect {
|
|
2038
|
-
(url: string, options: IClientOptions, client: MqttClient): string;
|
|
2039
|
-
}
|
|
2040
1205
|
/**
|
|
2041
|
-
*
|
|
1206
|
+
* 频道的类型化事件重载。
|
|
2042
1207
|
*
|
|
2043
1208
|
* 事件类型通过 `ChannelEventDataMap` 与 data 类型强关联,
|
|
2044
1209
|
* 子类如 webrtc / wx 通过 `declare module '../base/event'` 合并扩展事件。
|
|
2045
|
-
*
|
|
1210
|
+
* 这段 interface 不是另起炉灶,而是用 TS declaration merging 在 EventEmitter
|
|
2046
1211
|
* 的 `on/once/off/addListener/removeListener/emit` 上加强类型化重载;保留父类宽松签名
|
|
2047
|
-
* 作为兜底,不影响内部既有 `this.rtcSocket.on(SocketEvent.XXX)`
|
|
1212
|
+
* 作为兜底,不影响内部既有 `this.rtcSocket.on(SocketEvent.XXX)` 等用法(与 BaseTrack 同法)。
|
|
2048
1213
|
*/
|
|
2049
1214
|
export interface BaseChannel {
|
|
2050
1215
|
on<K extends keyof ChannelEventDataMap>(type: K, listener: (event: ChannelEventOf<K>) => void): this;
|
|
@@ -2054,6 +1219,19 @@ export interface BaseChannel {
|
|
|
2054
1219
|
removeListener<K extends keyof ChannelEventDataMap>(type: K, listener: (event: ChannelEventOf<K>) => void): this;
|
|
2055
1220
|
emit<K extends keyof ChannelEventDataMap>(type: K, event: ChannelEventOf<K>): boolean;
|
|
2056
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* 本地轨接口:在 BaseTrack 之上附加「可被频道发布」的能力。
|
|
1224
|
+
*
|
|
1225
|
+
* 「发布」只属于本地轨,远端轨不背这些语义(其 getInfo/id 等保持直读自身描述,
|
|
1226
|
+
* 零额外开销)。因两端本地轨的继承链不同(webrtc 端 local/remote 共享
|
|
1227
|
+
* BaseWebrtcTrack,wx 端是独立的 LocalTrack),发布能力用组合的
|
|
1228
|
+
* TrackPublishState 单处实现,各端本地轨基类实现本接口做薄代理。
|
|
1229
|
+
*
|
|
1230
|
+
* 注意本接口 extends 了含私有成员的 BaseTrack class,TS 规则决定了只有
|
|
1231
|
+
* BaseTrack 的子类才能 implements 它——正好是我们要的约束。
|
|
1232
|
+
*/
|
|
1233
|
+
export interface BaseLocalTrack extends BaseTrack {
|
|
1234
|
+
}
|
|
2057
1235
|
/**
|
|
2058
1236
|
* 流轨道
|
|
2059
1237
|
*
|
|
@@ -2077,15 +1255,6 @@ export interface BaseTrack {
|
|
|
2077
1255
|
listeners<K extends keyof TrackEventDataMap>(type: K): ((data: TrackEventDataMap[K]) => void)[];
|
|
2078
1256
|
listeners(type: string | symbol): Function[];
|
|
2079
1257
|
}
|
|
2080
|
-
/**
|
|
2081
|
-
* track临时扩展,方便统一管理
|
|
2082
|
-
*/
|
|
2083
|
-
export interface BaseTrackEx {
|
|
2084
|
-
kind: TrackKind;
|
|
2085
|
-
track: BaseTrack;
|
|
2086
|
-
opt?: AudioPublishOptions | VideoPublishOptions;
|
|
2087
|
-
exopt: Record<string, any>;
|
|
2088
|
-
}
|
|
2089
1258
|
/**
|
|
2090
1259
|
* sdk编译信息
|
|
2091
1260
|
*/
|
|
@@ -2178,32 +1347,6 @@ export interface ChannelEventDataMap {
|
|
|
2178
1347
|
[CommonChannelEventType.TRACK_UNMUTED]: BaseTrack;
|
|
2179
1348
|
[CommonChannelEventType.TRACK_ENDED]: BaseTrack;
|
|
2180
1349
|
}
|
|
2181
|
-
/**
|
|
2182
|
-
* 加入频道api返回
|
|
2183
|
-
*/
|
|
2184
|
-
export interface ChannelJoinRsp extends ReconnectRsp {
|
|
2185
|
-
/** 应用ID */
|
|
2186
|
-
app_id: string;
|
|
2187
|
-
/** 用户ID */
|
|
2188
|
-
uid: string;
|
|
2189
|
-
/** 会话ID */
|
|
2190
|
-
sid: string;
|
|
2191
|
-
/** 频道名 */
|
|
2192
|
-
channel: string;
|
|
2193
|
-
/** 网络 */
|
|
2194
|
-
net: string;
|
|
2195
|
-
/** 流媒体服务方 */
|
|
2196
|
-
stream_vendor: string;
|
|
2197
|
-
/** 频道流媒体连接id */
|
|
2198
|
-
channel_link_id: string;
|
|
2199
|
-
/** 用户流媒体连接id */
|
|
2200
|
-
link_id: number;
|
|
2201
|
-
/** 用户流媒体授权key */
|
|
2202
|
-
session_key: string;
|
|
2203
|
-
device_type: DeviceType;
|
|
2204
|
-
device_id: string;
|
|
2205
|
-
version: string;
|
|
2206
|
-
}
|
|
2207
1350
|
/**
|
|
2208
1351
|
* 连接质量变化事件 data
|
|
2209
1352
|
*/
|
|
@@ -2240,7 +1383,7 @@ export interface DisconnectEventData {
|
|
|
2240
1383
|
/**
|
|
2241
1384
|
* web环境详情
|
|
2242
1385
|
*/
|
|
2243
|
-
export interface EnvWebInfo extends
|
|
1386
|
+
export interface EnvWebInfo extends ParsedBrowserInfo {
|
|
2244
1387
|
/**
|
|
2245
1388
|
* 是否支持webrtc
|
|
2246
1389
|
*/
|
|
@@ -2322,181 +1465,6 @@ export interface EnvWebInfo extends Bowser$1.Parser.ParsedResult {
|
|
|
2322
1465
|
*/
|
|
2323
1466
|
devicePixelRatio: number;
|
|
2324
1467
|
}
|
|
2325
|
-
export interface IClientOptions extends ISecureClientOptions {
|
|
2326
|
-
port?: number; // port is made into a number subsequently
|
|
2327
|
-
host?: string; // host does NOT include port
|
|
2328
|
-
hostname?: string;
|
|
2329
|
-
path?: string;
|
|
2330
|
-
protocol?: "wss" | "ws" | "mqtt" | "mqtts" | "tcp" | "ssl" | "wx" | "wxs";
|
|
2331
|
-
wsOptions?: ClientOptions | ClientRequestArgs;
|
|
2332
|
-
/**
|
|
2333
|
-
* 10 seconds, set to 0 to disable
|
|
2334
|
-
*/
|
|
2335
|
-
keepalive?: number;
|
|
2336
|
-
/**
|
|
2337
|
-
* 'mqttjs_' + Math.random().toString(16).substr(2, 8)
|
|
2338
|
-
*/
|
|
2339
|
-
clientId?: string;
|
|
2340
|
-
/**
|
|
2341
|
-
* 'MQTT'
|
|
2342
|
-
*/
|
|
2343
|
-
protocolId?: string;
|
|
2344
|
-
/**
|
|
2345
|
-
* 4
|
|
2346
|
-
*/
|
|
2347
|
-
protocolVersion?: number;
|
|
2348
|
-
/**
|
|
2349
|
-
* true, set to false to receive QoS 1 and 2 messages while offline
|
|
2350
|
-
*/
|
|
2351
|
-
clean?: boolean;
|
|
2352
|
-
/**
|
|
2353
|
-
* 1000 milliseconds, interval between two reconnections
|
|
2354
|
-
*/
|
|
2355
|
-
reconnectPeriod?: number;
|
|
2356
|
-
/**
|
|
2357
|
-
* 30 * 1000 milliseconds, time to wait before a CONNACK is received
|
|
2358
|
-
*/
|
|
2359
|
-
connectTimeout?: number;
|
|
2360
|
-
/**
|
|
2361
|
-
* the username required by your broker, if any
|
|
2362
|
-
*/
|
|
2363
|
-
username?: string;
|
|
2364
|
-
/**
|
|
2365
|
-
* the password required by your broker, if any
|
|
2366
|
-
*/
|
|
2367
|
-
password?: string;
|
|
2368
|
-
/**
|
|
2369
|
-
* a Store for the incoming packets
|
|
2370
|
-
*/
|
|
2371
|
-
incomingStore?: Store;
|
|
2372
|
-
/**
|
|
2373
|
-
* a Store for the outgoing packets
|
|
2374
|
-
*/
|
|
2375
|
-
outgoingStore?: Store;
|
|
2376
|
-
queueQoSZero?: boolean;
|
|
2377
|
-
reschedulePings?: boolean;
|
|
2378
|
-
servers?: Array<{
|
|
2379
|
-
host: string;
|
|
2380
|
-
port: number;
|
|
2381
|
-
protocol?: "wss" | "ws" | "mqtt" | "mqtts" | "tcp" | "ssl" | "wx" | "wxs";
|
|
2382
|
-
}>;
|
|
2383
|
-
/**
|
|
2384
|
-
* true, set to false to disable re-subscribe functionality
|
|
2385
|
-
*/
|
|
2386
|
-
resubscribe?: boolean;
|
|
2387
|
-
/**
|
|
2388
|
-
* a message that will sent by the broker automatically when the client disconnect badly.
|
|
2389
|
-
*/
|
|
2390
|
-
will?: {
|
|
2391
|
-
/**
|
|
2392
|
-
* the topic to publish
|
|
2393
|
-
*/
|
|
2394
|
-
topic: string;
|
|
2395
|
-
/**
|
|
2396
|
-
* the message to publish
|
|
2397
|
-
*/
|
|
2398
|
-
payload: Buffer | string;
|
|
2399
|
-
/**
|
|
2400
|
-
* the QoS
|
|
2401
|
-
*/
|
|
2402
|
-
qos: QoS;
|
|
2403
|
-
/**
|
|
2404
|
-
* the retain flag
|
|
2405
|
-
*/
|
|
2406
|
-
retain: boolean;
|
|
2407
|
-
/*
|
|
2408
|
-
* properies object of will
|
|
2409
|
-
* */
|
|
2410
|
-
properties?: {
|
|
2411
|
-
willDelayInterval?: number;
|
|
2412
|
-
payloadFormatIndicator?: boolean;
|
|
2413
|
-
messageExpiryInterval?: number;
|
|
2414
|
-
contentType?: string;
|
|
2415
|
-
responseTopic?: string;
|
|
2416
|
-
correlationData?: Buffer;
|
|
2417
|
-
userProperties?: UserProperties;
|
|
2418
|
-
};
|
|
2419
|
-
};
|
|
2420
|
-
transformWsUrl?: (url: string, options: IClientOptions, client: MqttClient) => string;
|
|
2421
|
-
properties?: {
|
|
2422
|
-
sessionExpiryInterval?: number;
|
|
2423
|
-
receiveMaximum?: number;
|
|
2424
|
-
maximumPacketSize?: number;
|
|
2425
|
-
topicAliasMaximum?: number;
|
|
2426
|
-
requestResponseInformation?: boolean;
|
|
2427
|
-
requestProblemInformation?: boolean;
|
|
2428
|
-
userProperties?: UserProperties;
|
|
2429
|
-
authenticationMethod?: string;
|
|
2430
|
-
authenticationData?: Buffer;
|
|
2431
|
-
};
|
|
2432
|
-
messageIdProvider?: IMessageIdProvider;
|
|
2433
|
-
}
|
|
2434
|
-
export interface IClientPublishOptions {
|
|
2435
|
-
/**
|
|
2436
|
-
* the QoS
|
|
2437
|
-
*/
|
|
2438
|
-
qos?: QoS;
|
|
2439
|
-
/**
|
|
2440
|
-
* the retain flag
|
|
2441
|
-
*/
|
|
2442
|
-
retain?: boolean;
|
|
2443
|
-
/**
|
|
2444
|
-
* whether or not mark a message as duplicate
|
|
2445
|
-
*/
|
|
2446
|
-
dup?: boolean;
|
|
2447
|
-
/*
|
|
2448
|
-
* MQTT 5.0 properties object
|
|
2449
|
-
*/
|
|
2450
|
-
properties?: {
|
|
2451
|
-
payloadFormatIndicator?: boolean;
|
|
2452
|
-
messageExpiryInterval?: number;
|
|
2453
|
-
topicAlias?: number;
|
|
2454
|
-
responseTopic?: string;
|
|
2455
|
-
correlationData?: Buffer;
|
|
2456
|
-
userProperties?: UserProperties;
|
|
2457
|
-
subscriptionIdentifier?: number;
|
|
2458
|
-
contentType?: string;
|
|
2459
|
-
};
|
|
2460
|
-
/**
|
|
2461
|
-
* callback called when message is put into `outgoingStore`
|
|
2462
|
-
*/
|
|
2463
|
-
cbStorePut?: StorePutCallback;
|
|
2464
|
-
}
|
|
2465
|
-
export interface IClientReconnectOptions {
|
|
2466
|
-
/**
|
|
2467
|
-
* a Store for the incoming packets
|
|
2468
|
-
*/
|
|
2469
|
-
incomingStore?: Store;
|
|
2470
|
-
/**
|
|
2471
|
-
* a Store for the outgoing packets
|
|
2472
|
-
*/
|
|
2473
|
-
outgoingStore?: Store;
|
|
2474
|
-
}
|
|
2475
|
-
export interface IClientSubscribeOptions {
|
|
2476
|
-
/**
|
|
2477
|
-
* the QoS
|
|
2478
|
-
*/
|
|
2479
|
-
qos: QoS;
|
|
2480
|
-
/*
|
|
2481
|
-
* no local flag
|
|
2482
|
-
* */
|
|
2483
|
-
nl?: boolean;
|
|
2484
|
-
/*
|
|
2485
|
-
* Retain As Published flag
|
|
2486
|
-
* */
|
|
2487
|
-
rap?: boolean;
|
|
2488
|
-
/*
|
|
2489
|
-
* Retain Handling option
|
|
2490
|
-
* */
|
|
2491
|
-
rh?: number;
|
|
2492
|
-
/*
|
|
2493
|
-
* MQTT 5.0 properies object of subscribe
|
|
2494
|
-
* */
|
|
2495
|
-
properties?: {
|
|
2496
|
-
subscriptionIdentifier?: number;
|
|
2497
|
-
userProperties?: UserProperties;
|
|
2498
|
-
};
|
|
2499
|
-
}
|
|
2500
1468
|
/** 本地模拟远端混音流轨接口 */
|
|
2501
1469
|
export interface IMockRemoteAudioMixTrack {
|
|
2502
1470
|
readonly __type: "MockRemoteAudioMixTrack";
|
|
@@ -2527,76 +1495,6 @@ export interface IRemoteAudioMixTrack {
|
|
|
2527
1495
|
*/
|
|
2528
1496
|
getFilterUids(): string[];
|
|
2529
1497
|
}
|
|
2530
|
-
export interface ISecureClientOptions {
|
|
2531
|
-
/**
|
|
2532
|
-
* optional private keys in PEM format
|
|
2533
|
-
*/
|
|
2534
|
-
key?: string | string[] | Buffer | Buffer[] | Object[];
|
|
2535
|
-
/**
|
|
2536
|
-
* optional cert chains in PEM format
|
|
2537
|
-
*/
|
|
2538
|
-
cert?: string | string[] | Buffer | Buffer[];
|
|
2539
|
-
/**
|
|
2540
|
-
* Optionally override the trusted CA certificates in PEM format
|
|
2541
|
-
*/
|
|
2542
|
-
ca?: string | string[] | Buffer | Buffer[];
|
|
2543
|
-
rejectUnauthorized?: boolean;
|
|
2544
|
-
/**
|
|
2545
|
-
* optional alpn's
|
|
2546
|
-
*/
|
|
2547
|
-
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
|
|
2548
|
-
}
|
|
2549
|
-
export interface IStoreOptions {
|
|
2550
|
-
/**
|
|
2551
|
-
* true, clear _inflights at close
|
|
2552
|
-
*/
|
|
2553
|
-
clean?: boolean;
|
|
2554
|
-
}
|
|
2555
|
-
export interface IStream extends EventEmitter {
|
|
2556
|
-
pipe(to: any): any;
|
|
2557
|
-
destroy(): any;
|
|
2558
|
-
end(): any;
|
|
2559
|
-
}
|
|
2560
|
-
export interface ISubscriptionGrant {
|
|
2561
|
-
/**
|
|
2562
|
-
* is a subscribed to topic
|
|
2563
|
-
*/
|
|
2564
|
-
topic: string;
|
|
2565
|
-
/**
|
|
2566
|
-
* is the granted qos level on it, may return 128 on error
|
|
2567
|
-
*/
|
|
2568
|
-
qos: QoS | number;
|
|
2569
|
-
/*
|
|
2570
|
-
* no local flag
|
|
2571
|
-
* */
|
|
2572
|
-
nl?: boolean;
|
|
2573
|
-
/*
|
|
2574
|
-
* Retain As Published flag
|
|
2575
|
-
* */
|
|
2576
|
-
rap?: boolean;
|
|
2577
|
-
/*
|
|
2578
|
-
* Retain Handling option
|
|
2579
|
-
* */
|
|
2580
|
-
rh?: number;
|
|
2581
|
-
}
|
|
2582
|
-
export interface ISubscriptionMap {
|
|
2583
|
-
/**
|
|
2584
|
-
* object which has topic names as object keys and as value the options, like {'test1': {qos: 0}, 'test2': {qos: 2}}.
|
|
2585
|
-
*/
|
|
2586
|
-
[topic: string]: {
|
|
2587
|
-
qos: QoS;
|
|
2588
|
-
nl?: boolean;
|
|
2589
|
-
rap?: boolean;
|
|
2590
|
-
rh?: number;
|
|
2591
|
-
};
|
|
2592
|
-
}
|
|
2593
|
-
/**
|
|
2594
|
-
* im频道外消息连接/重连api返回
|
|
2595
|
-
*/
|
|
2596
|
-
export interface ImConnectRsp {
|
|
2597
|
-
/** mqtt信息 */
|
|
2598
|
-
mqtt: MqttServer;
|
|
2599
|
-
}
|
|
2600
1498
|
/** im强制断开事件data */
|
|
2601
1499
|
export interface ImDisconnectEventData {
|
|
2602
1500
|
/** 断开原因 */
|
|
@@ -2703,6 +1601,12 @@ export interface LocalCompositeRecorderVideoItem {
|
|
|
2703
1601
|
rect: LocalCompositeRecorderRect;
|
|
2704
1602
|
/** 绘制在视频左下角的标签文本,例如用户名;不传则不绘制标签 */
|
|
2705
1603
|
label?: string;
|
|
1604
|
+
/**
|
|
1605
|
+
* 头像 URL;当该槽位没有可绘制视频帧(如摄像头关闭)时,在格子中央绘制圆形头像。
|
|
1606
|
+
* 采用匿名跨域加载(crossOrigin='anonymous'):CDN 未配 CORS 头会触发加载失败而非污染 canvas,
|
|
1607
|
+
* 失败或未传时回退为「昵称首字母彩色圆」。
|
|
1608
|
+
*/
|
|
1609
|
+
avatar?: string;
|
|
2706
1610
|
/** 视频填充方式:contain 保留完整画面,cover 填满区域并裁剪溢出部分;默认 contain */
|
|
2707
1611
|
fit?: "contain" | "cover";
|
|
2708
1612
|
/** 单个视频槽位背景色;默认 #1a1c22 */
|
|
@@ -2761,29 +1665,6 @@ export interface MixedAudioMediaStreamTrack extends MediaStreamTrack {
|
|
|
2761
1665
|
removeTrack(track: MediaStreamTrack): void;
|
|
2762
1666
|
trackCount: number;
|
|
2763
1667
|
}
|
|
2764
|
-
/**
|
|
2765
|
-
* MQTT 服务器配置
|
|
2766
|
-
*/
|
|
2767
|
-
export interface MqttServer {
|
|
2768
|
-
/** MQTT 服务名称 */
|
|
2769
|
-
name: string;
|
|
2770
|
-
/** mqtt 客户端连接通过 jwt 验证授权,username 用 uid,clientid 用 sid */
|
|
2771
|
-
/** https://www.emqx.io/docs/zh/latest/access-control/authn/jwt.html */
|
|
2772
|
-
/** jwt 里加上权限控制,仅允许订阅特定 topic(不允许发送) */
|
|
2773
|
-
jwt_token: string;
|
|
2774
|
-
/** jwt token过期时间 */
|
|
2775
|
-
token_exp_at: number;
|
|
2776
|
-
/** tcp 连接地址 */
|
|
2777
|
-
tcp: string;
|
|
2778
|
-
/** ws 连接地址 */
|
|
2779
|
-
ws: string;
|
|
2780
|
-
/** 连接用的client id */
|
|
2781
|
-
client_id: string;
|
|
2782
|
-
/** 连接用的username */
|
|
2783
|
-
username: string;
|
|
2784
|
-
/** 监听的 topics */
|
|
2785
|
-
topics: string[];
|
|
2786
|
-
}
|
|
2787
1668
|
/**
|
|
2788
1669
|
* 网络总体统计
|
|
2789
1670
|
*/
|
|
@@ -2812,6 +1693,40 @@ export interface NetworkStats {
|
|
|
2812
1693
|
rtt_up?: number;
|
|
2813
1694
|
/** 订阅连接观测到的 RTT,单位 ms */
|
|
2814
1695
|
rtt_down?: number;
|
|
1696
|
+
/**
|
|
1697
|
+
* 服务端质量报告(上/下行)。来自 SFU 主动下发的 quality 报告(仅 seastart 等支持的 vendor 有)。
|
|
1698
|
+
* 与 getStats 客户端视角互补:上行实收/下行实发以服务端为准,缺省时上层自动回退客户端侧。
|
|
1699
|
+
*/
|
|
1700
|
+
server?: ServerQualityReport;
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* 浏览器 UA 解析结果。
|
|
1704
|
+
* 结构对齐 bowser 的 Parser.ParsedResult,但自行声明——公开类型面不依赖 bowser,
|
|
1705
|
+
* 否则 d.ts 会 import bowser 的类型,使用者不装它就编译不过。
|
|
1706
|
+
*/
|
|
1707
|
+
export interface ParsedBrowserInfo {
|
|
1708
|
+
/** 浏览器名称与版本 */
|
|
1709
|
+
browser: {
|
|
1710
|
+
name?: string;
|
|
1711
|
+
version?: string;
|
|
1712
|
+
};
|
|
1713
|
+
/** 操作系统 */
|
|
1714
|
+
os: {
|
|
1715
|
+
name?: string;
|
|
1716
|
+
version?: string;
|
|
1717
|
+
versionName?: string;
|
|
1718
|
+
};
|
|
1719
|
+
/** 设备平台(desktop/mobile/tablet 等) */
|
|
1720
|
+
platform: {
|
|
1721
|
+
type?: string;
|
|
1722
|
+
vendor?: string;
|
|
1723
|
+
model?: string;
|
|
1724
|
+
};
|
|
1725
|
+
/** 内核引擎 */
|
|
1726
|
+
engine: {
|
|
1727
|
+
name?: string;
|
|
1728
|
+
version?: string;
|
|
1729
|
+
};
|
|
2815
1730
|
}
|
|
2816
1731
|
/** 画中画句柄,用于控制画中画状态 */
|
|
2817
1732
|
export interface PipHandle {
|
|
@@ -2871,17 +1786,6 @@ export interface ProcessorOptions {
|
|
|
2871
1786
|
*/
|
|
2872
1787
|
audioContext?: AudioContext;
|
|
2873
1788
|
}
|
|
2874
|
-
/**
|
|
2875
|
-
* 属性更改项
|
|
2876
|
-
*/
|
|
2877
|
-
export interface PropChangeItem<T> {
|
|
2878
|
-
/** 属性名 */
|
|
2879
|
-
prop: T;
|
|
2880
|
-
/** 更改后的值 */
|
|
2881
|
-
value: any;
|
|
2882
|
-
/** 更改前的值 */
|
|
2883
|
-
old: any;
|
|
2884
|
-
}
|
|
2885
1789
|
/**
|
|
2886
1790
|
* 质量评估结果快照
|
|
2887
1791
|
*/
|
|
@@ -2922,32 +1826,6 @@ export interface ReceiverStats {
|
|
|
2922
1826
|
/** 本组 stats 的采集时间戳,单位 ms */
|
|
2923
1827
|
timestamp: number;
|
|
2924
1828
|
}
|
|
2925
|
-
/**
|
|
2926
|
-
* 断线重连api返回
|
|
2927
|
-
*/
|
|
2928
|
-
export interface ReconnectRsp {
|
|
2929
|
-
/** mqtt信息 */
|
|
2930
|
-
mqtt: MqttServer;
|
|
2931
|
-
/** 流媒体直连信息 */
|
|
2932
|
-
upload: UploadServer;
|
|
2933
|
-
/** rtmp网关信息 */
|
|
2934
|
-
rtmp: RtmpServer;
|
|
2935
|
-
/** webrtc网关信息 */
|
|
2936
|
-
webrtc: WebrtcServer;
|
|
2937
|
-
}
|
|
2938
|
-
/**
|
|
2939
|
-
* 程博 RTMP 网关连接信息
|
|
2940
|
-
*/
|
|
2941
|
-
export interface RtmpServer {
|
|
2942
|
-
/** RTMP 服务名称 */
|
|
2943
|
-
name: string;
|
|
2944
|
-
/** RTMP 推流前缀 */
|
|
2945
|
-
push_url: string;
|
|
2946
|
-
/** RTMP 拉流前缀 */
|
|
2947
|
-
pull_url: string;
|
|
2948
|
-
/** 对应upload服务的相对rtmp网关连接地址 */
|
|
2949
|
-
upload_host: string;
|
|
2950
|
-
}
|
|
2951
1829
|
/**
|
|
2952
1830
|
* 屏幕采集音频配置
|
|
2953
1831
|
*/
|
|
@@ -3031,25 +1909,42 @@ export interface SenderStats {
|
|
|
3031
1909
|
timestamp: number;
|
|
3032
1910
|
}
|
|
3033
1911
|
/**
|
|
3034
|
-
*
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
1912
|
+
* 服务端质量报告(上/下行双向)。仅在 SFU 支持并下发时存在,否则整体缺省。
|
|
1913
|
+
* seastart 引擎侧的 `SignalQualityMessage` 在此基础上再加一个 DC 消息类型判别字段。
|
|
1914
|
+
*/
|
|
1915
|
+
export interface ServerQualityReport {
|
|
1916
|
+
/** 服务端采样时间戳 ms */
|
|
1917
|
+
ts: number;
|
|
1918
|
+
/** 上行:客户端 -> SFU(服务端实收视角) */
|
|
1919
|
+
pub: ServerQualitySample;
|
|
1920
|
+
/** 下行:SFU -> 客户端(服务端实发视角) */
|
|
1921
|
+
sub: ServerQualitySample;
|
|
1922
|
+
}
|
|
1923
|
+
/**
|
|
1924
|
+
* 服务端质量报告的单方向采样。
|
|
1925
|
+
* 来源:SFU 主动下发的 quality 报告(如 seastart 的 quality DC,pub=上行、sub=下行)。字段与 SFU
|
|
1926
|
+
* `quality.go` 协议一一对应。作为权威定义放在此处,seastart 引擎侧的 `SignalQualitySample` 是它的别名。
|
|
1927
|
+
* 与客户端 getStats 视角互补:上行实收/下行实发以服务端为地面真值,客户端只在其缺省时兜底。
|
|
1928
|
+
*/
|
|
1929
|
+
export interface ServerQualitySample {
|
|
1930
|
+
/** 服务端算出的 0~100 连续分 */
|
|
1931
|
+
score: number;
|
|
1932
|
+
/** 服务端直接给出的档位 */
|
|
1933
|
+
level: ConnectionQuality;
|
|
1934
|
+
/** 服务端算好的 MOS,范围 1.0 ~ 4.5 */
|
|
1935
|
+
mos: number;
|
|
1936
|
+
/** 丢包率,0~1(注意:非百分数,上层展示需 ×100) */
|
|
1937
|
+
loss: number;
|
|
1938
|
+
/** RTT,单位 ms */
|
|
1939
|
+
rtt: number;
|
|
1940
|
+
/** jitter,单位 ms */
|
|
1941
|
+
jitter: number;
|
|
1942
|
+
/** 本窗口参与统计的包数 */
|
|
1943
|
+
packets: number;
|
|
1944
|
+
/** 本窗口该方向平均码率,单位 kbps */
|
|
1945
|
+
bitrate: number;
|
|
1946
|
+
/** 本窗口该方向字节数;和 bitrate 同源 */
|
|
1947
|
+
bytes: number;
|
|
3053
1948
|
}
|
|
3054
1949
|
/**
|
|
3055
1950
|
* 流媒体引擎周期性输出的 metric 快照
|
|
@@ -3121,17 +2016,6 @@ export interface TrackProcessor {
|
|
|
3121
2016
|
/** 释放资源:断开音频节点、关闭自建的 AudioContext 等 */
|
|
3122
2017
|
destroy(): Promise<void>;
|
|
3123
2018
|
}
|
|
3124
|
-
/**
|
|
3125
|
-
* 程博流媒体服务连接信息
|
|
3126
|
-
*/
|
|
3127
|
-
export interface UploadServer {
|
|
3128
|
-
/** 流媒体服务名称 */
|
|
3129
|
-
name: string;
|
|
3130
|
-
/** 流媒体服务器地址 */
|
|
3131
|
-
address: string;
|
|
3132
|
-
/** 流媒体服务器端口 */
|
|
3133
|
-
port: string;
|
|
3134
|
-
}
|
|
3135
2019
|
/** 用户离开事件data */
|
|
3136
2020
|
export interface UserLeaveEventData {
|
|
3137
2021
|
/** 用户id */
|
|
@@ -3253,17 +2137,6 @@ export interface VideoSenderStats extends SenderStats {
|
|
|
3253
2137
|
/** 目标码率 */
|
|
3254
2138
|
targetBitrate: number;
|
|
3255
2139
|
}
|
|
3256
|
-
/**
|
|
3257
|
-
* 程博 WebRTC 网关连接信息
|
|
3258
|
-
*/
|
|
3259
|
-
export interface WebrtcServer {
|
|
3260
|
-
/** WebRTC 服务名称 */
|
|
3261
|
-
name: string;
|
|
3262
|
-
/** WebRTC 接口前缀 */
|
|
3263
|
-
cmd_url: string;
|
|
3264
|
-
/** 对应upload服务的相对webrtc网关连接地址 */
|
|
3265
|
-
upload_host: string;
|
|
3266
|
-
}
|
|
3267
2140
|
/**
|
|
3268
2141
|
* 频道事件通知(判别联合类型:`type` 决定 `data` 的精确形状)。
|
|
3269
2142
|
*
|
|
@@ -3304,12 +2177,6 @@ export type ImEvent = {
|
|
|
3304
2177
|
export type LocalCompositeRecorderState = "inactive" | "recording" | "paused";
|
|
3305
2178
|
/** 本地合成录制器可接受的输入轨道 */
|
|
3306
2179
|
export type LocalCompositeRecorderTrack = MediaStreamTrack | LocalVideoTrack | RemoteVideoTrack | LocalAudioTrack | RemoteAudioTrack;
|
|
3307
|
-
/**
|
|
3308
|
-
* 重试执行器函数:直接调用开始执行,.cancel()取消重试,函数失败会返回maxretry或canceled
|
|
3309
|
-
*/
|
|
3310
|
-
export type retryCallback<T> = (() => Promise<T>) & {
|
|
3311
|
-
cancel: () => void;
|
|
3312
|
-
};
|
|
3313
2180
|
/**
|
|
3314
2181
|
* 频道信息
|
|
3315
2182
|
*/
|