@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.esm.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
  import { Logger, EventEmitter, isNumber, validate, isObject as isObject$1, ErrorCode, HttpMethod, isArray, ConnectionStatus, notEmptyObject, notEmptyArray, notEmptyString, isString, RTCMode as RTCMode$1, assert, ConversationType, isHttpUrl, isBoolean, isUndefined, forEach, VersionManage, LogL } from '@rongcloud/engine';
@@ -857,6 +857,38 @@ var RCLoggerTag;
857
857
  * 旧版日志
858
858
  */
859
859
  RCLoggerTag["L_OLD_DAILY_RECORD_O"] = "L-old_daily_record-O";
860
+ /**
861
+ * 远端用户加入房间后的本地存储的用户资源列表
862
+ */
863
+ RCLoggerTag["L_REMOTE_USER_JOINED_RESOURCES_O"] = "L-remote_user_joined_resources-O";
864
+ /**
865
+ * 远端用户在房间中状态变化的回调
866
+ */
867
+ RCLoggerTag["L_REMOTE_USER_STATE_HANDLE_O"] = "L-remote_user_state_handle-O";
868
+ /**
869
+ * 北极星 TCP 通道发送的数据类型
870
+ */
871
+ RCLoggerTag["L_CMP_POLARIS_REPORT_TYPE_O"] = "L-cmp_polaris_report_type-O";
872
+ /**
873
+ * 北极星 TCP 通道数据发送任务
874
+ */
875
+ RCLoggerTag["L_CMP_POLARIS_REPORT_T"] = "L-cmp_polaris_report-T";
876
+ /**
877
+ * 北极星 TCP 通道数据发送结果
878
+ */
879
+ RCLoggerTag["L_CMP_POLARIS_REPORT_R"] = "L-cmp_polaris_report-R";
880
+ /**
881
+ * 北极星 HTTP 通道发送数据任务
882
+ */
883
+ RCLoggerTag["L_HTTP_POLARIS_REPORT_T"] = "L-http_polaris_report-T";
884
+ /**
885
+ * 北极星 HTTP 通道发送数据结果
886
+ */
887
+ RCLoggerTag["L_HTTP_POLARIS_REPORT_R"] = "L-http_polaris_report-R";
888
+ /**
889
+ * 北极星 HTTP 通道发送数据类型
890
+ */
891
+ RCLoggerTag["L_HTTP_POLARIS_REPORT_TYPE_O"] = "L-http_polaris_report_type-O";
860
892
  })(RCLoggerTag || (RCLoggerTag = {}));
861
893
  var RCLoggerStatus;
