@rongcloud/plugin-rtc 5.4.7-alpha.3 → 5.4.7-beem-enterprise.1

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.
@@ -10,6 +10,8 @@ export default class RCAudioLevelReport {
10
10
  * 通知业务端音量 > 0 的数据,数组每一项包含 track、audioLevel
11
11
  */
12
12
  private _audioLevelReport;
13
+ private startAutoExecute;
14
+ private stopAutoExecute;
13
15
  onAudioLevelChange(handler: IAudioLevelChangeHandler | null, gap: number): void;
14
16
  clearAudioLevelReportTimer(): void;
15
17
  }
@@ -1,4 +1,4 @@
1
- import { IRCRTCReportListener } from '../interfaces';
1
+ import { IRCRTCReportListener, IInnerRCRTCStateReport } from '../interfaces';
2
2
  import PolarisReporter from '../PolarisReporter';
3
3
  import { RCLocalTrack } from '../tracks/RCLocalTrack';
4
4
  import { RCRemoteTrack } from '../tracks/RCRemoteTrack';
@@ -33,6 +33,8 @@ export default class RCRTCPeerConnection extends EventEmitter {
33
33
  private _reportStatsTimer;
34
34
  private _reportR3R4ToPolarisTimer;
35
35
  private _isDestroyed;
36
+ private _reportStatsData?;
37
+ private _originReportStatsData?;
36
38
  constructor(
37
39
  /**
38
40
  * peerConnection 对应名称
@@ -53,6 +55,8 @@ export default class RCRTCPeerConnection extends EventEmitter {
53
55
  getName(): string;
54
56
  getLocalTracks(): RCLocalTrack[];
55
57
  private _onConnectionStateChange;
58
+ private startAutoExecute;
59
+ private stopAutoExecute;
56
60
  private _onICEConnectionStateChange;
57
61
  private _onTrackReady;
58
62
  /**
@@ -87,7 +91,7 @@ export default class RCRTCPeerConnection extends EventEmitter {
87
91
  * @returns 返回格式化后的数据
88
92
  */
89
93
  private _getStatsData;
90
- getAudioLevelReportData(): Promise<{
94
+ getAudioLevelReportData(gap?: number): Promise<{
91
95
  trackId: string;
92
96
  audioLevel: number | null;
93
97
  }[] | undefined>;
@@ -96,6 +100,10 @@ export default class RCRTCPeerConnection extends EventEmitter {
96
100
  * @todo
97
101
  */
98
102
  private _reportHandle;
103
+ /**
104
+ * 获取缓存的本地质量数据
105
+ */
106
+ _getCacheStatsData(): IInnerRCRTCStateReport | null | undefined;
99
107
  /**
100
108
  * 北极星上报 R3、R4 数据
101
109
  */
@@ -46,6 +46,11 @@ export default abstract class ASdpBuilder {
46
46
  * @returns SDP 标头和音频和视频流的字符串。
47
47
  */
48
48
  abstract stringify(): string;
49
+ /**
50
+ * 它将 SDP 标头中的 `a=group` 行替换为 `b=AS` 和 `b=TIAS` 行
51
+ * @param {number} maxBitrate - 流的最大比特率。
52
+ */
53
+ setHeaderBitrate(maxBitrate: number): void;
49
54
  /**
50
55
  * 它获取音频流并将它们映射到一个新数组,其中每个项目都是调用 setAudioItemBitrate 函数的结果
51
56
  * @param {IRCTrackBitrate} bitrate - 以 kbps 为单位的比特率。
package/dist/helper.d.ts CHANGED
@@ -42,6 +42,10 @@ export declare const isValidLocation: boolean;
42
42
  * @param track
43
43
  */
44
44
  export declare const getVideoTrackInfo: (track: MediaStreamTrack) => {
45
+ /**
46
+ * applyConstraints 方法应用的宽高约束不一定可以立马生效
47
+ * 取值优先 constraints
48
+ */
45
49
  width: number;
46
50
  height: number;
47
51
  frameRate: number;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.4.7-alpha.3
3
- * CommitId - 851c4005fa6dfee3d966699f4bc260b0b6cbd7ea
4
- * Fri Sep 02 2022 09:48:41 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.4.7-beem-enterprise.1
3
+ * CommitId - f6d422487789e25a83b33d99ce339c2d264d3d88
4
+ * Wed Sep 21 2022 12:27:46 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { EventEmitter, RTCMode, IRuntime, RTCPluginContext, IJoinRTCRoomData, IReceivedMessage, ErrorCode, RTCJoinType, IRTCUserData, KVString, IServerRTCRoomEntry, LogLevel, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
@@ -2517,6 +2517,8 @@ declare class RCRTCPeerConnection extends EventEmitter {
2517
2517
  private _reportStatsTimer;
2518
2518
  private _reportR3R4ToPolarisTimer;
2519
2519
  private _isDestroyed;
2520
+ private _reportStatsData?;
2521
+ private _originReportStatsData?;
2520
2522
  constructor(
2521
2523
  /**
2522
2524
  * peerConnection 对应名称
@@ -2537,6 +2539,8 @@ declare class RCRTCPeerConnection extends EventEmitter {
2537
2539
  getName(): string;
2538
2540
  getLocalTracks(): RCLocalTrack[];
2539
2541
  private _onConnectionStateChange;
2542
+ private startAutoExecute;
2543
+ private stopAutoExecute;
2540
2544
  private _onICEConnectionStateChange;
2541
2545
  private _onTrackReady;
2542
2546
  /**
@@ -2571,7 +2575,7 @@ declare class RCRTCPeerConnection extends EventEmitter {
2571
2575
  * @returns 返回格式化后的数据
2572
2576
  */
2573
2577
  private _getStatsData;
2574
- getAudioLevelReportData(): Promise<{
2578
+ getAudioLevelReportData(gap?: number): Promise<{
2575
2579
  trackId: string;
2576
2580
  audioLevel: number | null;
2577
2581
  }[] | undefined>;
@@ -2580,6 +2584,10 @@ declare class RCRTCPeerConnection extends EventEmitter {
2580
2584
  * @todo
2581
2585
  */
2582
2586
  private _reportHandle;
2587
+ /**
2588
+ * 获取缓存的本地质量数据
2589
+ */
2590
+ _getCacheStatsData(): IInnerRCRTCStateReport | null | undefined;
2583
2591
  /**
2584
2592
  * 北极星上报 R3、R4 数据
2585
2593
  */
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.4.7-alpha.3
3
- * CommitId - 851c4005fa6dfee3d966699f4bc260b0b6cbd7ea
4
- * Fri Sep 02 2022 09:48:41 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.4.7-beem-enterprise.1
3
+ * CommitId - f6d422487789e25a83b33d99ce339c2d264d3d88
4
+ * Wed Sep 21 2022 12:27:46 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { Logger, EventEmitter, logger as logger$1, LogSource, isNumber, validate, ErrorCode, HttpMethod, ConnectionStatus, RTCMode, notEmptyString, isObject as isObject$1, isString, RTCJoinType, RTCApiType, isArray, assert, ConversationType, isHttpUrl, isBoolean, isUndefined, RTCIdentityChangeType, VersionManage } from '@rongcloud/engine';
@@ -6474,7 +6474,8 @@ class RCTrack extends EventEmitter {
6474
6474
  return __awaiter(this, void 0, void 0, function* () {
6475
6475
  logger$1.info(RCLoggerTag.L_TRACK_PLAY_T, {
6476
6476
  element,
6477
- options
6477
+ options,
6478
+ msg: `start play trackId: ${this._id}`
6478
6479
  }, {
6479
6480
  logSource: LogSource.RTC
6480
6481
  });
@@ -7349,8 +7350,12 @@ const getVideoTrackInfo = (track) => {
7349
7350
  const settings = track.getSettings();
7350
7351
  const constraints = track.getConstraints();
7351
7352
  return {
7352
- width: settings.width || getValue(constraints.width),
7353
- height: settings.height || getValue(constraints.height),
7353
+ /**
7354
+ * applyConstraints 方法应用的宽高约束不一定可以立马生效
7355
+ * 取值优先 constraints
7356
+ */
7357
+ width: getValue(constraints.width) || settings.width || 0,
7358
+ height: getValue(constraints.height) || settings.height || 0,
7354
7359
  frameRate: settings.frameRate || getValue(constraints.frameRate)
7355
7360
  };
7356
7361
  };
@@ -7541,7 +7546,7 @@ const isNull = (val) => {
7541
7546
  * 公有云连接私有云 SDK 为非法连接
7542
7547
  */
7543
7548
  const isIllegalConnection = (navi) => {
7544
- return navi.type === 1;
7549
+ return !true ;
7545
7550
  };
7546
7551
  /**
7547
7552
  * 获取将要发布的 track 数量
@@ -7935,7 +7940,7 @@ const getCommonHeader = () => ({
7935
7940
  'Content-Type': 'application/json;charset=UTF-8',
7936
7941
  'Cache-Control': 'no-cache',
7937
7942
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
7938
- ClientVersion: "5.4.7-alpha.3",
7943
+ ClientVersion: "5.4.7-beem-enterprise.1",
7939
7944
  'Client-Session-Id': getUUID(),
7940
7945
  'Request-Id': Date.now().toString()
7941
7946
  });
@@ -8453,16 +8458,11 @@ class AbstractStatParser {
8453
8458
  });
8454
8459
  }
8455
8460
  parseRTCStatsReport(reports) {
8456
- const keys = reports.keys();
8457
8461
  const stats = {};
8458
- let temp = keys.next();
8459
- while (!temp.done) {
8460
- const key = temp.value;
8461
- const value = reports.get(key);
8462
- if (!/^RTCCodec_/.test(key)) {
8463
- stats[key] = value;
8462
+ for (const key of reports.keys()) {
8463
+ if (!key.includes('RTCCodec_')) {
8464
+ stats[key] = reports.get(key);
8464
8465
  }
8465
- temp = keys.next();
8466
8466
  }
8467
8467
  return stats;
8468
8468
  }
@@ -9264,6 +9264,13 @@ class ASdpBuilder {
9264
9264
  }
9265
9265
  return stream;
9266
9266
  }
9267
+ /**
9268
+ * 它将 SDP 标头中的 `a=group` 行替换为 `b=AS` 和 `b=TIAS` 行
9269
+ * @param {number} maxBitrate - 流的最大比特率。
9270
+ */
9271
+ setHeaderBitrate(maxBitrate) {
9272
+ this.SDPHeader = this.SDPHeader.replace(/(\r\ns=[^\r\n]+)/ig, `$1\r\nc=IN IP4 0.0.0.0\r\nb=AS:${maxBitrate * ASdpBuilder.KBitrate}\r\nb=TIAS:${maxBitrate * ASdpBuilder.KBitrate * 850}`);
9273
+ }
9267
9274
  /**
9268
9275
  * 它获取音频流并将它们映射到一个新数组,其中每个项目都是调用 setAudioItemBitrate 函数的结果
9269
9276
  * @param {IRCTrackBitrate} bitrate - 以 kbps 为单位的比特率。
@@ -9354,7 +9361,7 @@ class ASdpBuilder {
9354
9361
  */
9355
9362
  addAudioBlineAS(sdpAudioBlock, bitrate) {
9356
9363
  if (!/\bb=AS:\d+\b/ig.test(sdpAudioBlock)) {
9357
- return sdpAudioBlock.replace(/^(m=audio[^\r\n]+)/, `$1\r\nb=AS:${bitrate.max * ASdpBuilder.KBitrate}`);
9364
+ return sdpAudioBlock.replace(/(\bc=IN[^\r\n]+)/ig, `$1\r\nb=AS:${bitrate.max * ASdpBuilder.KBitrate}\r\nb=TIAS:${bitrate.max * ASdpBuilder.KBitrate * 850}`);
9358
9365
  }
9359
9366
  return sdpAudioBlock;
9360
9367
  }
@@ -9452,7 +9459,7 @@ class ASdpBuilder {
9452
9459
  addVideoBlineAS(sdpVideoBlock, bitrate) {
9453
9460
  // b=AS: 定义本端带宽信息
9454
9461
  if (!/\bb=AS:\d+\b/ig.test(sdpVideoBlock)) {
9455
- return sdpVideoBlock.replace(/^(m=video[^\r\n]+)/, `$1\r\nb=AS:${bitrate.max * ASdpBuilder.KBitrate}`);
9462
+ return sdpVideoBlock.replace(/(\bc=IN[^\r\n]+)/ig, `$1\r\nb=AS:${bitrate.max * ASdpBuilder.KBitrate}\r\nb=TIAS:${bitrate.max * ASdpBuilder.KBitrate * 850}`);
9456
9463
  }
9457
9464
  return sdpVideoBlock;
9458
9465
  }
@@ -9581,7 +9588,7 @@ class ASdpStrategy {
9581
9588
  return __awaiter(this, void 0, void 0, function* () {
9582
9589
  // 过滤行末的空格,服务可能产生空格数据
9583
9590
  sdp = ASdpBuilder.trimBlankLine(sdp);
9584
- logger$1.info(`set remote answer -> ${sdp}`);
9591
+ logger.info(`set remote answer -> ${sdp}`);
9585
9592
  try {
9586
9593
  yield this._peer.setRemoteDescription({ type: 'answer', sdp });
9587
9594
  }
@@ -10218,6 +10225,10 @@ class RCRTCPeerConnection extends EventEmitter {
10218
10225
  // 上报上下行数据至北极星定时器
10219
10226
  this._reportR3R4ToPolarisTimer = null;
10220
10227
  this._isDestroyed = false;
10228
+ // 格式化后的质量数据
10229
+ this._reportStatsData = null;
10230
+ // 格式化之前的质量数据
10231
+ this._originReportStatsData = null;
10221
10232
  this._reportListener = null;
10222
10233
  const sdpSemantics = ASdpStrategy.getSdpSemantics();
10223
10234
  const peer = this._rtcPeerConn = new RTCPeerConnection({ sdpSemantics });
@@ -10249,15 +10260,24 @@ class RCRTCPeerConnection extends EventEmitter {
10249
10260
  logSource: LogSource.RTC
10250
10261
  });
10251
10262
  }
10263
+ startAutoExecute(gap = 1000) {
10264
+ this._reportStatsTimer = setTimeout(() => {
10265
+ this._reportHandle(gap);
10266
+ this._reportStatsTimer = this.startAutoExecute();
10267
+ }, gap);
10268
+ }
10269
+ stopAutoExecute() {
10270
+ clearTimeout(this._reportStatsTimer);
10271
+ }
10252
10272
  _onICEConnectionStateChange() {
10253
10273
  var _a, _b;
10254
10274
  logger.info(`oniceconnectionstatechange -> ${this._rtcPeerConn.iceConnectionState}, ${this._pcName}`);
10255
10275
  if (this._rtcPeerConn.iceConnectionState === 'connected') {
10256
10276
  // 开启 peerConnection stats 统计定时器
10257
10277
  if (this._reportStatsTimer) {
10258
- clearInterval(this._reportStatsTimer);
10278
+ this.stopAutoExecute();
10259
10279
  }
10260
- this._reportStatsTimer = setInterval(this._reportHandle.bind(this), 1000);
10280
+ this.startAutoExecute();
10261
10281
  }
10262
10282
  // ICE 连接中断后,需要尝试重新走 exchange 流程以恢复
10263
10283
  if (this._rtcPeerConn.iceConnectionState === 'failed' || this._rtcPeerConn.iceConnectionState === 'disconnected') {
@@ -10512,33 +10532,53 @@ class RCRTCPeerConnection extends EventEmitter {
10512
10532
  * 获取 peerConnection stats 数据并格式化
10513
10533
  * @returns 返回格式化后的数据
10514
10534
  */
10515
- _getStatsData() {
10516
- var _a, _b;
10535
+ _getStatsData(gap = 1000) {
10536
+ var _a, _b, _c;
10517
10537
  return __awaiter(this, void 0, void 0, function* () {
10518
- const reports = yield this._rtcPeerConn.getStats();
10519
- /**
10520
- * 解析 stats 数据
10521
- */
10522
- const data = (_a = this.reportParser) === null || _a === void 0 ? void 0 : _a.parseRTCStatsReport(reports);
10538
+ let data = null;
10539
+ if (((_a = this._originReportStatsData) === null || _a === void 0 ? void 0 : _a.timestamp) && this._originReportStatsData.timestamp > Date.now() - gap) {
10540
+ data = this._originReportStatsData.data;
10541
+ }
10542
+ else {
10543
+ const reports = yield this._rtcPeerConn.getStats();
10544
+ /**
10545
+ * 解析 stats 数据
10546
+ */
10547
+ data = (_b = this.reportParser) === null || _b === void 0 ? void 0 : _b.parseRTCStatsReport(reports);
10548
+ this._originReportStatsData = {
10549
+ data,
10550
+ timestamp: Date.now()
10551
+ };
10552
+ }
10523
10553
  /**
10524
10554
  * 获取 report 中的 iceCandidatePair、senders、receivers 中的所有字段
10525
10555
  */
10526
- const formatData = (_b = this.reportParser) === null || _b === void 0 ? void 0 : _b.formatRCRTCStateReport(data);
10556
+ const formatData = (_c = this.reportParser) === null || _c === void 0 ? void 0 : _c.formatRCRTCStateReport(data);
10527
10557
  return formatData;
10528
10558
  });
10529
10559
  }
10530
- getAudioLevelReportData() {
10531
- var _a, _b;
10560
+ getAudioLevelReportData(gap = 1000) {
10561
+ var _a, _b, _c;
10532
10562
  return __awaiter(this, void 0, void 0, function* () {
10533
- const reports = yield this._rtcPeerConn.getStats();
10534
- /**
10535
- * 解析 stats 数据
10536
- */
10537
- const data = (_a = this.reportParser) === null || _a === void 0 ? void 0 : _a.parseRTCStatsReport(reports);
10563
+ let data = null;
10564
+ if (((_a = this._originReportStatsData) === null || _a === void 0 ? void 0 : _a.timestamp) && this._originReportStatsData.timestamp > Date.now() - gap) {
10565
+ data = this._originReportStatsData.data;
10566
+ }
10567
+ else {
10568
+ const reports = yield this._rtcPeerConn.getStats();
10569
+ /**
10570
+ * 解析 stats 数据
10571
+ */
10572
+ data = (_b = this.reportParser) === null || _b === void 0 ? void 0 : _b.parseRTCStatsReport(reports);
10573
+ this._originReportStatsData = {
10574
+ data,
10575
+ timestamp: Date.now()
10576
+ };
10577
+ }
10538
10578
  if (!data) {
10539
10579
  return [];
10540
10580
  }
10541
- const audioLevelData = (_b = this.reportParser) === null || _b === void 0 ? void 0 : _b.getAudioLevelList(data);
10581
+ const audioLevelData = (_c = this.reportParser) === null || _c === void 0 ? void 0 : _c.getAudioLevelList(data);
10542
10582
  return audioLevelData;
10543
10583
  });
10544
10584
  }
@@ -10546,13 +10586,14 @@ class RCRTCPeerConnection extends EventEmitter {
10546
10586
  * 通知用户质量数据、peerConnection 北极星数据上报
10547
10587
  * @todo
10548
10588
  */
10549
- _reportHandle() {
10589
+ _reportHandle(gap) {
10550
10590
  var _a, _b;
10551
10591
  return __awaiter(this, void 0, void 0, function* () {
10552
- const formatData = yield this._getStatsData();
10592
+ const formatData = yield this._getStatsData(gap);
10553
10593
  if (!formatData) {
10554
10594
  return;
10555
10595
  }
10596
+ this._reportStatsData = formatData;
10556
10597
  /**
10557
10598
  * 组装用户层抛出数据
10558
10599
  */
@@ -10560,13 +10601,19 @@ class RCRTCPeerConnection extends EventEmitter {
10560
10601
  (_b = (_a = this._reportListener) === null || _a === void 0 ? void 0 : _a.onStateReport) === null || _b === void 0 ? void 0 : _b.call(_a, reportData);
10561
10602
  });
10562
10603
  }
10604
+ /**
10605
+ * 获取缓存的本地质量数据
10606
+ */
10607
+ _getCacheStatsData() {
10608
+ return this._reportStatsData;
10609
+ }
10563
10610
  /**
10564
10611
  * 北极星上报 R3、R4 数据
10565
10612
  */
10566
10613
  _sendR3R4Data() {
10567
10614
  var _a;
10568
10615
  return __awaiter(this, void 0, void 0, function* () {
10569
- const formatData = yield this._getStatsData();
10616
+ const formatData = this._getCacheStatsData();
10570
10617
  if (!formatData) {
10571
10618
  return true;
10572
10619
  }
@@ -10585,7 +10632,9 @@ class RCRTCPeerConnection extends EventEmitter {
10585
10632
  return __awaiter(this, void 0, void 0, function* () {
10586
10633
  clearTimeout(this._reportR3R4ToPolarisTimer);
10587
10634
  yield this._sendR3R4Data();
10588
- this._reportR3R4ToPolarisTimer = setTimeout(this.__reportR3R4ToPolaris.bind(this), 2000);
10635
+ this._reportR3R4ToPolarisTimer = setTimeout(() => {
10636
+ this.__reportR3R4ToPolaris();
10637
+ }, 2000);
10589
10638
  });
10590
10639
  }
10591
10640
  getRTCPeerConn() {
@@ -10597,7 +10646,7 @@ class RCRTCPeerConnection extends EventEmitter {
10597
10646
  clearTimeout(this._reportR3R4ToPolarisTimer);
10598
10647
  // 停止计时
10599
10648
  if (this._reportStatsTimer) {
10600
- clearInterval(this._reportStatsTimer);
10649
+ this.stopAutoExecute();
10601
10650
  this._reportStatsTimer = null;
10602
10651
  }
10603
10652
  this.registerReportListener(null);
@@ -10824,7 +10873,7 @@ class PolarisReporter {
10824
10873
  * 加入房间
10825
10874
  */
10826
10875
  sendR1() {
10827
- const rtcVersion = "5.4.7-alpha.3";
10876
+ const rtcVersion = "5.4.7-beem-enterprise.1";
10828
10877
  const imVersion = this._context.getCoreVersion();
10829
10878
  const platform = 'web';
10830
10879
  const pcName = navigator.platform;
@@ -10857,7 +10906,7 @@ class RCAudioLevelReport {
10857
10906
  /**
10858
10907
  * 通知业务端音量 > 0 的数据,数组每一项包含 track、audioLevel
10859
10908
  */
10860
- _audioLevelReport() {
10909
+ _audioLevelReport(gap) {
10861
10910
  return __awaiter(this, void 0, void 0, function* () {
10862
10911
  if (!this._audioLevelChangeHandler) {
10863
10912
  return;
@@ -10869,23 +10918,31 @@ class RCAudioLevelReport {
10869
10918
  if (pc.getRTCPeerConn().iceConnectionState === 'new') {
10870
10919
  return;
10871
10920
  }
10872
- const audioLevelData = yield pc.getAudioLevelReportData();
10873
- const list = audioLevelData.map((item) => {
10921
+ const audioLevelData = yield pc.getAudioLevelReportData(gap);
10922
+ audioLevelData === null || audioLevelData === void 0 ? void 0 : audioLevelData.forEach(item => {
10874
10923
  const { userId } = parseTrackId(item.trackId);
10875
10924
  const isLocal = this._room.getCrtUserId() === userId;
10876
10925
  const track = isLocal ? this._room.getLocalTrack(item.trackId) : this._room.getRemoteTrack(item.trackId);
10877
- return {
10878
- track,
10879
- audioLevel: item.audioLevel || 0
10880
- };
10881
- }).filter((item) => {
10882
- return item.track;
10926
+ if (track) {
10927
+ audioLevelList.push({
10928
+ track,
10929
+ audioLevel: item.audioLevel || 0
10930
+ });
10931
+ }
10883
10932
  });
10884
- audioLevelList.push(...list);
10885
10933
  }
10886
10934
  this._audioLevelChangeHandler(audioLevelList);
10887
10935
  });
10888
10936
  }
10937
+ startAutoExecute(gap = 1000) {
10938
+ this._timer = setTimeout(() => {
10939
+ this._audioLevelReport(gap);
10940
+ this._timer = this.startAutoExecute(gap);
10941
+ }, gap);
10942
+ }
10943
+ stopAutoExecute() {
10944
+ clearTimeout(this._timer);
10945
+ }
10889
10946
  onAudioLevelChange(handler, gap) {
10890
10947
  if (gap < 300 || gap > 1000) {
10891
10948
  logger.error('the valid range of onAudioLevelChange params "gap" is: > 300 && < 1000');
@@ -10896,12 +10953,12 @@ class RCAudioLevelReport {
10896
10953
  }
10897
10954
  else {
10898
10955
  this._audioLevelChangeHandler = handler;
10899
- this._timer = setInterval(this._audioLevelReport.bind(this), gap);
10956
+ this.startAutoExecute(gap);
10900
10957
  }
10901
10958
  }
10902
10959
  clearAudioLevelReportTimer() {
10903
10960
  if (this._timer) {
10904
- clearInterval(this._timer);
10961
+ this.stopAutoExecute();
10905
10962
  this._timer = null;
10906
10963
  }
10907
10964
  }
@@ -11647,14 +11704,7 @@ class JoinRoomCommand extends BaseCommand {
11647
11704
  }, { logSource: LogSource.RTC });
11648
11705
  return { code: RCRTCCode.SIGNAL_DISCONNECTED };
11649
11706
  }
11650
- if (isIllegalConnection(context.getNaviInfo())) {
11651
- logger$1.error(logTag, {
11652
- status: RCLoggerStatus.FAILED,
11653
- code: RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,
11654
- msg: 'navi_usl error'
11655
- }, { logSource: LogSource.RTC });
11656
- return { code: RCRTCCode.PACKAGE_ENVIRONMENT_ERROR };
11657
- }
11707
+ if (isIllegalConnection(context.getNaviInfo())) ;
11658
11708
  if (!validate('roomId', this.roomId, notEmptyString, true)) {
11659
11709
  logger$1.error(logTag, {
11660
11710
  status: RCLoggerStatus.FAILED,
@@ -12113,7 +12163,7 @@ class ParseUserStateCommand extends BaseCommand {
12113
12163
  users.forEach(item => {
12114
12164
  const userId = item.userId;
12115
12165
  if (+item.state === 0) {
12116
- logger.debug(`user joined -> ${userId}`);
12166
+ logger.info(`user joined -> ${userId}`);
12117
12167
  // 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
12118
12168
  const resArr = store.getResourcesByUserId(userId);
12119
12169
  if (!resArr) {
@@ -12122,7 +12172,7 @@ class ParseUserStateCommand extends BaseCommand {
12122
12172
  store.setResourcesByUserId(userId, resArr || []);
12123
12173
  }
12124
12174
  else {
12125
- logger.debug(`user left -> ${userId}`);
12175
+ logger.info(`user left -> ${userId}`);
12126
12176
  item.switchRoleType ? downgrade.push(userId) : left.push(userId);
12127
12177
  }
12128
12178
  });
@@ -12431,6 +12481,16 @@ class PublishCommand extends BaseCommand {
12431
12481
  const { track: localTrack } = track instanceof RCLocalTrack ? { track } : track;
12432
12482
  localTracks.push(localTrack);
12433
12483
  });
12484
+ /**
12485
+ * 将发布的视频流按从小到大进行排序
12486
+ */
12487
+ tracks.sort((item, nextItem) => {
12488
+ const { track: localTrack } = item instanceof RCLocalTrack ? { track: item } : item;
12489
+ const { max: maxBitrate } = localTrack.getBitrate();
12490
+ const { track: nextLocalTrack } = nextItem instanceof RCLocalTrack ? { track: nextItem } : nextItem;
12491
+ const { max: maxNextBitrate } = nextLocalTrack.getBitrate();
12492
+ return maxBitrate - maxNextBitrate;
12493
+ });
12434
12494
  /**
12435
12495
  * 一个 peerConnection 上行不超过 10 个
12436
12496
  */
@@ -13493,12 +13553,14 @@ class RCAbstractRoom extends EventEmitter {
13493
13553
  }
13494
13554
  __parseInnerMessage(message) {
13495
13555
  const { targetId: roomId, conversationType } = message;
13496
- // 过滤非 RTC 消息
13497
- if (conversationType !== ConversationType.RTC_ROOM) {
13498
- return false;
13499
- }
13500
13556
  // 为 RTC 消息,但不属于当前房间的不处理
13501
13557
  if (roomId !== this._roomId) {
13558
+ logger$1.warn(RCLoggerTag.L_RTC_CLIENT_MESSAGE_O, {
13559
+ status: RCLoggerStatus.FAILED,
13560
+ message: `roomId is different, msg roomId-> ${roomId}, this._roomId-> ${this._roomId} `
13561
+ }, {
13562
+ logSource: LogSource.RTC
13563
+ });
13502
13564
  return true;
13503
13565
  }
13504
13566
  logger.info(`recv inner msg -> message: ${JSON.stringify(message)} | roomid: ${this._roomId}`);
@@ -16751,16 +16813,7 @@ class RCAudienceClient {
16751
16813
  logSource: LogSource.RTC
16752
16814
  });
16753
16815
  const tracks = [];
16754
- if (isIllegalConnection(this._context.getNaviInfo())) {
16755
- logger$1.error(RCLoggerTag.L_AUDIENCE_CLIENT_SUBSCRIBE_R, {
16756
- status: RCLoggerStatus.FAILED,
16757
- code: RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,
16758
- msg: 'navi_url error'
16759
- }, {
16760
- logSource: LogSource.RTC
16761
- });
16762
- return { code: RCRTCCode.PACKAGE_ENVIRONMENT_ERROR, tracks };
16763
- }
16816
+ if (isIllegalConnection(this._context.getNaviInfo())) ;
16764
16817
  // 客户端主动调用 api 发请求时,清除 ice 断线重连的定时器
16765
16818
  !this._fromRetry && ((_a = this._pc) === null || _a === void 0 ? void 0 : _a.clearReTryExchangeTimer());
16766
16819
  this._fromRetry = false;
@@ -18770,7 +18823,6 @@ class RCRTCClient extends RCMediaStreamCapture {
18770
18823
  this._context.onmessage = this._handleMessage.bind(this);
18771
18824
  }
18772
18825
  _handleMessage(message) {
18773
- var _a;
18774
18826
  // 过滤非 RTC 消息
18775
18827
  if (message.conversationType !== ConversationType.RTC_ROOM) {
18776
18828
  return false;
@@ -18782,13 +18834,22 @@ class RCRTCClient extends RCMediaStreamCapture {
18782
18834
  room.__parseInnerMessage(message);
18783
18835
  });
18784
18836
  }
18785
- (_a = this._crtRoom) === null || _a === void 0 ? void 0 : _a.__parseInnerMessage(message);
18786
18837
  logger$1.info(RCLoggerTag.L_RTC_CLIENT_MESSAGE_O, {
18787
18838
  status: RCLoggerStatus.SUCCESSED,
18788
- message: Object.assign(message, { content: '内容涉及隐私不予显示' })
18839
+ message
18789
18840
  }, {
18790
18841
  logSource: LogSource.RTC
18791
18842
  });
18843
+ if (!this._crtRoom) {
18844
+ logger$1.warn(RCLoggerTag.L_RTC_CLIENT_MESSAGE_O, {
18845
+ status: RCLoggerStatus.FAILED,
18846
+ message: 'the crtRoom is empty'
18847
+ }, {
18848
+ logSource: LogSource.RTC
18849
+ });
18850
+ return true;
18851
+ }
18852
+ this._crtRoom.__parseInnerMessage(message);
18792
18853
  return true;
18793
18854
  }
18794
18855
  /**
@@ -18991,16 +19052,7 @@ class RCRTCClient extends RCMediaStreamCapture {
18991
19052
  }, {
18992
19053
  logSource: LogSource.RTC
18993
19054
  });
18994
- if (isIllegalConnection(this._context.getNaviInfo())) {
18995
- logger$1.error(RCLoggerTag.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R, {
18996
- status: RCLoggerStatus.FAILED,
18997
- code: RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,
18998
- msg: 'navi_url error'
18999
- }, {
19000
- logSource: LogSource.RTC
19001
- });
19002
- return { code: RCRTCCode.PACKAGE_ENVIRONMENT_ERROR };
19003
- }
19055
+ if (isIllegalConnection(this._context.getNaviInfo())) ;
19004
19056
  if (!(validate('roomId', roomId, notEmptyString, true) &&
19005
19057
  validate('livingType', livingType, (value) => value === RCLivingType.AUDIO || value === RCLivingType.VIDEO))) {
19006
19058
  logger$1.error(RCLoggerTag.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R, {
@@ -19308,9 +19360,9 @@ const installer = {
19308
19360
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
19309
19361
  return false;
19310
19362
  }
19311
- VersionManage.add('plugin-rtc', "5.4.7-alpha.3");
19312
- if (!VersionManage.validEngine("5.3.4 - 5.4.5")) {
19313
- logger.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"5.3.4 - 5.4.5"}'.`);
19363
+ VersionManage.add('plugin-rtc', "5.4.7-beem-enterprise.1");
19364
+ if (!VersionManage.validEngine("5.4.2-beem-enterprise.2")) {
19365
+ logger.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"5.4.2-beem-enterprise.2"}'.`);
19314
19366
  return false;
19315
19367
  }
19316
19368
  return true;
@@ -19319,7 +19371,7 @@ const installer = {
19319
19371
  var _a, _b, _c, _d, _e, _f, _g, _h;
19320
19372
  logger.setLogLevel(options.logLevel);
19321
19373
  logger.setLogStdout(options.logStdout);
19322
- logger.warn(`RCRTC Version: ${"5.4.7-alpha.3"}, Commit: ${"851c4005fa6dfee3d966699f4bc260b0b6cbd7ea"}`);
19374
+ logger.warn(`RCRTC Version: ${"5.4.7-beem-enterprise.1"}, Commit: ${"f6d422487789e25a83b33d99ce339c2d264d3d88"}`);
19323
19375
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
19324
19376
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
19325
19377
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);