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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.5.5-beem.3
3
- * CommitId - b639b89eb82e0b55da6285514427d887456ecbd2
4
- * Mon Oct 31 2022 13:25:42 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.5.5-beem.4
3
+ * CommitId - 1c464fa58c20897be94d3d50ee25c52729284323
4
+ * Tue Nov 08 2022 19:35:07 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { EventEmitter, isNumber, validate, isObject as isObject$1, ErrorCode, HttpMethod, isArray, ConnectionStatus, notEmptyObject, notEmptyArray, notEmptyString, isString, RTCMode as RTCMode$1, assert, ConversationType, isHttpUrl, isBoolean, isUndefined, forEach, VersionManage, LogL } from '@rongcloud/engine';
@@ -6822,7 +6822,7 @@ class RCTrack extends EventEmitter {
6822
6822
  }));
6823
6823
  return { code: RCRTCCode.VIDEO_TRACK_MISS_MEDIA_ELEMENT };
6824
6824
  }
6825
- this._element = isVideoTrack ? element : (this._element || new Audio());
6825
+ this._element = isVideoTrack ? element : new Audio();
6826
6826
  // 若本地静音,则恢复本地播放
6827
6827
  if (this._localMuted) {
6828
6828
  this._setLocalMuted(false);
@@ -6878,10 +6878,10 @@ class RCTrack extends EventEmitter {
6878
6878
  msg: `HTMLMediaElement oncanplay -> id: ${(_k = evt.target) === null || _k === void 0 ? void 0 : _k.id}, trackId: ${this._id}`,
6879
6879
  }));
6880
6880
  try {
6881
- yield ((_l = this._element) === null || _l === void 0 ? void 0 : _l.play());
6882
6881
  if ((options === null || options === void 0 ? void 0 : options.audioDeviceId) && !isVideoTrack) {
6883
6882
  yield this._element.setSinkId(options.audioDeviceId);
6884
6883
  }
6884
+ yield ((_l = this._element) === null || _l === void 0 ? void 0 : _l.play());
6885
6885
  }