862
894
  (function (RCLoggerStatus) {
@@ -14651,7 +14683,7 @@ const getCommonHeader$1 = () => ({
14651
14683
  'Content-Type': 'application/json;charset=UTF-8',
14652
14684
  'Cache-Control': 'no-cache',
14653
14685
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
14654
- ClientVersion: "5.5.5-beem",
14686
+ ClientVersion: "5.5.5-beem-alpha.4",
14655
14687
  'Client-Session-Id': getUUID(),
14656
14688
  'Request-Id': Date.now().toString(),
14657
14689
  });
@@ -14779,7 +14811,7 @@ class Memo {
14779
14811
  this._memo = new Memo();
14780
14812
  }
14781
14813
  // 方便调试使用
14782
- // (window as any).__memo__ = this._memo;
14814
+ window.__memo__ = this._memo;
14783
14815
  return this._memo;
14784
14816
  }
14785
14817
  static destroy() {
@@ -14791,7 +14823,7 @@ const getCommonHeader = () => ({
14791
14823
  'Content-Type': 'application/json;charset=UTF-8',
14792
14824
  'Cache-Control': 'no-cache',
14793
14825
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
14794
- ClientVersion: "5.5.5-beem",
14826
+ ClientVersion: "5.5.5-beem-alpha.4",
14795
14827
  'Client-Session-Id': getUUID(),
14796
14828
  'Request-Id': Date.now().toString(),
14797
14829
  });
@@ -15308,6 +15340,20 @@ class SdpResource {
15308
15340
  }
15309
15341
  }
15310
15342
 
15343
+ class SourceIdMap {
15344
+ constructor() { }
15345
+ static getInstance() {
15346
+ if (!this._instance) {
15347
+ this._instance = new Map([['sourceIdForPublishMap', new Map()], ['sourceIdForSubscribeMap', new Map()]]);
15348
+ }
15349
+ return this._instance;
15350
+ }
15351
+ static destroy() {
15352
+ this._instance = new Map([['sourceIdForPublishMap', new Map()], ['sourceIdForSubscribeMap', new Map()]]);
15353
+ }
15354
+ }
15355
+ SourceIdMap._instance = new Map([['sourceIdForPublishMap', new Map()], ['sourceIdForSubscribeMap', new Map()]]);
15356
+
15311
15357
  class AbstractStatParser {
15312
15358
  constructor(_rtcPeerConn, _sdpSemantics, _currentUserId) {
15313
15359
  this._rtcPeerConn = _rtcPeerConn;
@@ -15467,15 +15513,9 @@ class AbstractStatParser {
15467
15513
  }
15468
15514
  parseRTCStatsReport(reports) {
15469
15515
  const stats = {};
15470
- let flag = 0;
15471
- for (let name of reports.keys()) {
15472
- if (/RTCInbound/.test(name)) {
15473
- flag++;
15474
- }
15475
- }
15476
15516
  for (const key of reports.keys()) {
15477
15517
  // 过滤下行数据上报
15478
- if (!key.includes('RTCCodec_') && !(flag > 9 && key.includes('RTCInbound'))) {
15518
+ if (!key.includes('RTCCodec_')) {
15479
15519
  stats[key] = reports.get(key);
15480
15520
  }
15481
15521
  }
@@ -15504,31 +15544,21 @@ class AbstractStatParser {
15504
15544
  * @returns resourceId
15505
15545
  */
15506
15546
  getResourceIdByParseSdp(statInfo) {
15507
- var _a, _b;
15508
15547
  const { ssrc } = statInfo;
15509
15548
  const kind = statInfo.kind || statInfo.mediaType;
15510
- const offer = (_a = this._rtcPeerConn.currentLocalDescription) === null || _a === void 0 ? void 0 : _a.sdp;
15511
- const answer = (_b = this._rtcPeerConn.currentRemoteDescription) === null || _b === void 0 ? void 0 : _b.sdp;
15512
- let rule;
15513
- if (this._sdpSemantics === 'unified-plan') {
15514
- rule = new RegExp('a=msid:(.*?) ');
15515
- }
15516
- else {
15517
- rule = new RegExp(`a=ssrc:${ssrc} msid:(.*?) `);
15518
- }
15519
- const offerMArr = offer === null || offer === void 0 ? void 0 : offer.split('\r\nm=');
15520
- const selectOfferM = offerMArr === null || offerMArr === void 0 ? void 0 : offerMArr.filter((item) => item.includes(`a=ssrc:${ssrc}`))[0];
15521
- const matchOffer = selectOfferM === null || selectOfferM === void 0 ? void 0 : selectOfferM.match(rule);
15522
- let msid = matchOffer ? matchOffer[1] : '';
15523
- if (msid) {
15549
+ const sourceIdMap = SourceIdMap.getInstance();
15550
+ const sourceIdForPublishMap = sourceIdMap.get('sourceIdForPublishMap');
15551
+ const sourceIdForSubscribeMap = sourceIdMap.get('sourceIdForSubscribeMap');
15552
+ let publishRes = sourceIdForPublishMap === null || sourceIdForPublishMap === void 0 ? void 0 : sourceIdForPublishMap.get(String(ssrc));
15553
+ if (publishRes) {
15524
15554
  if (kind === 'audio') {
15525
- return `${msid}_0`;
15555
+ return `${publishRes}_0`;
15526
15556
  }
15527
15557
  /**
15528
15558
  * msid 为 userId_tag 或 userId_tag_tiny
15529
15559
  * 截取完 userId 之后,仅剩 tag 或 tag_tiny
15530
15560
  */
15531
- const tag = msid.replace(`${this._currentUserId}_`, '');
15561
+ const tag = publishRes.replace(`${this._currentUserId}_`, '');
15532
15562
  const splitTag = tag.split('_');
15533
15563
  /**
15534
15564
  * tag 或 tag_tiny 最后一位为 tiny,且长度大于 1 时为视频小流
@@ -15537,13 +15567,10 @@ class AbstractStatParser {
15537
15567
  return `${this._currentUserId}_${splitTag[0]}_1_tiny`;
15538
15568
  }
15539
15569
  // 视频大流
15540
- return `${msid}_1`;
15570
+ return `${publishRes}_1`;
15541
15571
  }
15542
- const answerMArr = answer === null || answer === void 0 ? void 0 : answer.split('\r\nm=');
15543
- const selectAnswerM = answerMArr === null || answerMArr === void 0 ? void 0 : answerMArr.filter((item) => item.includes(`a=ssrc:${ssrc}`))[0];
15544
- const matchAnswer = selectAnswerM === null || selectAnswerM === void 0 ? void 0 : selectAnswerM.match(rule);
15545
- msid = matchAnswer ? matchAnswer[1] : '';
15546
- return msid ? `${msid}_${kind === 'video' ? 1 : 0}` : '';
15572
+ let subscribeRes = sourceIdForSubscribeMap === null || sourceIdForSubscribeMap === void 0 ? void 0 : sourceIdForSubscribeMap.get(String(ssrc));
15573
+ return subscribeRes ? `${subscribeRes}_${kind === 'video' ? 1 : 0}` : '';
15547
15574
  }
15548
15575
  /**
15549
15576
  * 从 offer sdp 中查找 ssrc 对应的通道是否可用
@@ -15568,6 +15595,34 @@ class AbstractStatParser {
15568
15595
  return !valid;
15569
15596
  }
15570
15597
  }
15598
+ /**
15599
+ * 从sdp中解析出ssrc和msid并缓存
15600
+ * @param sdp string
15601
+ */
15602
+ AbstractStatParser.formatSourceIdMapFromSdp = (sdp, type) => {
15603
+ let rule = /a=ssrc:(.*) msid:(.*?) /ig;
15604
+ const sourceIdMap = SourceIdMap.getInstance();
15605
+ const matchList = sdp === null || sdp === void 0 ? void 0 : sdp.match(rule);
15606
+ if (!matchList) {
15607
+ return;
15608
+ }
15609
+ if (type === 'publish') {
15610
+ const sourceIdForPublishMap = sourceIdMap.get('sourceIdForPublishMap');
15611
+ sourceIdForPublishMap === null || sourceIdForPublishMap === void 0 ? void 0 : sourceIdForPublishMap.clear();
15612
+ matchList.forEach((item) => {
15613
+ const [ssrc, msid] = item.split(' ').map((child) => child.split(':')[1]);
15614
+ sourceIdForPublishMap === null || sourceIdForPublishMap === void 0 ? void 0 : sourceIdForPublishMap.set(ssrc, msid);
15615
+ });
15616
+ }
15617
+ if (type === 'subscribe') {
15618
+ const sourceIdForSubscribeMap = sourceIdMap.get('sourceIdForSubscribeMap');
15619
+ sourceIdForSubscribeMap === null || sourceIdForSubscribeMap === void 0 ? void 0 : sourceIdForSubscribeMap.clear();
15620
+ matchList.forEach((item) => {
15621
+ const [ssrc, msid] = item.split(' ').map((child) => child.split(':')[1]);
15622
+ sourceIdForSubscribeMap === null || sourceIdForSubscribeMap === void 0 ? void 0 : sourceIdForSubscribeMap.set(ssrc, msid);
15623
+ });
15624
+ }
15625
+ };
15571
15626
 
15572
15627
  /**
15573
15628
  * chrome 73 无 type 为 remote-inbound-rtp 的数据,上行拿不到 jetter、rtt、packetsLost 数据
@@ -17679,8 +17734,8 @@ class RCRTCPeerConnection extends EventEmitter {
17679
17734
  return {
17680
17735
  timestamp,
17681
17736
  iceCandidatePair,
17682
- senders: newSenders,
17683
- receivers: newReceivers,
17737
+ senders: newSenders.filter((item) => item.trackId),
17738
+ receivers: newReceivers.filter((item) => item.trackId),
17684
17739
  pcName: this._pcName,
17685
17740
  };
17686
17741
  }
@@ -17960,14 +18015,15 @@ class PolarisReporter {
17960
18015
  this._userRole = _userRole;
17961
18016
  }
17962
18017
  _send(report) {
18018
+ var _a, _b, _c, _d;
17963
18019
  return __awaiter(this, void 0, void 0, function* () {
17964
18020
  if (this._context.getConnectionStatus() !== ConnectionStatus.CONNECTED) {
17965
18021
  return RCSendCode.NOT_REPORT;
17966
18022
  }
17967
- console.log('回落 CMP 通道');
18023
+ (_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');
17968
18024
  const rCSendCode = yield this._context.setRTCState(this._roomId, report);
17969
18025
  if (rCSendCode === ErrorCode.SUCCESS) {
17970
- console.log('CMP 通道发送成功');
18026
+ (_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}`);
17971
18027
  return RCSendCode.REPORT_SUCCESS;
17972
18028
  }
17973
18029
  return RCSendCode.REPORT_FAIL;
@@ -18014,6 +18070,7 @@ class PolarisReporter {
18014
18070
  return polarisTrackId;
18015
18071
  }
18016
18072
  sendR3R4Data(data) {
18073
+ var _a, _b, _c, _d, _e, _f;
18017
18074
  return __awaiter(this, void 0, void 0, function* () {
18018
18075
  const { iceCandidatePair, senders, receivers } = data;
18019
18076
  /**
@@ -18098,14 +18155,14 @@ class PolarisReporter {
18098
18155
  let senderCode = RCSendCode.REPORT_FAIL;
18099
18156
  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');
18100
18157
  if (data.senders.length) {
18158
+ (_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');
18101
18159
  senderCode = yield this._send(`${r3}\r${this._userRole}`);
18102
- console.log('回落R3发送成功 ->', `${r3}\r${this._userRole}`);
18103
18160
  }
18104
18161
  let receiverCode = RCSendCode.REPORT_FAIL;
18105
18162
  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');
18106
18163
  if (data.receivers.length) {
18164
+ (_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');
18107
18165
  receiverCode = yield this._send(`${r4}\r${this._userRole}`);
18108
- console.log('回落R4发送成功 ->', `${r4}\r${this._userRole}`);
18109
18166
  }
18110
18167
  if (senderCode !== RCSendCode.REPORT_SUCCESS && receiverCode !== RCSendCode.REPORT_SUCCESS) {
18111
18168
  return RCSendCode.REPORT_FAIL;
@@ -18117,7 +18174,8 @@ class PolarisReporter {
18117
18174
  * 加入房间
18118
18175
  */
18119
18176
  sendR1() {
18120
- const rtcVersion = "5.5.5-beem";
18177
+ var _a, _b, _c;
18178
+ const rtcVersion = "5.5.5-beem-alpha.4";
18121
18179
  const imVersion = this._context.getCoreVersion();
18122
18180
  const platform = 'web';
18123
18181
  const pcName = navigator.platform;
@@ -18126,18 +18184,19 @@ class PolarisReporter {
18126
18184
  const browserVersion = browserInfo.version;
18127
18185
  const deviceId = this._getClientID();
18128
18186
  const r1 = `R1\t${rtcVersion}\t${imVersion}\t${platform}\t${pcName}\t${pcVersion}\t${browserName}\t${browserVersion}\t${deviceId}\t${this._userRole}`;
18187
+ (_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');
18129
18188
  this._send(r1);
18130
- console.log('回落R1发送成功 ->', r1);
18131
18189
  }
18132
18190
  /**
18133
18191
  * RTC 和 LIVE 发布、取消发布
18134
18192
  * RTC 订阅、取消订阅
18135
18193
  */
18136
18194
  sendR2(action, status, trackIds) {
18195
+ var _a, _b, _c;
18137
18196
  const deviceId = this._getClientID();
18138
18197
  const r2 = `R2\t${action}\t${status}\t${deviceId}\r${trackIds.join('\t')}\r${this._userRole}`;
18198
+ (_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');
18139
18199
  this._send(r2);
18140
- console.log('回落R2发送成功 ->', r2);
18141
18200
  }
18142
18201
  }
18143
18202
 
@@ -18154,7 +18213,7 @@ class PolarisHttpReporter {
18154
18213
  this._polarisSignalReporter = new PolarisReporter(_context, _runtime, _roomId, _crtRTCRoom, _userRole);
18155
18214
  }
18156
18215
  _send(report, reportType) {
18157
- var _a;
18216
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
18158
18217
  return __awaiter(this, void 0, void 0, function* () {
18159
18218
  if (this._context.getConnectionStatus() !== ConnectionStatus.CONNECTED) {
18160
18219
  return RCSendCode.NOT_REPORT;
@@ -18166,19 +18225,21 @@ class PolarisHttpReporter {
18166
18225
  if (!logServer || !this._useHttp || !RCMediaService.jwtToken) {
18167
18226
  return RCSendCode.REPORT_FAIL;
18168
18227
  }
18228
+ (_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');
18169
18229
  const code = yield this._context.setRTCStateByHttp(logServer, this._runtime, report, reportType);
18170
18230
  if (code === RCSendCode.REPORT_SUCCESS) {
18171
- console.log('http 通道发送成功');
18231
+ (_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}`);
18172
18232
  return RCSendCode.REPORT_SUCCESS;
18173
18233
  }
18174
18234
  // jwt 失效,重新请求 naviInfo
18175
18235
  if (code === RCRTCCode.JWT_TIME_OUT) {
18176
- console.log('jwt 失效');
18236
+ (_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}`);
18177
18237
  this._refetchNaviInfo();
18178
18238
  return RCSendCode.REPORT_FAIL;
18179
18239
  }
18180
18240
  // 其他错误情况
18181
18241
  if (code === RCSendCode.REPORT_FAIL || code === RCSendCode.PB_ERROR) {
18242
+ (_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}`);
18182
18243
  this._useHttp = false;
18183
18244
  return RCSendCode.REPORT_FAIL;
18184
18245
  }
@@ -18266,13 +18327,14 @@ class PolarisHttpReporter {
18266
18327
  _formatR1Data() {
18267
18328
  return {
18268
18329
  joinTime: this._context.userJoinTime || 0,
18269
- rtcVersion: "5.5.5-beem",
18330
+ rtcVersion: "5.5.5-beem-alpha.4",
18270
18331
  imVersion: this._context.getCoreVersion(),
18271
18332
  platform: 'web',
18272
18333
  device: navigator.platform,
18273
18334
  os: String(STAT_NONE),
18274
18335
  browserName: browserInfo.browser,
18275
18336
  browserVersion: String(browserInfo.version),
18337
+ receiveTime: Date.now(),
18276
18338
  };
18277
18339
  }
18278
18340
  _formatR2Data(params) {
@@ -18283,6 +18345,7 @@ class PolarisHttpReporter {
18283
18345
  rtcActionType: action,
18284
18346
  rtcActionStatus: status,
18285
18347
  trackId: trackIds,
18348
+ receiveTime: Date.now(),
18286
18349
  };
18287
18350
  }
18288
18351
  _formatR3R4Data(reportType, params) {
@@ -18365,11 +18428,12 @@ class PolarisHttpReporter {
18365
18428
  };
18366
18429
  }
18367
18430
  sendR3R4Data(data) {
18431
+ var _a, _b, _c, _d;
18368
18432
  return __awaiter(this, void 0, void 0, function* () {
18369
18433
  let senderCode = RCSendCode.REPORT_FAIL;
18370
18434
  if (data.senders.length) {
18371
18435
  const r3Info = this._formatReportData(RCReportType.R3, data);
18372
- console.log('发送r3Info ->', r3Info);
18436
+ (_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');
18373
18437
  senderCode = yield this._send(r3Info, RCReportType.R3);
18374
18438
  // 回落 R3
18375
18439
  if (senderCode === RCSendCode.REPORT_FAIL) {
@@ -18379,7 +18443,7 @@ class PolarisHttpReporter {
18379
18443
  let receiverCode = RCSendCode.REPORT_FAIL;
18380
18444
  if (data.receivers.length) {
18381
18445
  const r4Info = this._formatReportData(RCReportType.R4, data);
18382
- console.log('发送r4Info ->', r4Info);
18446
+ (_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');
18383
18447
  receiverCode = yield this._send(r4Info, RCReportType.R4);
18384
18448
  // 回落 R4
18385
18449
  if (receiverCode === RCSendCode.REPORT_FAIL) {
@@ -18396,14 +18460,14 @@ class PolarisHttpReporter {
18396
18460
  * 加入房间
18397
18461
  */
18398
18462
  sendR1() {
18399
- var _a;
18463
+ var _a, _b, _c;
18400
18464
  return __awaiter(this, void 0, void 0, function* () {
18401
18465
  const r1Info = this._formatReportData(RCReportType.R1);
18402
- console.log('发送r1Info ->', r1Info);
18466
+ (_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');
18403
18467
  const sendCode = yield this._send(r1Info, RCReportType.R1);
18404
18468
  // 回落 R1
18405
18469
  if (sendCode === RCSendCode.REPORT_FAIL) {
18406
- (_a = this._polarisSignalReporter) === null || _a === void 0 ? void 0 : _a.sendR1();
18470
+ (_c = this._polarisSignalReporter) === null || _c === void 0 ? void 0 : _c.sendR1();
18407
18471
  }
18408
18472
  });
18409
18473
  }
@@ -18412,14 +18476,14 @@ class PolarisHttpReporter {
18412
18476
  * RTC 订阅、取消订阅
18413
18477
  */
18414
18478
  sendR2(action, status, trackIds) {
18415
- var _a;
18479
+ var _a, _b, _c;
18416
18480
  return __awaiter(this, void 0, void 0, function* () {
18417
18481
  const r2Info = this._formatReportData(RCReportType.R2, { action, status, trackIds });
18418
- console.log('发送r2Info ->', r2Info);
18482
+ (_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');
18419
18483
  const sendCode = yield this._send(r2Info, RCReportType.R2);
18420
18484
  // 回落 R2
18421
18485
  if (sendCode === RCSendCode.REPORT_FAIL) {
18422
- (_a = this._polarisSignalReporter) === null || _a === void 0 ? void 0 : _a.sendR2(action, status, trackIds);
18486
+ (_c = this._polarisSignalReporter) === null || _c === void 0 ? void 0 : _c.sendR2(action, status, trackIds);
18423
18487
  }
18424
18488
  });
18425
18489
  }
@@ -19780,6 +19844,8 @@ class UpdateSubscribeListCommand extends BaseCommand {
19780
19844
  }
19781
19845
  return { code: resCode };
19782
19846
  }
19847
+ // 缓存订阅资源的ssrc和msid
19848
+ AbstractStatParser.formatSourceIdMapFromSdp(answer.sdp, 'subscribe');
19783
19849
  // 连通率相关埋点-订阅日志上报
19784
19850
  let msas = [];
19785
19851
  let dateNow = Date.now();
@@ -20183,6 +20249,7 @@ function transPullDataToStateMsgCont(data) {
20183
20249
  };
20184
20250
  return content;
20185
20251
  }
20252
+ const isIncludeUris = (userData) => userData.some((item) => (item.key === 'uris' || item.key === 'cdn_uris'));
20186
20253
  /**
20187
20254
  * 通知拉取到的增量房间数据格式为 IRoomStatus
20188
20255
  * 把 IRoomStatus 转化为通用解析资源方法(ParseRemoteResCommand)需要的数据
@@ -20190,13 +20257,21 @@ function transPullDataToStateMsgCont(data) {
20190
20257
  function transPullDataToResMsgCont(data) {
20191
20258
  var _a, _b;
20192
20259
  const { userId, userData } = data;
20260
+ /**
20261
+ * PullRoomStatusEvent 为 3 时,并不全代表资源变动,
20262
+ * 房间内设置的其他 key value,也会被拉下来,event 为 3
20263
+ */
20264
+ const hasUris = isIncludeUris(userData);
20265
+ if (!hasUris) {
20266
+ return;
20267
+ }
20193
20268
  const uris = (_a = userData.filter((item) => (item.key === 'uris'))[0]) === null || _a === void 0 ? void 0 : _a.value;
20194
20269
  const cdnUris = (_b = userData.filter((item) => (item.key === 'cdn_uris'))[0]) === null || _b === void 0 ? void 0 : _b.value;
20195
20270
  return {
20196
20271
  userId,
20197
20272
  content: {
20198
- uris: uris && JSON.parse(uris),
20199
- cdn_uris: cdnUris && JSON.parse(cdnUris),
20273
+ uris: (uris && JSON.parse(uris)),
20274
+ cdn_uris: (cdnUris && JSON.parse(cdnUris)),
20200
20275
  },
20201
20276
  };
20202
20277
  }
@@ -20275,19 +20350,20 @@ class ParseUserStateCommand extends BaseCommand {
20275
20350
  }
20276
20351
  }
20277
20352
  users.forEach((item) => {
20278
- var _a, _b, _c, _d;
20353
+ var _a, _b, _c, _d, _e, _f;
20279
20354
  const { userId } = item;
20280
20355
  if (Number(item.state) === 0) {
20281
20356
  (_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}`);
20282
20357
  // 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
20283
20358
  const resArr = store.getResourcesByUserId(userId);
20359
+ (_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}`);
20284
20360
  if (!resArr) {
20285
20361
  item.switchRoleType ? upgrade.push(userId) : joined.push(userId);
20286
20362
  }
20287
20363
  store.setResourcesByUserId(userId, resArr || []);
20288
20364
  }
20289
20365
  else {
20290
- (_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}`);
20366
+ (_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}`);
20291
20367
  item.switchRoleType ? downgrade.push(userId) : left.push(userId);
20292
20368
  }
20293
20369
  });
@@ -20689,6 +20765,8 @@ class PublishCommand extends BaseCommand {
20689
20765
  (_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({
20690
20766
  identify: qualityStatusId,
20691
20767
  }));
20768
+ // 缓存发布资源的ssrc和msid
20769
+ AbstractStatParser.formatSourceIdMapFromSdp(reqBody.sdp.sdp, 'publish');
20692
20770
  const resp = yield new ExchangeCommand(headers, reqBody).execute(store, invoker);
20693
20771
  if (resp.code !== RCRTCCode.SUCCESS) {
20694
20772
  // 连通率相关埋点-发布资源结束
@@ -21749,14 +21827,14 @@ var PullRoomStatusEvent;
21749
21827
  })(PullRoomStatusEvent || (PullRoomStatusEvent = {}));
21750
21828
 
21751
21829
  class PullRTCRoomStatusCommand extends BaseCommand {
21752
- constructor(_roomId, _traceId, _context, _callbacks, _subhook, _stateHandle) {
21830
+ constructor(_roomId, _traceId, _context, _callbacks, _subhook, _dealUserAppListener) {
21753
21831
  super();
21754
21832
  this._roomId = _roomId;
21755
21833
  this._traceId = _traceId;
21756
21834
  this._context = _context;
21757
21835
  this._callbacks = _callbacks;
21758
21836
  this._subhook = _subhook;
21759
- this._stateHandle = _stateHandle;
21837
+ this._dealUserAppListener = _dealUserAppListener;
21760
21838
  }
21761
21839
  execute(store, invoker) {
21762
21840
  var _a, _b;
@@ -21792,15 +21870,27 @@ class PullRTCRoomStatusCommand extends BaseCommand {
21792
21870
  for (let index = 0; index < roomStatus.length; index++) {
21793
21871
  const item = roomStatus[index];
21794
21872
  if (item.event === PullRoomStatusEvent.RESOURCECHANGE) {
21795
- const { content, userId } = transPullDataToResMsgCont(item);
21873
+ const resData = transPullDataToResMsgCont(item);
21874
+ /**
21875
+ * 无 uris 或 cdn_uris 时,无需继续执行解析资源数据
21876
+ */
21877
+ if (!resData) {
21878
+ continue;
21879
+ }
21880
+ const { content, userId } = resData;
21796
21881
  if (userId === store.crtUserId) {
21797
21882
  continue;
21798
21883
  }
21799
21884
  yield new ParseRemoteResCommand(content, RCRTCMessageType.TOTAL_CONTENT_RESOURCE, userId, this._subhook.bind(this), this._callbacks).execute(store, invoker);
21800
21885
  }
21801
21886
  else {
21887
+ /**
21888
+ * 转化拉到的房间数据为通用解析人员方法需要的格式
21889
+ * 处理解析完的结果
21890
+ */
21802
21891
  const content = transPullDataToStateMsgCont(item);
21803
- this._stateHandle(content);
21892
+ const userData = yield new ParseUserStateCommand(content, this._subhook.bind(this)).execute(store, invoker);
21893
+ this._dealUserAppListener(userData);
21804
21894
  }
21805
21895
  }
21806
21896
  return { code };
@@ -21884,7 +21974,7 @@ class RCAbstractRoom extends EventEmitter {
21884
21974
  onTrackPublish: this._onTrackPublish.bind(this),
21885
21975
  onTrackUnpublish: this._onTrackUnpublish.bind(this),
21886
21976
  onCDNEnableChange: this._callAppListener.bind(this, 'onCDNEnableChange'),
21887
- }, this._subhook.bind(this), this._stateHandle.bind(this)));
21977
+ }, this._subhook.bind(this), this._dealUserAppListener.bind(this)));
21888
21978
  });
21889
21979
  }
21890
21980
  __innerInit(mode, joinType, livingType, innerUserDatas, outerUserDatas) {
@@ -22124,30 +22214,40 @@ class RCAbstractRoom extends EventEmitter {
22124
22214
  * @param content
22125
22215
  */
22126
22216
  _stateHandle(content) {
22127
- var _a;
22128
22217
  return __awaiter(this, void 0, void 0, function* () {
22129
- const { left, joined, upgrade, downgrade, } = yield this._invoker.push(new ParseUserStateCommand(content, this._subhook.bind(this)));
22130
- /**
22131
- * 通知业务层
22132
- * 有 onSwitchRole 监听时,按 switchRole 分“角色切换、加入房间、退出房间”抛出
22133
- */
22134
- if ((_a = this._appListener) === null || _a === void 0 ? void 0 : _a.onSwitchRole) {
22135
- upgrade.length && upgrade.forEach((userId) => this._callAppListener('onSwitchRole', userId, RCRTCLiveRole.ANCHOR));
22136
- downgrade.length && downgrade.forEach((userId) => this._callAppListener('onSwitchRole', userId, RCRTCLiveRole.AUDIENCE));
22137
- joined.length && this._callAppListener('onUserJoin', joined);
22138
- left.length && this._callAppListener('onUserLeave', left);
22139
- return;
22140
- }
22141
- const allJoined = [...joined, ...upgrade];
22142
- const allLeft = [...left, ...downgrade];
22143
- /**
22144
- * 通知业务层
22145
- * 无 onSwitchRole 监听时,统一按“加入房间、退出房间”抛出
22146
- */
22147
- allJoined.length && this._callAppListener('onUserJoin', allJoined);
22148
- allLeft.length && this._callAppListener('onUserLeave', allLeft);
22218
+ const userData = yield this._invoker.push(new ParseUserStateCommand(content, this._subhook.bind(this)));
22219
+ this._dealUserAppListener(userData);
22149
22220
  });
22150
22221
  }
22222
+ /**
22223
+ * 处理人员应用层事件
22224
+ */
22225
+ _dealUserAppListener(userData) {
22226
+ var _a, _b, _c;
22227
+ const { left, joined, upgrade, downgrade, } = userData;
22228
+ (_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({
22229
+ left, joined, upgrade, downgrade,
22230
+ }));
22231
+ /**
22232
+ * 通知业务层
22233
+ * 有 onSwitchRole 监听时,按 switchRole 分“角色切换、加入房间、退出房间”抛出
22234
+ */
22235
+ if ((_c = this._appListener) === null || _c === void 0 ? void 0 : _c.onSwitchRole) {
22236
+ upgrade.length && upgrade.forEach((userId) => this._callAppListener('onSwitchRole', userId, RCRTCLiveRole.ANCHOR));
22237
+ downgrade.length && downgrade.forEach((userId) => this._callAppListener('onSwitchRole', userId, RCRTCLiveRole.AUDIENCE));
22238
+ joined.length && this._callAppListener('onUserJoin', joined);
22239
+ left.length && this._callAppListener('onUserLeave', left);
22240
+ return;
22241
+ }
22242
+ const allJoined = [...joined, ...upgrade];
22243
+ const allLeft = [...left, ...downgrade];
22244
+ /**
22245
+ * 通知业务层
22246
+ * 无 onSwitchRole 监听时,统一按“加入房间、退出房间”抛出
22247
+ */
22248
+ allJoined.length && this._callAppListener('onUserJoin', allJoined);
22249
+ allLeft.length && this._callAppListener('onUserLeave', allLeft);
22250
+ }
22151
22251
  /**
22152
22252
  * 获取房间 Id
22153
22253
  */
@@ -25238,6 +25338,8 @@ class RCAudienceClient {
25238
25338
  }));
25239
25339
  // 无需等待 setRemoteAnswer 完成,直接返回,避免业务层拿到 tracks 之前先获取了 onTrackReady 通知
25240
25340
  this._pc.setRemoteAnswer(answer.sdp);
25341
+ // 缓存订阅资源的ssrc和msid
25342
+ AbstractStatParser.formatSourceIdMapFromSdp(answer.sdp, 'subscribe');
25241
25343
  (_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({
25242
25344
  status: RCLoggerStatus.SUCCESSED,
25243
25345
  liveUrl,
@@ -27799,7 +27901,7 @@ class RCRTCClient extends RCMediaStreamCapture {
27799
27901
  }
27800
27902
  reportSDKInfo() {
27801
27903
  this._context.reportSDKInfo({
27802
- 'plugin-rtc': "5.5.5-beem",
27904
+ 'plugin-rtc': "5.5.5-beem-alpha.4",
27803
27905
  });
27804
27906
  }
27805
27907
  }
@@ -28174,6 +28276,7 @@ message probuf {
28174
28276
  required string os = 6;//系统版本(手机系统版本)
28175
28277
  optional string browserName = 7; //浏览器名称, 没有用 -1 表示
28176
28278
  optional string browserVersion = 8;//浏览器版本, 没有用 -1 表示
28279
+ optional int64 receiveTime = 9; // 发送数据的时间
28177
28280
  }
28178
28281
  message ${RTCPB.RtcPBR2Info} {
28179
28282
  required int64 joinTime = 1;
@@ -28181,6 +28284,7 @@ message probuf {
28181
28284
  required string rtcActionType = 3;//发布类型 subscribe : 订阅 publish : 发布
28182
28285
  required string rtcActionStatus = 4;//发布状态 begin : 开始 tend : 结束
28183
28286
  repeated string trackId = 5;
28287
+ optional int64 receiveTime = 6; // 发送数据的时间
28184
28288
  }
28185
28289
  message ${RTCPB.RtcPBR3Info} {
28186
28290
  required ${RTCPB.RtcPBStatusInfo} info = 1;
@@ -28500,7 +28604,7 @@ class RTCContext {
28500
28604
  headers: {
28501
28605
  jwt: RCMediaService.jwtToken,
28502
28606
  },
28503
- timeout: 5 * 1000,
28607
+ timeout: 2 * 1000,
28504
28608
  });
28505
28609
  if (!res.data) {
28506
28610
  throw new Error('http request fail');
@@ -28791,7 +28895,7 @@ const installer = {
28791
28895
  console.error('Please use the https protocol or use `http://localhost` to open the page!');
28792
28896
  return false;
28793
28897
  }
28794
- VersionManage.add('plugin-rtc', "5.5.5-beem");
28898
+ VersionManage.add('plugin-rtc', "5.5.5-beem-alpha.4");
28795
28899
  if (!VersionManage.validEngine("^5.6.0-beem")) {
28796
28900
  console.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"^5.6.0-beem"}'.`);
28797
28901
  return false;
@@ -28804,8 +28908,8 @@ const installer = {
28804
28908
  logger.setOutputLevel(options.logLevel || LogL.DEBUG);
28805
28909
  RTCLogger.setLogger(logger);
28806
28910
  logger.warn(RCLoggerTag.L_INDEX_INSTALL_RTC_PLUGIN_O, JSON.stringify({
28807
- 'RCRTC Version': "5.5.5-beem",
28808
- Commit: "b8e57d36680c1d71921cded6b91771d4dfd4f3e8",
28911
+ 'RCRTC Version': "5.5.5-beem-alpha.4",
28912
+ Commit: "0c078c138d99c8962f00f41c7d9a82e1d0f13b5a",
28809
28913
  'browserInfo.browser': browserInfo.browser,
28810
28914
  'browserInfo.supportsUnifiedPlan': browserInfo.supportsUnifiedPlan,
28811
28915
  'browserInfo.version': browserInfo.version,