@rongcloud/plugin-rtc 5.2.4-beem.1 → 5.2.4-beem.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4-beem.1
3
- * CommitId - d026964c6715be7805a3e5c8addd64d4008d17bd
4
- * Thu May 12 2022 18:57:27 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.4-beem.10
3
+ * CommitId - 6db922c5bab0ba43c929ae0deae91711d5ce1406
4
+ * Mon Jun 06 2022 15:29:07 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  'use strict';
@@ -130,8 +130,13 @@ var RTCSignalCode;
130
130
 
131
131
  class AsyncTaskQueue {
132
132
  constructor() {
133
+ /**
134
+ * 多个队列时便于区分队列实例的索引
135
+ */
136
+ this.index = AsyncTaskQueue.queueCount++;
133
137
  this.queue = [];
134
138
  this.locked = false;
139
+ this.taskCount = 0;
135
140
  }
136
141
  checkToStart() {
137
142
  return __awaiter(this, void 0, void 0, function* () {
@@ -139,7 +144,8 @@ class AsyncTaskQueue {
139
144
  return;
140
145
  }
141
146
  this.locked = true;
142
- const { resolve, task, reject } = this.queue.shift();
147
+ const { resolve, task, reject, name, index } = this.queue.shift();
148
+ logger.info(`[${this.index}] async task exec -> task: ${name}, index: ${index}, length: ${this.queue.length}`);
143
149
  let result;
144
150
  try {
145
151
  result = yield task();
@@ -153,14 +159,21 @@ class AsyncTaskQueue {
153
159
  this.checkToStart();
154
160
  });
155
161
  }
156
- push(task) {
162
+ push(task, _name = '') {
157
163
  const promise = new Promise((resolve, reject) => {
158
- this.queue.push({ resolve, task, reject });
164
+ const name = task.name || _name;
165
+ const index = this.taskCount++;
166
+ const length = this.queue.push({ resolve, task, reject, name, index });
167
+ logger.info(`[${this.index}] async task queue add -> task: ${name}, index: ${index}, length: ${length}`);
159
168
  });
160
169
  this.checkToStart();
161
170
  return promise;
162
171
  }
163
172
  }
173
+ /**
174
+ * 实例递增计数
175
+ */
176
+ AsyncTaskQueue.queueCount = 0;
164
177
  const defQueeu = new AsyncTaskQueue();
165
178
  /**
166
179
  * 将异步任务推送到异步队列,队列内任务先进先出,依次执行,执行完成后通过
@@ -168,8 +181,8 @@ const defQueeu = new AsyncTaskQueue();
168
181
  * @param task 传参不能是 `async () => {}` 所定义的异步函数,
169
182
  * 只能使用明确的 `() => Promise<T> | T` 形式,避免转义时微任务被提前执行
170
183
  */
171
- const push = (task) => {
172
- return defQueeu.push(task);
184
+ const push = (task, name = '') => {
185
+ return defQueeu.push(task, name);
173
186
  };
174
187
 
175
188
  /*
@@ -5622,6 +5635,7 @@ exports.RCMediaType = void 0;
5622
5635
  RCMediaType[RCMediaType["AUDIO_VIDEO"] = 2] = "AUDIO_VIDEO";
5623
5636
  })(exports.RCMediaType || (exports.RCMediaType = {}));
5624
5637
 
5638
+ // export const RongRTCVideoBitrate: { [key: RCResolution]: BitrateConf } = {
5625
5639
  const RongRTCVideoBitrate = {
5626
5640
  [exports.RCResolution.W176_H132]: { width: 176, height: 132, maxBitrate: 150, minBitrate: 80 },
5627
5641
  [exports.RCResolution.W176_H144]: { width: 176, height: 144, maxBitrate: 160, minBitrate: 80 },
@@ -5638,23 +5652,26 @@ const RongRTCVideoBitrate = {
5638
5652
  [exports.RCResolution.W1920_H1080]: { width: 1920, height: 1080, maxBitrate: 4000, minBitrate: 400 }
5639
5653
  };
5640
5654
  /**
5641
- * 取最接近的视频分辨率配置
5655
+ * 向上取最接近的视频分辨率配置
5642
5656
  * @param {number} width
5643
5657
  * @param {number} height
5644
5658
  */
5645
5659
  const getNearestResolution = (width, height) => {
5646
- const area = width * height;
5647
- let d = Number.MAX_VALUE;
5648
- let conf = null;
5649
- for (const key in RongRTCVideoBitrate) {
5650
- const item = RongRTCVideoBitrate[key];
5651
- const d2 = Math.abs(item.width * item.height - area);
5652
- if (d2 < d) {
5653
- conf = item;
5654
- d = d2;
5655
- }
5660
+ // 优先精准匹配
5661
+ const conf = RongRTCVideoBitrate[`W${width}_H${height}`];
5662
+ if (conf) {
5663
+ return conf;
5656
5664
  }
5657
- return conf;
5665
+ // 不规则分辨率计算最接近的配置
5666
+ const area = width * height;
5667
+ const confs = Object.keys(RongRTCVideoBitrate)
5668
+ .map(key => RongRTCVideoBitrate[key])
5669
+ // 升序
5670
+ .sort((item, item2) => item.height * item.width - item2.width * item2.height)
5671
+ // 过滤分辨率小于 area 的配置,避免分配带宽不足
5672
+ .filter(item => item.height * item.width >= area);
5673
+ // 若 confs 长度为 0 说明分辨率远大于可支持的分辨率配置,取最大配置
5674
+ return confs[0] || RongRTCVideoBitrate.W1920_H1080;
5658
5675
  };
5659
5676
  const Multiplier = {
5660
5677
  10: 1,
@@ -6220,13 +6237,18 @@ const getValue = (value) => {
6220
6237
  * @param track
6221
6238
  */
6222
6239
  const getVideoTrackInfo = (track) => {
6240
+ const settings = track.getSettings();
6223
6241
  const constraints = track.getConstraints();
6224
6242
  // firefox 平台不存在 getCapabilities 方法
6225
6243
  // const capabilities = track.getCapabilities()
6226
6244
  // const width = getValue(constraints.width) || getValue(capabilities.width)
6227
6245
  // const height = getValue(constraints.height) || getValue(capabilities.height)
6228
6246
  // const frameRate = getValue(constraints.frameRate) || getValue(capabilities.frameRate)
6229
- return { width: getValue(constraints.width), height: getValue(constraints.height), frameRate: getValue(constraints.frameRate) };
6247
+ return {
6248
+ width: settings.width || getValue(constraints.width),
6249
+ height: settings.height || getValue(constraints.height),
6250
+ frameRate: settings.frameRate || getValue(constraints.frameRate)
6251
+ };
6230
6252
  };
6231
6253
  /**
6232
6254
  * 取视频流动态码率
@@ -6235,8 +6257,8 @@ const getVideoTrackInfo = (track) => {
6235
6257
  */
6236
6258
  const getDynamicBitrate = (track) => {
6237
6259
  const { width, height, frameRate } = getVideoTrackInfo(track);
6238
- // 计算动态码率以备给 answer 使用
6239
- const config = getNearestResolution(width, height);
6260
+ // 计算动态码率,若 videoTrack 的分辨率读取失败,则以 640 * 480 的默认分辨率计算码率
6261
+ const config = getNearestResolution(width || 640, height || 480);
6240
6262
  const multiple = getBitrateMultiple(frameRate);
6241
6263
  return { min: config.minBitrate * multiple, max: config.maxBitrate * multiple };
6242
6264
  };
@@ -6574,72 +6596,85 @@ exports.RCRTCPingResult = void 0;
6574
6596
  /**
6575
6597
  * rtcping 间隔
6576
6598
  */
6577
- const PING_GAP = 10 * 1000;
6599
+ const PING_GAP = 5 * 1000;
6578
6600
  /**
6579
6601
  * rtcping 超时时间
6580
6602
  */
6581
- const PING_TIMEOUT = 10 * 1000;
6603
+ const PING_TIMEOUT = 5 * 1000;
6582
6604
  /**
6583
- * RTCPing 类,累计 1 分钟未能正确收到 Ping 值则认为 ping 失败
6605
+ * RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
6584
6606
  */
6585
6607
  class Pinger {
6586
- constructor(_roomId, _roomMode, _context, _gap = PING_GAP) {
6608
+ constructor(_roomId, _roomMode, _context, _gap = PING_GAP, _offlineKickTime = 60 * 1000) {
6587
6609
  this._roomId = _roomId;
6588
6610
  this._roomMode = _roomMode;
6589
6611
  this._context = _context;
6590
6612
  this._gap = _gap;
6613
+ this._offlineKickTime = _offlineKickTime;
6591
6614
  /**
6592
6615
  * 记录最近一次成功的 Ping 时间戳
6593
6616
  */
6594
6617
  this._latestTimestamp = Date.now();
6618
+ this._started = false;
6595
6619
  this._timer = null;
6596
6620
  }
6597
6621
  /**
6598
6622
  * 启动 Ping
6599
6623
  */
6600
6624
  start() {
6601
- return __awaiter(this, void 0, void 0, function* () {
6602
- if (this._timer) {
6603
- return;
6604
- }
6605
- // logger.debug('rtcping timer start ->')
6606
- this._timer = setInterval(this._loop.bind(this), this._gap);
6625
+ if (this._started) {
6626
+ return;
6627
+ }
6628
+ logger.info('rtcping start ->');
6629
+ this._started = true;
6630
+ this._checkAlive();
6631
+ }
6632
+ _sendPing() {
6633
+ return new Promise(resolve => {
6634
+ this._context.rtcPing(this._roomId, this._roomMode)
6635
+ .then(resolve)
6636
+ .catch(error => {
6637
+ logger.error(`rtcping receive unknown error -> ${error}`);
6638
+ resolve(engine.ErrorCode.UNKNOWN);
6639
+ });
6640
+ setTimeout(resolve, PING_TIMEOUT, engine.ErrorCode.TIMEOUT);
6607
6641
  });
6608
6642
  }
6609
- _loop() {
6643
+ _checkAlive() {
6610
6644
  var _a, _b, _c;
6611
6645
  return __awaiter(this, void 0, void 0, function* () {
6612
- // logger.debug('rtcping send ->')
6613
- const code = yield new Promise(resolve => {
6614
- this._context.rtcPing(this._roomId, this._roomMode)
6615
- .then(resolve)
6616
- .catch(error => {
6617
- logger.error(`rtcping receive unknown error -> ${error}`);
6618
- resolve(engine.ErrorCode.UNKNOWN);
6619
- });
6620
- setTimeout(resolve, PING_TIMEOUT, engine.ErrorCode.TIMEOUT);
6621
- });
6646
+ logger.info('rtcping ->');
6647
+ const code = yield this._sendPing();
6622
6648
  const now = Date.now();
6623
- // ping 成功,记录时间戳,延时递归
6649
+ // ping 成功
6624
6650
  if (code === engine.ErrorCode.SUCCESS) {
6625
- // logger.debug('rtcping success <-')
6651
+ logger.info('rtcping success ->');
6626
6652
  this._latestTimestamp = now;
6627
6653
  (_a = this.onPingResult) === null || _a === void 0 ? void 0 : _a.call(this, exports.RCRTCPingResult.SUCCESS);
6654
+ // 延迟递归
6655
+ this._timer = setTimeout(() => this._checkAlive(), this._gap);
6628
6656
  return;
6629
6657
  }
6630
- (_b = this.onPingResult) === null || _b === void 0 ? void 0 : _b.call(this, exports.RCRTCPingResult.FAIL);
6631
6658
  logger.warn(`rtcping failed -> code: ${code}`);
6632
- // 超出 1 分钟未成功进行 rtcping 操作,或用户已不存在于房间内时,通知客户离线
6633
- if (code === 40003 || now - this._latestTimestamp > 60 * 1000) {
6659
+ (_b = this.onPingResult) === null || _b === void 0 ? void 0 : _b.call(this, exports.RCRTCPingResult.FAIL);
6660
+ // 超出 _offlineKickTime ping 成功,或用户已不存在于房间内时,通知客户离线
6661
+ if (code === 40003 || now - this._latestTimestamp > this._offlineKickTime) {
6634
6662
  this.stop();
6635
6663
  (_c = this.onFailed) === null || _c === void 0 ? void 0 : _c.call(this, code === 40003);
6664
+ return;
6636
6665
  }
6666
+ // 延迟发 rtcping,避免调用栈递归阻塞
6667
+ this._timer = setTimeout(() => this._checkAlive(), 500);
6637
6668
  });
6638
6669
  }
6639
6670
  stop() {
6671
+ if (!this._started) {
6672
+ return;
6673
+ }
6674
+ logger.info('rtcping stop ->');
6675
+ this._started = false;
6640
6676
  if (this._timer) {
6641
- // logger.warn('rtcping timer stop <-')
6642
- clearInterval(this._timer);
6677
+ clearTimeout(this._timer);
6643
6678
  this._timer = null;
6644
6679
  }
6645
6680
  }
@@ -7647,6 +7682,7 @@ class ASdpStrategy {
7647
7682
  return __awaiter(this, void 0, void 0, function* () {
7648
7683
  // 过滤行末的空格,服务可能产生空格数据
7649
7684
  sdp = sdp.replace(/\s+\r\n/g, '\r\n');
7685
+ logger.info(`set remote answer -> ${sdp}`);
7650
7686
  try {
7651
7687
  yield this._peer.setRemoteDescription({ type: 'answer', sdp });
7652
7688
  }
@@ -7992,6 +8028,8 @@ class RCRTCPeerConnection extends engine.EventEmitter {
7992
8028
  this._reTryExchangeTimer = null;
7993
8029
  // peerConnection stats 计时器
7994
8030
  this._reportStatsTimer = null;
8031
+ // 上报上下行数据至北极星定时器
8032
+ this._reportR3R4ToPolarisTimer = null;
7995
8033
  this._reportListener = null;
7996
8034
  const sdpSemantics = ASdpStrategy.getSdpSemantics();
7997
8035
  const peer = this._rtcPeerConn = new RTCPeerConnection({ sdpSemantics });
@@ -8055,14 +8093,12 @@ class RCRTCPeerConnection extends engine.EventEmitter {
8055
8093
  createOffer(iceRestart) {
8056
8094
  return __awaiter(this, void 0, void 0, function* () {
8057
8095
  const offer = yield this._sdpStrategy.createOffer(iceRestart);
8058
- // logger.debug(`sdpDemantics -> ${offer.semantics}`)
8059
- logger.debug(`offer -> ${JSON.stringify(offer.sdp)}`);
8096
+ logger.info(`create offer -> ${JSON.stringify(offer.sdp)}`);
8060
8097
  return offer;
8061
8098
  });
8062
8099
  }
8063
8100
  setRemoteAnswer(answer) {
8064
8101
  return __awaiter(this, void 0, void 0, function* () {
8065
- logger.debug(`answer -> ${JSON.stringify(answer)}`);
8066
8102
  return this._sdpStrategy.setRemoteAnswer(answer);
8067
8103
  });
8068
8104
  }
@@ -8217,23 +8253,44 @@ class RCRTCPeerConnection extends engine.EventEmitter {
8217
8253
  * @todo
8218
8254
  */
8219
8255
  _reportHandle() {
8220
- var _a, _b, _c;
8256
+ var _a, _b;
8221
8257
  return __awaiter(this, void 0, void 0, function* () {
8222
8258
  const formatData = yield this._getStatsData();
8223
8259
  if (!formatData) {
8224
8260
  return;
8225
8261
  }
8262
+ /**
8263
+ * 组装用户层抛出数据
8264
+ */
8265
+ const reportData = this._createRCRTCStateReport(formatData);
8266
+ (_b = (_a = this._reportListener) === null || _a === void 0 ? void 0 : _a.onStateReport) === null || _b === void 0 ? void 0 : _b.call(_a, reportData);
8267
+ });
8268
+ }
8269
+ /**
8270
+ * 北极星上报 R3、R4 数据
8271
+ */
8272
+ _sendR3R4Data() {
8273
+ var _a;
8274
+ return __awaiter(this, void 0, void 0, function* () {
8275
+ const formatData = yield this._getStatsData();
8276
+ if (!formatData) {
8277
+ return true;
8278
+ }
8226
8279
  if (formatData.senders.length || formatData.receivers.length) {
8227
8280
  /**
8228
8281
  * 组装北极星上报 R3、R4 数据并发送
8229
8282
  */
8230
- (_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData);
8283
+ return yield ((_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData));
8231
8284
  }
8232
- /**
8233
- * 组装用户层抛出数据
8234
- */
8235
- const reportData = this._createRCRTCStateReport(formatData);
8236
- (_c = (_b = this._reportListener) === null || _b === void 0 ? void 0 : _b.onStateReport) === null || _c === void 0 ? void 0 : _c.call(_b, reportData);
8285
+ });
8286
+ }
8287
+ /**
8288
+ * 2s 给北极星上报一次 R3、R4
8289
+ */
8290
+ __reportR3R4ToPolaris() {
8291
+ return __awaiter(this, void 0, void 0, function* () {
8292
+ yield this._sendR3R4Data();
8293
+ this._reportR3R4ToPolarisTimer = setTimeout(this.__reportR3R4ToPolaris.bind(this), 2000);
8237
8294
  });
8238
8295
  }
8239
8296
  getRTCPeerConn() {
@@ -8242,6 +8299,7 @@ class RCRTCPeerConnection extends engine.EventEmitter {
8242
8299
  destroy() {
8243
8300
  this.clear();
8244
8301
  this.clearReTryExchangeTimer();
8302
+ clearTimeout(this._reportR3R4ToPolarisTimer);
8245
8303
  // 停止计时
8246
8304
  if (this._reportStatsTimer) {
8247
8305
  clearInterval(this._reportStatsTimer);
@@ -8300,7 +8358,20 @@ class PolarisReporter {
8300
8358
  this._userRole = _userRole;
8301
8359
  }
8302
8360
  _send(report) {
8303
- this._context.getConnectionStatus() === engine.ConnectionStatus.CONNECTED && this._context.setRTCState(this._roomId, report);
8361
+ return __awaiter(this, void 0, void 0, function* () {
8362
+ let isSuccess = false;
8363
+ if (this._context.getConnectionStatus() !== engine.ConnectionStatus.CONNECTED) {
8364
+ return isSuccess;
8365
+ }
8366
+ const sendCode = yield this._context.setRTCState(this._roomId, report);
8367
+ if (sendCode === engine.ErrorCode.SUCCESS) {
8368
+ isSuccess = true;
8369
+ }
8370
+ else {
8371
+ isSuccess = false;
8372
+ }
8373
+ return isSuccess;
8374
+ });
8304
8375
  }
8305
8376
  _getClientID() {
8306
8377
  const key = 'uuid';
@@ -8343,101 +8414,113 @@ class PolarisReporter {
8343
8414
  return polarisTrackId;
8344
8415
  }
8345
8416
  sendR3R4Data(data) {
8346
- const { iceCandidatePair, senders, receivers } = data;
8347
- /**
8348
- * 上下行 track 包含的公共字段
8349
- */
8350
- const baseData = {
8351
- bitrateSend: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateSend) || STAT_NONE,
8352
- bitrateRecv: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateRecv) || STAT_NONE,
8353
- networkType: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.networkType) || 'unknown',
8354
- rtt: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.rtt) || STAT_NONE,
8355
- localAddress: `${(iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.IP) || STAT_NONE}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.port}`,
8356
- remoteAddress: `${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remoteIP}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remotePort}`,
8357
- receiveBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableIncomingBitrate) || STAT_NONE,
8358
- sendBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableOutgoingBitrate) || STAT_NONE,
8359
- packetsLost: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) || STAT_NONE,
8360
- deviceId: this._context.getCurrentId()
8361
- };
8362
- 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`;
8363
- 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`;
8364
- /**
8365
- * 北极星上报 sender tracks 中的字段
8366
- */
8367
- const R3TrackData = senders.map((item) => {
8368
- var _a;
8369
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsSent, encoderImplementation } = item;
8370
- const trackId = this._getPolarisTrackId(resourceId);
8417
+ return __awaiter(this, void 0, void 0, function* () {
8418
+ const { iceCandidatePair, senders, receivers } = data;
8371
8419
  /**
8372
- * 小流需去掉 _tiny
8420
+ * 上下行 track 包含的公共字段
8373
8421
  */
8374
- const realResourceId = this._getRealResourceId(resourceId);
8375
- return {
8376
- trackId,
8377
- googCodecName: encoderImplementation || String(STAT_NONE),
8378
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8379
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8380
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8381
- frameRate: frameRate || STAT_NONE,
8382
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8383
- jitter: jitter || STAT_NONE,
8384
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8385
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8386
- rtt: rtt || STAT_NONE,
8387
- googFirsSent,
8388
- samplingRate,
8389
- googRenderDelayMs,
8390
- encoderImplementation: encoderImplementation || String(STAT_NONE),
8391
- trackState: ((_a = this._crtRTCRoom.getLocalTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8422
+ const baseData = {
8423
+ bitrateSend: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateSend) || STAT_NONE,
8424
+ bitrateRecv: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.bitrateRecv) || STAT_NONE,
8425
+ networkType: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.networkType) || 'unknown',
8426
+ rtt: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.rtt) || STAT_NONE,
8427
+ localAddress: `${(iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.IP) || STAT_NONE}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.port}`,
8428
+ remoteAddress: `${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remoteIP}:${iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.remotePort}`,
8429
+ receiveBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableIncomingBitrate) || STAT_NONE,
8430
+ sendBand: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.availableOutgoingBitrate) || STAT_NONE,
8431
+ packetsLost: (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) || STAT_NONE,
8432
+ deviceId: this._context.getCurrentId()
8392
8433
  };
8393
- });
8394
- /**
8395
- * 北极星上报 received tracks 中的字段
8396
- */
8397
- const R4TrackData = receivers.filter(item => {
8398
- // unified-plan 下 inactive 的数据会继续携带 ssrc,导致无 trackId
8399
- return !!item.trackId;
8400
- }).map((item) => {
8401
- var _a;
8402
- const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsReceived, codecImplementationName } = item;
8403
- const trackId = this._getPolarisTrackId(resourceId);
8434
+ 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`;
8435
+ 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`;
8404
8436
  /**
8405
- * 小流需去掉 _tiny
8437
+ * 北极星上报 sender tracks 中的字段
8406
8438
  */
8407
- const realResourceId = this._getRealResourceId(resourceId);
8408
- return {
8409
- trackId,
8410
- googCodecName: codecImplementationName || String(STAT_NONE),
8411
- audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8412
- bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8413
- packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8414
- frameRate: frameRate || STAT_NONE,
8415
- resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8416
- jitter: jitter || STAT_NONE,
8417
- nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8418
- pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8419
- rtt: rtt || STAT_NONE,
8420
- googFirsReceived,
8421
- samplingRate,
8422
- googRenderDelayMs,
8423
- codecImplementationName: codecImplementationName || String(STAT_NONE),
8424
- trackState: ((_a = this._crtRTCRoom.getRemoteTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8425
- };
8439
+ const R3TrackData = senders.map((item) => {
8440
+ var _a;
8441
+ const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsSent, encoderImplementation } = item;
8442
+ const trackId = this._getPolarisTrackId(resourceId);
8443
+ /**
8444
+ * 小流需去掉 _tiny
8445
+ */
8446
+ const realResourceId = this._getRealResourceId(resourceId);
8447
+ return {
8448
+ trackId,
8449
+ googCodecName: encoderImplementation || String(STAT_NONE),
8450
+ audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8451
+ bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8452
+ packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8453
+ frameRate: frameRate || STAT_NONE,
8454
+ resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8455
+ jitter: jitter || STAT_NONE,
8456
+ nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8457
+ pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8458
+ rtt: rtt || STAT_NONE,
8459
+ googFirsSent,
8460
+ samplingRate,
8461
+ googRenderDelayMs,
8462
+ encoderImplementation: encoderImplementation || String(STAT_NONE),
8463
+ trackState: ((_a = this._crtRTCRoom.getLocalTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8464
+ };
8465
+ });
8466
+ /**
8467
+ * 北极星上报 received tracks 中的字段
8468
+ */
8469
+ const R4TrackData = receivers.filter(item => {
8470
+ // unified-plan 下 inactive 的数据会继续携带 ssrc,导致无 trackId
8471
+ return !!item.trackId;
8472
+ }).map((item) => {
8473
+ var _a;
8474
+ const { trackId: resourceId, audioLevel, samplingRate, bitrate, packetsLostRate, frameRate, frameWidth, frameHeight, googRenderDelayMs, jitter, nackCount, pliCount, rtt, googFirsReceived, codecImplementationName } = item;
8475
+ const trackId = this._getPolarisTrackId(resourceId);
8476
+ /**
8477
+ * 小流需去掉 _tiny
8478
+ */
8479
+ const realResourceId = this._getRealResourceId(resourceId);
8480
+ return {
8481
+ trackId,
8482
+ googCodecName: codecImplementationName || String(STAT_NONE),
8483
+ audioLevel: (audioLevel || audioLevel === 0) ? audioLevel : STAT_NONE,
8484
+ bitrate: (bitrate || bitrate === 0) ? bitrate : STAT_NONE,
8485
+ packetsLostRate: (packetsLostRate || packetsLostRate === 0) ? packetsLostRate : STAT_NONE,
8486
+ frameRate: frameRate || STAT_NONE,
8487
+ resolution: (frameWidth && frameHeight) ? `${frameWidth} * ${frameHeight}` : '' + STAT_NONE,
8488
+ jitter: jitter || STAT_NONE,
8489
+ nackCount: (nackCount || nackCount === 0) ? nackCount : STAT_NONE,
8490
+ pliCount: (pliCount || pliCount === 0) ? pliCount : STAT_NONE,
8491
+ rtt: rtt || STAT_NONE,
8492
+ googFirsReceived,
8493
+ samplingRate,
8494
+ googRenderDelayMs,
8495
+ codecImplementationName: codecImplementationName || String(STAT_NONE),
8496
+ trackState: ((_a = this._crtRTCRoom.getRemoteTrack(realResourceId)) === null || _a === void 0 ? void 0 : _a.isLocalMuted()) ? TrackState.DISABLE : TrackState.ENABLE
8497
+ };
8498
+ });
8499
+ let senderIsSuccess = false;
8500
+ r3 += R3TrackData.map((item) => {
8501
+ 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}`;
8502
+ }).join('\n');
8503
+ if (data.senders.length) {
8504
+ senderIsSuccess = yield this._send(r3 + `\r${this._userRole}`);
8505
+ }
8506
+ let receiverIsSuccess = false;
8507
+ r4 += R4TrackData.map((item) => {
8508
+ 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}`;
8509
+ }).join('\n');
8510
+ if (data.receivers.length) {
8511
+ receiverIsSuccess = yield this._send(r4 + `\r${this._userRole}`);
8512
+ }
8513
+ if (!senderIsSuccess && !receiverIsSuccess) {
8514
+ return false;
8515
+ }
8516
+ return true;
8426
8517
  });
8427
- r3 += R3TrackData.map((item) => {
8428
- 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}`;
8429
- }).join('\n');
8430
- data.senders.length && this._send(r3 + `\r${this._userRole}`);
8431
- r4 += R4TrackData.map((item) => {
8432
- 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}`;
8433
- }).join('\n');
8434
- data.receivers.length && this._send(r4 + `\r${this._userRole}`);
8435
8518
  }
8436
8519
  /**
8437
8520
  * 加入房间
8438
8521
  */
8439
8522
  sendR1() {
8440
- const rtcVersion = "5.2.4-beem.1";
8523
+ const rtcVersion = "5.2.4-beem.10";
8441
8524
  const imVersion = this._context.getCoreVersion();
8442
8525
  const platform = 'web';
8443
8526
  const pcName = navigator.platform;
@@ -8601,25 +8684,29 @@ class RCAbstractRoom {
8601
8684
  this._initRemoteTracks();
8602
8685
  const crtUserId = this._context.getCurrentId();
8603
8686
  const selfRes = this._roomResources[crtUserId] = this._roomResources[crtUserId] || [];
8604
- logger.debug(`room data -> ${JSON.stringify(this._roomResources)}`);
8687
+ logger.info(`room data -> ${JSON.stringify(this._roomResources)}`);
8605
8688
  /*
8606
8689
  * 加入房间后,若房间中已存在己方发布的资源,表示之前未能完成正常退出流程
8607
8690
  * 需先清除房间内的己方资源,通知房间内其他人己方已取消当前资源的发布
8608
8691
  * 该步骤没有必要与 MediaServer 的交互,因后续资源变更交互为全量交互
8609
8692
  */
8610
- selfRes.length > 0 && push(() => this._unpublishPrev(selfRes));
8693
+ selfRes.length > 0 && push(() => this._unpublishPrev(selfRes), 'unpub-prev');
8611
8694
  /**
8612
8695
  * 观众升级为主播后不会收到全量 uri 消息,需直接触发人员、资源变更
8613
8696
  */
8614
8697
  isUpgrade && this._afterChangedRole(data);
8698
+ // 服务下发的 rtcping 超时时间,单位为秒
8699
+ const offlineKickTime = data.offlineKickTime * 1000;
8615
8700
  // 开始心跳,心跳失败时主动退出房间
8616
- this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap);
8701
+ this._pinger = new Pinger(_roomId, this._roomMode, _context, this._initOptions.pingGap, offlineKickTime);
8617
8702
  this._pinger.onFailed = this._kickoff.bind(this);
8618
8703
  this._pinger.onPingResult = this._handlePingResult.bind(this);
8619
8704
  this._pinger.start();
8620
8705
  this._polarisReport = new PolarisReporter(this._context, this._runtime, this._roomId, this);
8621
8706
  this._polarisReport.sendR1();
8622
8707
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this), this._polarisReport);
8708
+ // 发送上下行数据至北极星
8709
+ this._pc.__reportR3R4ToPolaris();
8623
8710
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
8624
8711
  this._pc.on(RCLocalTrack.__INNER_EVENT_MUTED_CHANGE__, this._onLocalTrackMuted, this);
8625
8712
  this._pc.on(RCLocalTrack.__INNER_EVENT_DESTROY__, this._onLocalTrackDestroied, this);
@@ -8679,6 +8766,7 @@ class RCAbstractRoom {
8679
8766
  }
8680
8767
  _callAppListener(eventType, ...attrs) {
8681
8768
  var _a;
8769
+ eventType !== 'onPing' && logger.info(`${eventType} callback ->`, ...attrs);
8682
8770
  const handle = (_a = this._appListener) === null || _a === void 0 ? void 0 : _a[eventType];
8683
8771
  if (!handle) {
8684
8772
  return;
@@ -8716,34 +8804,25 @@ class RCAbstractRoom {
8716
8804
  logger.error(`unpublish prev uris failed -> code: ${code}`);
8717
8805
  }
8718
8806
  else {
8719
- logger.debug('unpublish uris prev login succeed');
8807
+ logger.info('unpublish uris prev login succeed');
8720
8808
  }
8721
8809
  });
8722
8810
  }
8723
8811
  __parseInnerMessage(message) {
8724
- const { targetId: roomId, conversationType } = message;
8725
- // 过滤非 RTC 消息
8726
- if (conversationType !== engine.ConversationType.RTC_ROOM) {
8727
- return false;
8728
- }
8729
- // 为 RTC 消息,但不属于当前房间,不处理
8730
- if (roomId !== this._roomId) {
8731
- return true;
8732
- }
8733
- logger.info(`recv inner msg -> message: ${JSON.stringify(message)} | roomid: ${this._roomId}`);
8812
+ logger.info(`room parse msg -> ${message.messageUId}`);
8734
8813
  const content = message.content;
8735
8814
  switch (message.messageType) {
8736
8815
  case RCRTCMessageType.KICK:
8737
8816
  this._kickoff(true, content);
8738
8817
  break;
8739
8818
  case RCRTCMessageType.STATE:
8740
- this.msgTaskQueue.push(() => this._stateHandle(content));
8819
+ this.msgTaskQueue.push(() => this._stateHandle(content), `parse ${message.messageType}`);
8741
8820
  break;
8742
8821
  case RCRTCMessageType.MODIFY:
8743
8822
  case RCRTCMessageType.PUBLISH:
8744
8823
  case RCRTCMessageType.UNPUBLISH:
8745
8824
  case RCRTCMessageType.TOTAL_CONTENT_RESOURCE:
8746
- this.msgTaskQueue.push(() => this._resourceHandle(content, message.messageType, message.senderUserId));
8825
+ this.msgTaskQueue.push(() => this._resourceHandle(content, message.messageType, message.senderUserId), `parse ${message.messageType}`);
8747
8826
  break;
8748
8827
  case RCRTCMessageType.ROOM_NOTIFY:
8749
8828
  this._callAppListener('onRoomAttributeChange', message.messageType, message.content);
@@ -8764,7 +8843,10 @@ class RCAbstractRoom {
8764
8843
  * * 当值为 true 时,说明本端收到被踢出房间通知
8765
8844
  */
8766
8845
  _kickoff(byServer, content) {
8767
- logger.warn(`onKickOff -> byServer: ${byServer}`);
8846
+ if (this._destroyed) {
8847
+ return;
8848
+ }
8849
+ // logger.warn(`onKickOff -> byServer: ${byServer}`)
8768
8850
  this._ntfClearRoomItem();
8769
8851
  this._leaveHandle(!byServer);
8770
8852
  // 扩展字段,备注用户为什么被踢出房间
@@ -8860,8 +8942,8 @@ class RCAbstractRoom {
8860
8942
  // 重新订阅二次发布资源
8861
8943
  if (subedTracks.length) {
8862
8944
  const trackIds = subedTracks.map(item => item.getTrackId());
8863
- logger.debug(`resub tracks -> ${JSON.stringify(trackIds)}`);
8864
- const { code } = yield push(() => this.__subscribe(subedTracks, true));
8945
+ logger.info(`resub tracks -> ${JSON.stringify(trackIds)}`);
8946
+ const { code } = yield push(() => this.__subscribe(subedTracks, true), 'resub');
8865
8947
  if (code !== exports.RCRTCCode.SUCCESS) {
8866
8948
  logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
8867
8949
  }
@@ -8929,7 +9011,7 @@ class RCAbstractRoom {
8929
9011
  const downgrade = [];
8930
9012
  users.forEach(item => {
8931
9013
  if (+item.state === 0) {
8932
- logger.debug(`user joined -> ${item.userId}`);
9014
+ logger.info(`user joined -> ${item.userId}`);
8933
9015
  // 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
8934
9016
  if (!this._roomResources[item.userId]) {
8935
9017
  item.switchRoleType ? upgrade.push(item.userId) : joined.push(item.userId);
@@ -8937,7 +9019,7 @@ class RCAbstractRoom {
8937
9019
  this._roomResources[item.userId] = this._roomResources[item.userId] || [];
8938
9020
  }
8939
9021
  else {
8940
- logger.debug(`user left -> ${item.userId}`);
9022
+ logger.info(`user left -> ${item.userId}`);
8941
9023
  item.switchRoleType ? downgrade.push(item.userId) : left.push(item.userId);
8942
9024
  }
8943
9025
  });
@@ -9142,6 +9224,17 @@ class RCAbstractRoom {
9142
9224
  __destroy(quitRoom) {
9143
9225
  return this._leaveHandle(quitRoom);
9144
9226
  }
9227
+ /**
9228
+ * 退出房间之前禁用所有远端资源,避免退出动作耗时过长,
9229
+ * 导致在未完全退出的过程中仍能听到房间内的声音问题
9230
+ */
9231
+ _muteRemoteTracksBeforeQuit() {
9232
+ const remoteTracks = Object.values(this._remoteTracks);
9233
+ if (!remoteTracks.length) {
9234
+ return;
9235
+ }
9236
+ remoteTracks.forEach((track) => track.mute());
9237
+ }
9145
9238
  _leaveHandle(quitRoom) {
9146
9239
  var _a;
9147
9240
  return __awaiter(this, void 0, void 0, function* () {
@@ -9149,6 +9242,7 @@ class RCAbstractRoom {
9149
9242
  return;
9150
9243
  }
9151
9244
  this._destroyed = true;
9245
+ this._muteRemoteTracksBeforeQuit();
9152
9246
  // 清除音量上报定时器
9153
9247
  (_a = this._audioLevelReport) === null || _a === void 0 ? void 0 : _a.clearAudioLevelReportTimer();
9154
9248
  if (quitRoom) {
@@ -9201,7 +9295,7 @@ class RCAbstractRoom {
9201
9295
  break;
9202
9296
  }
9203
9297
  }
9204
- const code = yield push(() => this._context.setRTCTotalRes(this._roomId, buildPlusMessage(RCRTCMessageType.MODIFY, plusList), buildTotalURIMessageContent(publishedList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE));
9298
+ const code = yield push(() => this._context.setRTCTotalRes(this._roomId, buildPlusMessage(RCRTCMessageType.MODIFY, plusList), buildTotalURIMessageContent(publishedList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE), 'send-local-muted');
9205
9299
  if (code !== engine.ErrorCode.SUCCESS) {
9206
9300
  logger.error('notice `track.enabled` change failed -> code: ' + code);
9207
9301
  }
@@ -9220,7 +9314,7 @@ class RCAbstractRoom {
9220
9314
  _removePubFailedTracks(tracks) {
9221
9315
  tracks.forEach(item => {
9222
9316
  const track = item instanceof RCLocalTrack ? item : item.track;
9223
- logger.debug(`remove pub failed track from peerconnection -> trackId: ${track.getTrackId()}`);
9317
+ logger.info(`remove pub failed track from peerconnection -> trackId: ${track.getTrackId()}`);
9224
9318
  this._pc.removeLocalTrackById(track.getTrackId());
9225
9319
  });
9226
9320
  }
@@ -9231,7 +9325,7 @@ class RCAbstractRoom {
9231
9325
  */
9232
9326
  publish(tracks) {
9233
9327
  return __awaiter(this, void 0, void 0, function* () {
9234
- return push(() => this.__publish(tracks));
9328
+ return push(() => this.__publish(tracks), 'pub');
9235
9329
  });
9236
9330
  }
9237
9331
  __publish(tracks) {
@@ -9253,7 +9347,7 @@ class RCAbstractRoom {
9253
9347
  logger.error(`publish failed, tracks limit exceeded -> roomId: ${this._roomId}`);
9254
9348
  return { code: exports.RCRTCCode.PUBLISH_TRACK_LIMIT_EXCEEDED };
9255
9349
  }
9256
- logger.debug(`publish tracks -> roomId: ${this._roomId}, tracks: ${tracks.map(getTrackIdFromAttr)}`);
9350
+ logger.info(`publish tracks -> roomId: ${this._roomId}, tracks: ${tracks.map(getTrackIdFromAttr)}`);
9257
9351
  /*
9258
9352
  * 资源发布应先与 mediaserver 交换资源,建 PeerConnection 通道,后通知房间
9259
9353
  * 资源取消发布则应先通知取消发布,后与 mediaServer 协商取消资源发布
@@ -9334,7 +9428,7 @@ class RCAbstractRoom {
9334
9428
  const { track: localTrack } = item instanceof RCLocalTrack ? { track: item } : item;
9335
9429
  localTrack.__innerSetPublished(true);
9336
9430
  });
9337
- logger.debug(`publish success: ${publishTrackIds.join(',')}`);
9431
+ logger.info(`publish success -> ${publishTrackIds.join(',')}`);
9338
9432
  if (this._roomMode === engine.RTCMode.LIVE) {
9339
9433
  return { code: exports.RCRTCCode.SUCCESS, liveUrl: urls === null || urls === void 0 ? void 0 : urls.liveUrl };
9340
9434
  }
@@ -9365,7 +9459,7 @@ class RCAbstractRoom {
9365
9459
  if (resCode !== exports.RCRTCCode.SUCCESS) {
9366
9460
  return { code: resCode };
9367
9461
  }
9368
- }));
9462
+ }), 'retry-exchange');
9369
9463
  });
9370
9464
  }
9371
9465
  _exchangeHandle(body) {
@@ -9426,7 +9520,7 @@ class RCAbstractRoom {
9426
9520
  */
9427
9521
  unpublish(tracks) {
9428
9522
  return __awaiter(this, void 0, void 0, function* () {
9429
- return push(() => this.__unpublish(tracks));
9523
+ return push(() => this.__unpublish(tracks), 'unpub');
9430
9524
  });
9431
9525
  }
9432
9526
  __unpublish(tracks) {
@@ -9480,7 +9574,7 @@ class RCAbstractRoom {
9480
9574
  logger.error('send unpublish notification failed:', singalCode);
9481
9575
  return { code: exports.RCRTCCode.SIGNAL_ERROR };
9482
9576
  }
9483
- logger.debug(`unpublish success -> tracks: ${resourceIds.join(',')}`);
9577
+ logger.info(`unpublish success -> tracks: ${resourceIds.join(',')}`);
9484
9578
  const resCode = yield this._pc.setRemoteAnswer(answer.sdp);
9485
9579
  if (resCode !== exports.RCRTCCode.SUCCESS) {
9486
9580
  return { code: resCode };
@@ -9513,7 +9607,7 @@ class RCAbstractRoom {
9513
9607
  */
9514
9608
  subscribe(tracks) {
9515
9609
  return __awaiter(this, void 0, void 0, function* () {
9516
- return push(() => this.__subscribe(tracks, false));
9610
+ return push(() => this.__subscribe(tracks, false), 'sub');
9517
9611
  });
9518
9612
  }
9519
9613
  __subscribe(tracks, forceReq = false) {
@@ -9568,7 +9662,7 @@ class RCAbstractRoom {
9568
9662
  */
9569
9663
  unsubscribe(tracks) {
9570
9664
  return __awaiter(this, void 0, void 0, function* () {
9571
- return push(() => this.__unsubscribe(tracks));
9665
+ return push(() => this.__unsubscribe(tracks), 'unsub');
9572
9666
  });
9573
9667
  }
9574
9668
  __unsubscribe(tracks) {
@@ -9629,7 +9723,7 @@ class RCAbstractRoom {
9629
9723
  */
9630
9724
  updateSubList(tracks) {
9631
9725
  return __awaiter(this, void 0, void 0, function* () {
9632
- return push(() => this._updateSubListHandle(tracks, false));
9726
+ return push(() => this._updateSubListHandle(tracks, false), 'update-sub-list');
9633
9727
  });
9634
9728
  }
9635
9729
  _updateSubListHandle(tracks, forceReq = false) {
@@ -9705,7 +9799,7 @@ class RCAbstractRoom {
9705
9799
  logger.error(`change subscribe list failed: ${resultCode}`);
9706
9800
  return { code: resultCode };
9707
9801
  }
9708
- logger.debug(`subscribe success: ${subTrackIds.join(',')}`);
9802
+ logger.info(`subscribe success: ${subTrackIds.join(',')}`);
9709
9803
  const resCode = yield this._pc.setRemoteAnswer(answer.sdp);
9710
9804
  if (resCode !== exports.RCRTCCode.SUCCESS) {
9711
9805
  return { code: resCode };
@@ -9767,10 +9861,10 @@ class RCAbstractRoom {
9767
9861
  }
9768
9862
  const { code, data } = yield this._context.joinRTCRoom(this._roomId, this._roomMode, livingType);
9769
9863
  if (code !== engine.ErrorCode.SUCCESS) {
9770
- logger.error(`RTC __onReconnected getRTCRoomInfo failed: ${code}`);
9864
+ logger.warn(`RTC __onReconnected getRTCRoomInfo failed: ${code}`);
9771
9865
  return;
9772
9866
  }
9773
- logger.debug(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(data)}`);
9867
+ logger.info(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(data)}`);
9774
9868
  // 查找新加入人员
9775
9869
  const joinedUserIds = [];
9776
9870
  // 新发布资源
@@ -10478,7 +10572,7 @@ class RCLivingRoom extends RCAbstractRoom {
10478
10572
  /**
10479
10573
  * 扩散 cdn_uris
10480
10574
  */
10481
- const { code: sendSingalCode } = yield push(() => __awaiter(this, void 0, void 0, function* () { return this._sendCDNInfoSignal(); }));
10575
+ const { code: sendSingalCode } = yield push(() => __awaiter(this, void 0, void 0, function* () { return this._sendCDNInfoSignal(); }), 'send-cdninfo');
10482
10576
  if (sendSingalCode === exports.RCRTCCode.SUCCESS) {
10483
10577
  logger.info('enableInnerCDN succeed');
10484
10578
  return { code: exports.RCRTCCode.SUCCESS };
@@ -10679,7 +10773,7 @@ const getCommonHeader = () => ({
10679
10773
  'Content-Type': 'application/json;charset=UTF-8',
10680
10774
  'Cache-Control': 'no-cache',
10681
10775
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
10682
- ClientVersion: "5.2.4-beem.1",
10776
+ ClientVersion: "5.2.4-beem.10",
10683
10777
  'Client-Session-Id': getUUID(),
10684
10778
  'Request-Id': Date.now().toString()
10685
10779
  });
@@ -10754,7 +10848,7 @@ class RCMediaService {
10754
10848
  for (let i = 0; i < urls.length; i += 1) {
10755
10849
  const url = `${urls[i]}${path}`;
10756
10850
  const commonHeader = getCommonHeader();
10757
- logger.debug(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10851
+ logger.info(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10758
10852
  const { status, data } = yield this._runtime.httpReq({
10759
10853
  url,
10760
10854
  body: JSON.stringify(body),
@@ -10770,11 +10864,11 @@ class RCMediaService {
10770
10864
  if (resp.clusterId) {
10771
10865
  this._clusterId = resp.clusterId;
10772
10866
  }
10773
- logger.debug(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10867
+ logger.info(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10774
10868
  return { code: exports.RCRTCCode.SUCCESS, data: resp };
10775
10869
  }
10776
10870
  else {
10777
- logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}, status: ${status}, url: ${url}`);
10871
+ logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}, status: ${status}`);
10778
10872
  // 失败的请求需记录,避免多配置时总是请求无效的地址
10779
10873
  this._failedMs.push(...this._msInNavi.splice(i, 1));
10780
10874
  }
@@ -10837,7 +10931,7 @@ class RCMediaService {
10837
10931
  // mcu 地址默认使用 https 协议
10838
10932
  const url = `${this._configUrl.replace(/^(https?:\/\/)?/, 'https://')}/server/mcu/config`;
10839
10933
  const commonHeader = getCommonHeader();
10840
- logger.debug(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10934
+ logger.info(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10841
10935
  const { status, data: jsonStr } = yield this._runtime.httpReq({
10842
10936
  url,
10843
10937
  headers: Object.assign(Object.assign({}, commonHeader), headers),
@@ -10845,10 +10939,11 @@ class RCMediaService {
10845
10939
  method: engine.HttpMethod.POST
10846
10940
  });
10847
10941
  if (status === 200) {
10848
- logger.debug(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10942
+ logger.info(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10849
10943
  const data = JSON.parse(jsonStr);
10850
10944
  return { code: data.resultCode, res: data };
10851
10945
  }
10946
+ logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}`);
10852
10947
  return { code: exports.RCRTCCode.REQUEST_FAILED };
10853
10948
  });
10854
10949
  }
@@ -10969,7 +11064,7 @@ class RCAudienceClient {
10969
11064
  */
10970
11065
  subscribe(liveUrl, livingType, mediaType, subTiny = false) {
10971
11066
  return __awaiter(this, void 0, void 0, function* () {
10972
- return push(() => this.__subscribe(liveUrl, livingType, mediaType, subTiny));
11067
+ return push(() => this.__subscribe(liveUrl, livingType, mediaType, subTiny), 'audience-client-sub');
10973
11068
  });
10974
11069
  }
10975
11070
  __subscribe(liveUrl, livingType, mediaType, subTiny = false) {
@@ -11002,6 +11097,8 @@ class RCAudienceClient {
11002
11097
  this._pc = new RCRTCPeerConnection(this._reTryExchange.bind(this));
11003
11098
  this._pc.on(RCRTCPeerConnection.__INNER_EVENT_TRACK_READY__, this._onTrackReady, this);
11004
11099
  this.registerReportListener(this._reportListener);
11100
+ // 发送上下行数据至北极星
11101
+ this._pc.__reportR3R4ToPolaris();
11005
11102
  }
11006
11103
  // 暂存,避免同步栈内并发调用,若订阅失败需清理
11007
11104
  this._liveUrl = liveUrl;
@@ -11062,7 +11159,7 @@ class RCAudienceClient {
11062
11159
  */
11063
11160
  unsubscribe() {
11064
11161
  return __awaiter(this, void 0, void 0, function* () {
11065
- return push(() => this.__unsubscribe());
11162
+ return push(() => this.__unsubscribe(), 'audience-client-unsub');
11066
11163
  });
11067
11164
  }
11068
11165
  __unsubscribe() {
@@ -11186,6 +11283,8 @@ class RCAudienceLivingRoom {
11186
11283
  rTrack.__innerSetMediaStreamTrack(track);
11187
11284
  this._callAppListener('onTrackReady', rTrack);
11188
11285
  });
11286
+ // 发送上下行数据至北极星
11287
+ this._pc.__reportR3R4ToPolaris();
11189
11288
  // 房间主播加入|离开房间、发布|取消发布资源变更监听
11190
11289
  this._context.onrtcdatachange = this.singalDataChange.bind(this);
11191
11290
  }
@@ -11406,7 +11505,7 @@ class RCAudienceLivingRoom {
11406
11505
  if (subedTracks.length) {
11407
11506
  const trackIds = subedTracks.map(item => item.getTrackId());
11408
11507
  logger.debug(`resub tracks -> ${JSON.stringify(trackIds)}`);
11409
- const { code } = yield push(() => this._subscribeHandle(subedTracks, true));
11508
+ const { code } = yield push(() => this._subscribeHandle(subedTracks, true), 'audience-resub');
11410
11509
  if (code !== exports.RCRTCCode.SUCCESS) {
11411
11510
  logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
11412
11511
  }
@@ -11506,7 +11605,7 @@ class RCAudienceLivingRoom {
11506
11605
  if (resCode !== exports.RCRTCCode.SUCCESS) {
11507
11606
  return { code: resCode };
11508
11607
  }
11509
- }));
11608
+ }), 'audience-retry-exchange');
11510
11609
  });
11511
11610
  }
11512
11611
  /**
@@ -11851,7 +11950,7 @@ class RCAudienceLivingRoom {
11851
11950
  */
11852
11951
  subscribe(tracks) {
11853
11952
  return __awaiter(this, void 0, void 0, function* () {
11854
- return push(() => this._subscribeHandle(tracks, false));
11953
+ return push(() => this._subscribeHandle(tracks, false), 'audience-sub');
11855
11954
  });
11856
11955
  }
11857
11956
  __unsubscribe(tracks) {
@@ -11877,7 +11976,7 @@ class RCAudienceLivingRoom {
11877
11976
  */
11878
11977
  unsubscribe(tracks) {
11879
11978
  return __awaiter(this, void 0, void 0, function* () {
11880
- return push(() => this.__unsubscribe(tracks));
11979
+ return push(() => this.__unsubscribe(tracks), 'audience-unsub');
11881
11980
  });
11882
11981
  }
11883
11982
  /**
@@ -12102,7 +12201,16 @@ class RCRTCClient {
12102
12201
  if (message.conversationType !== engine.ConversationType.RTC_ROOM) {
12103
12202
  return false;
12104
12203
  }
12105
- (_a = this._crtRoom) === null || _a === void 0 ? void 0 : _a.__parseInnerMessage(message);
12204
+ logger.info(`recv inner msg -> message: ${JSON.stringify(message)}`);
12205
+ if (!this._crtRoom) {
12206
+ logger.warn(`ignore msg, crt room does not exist -> messageUId: ${message.messageUId}`);
12207
+ }
12208
+ else if (message.targetId !== this._crtRoom.getRoomId()) {
12209
+ logger.warn(`ignore msg, roomId mismatch -> crtRoomId: ${this._crtRoom.getRoomId()}, msgTargetId: ${message.targetId}`);
12210
+ }
12211
+ else {
12212
+ (_a = this._crtRoom) === null || _a === void 0 ? void 0 : _a.__parseInnerMessage(message);
12213
+ }
12106
12214
  return true;
12107
12215
  }
12108
12216
  /**
@@ -12121,7 +12229,7 @@ class RCRTCClient {
12121
12229
  * @param roomType 加入房间的类型 默认参数 RTCMode.RTC
12122
12230
  */
12123
12231
  joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = engine.RTCMode.RTC) {
12124
- return push(() => this._joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType));
12232
+ return push(() => this._joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType), 'join-rtcroom');
12125
12233
  }
12126
12234
  _joinRTCRoom(roomId, joinType, outerUserDatas, useMutilPeerC, roomType = engine.RTCMode.RTC) {
12127
12235
  return __awaiter(this, void 0, void 0, function* () {
@@ -12163,7 +12271,7 @@ class RCRTCClient {
12163
12271
  * @param livingType 直播间类型,`RCLivingType.AUDIO` 为音频直播,`RCLivingType.VIDEO` 为音视频直播
12164
12272
  */
12165
12273
  joinLivingRoom(roomId, livingType) {
12166
- return push(() => this._joinLivingRoom(roomId, livingType));
12274
+ return push(() => this._joinLivingRoom(roomId, livingType), 'join-livingroom');
12167
12275
  }
12168
12276
  _joinLivingRoom(roomId, livingType) {
12169
12277
  return __awaiter(this, void 0, void 0, function* () {
@@ -12231,7 +12339,7 @@ class RCRTCClient {
12231
12339
  * 退出并销毁当前房间实例,退出后该房间的所有方法将不可用
12232
12340
  */
12233
12341
  leaveRoom(room) {
12234
- return push(() => this._leaveRoom(room));
12342
+ return push(() => this._leaveRoom(room), 'leave-room');
12235
12343
  }
12236
12344
  _leaveRoom(room) {
12237
12345
  return __awaiter(this, void 0, void 0, function* () {
@@ -12707,9 +12815,9 @@ const installer = {
12707
12815
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
12708
12816
  return false;
12709
12817
  }
12710
- engine.VersionManage.add('plugin-rtc', "5.2.4-beem.1");
12711
- if (!engine.VersionManage.validEngine("4.6.0-beem.5")) {
12712
- logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.5"}'.`);
12818
+ engine.VersionManage.add('plugin-rtc', "5.2.4-beem.10");
12819
+ if (!engine.VersionManage.validEngine("4.6.0-beem.10")) {
12820
+ logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.10"}'.`);
12713
12821
  return false;
12714
12822
  }
12715
12823
  return true;
@@ -12717,7 +12825,7 @@ const installer = {
12717
12825
  setup(context, runtime, options = {}) {
12718
12826
  logger.setLogLevel(options.logLevel);
12719
12827
  logger.setLogStdout(options.logStdout);
12720
- logger.warn(`RCRTC Version: ${"5.2.4-beem.1"}, Commit: ${"d026964c6715be7805a3e5c8addd64d4008d17bd"}`);
12828
+ logger.warn(`RCRTC Version: ${"5.2.4-beem.10"}, Commit: ${"6db922c5bab0ba43c929ae0deae91711d5ce1406"}`);
12721
12829
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
12722
12830
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
12723
12831
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);