@rongcloud/plugin-rtc 5.5.5-beem.2 → 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.umd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.5.5-beem.2
3
- * CommitId - fb1da8eadeb0d8d9871ed026c4ccb09a9f570b77
4
- * Thu Oct 27 2022 20:08:26 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
  (function (global, factory) {
@@ -6826,7 +6826,7 @@
6826
6826
  }));
6827
6827
  return { code: exports.RCRTCCode.VIDEO_TRACK_MISS_MEDIA_ELEMENT };
6828
6828
  }
6829
- this._element = isVideoTrack ? element : (this._element || new Audio());
6829
+ this._element = isVideoTrack ? element : new Audio();
6830
6830
  // 若本地静音,则恢复本地播放
6831
6831
  if (this._localMuted) {
6832
6832
  this._setLocalMuted(false);
@@ -6882,10 +6882,10 @@
6882
6882
  msg: `HTMLMediaElement oncanplay -> id: ${(_k = evt.target) === null || _k === void 0 ? void 0 : _k.id}, trackId: ${this._id}`,
6883
6883
  }));
6884
6884
  try {
6885
- yield ((_l = this._element) === null || _l === void 0 ? void 0 : _l.play());
6886
6885
  if ((options === null || options === void 0 ? void 0 : options.audioDeviceId) && !isVideoTrack) {
6887
6886
  yield this._element.setSinkId(options.audioDeviceId);
6888
6887
  }
6888
+ yield ((_l = this._element) === null || _l === void 0 ? void 0 : _l.play());
6889
6889
  }
