@seastart/srtc-web-sdk 0.5.7 → 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/srtc.d.ts CHANGED
@@ -1,320 +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
- /** 频道级音频合成流(program,服务端统一混音,观众/录制用,区别于参与者本地混的 audioMixTrack) */
35
- protected audioMcuTrack?: BaseTrack;
36
- /** 兼容回调方式的事件响应 */
37
- protected eventCB: ((evt: ChannelEvent) => void) | null;
38
- /**
39
- * 根据userinfo实例化user
40
- * @param info
41
- */
42
- protected abstract newUser(info: BaseUserInfo): BaseUser;
43
- /**
44
- * 进行中的流订阅/取消订阅等互斥操作mutex
45
- */
46
- private trackMutex;
47
- /**
48
- * 流订阅/取消订阅防抖动
49
- */
50
- private trackDebounce;
51
- constructor(options: JoinOptions, rsp: ChannelJoinRsp, api: BaseRtcApi, streamEngine: BaseStreamEngine, socket: BaseRtcSocket, eventCB?: ((evt: ChannelEvent) => void) | null);
52
- /**
53
- * 刷新频道详情
54
- */
55
- protected refresh(isReconnected: boolean): Promise<void>;
56
- /**
57
- * 入会时对已有远端轨道进行自动订阅
58
- */
59
- private autoSubscribeExistingTracks;
60
- /**
61
- * 检查频道是否是已连接状态,不是则抛出错误
62
- * @returns
63
- */
64
- protected checkConnected(): void;
65
- /**
66
- * 监听socket
67
- */
68
- private addSocketListeners;
69
- /**
70
- * 取消监听socket
71
- */
72
- private removeSocketListeners;
73
- /**
74
- * 触发频道事件。
75
- *
76
- * 用 rest-tuple 技巧把 data 是否必填和 map 绑定起来:
77
- * - 当 `ChannelEventDataMap[K]` 是 `undefined`(如 RECONNECTING):调用处省略第二个参数;
78
- * - 其余情况:调用处**必须**传入与 map 对应的 data 类型。
79
- * 这样新增事件类型时 TS 会卡在对应 emit 位置,避免 data 漂移。
80
- *
81
- * @param type 事件类型
82
- * @param args 事件 data(类型由 map 决定)
83
- */
84
- protected triggerEvent<K extends keyof ChannelEventDataMap>(type: K, ...args: ChannelEventDataMap[K] extends undefined ? [
85
- ] : [
86
- data: ChannelEventDataMap[K]
87
- ]): void;
88
- /**
89
- * 心跳
90
- */
91
- private heartbeat;
92
- /**
93
- * socket连接成功
94
- */
95
- private onConnected;
96
- /**
97
- * socket开始重连
98
- */
99
- private onStartReconnect;
100
- /**
101
- * 收到频道内消息
102
- * @param pkt 消息体
103
- */
104
- private onChannelMessage;
105
- /**
106
- * 获取自己
107
- * @returns
108
- */
109
- getMe(): BaseUser;
110
- /**
111
- * 获取某用户
112
- * @param uid 用户id
113
- */
114
- getUser(uid: string): BaseUser;
115
- /**
116
- * 获取用户信息列表
117
- */
118
- getUsersInfo(map: boolean): BaseUserInfo[] | Record<string, BaseUserInfo>;
119
- /**
120
- * 离开频道
121
- */
122
- leave(reason: DisconnectReason, error?: any): Promise<void>;
123
- /**
124
- * 获取对sdk外部展现的频道信息
125
- * @returns
126
- */
127
- getInfo(): BaseChannelInfo;
128
- /**
129
- * 监听流媒体引擎事件(如质量/active speakers 等)。
130
- * 基类默认空实现;具体引擎的 Channel 子类 override 注册自己的事件转发。
131
- */
132
- protected addStreamEngineListeners(): void;
133
- /**
134
- * 获取流媒体引擎供应商
135
- */
136
- getStreamEngineVendor(): string;
137
- /**
138
- * 获取轨道发布额外参数
139
- */
140
- protected getPublishExOption(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): Promise<Record<string, any>>;
141
- /**
142
- * 获取发布后新增的tracks
143
- * 之所以是数组是因为自研引擎支持发布流时自动simucast
144
- */
145
- protected getAddedTracksAfterPublish(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): BaseTrack[];
146
- /**
147
- * 获取取消发布后删除的tracks
148
- */
149
- protected getDeletedTracksAfterUnpublish(track: BaseTrack): BaseTrack[];
150
- /**
151
- * 发布本地流轨道
152
- * @param track
153
- * @returns
154
- */
155
- publishLocalTrack(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): Promise<void>;
156
- /**
157
- * 取消发布本地流
158
- * @param track
159
- */
160
- unpublishLocalTrack(track: BaseTrack): Promise<void>;
161
- /**
162
- * 获取轨道订阅额外参数
163
- */
164
- protected getSubscribeExOption(track: BaseTrack): Promise<Record<string, any>>;
165
- /**
166
- * 生成"参与者视角"混音流(mix-minus)。
167
- * 由各平台按 vendor 决定具体类型:支持服务端混音的(OOK/wx/CDN)返回真 RemoteAudioMixTrack,
168
- * 不支持的(webrtc-seastart)返回 MockRemoteAudioMixTrack(自动订他人音频、本地混、排除自己)。
169
- * @param filter 可选 uid 过滤;仅本地混(Mock)生效
170
- */
171
- protected abstract newRemoteAudioMixTrack(filter?: ((track: BaseTrack) => boolean) | string[]): BaseTrack & (IMockRemoteAudioMixTrack | IRemoteAudioMixTrack);
172
- /**
173
- * 生成远端视频合成流(Mcu,服务端统一合成,含所有人,观众/录制用)。
174
- */
175
- protected abstract newRemoteVideoMcuTrack(): BaseTrack;
176
- /**
177
- * 生成远端音频合成流(program,服务端统一合成,含所有人,观众/录制用)。
178
- * 与 newRemoteAudioMixTrack 不同:本方法各平台都返回"真·服务端合成流",绝不返回本地混(Mock)。
179
- */
180
- protected abstract newRemoteAudioMcuTrack(): BaseTrack;
181
- /**
182
- * 获取远端频道混音流
183
- * @param filter 音频轨道过滤器,传递string[]时,根据uid过滤
184
- */
185
- subscribeRemoteAudioMixTrack(filter?: ((track: BaseTrack) => boolean) | string[]): Promise<BaseTrack & (IMockRemoteAudioMixTrack | IRemoteAudioMixTrack)>;
186
- /**
187
- * 订阅远端用户音频流
188
- * @param uid 用户id
189
- * @param id 流轨道id
190
- */
191
- subscribeRemoteAudioTrack(uid: string, id: string): Promise<BaseTrack>;
192
- /**
193
- * 订阅远端视频合成流
194
- */
195
- subscribeRemoteVideoMcuTrack(): Promise<BaseTrack>;
196
- /**
197
- * 订阅服务端统一合成的混音(program,含所有人,所有订阅者收到的一致)。
198
- * 给不发声的观众/录制/旁路用,与 subscribeRemoteVideoMcuTrack 对应;不做 vendor 降级。
199
- *
200
- * 该流含全场(包括你自己):会发声的参与者订它会听到自己的回声——
201
- * 参与者请改用 subscribeRemoteAudioMixTrack(本地 mix-minus,除自己)。
202
- */
203
- subscribeRemoteAudioMcuTrack(): Promise<BaseTrack>;
204
- /**
205
- * 订阅远端用户视频流
206
- * @param uid 用户id
207
- * @param id 流轨道id
208
- */
209
- subscribeRemoteVideoTrack(uid: string, id: string): Promise<BaseTrack>;
210
- /**
211
- * 取消订阅远端流
212
- * @param track 流轨道
213
- * @param debounceWaitMs 防取消订阅/订阅抖动ms数
214
- */
215
- unsubscribeRemoteTrack(track: BaseTrack, debounceWaitMs?: number): Promise<void>;
216
- }
217
- declare abstract class BaseRtcApi {
218
- /** rtc AppID */
219
- protected appID: string;
220
- /** rtc sid */
221
- protected sid: string;
222
- /** 客户端密钥 */
223
- protected clientKey: string;
224
- /** 服务器地址头部 */
225
- protected serverPrefix?: string;
226
- /**
227
- * 发起rtc api http请求
228
- */
229
- protected abstract http(api: string, params: Record<string, any>, headers: Record<string, string>): Promise<any>;
230
- constructor(appID: string, sid: string, clientKey: string, serverPrefix: string);
231
- /**
232
- * 加入频道
233
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=51c6ed8
234
- */
235
- join(params: {
236
- deviceType: DeviceType;
237
- deviceID: string;
238
- version: string;
239
- }): Promise<ChannelJoinRsp>;
240
- /**
241
- * 频道详情
242
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=520ba1f
243
- * @param listuser 是否包括在线用户列表,true则返回所有在线用户
244
- * @returns
245
- */
246
- detail(listuser: boolean): Promise<{
247
- channelinfo: BaseChannelInfo;
248
- userinfos: BaseUserInfo[] | null;
249
- }>;
250
- /**
251
- * 离开频道
252
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=51d732b
253
- * @returns
254
- */
255
- leave(): Promise<void>;
256
- /**
257
- * 发送心跳
258
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=51d38e3
259
- * @returns
260
- */
261
- heartbeat(): Promise<void>;
262
- /**
263
- * 断线重连
264
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=52602cf
265
- * @returns
266
- */
267
- reconnect(params: {
268
- type: number;
269
- }): Promise<ReconnectRsp>;
270
- /**
271
- * 更新流信息
272
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=51c6eae
273
- * @returns
274
- */
275
- updateStream(trackinfos: BaseTrackInfo[]): Promise<void>;
276
- /**
277
- * im连接
278
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=25c1132f700054
279
- * @returns
280
- */
281
- imConnect(params: {
282
- deviceType: DeviceType;
283
- deviceID: string;
284
- version: string;
285
- }): Promise<ImConnectRsp>;
286
- /**
287
- * im重连
288
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=25c2a79e70007f
289
- * @returns
290
- */
291
- imReconnect(): Promise<ImConnectRsp>;
292
- /**
293
- * im发送心跳
294
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=25c2da5cb00081
295
- * @returns
296
- */
297
- imHeartbeat(): Promise<void>;
298
- /**
299
- * im断开连接
300
- * @see https://doc.apipost.net/docs/detail/2be86df99864000?target_id=25c356d2300092
301
- * @returns
302
- */
303
- imDisconnect(): Promise<void>;
304
- /**
305
- * 发送rtc sdk api请求
306
- * @param api api接口
307
- * @param params 数据
308
- * @param headers 额外http头
309
- */
310
- protected req(api: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<any>;
311
- /**
312
- * 签名
313
- * @param params
314
- * @returns
315
- */
316
- private signature;
317
- }
318
3
  declare abstract class BaseSRTC {
319
4
  /**
320
5
  * 获取sdk编译信息
@@ -335,17 +20,20 @@ declare abstract class BaseSRTC {
335
20
  onNotifyImEvent?: ((event: ImEvent) => void) | null;
336
21
  constructor(initParams: SdkInitParams);
337
22
  /**
338
- * 加入频道的version信息
339
- */
340
- protected get joinVersion(): string;
341
- /**
342
- * 加入频道
23
+ * 加入频道,返回该频道的 Channel 对象。
24
+ *
25
+ * 频道级操作(发布/订阅/成员/事件/离会)都在返回的 Channel 上进行;SRTC 门面
26
+ * 的同名便捷方法等价于操作**默认频道**(最早加入且仍存活的那个)。
27
+ * web 端可多次 join 同时加入多个频道;小程序端受 live-pusher 独占限制仍是单频道。
28
+ *
343
29
  * @param token 加入频道token
344
30
  * @param options 加入频道选项
31
+ * @returns 频道对象;原先 join 返回的频道信息改用 `channel.getInfo()` 获取
345
32
  */
346
- join(token: string, options?: JoinOptions): Promise<BaseChannelInfo>;
33
+ join(token: string, options?: JoinOptions): Promise<BaseChannel>;
347
34
  /**
348
- * 离开频道
35
+ * 离开默认频道(最早加入且仍存活的频道)。
36
+ * 多频道场景建议直接用 `channel.leave()` 精确指定要离开的频道。
349
37
  */
350
38
  leave(): Promise<void>;
351
39
  /**
@@ -353,6 +41,15 @@ declare abstract class BaseSRTC {
353
41
  * @returns
354
42
  */
355
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;
356
53
  /**
357
54
  * 获取某用户信息
358
55
  * @returns
@@ -406,182 +103,36 @@ declare abstract class BaseSRTC {
406
103
  * 关闭频道外消息
407
104
  */
408
105
  disableIm(): Promise<void>;
409
- }
410
- declare abstract class BaseStreamEngine extends EventEmitter {
411
- /** 加入频道api返回的数据 */
412
- protected joinRsp: ChannelJoinRsp;
413
- /** 已发布轨道 */
414
- protected published: Record<string, BaseTrackEx>;
415
- /** 已订阅轨道 */
416
- protected subscribed: Record<string, BaseTrackEx>;
417
- /** 能力 */
418
- protected ability?: StreamEngineAbility;
419
- /** 采集metric指标定时器(用于日志上报) */
420
- protected monitorInterval?: number;
421
- constructor(rsp: ChannelJoinRsp, ability?: Partial<StreamEngineAbility>);
422
- /**
423
- * 流媒体服务商名
424
- */
425
- abstract vendor(): string;
426
- /**
427
- * 连接流媒体服务(如果需要,程博webrtc流媒体就需要)
428
- */
429
- connect(): Promise<void>;
430
- /**
431
- * 发布本地流
432
- * @param track
433
- * @param opt 通用发布参数
434
- * @param exopt 该引擎特有的发布参数
435
- */
436
- publish(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions, exopt: Record<string, any>): Promise<void>;
437
106
  /**
438
- * 取消发布本地流
439
- * @param track
440
- */
441
- abstract unpublish(track: BaseTrack): Promise<void>;
442
- /**
443
- * 订阅远端流
444
- * @param track
445
- * @param exopt 该引擎特有的订阅参数
446
- */
447
- subscribe(track: BaseTrack, exopt: Record<string, any>): Promise<void>;
448
- /**
449
- * 是否已订阅某轨道
450
- * @param track
451
- * @returns
452
- */
453
- haveSubscribed(track: BaseTrack): boolean;
454
- /**
455
- * 取消订阅远端流
456
- * @param track
457
- * @param exopt 该引擎特有的取消订阅参数
458
- */
459
- abstract unsubscribe(track: BaseTrack): Promise<void>;
460
- /**
461
- * 断开流媒体服务
462
- */
463
- disconnect(): Promise<void>;
464
- /**
465
- * 获取当前metric快照
466
- */
467
- getMetricSnapshot(): Record<string, any> | undefined;
468
- /**
469
- * 开始metric采集
107
+ * 彻底释放整个 SRTC 引擎:离开所有频道、关闭 im,并解除构造时注册的进程级监听
108
+ * (设备插拔、页面可见性等,由各端子类通过 releaseGlobalListeners 提供)。
470
109
  *
471
- * 基类只做 10s 低频日志上报。
472
- * 若子类需要更高频采样(例如 webrtc 引擎的质量评分),可 override 后 `super.startMonitor()`。
473
- */
474
- protected startMonitor(): void;
475
- /**
476
- * 获取metric数据
477
- * @returns
478
- */
479
- protected abstract getMetric(): Promise<Record<string, any>>;
480
- /**
481
- * 结束metric采集
110
+ * 不调用 destroy() 则引擎注册的浏览器事件监听会一直持有它的引用、永远不会被回收,
111
+ * SPA 路由切换、组件卸载时务必调用。
112
+ *
113
+ * 各离会/关闭步骤互不依赖,即使某一步报错也会继续做完剩下的清理,最后统一抛出汇总错误。
482
114
  */
483
- protected stopMonitor(): void;
115
+ destroy(): Promise<void>;
484
116
  }
485
- declare abstract class BaseTrack extends EventEmitter {
486
- constructor(info: BaseTrackInfo, uid: string);
117
+ declare abstract class BaseWebrtcLocalTrack extends BaseWebrtcTrack implements BaseLocalTrack {
487
118
  /**
488
- * 轨道id
119
+ * 轨道id。发布后引擎可能把 id 改写为服务端分配值(如 seastart 联播副轨),
120
+ * 单发布时代理到发布记录,保证与上报给会控的 id 一致
489
121
  */
490
122
  get id(): string;
491
- /**
492
- * 轨道类型
493
- */
494
- get kind(): TrackKind;
495
- /**
496
- * 轨道描述
497
- */
123
+ /** 轨道描述(单发布时代理到发布记录) */
498
124
  get desc(): string;
499
- /**
500
- * 是否为 simulcast 副层
501
- */
125
+ /** 是否为 simulcast 副层(单发布时代理到发布记录) */
502
126
  get variant(): boolean | undefined;
127
+ /** 视频角度(单发布时代理到发布记录) */
128
+ get angle(): number;
503
129
  /**
504
- * 获取流轨道信息
505
- * @returns
130
+ * 获取流轨道信息:单发布 → 该次发布在频道内的描述(与旧版行为一致);
131
+ * 未发布 → 采集轨自身描述;发布到多个频道 → 抛错,请改用 channel.getPublishInfo(track)
506
132
  */
507
133
  getInfo(): BaseTrackInfo;
508
- /**
509
- * 轨道所属用户
510
- * @returns
511
- */
134
+ /** 轨道归属 uid:发布登记到 me 名下时由频道回填到发布记录,单发布时代理过去 */
512
135
  getUid(): string;
513
- toString(): string;
514
- }
515
- declare abstract class BaseUser {
516
- /** track 数组 */
517
- protected tracks: Record<string, BaseTrack>;
518
- /** 对外输出的info */
519
- protected info: BaseUserInfo;
520
- /**
521
- * 根据trackinfo实例化track
522
- * @param trackinfo
523
- */
524
- protected abstract newTrack(info: BaseTrackInfo): BaseTrack;
525
- constructor(info: BaseUserInfo);
526
- /**
527
- * 获取某轨道
528
- */
529
- getTrack(id: string): BaseTrack | undefined;
530
- /**
531
- * 用给定 info 新造一个独立的 track 句柄(不登记进 this.tracks)。
532
- * 用途:自订阅回环——订阅本端自己发布的轨道时,需要一个独立于本地发布轨道的远端句柄来承接下行,
533
- * 否则 seastart 订阅 PC 的 ontrack 会用收到的远端轨道 setMediaStreamTrack 顶掉本地发布源,
534
- * 导致发布端静音、编码器无输入、SFU 永等不到关键帧的死锁。此处仅暴露 protected newTrack 的建轨能力。
535
- */
536
- spawnTrack(info: BaseTrackInfo): BaseTrack;
537
- /**
538
- * 根据desc获取某轨道
539
- */
540
- getTrackByDesc(desc: string): BaseTrack | undefined;
541
- /**
542
- * 获取所有轨道
543
- * @returns
544
- */
545
- getTracks(): Record<string, BaseTrack>;
546
- /**
547
- * 全量更新tracks,目前会控只有全量更新某用户的所有track
548
- * @param trackinfos 新的全量trackinfos
549
- */
550
- updateTracks(trackinfos: BaseTrackInfo[]): {
551
- added: BaseTrack[];
552
- updated: BaseTrack[];
553
- deleted: BaseTrack[];
554
- };
555
- /**
556
- * 第三方用户id
557
- */
558
- get uid(): string;
559
- /**
560
- * 会话id
561
- */
562
- get sid(): string;
563
- /**
564
- * 设备类型
565
- */
566
- get device_type(): number;
567
- /**
568
- * 设备id
569
- */
570
- get device_id(): string;
571
- /**
572
- * 流媒体连接id
573
- */
574
- get link_id(): number;
575
- /**
576
- * 获取对sdk外部展现的用户信息
577
- * @returns
578
- */
579
- getInfo(): BaseUserInfo;
580
- /**
581
- * 更新描述信息
582
- * @param info
583
- */
584
- updateInfo(info: Partial<BaseUserInfo>): void;
585
136
  }
586
137
  declare abstract class BaseWebrtcTrack extends BaseTrack {
587
138
  constructor(info: BaseTrackInfo, uid: string);
@@ -589,106 +140,6 @@ declare abstract class BaseWebrtcTrack extends BaseTrack {
589
140
  getMediaStreamTrack(): MediaStreamTrack | undefined;
590
141
  getMediaStream(): MediaStream;
591
142
  }
592
- declare class BaseRtcSocket extends EventEmitter {
593
- /** mqtt客户端 */
594
- private client;
595
- /** 会控协议版本头 */
596
- private version;
597
- /** 已订阅topics:qos */
598
- private ssTopics;
599
- /** 重连时刷新auth */
600
- protected authReconnect?: AuthReconnect;
601
- /** 是否首次连接 */
602
- private isFirstConnect;
603
- /** 消息解析 */
604
- private unpacker;
605
- constructor(authReconnect?: AuthReconnect);
606
- /**
607
- * 初始化mqtt客户端
608
- * @param server
609
- */
610
- private initClient;
611
- /**
612
- * 转换websocket地址,主要小程序需要用wxs前缀
613
- * @param ws
614
- * @returns
615
- */
616
- protected getBrokerUrl(ws: string): string;
617
- /**
618
- * 连接mqtt服务器
619
- * @param server
620
- */
621
- connect(server: MqttServer): Promise<void>;
622
- /**
623
- * 添加socket常驻监听
624
- */
625
- private addListeners;
626
- /**
627
- * 封装mqtt的subscribe为promise
628
- * @param topic 话题或者话题数组
629
- */
630
- subscribe(topic: string | string[], qos?: QoS): Promise<void>;
631
- /**
632
- * 封装mqtt的unsubscribe为promise
633
- * @param topic 话题或者话题数组
634
- */
635
- unsubscribe(topic: string | string[]): Promise<void>;
636
- /**
637
- * 关闭socket
638
- * @param force 是否强制退出(不等待ack),对应mqttclient的end里的force
639
- * @returns
640
- */
641
- close(force?: boolean): Promise<void>;
642
- /**
643
- * 发送消息
644
- * @param data 数据
645
- * @param type 消息类型
646
- */
647
- sendMsg(msg: string | Buffer, topic: string, qos?: QoS): Promise<void>;
648
- /**
649
- * 收到mqtt消息响应
650
- * @param topic mqtt主题
651
- * @param payload 消息载荷
652
- * @param packet
653
- * @returns
654
- */
655
- private onMsg;
656
- }
657
- declare class Channel extends BaseChannel {
658
- /**
659
- * override:注册 webrtc 引擎特有的质量 / active speakers 事件转发。
660
- */
661
- protected addStreamEngineListeners(): void;
662
- /**
663
- * 获取流媒体引擎的metric快照(全量,包含每条轨道的统计)
664
- */
665
- getStreamMetric(): StreamMetric | undefined;
666
- /**
667
- * 获取当前网络总体统计,轻量接口,只关心网络整体指标时使用
668
- */
669
- getNetworkStats(): NetworkStats | undefined;
670
- /**
671
- * 获取当前连接质量评估结果(等级、MOS、原因等)
672
- */
673
- getConnectionQuality(): QualityEvaluation | undefined;
674
- protected getPublishExOption(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): Promise<Record<string, any>>;
675
- protected getAddedTracksAfterPublish(track: BaseTrack, opt: AudioPublishOptions | VideoPublishOptions): BaseTrack[];
676
- protected getDeletedTracksAfterUnpublish(track: BaseTrack): BaseTrack[];
677
- protected getSubscribeExOption(track: BaseTrack): Promise<Record<string, any>>;
678
- protected newRemoteAudioMixTrack(filter?: ((track: BaseTrack) => boolean) | string[]): RemoteAudioMixTrack | MockRemoteAudioMixTrack;
679
- protected newRemoteVideoMcuTrack(): RemoteVideoMcuTrack;
680
- protected newRemoteAudioMcuTrack(): RemoteAudioMcuTrack;
681
- subscribeRemoteVideoTrack(uid: string, id: string): Promise<BaseTrack>;
682
- unsubscribeRemoteTrack(track: BaseTrack, debounceWaitMs?: number): Promise<void>;
683
- /** 自适应流管理器。懒初始化,避免父类构造期还未准备好 rtcStreamEngine/options 的问题。 */
684
- private adaptiveStream?;
685
- private getAdaptiveStream;
686
- /**
687
- * 解析某路远端视频订阅的完整候选层,顺序"高到低"。
688
- * 这一步依赖 user 结构,所以留在 Channel 里作为解析器喂给 Manager。
689
- */
690
- private getAdaptiveVideoCandidates;
691
- }
692
143
  declare class CommonChannelEventType {
693
144
  /** 频道自定义props更新 */
694
145
  static readonly CHANNEL_UPDATE = "channel_update";
@@ -746,340 +197,193 @@ declare class CommonTrackEventType {
746
197
  /** playback or streaming has stopped because the end of the media was reached or because no further data is available */
747
198
  static readonly ENDED = "ended";
748
199
  }
749
- declare class Logger {
750
- constructor(dp?: string, dclt?: string);
751
- setTarget(target: LogTarget): void;
752
- setLevel(level: LogLevel): void;
753
- debug(...args: any[]): void;
754
- info(...args: any[]): void;
755
- warn(...args: any[]): void;
756
- error(...args: any[]): void;
200
+ declare class RemoteVideoMcuTrack extends RemoteVideoTrack {
201
+ constructor();
757
202
  }
758
- declare class MockRemoteAudioMixTrack extends RemoteAudioTrack implements IMockRemoteAudioMixTrack {
759
- constructor(info: BaseTrackInfo, filter?: (track: BaseTrack) => boolean);
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 {
760
222
  /**
761
- * 检查是否要过滤某track
762
- * @param track
763
- * @returns
223
+ * 本频道事件的回调式入口,交给 SDK 使用者设置。
224
+ * 与 `channel.on()/once()` 的类型化监听等价,二选一即可;多频道场景下各频道
225
+ * 各自设置,事件天然按频道隔离(`srtc.onNotifyChannelEvent` 只收默认频道的)。
764
226
  */
765
- checkFilter(track: RemoteAudioTrack): boolean;
227
+ onNotifyEvent: ((evt: ChannelEvent) => void) | null;
766
228
  /**
767
- * 添加track
768
- * @param track
229
+ * Channel 由 `srtc.join()` 创建并返回,不允许外部直接 new。
230
+ *
231
+ * 这条重载签名是唯一进 d.ts 的构造签名:protected 挡住外部 new,参数刻意
232
+ * 不透明(真实参数类型都是内部类,写在这里会把它们连同 mqtt/ws 等依赖类型
233
+ * 一起拖进公开声明)。真实签名见下面的实现,SRTC 经各平台 Channel 的
234
+ * 内部静态工厂 create 实例化。
769
235
  */
770
- addTrack(track: RemoteAudioTrack): void;
236
+ protected constructor(...args: unknown[]);
771
237
  /**
772
- * 移除track
773
- * @param track
238
+ * 获取用户信息列表
774
239
  */
775
- removeTrack(track: RemoteAudioTrack): void;
240
+ getUsersInfo(map: boolean): BaseUserInfo[] | Record<string, BaseUserInfo>;
776
241
  /**
777
- * 停止混音
242
+ * 离开频道。SDK 使用者直接 `channel.leave()` 即可(原因默认为主动离开)。
778
243
  */
779
- stop(): void;
780
- }
781
- declare class MqttClient extends EventEmitter {
782
- public connected: boolean;
783
- public disconnecting: boolean;
784
- public disconnected: boolean;
785
- public reconnecting: boolean;
786
- public incomingStore: Store;
787
- public outgoingStore: Store;
788
- public options: IClientOptions;
789
- public queueQoSZero: boolean;
790
- constructor(streamBuilder: (client: MqttClient) => IStream, options: IClientOptions);
791
- public on(event: "connect", cb: OnConnectCallback): this;
792
- public on(event: "message", cb: OnMessageCallback): this;
793
- public on(event: "packetsend" | "packetreceive", cb: OnPacketCallback): this;
794
- public on(event: "disconnect", cb: OnDisconnectCallback): this;
795
- public on(event: "error", cb: OnErrorCallback): this;
796
- public on(event: "close", cb: OnCloseCallback): this;
797
- public on(event: "end" | "reconnect" | "offline" | "outgoingEmpty", cb: () => void): this;
798
- public on(event: string, cb: Function): this;
799
- public once(event: "connect", cb: OnConnectCallback): this;
800
- public once(event: "message", cb: OnMessageCallback): this;
801
- public once(event: "packetsend" | "packetreceive", cb: OnPacketCallback): this;
802
- public once(event: "disconnect", cb: OnDisconnectCallback): this;
803
- public once(event: "error", cb: OnErrorCallback): this;
804
- public once(event: "close", cb: OnCloseCallback): this;
805
- public once(event: "end" | "reconnect" | "offline" | "outgoingEmpty", cb: () => void): this;
806
- public once(event: string, cb: Function): this;
807
- /**
808
- * publish - publish <message> to <topic>
809
- *
810
- * @param {String} topic - topic to publish to
811
- * @param {(String|Buffer)} message - message to publish
812
- *
813
- * @param {Object} [opts] - publish options, includes:
814
- * @param {Number} [opts.qos] - qos level to publish on
815
- * @param {Boolean} [opts.retain] - whether or not to retain the message
816
- * @param {Function}[opts.cbStorePut] - function(){}
817
- * called when message is put into `outgoingStore`
818
- *
819
- * @param {Function} [callback] - function(err){}
820
- * called when publish succeeds or fails
821
- *
822
- * @returns {Client} this - for chaining
823
- * @api public
824
- *
825
- * @example client.publish('topic', 'message')
826
- * @example
827
- * client.publish('topic', 'message', {qos: 1, retain: true})
828
- * @example client.publish('topic', 'message', console.log)
244
+ leave(reason?: DisconnectReason, error?: any): Promise<void>;
245
+ /**
246
+ * 获取对sdk外部展现的频道信息
247
+ * @returns
829
248
  */
830
- public publish(topic: string, message: string | Buffer, opts: IClientPublishOptions, callback?: PacketCallback): this;
831
- public publish(topic: string, message: string | Buffer, callback?: PacketCallback): this;
249
+ getInfo(): BaseChannelInfo;
832
250
  /**
833
- * subscribe - subscribe to <topic>
834
- *
835
- * @param {String, Array, Object} topic - topic(s) to subscribe to, supports objects in the form {'topic': qos}
836
- * @param {Object} [opts] - optional subscription options, includes:
837
- * @param {Number} [opts.qos] - subscribe qos level
838
- * @param {Function} [callback] - function(err, granted){} where:
839
- * {Error} err - subscription error (none at the moment!)
840
- * {Array} granted - array of {topic: 't', qos: 0}
841
- * @returns {MqttClient} this - for chaining
842
- * @api public
843
- * @example client.subscribe('topic')
844
- * @example client.subscribe('topic', {qos: 1})
845
- * @example client.subscribe({'topic': 0, 'topic2': 1}, console.log)
846
- * @example client.subscribe('topic', console.log)
847
- */
848
- public subscribe(topic: string | string[], opts: IClientSubscribeOptions, callback?: ClientSubscribeCallback): this;
849
- public subscribe(topic: string | string[] | ISubscriptionMap, callback?: ClientSubscribeCallback): this;
850
- /**
851
- * unsubscribe - unsubscribe from topic(s)
852
- *
853
- * @param {String, Array} topic - topics to unsubscribe from
854
- * @param {Object} opts - opts of unsubscribe
855
- * @param {Function} [callback] - callback fired on unsuback
856
- * @returns {MqttClient} this - for chaining
857
- * @api public
858
- * @example client.unsubscribe('topic')
859
- * @example client.unsubscribe('topic', console.log)
860
- * @example client.unsubscribe('topic', opts, console.log)
861
- */
862
- public unsubscribe(topic: string | string[], opts?: Object, callback?: PacketCallback): this;
863
- /**
864
- * end - close connection
865
- *
866
- * @returns {MqttClient} this - for chaining
867
- * @param {Boolean} force - do not wait for all in-flight messages to be acked
868
- * @param {Object} opts - opts disconnect
869
- * @param {Function} cb - called when the client has been closed
870
- *
871
- * @api public
251
+ * 获取流媒体引擎供应商
872
252
  */
873
- public end(force?: boolean, opts?: Object, cb?: CloseCallback): this;
253
+ getStreamEngineVendor(): string;
874
254
  /**
875
- * removeOutgoingMessage - remove a message in outgoing store
876
- * the outgoing callback will be called withe Error('Message removed') if the message is removed
255
+ * 取某本地轨在本频道内的轨道描述。
877
256
  *
878
- * @param {Number} mid - messageId to remove message
879
- * @returns {MqttClient} this - for chaining
880
- * @api public
257
+ * 同一条采集轨发布到多个频道时,各频道的描述(服务端分配的 id、归属 uid、联播分层等)
258
+ * 各不相同,`track.getInfo()` 在这种情况下只能回落到采集轨自身描述,用本方法可精确
259
+ * 取到它在本频道的那一份。未在本频道发布则返回 undefined。
881
260
  *
882
- * @example client.removeOutgoingMessage(client.getLastMessageId());
883
261
  */
884
- public removeOutgoingMessage(mid: number): this;
262
+ getPublishInfo(track: BaseLocalTrack): BaseTrackInfo | undefined;
885
263
  /**
886
- * reconnect - connect again using the same options as connect()
887
- *
888
- * @param {Object} [opts] - optional reconnect options, includes:
889
- * {Store} incomingStore - a store for the incoming packets
890
- * {Store} outgoingStore - a store for the outgoing packets
891
- * if opts is not given, current stores are used
892
- *
893
- * @returns {MqttClient} this - for chaining
894
- *
895
- * @api public
264
+ * 发布本地流轨道
265
+ * @param track
266
+ * @param opt 发布参数,不传则用 track 的默认发布参数(由 createLocalXxxTrack 依预设写入)
267
+ * @returns 本次发布在本频道内的轨道描述快照。后续引擎可能回写实际编码参数等,
268
+ * 要拿最新的请用 getPublishInfo(track)。
896
269
  */
897
- public reconnect(opts?: IClientReconnectOptions): this;
270
+ publishLocalTrack(track: BaseLocalTrack, opt?: Partial<AudioPublishOptions> | Partial<VideoPublishOptions>): Promise<BaseTrackInfo>;
898
271
  /**
899
- * Handle messages with backpressure support, one at a time.
900
- * Override at will.
901
- *
902
- * @param packet packet the packet
903
- * @param callback callback call when finished
904
- * @api public
272
+ * 取消发布本地流
273
+ * @param track
905
274
  */
906
- public handleMessage(packet: Packet, callback: PacketCallback): void;
275
+ unpublishLocalTrack(track: BaseLocalTrack): Promise<void>;
907
276
  /**
908
- * Handle auth packages for MQTT 5 enhanced authentication methods such
909
- * as challenge response authentication.
910
- *
911
- * Challenge-response authentication flow would look something like this:
912
- *
913
- * --> CONNECT | authMethod = "mathChallenge" -->
914
- * <-- AUTH | authMethod = "mathChallenge", authData = "12 + 34" <--
915
- * --> AUTH | authMethod = "mathChallenge", authData = "46" -->
916
- * <-- CONNACK | reasonCode = SUCCESS <--
917
- *
918
- * This form of authentication has several advantages over traditional
919
- * credential-based approaches. For instance authentication without the direct
920
- * exchange of authentication secrets.
921
- *
922
- * @param packet the auth packet to handle
923
- * @param callback call when finished
924
- * @api public
277
+ * 获取远端频道混音流
278
+ * @param filter 音频轨道过滤器,传递string[]时,根据uid过滤
925
279
  */
926
- public handleAuth(packet: IAuthPacket, callback: PacketCallback): void;
280
+ subscribeRemoteAudioMixTrack(filter?: ((track: BaseTrack) => boolean) | string[]): Promise<BaseTrack & (IMockRemoteAudioMixTrack | IRemoteAudioMixTrack)>;
927
281
  /**
928
- * getLastMessageId
282
+ * 订阅远端用户音频流
283
+ * @param uid 用户id
284
+ * @param id 流轨道id
929
285
  */
930
- public getLastMessageId(): number;
931
- }
932
- declare class RemoteAudioMcuTrack extends RemoteAudioTrack {
933
- constructor();
934
- }
935
- declare class RemoteVideoMcuTrack extends RemoteVideoTrack {
936
- constructor();
937
- }
938
- declare class SdkError {
939
- /** 错误码 */
940
- code: number;
941
- /** 错误详情 */
942
- msg: string;
943
- /** 获取前缀错误码 */
944
- protected prefixCode(): string;
945
- constructor(msg: string, code?: number);
946
- /**
947
- * 从err转化为sdkError
948
- * @param err 原始error
949
- * @returns
286
+ subscribeRemoteAudioTrack(uid: string, id: string): Promise<BaseTrack>;
287
+ /**
288
+ * 订阅远端视频合成流
950
289
  */
951
- static fromError(err: Error): SdkError;
952
- toString(): string;
953
- toJSON(): {
954
- code: number;
955
- msg: string;
956
- };
957
- }
958
- declare class Store {
290
+ subscribeRemoteVideoMcuTrack(): Promise<BaseTrack>;
959
291
  /**
960
- * Store constructor
292
+ * 订阅服务端统一合成的混音(program,含所有人,所有订阅者收到的一致)。
293
+ * 给不发声的观众/录制/旁路用,与 subscribeRemoteVideoMcuTrack 对应;不做 vendor 降级。
961
294
  *
962
- * @param {Object} [options] - store options
295
+ * 该流含全场(包括你自己):会发声的参与者订它会听到自己的回声——
296
+ * 参与者请改用 subscribeRemoteAudioMixTrack(本地 mix-minus,除自己)。
297
+ */
298
+ subscribeRemoteAudioMcuTrack(): Promise<BaseTrack>;
299
+ /**
300
+ * 订阅远端用户视频流
301
+ * @param uid 用户id
302
+ * @param id 流轨道id
303
+ */
304
+ subscribeRemoteVideoTrack(uid: string, id: string): Promise<BaseTrack>;
305
+ /**
306
+ * 取消订阅远端流
307
+ * @param track 流轨道
308
+ * @param debounceWaitMs 防取消订阅/订阅抖动ms数
963
309
  */
964
- constructor(options: IStoreOptions);
310
+ unsubscribeRemoteTrack(track: BaseTrack, debounceWaitMs?: number): Promise<void>;
311
+ }
312
+ export declare abstract class BaseTrack extends EventEmitter {
313
+ constructor(info: BaseTrackInfo, uid: string);
965
314
  /**
966
- * Adds a packet to the store, a packet is
967
- * anything that has a messageId property.
315
+ * 轨道id
968
316
  *
317
+ * 本地轨发布后,id 可能被改写为服务端分配值——那属于「一次发布」,由本地轨基类
318
+ * override 代理到发布记录(见 BaseLocalTrack);远端轨直读自身描述。
969
319
  */
970
- public put(packet: any, cb?: Function): this;
320
+ get id(): string;
971
321
  /**
972
- * Creates a stream with all the packets in the store
973
- *
322
+ * 轨道类型
974
323
  */
975
- public createStream(): any;
324
+ get kind(): TrackKind;
976
325
  /**
977
- * deletes a packet from the store.
326
+ * 轨道描述
978
327
  */
979
- public del(packet: any, cb: Function): this;
328
+ get desc(): string;
980
329
  /**
981
- * get a packet from the store.
330
+ * 是否为 simulcast 副层
982
331
  */
983
- public get(packet: any, cb: Function): this;
332
+ get variant(): boolean | undefined;
984
333
  /**
985
- * Close the store
334
+ * 视频角度(视频轨才有,手机端旋转时变化)。
335
+ * 渲染路径用本 getter 而非 getInfo().angle——本地轨 getInfo 在多频道发布时会抛错,
336
+ * 字段糖则始终可用。
986
337
  */
987
- public close(cb: Function): void;
988
- }
989
- declare class TrackEventType extends CommonTrackEventType {
990
- /** 轨道自动播放失败,对应data为BaseTrack */
991
- static readonly AUTOPLAY_FAIL = "autoplay_fail";
992
- /** mediastreamtrack轨道被替换,对应data为BaseTrack,oldMsTrack为旧的MediaStreamTrack */
993
- static readonly MSTRACK_REPLACED = "mstrack_replaced";
994
- /** 轨道流媒体开始断线自动重连,对应data为BaseTrack*/
995
- static readonly RECONNECTING = "reconnecting";
996
- /** 轨道流媒体重连成功,对应data为BaseTrack */
997
- static readonly RECONNECTED = "reconnected";
998
- /** 进入画中画模式,对应data为BaseTrack */
999
- static readonly PIP_ENTER = "pip_enter";
1000
- /** 退出画中画模式,对应data为BaseTrack */
1001
- static readonly PIP_EXIT = "pip_exit";
1002
- /** 弹出独立窗口,对应data为BaseTrack */
1003
- static readonly POPOUT_OPEN = "popout_open";
1004
- /** 关闭独立窗口,对应data为BaseTrack */
1005
- static readonly POPOUT_CLOSE = "popout_close";
1006
- }
1007
- declare class UserContainer implements Iterable<[
1008
- string,
1009
- BaseUser
1010
- ]> {
1011
- /** uid为key的user Map */
1012
- private ctn;
1013
- /** linkid为key,与uid的映射 */
1014
- private linkids;
338
+ get angle(): number;
1015
339
  /**
1016
- * 实现Iterator接口,支持for...of迭代
1017
- * @returns 返回迭代器,每次迭代返回[uid, user]键值对
340
+ * 获取流轨道信息
341
+ *
342
+ * 远端轨直接返回自身描述的**拷贝**。本地轨由基类 override 代理到发布记录:
343
+ * 单发布时与「info 记在 track 上」时代完全一致;发布到多个频道时**抛错**,
344
+ * 请改用 channel.getPublishInfo(track)(见 BaseLocalTrack / TrackPublishState)。
345
+ * @returns
1018
346
  */
1019
- [Symbol.iterator](): Iterator<[
1020
- string,
1021
- BaseUser
1022
- ]>;
347
+ getInfo(): BaseTrackInfo;
1023
348
  /**
1024
- * 添加或覆盖某user
1025
- * @param uid
1026
- * @param user
349
+ * 轨道所属用户
350
+ *
351
+ * 远端轨道在 new 时就由所属 user 传入 uid(见各端 user.ts 的 newTrack),直读即可。
352
+ * 本地轨道的归属 uid 是「一次发布」的属性(同一条采集发布到不同频道可以是不同 uid),
353
+ * 记在发布记录里,由本地轨基类 override 做单发布代理(见 BaseLocalTrack)。
354
+ * @returns
1027
355
  */
1028
- set(uid: string, user: BaseUser): void;
356
+ getUid(): string;
357
+ toString(): string;
358
+ }
359
+ export declare class Channel extends BaseChannel {
1029
360
  /**
1030
- * 获取某user
1031
- * @param uid
1032
- * @returns
361
+ * 获取流媒体引擎的metric快照(全量,包含每条轨道的统计)
1033
362
  */
1034
- get(uid: string): BaseUser;
363
+ getStreamMetric(): StreamMetric | undefined;
1035
364
  /**
1036
- * 根据linkid获取某user
1037
- * @param linkid
1038
- * @returns
365
+ * 获取当前网络总体统计,轻量接口,只关心网络整体指标时使用
1039
366
  */
1040
- getByLinkid(linkid: string): BaseUser;
367
+ getNetworkStats(): NetworkStats | undefined;
1041
368
  /**
1042
- * 删除某account
1043
- * @param uid
369
+ * 获取当前连接质量评估结果(等级、MOS、原因等)
1044
370
  */
1045
- del(uid: string): void;
371
+ getConnectionQuality(): QualityEvaluation | undefined;
1046
372
  /**
1047
- * 清空
373
+ * override:webrtc 端的发布编排收口在这里,SRTC 门面只做纯委托。
374
+ * - 共享屏幕音频轨随屏幕轨一起发布;
375
+ * - ook/wangsu 的联播副轨需先各自完整发布,主轨建记录时从副轨记录反查
376
+ * variant/fallback_ids(见 createPublishRecords);seastart 走 webrtc 原生
377
+ * rid simulcast,副轨不单独推流,fallback_ids 由引擎发布后回写。
1048
378
  */
1049
- clear(): void;
379
+ publishLocalTrack(track: BaseLocalTrack, opt?: Partial<AudioPublishOptions> | Partial<VideoPublishOptions>): Promise<BaseTrackInfo>;
1050
380
  /**
1051
- * 获取成员对外信息列表
1052
- * @returns
381
+ * override:与 publishLocalTrack 对称,收尾共享屏幕音频轨与联播副轨。
1053
382
  */
1054
- listInfo(map: boolean): BaseUserInfo[] | Record<string, BaseUserInfo>;
1055
- }
1056
- declare enum ChannelConnectState {
1057
- /** 初始状态 */
1058
- INIT = "init",
1059
- /** 已连接 */
1060
- CONNECTED = "connected",
1061
- /** 重连中 */
1062
- RECONNECTING = "reconnecting",
1063
- /** 已离会 */
1064
- LEAVED = "leaved"
1065
- }
1066
- declare function dateFormat(format: string, date?: Date): string;
1067
- declare function dct(t: string): any;
1068
- declare function genNonce(len?: number): string;
1069
- declare function getHostnameFromUrl(url: string): string;
1070
- declare function isObject(value: any): boolean;
1071
- declare function isString(value: any): boolean;
1072
- declare function isWxxcx(): boolean;
1073
- declare function propAssign<T>(target: T, income: T, assigner?: Record<keyof T, (value: any, old: any) => void>): PropChangeItem<keyof T>[];
1074
- declare function retry<T>(f: () => Promise<T>, opt: {
1075
- /** 首次执行失败后的最大重试次数,默认10次,<=0代表不限制次数 */
1076
- maxRetries?: number;
1077
- /** 第一次重试间隔(ms),默认500ms,之后会以 initialDelay * 2^n 进行重试 */
1078
- initialDelay?: number;
1079
- /** 每次重试前的回调,e为上次失败catch到的错误,返回false则代表放弃重试,会返回canceled */
1080
- onRetry?: (attempt: number, e?: any) => boolean | void;
1081
- }): retryCallback<T>;
1082
- 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
+ }
1083
387
  /** 扩展的频道事件 */
1084
388
  export declare class ChannelEventType extends CommonChannelEventType {
1085
389
  /** 外设插入,对应data为MediaDeviceInfo */
@@ -1114,7 +418,7 @@ export declare class ChannelEventType extends CommonChannelEventType {
1114
418
  /**
1115
419
  * 本地音频流轨道
1116
420
  */
1117
- export declare class LocalAudioTrack extends BaseWebrtcTrack {
421
+ export declare class LocalAudioTrack extends BaseWebrtcLocalTrack {
1118
422
  constructor();
1119
423
  /**
1120
424
  * 挂载音频处理器(如 RNN 降噪、变声)。传入数组时按顺序串联。
@@ -1192,28 +496,6 @@ export declare class LocalCameraTrack extends LocalVideoTrack {
1192
496
  * 调用方需要把当前要录制的视频 track、音频 track 以及每个视频在画布上的位置传进来。
1193
497
  */
1194
498
  export declare class LocalCompositeRecorder {
1195
- private canvas?;
1196
- private canvasContext?;
1197
- private canvasStream?;
1198
- private recordStream?;
1199
- private mediaRecorder?;
1200
- private audioContext?;
1201
- private audioDestination?;
1202
- private audioSources;
1203
- private audioInputTracks;
1204
- private trackedTrackListeners;
1205
- private videoElements;
1206
- private avatarImages;
1207
- private avatarFailedUrls;
1208
- private chunks;
1209
- private videoItems;
1210
- private width;
1211
- private height;
1212
- private fps;
1213
- private background;
1214
- private labelBackground;
1215
- private animationFrameId;
1216
- private onDataAvailable?;
1217
499
  /**
1218
500
  * 获取当前录制状态。
1219
501
  *
@@ -1264,103 +546,6 @@ export declare class LocalCompositeRecorder {
1264
546
  * 适用于页面卸载或调用方不再需要输出 Blob 的异常清理场景。
1265
547
  */
1266
548
  destroy(): void;
1267
- /**
1268
- * 初始化混音管线。
1269
- *
1270
- * 通过 MediaStreamAudioDestinationNode 生成一条稳定的输出音频轨,供 MediaRecorder 持有。
1271
- */
1272
- private initAudio;
1273
- /**
1274
- * 重新连接输入音频轨道。
1275
- *
1276
- * 只替换 Web Audio 的 source 节点,不替换 destination 输出轨,保证录制过程不中断。
1277
- */
1278
- private setAudioTracks;
1279
- /**
1280
- * 断开并清空所有输入音频 source。
1281
- */
1282
- private clearAudioSources;
1283
- /**
1284
- * 从原生 MediaStreamTrack 或 SDK Track 中取出当前实际媒体轨。
1285
- */
1286
- private resolveMediaStreamTrack;
1287
- /**
1288
- * 读取 SDK Track 的视频旋转角度(FourCC)。
1289
- *
1290
- * 原生 MediaStreamTrack 不携带旋转信息,按未旋转(ANGLE_UP)处理。
1291
- * 用于让录制 canvas 与正常播放路径(CSS transform)的旋转表现保持一致。
1292
- */
1293
- private resolveTrackAngle;
1294
- /**
1295
- * 判断是否为可监听 MSTRACK_REPLACED 的 SDK Track。
1296
- */
1297
- private isTrackLike;
1298
- /**
1299
- * 同步 SDK Track 的替换监听。
1300
- *
1301
- * 调用方传 SDK Track 时,录制器会监听 MSTRACK_REPLACED,自动把隐藏 video 或混音 source 切到新轨。
1302
- */
1303
- private syncTrackedTrackListeners;
1304
- /**
1305
- * 解绑所有 SDK Track 替换监听。
1306
- */
1307
- private clearTrackedTrackListeners;
1308
- /**
1309
- * 同步视频解码元素。
1310
- *
1311
- * 每个视频 track 都需要一个隐藏 HTMLVideoElement 作为 canvas.drawImage 的帧来源。
1312
- * 这里以底层 MediaStreamTrack「对象引用」为 key 做复用:同一个 track 即使被多个槽位
1313
- * 引用(例如大小窗布局下同一成员同时出现在大窗和小窗),也只创建一个解码 video 共享。
1314
- * 否则同一个远端 track 被多个独立 video 同时播放会产生竞态,偶发其中一个 video
1315
- * 取不到帧(videoWidth=0)导致对应槽位黑屏。
1316
- *
1317
- * 注意:不能用 track.id 字符串做 key——远端 track 的 id 全局不保证唯一,
1318
- * 不同用户可能碰撞,会导致多个槽位错误共享同一路画面(“都变成同一个人”)。
1319
- */
1320
- private syncVideoElements;
1321
- /**
1322
- * 同步头像图片。
1323
- *
1324
- * 为当前 videoItems 中带 avatar 的槽位预加载头像图片,供摄像头关闭时在格子中央绘制圆形头像。
1325
- * 采用匿名跨域(crossOrigin='anonymous'):若头像 CDN 未返回 CORS 头,浏览器会触发 onerror
1326
- * 而非污染 canvas——被污染的 canvas 会导致 captureStream 整条录制流失效。加载失败的 URL 记入
1327
- * avatarFailedUrls,绘制时回退为「昵称首字母彩色圆」。
1328
- */
1329
- private syncAvatarImages;
1330
- /**
1331
- * 渲染循环。
1332
- *
1333
- * 每帧按最新 videoItems 重绘整张画布,canvas.captureStream 会把这些帧输出给 MediaRecorder。
1334
- */
1335
- private render;
1336
- /**
1337
- * 绘制单个视频槽位。
1338
- *
1339
- * contain 会完整显示视频,cover 会填满槽位并裁剪溢出区域。
1340
- * 移动端竖屏采集的视频携带旋转角度,这里会按角度对 canvas 做等价旋转/镜像,
1341
- * 与正常播放路径(PlayView.freshTransform 的 CSS transform)保持一致,避免录像横屏。
1342
- */
1343
- private drawVideo;
1344
- /**
1345
- * 绘制视频标签。
1346
- */
1347
- private drawLabel;
1348
- /**
1349
- * 在格子中央绘制圆形头像占位。
1350
- *
1351
- * 优先使用已加载成功的头像图片(cover 裁剪成圆);头像 URL 缺失、加载失败或跨域被拒时,
1352
- * 回退为「昵称首字母彩色圆」,底色由 id/label 稳定哈希得到,保证同一用户颜色固定。
1353
- */
1354
- private drawAvatarPlaceholder;
1355
- /**
1356
- * 取昵称首字符作为首字母头像文本;空昵称回退为 '?'。
1357
- * 用 Array.from 以正确处理 emoji / 代理对,拉丁字母转大写。
1358
- */
1359
- private avatarInitial;
1360
- /**
1361
- * 释放内部资源并重置状态。
1362
- */
1363
- private cleanup;
1364
549
  }
1365
550
  /**
1366
551
  * 本地麦克风流轨道
@@ -1415,7 +600,7 @@ export declare class LocalScreenTrack extends LocalVideoTrack {
1415
600
  /**
1416
601
  * 本地视频流轨道
1417
602
  */
1418
- export declare class LocalVideoTrack extends BaseWebrtcTrack {
603
+ export declare class LocalVideoTrack extends BaseWebrtcLocalTrack {
1419
604
  constructor();
1420
605
  /**
1421
606
  * 挂载视频处理器(如美颜、虚化背景)。传入数组时按顺序串联。
@@ -1493,9 +678,6 @@ export declare class LocalVideoTrack extends BaseWebrtcTrack {
1493
678
  export declare class ProcessorPipeline implements TrackProcessor {
1494
679
  readonly name: string;
1495
680
  processedTrack?: MediaStreamTrack;
1496
- private processors;
1497
- /** 仅当本组合器自建共享上下文时持有,destroy 时负责关闭 */
1498
- private ownedAudioContext?;
1499
681
  constructor(processors: TrackProcessor[]);
1500
682
  init(options: ProcessorOptions): Promise<void>;
1501
683
  destroy(): Promise<void>;
@@ -1505,6 +687,7 @@ export declare class ProcessorPipeline implements TrackProcessor {
1505
687
  * 参与者视角,服务端 mix-minus,排除自己以外
1506
688
  */
1507
689
  export declare class RemoteAudioMixTrack extends RemoteAudioTrack implements IRemoteAudioMixTrack {
690
+ readonly __type: "RemoteAudioMixTrack";
1508
691
  constructor(info: BaseTrackInfo, filterUids?: string[]);
1509
692
  /**
1510
693
  * 混音流中过滤的uid
@@ -1534,10 +717,6 @@ export declare class RemoteAudioTrack extends BaseWebrtcTrack {
1534
717
  * 远端视频流轨道
1535
718
  */
1536
719
  export declare class RemoteVideoTrack extends BaseWebrtcTrack {
1537
- /**
1538
- * 业务期望的抖动缓冲目标延迟(ms)。undefined 表示使用浏览器默认自适应策略。
1539
- */
1540
- private jitterBufferTargetMs?;
1541
720
  constructor(info: BaseTrackInfo, uid: string);
1542
721
  /**
1543
722
  * 添加播放窗口
@@ -1600,16 +779,8 @@ export declare class RemoteVideoTrack extends BaseWebrtcTrack {
1600
779
  * 获取业务当前设定的抖动缓冲目标延迟(ms);undefined 表示未设置。
1601
780
  */
1602
781
  getJitterBufferTarget(): number | undefined;
1603
- /**
1604
- * 同时写 jitterBufferTarget(W3C 标准,Chrome 113+)和 playoutDelayHint
1605
- * (Chrome 私有扩展,Chrome 70+),让新老浏览器都能生效。
1606
- * 浏览器只支持其中一个时另一个不存在,'in' 判断后静默跳过。
1607
- */
1608
- private applyJitterBufferTarget;
1609
782
  }
1610
783
  export declare class SRTC extends BaseSRTC {
1611
- /** 窄化父类的 channel 类型到 webrtc Channel,便于访问 webrtc 特有方法 */
1612
- protected channel?: Channel | null;
1613
784
  /**
1614
785
  * 获取流媒体引擎的metric快照(全量,含每条轨道的统计)
1615
786
  */
@@ -1637,6 +808,11 @@ export declare class SRTC extends BaseSRTC {
1637
808
  */
1638
809
  createLocalCompositeRecorder(): LocalCompositeRecorder;
1639
810
  constructor(initParams: SdkInitParams);
811
+ /**
812
+ * 加入频道,返回该频道的 Channel 对象(见 BaseSRTC.join 说明)。
813
+ * web 端可多次 join 同时加入多个频道。
814
+ */
815
+ join(token: string, options?: JoinOptions): Promise<Channel>;
1640
816
  /**
1641
817
  * 获取设备列表
1642
818
  * @param kind
@@ -1678,13 +854,14 @@ export declare class SRTC extends BaseSRTC {
1678
854
  */
1679
855
  disableLocalTrack(track: LocalAudioTrack | LocalVideoTrack): void;
1680
856
  /**
1681
- * 发布本地流轨道
857
+ * 发布本地流轨道(委托默认频道;发布编排——预设合并/屏幕音频/联播副轨——收口在 Channel)
1682
858
  * @param track
1683
- * @returns
859
+ * @param opt 发布参数,不传则用 track 的默认发布参数(由 createLocalXxxTrack 依预设写入)
860
+ * @returns 本次发布在本频道内的轨道描述快照,后续引擎回写的最新值请用 srtc.getPublishInfo(track)
1684
861
  */
1685
- publishLocalTrack(track: LocalAudioTrack | LocalVideoTrack, opt?: Partial<AudioPublishOptions> | Partial<VideoPublishOptions>): Promise<void>;
862
+ publishLocalTrack(track: LocalAudioTrack | LocalVideoTrack, opt?: Partial<AudioPublishOptions> | Partial<VideoPublishOptions>): Promise<BaseTrackInfo>;
1686
863
  /**
1687
- * 取消发布本地流
864
+ * 取消发布本地流(委托默认频道)
1688
865
  * @param track
1689
866
  */
1690
867
  unpublishLocalTrack(track: LocalAudioTrack | LocalVideoTrack): Promise<void>;
@@ -1893,67 +1070,6 @@ export declare function codec2str(codec: Codec): string;
1893
1070
  * 创建混音后的音频轨
1894
1071
  */
1895
1072
  export declare function createMixedAudioMediaStreamTrack(canvasContext?: CanvasRenderingContext2D): MixedAudioMediaStreamTrack;
1896
- /**
1897
- * MessageIdProvider
1898
- */
1899
- export declare interface IMessageIdProvider {
1900
- /**
1901
- * Allocate the first vacant messageId. The messageId become occupied status.
1902
- * @return {Number} - The first vacant messageId. If all messageIds are occupied, return null.
1903
- */
1904
- allocate(): Number | null;
1905
- /**
1906
- * Get the last allocated messageId.
1907
- * @return {Number} - messageId.
1908
- */
1909
- getLastAllocated(): Number | null;
1910
- /**
1911
- * Register the messageId. The messageId become occupied status.
1912
- * If the messageId has already been occupied, then return false.
1913
- * @param {Number} num - The messageId to request use.
1914
- * @return {Boolean} - If `num` was not occupied, then return true, otherwise return false.
1915
- */
1916
- register(num: Number): Boolean;
1917
- /**
1918
- * Deallocate the messageId. The messageId become vacant status.
1919
- * @param {Number} num - The messageId to deallocate. The messageId must be occupied status.
1920
- * In other words, the messageId must be allocated by allocate() or
1921
- * occupied by register().
1922
- */
1923
- deallocate(num: Number): void;
1924
- /**
1925
- * Clear all occupied messageIds.
1926
- * The all messageIds are set to vacant status.
1927
- */
1928
- clear(): void;
1929
- }
1930
- export declare namespace __INNER__ {
1931
- const BaseSRTC_I: typeof BaseSRTC;
1932
- const CommonChannelEventType_I: typeof CommonChannelEventType;
1933
- const isWxxcx_I: typeof isWxxcx;
1934
- const Logger_I: typeof Logger;
1935
- const SdkError_I: typeof SdkError;
1936
- const propAssign_I: typeof propAssign;
1937
- const isObject_I: typeof isObject;
1938
- const isString_I: typeof isString;
1939
- const sleep_I: typeof sleep;
1940
- const retry_I: typeof retry;
1941
- const dateFormat_I: typeof dateFormat;
1942
- const genNonce_I: typeof genNonce;
1943
- const getHostnameFromUrl_I: typeof getHostnameFromUrl;
1944
- const dct_I: typeof dct;
1945
- function hmac_I(msg: string, key: string): string;
1946
- }
1947
- export declare type ClientSubscribeCallback = (err: Error, granted: ISubscriptionGrant[]) => void;
1948
- export declare type CloseCallback = (error?: Error) => void;
1949
- export declare type OnCloseCallback = () => void;
1950
- export declare type OnConnectCallback = (packet: IConnackPacket) => void;
1951
- export declare type OnDisconnectCallback = (packet: IDisconnectPacket) => void;
1952
- export declare type OnErrorCallback = (error: Error) => void;
1953
- export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: IPublishPacket) => void;
1954
- export declare type OnPacketCallback = (packet: Packet) => void;
1955
- export declare type PacketCallback = (error?: Error, packet?: Packet) => any;
1956
- export declare type StorePutCallback = () => void;
1957
1073
  /**
1958
1074
  * Active speaker(说话中的用户)相关类型 / 事件枚举。
1959
1075
  *
@@ -2086,18 +1202,14 @@ export interface AudioSenderStats extends SenderStats {
2086
1202
  /** 音频电平 */
2087
1203
  audioLevel?: number;
2088
1204
  }
2089
- /** 重连时刷新auth */
2090
- export interface AuthReconnect {
2091
- (url: string, options: IClientOptions, client: MqttClient): string;
2092
- }
2093
1205
  /**
2094
- * 频道基类
1206
+ * 频道的类型化事件重载。
2095
1207
  *
2096
1208
  * 事件类型通过 `ChannelEventDataMap` 与 data 类型强关联,
2097
1209
  * 子类如 webrtc / wx 通过 `declare module '../base/event'` 合并扩展事件。
2098
- * 下面这段 interface 声明不是另起炉灶,而是用 TS declaration merging 在 EventEmitter
1210
+ * 这段 interface 不是另起炉灶,而是用 TS declaration merging 在 EventEmitter
2099
1211
  * 的 `on/once/off/addListener/removeListener/emit` 上加强类型化重载;保留父类宽松签名
2100
- * 作为兜底,不影响内部既有 `this.rtcSocket.on(SocketEvent.XXX)` 等用法。
1212
+ * 作为兜底,不影响内部既有 `this.rtcSocket.on(SocketEvent.XXX)` 等用法(与 BaseTrack 同法)。
2101
1213
  */
2102
1214
  export interface BaseChannel {
2103
1215
  on<K extends keyof ChannelEventDataMap>(type: K, listener: (event: ChannelEventOf<K>) => void): this;
@@ -2107,6 +1219,19 @@ export interface BaseChannel {
2107
1219
  removeListener<K extends keyof ChannelEventDataMap>(type: K, listener: (event: ChannelEventOf<K>) => void): this;
2108
1220
  emit<K extends keyof ChannelEventDataMap>(type: K, event: ChannelEventOf<K>): boolean;
2109
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
+ }
2110
1235
  /**
2111
1236
  * 流轨道
2112
1237
  *
@@ -2130,15 +1255,6 @@ export interface BaseTrack {
2130
1255
  listeners<K extends keyof TrackEventDataMap>(type: K): ((data: TrackEventDataMap[K]) => void)[];
2131
1256
  listeners(type: string | symbol): Function[];
2132
1257
  }
2133
- /**
2134
- * track临时扩展,方便统一管理
2135
- */
2136
- export interface BaseTrackEx {
2137
- kind: TrackKind;
2138
- track: BaseTrack;
2139
- opt?: AudioPublishOptions | VideoPublishOptions;
2140
- exopt: Record<string, any>;
2141
- }
2142
1258
  /**
2143
1259
  * sdk编译信息
2144
1260
  */
@@ -2231,32 +1347,6 @@ export interface ChannelEventDataMap {
2231
1347
  [CommonChannelEventType.TRACK_UNMUTED]: BaseTrack;
2232
1348
  [CommonChannelEventType.TRACK_ENDED]: BaseTrack;
2233
1349
  }
2234
- /**
2235
- * 加入频道api返回
2236
- */
2237
- export interface ChannelJoinRsp extends ReconnectRsp {
2238
- /** 应用ID */
2239
- app_id: string;
2240
- /** 用户ID */
2241
- uid: string;
2242
- /** 会话ID */
2243
- sid: string;
2244
- /** 频道名 */
2245
- channel: string;
2246
- /** 网络 */
2247
- net: string;
2248
- /** 流媒体服务方 */
2249
- stream_vendor: string;
2250
- /** 频道流媒体连接id */
2251
- channel_link_id: string;
2252
- /** 用户流媒体连接id */
2253
- link_id: number;
2254
- /** 用户流媒体授权key */
2255
- session_key: string;
2256
- device_type: DeviceType;
2257
- device_id: string;
2258
- version: string;
2259
- }
2260
1350
  /**
2261
1351
  * 连接质量变化事件 data
2262
1352
  */
@@ -2293,7 +1383,7 @@ export interface DisconnectEventData {
2293
1383
  /**
2294
1384
  * web环境详情
2295
1385
  */
2296
- export interface EnvWebInfo extends Bowser$1.Parser.ParsedResult {
1386
+ export interface EnvWebInfo extends ParsedBrowserInfo {
2297
1387
  /**
2298
1388
  * 是否支持webrtc
2299
1389
  */
@@ -2375,181 +1465,6 @@ export interface EnvWebInfo extends Bowser$1.Parser.ParsedResult {
2375
1465
  */
2376
1466
  devicePixelRatio: number;
2377
1467
  }
2378
- export interface IClientOptions extends ISecureClientOptions {
2379
- port?: number; // port is made into a number subsequently
2380
- host?: string; // host does NOT include port
2381
- hostname?: string;
2382
- path?: string;
2383
- protocol?: "wss" | "ws" | "mqtt" | "mqtts" | "tcp" | "ssl" | "wx" | "wxs";
2384
- wsOptions?: ClientOptions | ClientRequestArgs;
2385
- /**
2386
- * 10 seconds, set to 0 to disable
2387
- */
2388
- keepalive?: number;
2389
- /**
2390
- * 'mqttjs_' + Math.random().toString(16).substr(2, 8)
2391
- */
2392
- clientId?: string;
2393
- /**
2394
- * 'MQTT'
2395
- */
2396
- protocolId?: string;
2397
- /**
2398
- * 4
2399
- */
2400
- protocolVersion?: number;
2401
- /**
2402
- * true, set to false to receive QoS 1 and 2 messages while offline
2403
- */
2404
- clean?: boolean;
2405
- /**
2406
- * 1000 milliseconds, interval between two reconnections
2407
- */
2408
- reconnectPeriod?: number;
2409
- /**
2410
- * 30 * 1000 milliseconds, time to wait before a CONNACK is received
2411
- */
2412
- connectTimeout?: number;
2413
- /**
2414
- * the username required by your broker, if any
2415
- */
2416
- username?: string;
2417
- /**
2418
- * the password required by your broker, if any
2419
- */
2420
- password?: string;
2421
- /**
2422
- * a Store for the incoming packets
2423
- */
2424
- incomingStore?: Store;
2425
- /**
2426
- * a Store for the outgoing packets
2427
- */
2428
- outgoingStore?: Store;
2429
- queueQoSZero?: boolean;
2430
- reschedulePings?: boolean;
2431
- servers?: Array<{
2432
- host: string;
2433
- port: number;
2434
- protocol?: "wss" | "ws" | "mqtt" | "mqtts" | "tcp" | "ssl" | "wx" | "wxs";
2435
- }>;
2436
- /**
2437
- * true, set to false to disable re-subscribe functionality
2438
- */
2439
- resubscribe?: boolean;
2440
- /**
2441
- * a message that will sent by the broker automatically when the client disconnect badly.
2442
- */
2443
- will?: {
2444
- /**
2445
- * the topic to publish
2446
- */
2447
- topic: string;
2448
- /**
2449
- * the message to publish
2450
- */
2451
- payload: Buffer | string;
2452
- /**
2453
- * the QoS
2454
- */
2455
- qos: QoS;
2456
- /**
2457
- * the retain flag
2458
- */
2459
- retain: boolean;
2460
- /*
2461
- * properies object of will
2462
- * */
2463
- properties?: {
2464
- willDelayInterval?: number;
2465
- payloadFormatIndicator?: boolean;
2466
- messageExpiryInterval?: number;
2467
- contentType?: string;
2468
- responseTopic?: string;
2469
- correlationData?: Buffer;
2470
- userProperties?: UserProperties;
2471
- };
2472
- };
2473
- transformWsUrl?: (url: string, options: IClientOptions, client: MqttClient) => string;
2474
- properties?: {
2475
- sessionExpiryInterval?: number;
2476
- receiveMaximum?: number;
2477
- maximumPacketSize?: number;
2478
- topicAliasMaximum?: number;
2479
- requestResponseInformation?: boolean;
2480
- requestProblemInformation?: boolean;
2481
- userProperties?: UserProperties;
2482
- authenticationMethod?: string;
2483
- authenticationData?: Buffer;
2484
- };
2485
- messageIdProvider?: IMessageIdProvider;
2486
- }
2487
- export interface IClientPublishOptions {
2488
- /**
2489
- * the QoS
2490
- */
2491
- qos?: QoS;
2492
- /**
2493
- * the retain flag
2494
- */
2495
- retain?: boolean;
2496
- /**
2497
- * whether or not mark a message as duplicate
2498
- */
2499
- dup?: boolean;
2500
- /*
2501
- * MQTT 5.0 properties object
2502
- */
2503
- properties?: {
2504
- payloadFormatIndicator?: boolean;
2505
- messageExpiryInterval?: number;
2506
- topicAlias?: number;
2507
- responseTopic?: string;
2508
- correlationData?: Buffer;
2509
- userProperties?: UserProperties;
2510
- subscriptionIdentifier?: number;
2511
- contentType?: string;
2512
- };
2513
- /**
2514
- * callback called when message is put into `outgoingStore`
2515
- */
2516
- cbStorePut?: StorePutCallback;
2517
- }
2518
- export interface IClientReconnectOptions {
2519
- /**
2520
- * a Store for the incoming packets
2521
- */
2522
- incomingStore?: Store;
2523
- /**
2524
- * a Store for the outgoing packets
2525
- */
2526
- outgoingStore?: Store;
2527
- }
2528
- export interface IClientSubscribeOptions {
2529
- /**
2530
- * the QoS
2531
- */
2532
- qos: QoS;
2533
- /*
2534
- * no local flag
2535
- * */
2536
- nl?: boolean;
2537
- /*
2538
- * Retain As Published flag
2539
- * */
2540
- rap?: boolean;
2541
- /*
2542
- * Retain Handling option
2543
- * */
2544
- rh?: number;
2545
- /*
2546
- * MQTT 5.0 properies object of subscribe
2547
- * */
2548
- properties?: {
2549
- subscriptionIdentifier?: number;
2550
- userProperties?: UserProperties;
2551
- };
2552
- }
2553
1468
  /** 本地模拟远端混音流轨接口 */
2554
1469
  export interface IMockRemoteAudioMixTrack {
2555
1470
  readonly __type: "MockRemoteAudioMixTrack";
@@ -2580,76 +1495,6 @@ export interface IRemoteAudioMixTrack {
2580
1495
  */
2581
1496
  getFilterUids(): string[];
2582
1497
  }
2583
- export interface ISecureClientOptions {
2584
- /**
2585
- * optional private keys in PEM format
2586
- */
2587
- key?: string | string[] | Buffer | Buffer[] | Object[];
2588
- /**
2589
- * optional cert chains in PEM format
2590
- */
2591
- cert?: string | string[] | Buffer | Buffer[];
2592
- /**
2593
- * Optionally override the trusted CA certificates in PEM format
2594
- */
2595
- ca?: string | string[] | Buffer | Buffer[];
2596
- rejectUnauthorized?: boolean;
2597
- /**
2598
- * optional alpn's
2599
- */
2600
- ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
2601
- }
2602
- export interface IStoreOptions {
2603
- /**
2604
- * true, clear _inflights at close
2605
- */
2606
- clean?: boolean;
2607
- }
2608
- export interface IStream extends EventEmitter {
2609
- pipe(to: any): any;
2610
- destroy(): any;
2611
- end(): any;
2612
- }
2613
- export interface ISubscriptionGrant {
2614
- /**
2615
- * is a subscribed to topic
2616
- */
2617
- topic: string;
2618
- /**
2619
- * is the granted qos level on it, may return 128 on error
2620
- */
2621
- qos: QoS | number;
2622
- /*
2623
- * no local flag
2624
- * */
2625
- nl?: boolean;
2626
- /*
2627
- * Retain As Published flag
2628
- * */
2629
- rap?: boolean;
2630
- /*
2631
- * Retain Handling option
2632
- * */
2633
- rh?: number;
2634
- }
2635
- export interface ISubscriptionMap {
2636
- /**
2637
- * object which has topic names as object keys and as value the options, like {'test1': {qos: 0}, 'test2': {qos: 2}}.
2638
- */
2639
- [topic: string]: {
2640
- qos: QoS;
2641
- nl?: boolean;
2642
- rap?: boolean;
2643
- rh?: number;
2644
- };
2645
- }
2646
- /**
2647
- * im频道外消息连接/重连api返回
2648
- */
2649
- export interface ImConnectRsp {
2650
- /** mqtt信息 */
2651
- mqtt: MqttServer;
2652
- }
2653
1498
  /** im强制断开事件data */
2654
1499
  export interface ImDisconnectEventData {
2655
1500
  /** 断开原因 */
@@ -2820,29 +1665,6 @@ export interface MixedAudioMediaStreamTrack extends MediaStreamTrack {
2820
1665
  removeTrack(track: MediaStreamTrack): void;
2821
1666
  trackCount: number;
2822
1667
  }
2823
- /**
2824
- * MQTT 服务器配置
2825
- */
2826
- export interface MqttServer {
2827
- /** MQTT 服务名称 */
2828
- name: string;
2829
- /** mqtt 客户端连接通过 jwt 验证授权,username 用 uid,clientid 用 sid */
2830
- /** https://www.emqx.io/docs/zh/latest/access-control/authn/jwt.html */
2831
- /** jwt 里加上权限控制,仅允许订阅特定 topic(不允许发送) */
2832
- jwt_token: string;
2833
- /** jwt token过期时间 */
2834
- token_exp_at: number;
2835
- /** tcp 连接地址 */
2836
- tcp: string;
2837
- /** ws 连接地址 */
2838
- ws: string;
2839
- /** 连接用的client id */
2840
- client_id: string;
2841
- /** 连接用的username */
2842
- username: string;
2843
- /** 监听的 topics */
2844
- topics: string[];
2845
- }
2846
1668
  /**
2847
1669
  * 网络总体统计
2848
1670
  */
@@ -2877,6 +1699,35 @@ export interface NetworkStats {
2877
1699
  */
2878
1700
  server?: ServerQualityReport;
2879
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
+ };
1730
+ }
2880
1731
  /** 画中画句柄,用于控制画中画状态 */
2881
1732
  export interface PipHandle {
2882
1733
  /** 画中画类型:document-pip 支持自定义UI,video-pip 为传统模式 */
@@ -2935,17 +1786,6 @@ export interface ProcessorOptions {
2935
1786
  */
2936
1787
  audioContext?: AudioContext;
2937
1788
  }
2938
- /**
2939
- * 属性更改项
2940
- */
2941
- export interface PropChangeItem<T> {
2942
- /** 属性名 */
2943
- prop: T;
2944
- /** 更改后的值 */
2945
- value: any;
2946
- /** 更改前的值 */
2947
- old: any;
2948
- }
2949
1789
  /**
2950
1790
  * 质量评估结果快照
2951
1791
  */
@@ -2986,32 +1826,6 @@ export interface ReceiverStats {
2986
1826
  /** 本组 stats 的采集时间戳,单位 ms */
2987
1827
  timestamp: number;
2988
1828
  }
2989
- /**
2990
- * 断线重连api返回
2991
- */
2992
- export interface ReconnectRsp {
2993
- /** mqtt信息 */
2994
- mqtt: MqttServer;
2995
- /** 流媒体直连信息 */
2996
- upload: UploadServer;
2997
- /** rtmp网关信息 */
2998
- rtmp: RtmpServer;
2999
- /** webrtc网关信息 */
3000
- webrtc: WebrtcServer;
3001
- }
3002
- /**
3003
- * 程博 RTMP 网关连接信息
3004
- */
3005
- export interface RtmpServer {
3006
- /** RTMP 服务名称 */
3007
- name: string;
3008
- /** RTMP 推流前缀 */
3009
- push_url: string;
3010
- /** RTMP 拉流前缀 */
3011
- pull_url: string;
3012
- /** 对应upload服务的相对rtmp网关连接地址 */
3013
- upload_host: string;
3014
- }
3015
1829
  /**
3016
1830
  * 屏幕采集音频配置
3017
1831
  */
@@ -3132,27 +1946,6 @@ export interface ServerQualitySample {
3132
1946
  /** 本窗口该方向字节数;和 bitrate 同源 */
3133
1947
  bytes: number;
3134
1948
  }
3135
- /**
3136
- * 流媒体引擎能力
3137
- */
3138
- export interface StreamEngineAbility {
3139
- /** 支持的音频编解码 */
3140
- audioCodecs: Codec[];
3141
- /** 支持的视频编解码 */
3142
- videoCodecs: Codec[];
3143
- /** 最大支持的音频轨道发布数 */
3144
- audioMaxPub: number;
3145
- /** 最大支持的视频轨道发布数 */
3146
- videoMaxPub: number;
3147
- /** 最大支持的音频轨道订阅数 */
3148
- audioMaxSub: number;
3149
- /** 最大支持的音频轨道订阅数 */
3150
- videoMaxSub: number;
3151
- /** 希望的优先音频编码类型 */
3152
- preferAudioCodec?: Codec;
3153
- /** 希望的优先视频编码类型 */
3154
- preferVideoCodec?: Codec;
3155
- }
3156
1949
  /**
3157
1950
  * 流媒体引擎周期性输出的 metric 快照
3158
1951
  */
@@ -3223,17 +2016,6 @@ export interface TrackProcessor {
3223
2016
  /** 释放资源:断开音频节点、关闭自建的 AudioContext 等 */
3224
2017
  destroy(): Promise<void>;
3225
2018
  }
3226
- /**
3227
- * 程博流媒体服务连接信息
3228
- */
3229
- export interface UploadServer {
3230
- /** 流媒体服务名称 */
3231
- name: string;
3232
- /** 流媒体服务器地址 */
3233
- address: string;
3234
- /** 流媒体服务器端口 */
3235
- port: string;
3236
- }
3237
2019
  /** 用户离开事件data */
3238
2020
  export interface UserLeaveEventData {
3239
2021
  /** 用户id */
@@ -3355,17 +2137,6 @@ export interface VideoSenderStats extends SenderStats {
3355
2137
  /** 目标码率 */
3356
2138
  targetBitrate: number;
3357
2139
  }
3358
- /**
3359
- * 程博 WebRTC 网关连接信息
3360
- */
3361
- export interface WebrtcServer {
3362
- /** WebRTC 服务名称 */
3363
- name: string;
3364
- /** WebRTC 接口前缀 */
3365
- cmd_url: string;
3366
- /** 对应upload服务的相对webrtc网关连接地址 */
3367
- upload_host: string;
3368
- }
3369
2140
  /**
3370
2141
  * 频道事件通知(判别联合类型:`type` 决定 `data` 的精确形状)。
3371
2142
  *
@@ -3406,12 +2177,6 @@ export type ImEvent = {
3406
2177
  export type LocalCompositeRecorderState = "inactive" | "recording" | "paused";
3407
2178
  /** 本地合成录制器可接受的输入轨道 */
3408
2179
  export type LocalCompositeRecorderTrack = MediaStreamTrack | LocalVideoTrack | RemoteVideoTrack | LocalAudioTrack | RemoteAudioTrack;
3409
- /**
3410
- * 重试执行器函数:直接调用开始执行,.cancel()取消重试,函数失败会返回maxretry或canceled
3411
- */
3412
- export type retryCallback<T> = (() => Promise<T>) & {
3413
- cancel: () => void;
3414
- };
3415
2180
  /**
3416
2181
  * 频道信息
3417
2182
  */