@rongcloud/plugin-rtc 5.5.5-beem → 5.5.5-beem-alpha.4

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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.5.5-beem
3
- * CommitId - b8e57d36680c1d71921cded6b91771d4dfd4f3e8
4
- * Fri Oct 14 2022 19:54:22 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.5.5-beem-alpha.4
3
+ * CommitId - 0c078c138d99c8962f00f41c7d9a82e1d0f13b5a
4
+ * Thu Oct 20 2022 17:51:40 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  'use strict';
@@ -861,6 +861,38 @@ var RCLoggerTag;
861
861
  * 旧版日志
862
862
  */
863
863
  RCLoggerTag["L_OLD_DAILY_RECORD_O"] = "L-old_daily_record-O";
864
+ /**
865
+ * 远端用户加入房间后的本地存储的用户资源列表
866
+ */
867
+ RCLoggerTag["L_REMOTE_USER_JOINED_RESOURCES_O"] = "L-remote_user_joined_resources-O";
868
+ /**
869
+ * 远端用户在房间中状态变化的回调
870
+ */
871
+ RCLoggerTag["L_REMOTE_USER_STATE_HANDLE_O"] = "L-remote_user_state_handle-O";
872
+ /**
873
+ * 北极星 TCP 通道发送的数据类型
874
+ */
875
+ RCLoggerTag["L_CMP_POLARIS_REPORT_TYPE_O"] = "L-cmp_polaris_report_type-O";
876
+ /**
877
+ * 北极星 TCP 通道数据发送任务
878
+ */
879
+ RCLoggerTag["L_CMP_POLARIS_REPORT_T"] = "L-cmp_polaris_report-T";
880
+ /**
881
+ * 北极星 TCP 通道数据发送结果
882
+ */
883
+ RCLoggerTag["L_CMP_POLARIS_REPORT_R"] = "L-cmp_polaris_report-R";
884
+ /**
885
+ * 北极星 HTTP 通道发送数据任务
886
+ */
887
+ RCLoggerTag["L_HTTP_POLARIS_REPORT_T"] = "L-http_polaris_report-T";
888
+ /**
889
+ * 北极星 HTTP 通道发送数据结果
890
+ */
891
+ RCLoggerTag["L_HTTP_POLARIS_REPORT_R"] = "L-http_polaris_report-R";
892
+ /**
893
+ * 北极星 HTTP 通道发送数据类型
894
+ */
895
+ RCLoggerTag["L_HTTP_POLARIS_REPORT_TYPE_O"] = "L-http_polaris_report_type-O";
864
896
  })(RCLoggerTag || (RCLoggerTag = {}));
865
897
  var RCLoggerStatus;
