@rongcloud/plugin-rtc 5.4.7-alpha.4 → 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.
package/dist/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.4.7-alpha.4
3
- * CommitId - 1297531a6457c0e72d9fa276eee9a49a7b3c596e
4
- * Tue Sep 13 2022 20:41:55 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
  (function (global, factory) {
@@ -6477,7 +6477,8 @@
6477
6477
  return __awaiter(this, void 0, void 0, function* () {
6478
6478
  engine.logger.info(RCLoggerTag.L_TRACK_PLAY_T, {
6479
6479
  element,
6480
- options
6480
+ options,
6481
+ msg: `start play trackId: ${this._id}`
6481
6482
  }, {
6482
6483
  logSource: engine.LogSource.RTC
6483
6484
  });
@@ -7548,7 +7549,7 @@
7548
7549
  * 公有云连接私有云 SDK 为非法连接
7549
7550
  */
7550
7551
  const isIllegalConnection = (navi) => {
7551
- return navi.type === 1;
7552
+ return !true ;
7552
7553
  };
7553
7554
  /**
7554
7555
  * 获取将要发布的 track 数量
@@ -7942,7 +7943,7 @@
7942
7943
  'Content-Type': 'application/json;charset=UTF-8',
7943
7944
  'Cache-Control': 'no-cache',
7944
7945
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
7945
- ClientVersion: "5.4.7-alpha.4",
7946
+ ClientVersion: "5.4.7-beem-enterprise.1",
7946
7947
  'Client-Session-Id': getUUID(),
7947
7948
  'Request-Id': Date.now().toString()
7948
7949
  });
@@ -8460,16 +8461,11 @@
8460
8461
  });
8461
8462
  }
8462
8463
  parseRTCStatsReport(reports) {
8463
- const keys = reports.keys();
8464
8464
  const stats = {};
8465
- let temp = keys.next();
8466
- while (!temp.done) {
8467
- const key = temp.value;
8468
- const value = reports.get(key);
8469
- if (!/^RTCCodec_/.test(key)) {
8470
- stats[key] = value;
8465
+ for (const key of reports.keys()) {
8466
+ if (!key.includes('RTCCodec_')) {
8467
+ stats[key] = reports.get(key);
8471
8468
  }
8472
- temp = keys.next();
8473
8469
  }
8474
8470
  return stats;
8475
8471
  }
@@ -9595,7 +9591,7 @@
9595
9591
  return __awaiter(this, void 0, void 0, function* () {
9596
9592
  // 过滤行末的空格,服务可能产生空格数据
9597
9593
  sdp = ASdpBuilder.trimBlankLine(sdp);
9598
- engine.logger.info(`set remote answer -> ${sdp}`);
9594
+ logger.info(`set remote answer -> ${sdp}`);
9599
9595
  try {
9600
9596
  yield this._peer.setRemoteDescription({ type: 'answer', sdp });
9601
9597
  }
@@ -10232,6 +10228,10 @@
10232
10228
  // 上报上下行数据至北极星定时器
10233
10229
  this._reportR3R4ToPolarisTimer = null;
10234
10230
  this._isDestroyed = false;
10231
+ // 格式化后的质量数据
10232
+ this._reportStatsData = null;
10233
+ // 格式化之前的质量数据
10234
+ this._originReportStatsData = null;
10235
10235
  this._reportListener = null;
10236
10236
  const sdpSemantics = ASdpStrategy.getSdpSemantics();
10237
10237
  const peer = this._rtcPeerConn = new RTCPeerConnection({ sdpSemantics });
@@ -10263,15 +10263,24 @@
10263
10263
  logSource: engine.LogSource.RTC
10264
10264
  });
10265
10265
  }
10266
+ startAutoExecute(gap = 1000) {
10267
+ this._reportStatsTimer = setTimeout(() => {
10268
+ this._reportHandle(gap);
10269
+ this._reportStatsTimer = this.startAutoExecute();
10270
+ }, gap);
10271
+ }
10272
+ stopAutoExecute() {
10273
+ clearTimeout(this._reportStatsTimer);
10274
+ }
10266
10275
  _onICEConnectionStateChange() {
10267
10276
  var _a, _b;
10268
10277
  logger.info(`oniceconnectionstatechange -> ${this._rtcPeerConn.iceConnectionState}, ${this._pcName}`);
10269
10278
  if (this._rtcPeerConn.iceConnectionState === 'connected') {
10270
10279
  // 开启 peerConnection stats 统计定时器
10271
10280
  if (this._reportStatsTimer) {
10272
- clearInterval(this._reportStatsTimer);
10281
+ this.stopAutoExecute();
10273
10282
  }
10274
- this._reportStatsTimer = setInterval(this._reportHandle.bind(this), 1000);
10283
+ this.startAutoExecute();
10275
10284
  }
10276
10285
  // ICE 连接中断后,需要尝试重新走 exchange 流程以恢复
10277
10286
  if (this._rtcPeerConn.iceConnectionState === 'failed' || this._rtcPeerConn.iceConnectionState === 'disconnected') {
@@ -10526,33 +10535,53 @@
10526
10535
  * 获取 peerConnection stats 数据并格式化
10527
10536
  * @returns 返回格式化后的数据
10528
10537
  */
10529
- _getStatsData() {
10530
- var _a, _b;
10538
+ _getStatsData(gap = 1000) {
10539
+ var _a, _b, _c;
10531
10540
  return __awaiter(this, void 0, void 0, function* () {
10532
- const reports = yield this._rtcPeerConn.getStats();
10533
- /**
10534
- * 解析 stats 数据
10535
- */
10536
- const data = (_a = this.reportParser) === null || _a === void 0 ? void 0 : _a.parseRTCStatsReport(reports);
10541
+ let data = null;
10542
+ if (((_a = this._originReportStatsData) === null || _a === void 0 ? void 0 : _a.timestamp) && this._originReportStatsData.timestamp > Date.now() - gap) {
10543
+ data = this._originReportStatsData.data;
10544
+ }
10545
+ else {
10546
+ const reports = yield this._rtcPeerConn.getStats();
10547
+ /**
10548
+ * 解析 stats 数据
10549
+ */
10550
+ data = (_b = this.reportParser) === null || _b === void 0 ? void 0 : _b.parseRTCStatsReport(reports);
10551
+ this._originReportStatsData = {
10552
+ data,
10553
+ timestamp: Date.now()
10554
+ };
10555
+ }
10537
10556
  /**
10538
10557
  * 获取 report 中的 iceCandidatePair、senders、receivers 中的所有字段
10539
10558
  */
10540
- const formatData = (_b = this.reportParser) === null || _b === void 0 ? void 0 : _b.formatRCRTCStateReport(data);
10559
+ const formatData = (_c = this.reportParser) === null || _c === void 0 ? void 0 : _c.formatRCRTCStateReport(data);
10541
10560
  return formatData;
10542
10561
  });
10543
10562
  }
10544
- getAudioLevelReportData() {
10545
- var _a, _b;
10563
+ getAudioLevelReportData(gap = 1000) {
10564
+ var _a, _b, _c;
10546
10565
  return __awaiter(this, void 0, void 0, function* () {
10547
- const reports = yield this._rtcPeerConn.getStats();
10548
- /**
10549
- * 解析 stats 数据
10550
- */
10551
- const data = (_a = this.reportParser) === null || _a === void 0 ? void 0 : _a.parseRTCStatsReport(reports);
10566
+ let data = null;
10567
+ if (((_a = this._originReportStatsData) === null || _a === void 0 ? void 0 : _a.timestamp) && this._originReportStatsData.timestamp > Date.now() - gap) {
10568
+ data = this._originReportStatsData.data;
10569
+ }
10570
+ else {
10571
+ const reports = yield this._rtcPeerConn.getStats();
10572
+ /**
10573
+ * 解析 stats 数据
10574
+ */
10575
+ data = (_b = this.reportParser) === null || _b === void 0 ? void 0 : _b.parseRTCStatsReport(reports);
10576
+ this._originReportStatsData = {
10577
+ data,
10578
+ timestamp: Date.now()
10579
+ };
10580
+ }
10552
10581
  if (!data) {
10553
10582
  return [];
10554
10583
  }
10555
- const audioLevelData = (_b = this.reportParser) === null || _b === void 0 ? void 0 : _b.getAudioLevelList(data);
10584
+ const audioLevelData = (_c = this.reportParser) === null || _c === void 0 ? void 0 : _c.getAudioLevelList(data);
10556
10585
  return audioLevelData;
10557
10586
  });
10558
10587
  }
@@ -10560,13 +10589,14 @@
10560
10589
  * 通知用户质量数据、peerConnection 北极星数据上报
10561
10590
  * @todo
10562
10591
  */
10563
- _reportHandle() {
10592
+ _reportHandle(gap) {
10564
10593
  var _a, _b;
10565
10594
  return __awaiter(this, void 0, void 0, function* () {
10566
- const formatData = yield this._getStatsData();
10595
+ const formatData = yield this._getStatsData(gap);
10567
10596
  if (!formatData) {
10568
10597
  return;
10569
10598
  }
10599
+ this._reportStatsData = formatData;
10570
10600
  /**
10571
10601
  * 组装用户层抛出数据
10572
10602
  */
@@ -10574,13 +10604,19 @@
10574
10604
  (_b = (_a = this._reportListener) === null || _a === void 0 ? void 0 : _a.onStateReport) === null || _b === void 0 ? void 0 : _b.call(_a, reportData);
10575
10605
  });
10576
10606
  }
10607
+ /**
10608
+ * 获取缓存的本地质量数据
10609
+ */
10610
+ _getCacheStatsData() {
10611
+ return this._reportStatsData;
10612
+ }
10577
10613
  /**
10578
10614
  * 北极星上报 R3、R4 数据
10579
10615
  */
10580
10616
  _sendR3R4Data() {
10581
10617
  var _a;
10582
10618
  return __awaiter(this, void 0, void 0, function* () {
10583
- const formatData = yield this._getStatsData();
10619
+ const formatData = this._getCacheStatsData();
10584
10620
  if (!formatData) {
10585
10621
  return true;
10586
10622
  }
@@ -10599,7 +10635,9 @@
10599
10635
  return __awaiter(this, void 0, void 0, function* () {
10600
10636
  clearTimeout(this._reportR3R4ToPolarisTimer);
10601
10637
  yield this._sendR3R4Data();
10602
- this._reportR3R4ToPolarisTimer = setTimeout(this.__reportR3R4ToPolaris.bind(this), 2000);
10638
+ this._reportR3R4ToPolarisTimer = setTimeout(() => {
10639
+ this.__reportR3R4ToPolaris();
10640
+ }, 2000);
10603
10641
  });
10604
10642
  }
10605
10643
  getRTCPeerConn() {
@@ -10611,7 +10649,7 @@
10611
10649
  clearTimeout(this._reportR3R4ToPolarisTimer);
10612
10650
  // 停止计时
10613
10651
  if (this._reportStatsTimer) {
10614
- clearInterval(this._reportStatsTimer);
10652
+ this.stopAutoExecute();
10615
10653
  this._reportStatsTimer = null;
10616
10654
  }
10617
10655
  this.registerReportListener(null);
@@ -10838,7 +10876,7 @@
10838
10876
  * 加入房间
10839
10877
  */
10840
10878
  sendR1() {
10841
- const rtcVersion = "5.4.7-alpha.4";
10879
+ const rtcVersion = "5.4.7-beem-enterprise.1";
10842
10880
  const imVersion = this._context.getCoreVersion();
10843
10881
  const platform = 'web';
10844
10882
  const pcName = navigator.platform;
@@ -10871,7 +10909,7 @@
10871
10909
  /**
10872
10910
  * 通知业务端音量 > 0 的数据,数组每一项包含 track、audioLevel
10873
10911
  */
10874
- _audioLevelReport() {
10912
+ _audioLevelReport(gap) {
10875
10913
  return __awaiter(this, void 0, void 0, function* () {
10876
10914
  if (!this._audioLevelChangeHandler) {
10877
10915
  return;
@@ -10883,23 +10921,31 @@
10883
10921
  if (pc.getRTCPeerConn().iceConnectionState === 'new') {
10884
10922
  return;
10885
10923
  }
10886
- const audioLevelData = yield pc.getAudioLevelReportData();
10887
- const list = audioLevelData.map((item) => {
10924
+ const audioLevelData = yield pc.getAudioLevelReportData(gap);
10925
+ audioLevelData === null || audioLevelData === void 0 ? void 0 : audioLevelData.forEach(item => {
10888
10926
  const { userId } = parseTrackId(item.trackId);
10889
10927
  const isLocal = this._room.getCrtUserId() === userId;
10890
10928
  const track = isLocal ? this._room.getLocalTrack(item.trackId) : this._room.getRemoteTrack(item.trackId);
10891
- return {
10892
- track,
10893
- audioLevel: item.audioLevel || 0
10894
- };
10895
- }).filter((item) => {
10896
- return item.track;
10929
+ if (track) {
10930
+ audioLevelList.push({
10931
+ track,
10932
+ audioLevel: item.audioLevel || 0
10933
+ });
10934
+ }
10897
10935
  });
10898
- audioLevelList.push(...list);
10899
10936
  }
10900
10937
  this._audioLevelChangeHandler(audioLevelList);
10901
10938
  });
10902
10939
  }
10940
+ startAutoExecute(gap = 1000) {
10941
+ this._timer = setTimeout(() => {
10942
+ this._audioLevelReport(gap);
10943
+ this._timer = this.startAutoExecute(gap);
10944
+ }, gap);
10945
+ }
10946
+ stopAutoExecute() {
10947
+ clearTimeout(this._timer);
10948
+ }
10903
10949
  onAudioLevelChange(handler, gap) {
10904
10950
  if (gap < 300 || gap > 1000) {
10905
10951
  logger.error('the valid range of onAudioLevelChange params "gap" is: > 300 && < 1000');
@@ -10910,12 +10956,12 @@
10910
10956
  }
10911
10957
  else {
10912
10958
  this._audioLevelChangeHandler = handler;
10913
- this._timer = setInterval(this._audioLevelReport.bind(this), gap);
10959
+ this.startAutoExecute(gap);
10914
10960
  }
10915
10961
  }
10916
10962
  clearAudioLevelReportTimer() {
10917
10963
  if (this._timer) {
10918
- clearInterval(this._timer);
10964
+ this.stopAutoExecute();
10919
10965
  this._timer = null;
10920
10966
  }
10921
10967
  }
@@ -11661,14 +11707,7 @@
11661
11707
  }, { logSource: engine.LogSource.RTC });
11662
11708
  return { code: exports.RCRTCCode.SIGNAL_DISCONNECTED };
11663
11709
  }
11664
- if (isIllegalConnection(context.getNaviInfo())) {
11665
- engine.logger.error(logTag, {
11666
- status: RCLoggerStatus.FAILED,
11667
- code: exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,
11668
- msg: 'navi_usl error'
11669
- }, { logSource: engine.LogSource.RTC });
11670
- return { code: exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR };
11671
- }
11710
+ if (isIllegalConnection(context.getNaviInfo())) ;
11672
11711
  if (!engine.validate('roomId', this.roomId, engine.notEmptyString, true)) {
11673
11712
  engine.logger.error(logTag, {
11674
11713
  status: RCLoggerStatus.FAILED,
@@ -12127,7 +12166,7 @@
12127
12166
  users.forEach(item => {
12128
12167
  const userId = item.userId;
12129
12168
  if (+item.state === 0) {
12130
- logger.debug(`user joined -> ${userId}`);
12169
+ logger.info(`user joined -> ${userId}`);
12131
12170
  // 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
12132
12171
  const resArr = store.getResourcesByUserId(userId);
12133
12172
  if (!resArr) {
@@ -12136,7 +12175,7 @@
12136
12175
  store.setResourcesByUserId(userId, resArr || []);
12137
12176
  }
12138
12177
  else {
12139
- logger.debug(`user left -> ${userId}`);
12178
+ logger.info(`user left -> ${userId}`);
12140
12179
  item.switchRoleType ? downgrade.push(userId) : left.push(userId);
12141
12180
  }
12142
12181
  });
@@ -13517,12 +13556,14 @@
13517
13556
  }
13518
13557
  __parseInnerMessage(message) {
13519
13558
  const { targetId: roomId, conversationType } = message;
13520
- // 过滤非 RTC 消息
13521
- if (conversationType !== engine.ConversationType.RTC_ROOM) {
13522
- return false;
13523
- }
13524
13559
  // 为 RTC 消息,但不属于当前房间的不处理
13525
13560
  if (roomId !== this._roomId) {
13561
+ engine.logger.warn(RCLoggerTag.L_RTC_CLIENT_MESSAGE_O, {
13562
+ status: RCLoggerStatus.FAILED,
13563
+ message: `roomId is different, msg roomId-> ${roomId}, this._roomId-> ${this._roomId} `
13564
+ }, {
13565
+ logSource: engine.LogSource.RTC
13566
+ });
13526
13567
  return true;
13527
13568
  }
13528
13569
  logger.info(`recv inner msg -> message: ${JSON.stringify(message)} | roomid: ${this._roomId}`);
@@ -16775,16 +16816,7 @@
16775
16816
  logSource: engine.LogSource.RTC
16776
16817
  });
16777
16818
  const tracks = [];
16778
- if (isIllegalConnection(this._context.getNaviInfo())) {
16779
- engine.logger.error(RCLoggerTag.L_AUDIENCE_CLIENT_SUBSCRIBE_R, {
16780
- status: RCLoggerStatus.FAILED,
16781
- code: exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,
16782
- msg: 'navi_url error'
16783
- }, {
16784
- logSource: engine.LogSource.RTC
16785
- });
16786
- return { code: exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR, tracks };
16787
- }
16819
+ if (isIllegalConnection(this._context.getNaviInfo())) ;
16788
16820
  // 客户端主动调用 api 发请求时,清除 ice 断线重连的定时器
16789
16821
  !this._fromRetry && ((_a = this._pc) === null || _a === void 0 ? void 0 : _a.clearReTryExchangeTimer());
16790
16822
  this._fromRetry = false;
@@ -18794,7 +18826,6 @@
18794
18826
  this._context.onmessage = this._handleMessage.bind(this);
18795
18827
  }
18796
18828
  _handleMessage(message) {
18797
- var _a;
18798
18829
  // 过滤非 RTC 消息
18799
18830
  if (message.conversationType !== engine.ConversationType.RTC_ROOM) {
18800
18831
  return false;
@@ -18806,13 +18837,22 @@
18806
18837
  room.__parseInnerMessage(message);
18807
18838
  });
18808
18839
  }
18809
- (_a = this._crtRoom) === null || _a === void 0 ? void 0 : _a.__parseInnerMessage(message);
18810
18840
  engine.logger.info(RCLoggerTag.L_RTC_CLIENT_MESSAGE_O, {
18811
18841
  status: RCLoggerStatus.SUCCESSED,
18812
- message: Object.assign(message, { content: '内容涉及隐私不予显示' })
18842
+ message
18813
18843
  }, {
18814
18844
  logSource: engine.LogSource.RTC
18815
18845
  });
18846
+ if (!this._crtRoom) {
18847
+ engine.logger.warn(RCLoggerTag.L_RTC_CLIENT_MESSAGE_O, {
18848
+ status: RCLoggerStatus.FAILED,
18849
+ message: 'the crtRoom is empty'
18850
+ }, {
18851
+ logSource: engine.LogSource.RTC
18852
+ });
18853
+ return true;
18854
+ }
18855
+ this._crtRoom.__parseInnerMessage(message);
18816
18856
  return true;
18817
18857
  }
18818
18858
  /**
@@ -19015,16 +19055,7 @@
19015
19055
  }, {
19016
19056
  logSource: engine.LogSource.RTC
19017
19057
  });
19018
- if (isIllegalConnection(this._context.getNaviInfo())) {
19019
- engine.logger.error(RCLoggerTag.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R, {
19020
- status: RCLoggerStatus.FAILED,
19021
- code: exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,
19022
- msg: 'navi_url error'
19023
- }, {
19024
- logSource: engine.LogSource.RTC
19025
- });
19026
- return { code: exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR };
19027
- }
19058
+ if (isIllegalConnection(this._context.getNaviInfo())) ;
19028
19059
  if (!(engine.validate('roomId', roomId, engine.notEmptyString, true) &&
19029
19060
  engine.validate('livingType', livingType, (value) => value === exports.RCLivingType.AUDIO || value === exports.RCLivingType.VIDEO))) {
19030
19061
  engine.logger.error(RCLoggerTag.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R, {
@@ -19332,9 +19363,9 @@
19332
19363
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
19333
19364
  return false;
19334
19365
  }
19335
- engine.VersionManage.add('plugin-rtc', "5.4.7-alpha.4");
19336
- if (!engine.VersionManage.validEngine("5.3.4 - 5.4.5")) {
19337
- logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"5.3.4 - 5.4.5"}'.`);
19366
+ engine.VersionManage.add('plugin-rtc', "5.4.7-beem-enterprise.1");
19367
+ if (!engine.VersionManage.validEngine("5.4.2-beem-enterprise.2")) {
19368
+ logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"5.4.2-beem-enterprise.2"}'.`);
19338
19369
  return false;
19339
19370
  }
19340
19371
  return true;
@@ -19343,7 +19374,7 @@
19343
19374
  var _a, _b, _c, _d, _e, _f, _g, _h;
19344
19375
  logger.setLogLevel(options.logLevel);
19345
19376
  logger.setLogStdout(options.logStdout);
19346
- logger.warn(`RCRTC Version: ${"5.4.7-alpha.4"}, Commit: ${"1297531a6457c0e72d9fa276eee9a49a7b3c596e"}`);
19377
+ logger.warn(`RCRTC Version: ${"5.4.7-beem-enterprise.1"}, Commit: ${"f6d422487789e25a83b33d99ce339c2d264d3d88"}`);
19347
19378
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
19348
19379
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
19349
19380
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rongcloud/plugin-rtc",
3
- "version": "5.4.7-alpha.4",
3
+ "version": "5.4.7-beem-enterprise.1",
4
4
  "description": "@rongcloud/plugin-rtc",
5
5
  "main": "./dist/index.js",
6
6
  "__attrs__": {
@@ -31,7 +31,7 @@
31
31
  "node": ">=10.0.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@rongcloud/engine": "5.3.4 - 5.4.5"
34
+ "@rongcloud/engine": "5.4.2-beem-enterprise.2"
35
35
  },
36
- "__commit__": "1297531a6457c0e72d9fa276eee9a49a7b3c596e"
36
+ "__commit__": "f6d422487789e25a83b33d99ce339c2d264d3d88"
37
37
  }