@rongcloud/plugin-rtc 5.2.4-beem.3 → 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.3
3
- * CommitId - b51c6e49188dcadaf70257fc1d274d978d8db68e
4
- * Fri May 20 2022 15:05:00 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.3
3
- * CommitId - b51c6e49188dcadaf70257fc1d274d978d8db68e
4
- * Fri May 20 2022 15:05:00 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';
@@ -5621,6 +5621,7 @@ var RCMediaType;
5621
5621
  RCMediaType[RCMediaType["AUDIO_VIDEO"] = 2] = "AUDIO_VIDEO";
5622
5622
  })(RCMediaType || (RCMediaType = {}));
5623
5623
 
5624
+ // export const RongRTCVideoBitrate: { [key: RCResolution]: BitrateConf } = {
5624
5625
  const RongRTCVideoBitrate = {
5625
5626
  [RCResolution.W176_H132]: { width: 176, height: 132, maxBitrate: 150, minBitrate: 80 },
5626
5627
  [RCResolution.W176_H144]: { width: 176, height: 144, maxBitrate: 160, minBitrate: 80 },
@@ -5637,23 +5638,26 @@ const RongRTCVideoBitrate = {
5637
5638
  [RCResolution.W1920_H1080]: { width: 1920, height: 1080, maxBitrate: 4000, minBitrate: 400 }
5638
5639
  };
5639
5640
  /**
5640
- * 取最接近的视频分辨率配置
5641
+ * 向上取最接近的视频分辨率配置
5641
5642
  * @param {number} width
5642
5643
  * @param {number} height
5643
5644
  */
5644
5645
  const getNearestResolution = (width, height) => {
5645
- const area = width * height;
5646
- let d = Number.MAX_VALUE;
5647
- let conf = null;
5648
- for (const key in RongRTCVideoBitrate) {
5649
- const item = RongRTCVideoBitrate[key];
5650
- const d2 = Math.abs(item.width * item.height - area);
5651
- if (d2 < d) {
5652
- conf = item;
5653
- d = d2;
5654
- }
5646
+ // 优先精准匹配
5647
+ const conf = RongRTCVideoBitrate[`W${width}_H${height}`];
5648
+ if (conf) {
5649
+ return conf;
5655
5650
  }
5656
- return conf;
5651
+ // 不规则分辨率计算最接近的配置
5652
+ const area = width * height;
5653
+ const confs = Object.keys(RongRTCVideoBitrate)
5654
+ .map(key => RongRTCVideoBitrate[key])
5655
+ // 升序
5656
+ .sort((item, item2) => item.height * item.width - item2.width * item2.height)
5657
+ // 过滤分辨率小于 area 的配置,避免分配带宽不足
5658
+ .filter(item => item.height * item.width >= area);
5659
+ // 若 confs 长度为 0 说明分辨率远大于可支持的分辨率配置,取最大配置
5660
+ return confs[0] || RongRTCVideoBitrate.W1920_H1080;
5657
5661
  };
5658
5662
  const Multiplier = {
5659
5663
  10: 1,
@@ -6219,13 +6223,18 @@ const getValue = (value) => {
6219
6223
  * @param track
6220
6224
  */
6221
6225
  const getVideoTrackInfo = (track) => {
6226
+ const settings = track.getSettings();
6222
6227
  const constraints = track.getConstraints();
6223
6228
  // firefox 平台不存在 getCapabilities 方法
6224
6229
  // const capabilities = track.getCapabilities()
6225
6230
  // const width = getValue(constraints.width) || getValue(capabilities.width)
6226
6231
  // const height = getValue(constraints.height) || getValue(capabilities.height)
6227
6232
  // const frameRate = getValue(constraints.frameRate) || getValue(capabilities.frameRate)
6228
- return { width: getValue(constraints.width), height: getValue(constraints.height), frameRate: getValue(constraints.frameRate) };
6233
+ return {
6234
+ width: settings.width || getValue(constraints.width),
6235
+ height: settings.height || getValue(constraints.height),
6236
+ frameRate: settings.frameRate || getValue(constraints.frameRate)
6237
+ };
6229
6238
  };
6230
6239
  /**
6231
6240
  * 取视频流动态码率
@@ -6234,8 +6243,8 @@ const getVideoTrackInfo = (track) => {
6234
6243
  */
6235
6244
  const getDynamicBitrate = (track) => {
6236
6245
  const { width, height, frameRate } = getVideoTrackInfo(track);
6237
- // 计算动态码率以备给 answer 使用
6238
- const config = getNearestResolution(width, height);
6246
+ // 计算动态码率,若 videoTrack 的分辨率读取失败,则以 640 * 480 的默认分辨率计算码率
6247
+ const config = getNearestResolution(width || 640, height || 480);
6239
6248
  const multiple = getBitrateMultiple(frameRate);
6240
6249
  return { min: config.minBitrate * multiple, max: config.maxBitrate * multiple };
6241
6250
  };
@@ -6573,20 +6582,21 @@ var RCRTCPingResult;
6573
6582
  /**
6574
6583
  * rtcping 间隔
6575
6584
  */
6576
- const PING_GAP = 10 * 1000;
6585
+ const PING_GAP = 5 * 1000;
6577
6586
  /**
6578
6587
  * rtcping 超时时间
6579
6588
  */
6580
- const PING_TIMEOUT = 10 * 1000;
6589
+ const PING_TIMEOUT = 5 * 1000;
6581
6590
  /**
6582
- * RTCPing 类,累计 1 分钟未能正确收到 Ping 值则认为 ping 失败
6591
+ * RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
6583
6592
  */
6584
6593
  class Pinger {
6585
- constructor(_roomId, _roomMode, _context, _gap = PING_GAP) {
6594
+ constructor(_roomId, _roomMode, _context, _gap = PING_GAP, _offlineKickTime = 60 * 1000) {
6586
6595
  this._roomId = _roomId;
6587
6596
  this._roomMode = _roomMode;
6588
6597
  this._context = _context;
6589
6598
  this._gap = _gap;
6599
+ this._offlineKickTime = _offlineKickTime;
6590
6600
  /**
6591
6601
  * 记录最近一次成功的 Ping 时间戳
6592
6602
  */
@@ -6633,8 +6643,8 @@ class Pinger {
6633
6643
  }
6634
6644
  logger.warn(`rtcping failed -> code: ${code}`);
6635
6645
  (_b = this.onPingResult) === null || _b === void 0 ? void 0 : _b.call(this, RCRTCPingResult.FAIL);
6636
- // 超出 1 分钟未成功进行 rtcping 操作,或用户已不存在于房间内时,通知客户离线
6637
- if (code === 40003 || now - this._latestTimestamp > 60 * 1000) {
6646
+ // 超出 _offlineKickTime ping 成功,或用户已不存在于房间内时,通知客户离线
6647
+ if (code === 40003 || now - this._latestTimestamp > this._offlineKickTime) {
6638
6648
  this.stop();
6639
6649
  (_c = this.onFailed) === null || _c === void 0 ? void 0 : _c.call(this, code === 40003);
6640
6650
  return;
@@ -7658,6 +7668,7 @@ class ASdpStrategy {
7658
7668
  return __awaiter(this, void 0, void 0, function* () {
7659
7669
  // 过滤行末的空格,服务可能产生空格数据
7660
7670
  sdp = sdp.replace(/\s+\r\n/g, '\r\n');
7671
+ logger.info(`set remote answer -> ${sdp}`);
7661
7672
  try {
7662
7673
  yield this._peer.setRemoteDescription({ type: 'answer', sdp });
7663
7674
  }
@@ -8003,6 +8014,8 @@ class RCRTCPeerConnection extends EventEmitter {
8003
8014
  this._reTryExchangeTimer = null;
8004
8015
  // peerConnection stats 计时器
8005
8016
  this._reportStatsTimer = null;
8017
+ // 上报上下行数据至北极星定时器
8018
+ this._reportR3R4ToPolarisTimer = null;
8006
8019
  this._reportListener = null;
8007
8020
  const sdpSemantics = ASdpStrategy.getSdpSemantics();
8008
8021
  const peer = this._rtcPeerConn = new RTCPeerConnection({ sdpSemantics });
@@ -8072,7 +8085,6 @@ class RCRTCPeerConnection extends EventEmitter {
8072
8085
  }
8073
8086
  setRemoteAnswer(answer) {
8074
8087
  return __awaiter(this, void 0, void 0, function* () {
8075
- logger.info(`set remote answer -> ${JSON.stringify(answer)}`);
8076
8088
  return this._sdpStrategy.setRemoteAnswer(answer);
8077
8089
  });
8078
8090
  }
@@ -8227,23 +8239,44 @@ class RCRTCPeerConnection extends EventEmitter {
8227
8239
  * @todo
8228
8240
  */
8229
8241
  _reportHandle() {
8230
- var _a, _b, _c;
8242
+ var _a, _b;
8231
8243
  return __awaiter(this, void 0, void 0, function* () {
8232
8244
  const formatData = yield this._getStatsData();
8233
8245
  if (!formatData) {
8234
8246
  return;
8235
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
+ }
8236
8265
  if (formatData.senders.length || formatData.receivers.length) {
8237
8266
  /**
8238
8267
  * 组装北极星上报 R3、R4 数据并发送
8239
8268
  */
8240
- (_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));
8241
8270
  }
8242
- /**
8243
- * 组装用户层抛出数据
8244
- */
8245
- const reportData = this._createRCRTCStateReport(formatData);
8246
- (_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);
8247
8280
  });
8248
8281
  }
8249
8282
  getRTCPeerConn() {
@@ -8252,6 +8285,7 @@ class RCRTCPeerConnection extends EventEmitter {
8252
8285
  destroy() {
8253
8286
  this.clear();
8254
8287
  this.clearReTryExchangeTimer();
8288
+ clearTimeout(this._reportR3R4ToPolarisTimer);
8255
8289
  // 停止计时
8256
8290
  if (this._reportStatsTimer) {
8257
8291
  clearInterval(this._reportStatsTimer);
@@ -8310,7 +8344,20 @@ class PolarisReporter {
8310
8344
  this._userRole = _userRole;
8311
8345
  }
8312
8346
  _send(report) {
8313
- 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
+ });
8314
8361
  }
8315
8362
  _getClientID() {
8316
8363
  const key = 'uuid';
@@ -8353,101 +8400,113 @@ class PolarisReporter {
8353
8400
  return polarisTrackId;
8354
8401
  }
8355
8402
  sendR3R4Data(data) {
8356
- const { iceCandidatePair, senders, receivers } = data;
8357
- /**
8358
- * 上下行 track 包含的公共字段
8359
- */
8360
- const baseData = {
8361
- bitrateSend: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateSend) || STAT_NONE,
8362
- bitrateRecv: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateRecv) || STAT_NONE,
8363
- networkType: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.networkType) || 'unknown',
8364
- rtt: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.rtt) || STAT_NONE,
8365
- localAddress: `${(iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.IP) || STAT_NONE}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.port}`,
8366
- remoteAddress: `${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remoteIP}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remotePort}`,
8367
- receiveBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableIncomingBitrate) || STAT_NONE,
8368
- sendBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableOutgoingBitrate) || STAT_NONE,
8369
- packetsLost: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) || STAT_NONE,
8370
- deviceId: this._context.getCurrentId()
8371
- };
8372
- 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`;
8373
- 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`;
8374
- /**
8375
- * 北极星上报 sender tracks 中的字段
8376
- */
8377
- const R3TrackData = senders.map((item) => {
8378
- var _a;
8379
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsSent, encoderImplementation } = item;
8380
- const trackId = this._getPolarisTrackId(resourceId);
8403
+ return __awaiter(this, void 0, void 0, function* () {
8404
+ const { iceCandidatePair, senders, receivers } = data;
8381
8405
  /**
8382
- * 小流需去掉 _tiny
8406
+ * 上下行 track 包含的公共字段
8383
8407
  */
8384
- const realResourceId = this._getRealResourceId(resourceId);
8385
- return {
8386
- trackId,
8387
- googCodecName: encoderImplementation || String(STAT_NONE),
8388
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8389
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8390
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8391
- frameRate: frameRate || STAT_NONE,
8392
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8393
- jitter: jitter || STAT_NONE,
8394
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8395
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8396
- rtt: rtt || STAT_NONE,
8397
- googFirsSent,
8398
- samplingRate,
8399
- googRenderDelayMs,
8400
- encoderImplementation: encoderImplementation || String(STAT_NONE),
8401
- 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()
8402
8419
  };
8403
- });
8404
- /**
8405
- * 北极星上报 received tracks 中的字段
8406
- */
8407
- const R4TrackData = receivers.filter(item => {
8408
- // unified-plan 下 inactive 的数据会继续携带 ssrc,导致无 trackId
8409
- return !!item.trackId;
8410
- }).map((item) => {
8411
- var _a;
8412
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsReceived, codecImplementationName } = item;
8413
- 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`;
8414
8422
  /**
8415
- * 小流需去掉 _tiny
8423
+ * 北极星上报 sender tracks 中的字段
8416
8424
  */
8417
- const realResourceId = this._getRealResourceId(resourceId);
8418
- return {
8419
- trackId,
8420
- googCodecName: codecImplementationName || String(STAT_NONE),
8421
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8422
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8423
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8424
- frameRate: frameRate || STAT_NONE,
8425
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8426
- jitter: jitter || STAT_NONE,
8427
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8428
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8429
- rtt: rtt || STAT_NONE,
8430
- googFirsReceived,
8431
- samplingRate,
8432
- googRenderDelayMs,
8433
- codecImplementationName: codecImplementationName || String(STAT_NONE),
8434
- trackState: ((_a = this._crtRTCRoom.getRemoteTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8435
- };
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;
8436
8503
  });
8437
- r3 += R3TrackData.map((item) => {
8438
- 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}`;
8439
- }).join('\n');
8440
- data.senders.length && this._send(r3 + `\r${this._userRole}`);
8441
- r4 += R4TrackData.map((item) => {
8442
- 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}`;
8443
- }).join('\n');
8444
- data.receivers.length && this._send(r4 + `\r${this._userRole}`);
8445
8504
  }
8446
8505
  /**
8447
8506
  * 加入房间
8448
8507
  */
8449
8508
  sendR1() {
8450
- const rtcVersion = "5.2.4-beem.3";
8509
+ const rtcVersion = "5.2.4-beem.6";
8451
8510
  const imVersion = this._context.getCoreVersion();
8452
8511
  const platform = 'web';
8453
8512
  const pcName = navigator.platform;
@@ -8622,14 +8681,18 @@ class RCAbstractRoom {
8622
8681
  * 观众升级为主播后不会收到全量 uri 消息,需直接触发人员、资源变更
8623
8682
  */
8624
8683
  isUpgrade && this._afterChangedRole(data);
8684
+ // 服务下发的 rtcping 超时时间,单位为秒
8685
+ const offlineKickTime = data.offlineKickTime * 1000;
8625
8686
  // 开始心跳,心跳失败时主动退出房间
8626
- this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap);
8687
+ this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap, offlineKickTime);
8627
8688
  this._pinger.onFailed = this._kickoff.bind(this);
8628
8689
  this._pinger.onPingResult = this._handlePingResult.bind(this);
8629
8690
  this._pinger.start();
8630
8691
  this._polarisReport = new PolarisReporter(this._context, this._runtime, this._roomId, this);
8631
8692
  this._polarisReport.sendR1();
8632
8693
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this), this._polarisReport);
8694
+ // 发送上下行数据至北极星
8695
+ this._pc.__reportR3R4ToPolaris();
8633
8696
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
8634
8697
  this._pc.on(RCLocalTrack.__INNER_EVENT_MUTED_CHANGE__, this._onLocalTrackMuted, this);
8635
8698
  this._pc.on(RCLocalTrack.__INNER_EVENT_DESTROY__, this._onLocalTrackDestroied, this);
@@ -10705,7 +10768,7 @@ const getCommonHeader = () => ({
10705
10768
  'Content-Type': 'application/json;charset=UTF-8',
10706
10769
  'Cache-Control': 'no-cache',
10707
10770
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
10708
- ClientVersion: "5.2.4-beem.3",
10771
+ ClientVersion: "5.2.4-beem.6",
10709
10772
  'Client-Session-Id': getUUID(),
10710
10773
  'Request-Id': Date.now().toString()
10711
10774
  });
@@ -11029,6 +11092,8 @@ class RCAudienceClient {
11029
11092
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this));
11030
11093
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
11031
11094
  this.registerReportListener(this._reportListener);
11095
+ // 发送上下行数据至北极星
11096
+ this._pc.__reportR3R4ToPolaris();
11032
11097
  }
11033
11098
  // 暂存,避免同步栈内并发调用,若订阅失败需清理
11034
11099
  this._liveUrl = liveUrl;
@@ -11213,6 +11278,8 @@ class RCAudienceLivingRoom {
11213
11278
  rTrack.__innerSetMediaStreamTrack(track);
11214
11279
  this._callAppListener('onTrackReady', rTrack);
11215
11280
  });
11281
+ // 发送上下行数据至北极星
11282
+ this._pc.__reportR3R4ToPolaris();
11216
11283
  // 房间主播加入|离开房间、发布|取消发布资源变更监听
11217
11284
  this._context.onrtcdatachange = this.singalDataChange.bind(this);
11218
11285
  }
@@ -12734,9 +12801,9 @@ const installer = {
12734
12801
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
12735
12802
  return false;
12736
12803
  }
12737
- VersionManage.add('plugin-rtc', "5.2.4-beem.3");
12738
- if (!VersionManage.validEngine("4.6.0-beem.5")) {
12739
- 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"}'.`);
12740
12807
  return false;
12741
12808
  }
12742
12809
  return true;
@@ -12744,7 +12811,7 @@ const installer = {
12744
12811
  setup(context, runtime, options = {}) {
12745
12812
  logger.setLogLevel(options.logLevel);
12746
12813
  logger.setLogStdout(options.logStdout);
12747
- logger.warn(`RCRTC Version: ${"5.2.4-beem.3"}, Commit: ${"b51c6e49188dcadaf70257fc1d274d978d8db68e"}`);
12814
+ logger.warn(`RCRTC Version: ${"5.2.4-beem.6"}, Commit: ${"394e0005026dc17525168cd28dcaf60009b800ac"}`);
12748
12815
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
12749
12816
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
12750
12817
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);