866
898
  (function (RCLoggerStatus) {
@@ -14655,7 +14687,7 @@ const getCommonHeader$1 = () => ({
14655
14687
  'Content-Type': 'application/json;charset=UTF-8',
14656
14688
  'Cache-Control': 'no-cache',
14657
14689
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
14658
- ClientVersion: "5.5.5-beem",
14690
+ ClientVersion: "5.5.5-beem-alpha.4",
14659
14691
  'Client-Session-Id': getUUID(),
14660
14692
  'Request-Id': Date.now().toString(),
14661
14693
  });
@@ -14783,7 +14815,7 @@ class Memo {
14783
14815
  this._memo = new Memo();
14784
14816
  }
14785
14817
  // 方便调试使用
14786
- // (window as any).__memo__ = this._memo;
14818
+ window.__memo__ = this._memo;
14787
14819
  return this._memo;
14788
14820
  }
14789
14821
  static destroy() {
@@ -14795,7 +14827,7 @@ const getCommonHeader = () => ({
14795
14827
  'Content-Type': 'application/json;charset=UTF-8',
14796
14828
  'Cache-Control': 'no-cache',
14797
14829
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
14798
- ClientVersion: "5.5.5-beem",
14830
+ ClientVersion: "5.5.5-beem-alpha.4",
14799
14831
  'Client-Session-Id': getUUID(),
14800
14832
  'Request-Id': Date.now().toString(),
14801
14833
  });
@@ -15312,6 +15344,20 @@ class SdpResource {
15312
15344
  }
15313
15345
  }
15314
15346
 
15347
+ class SourceIdMap {
15348
+ constructor() { }
15349
+ static getInstance() {
15350
+ if (!this._instance) {
15351
+ this._instance = new Map([['sourceIdForPublishMap', new Map()], ['sourceIdForSubscribeMap', new Map()]]);
15352
+ }
15353
+ return this._instance;
15354
+ }
15355
+ static destroy() {
15356
+ this._instance = new Map([['sourceIdForPublishMap', new Map()], ['sourceIdForSubscribeMap', new Map()]]);
15357
+ }
15358
+ }
15359
+ SourceIdMap._instance = new Map([['sourceIdForPublishMap', new Map()], ['sourceIdForSubscribeMap', new Map()]]);
15360
+
15315
15361
  class AbstractStatParser {
15316
15362
  constructor(_rtcPeerConn, _sdpSemantics, _currentUserId) {
15317
15363
  this._rtcPeerConn = _rtcPeerConn;
@@ -15471,15 +15517,9 @@ class AbstractStatParser {
15471
15517
  }
15472
15518
  parseRTCStatsReport(reports) {
15473
15519
  const stats = {};
15474
- let flag = 0;
15475
- for (let name of reports.keys()) {
15476
- if (/RTCInbound/.test(name)) {
15477
- flag++;
15478
- }
15479
- }
15480
15520
  for (const key of reports.keys()) {
15481
15521
  // 过滤下行数据上报
15482
- if (!key.includes('RTCCodec_') && !(flag > 9 && key.includes('RTCInbound'))) {
15522
+ if (!key.includes('RTCCodec_')) {
15483
15523
  stats[key] = reports.get(key);
15484
15524
  }
15485
15525
  }
@@ -15508,31 +15548,21 @@ class AbstractStatParser {
15508
15548
  * @returns resourceId
15509
15549
  */
15510
15550
  getResourceIdByParseSdp(statInfo) {
15511
- var _a, _b;
15512
15551
  const { ssrc } = statInfo;
15513
15552
  const kind = statInfo.kind || statInfo.mediaType;
15514
- const offer = (_a = this._rtcPeerConn.currentLocalDescription) === null || _a === void 0 ? void 0 : _a.sdp;
15515
- const answer = (_b = this._rtcPeerConn.currentRemoteDescription) === null || _b === void 0 ? void 0 : _b.sdp;
15516
- let rule;
15517
- if (this._sdpSemantics === 'unified-plan') {
15518
- rule = new RegExp('a=msid:(.*?) ');
15519
- }
15520
- else {
15521
- rule = new RegExp(`a=ssrc:${ssrc} msid:(.*?) `);
15522
- }
15523
- const offerMArr = offer === null || offer === void 0 ? void 0 : offer.split('\r\nm=');
15524
- const selectOfferM = offerMArr === null || offerMArr === void 0 ? void 0 : offerMArr.filter((item) => item.includes(`a=ssrc:${ssrc}`))[0];
15525
- const matchOffer = selectOfferM === null || selectOfferM === void 0 ? void 0 : selectOfferM.match(rule);
15526
- let msid = matchOffer ? matchOffer[1] : '';
15527
- if (msid) {
15553
+ const sourceIdMap = SourceIdMap.getInstance();
15554
+ const sourceIdForPublishMap = sourceIdMap.get('sourceIdForPublishMap');
15555
+ const sourceIdForSubscribeMap = sourceIdMap.get('sourceIdForSubscribeMap');
15556
+ let publishRes = sourceIdForPublishMap === null || sourceIdForPublishMap === void 0 ? void 0 : sourceIdForPublishMap.get(String(ssrc));
15557
+ if (publishRes) {
15528
15558
  if (kind === 'audio') {
15529
- return `${msid}_0`;
15559
+ return `${publishRes}_0`;
15530
15560
  }
15531
15561
  /**
15532
15562
  * msid 为 userId_tag 或 userId_tag_tiny
15533
15563
  * 截取完 userId 之后,仅剩 tag 或 tag_tiny
15534
15564
  */
15535
- const tag = msid.replace(`${this._currentUserId}_`, '');
15565
+ const tag = publishRes.replace(`${this._currentUserId}_`, '');
15536
15566
  const splitTag = tag.split('_');
15537
15567
  /**
15538
15568
  * tag 或 tag_tiny 最后一位为 tiny,且长度大于 1 时为视频小流
@@ -15541,13 +15571,10 @@ class AbstractStatParser {
15541
15571
  return `${this._currentUserId}_${splitTag[0]}_1_tiny`;
15542
15572
  }
15543
15573
  // 视频大流
15544
- return `${msid}_1`;
15574
+ return `${publishRes}_1`;
15545
15575
  }
15546
- const answerMArr = answer === null || answer === void 0 ? void 0 : answer.split('\r\nm=');
15547
- const selectAnswerM = answerMArr === null || answerMArr === void 0 ? void 0 : answerMArr.filter((item) => item.includes(`a=ssrc:${ssrc}`))[0];
15548
- const matchAnswer = selectAnswerM === null || selectAnswerM === void 0 ? void 0 : selectAnswerM.match(rule);
15549
- msid = matchAnswer ? matchAnswer[1] : '';
15550
- return msid ? `${msid}_${kind === 'video' ? 1 : 0}` : '';
15576
+ let subscribeRes = sourceIdForSubscribeMap === null || sourceIdForSubscribeMap === void 0 ? void 0 : sourceIdForSubscribeMap.get(String(ssrc));
15577
+ return subscribeRes ? `${subscribeRes}_${kind === 'video' ? 1 : 0}` : '';
15551
15578
  }
15552
15579
  /**
15553
15580
  * 从 offer sdp 中查找 ssrc 对应的通道是否可用
@@ -15572,6 +15599,34 @@ class AbstractStatParser {
15572
15599
  return !valid;
15573
15600
  }
15574
15601
  }
15602
+ /**
15603
+ * 从sdp中解析出ssrc和msid并缓存
15604
+ * @param sdp string
15605
+ */
15606
+ AbstractStatParser.formatSourceIdMapFromSdp = (sdp, type) => {
15607
+ let rule = /a=ssrc:(.*) msid:(.*?) /ig;
15608
+ const sourceIdMap = SourceIdMap.getInstance();
15609
+ const matchList = sdp === null || sdp === void 0 ? void 0 : sdp.match(rule);
15610
+ if (!matchList) {
15611
+ return;
15612
+ }
15613
+ if (type === 'publish') {
15614
+ const sourceIdForPublishMap = sourceIdMap.get('sourceIdForPublishMap');
15615
+ sourceIdForPublishMap === null || sourceIdForPublishMap === void 0 ? void 0 : sourceIdForPublishMap.clear();
15616
+ matchList.forEach((item) => {
15617
+ const [ssrc, msid] = item.split(' ').map((child) => child.split(':')[1]);
15618
+ sourceIdForPublishMap === null || sourceIdForPublishMap === void 0 ? void 0 : sourceIdForPublishMap.set(ssrc, msid);
15619
+ });
15620
+ }
15621
+ if (type === 'subscribe') {
15622
+ const sourceIdForSubscribeMap = sourceIdMap.get('sourceIdForSubscribeMap');
15623
+ sourceIdForSubscribeMap === null || sourceIdForSubscribeMap === void 0 ? void 0 : sourceIdForSubscribeMap.clear();
15624
+ matchList.forEach((item) => {
15625
+ const [ssrc, msid] = item.split(' ').map((child) => child.split(':')[1]);
15626
+ sourceIdForSubscribeMap === null || sourceIdForSubscribeMap === void 0 ? void 0 : sourceIdForSubscribeMap.set(ssrc, msid);
15627
+ });
15628
+ }
15629
+ };
15575
15630
 
15576
15631
  /**
15577
15632
  * chrome 73 无 type 为 remote-inbound-rtp 的数据,上行拿不到 jetter、rtt、packetsLost 数据
@@ -17683,8 +17738,8 @@ class RCRTCPeerConnection extends engine.EventEmitter {
17683
17738
  return {
17684
17739
  timestamp,
17685
17740
  iceCandidatePair,
17686
- senders: newSenders,
17687
- receivers: newReceivers,
17741
+ senders: newSenders.filter((item) => item.trackId),
17742
+ receivers: newReceivers.filter((item) => item.trackId),
17688
17743
  pcName: this._pcName,
17689
17744
  };
17690
17745
  }
@@ -17964,14 +18019,15 @@ class PolarisReporter {
17964
18019
  this._userRole = _userRole;
17965
18020
  }
17966
18021
  _send(report) {
18022
+ var _a, _b, _c, _d;
17967
18023
  return __awaiter(this, void 0, void 0, function* () {
17968
18024
  if (this._context.getConnectionStatus() !== engine.ConnectionStatus.CONNECTED) {
17969
18025
  return RCSendCode.NOT_REPORT;
17970
18026
  }
17971
- console.log('回落 CMP 通道');
18027
+ (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_CMP_POLARIS_REPORT_T, 'start send data by TCP');
17972
18028
  const rCSendCode = yield this._context.setRTCState(this._roomId, report);
17973
18029
  if (rCSendCode === engine.ErrorCode.SUCCESS) {
17974
- console.log('CMP 通道发送成功');
18030
+ (_d = (_c = this._context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_CMP_POLARIS_REPORT_R, `send data success -> code: ${rCSendCode}`);
17975
18031
  return RCSendCode.REPORT_SUCCESS;
17976
18032
  }
17977
18033
  return RCSendCode.REPORT_FAIL;
@@ -18018,6 +18074,7 @@ class PolarisReporter {
18018
18074
  return polarisTrackId;
18019
18075
  }
18020
18076
  sendR3R4Data(data) {
18077
+ var _a, _b, _c, _d, _e, _f;
18021
18078
  return __awaiter(this, void 0, void 0, function* () {
18022
18079
  const { iceCandidatePair, senders, receivers } = data;
18023
18080
  /**
@@ -18102,14 +18159,14 @@ class PolarisReporter {
18102
18159
  let senderCode = RCSendCode.REPORT_FAIL;
18103
18160
  r3 += R3TrackData.map((item) => `${item.trackId}\t${item.googCodecName}\t${item.audioLevel}\t${item.samplingRate}\t${item.bitrate}\t${item.packetsLostRate}\t${item.frameRate}\t${item.resolution}\t${item.googRenderDelayMs}\t${item.jitter}\t${item.nackCount}\t${item.pliCount}\t${item.rtt}\t${item.googFirsSent}\t${item.encoderImplementation}\t${item.trackState}`).join('\n');
18104
18161
  if (data.senders.length) {
18162
+ (_c = (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info) === null || _c === void 0 ? void 0 : _c.call(_b, RCLoggerTag.L_CMP_POLARIS_REPORT_TYPE_O, 'send data type -> R3');
18105
18163
  senderCode = yield this._send(`${r3}\r${this._userRole}`);
18106
- console.log('回落R3发送成功 ->', `${r3}\r${this._userRole}`);
18107
18164
  }
18108
18165
  let receiverCode = RCSendCode.REPORT_FAIL;
18109
18166
  r4 += R4TrackData.map((item) => `${item.trackId}\t${item.googCodecName}\t${item.audioLevel}\t${item.samplingRate}\t${item.bitrate}\t${item.packetsLostRate}\t${item.frameRate}\t${item.resolution}\t${item.googRenderDelayMs}\t${item.jitter}\t${item.nackCount}\t${item.pliCount}\t${item.rtt}\t${item.googFirsReceived}\t${item.codecImplementationName}\t${item.trackState}`).join('\n');
18110
18167
  if (data.receivers.length) {
18168
+ (_f = (_e = (_d = this._context) === null || _d === void 0 ? void 0 : _d.logger) === null || _e === void 0 ? void 0 : _e.info) === null || _f === void 0 ? void 0 : _f.call(_e, RCLoggerTag.L_CMP_POLARIS_REPORT_TYPE_O, 'send data type -> R4');
18111
18169
  receiverCode = yield this._send(`${r4}\r${this._userRole}`);
18112
- console.log('回落R4发送成功 ->', `${r4}\r${this._userRole}`);
18113
18170
  }
18114
18171
  if (senderCode !== RCSendCode.REPORT_SUCCESS && receiverCode !== RCSendCode.REPORT_SUCCESS) {
18115
18172
  return RCSendCode.REPORT_FAIL;
@@ -18121,7 +18178,8 @@ class PolarisReporter {
18121
18178
  * 加入房间
18122
18179
  */
18123
18180
  sendR1() {
18124
- const rtcVersion = "5.5.5-beem";
18181
+ var _a, _b, _c;
18182
+ const rtcVersion = "5.5.5-beem-alpha.4";
18125
18183
  const imVersion = this._context.getCoreVersion();
18126
18184
  const platform = 'web';
18127
18185
  const pcName = navigator.platform;
@@ -18130,18 +18188,19 @@ class PolarisReporter {
18130
18188
  const browserVersion = browserInfo.version;
18131
18189
  const deviceId = this._getClientID();
18132
18190
  const r1 = `R1\t${rtcVersion}\t${imVersion}\t${platform}\t${pcName}\t${pcVersion}\t${browserName}\t${browserVersion}\t${deviceId}\t${this._userRole}`;
18191
+ (_c = (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info) === null || _c === void 0 ? void 0 : _c.call(_b, RCLoggerTag.L_CMP_POLARIS_REPORT_TYPE_O, 'send data type -> R1');
18133
18192
  this._send(r1);
18134
- console.log('回落R1发送成功 ->', r1);
18135
18193
  }
18136
18194
  /**
18137
18195
  * RTC 和 LIVE 发布、取消发布
18138
18196
  * RTC 订阅、取消订阅
18139
18197
  */
18140
18198
  sendR2(action, status, trackIds) {
18199
+ var _a, _b, _c;
18141
18200
  const deviceId = this._getClientID();
18142
18201
  const r2 = `R2\t${action}\t${status}\t${deviceId}\r${trackIds.join('\t')}\r${this._userRole}`;
18202
+ (_c = (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info) === null || _c === void 0 ? void 0 : _c.call(_b, RCLoggerTag.L_CMP_POLARIS_REPORT_TYPE_O, 'send data type -> R2');
18143
18203
  this._send(r2);
18144
- console.log('回落R2发送成功 ->', r2);
18145
18204
  }
18146
18205
  }
18147
18206
 
@@ -18158,7 +18217,7 @@ class PolarisHttpReporter {
18158
18217
  this._polarisSignalReporter = new PolarisReporter(_context, _runtime, _roomId, _crtRTCRoom, _userRole);
18159
18218
  }
18160
18219
  _send(report, reportType) {
18161
- var _a;
18220
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
18162
18221
  return __awaiter(this, void 0, void 0, function* () {
18163
18222
  if (this._context.getConnectionStatus() !== engine.ConnectionStatus.CONNECTED) {
18164
18223
  return RCSendCode.NOT_REPORT;
@@ -18170,19 +18229,21 @@ class PolarisHttpReporter {
18170
18229
  if (!logServer || !this._useHttp || !RCMediaService.jwtToken) {
18171
18230
  return RCSendCode.REPORT_FAIL;
18172
18231
  }
18232
+ (_c = (_b = this._context) === null || _b === void 0 ? void 0 : _b.logger) === null || _c === void 0 ? void 0 : _c.info(RCLoggerTag.L_HTTP_POLARIS_REPORT_T, 'start send data by http');
18173
18233
  const code = yield this._context.setRTCStateByHttp(logServer, this._runtime, report, reportType);
18174
18234
  if (code === RCSendCode.REPORT_SUCCESS) {
18175
- console.log('http 通道发送成功');
18235
+ (_e = (_d = this._context) === null || _d === void 0 ? void 0 : _d.logger) === null || _e === void 0 ? void 0 : _e.info(RCLoggerTag.L_HTTP_POLARIS_REPORT_R, `send data success -> code: ${code}`);
18176
18236
  return RCSendCode.REPORT_SUCCESS;
18177
18237
  }
18178
18238
  // jwt 失效,重新请求 naviInfo
18179
18239
  if (code === exports.RCRTCCode.JWT_TIME_OUT) {
18180
- console.log('jwt 失效');
18240
+ (_g = (_f = this._context) === null || _f === void 0 ? void 0 : _f.logger) === null || _g === void 0 ? void 0 : _g.info(RCLoggerTag.L_HTTP_POLARIS_REPORT_R, `jwt expired -> code: ${code}`);
18181
18241
  this._refetchNaviInfo();
18182
18242
  return RCSendCode.REPORT_FAIL;
18183
18243
  }
18184
18244
  // 其他错误情况
18185
18245
  if (code === RCSendCode.REPORT_FAIL || code === RCSendCode.PB_ERROR) {
18246
+ (_j = (_h = this._context) === null || _h === void 0 ? void 0 : _h.logger) === null || _j === void 0 ? void 0 : _j.info(RCLoggerTag.L_HTTP_POLARIS_REPORT_R, `send data fail -> code: ${code}`);
18186
18247
  this._useHttp = false;
18187
18248
  return RCSendCode.REPORT_FAIL;
18188
18249
  }
@@ -18270,13 +18331,14 @@ class PolarisHttpReporter {
18270
18331
  _formatR1Data() {
18271
18332
  return {
18272
18333
  joinTime: this._context.userJoinTime || 0,
18273
- rtcVersion: "5.5.5-beem",
18334
+ rtcVersion: "5.5.5-beem-alpha.4",
18274
18335
  imVersion: this._context.getCoreVersion(),
18275
18336
  platform: 'web',
18276
18337
  device: navigator.platform,
18277
18338
  os: String(STAT_NONE),
18278
18339
  browserName: browserInfo.browser,
18279
18340
  browserVersion: String(browserInfo.version),
18341
+ receiveTime: Date.now(),
18280
18342
  };
18281
18343
  }
18282
18344
  _formatR2Data(params) {
@@ -18287,6 +18349,7 @@ class PolarisHttpReporter {
18287
18349
  rtcActionType: action,
18288
18350
  rtcActionStatus: status,
18289
18351
  trackId: trackIds,
18352
+ receiveTime: Date.now(),
18290
18353
  };
18291
18354
  }
18292
18355
  _formatR3R4Data(reportType, params) {
@@ -18369,11 +18432,12 @@ class PolarisHttpReporter {
18369
18432
  };
18370
18433
  }
18371
18434
  sendR3R4Data(data) {
18435
+ var _a, _b, _c, _d;
18372
18436
  return __awaiter(this, void 0, void 0, function* () {
18373
18437
  let senderCode = RCSendCode.REPORT_FAIL;
18374
18438
  if (data.senders.length) {
18375
18439
  const r3Info = this._formatReportData(RCReportType.R3, data);
18376
- console.log('发送r3Info ->', r3Info);
18440
+ (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_HTTP_POLARIS_REPORT_TYPE_O, 'send data type -> R3');
18377
18441
  senderCode = yield this._send(r3Info, RCReportType.R3);
18378
18442
  // 回落 R3
18379
18443
  if (senderCode === RCSendCode.REPORT_FAIL) {
@@ -18383,7 +18447,7 @@ class PolarisHttpReporter {
18383
18447
  let receiverCode = RCSendCode.REPORT_FAIL;
18384
18448
  if (data.receivers.length) {
18385
18449
  const r4Info = this._formatReportData(RCReportType.R4, data);
18386
- console.log('发送r4Info ->', r4Info);
18450
+ (_d = (_c = this._context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_HTTP_POLARIS_REPORT_TYPE_O, 'send data type -> R4');
18387
18451
  receiverCode = yield this._send(r4Info, RCReportType.R4);
18388
18452
  // 回落 R4
18389
18453
  if (receiverCode === RCSendCode.REPORT_FAIL) {
@@ -18400,14 +18464,14 @@ class PolarisHttpReporter {
18400
18464
  * 加入房间
18401
18465
  */
18402
18466
  sendR1() {
18403
- var _a;
18467
+ var _a, _b, _c;
18404
18468
  return __awaiter(this, void 0, void 0, function* () {
18405
18469
  const r1Info = this._formatReportData(RCReportType.R1);
18406
- console.log('发送r1Info ->', r1Info);
18470
+ (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_HTTP_POLARIS_REPORT_TYPE_O, 'send data type -> R1');
18407
18471
  const sendCode = yield this._send(r1Info, RCReportType.R1);
18408
18472
  // 回落 R1
18409
18473
  if (sendCode === RCSendCode.REPORT_FAIL) {
18410
- (_a = this._polarisSignalReporter) === null || _a === void 0 ? void 0 : _a.sendR1();
18474
+ (_c = this._polarisSignalReporter) === null || _c === void 0 ? void 0 : _c.sendR1();
18411
18475
  }
18412
18476
  });
18413
18477
  }
@@ -18416,14 +18480,14 @@ class PolarisHttpReporter {
18416
18480
  * RTC 订阅、取消订阅
18417
18481
  */
18418
18482
  sendR2(action, status, trackIds) {
18419
- var _a;
18483
+ var _a, _b, _c;
18420
18484
  return __awaiter(this, void 0, void 0, function* () {
18421
18485
  const r2Info = this._formatReportData(RCReportType.R2, { action, status, trackIds });
18422
- console.log('发送r2Info ->', r2Info);
18486
+ (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_HTTP_POLARIS_REPORT_TYPE_O, 'send data type -> R2');
18423
18487
  const sendCode = yield this._send(r2Info, RCReportType.R2);
18424
18488
  // 回落 R2
18425
18489
  if (sendCode === RCSendCode.REPORT_FAIL) {
18426
- (_a = this._polarisSignalReporter) === null || _a === void 0 ? void 0 : _a.sendR2(action, status, trackIds);
18490
+ (_c = this._polarisSignalReporter) === null || _c === void 0 ? void 0 : _c.sendR2(action, status, trackIds);
18427
18491
  }
18428
18492
  });
18429
18493
  }
@@ -19784,6 +19848,8 @@ class UpdateSubscribeListCommand extends BaseCommand {
19784
19848
  }
19785
19849
  return { code: resCode };
19786
19850
  }
19851
+ // 缓存订阅资源的ssrc和msid
19852
+ AbstractStatParser.formatSourceIdMapFromSdp(answer.sdp, 'subscribe');
19787
19853
  // 连通率相关埋点-订阅日志上报
19788
19854
  let msas = [];
19789
19855
  let dateNow = Date.now();
@@ -20187,6 +20253,7 @@ function transPullDataToStateMsgCont(data) {
20187
20253
  };
20188
20254
  return content;
20189
20255
  }
20256
+ const isIncludeUris = (userData) => userData.some((item) => (item.key === 'uris' || item.key === 'cdn_uris'));
20190
20257
  /**
20191
20258
  * 通知拉取到的增量房间数据格式为 IRoomStatus
20192
20259
  * 把 IRoomStatus 转化为通用解析资源方法(ParseRemoteResCommand)需要的数据
@@ -20194,13 +20261,21 @@ function transPullDataToStateMsgCont(data) {
20194
20261
  function transPullDataToResMsgCont(data) {
20195
20262
  var _a, _b;
20196
20263
  const { userId, userData } = data;
20264
+ /**
20265
+ * PullRoomStatusEvent 为 3 时,并不全代表资源变动,
20266
+ * 房间内设置的其他 key value,也会被拉下来,event 为 3
20267
+ */
20268
+ const hasUris = isIncludeUris(userData);
20269
+ if (!hasUris) {
20270
+ return;
20271
+ }
20197
20272
  const uris = (_a = userData.filter((item) => (item.key === 'uris'))[0]) === null || _a === void 0 ? void 0 : _a.value;
20198
20273
  const cdnUris = (_b = userData.filter((item) => (item.key === 'cdn_uris'))[0]) === null || _b === void 0 ? void 0 : _b.value;
20199
20274
  return {
20200
20275
  userId,
20201
20276
  content: {
20202
- uris: uris && JSON.parse(uris),
20203
- cdn_uris: cdnUris && JSON.parse(cdnUris),
20277
+ uris: (uris && JSON.parse(uris)),
20278
+ cdn_uris: (cdnUris && JSON.parse(cdnUris)),
20204
20279
  },
20205
20280
  };
20206
20281
  }
@@ -20279,19 +20354,20 @@ class ParseUserStateCommand extends BaseCommand {
20279
20354
  }
20280
20355
  }
20281
20356
  users.forEach((item) => {
20282
- var _a, _b, _c, _d;
20357
+ var _a, _b, _c, _d, _e, _f;
20283
20358
  const { userId } = item;
20284
20359
  if (Number(item.state) === 0) {
20285
20360
  (_b = (_a = store === null || store === void 0 ? void 0 : store.context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, `user joined -> ${userId}`);
20286
20361
  // 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
20287
20362
  const resArr = store.getResourcesByUserId(userId);
20363
+ (_d = (_c = store === null || store === void 0 ? void 0 : store.context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_REMOTE_USER_JOINED_RESOURCES_O, `resources list -> ${resArr}`);
20288
20364
  if (!resArr) {
20289
20365
  item.switchRoleType ? upgrade.push(userId) : joined.push(userId);
20290
20366
  }
20291
20367
  store.setResourcesByUserId(userId, resArr || []);
20292
20368
  }
20293
20369
  else {
20294
- (_d = (_c = store.context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, `user left -> ${userId}`);
20370
+ (_f = (_e = store.context) === null || _e === void 0 ? void 0 : _e.logger) === null || _f === void 0 ? void 0 : _f.info(RCLoggerTag.L_OLD_DAILY_RECORD_O, `user left -> ${userId}`);
20295
20371
  item.switchRoleType ? downgrade.push(userId) : left.push(userId);
20296
20372
  }
20297
20373
  });
@@ -20693,6 +20769,8 @@ class PublishCommand extends BaseCommand {
20693
20769
  (_h = (_g = store.context) === null || _g === void 0 ? void 0 : _g.logger) === null || _h === void 0 ? void 0 : _h.info(RCLoggerTag.L_QS_PUBLISH_EXCHANGE_O, JSON.stringify({
20694
20770
  identify: qualityStatusId,
20695
20771
  }));
20772
+ // 缓存发布资源的ssrc和msid
20773
+ AbstractStatParser.formatSourceIdMapFromSdp(reqBody.sdp.sdp, 'publish');
20696
20774
  const resp = yield new ExchangeCommand(headers, reqBody).execute(store, invoker);
20697
20775
  if (resp.code !== exports.RCRTCCode.SUCCESS) {
20698
20776
  // 连通率相关埋点-发布资源结束
@@ -21753,14 +21831,14 @@ var PullRoomStatusEvent;
21753
21831
  })(PullRoomStatusEvent || (PullRoomStatusEvent = {}));
21754
21832
 
21755
21833
  class PullRTCRoomStatusCommand extends BaseCommand {
21756
- constructor(_roomId, _traceId, _context, _callbacks, _subhook, _stateHandle) {
21834
+ constructor(_roomId, _traceId, _context, _callbacks, _subhook, _dealUserAppListener) {
21757
21835
  super();
21758
21836
  this._roomId = _roomId;
21759
21837
  this._traceId = _traceId;
21760
21838
  this._context = _context;
21761
21839
  this._callbacks = _callbacks;
21762
21840
  this._subhook = _subhook;
21763
- this._stateHandle = _stateHandle;
21841
+ this._dealUserAppListener = _dealUserAppListener;
21764
21842
  }
21765
21843
  execute(store, invoker) {
21766
21844
  var _a, _b;
@@ -21796,15 +21874,27 @@ class PullRTCRoomStatusCommand extends BaseCommand {
21796
21874
  for (let index = 0; index < roomStatus.length; index++) {
21797
21875
  const item = roomStatus[index];
21798
21876
  if (item.event === PullRoomStatusEvent.RESOURCECHANGE) {
21799
- const { content, userId } = transPullDataToResMsgCont(item);
21877
+ const resData = transPullDataToResMsgCont(item);
21878
+ /**
21879
+ * 无 uris 或 cdn_uris 时,无需继续执行解析资源数据
21880
+ */
21881
+ if (!resData) {
21882
+ continue;
21883
+ }
21884
+ const { content, userId } = resData;
21800
21885
  if (userId === store.crtUserId) {
21801
21886
  continue;
21802
21887
  }
21803
21888
  yield new ParseRemoteResCommand(content, RCRTCMessageType.TOTAL_CONTENT_RESOURCE, userId, this._subhook.bind(this), this._callbacks).execute(store, invoker);
21804
21889
  }
21805
21890
  else {
21891
+ /**
21892
+ * 转化拉到的房间数据为通用解析人员方法需要的格式
21893
+ * 处理解析完的结果
21894
+ */
21806
21895
  const content = transPullDataToStateMsgCont(item);
21807
- this._stateHandle(content);
21896
+ const userData = yield new ParseUserStateCommand(content, this._subhook.bind(this)).execute(store, invoker);
21897
+ this._dealUserAppListener(userData);
21808
21898
  }
21809
21899
  }
21810
21900
  return { code };
@@ -21888,7 +21978,7 @@ class RCAbstractRoom extends engine.EventEmitter {
21888
21978
  onTrackPublish: this._onTrackPublish.bind(this),
21889
21979
  onTrackUnpublish: this._onTrackUnpublish.bind(this),
21890
21980
  onCDNEnableChange: this._callAppListener.bind(this, 'onCDNEnableChange'),
21891
- }, this._subhook.bind(this), this._stateHandle.bind(this)));
21981
+ }, this._subhook.bind(this), this._dealUserAppListener.bind(this)));
21892
21982
  });
21893
21983
  }
21894
21984
  __innerInit(mode, joinType, livingType, innerUserDatas, outerUserDatas) {
@@ -22128,30 +22218,40 @@ class RCAbstractRoom extends engine.EventEmitter {
22128
22218
  * @param content
22129
22219
  */
22130
22220
  _stateHandle(content) {
22131
- var _a;
22132
22221
  return __awaiter(this, void 0, void 0, function* () {
22133
- const { left, joined, upgrade, downgrade, } = yield this._invoker.push(new ParseUserStateCommand(content, this._subhook.bind(this)));
22134
- /**
22135
- * 通知业务层
22136
- * 有 onSwitchRole 监听时,按 switchRole 分“角色切换、加入房间、退出房间”抛出
22137
- */
22138
- if ((_a = this._appListener) === null || _a === void 0 ? void 0 : _a.onSwitchRole) {
22139
- upgrade.length && upgrade.forEach((userId) => this._callAppListener('onSwitchRole', userId, exports.RCRTCLiveRole.ANCHOR));
22140
- downgrade.length && downgrade.forEach((userId) => this._callAppListener('onSwitchRole', userId, exports.RCRTCLiveRole.AUDIENCE));
22141
- joined.length && this._callAppListener('onUserJoin', joined);
22142
- left.length && this._callAppListener('onUserLeave', left);
22143
- return;
22144
- }
22145
- const allJoined = [...joined, ...upgrade];
22146
- const allLeft = [...left, ...downgrade];
22147
- /**
22148
- * 通知业务层
22149
- * 无 onSwitchRole 监听时,统一按“加入房间、退出房间”抛出
22150
- */
22151
- allJoined.length && this._callAppListener('onUserJoin', allJoined);
22152
- allLeft.length && this._callAppListener('onUserLeave', allLeft);
22222
+ const userData = yield this._invoker.push(new ParseUserStateCommand(content, this._subhook.bind(this)));
22223
+ this._dealUserAppListener(userData);
22153
22224
  });
22154
22225
  }
22226
+ /**
22227
+ * 处理人员应用层事件
22228
+ */
22229
+ _dealUserAppListener(userData) {
22230
+ var _a, _b, _c;
22231
+ const { left, joined, upgrade, downgrade, } = userData;
22232
+ (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.logger) === null || _b === void 0 ? void 0 : _b.info(RCLoggerTag.L_REMOTE_USER_STATE_HANDLE_O, JSON.stringify({
22233
+ left, joined, upgrade, downgrade,
22234
+ }));
22235
+ /**
22236
+ * 通知业务层
22237
+ * 有 onSwitchRole 监听时,按 switchRole 分“角色切换、加入房间、退出房间”抛出
22238
+ */
22239
+ if ((_c = this._appListener) === null || _c === void 0 ? void 0 : _c.onSwitchRole) {
22240
+ upgrade.length && upgrade.forEach((userId) => this._callAppListener('onSwitchRole', userId, exports.RCRTCLiveRole.ANCHOR));
22241
+ downgrade.length && downgrade.forEach((userId) => this._callAppListener('onSwitchRole', userId, exports.RCRTCLiveRole.AUDIENCE));
22242
+ joined.length && this._callAppListener('onUserJoin', joined);
22243
+ left.length && this._callAppListener('onUserLeave', left);
22244
+ return;
22245
+ }
22246
+ const allJoined = [...joined, ...upgrade];
22247
+ const allLeft = [...left, ...downgrade];
22248
+ /**
22249
+ * 通知业务层
22250
+ * 无 onSwitchRole 监听时,统一按“加入房间、退出房间”抛出
22251
+ */
22252
+ allJoined.length && this._callAppListener('onUserJoin', allJoined);
22253
+ allLeft.length && this._callAppListener('onUserLeave', allLeft);
22254
+ }
22155
22255
  /**
22156
22256
  * 获取房间 Id
22157
22257
  */
@@ -25242,6 +25342,8 @@ class RCAudienceClient {
25242
25342
  }));
25243
25343
  // 无需等待 setRemoteAnswer 完成,直接返回,避免业务层拿到 tracks 之前先获取了 onTrackReady 通知
25244
25344
  this._pc.setRemoteAnswer(answer.sdp);
25345
+ // 缓存订阅资源的ssrc和msid
25346
+ AbstractStatParser.formatSourceIdMapFromSdp(answer.sdp, 'subscribe');
25245
25347
  (_16 = (_15 = this._context) === null || _15 === void 0 ? void 0 : _15.logger) === null || _16 === void 0 ? void 0 : _16.info(RCLoggerTag.L_AUDIENCE_CLIENT_SUBSCRIBE_R, JSON.stringify({
25246
25348
  status: RCLoggerStatus.SUCCESSED,
25247
25349
  liveUrl,
@@ -27803,7 +27905,7 @@ class RCRTCClient extends RCMediaStreamCapture {
27803
27905
  }
27804
27906
  reportSDKInfo() {
27805
27907
  this._context.reportSDKInfo({
27806
- 'plugin-rtc': "5.5.5-beem",
27908
+ 'plugin-rtc': "5.5.5-beem-alpha.4",
27807
27909
  });
27808
27910
  }
27809
27911
  }
@@ -28178,6 +28280,7 @@ message probuf {
28178
28280
  required string os = 6;//系统版本(手机系统版本)
28179
28281
  optional string browserName = 7; //浏览器名称, 没有用 -1 表示
28180
28282
  optional string browserVersion = 8;//浏览器版本, 没有用 -1 表示
28283
+ optional int64 receiveTime = 9; // 发送数据的时间
28181
28284
  }
28182
28285
  message ${RTCPB.RtcPBR2Info} {
28183
28286
  required int64 joinTime = 1;
@@ -28185,6 +28288,7 @@ message probuf {
28185
28288
  required string rtcActionType = 3;//发布类型 subscribe : 订阅 publish : 发布
28186
28289
  required string rtcActionStatus = 4;//发布状态 begin : 开始 tend : 结束
28187
28290
  repeated string trackId = 5;
28291
+ optional int64 receiveTime = 6; // 发送数据的时间
28188
28292
  }
28189
28293
  message ${RTCPB.RtcPBR3Info} {
28190
28294
  required ${RTCPB.RtcPBStatusInfo} info = 1;
@@ -28504,7 +28608,7 @@ class RTCContext {
28504
28608
  headers: {
28505
28609
  jwt: RCMediaService.jwtToken,
28506
28610
  },
28507
- timeout: 5 * 1000,
28611
+ timeout: 2 * 1000,
28508
28612
  });
28509
28613
  if (!res.data) {
28510
28614
  throw new Error('http request fail');
@@ -28795,7 +28899,7 @@ const installer = {
28795
28899
  console.error('Please use the https protocol or use `http://localhost` to open the page!');
28796
28900
  return false;
28797
28901
  }
28798
- engine.VersionManage.add('plugin-rtc', "5.5.5-beem");
28902
+ engine.VersionManage.add('plugin-rtc', "5.5.5-beem-alpha.4");
28799
28903
  if (!engine.VersionManage.validEngine("^5.6.0-beem")) {
28800
28904
  console.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"^5.6.0-beem"}'.`);
28801
28905
  return false;
@@ -28808,8 +28912,8 @@ const installer = {
28808
28912
  logger.setOutputLevel(options.logLevel || engine.LogL.DEBUG);
28809
28913
  RTCLogger.setLogger(logger);
28810
28914
  logger.warn(RCLoggerTag.L_INDEX_INSTALL_RTC_PLUGIN_O, JSON.stringify({
28811
- 'RCRTC Version': "5.5.5-beem",
28812
- Commit: "b8e57d36680c1d71921cded6b91771d4dfd4f3e8",
28915
+ 'RCRTC Version': "5.5.5-beem-alpha.4",
28916
+ Commit: "0c078c138d99c8962f00f41c7d9a82e1d0f13b5a",
28813
28917
  'browserInfo.browser': browserInfo.browser,
28814
28918
  'browserInfo.supportsUnifiedPlan': browserInfo.supportsUnifiedPlan,
28815
28919
  'browserInfo.version': browserInfo.version,