@rongcloud/plugin-rtc 5.2.4-beem.5 → 5.2.4-beem.6

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.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4-beem.5
3
- * CommitId - 13f398c4a680ab6054d831b2e76e51f68a677de9
4
- * Mon May 23 2022 11:07:54 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.4-beem.6
3
+ * CommitId - 394e0005026dc17525168cd28dcaf60009b800ac
4
+ * Thu May 26 2022 17:01:57 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { EventEmitter, LogLevel, RTCMode, IRuntime, RTCPluginContext, IServerRTCRoomEntry, IJoinRTCRoomData, IReceivedMessage, KVString, RTCJoinType, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
@@ -1941,7 +1941,7 @@ declare class PolarisReporter {
1941
1941
  * @param resourceId userId_11_1_tiny 改为 userId_11_tiny_video
1942
1942
  */
1943
1943
  private _getPolarisTrackId;
1944
- sendR3R4Data(data: IInnerRCRTCStateReport): void;
1944
+ sendR3R4Data(data: IInnerRCRTCStateReport): Promise<boolean>;
1945
1945
  /**
1946
1946
  * 加入房间
1947
1947
  */
@@ -1972,6 +1972,7 @@ declare class RCRTCPeerConnection extends EventEmitter {
1972
1972
  private pubLocalTracks;
1973
1973
  private _reTryExchangeTimer;
1974
1974
  private _reportStatsTimer;
1975
+ private _reportR3R4ToPolarisTimer;
1975
1976
  constructor(
1976
1977
  /**
1977
1978
  * _reTryExchange 方法
@@ -2022,6 +2023,14 @@ declare class RCRTCPeerConnection extends EventEmitter {
2022
2023
  * @todo
2023
2024
  */
2024
2025
  private _reportHandle;
2026
+ /**
2027
+ * 北极星上报 R3、R4 数据
2028
+ */
2029
+ private _sendR3R4Data;
2030
+ /**
2031
+ * 2s 给北极星上报一次 R3、R4
2032
+ */
2033
+ __reportR3R4ToPolaris(): Promise<void>;
2025
2034
  getRTCPeerConn(): RTCPeerConnection;
2026
2035
  destroy(): void;
2027
2036
  clearReTryExchangeTimer(): void;
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4-beem.5
3
- * CommitId - 13f398c4a680ab6054d831b2e76e51f68a677de9
4
- * Mon May 23 2022 11:07:54 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.4-beem.6
3
+ * CommitId - 394e0005026dc17525168cd28dcaf60009b800ac
4
+ * Thu May 26 2022 17:01:57 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { Logger, EventEmitter, isNumber, ErrorCode, ConnectionStatus, assert, ConversationType, RTCApiType, validate, isArray, RTCMode, isHttpUrl, isBoolean, HttpMethod, isString, notEmptyString, RTCJoinType, RTCIdentityChangeType, VersionManage } from '@rongcloud/engine';
@@ -6582,20 +6582,21 @@ var RCRTCPingResult;
6582
6582
  /**
6583
6583
  * rtcping 间隔
6584
6584
  */
6585
- const PING_GAP = 10 * 1000;
6585
+ const PING_GAP = 5 * 1000;
6586
6586
  /**
6587
6587
  * rtcping 超时时间
6588
6588
  */
6589
- const PING_TIMEOUT = 10 * 1000;
6589
+ const PING_TIMEOUT = 5 * 1000;
6590
6590
  /**
6591
- * RTCPing 类,累计 1 分钟未能正确收到 Ping 值则认为 ping 失败
6591
+ * RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
6592
6592
  */
6593
6593
  class Pinger {
6594
- constructor(_roomId, _roomMode, _context, _gap = PING_GAP) {
6594
+ constructor(_roomId, _roomMode, _context, _gap = PING_GAP, _offlineKickTime = 60 * 1000) {
6595
6595
  this._roomId = _roomId;
6596
6596
  this._roomMode = _roomMode;
6597
6597
  this._context = _context;
6598
6598
  this._gap = _gap;
6599
+ this._offlineKickTime = _offlineKickTime;
6599
6600
  /**
6600
6601
  * 记录最近一次成功的 Ping 时间戳
6601
6602
  */
@@ -6642,8 +6643,8 @@ class Pinger {
6642
6643
  }
6643
6644
  logger.warn(`rtcping failed -> code: ${code}`);
6644
6645
  (_b = this.onPingResult) === null || _b === void 0 ? void 0 : _b.call(this, RCRTCPingResult.FAIL);
6645
- // 超出 1 分钟未成功进行 rtcping 操作,或用户已不存在于房间内时,通知客户离线
6646
- if (code === 40003 || now - this._latestTimestamp > 60 * 1000) {
6646
+ // 超出 _offlineKickTime ping 成功,或用户已不存在于房间内时,通知客户离线
6647
+ if (code === 40003 || now - this._latestTimestamp > this._offlineKickTime) {
6647
6648
  this.stop();
6648
6649
  (_c = this.onFailed) === null || _c === void 0 ? void 0 : _c.call(this, code === 40003);
6649
6650
  return;
@@ -8013,6 +8014,8 @@ class RCRTCPeerConnection extends EventEmitter {
8013
8014
  this._reTryExchangeTimer = null;
8014
8015
  // peerConnection stats 计时器
8015
8016
  this._reportStatsTimer = null;
8017
+ // 上报上下行数据至北极星定时器
8018
+ this._reportR3R4ToPolarisTimer = null;
8016
8019
  this._reportListener = null;
8017
8020
  const sdpSemantics = ASdpStrategy.getSdpSemantics();
8018
8021
  const peer = this._rtcPeerConn = new RTCPeerConnection({ sdpSemantics });
@@ -8236,23 +8239,44 @@ class RCRTCPeerConnection extends EventEmitter {
8236
8239
  * @todo
8237
8240
  */
8238
8241
  _reportHandle() {
8239
- var _a, _b, _c;
8242
+ var _a, _b;
8240
8243
  return __awaiter(this, void 0, void 0, function* () {
8241
8244
  const formatData = yield this._getStatsData();
8242
8245
  if (!formatData) {
8243
8246
  return;
8244
8247
  }
8248
+ /**
8249
+ * 组装用户层抛出数据
8250
+ */
8251
+ const reportData = this._createRCRTCStateReport(formatData);
8252
+ (_b = (_a = this._reportListener) === null || _a === void 0 ? void 0 : _a.onStateReport) === null || _b === void 0 ? void 0 : _b.call(_a, reportData);
8253
+ });
8254
+ }
8255
+ /**
8256
+ * 北极星上报 R3、R4 数据
8257
+ */
8258
+ _sendR3R4Data() {
8259
+ var _a;
8260
+ return __awaiter(this, void 0, void 0, function* () {
8261
+ const formatData = yield this._getStatsData();
8262
+ if (!formatData) {
8263
+ return true;
8264
+ }
8245
8265
  if (formatData.senders.length || formatData.receivers.length) {
8246
8266
  /**
8247
8267
  * 组装北极星上报 R3、R4 数据并发送
8248
8268
  */
8249
- (_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData);
8269
+ return yield ((_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData));
8250
8270
  }
8251
- /**
8252
- * 组装用户层抛出数据
8253
- */
8254
- const reportData = this._createRCRTCStateReport(formatData);
8255
- (_c = (_b = this._reportListener) === null || _b === void 0 ? void 0 : _b.onStateReport) === null || _c === void 0 ? void 0 : _c.call(_b, reportData);
8271
+ });
8272
+ }
8273
+ /**
8274
+ * 2s 给北极星上报一次 R3、R4
8275
+ */
8276
+ __reportR3R4ToPolaris() {
8277
+ return __awaiter(this, void 0, void 0, function* () {
8278
+ yield this._sendR3R4Data();
8279
+ this._reportR3R4ToPolarisTimer = setTimeout(this.__reportR3R4ToPolaris.bind(this), 2000);
8256
8280
  });
8257
8281
  }
8258
8282
  getRTCPeerConn() {
@@ -8261,6 +8285,7 @@ class RCRTCPeerConnection extends EventEmitter {
8261
8285
  destroy() {
8262
8286
  this.clear();
8263
8287
  this.clearReTryExchangeTimer();
8288
+ clearTimeout(this._reportR3R4ToPolarisTimer);
8264
8289
  // 停止计时
8265
8290
  if (this._reportStatsTimer) {
8266
8291
  clearInterval(this._reportStatsTimer);
@@ -8319,7 +8344,20 @@ class PolarisReporter {
8319
8344
  this._userRole = _userRole;
8320
8345
  }
8321
8346
  _send(report) {
8322
- this._context.getConnectionStatus() === ConnectionStatus.CONNECTED && this._context.setRTCState(this._roomId, report);
8347
+ return __awaiter(this, void 0, void 0, function* () {
8348
+ let isSuccess = false;
8349
+ if (this._context.getConnectionStatus() !== ConnectionStatus.CONNECTED) {
8350
+ return isSuccess;
8351
+ }
8352
+ const sendCode = yield this._context.setRTCState(this._roomId, report);
8353
+ if (sendCode === ErrorCode.SUCCESS) {
8354
+ isSuccess = true;
8355
+ }
8356
+ else {
8357
+ isSuccess = false;
8358
+ }
8359
+ return isSuccess;
8360
+ });
8323
8361
  }
8324
8362
  _getClientID() {
8325
8363
  const key = 'uuid';
@@ -8362,101 +8400,113 @@ class PolarisReporter {
8362
8400
  return polarisTrackId;
8363
8401
  }
8364
8402
  sendR3R4Data(data) {
8365
- const { iceCandidatePair, senders, receivers } = data;
8366
- /**
8367
- * 上下行 track 包含的公共字段
8368
- */
8369
- const baseData = {
8370
- bitrateSend: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateSend) || STAT_NONE,
8371
- bitrateRecv: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateRecv) || STAT_NONE,
8372
- networkType: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.networkType) || 'unknown',
8373
- rtt: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.rtt) || STAT_NONE,
8374
- localAddress: `${(iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.IP) || STAT_NONE}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.port}`,
8375
- remoteAddress: `${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remoteIP}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remotePort}`,
8376
- receiveBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableIncomingBitrate) || STAT_NONE,
8377
- sendBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableOutgoingBitrate) || STAT_NONE,
8378
- packetsLost: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) || STAT_NONE,
8379
- deviceId: this._context.getCurrentId()
8380
- };
8381
- let r3 = `R3\t${baseData.bitrateSend}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8382
- let r4 = `R4\t${baseData.bitrateRecv}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8383
- /**
8384
- * 北极星上报 sender tracks 中的字段
8385
- */
8386
- const R3TrackData = senders.map((item) => {
8387
- var _a;
8388
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsSent, encoderImplementation } = item;
8389
- const trackId = this._getPolarisTrackId(resourceId);
8403
+ return __awaiter(this, void 0, void 0, function* () {
8404
+ const { iceCandidatePair, senders, receivers } = data;
8390
8405
  /**
8391
- * 小流需去掉 _tiny
8406
+ * 上下行 track 包含的公共字段
8392
8407
  */
8393
- const realResourceId = this._getRealResourceId(resourceId);
8394
- return {
8395
- trackId,
8396
- googCodecName: encoderImplementation || String(STAT_NONE),
8397
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8398
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8399
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8400
- frameRate: frameRate || STAT_NONE,
8401
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8402
- jitter: jitter || STAT_NONE,
8403
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8404
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8405
- rtt: rtt || STAT_NONE,
8406
- googFirsSent,
8407
- samplingRate,
8408
- googRenderDelayMs,
8409
- encoderImplementation: encoderImplementation || String(STAT_NONE),
8410
- trackState: ((_a = this._crtRTCRoom.getLocalTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8408
+ const baseData = {
8409
+ bitrateSend: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateSend) || STAT_NONE,
8410
+ bitrateRecv: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateRecv) || STAT_NONE,
8411
+ networkType: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.networkType) || 'unknown',
8412
+ rtt: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.rtt) || STAT_NONE,
8413
+ localAddress: `${(iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.IP) || STAT_NONE}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.port}`,
8414
+ remoteAddress: `${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remoteIP}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remotePort}`,
8415
+ receiveBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableIncomingBitrate) || STAT_NONE,
8416
+ sendBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableOutgoingBitrate) || STAT_NONE,
8417
+ packetsLost: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) || STAT_NONE,
8418
+ deviceId: this._context.getCurrentId()
8411
8419
  };
8412
- });
8413
- /**
8414
- * 北极星上报 received tracks 中的字段
8415
- */
8416
- const R4TrackData = receivers.filter(item => {
8417
- // unified-plan 下 inactive 的数据会继续携带 ssrc,导致无 trackId
8418
- return !!item.trackId;
8419
- }).map((item) => {
8420
- var _a;
8421
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsReceived, codecImplementationName } = item;
8422
- const trackId = this._getPolarisTrackId(resourceId);
8420
+ let r3 = `R3\t${baseData.bitrateSend}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8421
+ let r4 = `R4\t${baseData.bitrateRecv}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8423
8422
  /**
8424
- * 小流需去掉 _tiny
8423
+ * 北极星上报 sender tracks 中的字段
8425
8424
  */
8426
- const realResourceId = this._getRealResourceId(resourceId);
8427
- return {
8428
- trackId,
8429
- googCodecName: codecImplementationName || String(STAT_NONE),
8430
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8431
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8432
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8433
- frameRate: frameRate || STAT_NONE,
8434
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8435
- jitter: jitter || STAT_NONE,
8436
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8437
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8438
- rtt: rtt || STAT_NONE,
8439
- googFirsReceived,
8440
- samplingRate,
8441
- googRenderDelayMs,
8442
- codecImplementationName: codecImplementationName || String(STAT_NONE),
8443
- trackState: ((_a = this._crtRTCRoom.getRemoteTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8444
- };
8425
+ const R3TrackData = senders.map((item) => {
8426
+ var _a;
8427
+ const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsSent, encoderImplementation } = item;
8428
+ const trackId = this._getPolarisTrackId(resourceId);
8429
+ /**
8430
+ * 小流需去掉 _tiny
8431
+ */
8432
+ const realResourceId = this._getRealResourceId(resourceId);
8433
+ return {
8434
+ trackId,
8435
+ googCodecName: encoderImplementation || String(STAT_NONE),
8436
+ audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8437
+ bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8438
+ packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8439
+ frameRate: frameRate || STAT_NONE,
8440
+ resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8441
+ jitter: jitter || STAT_NONE,
8442
+ nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8443
+ pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8444
+ rtt: rtt || STAT_NONE,
8445
+ googFirsSent,
8446
+ samplingRate,
8447
+ googRenderDelayMs,
8448
+ encoderImplementation: encoderImplementation || String(STAT_NONE),
8449
+ trackState: ((_a = this._crtRTCRoom.getLocalTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8450
+ };
8451
+ });
8452
+ /**
8453
+ * 北极星上报 received tracks 中的字段
8454
+ */
8455
+ const R4TrackData = receivers.filter(item => {
8456
+ // unified-plan 下 inactive 的数据会继续携带 ssrc,导致无 trackId
8457
+ return !!item.trackId;
8458
+ }).map((item) => {
8459
+ var _a;
8460
+ const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsReceived, codecImplementationName } = item;
8461
+ const trackId = this._getPolarisTrackId(resourceId);
8462
+ /**
8463
+ * 小流需去掉 _tiny
8464
+ */
8465
+ const realResourceId = this._getRealResourceId(resourceId);
8466
+ return {
8467
+ trackId,
8468
+ googCodecName: codecImplementationName || String(STAT_NONE),
8469
+ audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8470
+ bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8471
+ packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8472
+ frameRate: frameRate || STAT_NONE,
8473
+ resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8474
+ jitter: jitter || STAT_NONE,
8475
+ nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8476
+ pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8477
+ rtt: rtt || STAT_NONE,
8478
+ googFirsReceived,
8479
+ samplingRate,
8480
+ googRenderDelayMs,
8481
+ codecImplementationName: codecImplementationName || String(STAT_NONE),
8482
+ trackState: ((_a = this._crtRTCRoom.getRemoteTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8483
+ };
8484
+ });
8485
+ let senderIsSuccess = false;
8486
+ r3 += R3TrackData.map((item) => {
8487
+ return `${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}`;
8488
+ }).join('\n');
8489
+ if (data.senders.length) {
8490
+ senderIsSuccess = yield this._send(r3 + `\r${this._userRole}`);
8491
+ }
8492
+ let receiverIsSuccess = false;
8493
+ r4 += R4TrackData.map((item) => {
8494
+ return `${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}`;
8495
+ }).join('\n');
8496
+ if (data.receivers.length) {
8497
+ receiverIsSuccess = yield this._send(r4 + `\r${this._userRole}`);
8498
+ }
8499
+ if (!senderIsSuccess && !receiverIsSuccess) {
8500
+ return false;
8501
+ }
8502
+ return true;
8445
8503
  });
8446
- r3 += R3TrackData.map((item) => {
8447
- return `${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}`;
8448
- }).join('\n');
8449
- data.senders.length && this._send(r3 + `\r${this._userRole}`);
8450
- r4 += R4TrackData.map((item) => {
8451
- return `${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}`;
8452
- }).join('\n');
8453
- data.receivers.length && this._send(r4 + `\r${this._userRole}`);
8454
8504
  }
8455
8505
  /**
8456
8506
  * 加入房间
8457
8507
  */
8458
8508
  sendR1() {
8459
- const rtcVersion = "5.2.4-beem.5";
8509
+ const rtcVersion = "5.2.4-beem.6";
8460
8510
  const imVersion = this._context.getCoreVersion();
8461
8511
  const platform = 'web';
8462
8512
  const pcName = navigator.platform;
@@ -8631,14 +8681,18 @@ class RCAbstractRoom {
8631
8681
  * 观众升级为主播后不会收到全量 uri 消息,需直接触发人员、资源变更
8632
8682
  */
8633
8683
  isUpgrade && this._afterChangedRole(data);
8684
+ // 服务下发的 rtcping 超时时间,单位为秒
8685
+ const offlineKickTime = data.offlineKickTime * 1000;
8634
8686
  // 开始心跳,心跳失败时主动退出房间
8635
- this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap);
8687
+ this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap, offlineKickTime);
8636
8688
  this._pinger.onFailed = this._kickoff.bind(this);
8637
8689
  this._pinger.onPingResult = this._handlePingResult.bind(this);
8638
8690
  this._pinger.start();
8639
8691
  this._polarisReport = new PolarisReporter(this._context, this._runtime, this._roomId, this);
8640
8692
  this._polarisReport.sendR1();
8641
8693
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this), this._polarisReport);
8694
+ // 发送上下行数据至北极星
8695
+ this._pc.__reportR3R4ToPolaris();
8642
8696
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
8643
8697
  this._pc.on(RCLocalTrack.__INNER_EVENT_MUTED_CHANGE__, this._onLocalTrackMuted, this);
8644
8698
  this._pc.on(RCLocalTrack.__INNER_EVENT_DESTROY__, this._onLocalTrackDestroied, this);
@@ -10714,7 +10768,7 @@ const getCommonHeader = () => ({
10714
10768
  'Content-Type': 'application/json;charset=UTF-8',
10715
10769
  'Cache-Control': 'no-cache',
10716
10770
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
10717
- ClientVersion: "5.2.4-beem.5",
10771
+ ClientVersion: "5.2.4-beem.6",
10718
10772
  'Client-Session-Id': getUUID(),
10719
10773
  'Request-Id': Date.now().toString()
10720
10774
  });
@@ -11038,6 +11092,8 @@ class RCAudienceClient {
11038
11092
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this));
11039
11093
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
11040
11094
  this.registerReportListener(this._reportListener);
11095
+ // 发送上下行数据至北极星
11096
+ this._pc.__reportR3R4ToPolaris();
11041
11097
  }
11042
11098
  // 暂存,避免同步栈内并发调用,若订阅失败需清理
11043
11099
  this._liveUrl = liveUrl;
@@ -11222,6 +11278,8 @@ class RCAudienceLivingRoom {
11222
11278
  rTrack.__innerSetMediaStreamTrack(track);
11223
11279
  this._callAppListener('onTrackReady', rTrack);
11224
11280
  });
11281
+ // 发送上下行数据至北极星
11282
+ this._pc.__reportR3R4ToPolaris();
11225
11283
  // 房间主播加入|离开房间、发布|取消发布资源变更监听
11226
11284
  this._context.onrtcdatachange = this.singalDataChange.bind(this);
11227
11285
  }
@@ -12743,9 +12801,9 @@ const installer = {
12743
12801
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
12744
12802
  return false;
12745
12803
  }
12746
- VersionManage.add('plugin-rtc', "5.2.4-beem.5");
12747
- if (!VersionManage.validEngine("4.6.0-beem.5")) {
12748
- logger.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.5"}'.`);
12804
+ VersionManage.add('plugin-rtc', "5.2.4-beem.6");
12805
+ if (!VersionManage.validEngine("4.6.0-beem.7")) {
12806
+ logger.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.7"}'.`);
12749
12807
  return false;
12750
12808
  }
12751
12809
  return true;
@@ -12753,7 +12811,7 @@ const installer = {
12753
12811
  setup(context, runtime, options = {}) {
12754
12812
  logger.setLogLevel(options.logLevel);
12755
12813
  logger.setLogStdout(options.logStdout);
12756
- logger.warn(`RCRTC Version: ${"5.2.4-beem.5"}, Commit: ${"13f398c4a680ab6054d831b2e76e51f68a677de9"}`);
12814
+ logger.warn(`RCRTC Version: ${"5.2.4-beem.6"}, Commit: ${"394e0005026dc17525168cd28dcaf60009b800ac"}`);
12757
12815
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
12758
12816
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
12759
12817
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4-beem.5
3
- * CommitId - 13f398c4a680ab6054d831b2e76e51f68a677de9
4
- * Mon May 23 2022 11:07:54 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.4-beem.6
3
+ * CommitId - 394e0005026dc17525168cd28dcaf60009b800ac
4
+ * Thu May 26 2022 17:01:57 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  'use strict';
@@ -6585,20 +6585,21 @@ exports.RCRTCPingResult = void 0;
6585
6585
  /**
6586
6586
  * rtcping 间隔
6587
6587
  */
6588
- const PING_GAP = 10 * 1000;
6588
+ const PING_GAP = 5 * 1000;
6589
6589
  /**
6590
6590
  * rtcping 超时时间
6591
6591
  */
6592
- const PING_TIMEOUT = 10 * 1000;
6592
+ const PING_TIMEOUT = 5 * 1000;
6593
6593
  /**
6594
- * RTCPing 类,累计 1 分钟未能正确收到 Ping 值则认为 ping 失败
6594
+ * RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
6595
6595
  */
6596
6596
  class Pinger {
6597
- constructor(_roomId, _roomMode, _context, _gap = PING_GAP) {
6597
+ constructor(_roomId, _roomMode, _context, _gap = PING_GAP, _offlineKickTime = 60 * 1000) {
6598
6598
  this._roomId = _roomId;
6599
6599
  this._roomMode = _roomMode;
6600
6600
  this._context = _context;
6601
6601
  this._gap = _gap;
6602
+ this._offlineKickTime = _offlineKickTime;
6602
6603
  /**
6603
6604
  * 记录最近一次成功的 Ping 时间戳
6604
6605
  */
@@ -6645,8 +6646,8 @@ class Pinger {
6645
6646
  }
6646
6647
  logger.warn(`rtcping failed -> code: ${code}`);
6647
6648
  (_b = this.onPingResult) === null || _b === void 0 ? void 0 : _b.call(this, exports.RCRTCPingResult.FAIL);
6648
- // 超出 1 分钟未成功进行 rtcping 操作,或用户已不存在于房间内时,通知客户离线
6649
- if (code === 40003 || now - this._latestTimestamp > 60 * 1000) {
6649
+ // 超出 _offlineKickTime ping 成功,或用户已不存在于房间内时,通知客户离线
6650
+ if (code === 40003 || now - this._latestTimestamp > this._offlineKickTime) {
6650
6651
  this.stop();
6651
6652
  (_c = this.onFailed) === null || _c === void 0 ? void 0 : _c.call(this, code === 40003);
6652
6653
  return;
@@ -8016,6 +8017,8 @@ class RCRTCPeerConnection extends engine.EventEmitter {
8016
8017
  this._reTryExchangeTimer = null;
8017
8018
  // peerConnection stats 计时器
8018
8019
  this._reportStatsTimer = null;
8020
+ // 上报上下行数据至北极星定时器
8021
+ this._reportR3R4ToPolarisTimer = null;
8019
8022
  this._reportListener = null;
8020
8023
  const sdpSemantics = ASdpStrategy.getSdpSemantics();
8021
8024
  const peer = this._rtcPeerConn = new RTCPeerConnection({ sdpSemantics });
@@ -8239,23 +8242,44 @@ class RCRTCPeerConnection extends engine.EventEmitter {
8239
8242
  * @todo
8240
8243
  */
8241
8244
  _reportHandle() {
8242
- var _a, _b, _c;
8245
+ var _a, _b;
8243
8246
  return __awaiter(this, void 0, void 0, function* () {
8244
8247
  const formatData = yield this._getStatsData();
8245
8248
  if (!formatData) {
8246
8249
  return;
8247
8250
  }
8251
+ /**
8252
+ * 组装用户层抛出数据
8253
+ */
8254
+ const reportData = this._createRCRTCStateReport(formatData);
8255
+ (_b = (_a = this._reportListener) === null || _a === void 0 ? void 0 : _a.onStateReport) === null || _b === void 0 ? void 0 : _b.call(_a, reportData);
8256
+ });
8257
+ }
8258
+ /**
8259
+ * 北极星上报 R3、R4 数据
8260
+ */
8261
+ _sendR3R4Data() {
8262
+ var _a;
8263
+ return __awaiter(this, void 0, void 0, function* () {
8264
+ const formatData = yield this._getStatsData();
8265
+ if (!formatData) {
8266
+ return true;
8267
+ }
8248
8268
  if (formatData.senders.length || formatData.receivers.length) {
8249
8269
  /**
8250
8270
  * 组装北极星上报 R3、R4 数据并发送
8251
8271
  */
8252
- (_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData);
8272
+ return yield ((_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData));
8253
8273
  }
8254
- /**
8255
- * 组装用户层抛出数据
8256
- */
8257
- const reportData = this._createRCRTCStateReport(formatData);
8258
- (_c = (_b = this._reportListener) === null || _b === void 0 ? void 0 : _b.onStateReport) === null || _c === void 0 ? void 0 : _c.call(_b, reportData);
8274
+ });
8275
+ }
8276
+ /**
8277
+ * 2s 给北极星上报一次 R3、R4
8278
+ */
8279
+ __reportR3R4ToPolaris() {
8280
+ return __awaiter(this, void 0, void 0, function* () {
8281
+ yield this._sendR3R4Data();
8282
+ this._reportR3R4ToPolarisTimer = setTimeout(this.__reportR3R4ToPolaris.bind(this), 2000);
8259
8283
  });
8260
8284
  }
8261
8285
  getRTCPeerConn() {
@@ -8264,6 +8288,7 @@ class RCRTCPeerConnection extends engine.EventEmitter {
8264
8288
  destroy() {
8265
8289
  this.clear();
8266
8290
  this.clearReTryExchangeTimer();
8291
+ clearTimeout(this._reportR3R4ToPolarisTimer);
8267
8292
  // 停止计时
8268
8293
  if (this._reportStatsTimer) {
8269
8294
  clearInterval(this._reportStatsTimer);
@@ -8322,7 +8347,20 @@ class PolarisReporter {
8322
8347
  this._userRole = _userRole;
8323
8348
  }
8324
8349
  _send(report) {
8325
- this._context.getConnectionStatus() === engine.ConnectionStatus.CONNECTED && this._context.setRTCState(this._roomId, report);
8350
+ return __awaiter(this, void 0, void 0, function* () {
8351
+ let isSuccess = false;
8352
+ if (this._context.getConnectionStatus() !== engine.ConnectionStatus.CONNECTED) {
8353
+ return isSuccess;
8354
+ }
8355
+ const sendCode = yield this._context.setRTCState(this._roomId, report);
8356
+ if (sendCode === engine.ErrorCode.SUCCESS) {
8357
+ isSuccess = true;
8358
+ }
8359
+ else {
8360
+ isSuccess = false;
8361
+ }
8362
+ return isSuccess;
8363
+ });
8326
8364
  }
8327
8365
  _getClientID() {
8328
8366
  const key = 'uuid';
@@ -8365,101 +8403,113 @@ class PolarisReporter {
8365
8403
  return polarisTrackId;
8366
8404
  }
8367
8405
  sendR3R4Data(data) {
8368
- const { iceCandidatePair, senders, receivers } = data;
8369
- /**
8370
- * 上下行 track 包含的公共字段
8371
- */
8372
- const baseData = {
8373
- bitrateSend: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateSend) || STAT_NONE,
8374
- bitrateRecv: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateRecv) || STAT_NONE,
8375
- networkType: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.networkType) || 'unknown',
8376
- rtt: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.rtt) || STAT_NONE,
8377
- localAddress: `${(iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.IP) || STAT_NONE}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.port}`,
8378
- remoteAddress: `${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remoteIP}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remotePort}`,
8379
- receiveBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableIncomingBitrate) || STAT_NONE,
8380
- sendBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableOutgoingBitrate) || STAT_NONE,
8381
- packetsLost: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) || STAT_NONE,
8382
- deviceId: this._context.getCurrentId()
8383
- };
8384
- let r3 = `R3\t${baseData.bitrateSend}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8385
- let r4 = `R4\t${baseData.bitrateRecv}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8386
- /**
8387
- * 北极星上报 sender tracks 中的字段
8388
- */
8389
- const R3TrackData = senders.map((item) => {
8390
- var _a;
8391
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsSent, encoderImplementation } = item;
8392
- const trackId = this._getPolarisTrackId(resourceId);
8406
+ return __awaiter(this, void 0, void 0, function* () {
8407
+ const { iceCandidatePair, senders, receivers } = data;
8393
8408
  /**
8394
- * 小流需去掉 _tiny
8409
+ * 上下行 track 包含的公共字段
8395
8410
  */
8396
- const realResourceId = this._getRealResourceId(resourceId);
8397
- return {
8398
- trackId,
8399
- googCodecName: encoderImplementation || String(STAT_NONE),
8400
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8401
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8402
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8403
- frameRate: frameRate || STAT_NONE,
8404
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8405
- jitter: jitter || STAT_NONE,
8406
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8407
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8408
- rtt: rtt || STAT_NONE,
8409
- googFirsSent,
8410
- samplingRate,
8411
- googRenderDelayMs,
8412
- encoderImplementation: encoderImplementation || String(STAT_NONE),
8413
- trackState: ((_a = this._crtRTCRoom.getLocalTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8411
+ const baseData = {
8412
+ bitrateSend: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateSend) || STAT_NONE,
8413
+ bitrateRecv: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateRecv) || STAT_NONE,
8414
+ networkType: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.networkType) || 'unknown',
8415
+ rtt: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.rtt) || STAT_NONE,
8416
+ localAddress: `${(iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.IP) || STAT_NONE}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.port}`,
8417
+ remoteAddress: `${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remoteIP}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remotePort}`,
8418
+ receiveBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableIncomingBitrate) || STAT_NONE,
8419
+ sendBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableOutgoingBitrate) || STAT_NONE,
8420
+ packetsLost: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) || STAT_NONE,
8421
+ deviceId: this._context.getCurrentId()
8414
8422
  };
8415
- });
8416
- /**
8417
- * 北极星上报 received tracks 中的字段
8418
- */
8419
- const R4TrackData = receivers.filter(item => {
8420
- // unified-plan 下 inactive 的数据会继续携带 ssrc,导致无 trackId
8421
- return !!item.trackId;
8422
- }).map((item) => {
8423
- var _a;
8424
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsReceived, codecImplementationName } = item;
8425
- const trackId = this._getPolarisTrackId(resourceId);
8423
+ let r3 = `R3\t${baseData.bitrateSend}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8424
+ let r4 = `R4\t${baseData.bitrateRecv}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8426
8425
  /**
8427
- * 小流需去掉 _tiny
8426
+ * 北极星上报 sender tracks 中的字段
8428
8427
  */
8429
- const realResourceId = this._getRealResourceId(resourceId);
8430
- return {
8431
- trackId,
8432
- googCodecName: codecImplementationName || String(STAT_NONE),
8433
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8434
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8435
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8436
- frameRate: frameRate || STAT_NONE,
8437
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8438
- jitter: jitter || STAT_NONE,
8439
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8440
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8441
- rtt: rtt || STAT_NONE,
8442
- googFirsReceived,
8443
- samplingRate,
8444
- googRenderDelayMs,
8445
- codecImplementationName: codecImplementationName || String(STAT_NONE),
8446
- trackState: ((_a = this._crtRTCRoom.getRemoteTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8447
- };
8428
+ const R3TrackData = senders.map((item) => {
8429
+ var _a;
8430
+ const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsSent, encoderImplementation } = item;
8431
+ const trackId = this._getPolarisTrackId(resourceId);
8432
+ /**
8433
+ * 小流需去掉 _tiny
8434
+ */
8435
+ const realResourceId = this._getRealResourceId(resourceId);
8436
+ return {
8437
+ trackId,
8438
+ googCodecName: encoderImplementation || String(STAT_NONE),
8439
+ audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8440
+ bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8441
+ packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8442
+ frameRate: frameRate || STAT_NONE,
8443
+ resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8444
+ jitter: jitter || STAT_NONE,
8445
+ nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8446
+ pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8447
+ rtt: rtt || STAT_NONE,
8448
+ googFirsSent,
8449
+ samplingRate,
8450
+ googRenderDelayMs,
8451
+ encoderImplementation: encoderImplementation || String(STAT_NONE),
8452
+ trackState: ((_a = this._crtRTCRoom.getLocalTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8453
+ };
8454
+ });
8455
+ /**
8456
+ * 北极星上报 received tracks 中的字段
8457
+ */
8458
+ const R4TrackData = receivers.filter(item => {
8459
+ // unified-plan 下 inactive 的数据会继续携带 ssrc,导致无 trackId
8460
+ return !!item.trackId;
8461
+ }).map((item) => {
8462
+ var _a;
8463
+ const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsReceived, codecImplementationName } = item;
8464
+ const trackId = this._getPolarisTrackId(resourceId);
8465
+ /**
8466
+ * 小流需去掉 _tiny
8467
+ */
8468
+ const realResourceId = this._getRealResourceId(resourceId);
8469
+ return {
8470
+ trackId,
8471
+ googCodecName: codecImplementationName || String(STAT_NONE),
8472
+ audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8473
+ bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8474
+ packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8475
+ frameRate: frameRate || STAT_NONE,
8476
+ resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8477
+ jitter: jitter || STAT_NONE,
8478
+ nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8479
+ pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8480
+ rtt: rtt || STAT_NONE,
8481
+ googFirsReceived,
8482
+ samplingRate,
8483
+ googRenderDelayMs,
8484
+ codecImplementationName: codecImplementationName || String(STAT_NONE),
8485
+ trackState: ((_a = this._crtRTCRoom.getRemoteTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8486
+ };
8487
+ });
8488
+ let senderIsSuccess = false;
8489
+ r3 += R3TrackData.map((item) => {
8490
+ return `${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}`;
8491
+ }).join('\n');
8492
+ if (data.senders.length) {
8493
+ senderIsSuccess = yield this._send(r3 + `\r${this._userRole}`);
8494
+ }
8495
+ let receiverIsSuccess = false;
8496
+ r4 += R4TrackData.map((item) => {
8497
+ return `${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}`;
8498
+ }).join('\n');
8499
+ if (data.receivers.length) {
8500
+ receiverIsSuccess = yield this._send(r4 + `\r${this._userRole}`);
8501
+ }
8502
+ if (!senderIsSuccess && !receiverIsSuccess) {
8503
+ return false;
8504
+ }
8505
+ return true;
8448
8506
  });
8449
- r3 += R3TrackData.map((item) => {
8450
- return `${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}`;
8451
- }).join('\n');
8452
- data.senders.length && this._send(r3 + `\r${this._userRole}`);
8453
- r4 += R4TrackData.map((item) => {
8454
- return `${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}`;
8455
- }).join('\n');
8456
- data.receivers.length && this._send(r4 + `\r${this._userRole}`);
8457
8507
  }
8458
8508
  /**
8459
8509
  * 加入房间
8460
8510
  */
8461
8511
  sendR1() {
8462
- const rtcVersion = "5.2.4-beem.5";
8512
+ const rtcVersion = "5.2.4-beem.6";
8463
8513
  const imVersion = this._context.getCoreVersion();
8464
8514
  const platform = 'web';
8465
8515
  const pcName = navigator.platform;
@@ -8634,14 +8684,18 @@ class RCAbstractRoom {
8634
8684
  * 观众升级为主播后不会收到全量 uri 消息,需直接触发人员、资源变更
8635
8685
  */
8636
8686
  isUpgrade && this._afterChangedRole(data);
8687
+ // 服务下发的 rtcping 超时时间,单位为秒
8688
+ const offlineKickTime = data.offlineKickTime * 1000;
8637
8689
  // 开始心跳,心跳失败时主动退出房间
8638
- this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap);
8690
+ this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap, offlineKickTime);
8639
8691
  this._pinger.onFailed = this._kickoff.bind(this);
8640
8692
  this._pinger.onPingResult = this._handlePingResult.bind(this);
8641
8693
  this._pinger.start();
8642
8694
  this._polarisReport = new PolarisReporter(this._context, this._runtime, this._roomId, this);
8643
8695
  this._polarisReport.sendR1();
8644
8696
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this), this._polarisReport);
8697
+ // 发送上下行数据至北极星
8698
+ this._pc.__reportR3R4ToPolaris();
8645
8699
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
8646
8700
  this._pc.on(RCLocalTrack.__INNER_EVENT_MUTED_CHANGE__, this._onLocalTrackMuted, this);
8647
8701
  this._pc.on(RCLocalTrack.__INNER_EVENT_DESTROY__, this._onLocalTrackDestroied, this);
@@ -10717,7 +10771,7 @@ const getCommonHeader = () => ({
10717
10771
  'Content-Type': 'application/json;charset=UTF-8',
10718
10772
  'Cache-Control': 'no-cache',
10719
10773
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
10720
- ClientVersion: "5.2.4-beem.5",
10774
+ ClientVersion: "5.2.4-beem.6",
10721
10775
  'Client-Session-Id': getUUID(),
10722
10776
  'Request-Id': Date.now().toString()
10723
10777
  });
@@ -11041,6 +11095,8 @@ class RCAudienceClient {
11041
11095
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this));
11042
11096
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
11043
11097
  this.registerReportListener(this._reportListener);
11098
+ // 发送上下行数据至北极星
11099
+ this._pc.__reportR3R4ToPolaris();
11044
11100
  }
11045
11101
  // 暂存,避免同步栈内并发调用,若订阅失败需清理
11046
11102
  this._liveUrl = liveUrl;
@@ -11225,6 +11281,8 @@ class RCAudienceLivingRoom {
11225
11281
  rTrack.__innerSetMediaStreamTrack(track);
11226
11282
  this._callAppListener('onTrackReady', rTrack);
11227
11283
  });
11284
+ // 发送上下行数据至北极星
11285
+ this._pc.__reportR3R4ToPolaris();
11228
11286
  // 房间主播加入|离开房间、发布|取消发布资源变更监听
11229
11287
  this._context.onrtcdatachange = this.singalDataChange.bind(this);
11230
11288
  }
@@ -12746,9 +12804,9 @@ const installer = {
12746
12804
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
12747
12805
  return false;
12748
12806
  }
12749
- engine.VersionManage.add('plugin-rtc', "5.2.4-beem.5");
12750
- if (!engine.VersionManage.validEngine("4.6.0-beem.5")) {
12751
- logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.5"}'.`);
12807
+ engine.VersionManage.add('plugin-rtc', "5.2.4-beem.6");
12808
+ if (!engine.VersionManage.validEngine("4.6.0-beem.7")) {
12809
+ logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.7"}'.`);
12752
12810
  return false;
12753
12811
  }
12754
12812
  return true;
@@ -12756,7 +12814,7 @@ const installer = {
12756
12814
  setup(context, runtime, options = {}) {
12757
12815
  logger.setLogLevel(options.logLevel);
12758
12816
  logger.setLogStdout(options.logStdout);
12759
- logger.warn(`RCRTC Version: ${"5.2.4-beem.5"}, Commit: ${"13f398c4a680ab6054d831b2e76e51f68a677de9"}`);
12817
+ logger.warn(`RCRTC Version: ${"5.2.4-beem.6"}, Commit: ${"394e0005026dc17525168cd28dcaf60009b800ac"}`);
12760
12818
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
12761
12819
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
12762
12820
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);
package/dist/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4-beem.5
3
- * CommitId - 13f398c4a680ab6054d831b2e76e51f68a677de9
4
- * Mon May 23 2022 11:07:54 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.4-beem.6
3
+ * CommitId - 394e0005026dc17525168cd28dcaf60009b800ac
4
+ * Thu May 26 2022 17:01:57 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  (function (global, factory) {
@@ -6585,20 +6585,21 @@
6585
6585
  /**
6586
6586
  * rtcping 间隔
6587
6587
  */
6588
- const PING_GAP = 10 * 1000;
6588
+ const PING_GAP = 5 * 1000;
6589
6589
  /**
6590
6590
  * rtcping 超时时间
6591
6591
  */
6592
- const PING_TIMEOUT = 10 * 1000;
6592
+ const PING_TIMEOUT = 5 * 1000;
6593
6593
  /**
6594
- * RTCPing 类,累计 1 分钟未能正确收到 Ping 值则认为 ping 失败
6594
+ * RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
6595
6595
  */
6596
6596
  class Pinger {
6597
- constructor(_roomId, _roomMode, _context, _gap = PING_GAP) {
6597
+ constructor(_roomId, _roomMode, _context, _gap = PING_GAP, _offlineKickTime = 60 * 1000) {
6598
6598
  this._roomId = _roomId;
6599
6599
  this._roomMode = _roomMode;
6600
6600
  this._context = _context;
6601
6601
  this._gap = _gap;
6602
+ this._offlineKickTime = _offlineKickTime;
6602
6603
  /**
6603
6604
  * 记录最近一次成功的 Ping 时间戳
6604
6605
  */
@@ -6645,8 +6646,8 @@
6645
6646
  }
6646
6647
  logger.warn(`rtcping failed -> code: ${code}`);
6647
6648
  (_b = this.onPingResult) === null || _b === void 0 ? void 0 : _b.call(this, exports.RCRTCPingResult.FAIL);
6648
- // 超出 1 分钟未成功进行 rtcping 操作,或用户已不存在于房间内时,通知客户离线
6649
- if (code === 40003 || now - this._latestTimestamp > 60 * 1000) {
6649
+ // 超出 _offlineKickTime ping 成功,或用户已不存在于房间内时,通知客户离线
6650
+ if (code === 40003 || now - this._latestTimestamp > this._offlineKickTime) {
6650
6651
  this.stop();
6651
6652
  (_c = this.onFailed) === null || _c === void 0 ? void 0 : _c.call(this, code === 40003);
6652
6653
  return;
@@ -8016,6 +8017,8 @@
8016
8017
  this._reTryExchangeTimer = null;
8017
8018
  // peerConnection stats 计时器
8018
8019
  this._reportStatsTimer = null;
8020
+ // 上报上下行数据至北极星定时器
8021
+ this._reportR3R4ToPolarisTimer = null;
8019
8022
  this._reportListener = null;
8020
8023
  const sdpSemantics = ASdpStrategy.getSdpSemantics();
8021
8024
  const peer = this._rtcPeerConn = new RTCPeerConnection({ sdpSemantics });
@@ -8239,23 +8242,44 @@
8239
8242
  * @todo
8240
8243
  */
8241
8244
  _reportHandle() {
8242
- var _a, _b, _c;
8245
+ var _a, _b;
8243
8246
  return __awaiter(this, void 0, void 0, function* () {
8244
8247
  const formatData = yield this._getStatsData();
8245
8248
  if (!formatData) {
8246
8249
  return;
8247
8250
  }
8251
+ /**
8252
+ * 组装用户层抛出数据
8253
+ */
8254
+ const reportData = this._createRCRTCStateReport(formatData);
8255
+ (_b = (_a = this._reportListener) === null || _a === void 0 ? void 0 : _a.onStateReport) === null || _b === void 0 ? void 0 : _b.call(_a, reportData);
8256
+ });
8257
+ }
8258
+ /**
8259
+ * 北极星上报 R3、R4 数据
8260
+ */
8261
+ _sendR3R4Data() {
8262
+ var _a;
8263
+ return __awaiter(this, void 0, void 0, function* () {
8264
+ const formatData = yield this._getStatsData();
8265
+ if (!formatData) {
8266
+ return true;
8267
+ }
8248
8268
  if (formatData.senders.length || formatData.receivers.length) {
8249
8269
  /**
8250
8270
  * 组装北极星上报 R3、R4 数据并发送
8251
8271
  */
8252
- (_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData);
8272
+ return yield ((_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData));
8253
8273
  }
8254
- /**
8255
- * 组装用户层抛出数据
8256
- */
8257
- const reportData = this._createRCRTCStateReport(formatData);
8258
- (_c = (_b = this._reportListener) === null || _b === void 0 ? void 0 : _b.onStateReport) === null || _c === void 0 ? void 0 : _c.call(_b, reportData);
8274
+ });
8275
+ }
8276
+ /**
8277
+ * 2s 给北极星上报一次 R3、R4
8278
+ */
8279
+ __reportR3R4ToPolaris() {
8280
+ return __awaiter(this, void 0, void 0, function* () {
8281
+ yield this._sendR3R4Data();
8282
+ this._reportR3R4ToPolarisTimer = setTimeout(this.__reportR3R4ToPolaris.bind(this), 2000);
8259
8283
  });
8260
8284
  }
8261
8285
  getRTCPeerConn() {
@@ -8264,6 +8288,7 @@
8264
8288
  destroy() {
8265
8289
  this.clear();
8266
8290
  this.clearReTryExchangeTimer();
8291
+ clearTimeout(this._reportR3R4ToPolarisTimer);
8267
8292
  // 停止计时
8268
8293
  if (this._reportStatsTimer) {
8269
8294
  clearInterval(this._reportStatsTimer);
@@ -8322,7 +8347,20 @@
8322
8347
  this._userRole = _userRole;
8323
8348
  }
8324
8349
  _send(report) {
8325
- this._context.getConnectionStatus() === engine.ConnectionStatus.CONNECTED && this._context.setRTCState(this._roomId, report);
8350
+ return __awaiter(this, void 0, void 0, function* () {
8351
+ let isSuccess = false;
8352
+ if (this._context.getConnectionStatus() !== engine.ConnectionStatus.CONNECTED) {
8353
+ return isSuccess;
8354
+ }
8355
+ const sendCode = yield this._context.setRTCState(this._roomId, report);
8356
+ if (sendCode === engine.ErrorCode.SUCCESS) {
8357
+ isSuccess = true;
8358
+ }
8359
+ else {
8360
+ isSuccess = false;
8361
+ }
8362
+ return isSuccess;
8363
+ });
8326
8364
  }
8327
8365
  _getClientID() {
8328
8366
  const key = 'uuid';
@@ -8365,101 +8403,113 @@
8365
8403
  return polarisTrackId;
8366
8404
  }
8367
8405
  sendR3R4Data(data) {
8368
- const { iceCandidatePair, senders, receivers } = data;
8369
- /**
8370
- * 上下行 track 包含的公共字段
8371
- */
8372
- const baseData = {
8373
- bitrateSend: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateSend) || STAT_NONE,
8374
- bitrateRecv: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateRecv) || STAT_NONE,
8375
- networkType: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.networkType) || 'unknown',
8376
- rtt: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.rtt) || STAT_NONE,
8377
- localAddress: `${(iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.IP) || STAT_NONE}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.port}`,
8378
- remoteAddress: `${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remoteIP}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remotePort}`,
8379
- receiveBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableIncomingBitrate) || STAT_NONE,
8380
- sendBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableOutgoingBitrate) || STAT_NONE,
8381
- packetsLost: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) || STAT_NONE,
8382
- deviceId: this._context.getCurrentId()
8383
- };
8384
- let r3 = `R3\t${baseData.bitrateSend}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8385
- let r4 = `R4\t${baseData.bitrateRecv}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8386
- /**
8387
- * 北极星上报 sender tracks 中的字段
8388
- */
8389
- const R3TrackData = senders.map((item) => {
8390
- var _a;
8391
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsSent, encoderImplementation } = item;
8392
- const trackId = this._getPolarisTrackId(resourceId);
8406
+ return __awaiter(this, void 0, void 0, function* () {
8407
+ const { iceCandidatePair, senders, receivers } = data;
8393
8408
  /**
8394
- * 小流需去掉 _tiny
8409
+ * 上下行 track 包含的公共字段
8395
8410
  */
8396
- const realResourceId = this._getRealResourceId(resourceId);
8397
- return {
8398
- trackId,
8399
- googCodecName: encoderImplementation || String(STAT_NONE),
8400
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8401
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8402
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8403
- frameRate: frameRate || STAT_NONE,
8404
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8405
- jitter: jitter || STAT_NONE,
8406
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8407
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8408
- rtt: rtt || STAT_NONE,
8409
- googFirsSent,
8410
- samplingRate,
8411
- googRenderDelayMs,
8412
- encoderImplementation: encoderImplementation || String(STAT_NONE),
8413
- trackState: ((_a = this._crtRTCRoom.getLocalTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8411
+ const baseData = {
8412
+ bitrateSend: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateSend) || STAT_NONE,
8413
+ bitrateRecv: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateRecv) || STAT_NONE,
8414
+ networkType: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.networkType) || 'unknown',
8415
+ rtt: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.rtt) || STAT_NONE,
8416
+ localAddress: `${(iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.IP) || STAT_NONE}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.port}`,
8417
+ remoteAddress: `${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remoteIP}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remotePort}`,
8418
+ receiveBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableIncomingBitrate) || STAT_NONE,
8419
+ sendBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableOutgoingBitrate) || STAT_NONE,
8420
+ packetsLost: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) || STAT_NONE,
8421
+ deviceId: this._context.getCurrentId()
8414
8422
  };
8415
- });
8416
- /**
8417
- * 北极星上报 received tracks 中的字段
8418
- */
8419
- const R4TrackData = receivers.filter(item => {
8420
- // unified-plan 下 inactive 的数据会继续携带 ssrc,导致无 trackId
8421
- return !!item.trackId;
8422
- }).map((item) => {
8423
- var _a;
8424
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsReceived, codecImplementationName } = item;
8425
- const trackId = this._getPolarisTrackId(resourceId);
8423
+ let r3 = `R3\t${baseData.bitrateSend}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8424
+ let r4 = `R4\t${baseData.bitrateRecv}\t-1\t-1\t-1\t${baseData.networkType}\t${baseData.rtt}\t${baseData.localAddress}\t${baseData.receiveBand}\t${baseData.sendBand}\t${baseData.packetsLost}\t${baseData.deviceId}\r`;
8426
8425
  /**
8427
- * 小流需去掉 _tiny
8426
+ * 北极星上报 sender tracks 中的字段
8428
8427
  */
8429
- const realResourceId = this._getRealResourceId(resourceId);
8430
- return {
8431
- trackId,
8432
- googCodecName: codecImplementationName || String(STAT_NONE),
8433
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8434
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8435
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8436
- frameRate: frameRate || STAT_NONE,
8437
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8438
- jitter: jitter || STAT_NONE,
8439
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8440
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8441
- rtt: rtt || STAT_NONE,
8442
- googFirsReceived,
8443
- samplingRate,
8444
- googRenderDelayMs,
8445
- codecImplementationName: codecImplementationName || String(STAT_NONE),
8446
- trackState: ((_a = this._crtRTCRoom.getRemoteTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8447
- };
8428
+ const R3TrackData = senders.map((item) => {
8429
+ var _a;
8430
+ const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsSent, encoderImplementation } = item;
8431
+ const trackId = this._getPolarisTrackId(resourceId);
8432
+ /**
8433
+ * 小流需去掉 _tiny
8434
+ */
8435
+ const realResourceId = this._getRealResourceId(resourceId);
8436
+ return {
8437
+ trackId,
8438
+ googCodecName: encoderImplementation || String(STAT_NONE),
8439
+ audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8440
+ bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8441
+ packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8442
+ frameRate: frameRate || STAT_NONE,
8443
+ resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8444
+ jitter: jitter || STAT_NONE,
8445
+ nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8446
+ pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8447
+ rtt: rtt || STAT_NONE,
8448
+ googFirsSent,
8449
+ samplingRate,
8450
+ googRenderDelayMs,
8451
+ encoderImplementation: encoderImplementation || String(STAT_NONE),
8452
+ trackState: ((_a = this._crtRTCRoom.getLocalTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8453
+ };
8454
+ });
8455
+ /**
8456
+ * 北极星上报 received tracks 中的字段
8457
+ */
8458
+ const R4TrackData = receivers.filter(item => {
8459
+ // unified-plan 下 inactive 的数据会继续携带 ssrc,导致无 trackId
8460
+ return !!item.trackId;
8461
+ }).map((item) => {
8462
+ var _a;
8463
+ const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsReceived, codecImplementationName } = item;
8464
+ const trackId = this._getPolarisTrackId(resourceId);
8465
+ /**
8466
+ * 小流需去掉 _tiny
8467
+ */
8468
+ const realResourceId = this._getRealResourceId(resourceId);
8469
+ return {
8470
+ trackId,
8471
+ googCodecName: codecImplementationName || String(STAT_NONE),
8472
+ audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8473
+ bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8474
+ packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8475
+ frameRate: frameRate || STAT_NONE,
8476
+ resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8477
+ jitter: jitter || STAT_NONE,
8478
+ nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8479
+ pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8480
+ rtt: rtt || STAT_NONE,
8481
+ googFirsReceived,
8482
+ samplingRate,
8483
+ googRenderDelayMs,
8484
+ codecImplementationName: codecImplementationName || String(STAT_NONE),
8485
+ trackState: ((_a = this._crtRTCRoom.getRemoteTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8486
+ };
8487
+ });
8488
+ let senderIsSuccess = false;
8489
+ r3 += R3TrackData.map((item) => {
8490
+ return `${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}`;
8491
+ }).join('\n');
8492
+ if (data.senders.length) {
8493
+ senderIsSuccess = yield this._send(r3 + `\r${this._userRole}`);
8494
+ }
8495
+ let receiverIsSuccess = false;
8496
+ r4 += R4TrackData.map((item) => {
8497
+ return `${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}`;
8498
+ }).join('\n');
8499
+ if (data.receivers.length) {
8500
+ receiverIsSuccess = yield this._send(r4 + `\r${this._userRole}`);
8501
+ }
8502
+ if (!senderIsSuccess && !receiverIsSuccess) {
8503
+ return false;
8504
+ }
8505
+ return true;
8448
8506
  });
8449
- r3 += R3TrackData.map((item) => {
8450
- return `${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}`;
8451
- }).join('\n');
8452
- data.senders.length && this._send(r3 + `\r${this._userRole}`);
8453
- r4 += R4TrackData.map((item) => {
8454
- return `${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}`;
8455
- }).join('\n');
8456
- data.receivers.length && this._send(r4 + `\r${this._userRole}`);
8457
8507
  }
8458
8508
  /**
8459
8509
  * 加入房间
8460
8510
  */
8461
8511
  sendR1() {
8462
- const rtcVersion = "5.2.4-beem.5";
8512
+ const rtcVersion = "5.2.4-beem.6";
8463
8513
  const imVersion = this._context.getCoreVersion();
8464
8514
  const platform = 'web';
8465
8515
  const pcName = navigator.platform;
@@ -8634,14 +8684,18 @@
8634
8684
  * 观众升级为主播后不会收到全量 uri 消息,需直接触发人员、资源变更
8635
8685
  */
8636
8686
  isUpgrade && this._afterChangedRole(data);
8687
+ // 服务下发的 rtcping 超时时间,单位为秒
8688
+ const offlineKickTime = data.offlineKickTime * 1000;
8637
8689
  // 开始心跳,心跳失败时主动退出房间
8638
- this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap);
8690
+ this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap, offlineKickTime);
8639
8691
  this._pinger.onFailed = this._kickoff.bind(this);
8640
8692
  this._pinger.onPingResult = this._handlePingResult.bind(this);
8641
8693
  this._pinger.start();
8642
8694
  this._polarisReport = new PolarisReporter(this._context, this._runtime, this._roomId, this);
8643
8695
  this._polarisReport.sendR1();
8644
8696
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this), this._polarisReport);
8697
+ // 发送上下行数据至北极星
8698
+ this._pc.__reportR3R4ToPolaris();
8645
8699
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
8646
8700
  this._pc.on(RCLocalTrack.__INNER_EVENT_MUTED_CHANGE__, this._onLocalTrackMuted, this);
8647
8701
  this._pc.on(RCLocalTrack.__INNER_EVENT_DESTROY__, this._onLocalTrackDestroied, this);
@@ -10717,7 +10771,7 @@
10717
10771
  'Content-Type': 'application/json;charset=UTF-8',
10718
10772
  'Cache-Control': 'no-cache',
10719
10773
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
10720
- ClientVersion: "5.2.4-beem.5",
10774
+ ClientVersion: "5.2.4-beem.6",
10721
10775
  'Client-Session-Id': getUUID(),
10722
10776
  'Request-Id': Date.now().toString()
10723
10777
  });
@@ -11041,6 +11095,8 @@
11041
11095
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this));
11042
11096
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
11043
11097
  this.registerReportListener(this._reportListener);
11098
+ // 发送上下行数据至北极星
11099
+ this._pc.__reportR3R4ToPolaris();
11044
11100
  }
11045
11101
  // 暂存,避免同步栈内并发调用,若订阅失败需清理
11046
11102
  this._liveUrl = liveUrl;
@@ -11225,6 +11281,8 @@
11225
11281
  rTrack.__innerSetMediaStreamTrack(track);
11226
11282
  this._callAppListener('onTrackReady', rTrack);
11227
11283
  });
11284
+ // 发送上下行数据至北极星
11285
+ this._pc.__reportR3R4ToPolaris();
11228
11286
  // 房间主播加入|离开房间、发布|取消发布资源变更监听
11229
11287
  this._context.onrtcdatachange = this.singalDataChange.bind(this);
11230
11288
  }
@@ -12746,9 +12804,9 @@
12746
12804
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
12747
12805
  return false;
12748
12806
  }
12749
- engine.VersionManage.add('plugin-rtc', "5.2.4-beem.5");
12750
- if (!engine.VersionManage.validEngine("4.6.0-beem.5")) {
12751
- logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.5"}'.`);
12807
+ engine.VersionManage.add('plugin-rtc', "5.2.4-beem.6");
12808
+ if (!engine.VersionManage.validEngine("4.6.0-beem.7")) {
12809
+ logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.7"}'.`);
12752
12810
  return false;
12753
12811
  }
12754
12812
  return true;
@@ -12756,7 +12814,7 @@
12756
12814
  setup(context, runtime, options = {}) {
12757
12815
  logger.setLogLevel(options.logLevel);
12758
12816
  logger.setLogStdout(options.logStdout);
12759
- logger.warn(`RCRTC Version: ${"5.2.4-beem.5"}, Commit: ${"13f398c4a680ab6054d831b2e76e51f68a677de9"}`);
12817
+ logger.warn(`RCRTC Version: ${"5.2.4-beem.6"}, Commit: ${"394e0005026dc17525168cd28dcaf60009b800ac"}`);
12760
12818
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
12761
12819
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
12762
12820
  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.2.4-beem.5",
3
+ "version": "5.2.4-beem.6",
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": "4.6.0-beem.5"
34
+ "@rongcloud/engine": "4.6.0-beem.7"
35
35
  },
36
- "__commit__": "13f398c4a680ab6054d831b2e76e51f68a677de9"
36
+ "__commit__": "394e0005026dc17525168cd28dcaf60009b800ac"
37
37
  }