6886
6886
  catch (error) {
6887
6887
  /**
@@ -6919,9 +6919,9 @@ class RCTrack extends EventEmitter {
6919
6919
  this._element.x5PlaysInline = true;
6920
6920
  this._element.webkitPlaysInline = true;
6921
6921
  }
6922
- // if (options?.audioDeviceId && !isVideoTrack) {
6923
- // await (this._element as any).setSinkId(options.audioDeviceId)
6924
- // }
6922
+ if ((options === null || options === void 0 ? void 0 : options.audioDeviceId) && !isVideoTrack) {
6923
+ yield this._element.setSinkId(options.audioDeviceId);
6924
+ }
6925
6925
  // audio 标签设置音量
6926
6926
  if (!isVideoTrack && ((options === null || options === void 0 ? void 0 : options.volume) || (options === null || options === void 0 ? void 0 : options.volume) === 0)) {
6927
6927
  this._element.volume = (options === null || options === void 0 ? void 0 : options.volume) / 100;
@@ -7981,6 +7981,13 @@ const PING_TIMEOUT = 5 * 1000;
7981
7981
  * RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
7982
7982
  */
7983
7983
  class Pinger {
7984
+ /**
7985
+ * 一个构造函数。
7986
+ * @param {ReadableStore} _store - ReadableStore:包含房间信息的商店。
7987
+ * @param {RTCContext} _context - RTC上下文
7988
+ * @param {number} _gap - ping 之间的时间间隔。
7989
+ * @param {number} _offlineKickTime - 用户离线时被踢出房间的时间。
7990
+ */
7984
7991
  constructor(_store, _context, _gap = PING_GAP, _offlineKickTime = 60 * 1000) {
7985
7992
  this._store = _store;
7986
7993
  this._context = _context;
@@ -7996,6 +8003,10 @@ class Pinger {
7996
8003
  const { roomId, roomMode } = this._store;
7997
8004
  this._roomId = roomId;
7998
8005
  this._roomMode = roomMode;
8006
+ // 设置最小 offlineKickTime 值
8007
+ if (this._offlineKickTime < 15 * 1000) {
8008
+ this._offlineKickTime = 15000;
8009
+ }
7999
8010
  }
8000
8011
  /**
8001
8012
  * 启动 Ping
@@ -14738,7 +14749,7 @@ const getCommonHeader$1 = () => ({
14738
14749
  'Content-Type': 'application/json;charset=UTF-8',
14739
14750
  'Cache-Control': 'no-cache',
14740
14751
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
14741
- ClientVersion: "5.5.5-beem.3",
14752
+ ClientVersion: "5.5.5-beem.4",
14742
14753
  'Client-Session-Id': getUUID(),
14743
14754
  'Request-Id': Date.now().toString(),
14744
14755
  });
@@ -14988,7 +14999,7 @@ const reportQualitySubscribeAndUnsubscribeData = (attrs, code) => {
14988
14999
  rsid: item.reqId,
14989
15000
  rsdur: item.end - item.start,
14990
15001
  msa: item.url,
14991
- rscod: item.rscod,
15002
+ rscod: item.status,
14992
15003
  });
14993
15004
  });
14994
15005
  if (memo.subscribeCommand) {
@@ -15107,7 +15118,7 @@ const reportQualityPublishData = (localTracks, code) => {
15107
15118
  rsid: item.reqId,
15108
15119
  rsdur: item.end - item.start,
15109
15120
  msa: item.url,
15110
- rscod: item.rscod,
15121
+ rscod: item.status,
15111
15122
  });
15112
15123
  });
15113
15124
  localTracks.forEach((track) => {
@@ -15126,7 +15137,7 @@ const reportQualityPublishSignalTotalData = (allPublishList, code) => {
15126
15137
  rsid: item.reqId,
15127
15138
  rsdur: item.end - item.start,
15128
15139
  msa: item.url,
15129
- rscod: item.rscod,
15140
+ rscod: item.status,
15130
15141
  });
15131
15142
  });
15132
15143
  const sigs = [];
@@ -15182,7 +15193,7 @@ const reportQualityUnpublishData = (tracks, code) => {
15182
15193
  rsid: item.reqId,
15183
15194
  rsdur: item.end - item.start,
15184
15195
  msa: item.url,
15185
- rscod: item.rscod,
15196
+ rscod: item.status,
15186
15197
  });
15187
15198
  });
15188
15199
  const sigs = [];
@@ -15208,7 +15219,7 @@ const reportQualityUnpublishSignalTotalData = (unpublishList, code) => {
15208
15219
  rsid: item.reqId,
15209
15220
  rsdur: item.end - item.start,
15210
15221
  msa: item.url,
15211
- rscod: item.rscod,
15222
+ rscod: item.status,
15212
15223
  });
15213
15224
  });
15214
15225
  const sigs = [];
@@ -15277,7 +15288,7 @@ const reportQualityIceStatusData = () => {
15277
15288
  var _a, _b, _c, _d;
15278
15289
  const memo = Memo.getMemo();
15279
15290
  const reportData = JSON.stringify(Object.assign(Object.assign({}, memo.qualityIceStatusReportData), { dur: (((_a = memo.iceNewStatusData) === null || _a === void 0 ? void 0 : _a.start) || 0) - (((_b = memo.iceOldStatusData) === null || _b === void 0 ? void 0 : _b.start) || 0), pices: ICEConnectionState[((_c = memo.iceOldStatusData) === null || _c === void 0 ? void 0 : _c.status) || 0], ices: ICEConnectionState[((_d = memo.iceNewStatusData) === null || _d === void 0 ? void 0 : _d.status) || 0], time: Date.now(), cncdts: [] }));
15280
- logger.__statistics(RCLoggerTag.L_QS_SUBSCRIBE_S, reportData);
15291
+ logger.__statistics(RCLoggerTag.L_QS_ICE_STATUS_S, reportData);
15281
15292
  };
15282
15293
  const reportQualityFirstSubOrPubStatusData = () => {
15283
15294
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
@@ -15316,7 +15327,7 @@ const getCommonHeader = () => ({
15316
15327
  'Content-Type': 'application/json;charset=UTF-8',
15317
15328
  'Cache-Control': 'no-cache',
15318
15329
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
15319
- ClientVersion: "5.5.5-beem.3",
15330
+ ClientVersion: "5.5.5-beem.4",
15320
15331
  'Client-Session-Id': getUUID(),
15321
15332
  'Request-Id': Date.now().toString(),
15322
15333
  });
@@ -16001,10 +16012,10 @@ class AbstractStatParser {
16001
16012
  }
16002
16013
  parseRTCStatsReport(reports) {
16003
16014
  const stats = {};
16004
- for (const key of reports.keys()) {
16015
+ for (const [key, value] of reports.entries()) {
16005
16016
  // 过滤下行数据上报
16006
- if (!key.includes('RTCCodec_')) {
16007
- stats[key] = reports.get(key);
16017
+ if (!/codec/ig.test(value) || !key.includes('RTCCodec_')) {
16018
+ stats[key] = value;
16008
16019
  }
16009
16020
  }
16010
16021
  return stats;
@@ -16148,6 +16159,11 @@ AbstractStatParser.formatSourceIdMapFromSdp = (sdp, type) => {
16148
16159
  * chrome 73 无 type 为 remote-inbound-rtp 的数据,上行拿不到 jetter、rtt、packetsLost 数据
16149
16160
  */
16150
16161
  class RTCReportParser$2 extends AbstractStatParser {
16162
+ /**
16163
+ * 该函数用于解析getStats()方法返回的RTCStatsReport对象的数据,然后以RCRTCStateReport对象的格式返回数据
16164
+ * @param stats - getStats 方法返回的数据
16165
+ * @returns 返回值是一个具有以下属性的对象:IInnerRCRTCStateReport
16166
+ */
16151
16167
  formatRCRTCStateReport(stats) {
16152
16168
  const { outbound, remoteInbound, inbound, transport, connection, } = this.formatStateData(stats);
16153
16169
  const reports = {
@@ -16162,7 +16178,96 @@ class RTCReportParser$2 extends AbstractStatParser {
16162
16178
  // 上行码率总和
16163
16179
  let bitrateSend = 0;
16164
16180
  // 解析上行媒体流数据: RTCOutboundRTPVideoStream | RTCOutboundRTPAudioStream
16165
- // const outboundKeys = keys.filter((key) => /^RTCOutboundRTP(Video|Audio)Stream_/.test(key));
16181
+ ({ totalPacketsLost, bitrateSend, senders: reports.senders } = this.pickOutbound(outbound, stats, totalPacketsLost, timestamp, bitrateSend));
16182
+ /**
16183
+ * outbound-rtp 存在无 remoteId 的情况,导致取不到有效的 jitter、rtt、packetsLost,
16184
+ * 可拿到 remote-inbound-rtp 的 localId,补充 senders 中的 jitter、rtt、packetsLost 数据,重新计算丢包率
16185
+ */
16186
+ if (remoteInbound.length > 0 && reports.senders.length > 0) {
16187
+ this.pickRemoteInbound(remoteInbound, reports.senders, stats);
16188
+ }
16189
+ // 下行码率总和
16190
+ let bitrateRecv = 0;
16191
+ // 下行流数据解析
16192
+ ({ totalPacketsLost, bitrateRecv, receivers: reports.receivers } = this.pickInbound(inbound, stats, totalPacketsLost, timestamp, bitrateRecv));
16193
+ // 解析本端/远端 IP、Port 数据
16194
+ if (transport.length > 0) {
16195
+ const rtcTransport = transport[0];
16196
+ this.pickRtcTransport(rtcTransport, stats, reports, bitrateRecv, bitrateSend, totalPacketsLost);
16197
+ }
16198
+ return reports;
16199
+ }
16200
+ /**
16201
+ * 选择 RTC 传输的函数。
16202
+ * @param {ReportData[]} transport - 报告中的传输对象
16203
+ * @param stats - 当前 RTCPeerConnection 的统计信息
16204
+ * @param {IInnerRCRTCStateReport} reports - IInnerRCRTCStateReport
16205
+ * @param {number} bitrateRecv - 接收流的总比特率。
16206
+ * @param {number} bitrateSend - 传出流的比特率。
16207
+ * @param {number} totalPacketsLost - 当前会话中丢失的数据包总数。
16208
+ */
16209
+ pickRtcTransport(rtcTransport, stats, reports, bitrateRecv, bitrateSend, totalPacketsLost) {
16210
+ const { selectedCandidatePairId } = rtcTransport;
16211
+ if (selectedCandidatePairId) {
16212
+ const iceCandidatePair = stats[selectedCandidatePairId];
16213
+ const { availableOutgoingBitrate,
16214
+ // 下行带宽只在有下行资源时有值
16215
+ availableIncomingBitrate, currentRoundTripTime: rtt, localCandidateId, remoteCandidateId, } = iceCandidatePair;
16216
+ const localCandidate = stats[localCandidateId];
16217
+ const { ip: IP, port, networkType } = localCandidate;
16218
+ const remoteCandidate = stats[remoteCandidateId];
16219
+ const { ip: remoteIP, port: remotePort, protocol } = remoteCandidate;
16220
+ reports.iceCandidatePair = {
16221
+ IP,
16222
+ port,
16223
+ networkType,
16224
+ remoteIP,
16225
+ remotePort,
16226
+ protocol,
16227
+ bitrateRecv,
16228
+ bitrateSend,
16229
+ rtt: rtt * 1000,
16230
+ availableOutgoingBitrate,
16231
+ availableIncomingBitrate,
16232
+ totalPacketsLost,
16233
+ };
16234
+ // 给下行 rtt 赋值
16235
+ reports.receivers.forEach((item) => {
16236
+ item.rtt = rtt;
16237
+ });
16238
+ }
16239
+ }
16240
+ /**
16241
+ * 它接收一个 ReportData 对象数组、一个 ISendTrackState 对象数组和一个 stats 对象。然后,它遍历 ReportData 对象,并为每个对象过滤
16242
+ * ISendTrackState 对象以找到与 ReportData 对象的 localId
16243
+ * 匹配的对象。如果找到匹配项,则检查发送方是否有远程数据。如果没有,则通过解析SDP获取resourceId,设置发送者的jitter和rtt,获取packetsSent,然后更新发送者的packetsLostRate
16244
+ * @param {ReportData[]} remoteInbound - 远程入站轨迹的数据。
16245
+ * @param {ISendTrackState[]} senders - 本地流的发送者列表。
16246
+ * @param stats - 本地流的统计信息。
16247
+ */
16248
+ pickRemoteInbound(remoteInbound, senders, stats) {
16249
+ remoteInbound.forEach((remoteInboundItem) => {
16250
+ const { localId, jitter, roundTripTime: rtt, packetsLost, } = remoteInboundItem;
16251
+ const sender = senders.filter((item) => item.id === localId)[0];
16252
+ if (sender && !senderHasRemoteData(sender)) {
16253
+ const resourceId = this.getResourceIdByParseSdp(stats[sender.id]);
16254
+ sender.jitter = Math.round(jitter * 1000);
16255
+ sender.rtt = rtt;
16256
+ const packetsSent = this._latestPacketsSent[resourceId].crtPacketsSent;
16257
+ sender.packetsLostRate = this.updateSenderPacketsLost(resourceId, packetsLost, packetsSent);
16258
+ }
16259
+ });
16260
+ }
16261
+ /**
16262
+ * 该函数用于解析发送到远程端的本地流的数据
16263
+ * @param {ReportData[]} outbound - 本端发送的数据。
16264
+ * @param stats - 当前流的统计信息。
16265
+ * @param {number} totalPacketsLost - 本地和远程端丢失的数据包总数。
16266
+ * @param {number} timestamp - 当前报告的时间戳。
16267
+ * @param {number} bitrateSend - 本地流的总比特率。
16268
+ */
16269
+ pickOutbound(outbound, stats, totalPacketsLost, timestamp, bitrateSend) {
16270
+ const senders = [];
16166
16271
  outbound.forEach((outboundInfo) => {
16167
16272
  var _a;
16168
16273
  // 本端输出数据
@@ -16229,7 +16334,7 @@ class RTCReportParser$2 extends AbstractStatParser {
16229
16334
  }
16230
16335
  // 总和累加
16231
16336
  bitrateSend += bitrate;
16232
- reports.senders.push({
16337
+ senders.push({
16233
16338
  id,
16234
16339
  trackId: resourceId,
16235
16340
  kind,
@@ -16251,24 +16356,18 @@ class RTCReportParser$2 extends AbstractStatParser {
16251
16356
  trackState: STAT_NONE,
16252
16357
  });
16253
16358
  });
16254
- /**
16255
- * outbound-rtp 存在无 remoteId 的情况,导致取不到有效的 jitter、rtt、packetsLost,
16256
- * 可拿到 remote-inbound-rtp 的 localId,补充 senders 中的 jitter、rtt、packetsLost 数据,重新计算丢包率
16257
- */
16258
- remoteInbound.forEach((remoteInboundItem) => {
16259
- const { localId, jitter, roundTripTime: rtt, packetsLost, } = remoteInboundItem;
16260
- const sender = reports.senders.filter((item) => item.id === localId)[0];
16261
- if (sender && !senderHasRemoteData(sender)) {
16262
- const resourceId = this.getResourceIdByParseSdp(stats[sender.id]);
16263
- sender.jitter = Math.round(jitter * 1000);
16264
- sender.rtt = rtt;
16265
- const packetsSent = this._latestPacketsSent[resourceId].crtPacketsSent;
16266
- sender.packetsLostRate = this.updateSenderPacketsLost(resourceId, packetsLost, packetsSent);
16267
- }
16268
- });
16269
- // 下行码率总和
16270
- let bitrateRecv = 0;
16271
- // 下行流数据解析
16359
+ return { totalPacketsLost, bitrateSend, senders };
16360
+ }
16361
+ /**
16362
+ * 解析报表的入站数据的函数。
16363
+ * @param {ReportData[]} inbound - 报表的入站数据
16364
+ * @param stats - 当前 RTCPeerConnection 的统计信息。
16365
+ * @param {number} totalPacketsLost - 丢包总数
16366
+ * @param {number} timestamp - 当前报告的时间戳。
16367
+ * @param {number} bitrateRecv - 接收流的总比特率。
16368
+ */
16369
+ pickInbound(inbound, stats, totalPacketsLost, timestamp, bitrateRecv) {
16370
+ let receivers = [];
16272
16371
  inbound.forEach((inboundInfo) => {
16273
16372
  if (this._sdpSemantics === 'unified-plan' && !this.isValidReceiver(inboundInfo)) {
16274
16373
  return;
@@ -16296,7 +16395,7 @@ class RTCReportParser$2 extends AbstractStatParser {
16296
16395
  bitrate = 0;
16297
16396
  }
16298
16397
  bitrateRecv += bitrate;
16299
- reports.receivers.push({
16398
+ receivers.push({
16300
16399
  trackId: resourceId,
16301
16400
  kind,
16302
16401
  packetsLostRate,
@@ -16317,41 +16416,13 @@ class RTCReportParser$2 extends AbstractStatParser {
16317
16416
  trackState: STAT_NONE,
16318
16417
  });
16319
16418
  });
16320
- // 解析本端/远端 IP、Port 数据
16321
- if (transport.length > 0) {
16322
- const rtcTransport = transport[0];
16323
- const { selectedCandidatePairId } = rtcTransport;
16324
- if (selectedCandidatePairId) {
16325
- const iceCandidatePair = stats[selectedCandidatePairId];
16326
- const { availableOutgoingBitrate,
16327
- // 下行带宽只在有下行资源时有值
16328
- availableIncomingBitrate, currentRoundTripTime: rtt, localCandidateId, remoteCandidateId, } = iceCandidatePair;
16329
- const localCandidate = stats[localCandidateId];
16330
- const { ip: IP, port, networkType } = localCandidate;
16331
- const remoteCandidate = stats[remoteCandidateId];
16332
- const { ip: remoteIP, port: remotePort, protocol } = remoteCandidate;
16333
- reports.iceCandidatePair = {
16334
- IP,
16335
- port,
16336
- networkType,
16337
- remoteIP,
16338
- remotePort,
16339
- protocol,
16340
- bitrateRecv,
16341
- bitrateSend,
16342
- rtt: rtt * 1000,
16343
- availableOutgoingBitrate,
16344
- availableIncomingBitrate,
16345
- totalPacketsLost,
16346
- };
16347
- // 给下行 rtt 赋值
16348
- reports.receivers.forEach((item) => {
16349
- item.rtt = rtt;
16350
- });
16351
- }
16352
- }
16353
- return reports;
16419
+ return { totalPacketsLost, bitrateRecv, receivers };
16354
16420
  }
16421
+ /**
16422
+ * 该函数用于获取当前流的音频电平
16423
+ * @param stats - getStats 方法返回的数据
16424
+ * @returns 具有以下属性的对象数组:
16425
+ */
16355
16426
  getAudioLevelList(stats) {
16356
16427
  const audioLevelList = [];
16357
16428
  // 解析上行媒体流数据: RTCOutboundRTPVideoStream | RTCOutboundRTPAudioStream
@@ -17182,6 +17253,10 @@ class ASdpStrategy {
17182
17253
  return __awaiter(this, void 0, void 0, function* () {
17183
17254
  // 过滤行末的空格,服务可能产生空格数据
17184
17255
  sdp = ASdpBuilder.trimBlankLine(sdp);
17256
+ if (this._peer.connectionState === 'disconnected'
17257
+ || this._peer.connectionState === 'closed') {
17258
+ return RCRTCCode.SET_REMOTE_DESCRIPTION_FAILED;
17259
+ }
17185
17260
  try {
17186
17261
  yield this._peer.setRemoteDescription({ type: 'answer', sdp });
17187
17262
  }
@@ -17536,6 +17611,10 @@ class UnifiedPlanStrategy extends ASdpStrategy {
17536
17611
  var _a;
17537
17612
  (_a = this._logger) === null || _a === void 0 ? void 0 : _a.warn(RCLoggerTag.L_OLD_DAILY_RECORD_O, 'the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`');
17538
17613
  }
17614
+ /**
17615
+ * 该函数用于向对等连接添加本地轨道
17616
+ * @param {RCLocalTrack} track - RCLocalTrack
17617
+ */
17539
17618
  addLocalTrack(track) {
17540
17619
  var _a;
17541
17620
  const trackId = track.getTrackId();
@@ -17560,6 +17639,11 @@ class UnifiedPlanStrategy extends ASdpStrategy {
17560
17639
  const SingleInstance = SdpResource.getInstance();
17561
17640
  SingleInstance.push(trackId, { msid, id: this._outboundStreams[msid].id, kind: (_a = track.streamTrack) === null || _a === void 0 ? void 0 : _a.kind });
17562
17641
  }
17642
+ /**
17643
+ * 该函数从对等连接中删除本地轨道
17644
+ * @param {RCLocalTrack} track - RCLocalTrack
17645
+ * @returns 返回值是函数中执行的最后一条语句返回的值。
17646
+ */
17563
17647
  removeLocalTrack(track) {
17564
17648
  const trackId = track.getTrackId();
17565
17649
  const msid = track.getStreamId();
@@ -17598,6 +17682,11 @@ class UnifiedPlanStrategy extends ASdpStrategy {
17598
17682
  tinyTrack.stop();
17599
17683
  }
17600
17684
  }
17685
+ /**
17686
+ * 更新trackId和收发器的映射关系,从候选列表中删除收发器
17687
+ * @param {string} trackId - 要添加的轨道的 trackId。
17688
+ * @param {RTCRtpTransceiver} transceiver - RTCRtp收发器
17689
+ */
17601
17690
  updateRecvTransceiverMap(trackId, transceiver) {
17602
17691
  const { mediaType } = parseTrackId(trackId);
17603
17692
  // 更新映射关系
@@ -17607,6 +17696,10 @@ class UnifiedPlanStrategy extends ASdpStrategy {
17607
17696
  const index = arrTransceiver.findIndex((item) => item === transceiver);
17608
17697
  index >= 0 && arrTransceiver.splice(index, 1);
17609
17698
  }
17699
+ /**
17700
+ * 该函数用于更新本地客户端订阅的远程轨道
17701
+ * @param {RCRemoteTrack[]} tracks - 要更新的远程轨道数组。
17702
+ */
17610
17703
  updateSubRemoteTracks(tracks) {
17611
17704
  // 减法记录新增订阅
17612
17705
  const addTracks = tracks.slice();
@@ -17820,13 +17913,17 @@ class RCRTCPeerConnection extends EventEmitter {
17820
17913
  /**
17821
17914
  * 北极星上传实例
17822
17915
  */
17823
- _polarisReport, onTrackTrouble) {
17916
+ _polarisReport, onTrackTrouble,
17917
+ /* 私有只读属性。RTCContext */
17918
+ _initOptions) {
17824
17919
  super();
17825
17920
  this._pcName = _pcName;
17826
17921
  this._reTryExchange = _reTryExchange;
17827
17922
  this._currentUserId = _currentUserId;
17828
17923
  this._polarisReport = _polarisReport;
17829
17924
  this.onTrackTrouble = onTrackTrouble;
17925
+ this._initOptions = _initOptions;
17926
+ this.senderAndReciveSize = 32;
17830
17927
  this.pubLocalTracks = {};
17831
17928
  this._reTryExchangeTimer = null;
17832
17929
  // peerConnection stats 计时器
@@ -17949,6 +18046,13 @@ class RCRTCPeerConnection extends EventEmitter {
17949
18046
  }));
17950
18047
  });
17951
18048
  }
18049
+ /**
18050
+ * `createOffer` 是一个创建报价并记录报价 SDP 和 SDP 语义的函数
18051
+ * @param {boolean} iceRestart - 布尔值
18052
+ * @returns 具有两个属性的对象:
18053
+ * - sdp:SDP 字符串
18054
+ * - 语义:SDP 语义
18055
+ */
17952
18056
  createOffer(iceRestart) {
17953
18057
  var _a;
17954
18058
  return __awaiter(this, void 0, void 0, function* () {
@@ -17968,6 +18072,10 @@ class RCRTCPeerConnection extends EventEmitter {
17968
18072
  getLocalTrack(trackId) {
17969
18073
  return this.pubLocalTracks[trackId] || null;
17970
18074
  }
18075
+ /**
18076
+ * 它将本地轨道添加到对等连接。
18077
+ * @param {RCLocalTrack} track - 要添加的本地轨道。
18078
+ */
17971
18079
  addLocalTrack(track) {
17972
18080
  var _a;
17973
18081
  this.pubLocalTracks[track.getTrackId()] = track;
@@ -17981,6 +18089,11 @@ class RCRTCPeerConnection extends EventEmitter {
17981
18089
  trackId: track.getTrackId(),
17982
18090
  }));
17983
18091
  }
18092
+ /**
18093
+ * 按 ID 删除本地轨道
18094
+ * @param {string} trackId - 要移除的轨道的 ID。
18095
+ * @returns 正在删除的轨道。
18096
+ */
17984
18097
  removeLocalTrackById(trackId) {
17985
18098
  var _a, _b;
17986
18099
  const track = this.getLocalTrack(trackId);
@@ -17998,12 +18111,19 @@ class RCRTCPeerConnection extends EventEmitter {
17998
18111
  }));
17999
18112
  this.removeLocalTrack(track);
18000
18113
  }
18114
+ /**
18115
+ * 它会删除所有本地Track。
18116
+ */
18001
18117
  removeAllLocalTrack() {
18002
18118
  Object.keys(this.pubLocalTracks).forEach((id) => {
18003
18119
  // 小流不可先于大流执行 removeLocalTrackById,否则可能存在小流被当做大流进而不可被销毁
18004
18120
  /_tiny$/.test(id) || this.removeLocalTrackById(id);
18005
18121
  });
18006
18122
  }
18123
+ /**
18124
+ * 从对等连接中删除本地轨道。
18125
+ * @param {RCLocalTrack} track - 要删除的本地轨道。
18126
+ */
18007
18127
  removeLocalTrack(track) {
18008
18128
  var _a;
18009
18129
  const trackId = track.getTrackId();
@@ -18059,44 +18179,46 @@ class RCRTCPeerConnection extends EventEmitter {
18059
18179
  this._reportListener = listener;
18060
18180
  }
18061
18181
  _createRCRTCStateReport(data) {
18062
- const { timestamp, iceCandidatePair, senders, receivers, } = JSON.parse(JSON.stringify(data));
18063
- iceCandidatePair === null || iceCandidatePair === void 0 ? true : delete iceCandidatePair.totalPacketsLost;
18182
+ const { timestamp, iceCandidatePair, senders, receivers, } = data;
18183
+ if (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) {
18184
+ iceCandidatePair === null || iceCandidatePair === void 0 ? true : delete iceCandidatePair.totalPacketsLost;
18185
+ }
18064
18186
  for (const key in iceCandidatePair) {
18065
18187
  isNull(iceCandidatePair[key]) && delete iceCandidatePair[key];
18066
18188
  }
18067
- const newSenders = senders.map((item) => {
18068
- const sender = {};
18069
- item.trackId && (sender.trackId = item.trackId);
18070
- item.kind && (sender.kind = item.kind);
18071
- (item.packetsLostRate || item.packetsLostRate === 0) && (sender.packetsLostRate = item.packetsLostRate);
18072
- sender.remoteResource = item.remoteResource;
18189
+ const pickSender = [];
18190
+ senders.forEach((item) => {
18191
+ const { trackId, kind, packetsLostRate, remoteResource, bitrate, jitter, } = item;
18192
+ const sender = {
18193
+ trackId, kind, packetsLostRate, remoteResource, bitrate, jitter,
18194
+ };
18073
18195
  (item.audioLevel || item.audioLevel === 0) && (sender.audioLevel = item.audioLevel);
18074
18196
  item.frameWidth && (sender.frameWidth = item.frameWidth);
18075
18197
  item.frameHeight && (sender.frameHeight = item.frameHeight);
18076
18198
  item.frameRate && (sender.frameRate = item.frameRate);
18077
- (item.bitrate || item.bitrate === 0) && (sender.bitrate = item.bitrate);
18078
- item.jitter && (sender.jitter = item.jitter);
18079
- return sender;
18080
- });
18081
- const newReceivers = receivers.map((item) => {
18082
- const receiver = {};
18083
- item.trackId && (receiver.trackId = item.trackId);
18084
- item.kind && (receiver.kind = item.kind);
18085
- (item.packetsLostRate || item.packetsLostRate === 0) && (receiver.packetsLostRate = item.packetsLostRate);
18086
- receiver.remoteResource = item.remoteResource;
18199
+ if (item.trackId) {
18200
+ pickSender.push(Object.assign({}, sender));
18201
+ }
18202
+ });
18203
+ const newReceivers = [];
18204
+ receivers.forEach((item) => {
18205
+ const { trackId, kind, packetsLostRate, remoteResource, bitrate, jitter, } = item;
18206
+ const receiver = {
18207
+ trackId, kind, packetsLostRate, remoteResource, bitrate, jitter,
18208
+ };
18087
18209
  (item.audioLevel || item.audioLevel === 0) && (receiver.audioLevel = item.audioLevel);
18088
18210
  item.frameWidth && (receiver.frameWidth = item.frameWidth);
18089
18211
  item.frameHeight && (receiver.frameHeight = item.frameHeight);
18090
18212
  item.frameRate && (receiver.frameRate = item.frameRate);
18091
- (item.bitrate || item.bitrate === 0) && (receiver.bitrate = item.bitrate);
18092
- item.jitter && (receiver.jitter = item.jitter);
18093
- return receiver;
18213
+ if (item.trackId) {
18214
+ newReceivers.push(Object.assign({}, receiver));
18215
+ }
18094
18216
  });
18095
18217
  return {
18096
18218
  timestamp,
18097
18219
  iceCandidatePair,
18098
- senders: newSenders.filter((item) => item.trackId),
18099
- receivers: newReceivers.filter((item) => item.trackId),
18220
+ senders: pickSender,
18221
+ receivers: newReceivers,
18100
18222
  pcName: this._pcName,
18101
18223
  };
18102
18224
  }
@@ -18177,35 +18299,48 @@ class RCRTCPeerConnection extends EventEmitter {
18177
18299
  * 获取缓存的本地质量数据
18178
18300
  */
18179
18301
  _getCacheStatsData() {
18180
- return this._reportStatsData;
18302
+ return __awaiter(this, void 0, void 0, function* () {
18303
+ return this._getStatsData();
18304
+ });
18181
18305
  }
18182
18306
  /**
18183
18307
  * 北极星上报 R3、R4 数据
18184
18308
  */
18185
18309
  _sendR3R4Data() {
18186
- var _a;
18310
+ var _a, _b;
18187
18311
  return __awaiter(this, void 0, void 0, function* () {
18188
- const formatData = this._getCacheStatsData();
18312
+ const formatData = yield this._getCacheStatsData();
18189
18313
  if (!formatData) {
18190
18314
  return true;
18191
18315
  }
18316
+ /**
18317
+ * 优化 300 人大会议室 https://rc-jira.rongcloud.net/browse/BEEM-289
18318
+ * Mac 端卡顿严重, RTCLib 房间超出 32 路流时,不再做北极星质量数据上报,仅取音量数据,以保持 Beem 声音激励功能可用
18319
+ */
18320
+ if (!((_a = this === null || this === void 0 ? void 0 : this._initOptions) === null || _a === void 0 ? void 0 : _a.polarisThrottle) && formatData.receivers.length + formatData.senders.length > this.senderAndReciveSize) {
18321
+ return true;
18322
+ }
18192
18323
  if (formatData.senders.length || formatData.receivers.length) {
18193
18324
  /**
18194
18325
  * 组装北极星上报 R3、R4 数据并发送
18195
18326
  */
18196
- const res = yield ((_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData));
18327
+ const res = yield ((_b = this._polarisReport) === null || _b === void 0 ? void 0 : _b.sendR3R4Data(formatData));
18197
18328
  if (formatData.senders.length > 0) {
18198
18329
  formatData.senders.forEach((item) => {
18199
- const { encoderImplementation, frameRate, frameWidth, frameHeight, } = item;
18200
- let flag = 0;
18201
- if ((encoderImplementation === null || encoderImplementation === void 0 ? void 0 : encoderImplementation.toLowerCase()) === 'unknown' || !frameRate || !frameWidth || !frameHeight) {
18202
- flag = 1;
18330
+ if (item.kind === 'video') {
18331
+ const { encoderImplementation, frameRate, frameWidth, frameHeight, } = item;
18332
+ let flag = 0;
18333
+ if ((encoderImplementation === null || encoderImplementation === void 0 ? void 0 : encoderImplementation.toLowerCase()) === 'unknown' || !frameRate || !frameWidth || !frameHeight) {
18334
+ flag = 1;
18335
+ }
18336
+ // 当前 trackId 的视频出现问题
18337
+ this.setTroubleTrack(item.trackId, flag);
18203
18338
  }
18204
- this.setTroubleTrack(item.trackId, flag);
18205
18339
  });
18206
18340
  }
18207
18341
  return res;
18208
18342
  }
18343
+ return true;
18209
18344
  });
18210
18345
  }
18211
18346
  /**
@@ -18214,10 +18349,11 @@ class RCRTCPeerConnection extends EventEmitter {
18214
18349
  __reportR3R4ToPolaris() {
18215
18350
  return __awaiter(this, void 0, void 0, function* () {
18216
18351
  clearTimeout(this._reportR3R4ToPolarisTimer);
18217
- yield this._sendR3R4Data();
18218
- this._reportR3R4ToPolarisTimer = setTimeout(() => {
18219
- this.__reportR3R4ToPolaris();
18220
- }, 2000);
18352
+ this._reportR3R4ToPolarisTimer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
18353
+ this._sendR3R4Data().then(() => {
18354
+ this.__reportR3R4ToPolaris();
18355
+ });
18356
+ }), 2000);
18221
18357
  });
18222
18358
  }
18223
18359
  getRTCPeerConn() {
@@ -18529,7 +18665,7 @@ class PolarisReporter {
18529
18665
  * 加入房间
18530
18666
  */
18531
18667
  sendR1() {
18532
- const rtcVersion = "5.5.5-beem.3";
18668
+ const rtcVersion = "5.5.5-beem.4";
18533
18669
  const imVersion = this._context.getCoreVersion();
18534
18670
  const platform = 'web';
18535
18671
  const pcName = navigator.platform;
@@ -18679,7 +18815,7 @@ class PolarisHttpReporter {
18679
18815
  _formatR1Data() {
18680
18816
  return {
18681
18817
  joinTime: this._context.userJoinTime || 0,
18682
- rtcVersion: "5.5.5-beem.3",
18818
+ rtcVersion: "5.5.5-beem.4",
18683
18819
  imVersion: this._context.getCoreVersion(),
18684
18820
  platform: 'web',
18685
18821
  device: navigator.platform,
@@ -18940,12 +19076,17 @@ class RCRTCPeerCManager {
18940
19076
  /**
18941
19077
  * 北极星上报模块
18942
19078
  */
18943
- _polarisReport) {
19079
+ _polarisReport,
19080
+ /**
19081
+ * context
19082
+ */
19083
+ _initOptions) {
18944
19084
  this._useMutilPeerC = _useMutilPeerC;
18945
19085
  this._roomId = _roomId;
18946
19086
  this._reTryExchange = _reTryExchange;
18947
19087
  this._currentUserId = _currentUserId;
18948
19088
  this._polarisReport = _polarisReport;
19089
+ this._initOptions = _initOptions;
18949
19090
  // private _reportListener: {[key: string]: IRCRTCReportListener | null} = {}
18950
19091
  /**
18951
19092
  * 存储创建的所有 peerC,key 为 pcName,/exchange 请求中 request header 中的 Peer-Connection-Id 值
@@ -19012,7 +19153,7 @@ class RCRTCPeerCManager {
19012
19153
  * 创建一个新 peerC
19013
19154
  */
19014
19155
  const isPub = this._isPub(tracks);
19015
- const newPeerC = new RCRTCPeerConnection(pcName, () => this._reTryExchange(pcName, isPub), this._currentUserId, this._polarisReport, this.onTrackTrouble);
19156
+ const newPeerC = new RCRTCPeerConnection(pcName, () => this._reTryExchange(pcName, isPub), this._currentUserId, this._polarisReport, this.onTrackTrouble, this._initOptions);
19016
19157
  this._mutilPeerC[pcName] = {
19017
19158
  pc: newPeerC,
19018
19159
  tracks,
@@ -19861,13 +20002,15 @@ class ExchangeCommand extends BaseCommand {
19861
20002
  }
19862
20003
  /**
19863
20004
  * 自动模式下:
20005
+ * 无 pull_url 字段
19864
20006
  * /exchange 完需根据 broadcast 字端判断是否扩散 cdn_uris 数据,设置房间 cdn_uris 数据
19865
20007
  */
19866
20008
  const uris = JSON.parse(pullUrl);
19867
20009
  store.setCDNUris(uris);
19868
20010
  if ((uris === null || uris === void 0 ? void 0 : uris.broadcast) === RCInnerCDNBroadcast.SPREAD) {
19869
20011
  store.setCDNEnabel(true);
19870
- sendCDNInfoSignal(store);
20012
+ const CDNUris = Object.assign(Object.assign({}, uris), { enableInnerCDN: true });
20013
+ setRoomCDNInfo(store.context, store.roomId, CDNUris);
19871
20014
  }
19872
20015
  return res;
19873
20016
  });
@@ -20720,11 +20863,12 @@ class RetrySignaling {
20720
20863
  }
20721
20864
  }
20722
20865
 
20866
+ const PUBLISHSIGNALRETRYTIME = 30 * 1000;
20723
20867
  /**
20724
20868
  * 资源发布命令
20725
20869
  */
20726
20870
  class PublishCommand extends BaseCommand {
20727
- constructor(tracks, pubhook, signalRetryTime) {
20871
+ constructor(tracks, pubhook, signalRetryTime = PUBLISHSIGNALRETRYTIME) {
20728
20872
  var _a;
20729
20873
  super();
20730
20874
  this.tracks = tracks;
@@ -20915,10 +21059,12 @@ class PublishCommand extends BaseCommand {
20915
21059
  });
20916
21060
  // 计算此次发布的增量资源数据
20917
21061
  const { publishedList: plus } = diffPublishResources(oldPublisheList, allPublishList);
21062
+ const CDNUris = Object.assign(Object.assign({}, store.getCDNUris()), { enableInnerCDN: store.getCDNEnable() });
21063
+ const CDNValueInfo = (CDNUris && CDNUris.broadcast === RCInnerCDNBroadcast.SPREAD) ? JSON.stringify([CDNUris]) : '';
20918
21064
  // 通知房间成员
20919
21065
  // 连通率相关埋点-统计扩散耗时
20920
21066
  recordPublishSignalTotalData();
20921
- let errorCode = yield store.context.setRTCTotalRes(roomId, buildPlusMessage(RCRTCMessageType.PUBLISH, plus), buildTotalURIMessageContent(allPublishList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE, buildTotalURIMessageContent(crtMcuPublishList));
21067
+ let errorCode = yield store.context.setRTCTotalRes(roomId, buildPlusMessage(RCRTCMessageType.PUBLISH, plus), buildTotalURIMessageContent(allPublishList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE, buildTotalURIMessageContent(crtMcuPublishList), CDNValueInfo);
20922
21068
  // TIPS: 通知房间成员失败,对信息进行重试操作
20923
21069
  if (errorCode !== ErrorCode.SUCCESS) {
20924
21070
  const RetrySignal = RetrySignaling.handler();
@@ -21022,7 +21168,7 @@ class PublishCommand extends BaseCommand {
21022
21168
  });
21023
21169
  if (!tracks.length) {
21024
21170
  (_f = (_e = store.context) === null || _e === void 0 ? void 0 : _e.logger) === null || _f === void 0 ? void 0 : _f.error(RCLoggerTag.L_ABSTRACT_ROOM_PUBLISH_R, JSON.stringify({
21025
- status: RCLoggerStatus.SUCCESSED,
21171
+ status: RCLoggerStatus.FAILED,
21026
21172
  code: RCRTCCode.PUBLISH_TRACKS_IS_INVALID,
21027
21173
  msg: 'params tracks is invalid',
21028
21174
  }), this._traceId);
@@ -21738,11 +21884,25 @@ const RCAbstractRoomEvent = {
21738
21884
  * 房间抽象基类
21739
21885
  */
21740
21886
  class RCAbstractRoom extends EventEmitter {
21887
+ /**
21888
+ * RCRTCRoom 类的构造函数。
21889
+ * @param {RTCContext} _context - RTC上下文,
21890
+ * @param {IRuntime} _runtime - 运行时
21891
+ * @param {string} _roomId - 房间号
21892
+ * @param {RTCMode} _roomMode - RTC模式,
21893
+ * @param {RCMediaService} _service - RCMediaService
21894
+ * @param {IRCRTCInitOptions} _initOptions - IRCRTCInitOptions
21895
+ * @param {boolean} [isUpgrade] - 是否是升级,如果是升级则不会创建新的peerConnection
21896
+ * @param {boolean} [isMainRoom] - 无论是主房间,主房间都是用户创建的房间,子房间是用户创建的房间。
21897
+ * @param {boolean} [_useMutilPeerC] - 是否使用多个 peerConnections
21898
+ * @param {string} _clientSessionId - 客户端会话 ID,用于标识客户端。
21899
+ * @param {number} signalRetryTime - 发送信号的时间间隔。
21900
+ */
21741
21901
  constructor(_context, _runtime, _roomId, _roomMode, _service, _initOptions, isUpgrade, isMainRoom,
21742
21902
  /**
21743
21903
  * 是否使用多 peerConnection
21744
21904
  */
21745
- _useMutilPeerC, _clientSessionId = getUUID()) {
21905
+ _useMutilPeerC, _clientSessionId = getUUID(), signalRetryTime = PUBLISHSIGNALRETRYTIME) {
21746
21906
  super();
21747
21907
  this._context = _context;
21748
21908
  this._runtime = _runtime;
@@ -21751,6 +21911,7 @@ class RCAbstractRoom extends EventEmitter {
21751
21911
  this._initOptions = _initOptions;
21752
21912
  this._useMutilPeerC = _useMutilPeerC;
21753
21913
  this._clientSessionId = _clientSessionId;
21914
+ this.signalRetryTime = signalRetryTime;
21754
21915
  this._appListener = null;
21755
21916
  this._reportListener = null;
21756
21917
  /**
@@ -21758,7 +21919,7 @@ class RCAbstractRoom extends EventEmitter {
21758
21919
  */
21759
21920
  this._onRecvPKMsg = null;
21760
21921
  this._polarisReport = new PolarisHttpReporter(this._context, this._runtime, this._roomId, this);
21761
- this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._roomId, this._reTryExchange.bind(this), this._context.getCurrentId(), this._polarisReport);
21922
+ this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._roomId, this._reTryExchange.bind(this), this._context.getCurrentId(), this._polarisReport, this._initOptions);
21762
21923
  this._invoker = new Invoker(this._context, this._service, this._peerCManager, _roomId, this._context.getCurrentId(), _roomMode, this._polarisReport, isUpgrade, isMainRoom);
21763
21924
  this._store = this._invoker.store;
21764
21925
  // 注册监听 rtc_ntf 信令数据,收到通知时拉取房间数据
@@ -22416,7 +22577,7 @@ class RCAbstractRoom extends EventEmitter {
22416
22577
  */
22417
22578
  publish(tracks) {
22418
22579
  return __awaiter(this, void 0, void 0, function* () {
22419
- return this._invoker.push(new PublishCommand(tracks, this._pubhook.bind(this), this._initOptions.signalRetryTime || 30 * 1000));
22580
+ return this._invoker.push(new PublishCommand(tracks, this._pubhook.bind(this), this.signalRetryTime));
22420
22581
  });
22421
22582
  }
22422
22583
  /**
@@ -24514,6 +24675,19 @@ class RTCIdentityChangeCommand extends BaseCommand {
24514
24675
  * 直播房间
24515
24676
  */
24516
24677
  class RCLivingRoom extends RCAbstractRoom {
24678
+ /**
24679
+ * 一个构造函数。
24680
+ * @param {RTCContext} context - RTC上下文,
24681
+ * @param {IRuntime} runtime - 运行时
24682
+ * @param {string} roomId - 房间号
24683
+ * @param {RCMediaService} service - RCMediaService
24684
+ * @param {IRCRTCInitOptions} initOptions - IRCRTCInitOptions
24685
+ * @param {RCLivingType} _livingType - RCLivingType.LIVE_ROOM,
24686
+ * @param {boolean} [isUpgrade] - 是否升级房间,如果为真,则表示房间从会议室升级到直播间,会议室关闭。
24687
+ * @param {boolean} [isMainRoom] - 无论是主房间,主房间都是发起呼叫的房间,子房间是接收呼叫的房间。
24688
+ * @param {boolean} [useMutilPeerC] - 是否使用多个 peerConnections
24689
+ * @param {string} [_clientSessionId] - 当前用户的会话 ID。
24690
+ */
24517
24691
  constructor(context, runtime, roomId, service, initOptions, _livingType, isUpgrade, isMainRoom,
24518
24692
  /**
24519
24693
  * 是否使用多 peerConnection
@@ -24851,12 +25025,26 @@ class RCLivingRoom extends RCAbstractRoom {
24851
25025
  * 普通音视频房间
24852
25026
  */
24853
25027
  class RCRTCRoom extends RCAbstractRoom {
25028
+ /**
25029
+ * 类的构造函数。
25030
+ * @param {RTCContext} context - RTC上下文
25031
+ * @param {IRuntime} runtime - 运行时
25032
+ * @param {string} roomId - 房间号
25033
+ * @param {RCMediaService} service - RCMediaService
25034
+ * @param {IRCRTCInitOptions} initOptions - IRCRTCInitOptions
25035
+ * @param {boolean} [isUpgrade] - 是否升级房间,默认为false
25036
+ * @param {boolean} [isMainRoom] - 无论是主房间,主房间是用户进入的房间,子房间是用户进入主房间后进入的房间。
25037
+ * @param {boolean} [useMutilPeerC] - 是否使用多个 peerConnections
25038
+ * @param {string} [_clientSessionId] - 当前房间的clientSessionId,用于区分当前房间和其他房间。
25039
+ * @param {RTCMode} roomType - RTCMode = RTCMode.RTC,
25040
+ * @param {number} signalRetryTime - 重新连接信令服务器的时间间隔。
25041
+ */
24854
25042
  constructor(context, runtime, roomId, service, initOptions, isUpgrade, isMainRoom,
24855
25043
  /**
24856
25044
  * 是否使用多 peerConnection
24857
25045
  */
24858
- useMutilPeerC, _clientSessionId, roomType = RTCMode.RTC) {
24859
- super(context, runtime, roomId, roomType, service, initOptions, isUpgrade, isMainRoom, useMutilPeerC, _clientSessionId);
25046
+ useMutilPeerC, _clientSessionId, roomType = RTCMode.RTC, signalRetryTime = PUBLISHSIGNALRETRYTIME) {
25047
+ super(context, runtime, roomId, roomType, service, initOptions, isUpgrade, isMainRoom, useMutilPeerC, _clientSessionId, signalRetryTime);
24860
25048
  }
24861
25049
  }
24862
25050
 
@@ -24934,7 +25122,7 @@ class RCAudienceClient {
24934
25122
  this._fromRetry = false;
24935
25123
  this._appListener = null;
24936
25124
  this._service = new RCMediaService(runtime, _context, _initOption.mediaServer);
24937
- this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._context.getCurrentId(), this._reTryExchange.bind(this), this._context.getCurrentId());
25125
+ this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._context.getCurrentId(), this._reTryExchange.bind(this), this._context.getCurrentId(), undefined, _initOption);
24938
25126
  }
24939
25127
  _getReqHeaders(livingType) {
24940
25128
  var _a, _b;
@@ -25280,7 +25468,7 @@ class RCAudienceLivingRoom {
25280
25468
  // 北极星数据
25281
25469
  this._polarisReport = new PolarisHttpReporter(this._context, this._runtime, this._roomId, this, PolarisRole.Audience);
25282
25470
  this._polarisReport.sendR1();
25283
- this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._roomId, this._reTryExchange.bind(this), this._context.getCurrentId(), this._polarisReport);
25471
+ this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._roomId, this._reTryExchange.bind(this), this._context.getCurrentId(), this._polarisReport, this._initOptions);
25284
25472
  // 注册监听 rtc_ntf 信令数据,解码后拉取指定房间数据
25285
25473
  this._context.registerRTCSignalListener((buffer) => __awaiter(this, void 0, void 0, function* () {
25286
25474
  var _a, _b;
@@ -26825,7 +27013,7 @@ class RCMediaStreamCapture {
26825
27013
  }));
26826
27014
  return { code: RCRTCCode.INVALID_TAGS };
26827
27015
  }
26828
- if (!track || track.toString() !== '[object MediaStreamTrack]' || track.kind !== 'video') {
27016
+ if (!track || !(track instanceof MediaStreamTrack) || track.kind !== 'video') {
26829
27017
  (_d = (_c = this._context) === null || _c === void 0 ? void 0 : _c.logger) === null || _d === void 0 ? void 0 : _d.error(RCLoggerTag.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O, JSON.stringify({
26830
27018
  status: RCLoggerStatus.FAILED,
26831
27019
  code: RCRTCCode.CREATE_CUSTOM_TRACK_FAILED,
@@ -27115,11 +27303,7 @@ class RCRTCClient extends RCMediaStreamCapture {
27115
27303
  }), traceId);
27116
27304
  return { code: RCRTCCode.REPERT_JOIN_ROOM };
27117
27305
  }
27118
- // 修改初始化配置中的超时时间
27119
- if (signalRetryTime) {
27120
- this._options.signalRetryTime = signalRetryTime;
27121
- }
27122
- const room = this._crtRoom = new RCRTCRoom(this._context, this._runtime, roomId, this._service, this._options, false, false, useMutilPeerC, getUUID());
27306
+ const room = this._crtRoom = new RCRTCRoom(this._context, this._runtime, roomId, this._service, this._options, false, false, useMutilPeerC, getUUID(), signalRetryTime);
27123
27307
  const { code } = yield room.__innerInit(roomType, joinType, undefined, undefined, outerUserDatas, traceId);
27124
27308
  if (code !== RCRTCCode.SUCCESS) {
27125
27309
  this._crtRoom = null;
@@ -27566,7 +27750,7 @@ class RCRTCClient extends RCMediaStreamCapture {
27566
27750
  }
27567
27751
  reportSDKInfo() {
27568
27752
  this._context.reportSDKInfo({
27569
- 'plugin-rtc': "5.5.5-beem.3",
27753
+ 'plugin-rtc': "5.5.5-beem.4",
27570
27754
  });
27571
27755
  }
27572
27756
  }
@@ -28031,7 +28215,8 @@ const encodeRtcInput = (codec, roomType, broadcastType, joinType, innerUserDatas
28031
28215
  };
28032
28216
  const decodeRtcUserListOutput = (codec, buffer) => {
28033
28217
  const rtcInfos = codec.decode(RTCPB.RtcUserListOutput, buffer);
28034
- const { users: list, token, sessionId, roomInfo, entries, offlineKickTime, codeFormat, roomCreateTime, userJoinTime, version, } = rtcInfos;
28218
+ // 多端对齐 OfflineKickTime 默认为 60 S (单位为秒)
28219
+ const { users: list, token, sessionId, roomInfo, entries, offlineKickTime = 60, codeFormat, roomCreateTime, userJoinTime, version, } = rtcInfos;
28035
28220
  const users = {};
28036
28221
  forEach(list, (item) => {
28037
28222
  const { userId, userData } = item;
@@ -28187,16 +28372,17 @@ class RTCContext {
28187
28372
  * @param valueInfo 全量资源数据
28188
28373
  * @param objectName 全量 URI 消息名
28189
28374
  */
28190
- setRTCTotalRes(roomId, message, valueInfo, objectName, mcuValInfo = '') {
28375
+ setRTCTotalRes(roomId, message, valueInfo, objectName, mcuValInfo, cdnValInfo) {
28191
28376
  return __awaiter(this, void 0, void 0, function* () {
28192
28377
  const params = {
28193
28378
  objectName,
28194
28379
  content: this.codec.encode(RTCPB.RtcValueInfo, { key: message.name, value: message.content }, true),
28195
28380
  valueInfo: [
28196
28381
  this.codec.encode(RTCPB.RtcValueInfo, { key: 'uris', value: valueInfo }, true),
28197
- this.codec.encode(RTCPB.RtcValueInfo, { key: 'mcu_uris', value: mcuValInfo }, true),
28198
28382
  ],
28199
28383
  };
28384
+ mcuValInfo && params.valueInfo.push(this.codec.encode(RTCPB.RtcValueInfo, { key: 'mcu_uris', value: mcuValInfo }, true));
28385
+ cdnValInfo && params.valueInfo.push(this.codec.encode(RTCPB.RtcValueInfo, { key: 'cdn_uris', value: cdnValInfo }, true));
28200
28386
  const sourceData = this.codec.encode(RTCPB.RtcUserSetDataInput, params);
28201
28387
  const { code } = yield this.context.rtcSignaling(roomId, RTC_API.userSetData, true, sourceData);
28202
28388
  return code;
@@ -28553,22 +28739,22 @@ const installer = {
28553
28739
  console.error('Please use the https protocol or use `http://localhost` to open the page!');
28554
28740
  return false;
28555
28741
  }
28556
- VersionManage.add('plugin-rtc', "5.5.5-beem.3");
28557
- if (!VersionManage.validEngine("^5.6.2-beem.2")) {
28558
- console.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"^5.6.2-beem.2"}'.`);
28742
+ VersionManage.add('plugin-rtc', "5.5.5-beem.4");
28743
+ if (!VersionManage.validEngine("^5.6.0")) {
28744
+ console.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"^5.6.0"}'.`);
28559
28745
  return false;
28560
28746
  }
28561
28747
  return true;
28562
28748
  },
28563
- setup(context, runtime, options = { signalRetryTime: 30 * 1000 }) {
28749
+ setup(context, runtime, options = {}) {
28564
28750
  var _a, _b, _c, _d, _e, _f, _g, _h;
28565
28751
  const originLogger = context.createLogger('RCRTC', LogSource.RTC);
28566
28752
  originLogger.setOutputLevel(options.logLevel || LogL.DEBUG);
28567
28753
  RTCLogger.setLogger(originLogger);
28568
28754
  logger.setLogger(originLogger);
28569
28755
  originLogger.warn(RCLoggerTag.L_INDEX_INSTALL_RTC_PLUGIN_O, JSON.stringify({
28570
- 'RCRTC Version': "5.5.5-beem.3",
28571
- Commit: "b639b89eb82e0b55da6285514427d887456ecbd2",
28756
+ 'RCRTC Version': "5.5.5-beem.4",
28757
+ Commit: "1c464fa58c20897be94d3d50ee25c52729284323",
28572
28758
  'browserInfo.browser': browserInfo.browser,
28573
28759
  'browserInfo.supportsUnifiedPlan': browserInfo.supportsUnifiedPlan,
28574
28760
  'browserInfo.version': browserInfo.version,