6890
6890
  catch (error) {
6891
6891
  /**
@@ -6923,9 +6923,9 @@
6923
6923
  this._element.x5PlaysInline = true;
6924
6924
  this._element.webkitPlaysInline = true;
6925
6925
  }
6926
- // if (options?.audioDeviceId && !isVideoTrack) {
6927
- // await (this._element as any).setSinkId(options.audioDeviceId)
6928
- // }
6926
+ if ((options === null || options === void 0 ? void 0 : options.audioDeviceId) && !isVideoTrack) {
6927
+ yield this._element.setSinkId(options.audioDeviceId);
6928
+ }
6929
6929
  // audio 标签设置音量
6930
6930
  if (!isVideoTrack && ((options === null || options === void 0 ? void 0 : options.volume) || (options === null || options === void 0 ? void 0 : options.volume) === 0)) {
6931
6931
  this._element.volume = (options === null || options === void 0 ? void 0 : options.volume) / 100;
@@ -7985,6 +7985,13 @@
7985
7985
  * RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
7986
7986
  */
7987
7987
  class Pinger {
7988
+ /**
7989
+ * 一个构造函数。
7990
+ * @param {ReadableStore} _store - ReadableStore:包含房间信息的商店。
7991
+ * @param {RTCContext} _context - RTC上下文
7992
+ * @param {number} _gap - ping 之间的时间间隔。
7993
+ * @param {number} _offlineKickTime - 用户离线时被踢出房间的时间。
7994
+ */
7988
7995
  constructor(_store, _context, _gap = PING_GAP, _offlineKickTime = 60 * 1000) {
7989
7996
  this._store = _store;
7990
7997
  this._context = _context;
@@ -8000,6 +8007,10 @@
8000
8007
  const { roomId, roomMode } = this._store;
8001
8008
  this._roomId = roomId;
8002
8009
  this._roomMode = roomMode;
8010
+ // 设置最小 offlineKickTime 值
8011
+ if (this._offlineKickTime < 15 * 1000) {
8012
+ this._offlineKickTime = 15000;
8013
+ }
8003
8014
  }
8004
8015
  /**
8005
8016
  * 启动 Ping
@@ -14742,7 +14753,7 @@
14742
14753
  'Content-Type': 'application/json;charset=UTF-8',
14743
14754
  'Cache-Control': 'no-cache',
14744
14755
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
14745
- ClientVersion: "5.5.5-beem.2",
14756
+ ClientVersion: "5.5.5-beem.4",
14746
14757
  'Client-Session-Id': getUUID(),
14747
14758
  'Request-Id': Date.now().toString(),
14748
14759
  });
@@ -14992,7 +15003,7 @@
14992
15003
  rsid: item.reqId,
14993
15004
  rsdur: item.end - item.start,
14994
15005
  msa: item.url,
14995
- rscod: item.rscod,
15006
+ rscod: item.status,
14996
15007
  });
14997
15008
  });
14998
15009
  if (memo.subscribeCommand) {
@@ -15111,7 +15122,7 @@
15111
15122
  rsid: item.reqId,
15112
15123
  rsdur: item.end - item.start,
15113
15124
  msa: item.url,
15114
- rscod: item.rscod,
15125
+ rscod: item.status,
15115
15126
  });
15116
15127
  });
15117
15128
  localTracks.forEach((track) => {
@@ -15130,7 +15141,7 @@
15130
15141
  rsid: item.reqId,
15131
15142
  rsdur: item.end - item.start,
15132
15143
  msa: item.url,
15133
- rscod: item.rscod,
15144
+ rscod: item.status,
15134
15145
  });
15135
15146
  });
15136
15147
  const sigs = [];
@@ -15186,7 +15197,7 @@
15186
15197
  rsid: item.reqId,
15187
15198
  rsdur: item.end - item.start,
15188
15199
  msa: item.url,
15189
- rscod: item.rscod,
15200
+ rscod: item.status,
15190
15201
  });
15191
15202
  });
15192
15203
  const sigs = [];
@@ -15212,7 +15223,7 @@
15212
15223
  rsid: item.reqId,
15213
15224
  rsdur: item.end - item.start,
15214
15225
  msa: item.url,
15215
- rscod: item.rscod,
15226
+ rscod: item.status,
15216
15227
  });
15217
15228
  });
15218
15229
  const sigs = [];
@@ -15281,7 +15292,7 @@
15281
15292
  var _a, _b, _c, _d;
15282
15293
  const memo = Memo.getMemo();
15283
15294
  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: [] }));
15284
- logger.__statistics(RCLoggerTag.L_QS_SUBSCRIBE_S, reportData);
15295
+ logger.__statistics(RCLoggerTag.L_QS_ICE_STATUS_S, reportData);
15285
15296
  };
15286
15297
  const reportQualityFirstSubOrPubStatusData = () => {
15287
15298
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
@@ -15320,7 +15331,7 @@
15320
15331
  'Content-Type': 'application/json;charset=UTF-8',
15321
15332
  'Cache-Control': 'no-cache',
15322
15333
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
15323
- ClientVersion: "5.5.5-beem.2",
15334
+ ClientVersion: "5.5.5-beem.4",
15324
15335
  'Client-Session-Id': getUUID(),
15325
15336
  'Request-Id': Date.now().toString(),
15326
15337
  });
@@ -15831,6 +15842,21 @@
15831
15842
  }
15832
15843
  SourceIdMap._instance = new Map([['sourceIdForPublishMap', new Map()], ['sourceIdForSubscribeMap', new Map()]]);
15833
15844
 
15845
+ var ReportTypes;
15846
+ (function (ReportTypes) {
15847
+ ReportTypes["TRACK"] = "track";
15848
+ ReportTypes["STREAM"] = "stream";
15849
+ ReportTypes["MEDIASOURCE"] = "media-source";
15850
+ ReportTypes["INBOUNDRTP"] = "inbound-rtp";
15851
+ ReportTypes["OUTBOUNDRTP"] = "outbound-rtp";
15852
+ ReportTypes["REMOTEINBOUNDRTP"] = "remote-inbound-rtp";
15853
+ ReportTypes["PEERCONNECTION"] = "peer-connection";
15854
+ ReportTypes["TRANSPORT"] = "transport";
15855
+ ReportTypes["CERTIFICATE"] = "certificate";
15856
+ ReportTypes["CANDIDATEPAIR"] = "candidate-pair";
15857
+ ReportTypes["REMOTECANDIDATE"] = "remote-candidate";
15858
+ ReportTypes["LOCALCANDIDATE"] = "local-candidate";
15859
+ })(ReportTypes || (ReportTypes = {}));
15834
15860
  class AbstractStatParser {
15835
15861
  constructor(_rtcPeerConn, _sdpSemantics, _currentUserId) {
15836
15862
  this._rtcPeerConn = _rtcPeerConn;
@@ -15990,10 +16016,10 @@
15990
16016
  }
15991
16017
  parseRTCStatsReport(reports) {
15992
16018
  const stats = {};
15993
- for (const key of reports.keys()) {
16019
+ for (const [key, value] of reports.entries()) {
15994
16020
  // 过滤下行数据上报
15995
- if (!key.includes('RTCCodec_')) {
15996
- stats[key] = reports.get(key);
16021
+ if (!/codec/ig.test(value) || !key.includes('RTCCodec_')) {
16022
+ stats[key] = value;
15997
16023
  }
15998
16024
  }
15999
16025
  return stats;
@@ -16071,6 +16097,38 @@
16071
16097
  const valid = answer === null || answer === void 0 ? void 0 : answer.split('\r\nm=').some((item) => (item.includes(ssrc) && item.includes('a=inactive')));
16072
16098
  return !valid;
16073
16099
  }
16100
+ formatStateData(stats) {
16101
+ const init = {
16102
+ outbound: [],
16103
+ remoteInbound: [],
16104
+ inbound: [],
16105
+ transport: [],
16106
+ connection: [],
16107
+ };
16108
+ return Object.values(stats).reduce((result, item) => {
16109
+ if (item.type === ReportTypes.REMOTEINBOUNDRTP) {
16110
+ result.remoteInbound.push(item);
16111
+ return result;
16112
+ }
16113
+ if (item.type === ReportTypes.INBOUNDRTP) {
16114
+ result.inbound.push(item);
16115
+ return result;
16116
+ }
16117
+ if (item.type === ReportTypes.OUTBOUNDRTP) {
16118
+ result.outbound.push(item);
16119
+ return result;
16120
+ }
16121
+ if (item.type === ReportTypes.TRANSPORT) {
16122
+ result.transport.push(item);
16123
+ return result;
16124
+ }
16125
+ if (item.type === ReportTypes.PEERCONNECTION) {
16126
+ result.connection.push(item);
16127
+ return result;
16128
+ }
16129
+ return result;
16130
+ }, init);
16131
+ }
16074
16132
  }
16075
16133
  /**
16076
16134
  * 从sdp中解析出ssrc和msid并缓存
@@ -16105,25 +16163,118 @@
16105
16163
  * chrome 73 无 type 为 remote-inbound-rtp 的数据,上行拿不到 jetter、rtt、packetsLost 数据
16106
16164
  */
16107
16165
  class RTCReportParser$2 extends AbstractStatParser {
16166
+ /**
16167
+ * 该函数用于解析getStats()方法返回的RTCStatsReport对象的数据,然后以RCRTCStateReport对象的格式返回数据
16168
+ * @param stats - getStats 方法返回的数据
16169
+ * @returns 返回值是一个具有以下属性的对象:IInnerRCRTCStateReport
16170
+ */
16108
16171
  formatRCRTCStateReport(stats) {
16172
+ const { outbound, remoteInbound, inbound, transport, connection, } = this.formatStateData(stats);
16109
16173
  const reports = {
16110
16174
  senders: [],
16111
16175
  receivers: [],
16112
16176
  };
16113
16177
  // 当次报告创建时的时间戳
16114
- const timestamp = Math.floor(stats.RTCPeerConnection.timestamp);
16178
+ const timestamp = Math.floor(connection[0].timestamp);
16115
16179
  reports.timestamp = timestamp;
16116
- const keys = Object.keys(stats);
16117
16180
  // 总丢包数
16118
16181
  let totalPacketsLost = 0;
16119
16182
  // 上行码率总和
16120
16183
  let bitrateSend = 0;
16121
16184
  // 解析上行媒体流数据: RTCOutboundRTPVideoStream | RTCOutboundRTPAudioStream
16122
- const outboundKeys = keys.filter((key) => /^RTCOutboundRTP(Video|Audio)Stream_/.test(key));
16123
- outboundKeys.forEach((key) => {
16185
+ ({ totalPacketsLost, bitrateSend, senders: reports.senders } = this.pickOutbound(outbound, stats, totalPacketsLost, timestamp, bitrateSend));
16186
+ /**
16187
+ * outbound-rtp 存在无 remoteId 的情况,导致取不到有效的 jitter、rtt、packetsLost,
16188
+ * 可拿到 remote-inbound-rtp 的 localId,补充 senders 中的 jitter、rtt、packetsLost 数据,重新计算丢包率
16189
+ */
16190
+ if (remoteInbound.length > 0 && reports.senders.length > 0) {
16191
+ this.pickRemoteInbound(remoteInbound, reports.senders, stats);
16192
+ }
16193
+ // 下行码率总和
16194
+ let bitrateRecv = 0;
16195
+ // 下行流数据解析
16196
+ ({ totalPacketsLost, bitrateRecv, receivers: reports.receivers } = this.pickInbound(inbound, stats, totalPacketsLost, timestamp, bitrateRecv));
16197
+ // 解析本端/远端 IP、Port 数据
16198
+ if (transport.length > 0) {
16199
+ const rtcTransport = transport[0];
16200
+ this.pickRtcTransport(rtcTransport, stats, reports, bitrateRecv, bitrateSend, totalPacketsLost);
16201
+ }
16202
+ return reports;
16203
+ }
16204
+ /**
16205
+ * 选择 RTC 传输的函数。
16206
+ * @param {ReportData[]} transport - 报告中的传输对象
16207
+ * @param stats - 当前 RTCPeerConnection 的统计信息
16208
+ * @param {IInnerRCRTCStateReport} reports - IInnerRCRTCStateReport
16209
+ * @param {number} bitrateRecv - 接收流的总比特率。
16210
+ * @param {number} bitrateSend - 传出流的比特率。
16211
+ * @param {number} totalPacketsLost - 当前会话中丢失的数据包总数。
16212
+ */
16213
+ pickRtcTransport(rtcTransport, stats, reports, bitrateRecv, bitrateSend, totalPacketsLost) {
16214
+ const { selectedCandidatePairId } = rtcTransport;
16215
+ if (selectedCandidatePairId) {
16216
+ const iceCandidatePair = stats[selectedCandidatePairId];
16217
+ const { availableOutgoingBitrate,
16218
+ // 下行带宽只在有下行资源时有值
16219
+ availableIncomingBitrate, currentRoundTripTime: rtt, localCandidateId, remoteCandidateId, } = iceCandidatePair;
16220
+ const localCandidate = stats[localCandidateId];
16221
+ const { ip: IP, port, networkType } = localCandidate;
16222
+ const remoteCandidate = stats[remoteCandidateId];
16223
+ const { ip: remoteIP, port: remotePort, protocol } = remoteCandidate;
16224
+ reports.iceCandidatePair = {
16225
+ IP,
16226
+ port,
16227
+ networkType,
16228
+ remoteIP,
16229
+ remotePort,
16230
+ protocol,
16231
+ bitrateRecv,
16232
+ bitrateSend,
16233
+ rtt: rtt * 1000,
16234
+ availableOutgoingBitrate,
16235
+ availableIncomingBitrate,
16236
+ totalPacketsLost,
16237
+ };
16238
+ // 给下行 rtt 赋值
16239
+ reports.receivers.forEach((item) => {
16240
+ item.rtt = rtt;
16241
+ });
16242
+ }
16243
+ }
16244
+ /**
16245
+ * 它接收一个 ReportData 对象数组、一个 ISendTrackState 对象数组和一个 stats 对象。然后,它遍历 ReportData 对象,并为每个对象过滤
16246
+ * ISendTrackState 对象以找到与 ReportData 对象的 localId
16247
+ * 匹配的对象。如果找到匹配项,则检查发送方是否有远程数据。如果没有,则通过解析SDP获取resourceId,设置发送者的jitter和rtt,获取packetsSent,然后更新发送者的packetsLostRate
16248
+ * @param {ReportData[]} remoteInbound - 远程入站轨迹的数据。
16249
+ * @param {ISendTrackState[]} senders - 本地流的发送者列表。
16250
+ * @param stats - 本地流的统计信息。
16251
+ */
16252
+ pickRemoteInbound(remoteInbound, senders, stats) {
16253
+ remoteInbound.forEach((remoteInboundItem) => {
16254
+ const { localId, jitter, roundTripTime: rtt, packetsLost, } = remoteInboundItem;
16255
+ const sender = senders.filter((item) => item.id === localId)[0];
16256
+ if (sender && !senderHasRemoteData(sender)) {
16257
+ const resourceId = this.getResourceIdByParseSdp(stats[sender.id]);
16258
+ sender.jitter = Math.round(jitter * 1000);
16259
+ sender.rtt = rtt;
16260
+ const packetsSent = this._latestPacketsSent[resourceId].crtPacketsSent;
16261
+ sender.packetsLostRate = this.updateSenderPacketsLost(resourceId, packetsLost, packetsSent);
16262
+ }
16263
+ });
16264
+ }
16265
+ /**
16266
+ * 该函数用于解析发送到远程端的本地流的数据
16267
+ * @param {ReportData[]} outbound - 本端发送的数据。
16268
+ * @param stats - 当前流的统计信息。
16269
+ * @param {number} totalPacketsLost - 本地和远程端丢失的数据包总数。
16270
+ * @param {number} timestamp - 当前报告的时间戳。
16271
+ * @param {number} bitrateSend - 本地流的总比特率。
16272
+ */
16273
+ pickOutbound(outbound, stats, totalPacketsLost, timestamp, bitrateSend) {
16274
+ const senders = [];
16275
+ outbound.forEach((outboundInfo) => {
16124
16276
  var _a;
16125
16277
  // 本端输出数据
16126
- const outboundInfo = stats[key];
16127
16278
  if (this._sdpSemantics === 'unified-plan' && !this.isValidSender(outboundInfo)) {
16128
16279
  return;
16129
16280
  }
@@ -16187,7 +16338,7 @@
16187
16338
  }
16188
16339
  // 总和累加
16189
16340
  bitrateSend += bitrate;
16190
- reports.senders.push({
16341
+ senders.push({
16191
16342
  id,
16192
16343
  trackId: resourceId,
16193
16344
  kind,
@@ -16209,28 +16360,19 @@
16209
16360
  trackState: STAT_NONE,
16210
16361
  });
16211
16362
  });
16212
- /**
16213
- * outbound-rtp 存在无 remoteId 的情况,导致取不到有效的 jitter、rtt、packetsLost,
16214
- * 可拿到 remote-inbound-rtp 的 localId,补充 senders 中的 jitter、rtt、packetsLost 数据,重新计算丢包率
16215
- */
16216
- const remoteInboundKeys = keys.filter((key) => /RTCRemoteInboundRtp(Video|Audio)Stream_/.test(key));
16217
- remoteInboundKeys.forEach((key) => {
16218
- const { localId, jitter, roundTripTime: rtt, packetsLost, } = stats[key];
16219
- const sender = reports.senders.filter((item) => item.id === localId)[0];
16220
- if (sender && !senderHasRemoteData(sender)) {
16221
- const resourceId = this.getResourceIdByParseSdp(stats[sender.id]);
16222
- sender.jitter = Math.round(jitter * 1000);
16223
- sender.rtt = rtt;
16224
- const packetsSent = this._latestPacketsSent[resourceId].crtPacketsSent;
16225
- sender.packetsLostRate = this.updateSenderPacketsLost(resourceId, packetsLost, packetsSent);
16226
- }
16227
- });
16228
- // 下行码率总和
16229
- let bitrateRecv = 0;
16230
- // 下行流数据解析
16231
- const inboundKeys = keys.filter((key) => /^RTCInboundRTP(Video|Audio)Stream_/.test(key));
16232
- inboundKeys.forEach((key) => {
16233
- const inboundInfo = stats[key];
16363
+ return { totalPacketsLost, bitrateSend, senders };
16364
+ }
16365
+ /**
16366
+ * 解析报表的入站数据的函数。
16367
+ * @param {ReportData[]} inbound - 报表的入站数据
16368
+ * @param stats - 当前 RTCPeerConnection 的统计信息。
16369
+ * @param {number} totalPacketsLost - 丢包总数
16370
+ * @param {number} timestamp - 当前报告的时间戳。
16371
+ * @param {number} bitrateRecv - 接收流的总比特率。
16372
+ */
16373
+ pickInbound(inbound, stats, totalPacketsLost, timestamp, bitrateRecv) {
16374
+ let receivers = [];
16375
+ inbound.forEach((inboundInfo) => {
16234
16376
  if (this._sdpSemantics === 'unified-plan' && !this.isValidReceiver(inboundInfo)) {
16235
16377
  return;
16236
16378
  }
@@ -16257,7 +16399,7 @@
16257
16399
  bitrate = 0;
16258
16400
  }
16259
16401
  bitrateRecv += bitrate;
16260
- reports.receivers.push({
16402
+ receivers.push({
16261
16403
  trackId: resourceId,
16262
16404
  kind,
16263
16405
  packetsLostRate,
@@ -16278,78 +16420,35 @@
16278
16420
  trackState: STAT_NONE,
16279
16421
  });
16280
16422
  });
16281
- // 解析本端/远端 IP、Port 数据
16282
- const transportKey = keys.filter((key) => /^RTCTransport_/.test(key))[0];
16283
- if (transportKey) {
16284
- const rtcTransport = stats[transportKey];
16285
- const { selectedCandidatePairId } = rtcTransport;
16286
- if (selectedCandidatePairId) {
16287
- const iceCandidatePair = stats[selectedCandidatePairId];
16288
- const { availableOutgoingBitrate,
16289
- // 下行带宽只在有下行资源时有值
16290
- availableIncomingBitrate, currentRoundTripTime: rtt, localCandidateId, remoteCandidateId, } = iceCandidatePair;
16291
- const localCandidate = stats[localCandidateId];
16292
- const { ip: IP, port, networkType } = localCandidate;
16293
- const remoteCandidate = stats[remoteCandidateId];
16294
- const { ip: remoteIP, port: remotePort, protocol } = remoteCandidate;
16295
- reports.iceCandidatePair = {
16296
- IP,
16297
- port,
16298
- networkType,
16299
- remoteIP,
16300
- remotePort,
16301
- protocol,
16302
- bitrateRecv,
16303
- bitrateSend,
16304
- rtt: rtt * 1000,
16305
- availableOutgoingBitrate,
16306
- availableIncomingBitrate,
16307
- totalPacketsLost,
16308
- };
16309
- // 给下行 rtt 赋值
16310
- reports.receivers.forEach((item) => {
16311
- item.rtt = rtt;
16312
- });
16313
- }
16314
- }
16315
- return reports;
16423
+ return { totalPacketsLost, bitrateRecv, receivers };
16316
16424
  }
16425
+ /**
16426
+ * 该函数用于获取当前流的音频电平
16427
+ * @param stats - getStats 方法返回的数据
16428
+ * @returns 具有以下属性的对象数组:
16429
+ */
16317
16430
  getAudioLevelList(stats) {
16318
16431
  const audioLevelList = [];
16319
- const keys = Object.keys(stats);
16320
16432
  // 解析上行媒体流数据: RTCOutboundRTPVideoStream | RTCOutboundRTPAudioStream
16321
- const outboundKeys = keys.filter((key) => /^RTCOutboundRTPAudioStream_/.test(key));
16322
- outboundKeys.forEach((key) => {
16323
- var _a, _b;
16433
+ const { outbound, inbound } = this.formatStateData(stats);
16434
+ const outboundList = outbound.filter((item) => (item === null || item === void 0 ? void 0 : item.kind) === 'audio');
16435
+ outboundList.forEach((outboundInfo) => {
16436
+ var _a;
16324
16437
  // 本端输出数据
16325
- const outboundInfo = stats[key];
16326
16438
  if (this._sdpSemantics === 'unified-plan' && !this.isValidSender(outboundInfo)) {
16327
16439
  return;
16328
16440
  }
16329
16441
  const { mediaSourceId, trackId, kind } = outboundInfo;
16330
- const SingleInstance = SdpResource.getInstance();
16331
- const resourceIds = SingleInstance.streams;
16332
- let resourceId = '';
16333
- for (const streamId of resourceIds.keys()) {
16334
- const value = resourceIds.get(streamId);
16335
- if (value) {
16336
- const tracks = (_a = stats[`RTCMediaStream_${value.msid}`]) === null || _a === void 0 ? void 0 : _a.trackIds;
16337
- if (tracks && tracks.includes(outboundInfo.trackId) && kind === value.kind) {
16338
- resourceId = streamId;
16339
- }
16340
- }
16341
- }
16342
- // const resourceId = this.getResourceIdByParseSdp(outboundInfo);
16343
- const audioLevel = mediaSourceId && stats[mediaSourceId] ? stats[mediaSourceId].audioLevel : (((_b = stats[trackId]) === null || _b === void 0 ? void 0 : _b.audioLevel) || null);
16442
+ const resourceId = this.getResourceIdByParseSdp(outboundInfo);
16443
+ const audioLevel = mediaSourceId && stats[mediaSourceId] ? stats[mediaSourceId].audioLevel : (((_a = stats[trackId]) === null || _a === void 0 ? void 0 : _a.audioLevel) || null);
16344
16444
  audioLevelList.push({
16345
16445
  trackId: resourceId,
16346
16446
  audioLevel: (audioLevel || audioLevel === 0) ? handleAudioLevel(audioLevel) : null,
16347
16447
  });
16348
16448
  });
16349
16449
  // 下行流数据解析
16350
- const inboundKeys = keys.filter((key) => /^RTCInboundRTPAudioStream_/.test(key));
16351
- inboundKeys.forEach((key) => {
16352
- const inboundInfo = stats[key];
16450
+ const inboundList = inbound.filter((item) => (item === null || item === void 0 ? void 0 : item.kind) === 'audio');
16451
+ inboundList.forEach((inboundInfo) => {
16353
16452
  if (this._sdpSemantics === 'unified-plan' && !this.isValidReceiver(inboundInfo)) {
16354
16453
  return;
16355
16454
  }
@@ -17158,6 +17257,10 @@
17158
17257
  return __awaiter(this, void 0, void 0, function* () {
17159
17258
  // 过滤行末的空格,服务可能产生空格数据
17160
17259
  sdp = ASdpBuilder.trimBlankLine(sdp);
17260
+ if (this._peer.connectionState === 'disconnected'
17261
+ || this._peer.connectionState === 'closed') {
17262
+ return exports.RCRTCCode.SET_REMOTE_DESCRIPTION_FAILED;
17263
+ }
17161
17264
  try {
17162
17265
  yield this._peer.setRemoteDescription({ type: 'answer', sdp });
17163
17266
  }
@@ -17512,6 +17615,10 @@
17512
17615
  var _a;
17513
17616
  (_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`');
17514
17617
  }
17618
+ /**
17619
+ * 该函数用于向对等连接添加本地轨道
17620
+ * @param {RCLocalTrack} track - RCLocalTrack
17621
+ */
17515
17622
  addLocalTrack(track) {
17516
17623
  var _a;
17517
17624
  const trackId = track.getTrackId();
@@ -17536,6 +17643,11 @@
17536
17643
  const SingleInstance = SdpResource.getInstance();
17537
17644
  SingleInstance.push(trackId, { msid, id: this._outboundStreams[msid].id, kind: (_a = track.streamTrack) === null || _a === void 0 ? void 0 : _a.kind });
17538
17645
  }
17646
+ /**
17647
+ * 该函数从对等连接中删除本地轨道
17648
+ * @param {RCLocalTrack} track - RCLocalTrack
17649
+ * @returns 返回值是函数中执行的最后一条语句返回的值。
17650
+ */
17539
17651
  removeLocalTrack(track) {
17540
17652
  const trackId = track.getTrackId();
17541
17653
  const msid = track.getStreamId();
@@ -17574,6 +17686,11 @@
17574
17686
  tinyTrack.stop();
17575
17687
  }
17576
17688
  }
17689
+ /**
17690
+ * 更新trackId和收发器的映射关系,从候选列表中删除收发器
17691
+ * @param {string} trackId - 要添加的轨道的 trackId。
17692
+ * @param {RTCRtpTransceiver} transceiver - RTCRtp收发器
17693
+ */
17577
17694
  updateRecvTransceiverMap(trackId, transceiver) {
17578
17695
  const { mediaType } = parseTrackId(trackId);
17579
17696
  // 更新映射关系
@@ -17583,6 +17700,10 @@
17583
17700
  const index = arrTransceiver.findIndex((item) => item === transceiver);
17584
17701
  index >= 0 && arrTransceiver.splice(index, 1);
17585
17702
  }
17703
+ /**
17704
+ * 该函数用于更新本地客户端订阅的远程轨道
17705
+ * @param {RCRemoteTrack[]} tracks - 要更新的远程轨道数组。
17706
+ */
17586
17707
  updateSubRemoteTracks(tracks) {
17587
17708
  // 减法记录新增订阅
17588
17709
  const addTracks = tracks.slice();
@@ -17796,13 +17917,17 @@
17796
17917
  /**
17797
17918
  * 北极星上传实例
17798
17919
  */
17799
- _polarisReport, onTrackTrouble) {
17920
+ _polarisReport, onTrackTrouble,
17921
+ /* 私有只读属性。RTCContext */
17922
+ _initOptions) {
17800
17923
  super();
17801
17924
  this._pcName = _pcName;
17802
17925
  this._reTryExchange = _reTryExchange;
17803
17926
  this._currentUserId = _currentUserId;
17804
17927
  this._polarisReport = _polarisReport;
17805
17928
  this.onTrackTrouble = onTrackTrouble;
17929
+ this._initOptions = _initOptions;
17930
+ this.senderAndReciveSize = 32;
17806
17931
  this.pubLocalTracks = {};
17807
17932
  this._reTryExchangeTimer = null;
17808
17933
  // peerConnection stats 计时器
@@ -17925,6 +18050,13 @@
17925
18050
  }));
17926
18051
  });
17927
18052
  }
18053
+ /**
18054
+ * `createOffer` 是一个创建报价并记录报价 SDP 和 SDP 语义的函数
18055
+ * @param {boolean} iceRestart - 布尔值
18056
+ * @returns 具有两个属性的对象:
18057
+ * - sdp:SDP 字符串
18058
+ * - 语义:SDP 语义
18059
+ */
17928
18060
  createOffer(iceRestart) {
17929
18061
  var _a;
17930
18062
  return __awaiter(this, void 0, void 0, function* () {
@@ -17944,6 +18076,10 @@
17944
18076
  getLocalTrack(trackId) {
17945
18077
  return this.pubLocalTracks[trackId] || null;
17946
18078
  }
18079
+ /**
18080
+ * 它将本地轨道添加到对等连接。
18081
+ * @param {RCLocalTrack} track - 要添加的本地轨道。
18082
+ */
17947
18083
  addLocalTrack(track) {
17948
18084
  var _a;
17949
18085
  this.pubLocalTracks[track.getTrackId()] = track;
@@ -17957,6 +18093,11 @@
17957
18093
  trackId: track.getTrackId(),
17958
18094
  }));
17959
18095
  }
18096
+ /**
18097
+ * 按 ID 删除本地轨道
18098
+ * @param {string} trackId - 要移除的轨道的 ID。
18099
+ * @returns 正在删除的轨道。
18100
+ */
17960
18101
  removeLocalTrackById(trackId) {
17961
18102
  var _a, _b;
17962
18103
  const track = this.getLocalTrack(trackId);
@@ -17974,12 +18115,19 @@
17974
18115
  }));
17975
18116
  this.removeLocalTrack(track);
17976
18117
  }
18118
+ /**
18119
+ * 它会删除所有本地Track。
18120
+ */
17977
18121
  removeAllLocalTrack() {
17978
18122
  Object.keys(this.pubLocalTracks).forEach((id) => {
17979
18123
  // 小流不可先于大流执行 removeLocalTrackById,否则可能存在小流被当做大流进而不可被销毁
17980
18124
  /_tiny$/.test(id) || this.removeLocalTrackById(id);
17981
18125
  });
17982
18126
  }
18127
+ /**
18128
+ * 从对等连接中删除本地轨道。
18129
+ * @param {RCLocalTrack} track - 要删除的本地轨道。
18130
+ */
17983
18131
  removeLocalTrack(track) {
17984
18132
  var _a;
17985
18133
  const trackId = track.getTrackId();
@@ -18035,44 +18183,46 @@
18035
18183
  this._reportListener = listener;
18036
18184
  }
18037
18185
  _createRCRTCStateReport(data) {
18038
- const { timestamp, iceCandidatePair, senders, receivers, } = JSON.parse(JSON.stringify(data));
18039
- iceCandidatePair === null || iceCandidatePair === void 0 ? true : delete iceCandidatePair.totalPacketsLost;
18186
+ const { timestamp, iceCandidatePair, senders, receivers, } = data;
18187
+ if (iceCandidatePair === null || iceCandidatePair === void 0 ? void 0 : iceCandidatePair.totalPacketsLost) {
18188
+ iceCandidatePair === null || iceCandidatePair === void 0 ? true : delete iceCandidatePair.totalPacketsLost;
18189
+ }
18040
18190
  for (const key in iceCandidatePair) {
18041
18191
  isNull(iceCandidatePair[key]) && delete iceCandidatePair[key];
18042
18192
  }
18043
- const newSenders = senders.map((item) => {
18044
- const sender = {};
18045
- item.trackId && (sender.trackId = item.trackId);
18046
- item.kind && (sender.kind = item.kind);
18047
- (item.packetsLostRate || item.packetsLostRate === 0) && (sender.packetsLostRate = item.packetsLostRate);
18048
- sender.remoteResource = item.remoteResource;
18193
+ const pickSender = [];
18194
+ senders.forEach((item) => {
18195
+ const { trackId, kind, packetsLostRate, remoteResource, bitrate, jitter, } = item;
18196
+ const sender = {
18197
+ trackId, kind, packetsLostRate, remoteResource, bitrate, jitter,
18198
+ };
18049
18199
  (item.audioLevel || item.audioLevel === 0) && (sender.audioLevel = item.audioLevel);
18050
18200
  item.frameWidth && (sender.frameWidth = item.frameWidth);
18051
18201
  item.frameHeight && (sender.frameHeight = item.frameHeight);
18052
18202
  item.frameRate && (sender.frameRate = item.frameRate);
18053
- (item.bitrate || item.bitrate === 0) && (sender.bitrate = item.bitrate);
18054
- item.jitter && (sender.jitter = item.jitter);
18055
- return sender;
18056
- });
18057
- const newReceivers = receivers.map((item) => {
18058
- const receiver = {};
18059
- item.trackId && (receiver.trackId = item.trackId);
18060
- item.kind && (receiver.kind = item.kind);
18061
- (item.packetsLostRate || item.packetsLostRate === 0) && (receiver.packetsLostRate = item.packetsLostRate);
18062
- receiver.remoteResource = item.remoteResource;
18203
+ if (item.trackId) {
18204
+ pickSender.push(Object.assign({}, sender));
18205
+ }
18206
+ });
18207
+ const newReceivers = [];
18208
+ receivers.forEach((item) => {
18209
+ const { trackId, kind, packetsLostRate, remoteResource, bitrate, jitter, } = item;
18210
+ const receiver = {
18211
+ trackId, kind, packetsLostRate, remoteResource, bitrate, jitter,
18212
+ };
18063
18213
  (item.audioLevel || item.audioLevel === 0) && (receiver.audioLevel = item.audioLevel);
18064
18214
  item.frameWidth && (receiver.frameWidth = item.frameWidth);
18065
18215
  item.frameHeight && (receiver.frameHeight = item.frameHeight);
18066
18216
  item.frameRate && (receiver.frameRate = item.frameRate);
18067
- (item.bitrate || item.bitrate === 0) && (receiver.bitrate = item.bitrate);
18068
- item.jitter && (receiver.jitter = item.jitter);
18069
- return receiver;
18217
+ if (item.trackId) {
18218
+ newReceivers.push(Object.assign({}, receiver));
18219
+ }
18070
18220
  });
18071
18221
  return {
18072
18222
  timestamp,
18073
18223
  iceCandidatePair,
18074
- senders: newSenders.filter((item) => item.trackId),
18075
- receivers: newReceivers.filter((item) => item.trackId),
18224
+ senders: pickSender,
18225
+ receivers: newReceivers,
18076
18226
  pcName: this._pcName,
18077
18227
  };
18078
18228
  }
@@ -18153,35 +18303,48 @@
18153
18303
  * 获取缓存的本地质量数据
18154
18304
  */
18155
18305
  _getCacheStatsData() {
18156
- return this._reportStatsData;
18306
+ return __awaiter(this, void 0, void 0, function* () {
18307
+ return this._getStatsData();
18308
+ });
18157
18309
  }
18158
18310
  /**
18159
18311
  * 北极星上报 R3、R4 数据
18160
18312
  */
18161
18313
  _sendR3R4Data() {
18162
- var _a;
18314
+ var _a, _b;
18163
18315
  return __awaiter(this, void 0, void 0, function* () {
18164
- const formatData = this._getCacheStatsData();
18316
+ const formatData = yield this._getCacheStatsData();
18165
18317
  if (!formatData) {
18166
18318
  return true;
18167
18319
  }
18320
+ /**
18321
+ * 优化 300 人大会议室 https://rc-jira.rongcloud.net/browse/BEEM-289
18322
+ * Mac 端卡顿严重, RTCLib 房间超出 32 路流时,不再做北极星质量数据上报,仅取音量数据,以保持 Beem 声音激励功能可用
18323
+ */
18324
+ 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) {
18325
+ return true;
18326
+ }
18168
18327
  if (formatData.senders.length || formatData.receivers.length) {
18169
18328
  /**
18170
18329
  * 组装北极星上报 R3、R4 数据并发送
18171
18330
  */
18172
- const res = yield ((_a = this._polarisReport) === null || _a === void 0 ? void 0 : _a.sendR3R4Data(formatData));
18331
+ const res = yield ((_b = this._polarisReport) === null || _b === void 0 ? void 0 : _b.sendR3R4Data(formatData));
18173
18332
  if (formatData.senders.length > 0) {
18174
18333
  formatData.senders.forEach((item) => {
18175
- const { encoderImplementation, frameRate, frameWidth, frameHeight, } = item;
18176
- let flag = 0;
18177
- if ((encoderImplementation === null || encoderImplementation === void 0 ? void 0 : encoderImplementation.toLowerCase()) === 'unknown' || !frameRate || !frameWidth || !frameHeight) {
18178
- flag = 1;
18334
+ if (item.kind === 'video') {
18335
+ const { encoderImplementation, frameRate, frameWidth, frameHeight, } = item;
18336
+ let flag = 0;
18337
+ if ((encoderImplementation === null || encoderImplementation === void 0 ? void 0 : encoderImplementation.toLowerCase()) === 'unknown' || !frameRate || !frameWidth || !frameHeight) {
18338
+ flag = 1;
18339
+ }
18340
+ // 当前 trackId 的视频出现问题
18341
+ this.setTroubleTrack(item.trackId, flag);
18179
18342
  }
18180
- this.setTroubleTrack(item.trackId, flag);
18181
18343
  });
18182
18344
  }
18183
18345
  return res;
18184
18346
  }
18347
+ return true;
18185
18348
  });
18186
18349
  }
18187
18350
  /**
@@ -18190,10 +18353,11 @@
18190
18353
  __reportR3R4ToPolaris() {
18191
18354
  return __awaiter(this, void 0, void 0, function* () {
18192
18355
  clearTimeout(this._reportR3R4ToPolarisTimer);
18193
- yield this._sendR3R4Data();
18194
- this._reportR3R4ToPolarisTimer = setTimeout(() => {
18195
- this.__reportR3R4ToPolaris();
18196
- }, 2000);
18356
+ this._reportR3R4ToPolarisTimer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
18357
+ this._sendR3R4Data().then(() => {
18358
+ this.__reportR3R4ToPolaris();
18359
+ });
18360
+ }), 2000);
18197
18361
  });
18198
18362
  }
18199
18363
  getRTCPeerConn() {
@@ -18505,7 +18669,7 @@
18505
18669
  * 加入房间
18506
18670
  */
18507
18671
  sendR1() {
18508
- const rtcVersion = "5.5.5-beem.2";
18672
+ const rtcVersion = "5.5.5-beem.4";
18509
18673
  const imVersion = this._context.getCoreVersion();
18510
18674
  const platform = 'web';
18511
18675
  const pcName = navigator.platform;
@@ -18655,7 +18819,7 @@
18655
18819
  _formatR1Data() {
18656
18820
  return {
18657
18821
  joinTime: this._context.userJoinTime || 0,
18658
- rtcVersion: "5.5.5-beem.2",
18822
+ rtcVersion: "5.5.5-beem.4",
18659
18823
  imVersion: this._context.getCoreVersion(),
18660
18824
  platform: 'web',
18661
18825
  device: navigator.platform,
@@ -18916,12 +19080,17 @@
18916
19080
  /**
18917
19081
  * 北极星上报模块
18918
19082
  */
18919
- _polarisReport) {
19083
+ _polarisReport,
19084
+ /**
19085
+ * context
19086
+ */
19087
+ _initOptions) {
18920
19088
  this._useMutilPeerC = _useMutilPeerC;
18921
19089
  this._roomId = _roomId;
18922
19090
  this._reTryExchange = _reTryExchange;
18923
19091
  this._currentUserId = _currentUserId;
18924
19092
  this._polarisReport = _polarisReport;
19093
+ this._initOptions = _initOptions;
18925
19094
  // private _reportListener: {[key: string]: IRCRTCReportListener | null} = {}
18926
19095
  /**
18927
19096
  * 存储创建的所有 peerC,key 为 pcName,/exchange 请求中 request header 中的 Peer-Connection-Id 值
@@ -18988,7 +19157,7 @@
18988
19157
  * 创建一个新 peerC
18989
19158
  */
18990
19159
  const isPub = this._isPub(tracks);
18991
- const newPeerC = new RCRTCPeerConnection(pcName, () => this._reTryExchange(pcName, isPub), this._currentUserId, this._polarisReport, this.onTrackTrouble);
19160
+ const newPeerC = new RCRTCPeerConnection(pcName, () => this._reTryExchange(pcName, isPub), this._currentUserId, this._polarisReport, this.onTrackTrouble, this._initOptions);
18992
19161
  this._mutilPeerC[pcName] = {
18993
19162
  pc: newPeerC,
18994
19163
  tracks,
@@ -19837,13 +20006,15 @@
19837
20006
  }
19838
20007
  /**
19839
20008
  * 自动模式下:
20009
+ * 无 pull_url 字段
19840
20010
  * /exchange 完需根据 broadcast 字端判断是否扩散 cdn_uris 数据,设置房间 cdn_uris 数据
19841
20011
  */
19842
20012
  const uris = JSON.parse(pullUrl);
19843
20013
  store.setCDNUris(uris);
19844
20014
  if ((uris === null || uris === void 0 ? void 0 : uris.broadcast) === RCInnerCDNBroadcast.SPREAD) {
19845
20015
  store.setCDNEnabel(true);
19846
- sendCDNInfoSignal(store);
20016
+ const CDNUris = Object.assign(Object.assign({}, uris), { enableInnerCDN: true });
20017
+ setRoomCDNInfo(store.context, store.roomId, CDNUris);
19847
20018
  }
19848
20019
  return res;
19849
20020
  });
@@ -20696,11 +20867,12 @@
20696
20867
  }
20697
20868
  }
20698
20869
 
20870
+ const PUBLISHSIGNALRETRYTIME = 30 * 1000;
20699
20871
  /**
20700
20872
  * 资源发布命令
20701
20873
  */
20702
20874
  class PublishCommand extends BaseCommand {
20703
- constructor(tracks, pubhook, signalRetryTime) {
20875
+ constructor(tracks, pubhook, signalRetryTime = PUBLISHSIGNALRETRYTIME) {
20704
20876
  var _a;
20705
20877
  super();
20706
20878
  this.tracks = tracks;
@@ -20891,10 +21063,12 @@
20891
21063
  });
20892
21064
  // 计算此次发布的增量资源数据
20893
21065
  const { publishedList: plus } = diffPublishResources(oldPublisheList, allPublishList);
21066
+ const CDNUris = Object.assign(Object.assign({}, store.getCDNUris()), { enableInnerCDN: store.getCDNEnable() });
21067
+ const CDNValueInfo = (CDNUris && CDNUris.broadcast === RCInnerCDNBroadcast.SPREAD) ? JSON.stringify([CDNUris]) : '';
20894
21068
  // 通知房间成员
20895
21069
  // 连通率相关埋点-统计扩散耗时
20896
21070
  recordPublishSignalTotalData();
20897
- let errorCode = yield store.context.setRTCTotalRes(roomId, buildPlusMessage(RCRTCMessageType.PUBLISH, plus), buildTotalURIMessageContent(allPublishList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE, buildTotalURIMessageContent(crtMcuPublishList));
21071
+ let errorCode = yield store.context.setRTCTotalRes(roomId, buildPlusMessage(RCRTCMessageType.PUBLISH, plus), buildTotalURIMessageContent(allPublishList), RCRTCMessageType.TOTAL_CONTENT_RESOURCE, buildTotalURIMessageContent(crtMcuPublishList), CDNValueInfo);
20898
21072
  // TIPS: 通知房间成员失败,对信息进行重试操作
20899
21073
  if (errorCode !== engine.ErrorCode.SUCCESS) {
20900
21074
  const RetrySignal = RetrySignaling.handler();
@@ -20998,7 +21172,7 @@
20998
21172
  });
20999
21173
  if (!tracks.length) {
21000
21174
  (_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({
21001
- status: RCLoggerStatus.SUCCESSED,
21175
+ status: RCLoggerStatus.FAILED,
21002
21176
  code: exports.RCRTCCode.PUBLISH_TRACKS_IS_INVALID,
21003
21177
  msg: 'params tracks is invalid',
21004
21178
  }), this._traceId);
@@ -21714,11 +21888,25 @@
21714
21888
  * 房间抽象基类
21715
21889
  */
21716
21890
  class RCAbstractRoom extends engine.EventEmitter {
21891
+ /**
21892
+ * RCRTCRoom 类的构造函数。
21893
+ * @param {RTCContext} _context - RTC上下文,
21894
+ * @param {IRuntime} _runtime - 运行时
21895
+ * @param {string} _roomId - 房间号
21896
+ * @param {RTCMode} _roomMode - RTC模式,
21897
+ * @param {RCMediaService} _service - RCMediaService
21898
+ * @param {IRCRTCInitOptions} _initOptions - IRCRTCInitOptions
21899
+ * @param {boolean} [isUpgrade] - 是否是升级,如果是升级则不会创建新的peerConnection
21900
+ * @param {boolean} [isMainRoom] - 无论是主房间,主房间都是用户创建的房间,子房间是用户创建的房间。
21901
+ * @param {boolean} [_useMutilPeerC] - 是否使用多个 peerConnections
21902
+ * @param {string} _clientSessionId - 客户端会话 ID,用于标识客户端。
21903
+ * @param {number} signalRetryTime - 发送信号的时间间隔。
21904
+ */
21717
21905
  constructor(_context, _runtime, _roomId, _roomMode, _service, _initOptions, isUpgrade, isMainRoom,
21718
21906
  /**
21719
21907
  * 是否使用多 peerConnection
21720
21908
  */
21721
- _useMutilPeerC, _clientSessionId = getUUID()) {
21909
+ _useMutilPeerC, _clientSessionId = getUUID(), signalRetryTime = PUBLISHSIGNALRETRYTIME) {
21722
21910
  super();
21723
21911
  this._context = _context;
21724
21912
  this._runtime = _runtime;
@@ -21727,6 +21915,7 @@
21727
21915
  this._initOptions = _initOptions;
21728
21916
  this._useMutilPeerC = _useMutilPeerC;
21729
21917
  this._clientSessionId = _clientSessionId;
21918
+ this.signalRetryTime = signalRetryTime;
21730
21919
  this._appListener = null;
21731
21920
  this._reportListener = null;
21732
21921
  /**
@@ -21734,7 +21923,7 @@
21734
21923
  */
21735
21924
  this._onRecvPKMsg = null;
21736
21925
  this._polarisReport = new PolarisHttpReporter(this._context, this._runtime, this._roomId, this);
21737
- this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._roomId, this._reTryExchange.bind(this), this._context.getCurrentId(), this._polarisReport);
21926
+ this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._roomId, this._reTryExchange.bind(this), this._context.getCurrentId(), this._polarisReport, this._initOptions);
21738
21927
  this._invoker = new Invoker(this._context, this._service, this._peerCManager, _roomId, this._context.getCurrentId(), _roomMode, this._polarisReport, isUpgrade, isMainRoom);
21739
21928
  this._store = this._invoker.store;
21740
21929
  // 注册监听 rtc_ntf 信令数据,收到通知时拉取房间数据
@@ -22392,7 +22581,7 @@
22392
22581
  */
22393
22582
  publish(tracks) {
22394
22583
  return __awaiter(this, void 0, void 0, function* () {
22395
- return this._invoker.push(new PublishCommand(tracks, this._pubhook.bind(this), this._initOptions.signalRetryTime || 30 * 1000));
22584
+ return this._invoker.push(new PublishCommand(tracks, this._pubhook.bind(this), this.signalRetryTime));
22396
22585
  });
22397
22586
  }
22398
22587
  /**
@@ -24490,6 +24679,19 @@
24490
24679
  * 直播房间
24491
24680
  */
24492
24681
  class RCLivingRoom extends RCAbstractRoom {
24682
+ /**
24683
+ * 一个构造函数。
24684
+ * @param {RTCContext} context - RTC上下文,
24685
+ * @param {IRuntime} runtime - 运行时
24686
+ * @param {string} roomId - 房间号
24687
+ * @param {RCMediaService} service - RCMediaService
24688
+ * @param {IRCRTCInitOptions} initOptions - IRCRTCInitOptions
24689
+ * @param {RCLivingType} _livingType - RCLivingType.LIVE_ROOM,
24690
+ * @param {boolean} [isUpgrade] - 是否升级房间,如果为真,则表示房间从会议室升级到直播间,会议室关闭。
24691
+ * @param {boolean} [isMainRoom] - 无论是主房间,主房间都是发起呼叫的房间,子房间是接收呼叫的房间。
24692
+ * @param {boolean} [useMutilPeerC] - 是否使用多个 peerConnections
24693
+ * @param {string} [_clientSessionId] - 当前用户的会话 ID。
24694
+ */
24493
24695
  constructor(context, runtime, roomId, service, initOptions, _livingType, isUpgrade, isMainRoom,
24494
24696
  /**
24495
24697
  * 是否使用多 peerConnection
@@ -24827,12 +25029,26 @@
24827
25029
  * 普通音视频房间
24828
25030
  */
24829
25031
  class RCRTCRoom extends RCAbstractRoom {
25032
+ /**
25033
+ * 类的构造函数。
25034
+ * @param {RTCContext} context - RTC上下文
25035
+ * @param {IRuntime} runtime - 运行时
25036
+ * @param {string} roomId - 房间号
25037
+ * @param {RCMediaService} service - RCMediaService
25038
+ * @param {IRCRTCInitOptions} initOptions - IRCRTCInitOptions
25039
+ * @param {boolean} [isUpgrade] - 是否升级房间,默认为false
25040
+ * @param {boolean} [isMainRoom] - 无论是主房间,主房间是用户进入的房间,子房间是用户进入主房间后进入的房间。
25041
+ * @param {boolean} [useMutilPeerC] - 是否使用多个 peerConnections
25042
+ * @param {string} [_clientSessionId] - 当前房间的clientSessionId,用于区分当前房间和其他房间。
25043
+ * @param {RTCMode} roomType - RTCMode = RTCMode.RTC,
25044
+ * @param {number} signalRetryTime - 重新连接信令服务器的时间间隔。
25045
+ */
24830
25046
  constructor(context, runtime, roomId, service, initOptions, isUpgrade, isMainRoom,
24831
25047
  /**
24832
25048
  * 是否使用多 peerConnection
24833
25049
  */
24834
- useMutilPeerC, _clientSessionId, roomType = RTCMode.RTC) {
24835
- super(context, runtime, roomId, roomType, service, initOptions, isUpgrade, isMainRoom, useMutilPeerC, _clientSessionId);
25050
+ useMutilPeerC, _clientSessionId, roomType = RTCMode.RTC, signalRetryTime = PUBLISHSIGNALRETRYTIME) {
25051
+ super(context, runtime, roomId, roomType, service, initOptions, isUpgrade, isMainRoom, useMutilPeerC, _clientSessionId, signalRetryTime);
24836
25052
  }
24837
25053
  }
24838
25054
 
@@ -24910,7 +25126,7 @@
24910
25126
  this._fromRetry = false;
24911
25127
  this._appListener = null;
24912
25128
  this._service = new RCMediaService(runtime, _context, _initOption.mediaServer);
24913
- this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._context.getCurrentId(), this._reTryExchange.bind(this), this._context.getCurrentId());
25129
+ this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._context.getCurrentId(), this._reTryExchange.bind(this), this._context.getCurrentId(), undefined, _initOption);
24914
25130
  }
24915
25131
  _getReqHeaders(livingType) {
24916
25132
  var _a, _b;
@@ -25256,7 +25472,7 @@
25256
25472
  // 北极星数据
25257
25473
  this._polarisReport = new PolarisHttpReporter(this._context, this._runtime, this._roomId, this, PolarisRole.Audience);
25258
25474
  this._polarisReport.sendR1();
25259
- this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._roomId, this._reTryExchange.bind(this), this._context.getCurrentId(), this._polarisReport);
25475
+ this._peerCManager = new RCRTCPeerCManager(this._useMutilPeerC, this._roomId, this._reTryExchange.bind(this), this._context.getCurrentId(), this._polarisReport, this._initOptions);
25260
25476
  // 注册监听 rtc_ntf 信令数据,解码后拉取指定房间数据
25261
25477
  this._context.registerRTCSignalListener((buffer) => __awaiter(this, void 0, void 0, function* () {
25262
25478
  var _a, _b;
@@ -26801,7 +27017,7 @@
26801
27017
  }));
26802
27018
  return { code: exports.RCRTCCode.INVALID_TAGS };
26803
27019
  }
26804
- if (!track || track.toString() !== '[object MediaStreamTrack]' || track.kind !== 'video') {
27020
+ if (!track || !(track instanceof MediaStreamTrack) || track.kind !== 'video') {
26805
27021
  (_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({
26806
27022
  status: RCLoggerStatus.FAILED,
26807
27023
  code: exports.RCRTCCode.CREATE_CUSTOM_TRACK_FAILED,
@@ -27091,11 +27307,7 @@
27091
27307
  }), traceId);
27092
27308
  return { code: exports.RCRTCCode.REPERT_JOIN_ROOM };
27093
27309
  }
27094
- // 修改初始化配置中的超时时间
27095
- if (signalRetryTime) {
27096
- this._options.signalRetryTime = signalRetryTime;
27097
- }
27098
- const room = this._crtRoom = new RCRTCRoom(this._context, this._runtime, roomId, this._service, this._options, false, false, useMutilPeerC, getUUID());
27310
+ const room = this._crtRoom = new RCRTCRoom(this._context, this._runtime, roomId, this._service, this._options, false, false, useMutilPeerC, getUUID(), signalRetryTime);
27099
27311
  const { code } = yield room.__innerInit(roomType, joinType, undefined, undefined, outerUserDatas, traceId);
27100
27312
  if (code !== exports.RCRTCCode.SUCCESS) {
27101
27313
  this._crtRoom = null;
@@ -27542,7 +27754,7 @@
27542
27754
  }
27543
27755
  reportSDKInfo() {
27544
27756
  this._context.reportSDKInfo({
27545
- 'plugin-rtc': "5.5.5-beem.2",
27757
+ 'plugin-rtc': "5.5.5-beem.4",
27546
27758
  });
27547
27759
  }
27548
27760
  }
@@ -28007,7 +28219,8 @@ message probuf {
28007
28219
  };
28008
28220
  const decodeRtcUserListOutput = (codec, buffer) => {
28009
28221
  const rtcInfos = codec.decode(RTCPB.RtcUserListOutput, buffer);
28010
- const { users: list, token, sessionId, roomInfo, entries, offlineKickTime, codeFormat, roomCreateTime, userJoinTime, version, } = rtcInfos;
28222
+ // 多端对齐 OfflineKickTime 默认为 60 S (单位为秒)
28223
+ const { users: list, token, sessionId, roomInfo, entries, offlineKickTime = 60, codeFormat, roomCreateTime, userJoinTime, version, } = rtcInfos;
28011
28224
  const users = {};
28012
28225
  engine.forEach(list, (item) => {
28013
28226
  const { userId, userData } = item;
@@ -28053,7 +28266,7 @@ message probuf {
28053
28266
  if ((reportType === RCReportType.R3 && r3Info)) {
28054
28267
  const { info } = r3Info;
28055
28268
  const { streams } = info;
28056
- let innerStreams = Array.isArray(streams) && streams.map((stream) => codec.encode(RTCPB.RtcPBStreamInfo, stream, true));
28269
+ let innerStreams = Array.isArray(streams) && streams.map((stream) => stream && codec.encode(RTCPB.RtcPBStreamInfo, stream, true));
28057
28270
  let innerInfo = codec.encode(RTCPB.RtcPBStatusInfo, Object.assign(Object.assign({}, info), { streams: innerStreams }), true);
28058
28271
  let innterR3Info = codec.encode(RTCPB.RtcPBR3Info, { info: innerInfo }, true);
28059
28272
  return codec.encode(RTCPB.RtcPBPolaris, Object.assign(Object.assign({}, commonData), { r3Info: innterR3Info }));
@@ -28061,7 +28274,7 @@ message probuf {
28061
28274
  if ((reportType === RCReportType.R4 && r4Info)) {
28062
28275
  const { info } = r4Info;
28063
28276
  const { streams } = info;
28064
- let innerStreams = Array.isArray(streams) && streams.map((stream) => codec.encode(RTCPB.RtcPBStreamInfo, stream, true));
28277
+ let innerStreams = Array.isArray(streams) && streams.map((stream) => stream && codec.encode(RTCPB.RtcPBStreamInfo, stream, true));
28065
28278
  let innerInfo = codec.encode(RTCPB.RtcPBStatusInfo, Object.assign(Object.assign({}, info), { streams: innerStreams }), true);
28066
28279
  let innerR4Info = codec.encode(RTCPB.RtcPBR4Info, { info: innerInfo }, true);
28067
28280
  return codec.encode(RTCPB.RtcPBPolaris, Object.assign(Object.assign({}, commonData), { r4Info: innerR4Info }));
@@ -28163,16 +28376,17 @@ message probuf {
28163
28376
  * @param valueInfo 全量资源数据
28164
28377
  * @param objectName 全量 URI 消息名
28165
28378
  */
28166
- setRTCTotalRes(roomId, message, valueInfo, objectName, mcuValInfo = '') {
28379
+ setRTCTotalRes(roomId, message, valueInfo, objectName, mcuValInfo, cdnValInfo) {
28167
28380
  return __awaiter(this, void 0, void 0, function* () {
28168
28381
  const params = {
28169
28382
  objectName,
28170
28383
  content: this.codec.encode(RTCPB.RtcValueInfo, { key: message.name, value: message.content }, true),
28171
28384
  valueInfo: [
28172
28385
  this.codec.encode(RTCPB.RtcValueInfo, { key: 'uris', value: valueInfo }, true),
28173
- this.codec.encode(RTCPB.RtcValueInfo, { key: 'mcu_uris', value: mcuValInfo }, true),
28174
28386
  ],
28175
28387
  };
28388
+ mcuValInfo && params.valueInfo.push(this.codec.encode(RTCPB.RtcValueInfo, { key: 'mcu_uris', value: mcuValInfo }, true));
28389
+ cdnValInfo && params.valueInfo.push(this.codec.encode(RTCPB.RtcValueInfo, { key: 'cdn_uris', value: cdnValInfo }, true));
28176
28390
  const sourceData = this.codec.encode(RTCPB.RtcUserSetDataInput, params);
28177
28391
  const { code } = yield this.context.rtcSignaling(roomId, RTC_API.userSetData, true, sourceData);
28178
28392
  return code;
@@ -28529,22 +28743,22 @@ message probuf {
28529
28743
  console.error('Please use the https protocol or use `http://localhost` to open the page!');
28530
28744
  return false;
28531
28745
  }
28532
- engine.VersionManage.add('plugin-rtc', "5.5.5-beem.2");
28533
- if (!engine.VersionManage.validEngine("^5.6.2-beem.2")) {
28534
- console.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"^5.6.2-beem.2"}'.`);
28746
+ engine.VersionManage.add('plugin-rtc', "5.5.5-beem.4");
28747
+ if (!engine.VersionManage.validEngine("^5.6.0")) {
28748
+ console.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"^5.6.0"}'.`);
28535
28749
  return false;
28536
28750
  }
28537
28751
  return true;
28538
28752
  },
28539
- setup(context, runtime, options = { signalRetryTime: 30 * 1000 }) {
28753
+ setup(context, runtime, options = {}) {
28540
28754
  var _a, _b, _c, _d, _e, _f, _g, _h;
28541
28755
  const originLogger = context.createLogger('RCRTC', LogSource.RTC);
28542
28756
  originLogger.setOutputLevel(options.logLevel || engine.LogL.DEBUG);
28543
28757
  RTCLogger.setLogger(originLogger);
28544
28758
  logger.setLogger(originLogger);
28545
28759
  originLogger.warn(RCLoggerTag.L_INDEX_INSTALL_RTC_PLUGIN_O, JSON.stringify({
28546
- 'RCRTC Version': "5.5.5-beem.2",
28547
- Commit: "fb1da8eadeb0d8d9871ed026c4ccb09a9f570b77",
28760
+ 'RCRTC Version': "5.5.5-beem.4",
28761
+ Commit: "1c464fa58c20897be94d3d50ee25c52729284323",
28548
28762
  'browserInfo.browser': browserInfo.browser,
28549
28763
  'browserInfo.supportsUnifiedPlan': browserInfo.supportsUnifiedPlan,
28550
28764
  'browserInfo.version': browserInfo.version,