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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4-beem.2
3
- * CommitId - 51c7e1de9a288f3456394ed2bc6ee9e09c4afa8c
4
- * Mon May 16 2022 17:37:30 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.4-beem.5
3
+ * CommitId - 13f398c4a680ab6054d831b2e76e51f68a677de9
4
+ * Mon May 23 2022 11:07:54 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { EventEmitter, LogLevel, RTCMode, IRuntime, RTCPluginContext, IServerRTCRoomEntry, IJoinRTCRoomData, IReceivedMessage, KVString, RTCJoinType, IRTCJoinedInfo, IPluginGenerator } from '@rongcloud/engine';
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4-beem.2
3
- * CommitId - 51c7e1de9a288f3456394ed2bc6ee9e09c4afa8c
4
- * Mon May 16 2022 17:37:30 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.4-beem.5
3
+ * CommitId - 13f398c4a680ab6054d831b2e76e51f68a677de9
4
+ * Mon May 23 2022 11:07:54 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  import { Logger, EventEmitter, isNumber, ErrorCode, ConnectionStatus, assert, ConversationType, RTCApiType, validate, isArray, RTCMode, isHttpUrl, isBoolean, HttpMethod, isString, notEmptyString, RTCJoinType, RTCIdentityChangeType, VersionManage } from '@rongcloud/engine';
@@ -137,6 +137,7 @@ class AsyncTaskQueue {
137
137
  }
138
138
  this.locked = true;
139
139
  const { resolve, task, reject } = this.queue.shift();
140
+ logger.info(`async task queue waiting length -> ${this.queue.length}`);
140
141
  let result;
141
142
  try {
142
143
  result = yield task();
@@ -152,7 +153,8 @@ class AsyncTaskQueue {
152
153
  }
153
154
  push(task) {
154
155
  const promise = new Promise((resolve, reject) => {
155
- this.queue.push({ resolve, task, reject });
156
+ const length = this.queue.push({ resolve, task, reject });
157
+ logger.info(`async task queue length -> ${length}`);
156
158
  });
157
159
  this.checkToStart();
158
160
  return promise;
@@ -5619,6 +5621,7 @@ var RCMediaType;
5619
5621
  RCMediaType[RCMediaType["AUDIO_VIDEO"] = 2] = "AUDIO_VIDEO";
5620
5622
  })(RCMediaType || (RCMediaType = {}));
5621
5623
 
5624
+ // export const RongRTCVideoBitrate: { [key: RCResolution]: BitrateConf } = {
5622
5625
  const RongRTCVideoBitrate = {
5623
5626
  [RCResolution.W176_H132]: { width: 176, height: 132, maxBitrate: 150, minBitrate: 80 },
5624
5627
  [RCResolution.W176_H144]: { width: 176, height: 144, maxBitrate: 160, minBitrate: 80 },
@@ -5635,23 +5638,26 @@ const RongRTCVideoBitrate = {
5635
5638
  [RCResolution.W1920_H1080]: { width: 1920, height: 1080, maxBitrate: 4000, minBitrate: 400 }
5636
5639
  };
5637
5640
  /**
5638
- * 取最接近的视频分辨率配置
5641
+ * 向上取最接近的视频分辨率配置
5639
5642
  * @param {number} width
5640
5643
  * @param {number} height
5641
5644
  */
5642
5645
  const getNearestResolution = (width, height) => {
5643
- const area = width * height;
5644
- let d = Number.MAX_VALUE;
5645
- let conf = null;
5646
- for (const key in RongRTCVideoBitrate) {
5647
- const item = RongRTCVideoBitrate[key];
5648
- const d2 = Math.abs(item.width * item.height - area);
5649
- if (d2 < d) {
5650
- conf = item;
5651
- d = d2;
5652
- }
5646
+ // 优先精准匹配
5647
+ const conf = RongRTCVideoBitrate[`W${width}_H${height}`];
5648
+ if (conf) {
5649
+ return conf;
5653
5650
  }
5654
- return conf;
5651
+ // 不规则分辨率计算最接近的配置
5652
+ const area = width * height;
5653
+ const confs = Object.keys(RongRTCVideoBitrate)
5654
+ .map(key => RongRTCVideoBitrate[key])
5655
+ // 升序
5656
+ .sort((item, item2) => item.height * item.width - item2.width * item2.height)
5657
+ // 过滤分辨率小于 area 的配置,避免分配带宽不足
5658
+ .filter(item => item.height * item.width >= area);
5659
+ // 若 confs 长度为 0 说明分辨率远大于可支持的分辨率配置,取最大配置
5660
+ return confs[0] || RongRTCVideoBitrate.W1920_H1080;
5655
5661
  };
5656
5662
  const Multiplier = {
5657
5663
  10: 1,
@@ -6217,13 +6223,18 @@ const getValue = (value) => {
6217
6223
  * @param track
6218
6224
  */
6219
6225
  const getVideoTrackInfo = (track) => {
6226
+ const settings = track.getSettings();
6220
6227
  const constraints = track.getConstraints();
6221
6228
  // firefox 平台不存在 getCapabilities 方法
6222
6229
  // const capabilities = track.getCapabilities()
6223
6230
  // const width = getValue(constraints.width) || getValue(capabilities.width)
6224
6231
  // const height = getValue(constraints.height) || getValue(capabilities.height)
6225
6232
  // const frameRate = getValue(constraints.frameRate) || getValue(capabilities.frameRate)
6226
- return { width: getValue(constraints.width), height: getValue(constraints.height), frameRate: getValue(constraints.frameRate) };
6233
+ return {
6234
+ width: settings.width || getValue(constraints.width),
6235
+ height: settings.height || getValue(constraints.height),
6236
+ frameRate: settings.frameRate || getValue(constraints.frameRate)
6237
+ };
6227
6238
  };
6228
6239
  /**
6229
6240
  * 取视频流动态码率
@@ -6232,8 +6243,8 @@ const getVideoTrackInfo = (track) => {
6232
6243
  */
6233
6244
  const getDynamicBitrate = (track) => {
6234
6245
  const { width, height, frameRate } = getVideoTrackInfo(track);
6235
- // 计算动态码率以备给 answer 使用
6236
- const config = getNearestResolution(width, height);
6246
+ // 计算动态码率,若 videoTrack 的分辨率读取失败,则以 640 * 480 的默认分辨率计算码率
6247
+ const config = getNearestResolution(width || 640, height || 480);
6237
6248
  const multiple = getBitrateMultiple(frameRate);
6238
6249
  return { min: config.minBitrate * multiple, max: config.maxBitrate * multiple };
6239
6250
  };
@@ -7656,6 +7667,7 @@ class ASdpStrategy {
7656
7667
  return __awaiter(this, void 0, void 0, function* () {
7657
7668
  // 过滤行末的空格,服务可能产生空格数据
7658
7669
  sdp = sdp.replace(/\s+\r\n/g, '\r\n');
7670
+ logger.info(`set remote answer -> ${sdp}`);
7659
7671
  try {
7660
7672
  yield this._peer.setRemoteDescription({ type: 'answer', sdp });
7661
7673
  }
@@ -8064,14 +8076,12 @@ class RCRTCPeerConnection extends EventEmitter {
8064
8076
  createOffer(iceRestart) {
8065
8077
  return __awaiter(this, void 0, void 0, function* () {
8066
8078
  const offer = yield this._sdpStrategy.createOffer(iceRestart);
8067
- // logger.debug(`sdpDemantics -> ${offer.semantics}`)
8068
- logger.debug(`offer -> ${JSON.stringify(offer.sdp)}`);
8079
+ logger.info(`create offer -> ${JSON.stringify(offer.sdp)}`);
8069
8080
  return offer;
8070
8081
  });
8071
8082
  }
8072
8083
  setRemoteAnswer(answer) {
8073
8084
  return __awaiter(this, void 0, void 0, function* () {
8074
- logger.debug(`answer -> ${JSON.stringify(answer)}`);
8075
8085
  return this._sdpStrategy.setRemoteAnswer(answer);
8076
8086
  });
8077
8087
  }
@@ -8446,7 +8456,7 @@ class PolarisReporter {
8446
8456
  * 加入房间
8447
8457
  */
8448
8458
  sendR1() {
8449
- const rtcVersion = "5.2.4-beem.2";
8459
+ const rtcVersion = "5.2.4-beem.5";
8450
8460
  const imVersion = this._context.getCoreVersion();
8451
8461
  const platform = 'web';
8452
8462
  const pcName = navigator.platform;
@@ -8610,7 +8620,7 @@ class RCAbstractRoom {
8610
8620
  this._initRemoteTracks();
8611
8621
  const crtUserId = this._context.getCurrentId();
8612
8622
  const selfRes = this._roomResources[crtUserId] = this._roomResources[crtUserId] || [];
8613
- logger.debug(`room data -> ${JSON.stringify(this._roomResources)}`);
8623
+ logger.info(`room data -> ${JSON.stringify(this._roomResources)}`);
8614
8624
  /*
8615
8625
  * 加入房间后,若房间中已存在己方发布的资源,表示之前未能完成正常退出流程
8616
8626
  * 需先清除房间内的己方资源,通知房间内其他人己方已取消当前资源的发布
@@ -8688,6 +8698,7 @@ class RCAbstractRoom {
8688
8698
  }
8689
8699
  _callAppListener(eventType, ...attrs) {
8690
8700
  var _a;
8701
+ eventType !== 'onPing' && logger.info(`${eventType} callback ->`, ...attrs);
8691
8702
  const handle = (_a = this._appListener) === null || _a === void 0 ? void 0 : _a[eventType];
8692
8703
  if (!handle) {
8693
8704
  return;
@@ -8725,7 +8736,7 @@ class RCAbstractRoom {
8725
8736
  logger.error(`unpublish prev uris failed -> code: ${code}`);
8726
8737
  }
8727
8738
  else {
8728
- logger.debug('unpublish uris prev login succeed');
8739
+ logger.info('unpublish uris prev login succeed');
8729
8740
  }
8730
8741
  });
8731
8742
  }
@@ -8776,7 +8787,7 @@ class RCAbstractRoom {
8776
8787
  if (this._destroyed) {
8777
8788
  return;
8778
8789
  }
8779
- logger.warn(`onKickOff -> byServer: ${byServer}`);
8790
+ // logger.warn(`onKickOff -> byServer: ${byServer}`)
8780
8791
  this._ntfClearRoomItem();
8781
8792
  this._leaveHandle(!byServer);
8782
8793
  // 扩展字段,备注用户为什么被踢出房间
@@ -8872,7 +8883,7 @@ class RCAbstractRoom {
8872
8883
  // 重新订阅二次发布资源
8873
8884
  if (subedTracks.length) {
8874
8885
  const trackIds = subedTracks.map(item => item.getTrackId());
8875
- logger.debug(`resub tracks -> ${JSON.stringify(trackIds)}`);
8886
+ logger.info(`resub tracks -> ${JSON.stringify(trackIds)}`);
8876
8887
  const { code } = yield push(() => this.__subscribe(subedTracks, true));
8877
8888
  if (code !== RCRTCCode.SUCCESS) {
8878
8889
  logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
@@ -8941,7 +8952,7 @@ class RCAbstractRoom {
8941
8952
  const downgrade = [];
8942
8953
  users.forEach(item => {
8943
8954
  if (+item.state === 0) {
8944
- logger.debug(`user joined -> ${item.userId}`);
8955
+ logger.info(`user joined -> ${item.userId}`);
8945
8956
  // 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
8946
8957
  if (!this._roomResources[item.userId]) {
8947
8958
  item.switchRoleType ? upgrade.push(item.userId) : joined.push(item.userId);
@@ -8949,7 +8960,7 @@ class RCAbstractRoom {
8949
8960
  this._roomResources[item.userId] = this._roomResources[item.userId] || [];
8950
8961
  }
8951
8962
  else {
8952
- logger.debug(`user left -> ${item.userId}`);
8963
+ logger.info(`user left -> ${item.userId}`);
8953
8964
  item.switchRoleType ? downgrade.push(item.userId) : left.push(item.userId);
8954
8965
  }
8955
8966
  });
@@ -9244,7 +9255,7 @@ class RCAbstractRoom {
9244
9255
  _removePubFailedTracks(tracks) {
9245
9256
  tracks.forEach(item => {
9246
9257
  const track = item instanceof RCLocalTrack ? item : item.track;
9247
- logger.debug(`remove pub failed track from peerconnection -> trackId: ${track.getTrackId()}`);
9258
+ logger.info(`remove pub failed track from peerconnection -> trackId: ${track.getTrackId()}`);
9248
9259
  this._pc.removeLocalTrackById(track.getTrackId());
9249
9260
  });
9250
9261
  }
@@ -9277,7 +9288,7 @@ class RCAbstractRoom {
9277
9288
  logger.error(`publish failed, tracks limit exceeded -> roomId: ${this._roomId}`);
9278
9289
  return { code: RCRTCCode.PUBLISH_TRACK_LIMIT_EXCEEDED };
9279
9290
  }
9280
- logger.debug(`publish tracks -> roomId: ${this._roomId}, tracks: ${tracks.map(getTrackIdFromAttr)}`);
9291
+ logger.info(`publish tracks -> roomId: ${this._roomId}, tracks: ${tracks.map(getTrackIdFromAttr)}`);
9281
9292
  /*
9282
9293
  * 资源发布应先与 mediaserver 交换资源,建 PeerConnection 通道,后通知房间
9283
9294
  * 资源取消发布则应先通知取消发布,后与 mediaServer 协商取消资源发布
@@ -9358,7 +9369,7 @@ class RCAbstractRoom {
9358
9369
  const { track: localTrack } = item instanceof RCLocalTrack ? { track: item } : item;
9359
9370
  localTrack.__innerSetPublished(true);
9360
9371
  });
9361
- logger.debug(`publish success: ${publishTrackIds.join(',')}`);
9372
+ logger.info(`publish success -> ${publishTrackIds.join(',')}`);
9362
9373
  if (this._roomMode === RTCMode.LIVE) {
9363
9374
  return { code: RCRTCCode.SUCCESS, liveUrl: urls === null || urls === void 0 ? void 0 : urls.liveUrl };
9364
9375
  }
@@ -9504,7 +9515,7 @@ class RCAbstractRoom {
9504
9515
  logger.error('send unpublish notification failed:', singalCode);
9505
9516
  return { code: RCRTCCode.SIGNAL_ERROR };
9506
9517
  }
9507
- logger.debug(`unpublish success -> tracks: ${resourceIds.join(',')}`);
9518
+ logger.info(`unpublish success -> tracks: ${resourceIds.join(',')}`);
9508
9519
  const resCode = yield this._pc.setRemoteAnswer(answer.sdp);
9509
9520
  if (resCode !== RCRTCCode.SUCCESS) {
9510
9521
  return { code: resCode };
@@ -9729,7 +9740,7 @@ class RCAbstractRoom {
9729
9740
  logger.error(`change subscribe list failed: ${resultCode}`);
9730
9741
  return { code: resultCode };
9731
9742
  }
9732
- logger.debug(`subscribe success: ${subTrackIds.join(',')}`);
9743
+ logger.info(`subscribe success: ${subTrackIds.join(',')}`);
9733
9744
  const resCode = yield this._pc.setRemoteAnswer(answer.sdp);
9734
9745
  if (resCode !== RCRTCCode.SUCCESS) {
9735
9746
  return { code: resCode };
@@ -9791,10 +9802,10 @@ class RCAbstractRoom {
9791
9802
  }
9792
9803
  const { code, data } = yield this._context.joinRTCRoom(this._roomId, this._roomMode, livingType);
9793
9804
  if (code !== ErrorCode.SUCCESS) {
9794
- logger.error(`RTC __onReconnected getRTCRoomInfo failed: ${code}`);
9805
+ logger.warn(`RTC __onReconnected getRTCRoomInfo failed: ${code}`);
9795
9806
  return;
9796
9807
  }
9797
- logger.debug(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(data)}`);
9808
+ logger.info(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(data)}`);
9798
9809
  // 查找新加入人员
9799
9810
  const joinedUserIds = [];
9800
9811
  // 新发布资源
@@ -10703,7 +10714,7 @@ const getCommonHeader = () => ({
10703
10714
  'Content-Type': 'application/json;charset=UTF-8',
10704
10715
  'Cache-Control': 'no-cache',
10705
10716
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
10706
- ClientVersion: "5.2.4-beem.2",
10717
+ ClientVersion: "5.2.4-beem.5",
10707
10718
  'Client-Session-Id': getUUID(),
10708
10719
  'Request-Id': Date.now().toString()
10709
10720
  });
@@ -10778,7 +10789,7 @@ class RCMediaService {
10778
10789
  for (let i = 0; i < urls.length; i += 1) {
10779
10790
  const url = `${urls[i]}${path}`;
10780
10791
  const commonHeader = getCommonHeader();
10781
- logger.debug(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10792
+ logger.info(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10782
10793
  const { status, data } = yield this._runtime.httpReq({
10783
10794
  url,
10784
10795
  body: JSON.stringify(body),
@@ -10794,11 +10805,11 @@ class RCMediaService {
10794
10805
  if (resp.clusterId) {
10795
10806
  this._clusterId = resp.clusterId;
10796
10807
  }
10797
- logger.debug(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10808
+ logger.info(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10798
10809
  return { code: RCRTCCode.SUCCESS, data: resp };
10799
10810
  }
10800
10811
  else {
10801
- logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}, status: ${status}, url: ${url}`);
10812
+ logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}, status: ${status}`);
10802
10813
  // 失败的请求需记录,避免多配置时总是请求无效的地址
10803
10814
  this._failedMs.push(...this._msInNavi.splice(i, 1));
10804
10815
  }
@@ -10861,7 +10872,7 @@ class RCMediaService {
10861
10872
  // mcu 地址默认使用 https 协议
10862
10873
  const url = `${this._configUrl.replace(/^(https?:\/\/)?/, 'https://')}/server/mcu/config`;
10863
10874
  const commonHeader = getCommonHeader();
10864
- logger.debug(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10875
+ logger.info(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10865
10876
  const { status, data: jsonStr } = yield this._runtime.httpReq({
10866
10877
  url,
10867
10878
  headers: Object.assign(Object.assign({}, commonHeader), headers),
@@ -10869,10 +10880,11 @@ class RCMediaService {
10869
10880
  method: HttpMethod.POST
10870
10881
  });
10871
10882
  if (status === 200) {
10872
- logger.debug(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10883
+ logger.info(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10873
10884
  const data = JSON.parse(jsonStr);
10874
10885
  return { code: data.resultCode, res: data };
10875
10886
  }
10887
+ logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}`);
10876
10888
  return { code: RCRTCCode.REQUEST_FAILED };
10877
10889
  });
10878
10890
  }
@@ -12731,7 +12743,7 @@ const installer = {
12731
12743
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
12732
12744
  return false;
12733
12745
  }
12734
- VersionManage.add('plugin-rtc', "5.2.4-beem.2");
12746
+ VersionManage.add('plugin-rtc', "5.2.4-beem.5");
12735
12747
  if (!VersionManage.validEngine("4.6.0-beem.5")) {
12736
12748
  logger.error(`The current engine version '${VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.5"}'.`);
12737
12749
  return false;
@@ -12741,7 +12753,7 @@ const installer = {
12741
12753
  setup(context, runtime, options = {}) {
12742
12754
  logger.setLogLevel(options.logLevel);
12743
12755
  logger.setLogStdout(options.logStdout);
12744
- logger.warn(`RCRTC Version: ${"5.2.4-beem.2"}, Commit: ${"51c7e1de9a288f3456394ed2bc6ee9e09c4afa8c"}`);
12756
+ logger.warn(`RCRTC Version: ${"5.2.4-beem.5"}, Commit: ${"13f398c4a680ab6054d831b2e76e51f68a677de9"}`);
12745
12757
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
12746
12758
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
12747
12759
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4-beem.2
3
- * CommitId - 51c7e1de9a288f3456394ed2bc6ee9e09c4afa8c
4
- * Mon May 16 2022 17:37:30 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.4-beem.5
3
+ * CommitId - 13f398c4a680ab6054d831b2e76e51f68a677de9
4
+ * Mon May 23 2022 11:07:54 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  'use strict';
@@ -140,6 +140,7 @@ class AsyncTaskQueue {
140
140
  }
141
141
  this.locked = true;
142
142
  const { resolve, task, reject } = this.queue.shift();
143
+ logger.info(`async task queue waiting length -> ${this.queue.length}`);
143
144
  let result;
144
145
  try {
145
146
  result = yield task();
@@ -155,7 +156,8 @@ class AsyncTaskQueue {
155
156
  }
156
157
  push(task) {
157
158
  const promise = new Promise((resolve, reject) => {
158
- this.queue.push({ resolve, task, reject });
159
+ const length = this.queue.push({ resolve, task, reject });
160
+ logger.info(`async task queue length -> ${length}`);
159
161
  });
160
162
  this.checkToStart();
161
163
  return promise;
@@ -5622,6 +5624,7 @@ exports.RCMediaType = void 0;
5622
5624
  RCMediaType[RCMediaType["AUDIO_VIDEO"] = 2] = "AUDIO_VIDEO";
5623
5625
  })(exports.RCMediaType || (exports.RCMediaType = {}));
5624
5626
 
5627
+ // export const RongRTCVideoBitrate: { [key: RCResolution]: BitrateConf } = {
5625
5628
  const RongRTCVideoBitrate = {
5626
5629
  [exports.RCResolution.W176_H132]: { width: 176, height: 132, maxBitrate: 150, minBitrate: 80 },
5627
5630
  [exports.RCResolution.W176_H144]: { width: 176, height: 144, maxBitrate: 160, minBitrate: 80 },
@@ -5638,23 +5641,26 @@ const RongRTCVideoBitrate = {
5638
5641
  [exports.RCResolution.W1920_H1080]: { width: 1920, height: 1080, maxBitrate: 4000, minBitrate: 400 }
5639
5642
  };
5640
5643
  /**
5641
- * 取最接近的视频分辨率配置
5644
+ * 向上取最接近的视频分辨率配置
5642
5645
  * @param {number} width
5643
5646
  * @param {number} height
5644
5647
  */
5645
5648
  const getNearestResolution = (width, height) => {
5646
- const area = width * height;
5647
- let d = Number.MAX_VALUE;
5648
- let conf = null;
5649
- for (const key in RongRTCVideoBitrate) {
5650
- const item = RongRTCVideoBitrate[key];
5651
- const d2 = Math.abs(item.width * item.height - area);
5652
- if (d2 < d) {
5653
- conf = item;
5654
- d = d2;
5655
- }
5649
+ // 优先精准匹配
5650
+ const conf = RongRTCVideoBitrate[`W${width}_H${height}`];
5651
+ if (conf) {
5652
+ return conf;
5656
5653
  }
5657
- return conf;
5654
+ // 不规则分辨率计算最接近的配置
5655
+ const area = width * height;
5656
+ const confs = Object.keys(RongRTCVideoBitrate)
5657
+ .map(key => RongRTCVideoBitrate[key])
5658
+ // 升序
5659
+ .sort((item, item2) => item.height * item.width - item2.width * item2.height)
5660
+ // 过滤分辨率小于 area 的配置,避免分配带宽不足
5661
+ .filter(item => item.height * item.width >= area);
5662
+ // 若 confs 长度为 0 说明分辨率远大于可支持的分辨率配置,取最大配置
5663
+ return confs[0] || RongRTCVideoBitrate.W1920_H1080;
5658
5664
  };
5659
5665
  const Multiplier = {
5660
5666
  10: 1,
@@ -6220,13 +6226,18 @@ const getValue = (value) => {
6220
6226
  * @param track
6221
6227
  */
6222
6228
  const getVideoTrackInfo = (track) => {
6229
+ const settings = track.getSettings();
6223
6230
  const constraints = track.getConstraints();
6224
6231
  // firefox 平台不存在 getCapabilities 方法
6225
6232
  // const capabilities = track.getCapabilities()
6226
6233
  // const width = getValue(constraints.width) || getValue(capabilities.width)
6227
6234
  // const height = getValue(constraints.height) || getValue(capabilities.height)
6228
6235
  // const frameRate = getValue(constraints.frameRate) || getValue(capabilities.frameRate)
6229
- return { width: getValue(constraints.width), height: getValue(constraints.height), frameRate: getValue(constraints.frameRate) };
6236
+ return {
6237
+ width: settings.width || getValue(constraints.width),
6238
+ height: settings.height || getValue(constraints.height),
6239
+ frameRate: settings.frameRate || getValue(constraints.frameRate)
6240
+ };
6230
6241
  };
6231
6242
  /**
6232
6243
  * 取视频流动态码率
@@ -6235,8 +6246,8 @@ const getVideoTrackInfo = (track) => {
6235
6246
  */
6236
6247
  const getDynamicBitrate = (track) => {
6237
6248
  const { width, height, frameRate } = getVideoTrackInfo(track);
6238
- // 计算动态码率以备给 answer 使用
6239
- const config = getNearestResolution(width, height);
6249
+ // 计算动态码率,若 videoTrack 的分辨率读取失败,则以 640 * 480 的默认分辨率计算码率
6250
+ const config = getNearestResolution(width || 640, height || 480);
6240
6251
  const multiple = getBitrateMultiple(frameRate);
6241
6252
  return { min: config.minBitrate * multiple, max: config.maxBitrate * multiple };
6242
6253
  };
@@ -7659,6 +7670,7 @@ class ASdpStrategy {
7659
7670
  return __awaiter(this, void 0, void 0, function* () {
7660
7671
  // 过滤行末的空格,服务可能产生空格数据
7661
7672
  sdp = sdp.replace(/\s+\r\n/g, '\r\n');
7673
+ logger.info(`set remote answer -> ${sdp}`);
7662
7674
  try {
7663
7675
  yield this._peer.setRemoteDescription({ type: 'answer', sdp });
7664
7676
  }
@@ -8067,14 +8079,12 @@ class RCRTCPeerConnection extends engine.EventEmitter {
8067
8079
  createOffer(iceRestart) {
8068
8080
  return __awaiter(this, void 0, void 0, function* () {
8069
8081
  const offer = yield this._sdpStrategy.createOffer(iceRestart);
8070
- // logger.debug(`sdpDemantics -> ${offer.semantics}`)
8071
- logger.debug(`offer -> ${JSON.stringify(offer.sdp)}`);
8082
+ logger.info(`create offer -> ${JSON.stringify(offer.sdp)}`);
8072
8083
  return offer;
8073
8084
  });
8074
8085
  }
8075
8086
  setRemoteAnswer(answer) {
8076
8087
  return __awaiter(this, void 0, void 0, function* () {
8077
- logger.debug(`answer -> ${JSON.stringify(answer)}`);
8078
8088
  return this._sdpStrategy.setRemoteAnswer(answer);
8079
8089
  });
8080
8090
  }
@@ -8449,7 +8459,7 @@ class PolarisReporter {
8449
8459
  * 加入房间
8450
8460
  */
8451
8461
  sendR1() {
8452
- const rtcVersion = "5.2.4-beem.2";
8462
+ const rtcVersion = "5.2.4-beem.5";
8453
8463
  const imVersion = this._context.getCoreVersion();
8454
8464
  const platform = 'web';
8455
8465
  const pcName = navigator.platform;
@@ -8613,7 +8623,7 @@ class RCAbstractRoom {
8613
8623
  this._initRemoteTracks();
8614
8624
  const crtUserId = this._context.getCurrentId();
8615
8625
  const selfRes = this._roomResources[crtUserId] = this._roomResources[crtUserId] || [];
8616
- logger.debug(`room data -> ${JSON.stringify(this._roomResources)}`);
8626
+ logger.info(`room data -> ${JSON.stringify(this._roomResources)}`);
8617
8627
  /*
8618
8628
  * 加入房间后,若房间中已存在己方发布的资源,表示之前未能完成正常退出流程
8619
8629
  * 需先清除房间内的己方资源,通知房间内其他人己方已取消当前资源的发布
@@ -8691,6 +8701,7 @@ class RCAbstractRoom {
8691
8701
  }
8692
8702
  _callAppListener(eventType, ...attrs) {
8693
8703
  var _a;
8704
+ eventType !== 'onPing' && logger.info(`${eventType} callback ->`, ...attrs);
8694
8705
  const handle = (_a = this._appListener) === null || _a === void 0 ? void 0 : _a[eventType];
8695
8706
  if (!handle) {
8696
8707
  return;
@@ -8728,7 +8739,7 @@ class RCAbstractRoom {
8728
8739
  logger.error(`unpublish prev uris failed -> code: ${code}`);
8729
8740
  }
8730
8741
  else {
8731
- logger.debug('unpublish uris prev login succeed');
8742
+ logger.info('unpublish uris prev login succeed');
8732
8743
  }
8733
8744
  });
8734
8745
  }
@@ -8779,7 +8790,7 @@ class RCAbstractRoom {
8779
8790
  if (this._destroyed) {
8780
8791
  return;
8781
8792
  }
8782
- logger.warn(`onKickOff -> byServer: ${byServer}`);
8793
+ // logger.warn(`onKickOff -> byServer: ${byServer}`)
8783
8794
  this._ntfClearRoomItem();
8784
8795
  this._leaveHandle(!byServer);
8785
8796
  // 扩展字段,备注用户为什么被踢出房间
@@ -8875,7 +8886,7 @@ class RCAbstractRoom {
8875
8886
  // 重新订阅二次发布资源
8876
8887
  if (subedTracks.length) {
8877
8888
  const trackIds = subedTracks.map(item => item.getTrackId());
8878
- logger.debug(`resub tracks -> ${JSON.stringify(trackIds)}`);
8889
+ logger.info(`resub tracks -> ${JSON.stringify(trackIds)}`);
8879
8890
  const { code } = yield push(() => this.__subscribe(subedTracks, true));
8880
8891
  if (code !== exports.RCRTCCode.SUCCESS) {
8881
8892
  logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
@@ -8944,7 +8955,7 @@ class RCAbstractRoom {
8944
8955
  const downgrade = [];
8945
8956
  users.forEach(item => {
8946
8957
  if (+item.state === 0) {
8947
- logger.debug(`user joined -> ${item.userId}`);
8958
+ logger.info(`user joined -> ${item.userId}`);
8948
8959
  // 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
8949
8960
  if (!this._roomResources[item.userId]) {
8950
8961
  item.switchRoleType ? upgrade.push(item.userId) : joined.push(item.userId);
@@ -8952,7 +8963,7 @@ class RCAbstractRoom {
8952
8963
  this._roomResources[item.userId] = this._roomResources[item.userId] || [];
8953
8964
  }
8954
8965
  else {
8955
- logger.debug(`user left -> ${item.userId}`);
8966
+ logger.info(`user left -> ${item.userId}`);
8956
8967
  item.switchRoleType ? downgrade.push(item.userId) : left.push(item.userId);
8957
8968
  }
8958
8969
  });
@@ -9247,7 +9258,7 @@ class RCAbstractRoom {
9247
9258
  _removePubFailedTracks(tracks) {
9248
9259
  tracks.forEach(item => {
9249
9260
  const track = item instanceof RCLocalTrack ? item : item.track;
9250
- logger.debug(`remove pub failed track from peerconnection -> trackId: ${track.getTrackId()}`);
9261
+ logger.info(`remove pub failed track from peerconnection -> trackId: ${track.getTrackId()}`);
9251
9262
  this._pc.removeLocalTrackById(track.getTrackId());
9252
9263
  });
9253
9264
  }
@@ -9280,7 +9291,7 @@ class RCAbstractRoom {
9280
9291
  logger.error(`publish failed, tracks limit exceeded -> roomId: ${this._roomId}`);
9281
9292
  return { code: exports.RCRTCCode.PUBLISH_TRACK_LIMIT_EXCEEDED };
9282
9293
  }
9283
- logger.debug(`publish tracks -> roomId: ${this._roomId}, tracks: ${tracks.map(getTrackIdFromAttr)}`);
9294
+ logger.info(`publish tracks -> roomId: ${this._roomId}, tracks: ${tracks.map(getTrackIdFromAttr)}`);
9284
9295
  /*
9285
9296
  * 资源发布应先与 mediaserver 交换资源,建 PeerConnection 通道,后通知房间
9286
9297
  * 资源取消发布则应先通知取消发布,后与 mediaServer 协商取消资源发布
@@ -9361,7 +9372,7 @@ class RCAbstractRoom {
9361
9372
  const { track: localTrack } = item instanceof RCLocalTrack ? { track: item } : item;
9362
9373
  localTrack.__innerSetPublished(true);
9363
9374
  });
9364
- logger.debug(`publish success: ${publishTrackIds.join(',')}`);
9375
+ logger.info(`publish success -> ${publishTrackIds.join(',')}`);
9365
9376
  if (this._roomMode === engine.RTCMode.LIVE) {
9366
9377
  return { code: exports.RCRTCCode.SUCCESS, liveUrl: urls === null || urls === void 0 ? void 0 : urls.liveUrl };
9367
9378
  }
@@ -9507,7 +9518,7 @@ class RCAbstractRoom {
9507
9518
  logger.error('send unpublish notification failed:', singalCode);
9508
9519
  return { code: exports.RCRTCCode.SIGNAL_ERROR };
9509
9520
  }
9510
- logger.debug(`unpublish success -> tracks: ${resourceIds.join(',')}`);
9521
+ logger.info(`unpublish success -> tracks: ${resourceIds.join(',')}`);
9511
9522
  const resCode = yield this._pc.setRemoteAnswer(answer.sdp);
9512
9523
  if (resCode !== exports.RCRTCCode.SUCCESS) {
9513
9524
  return { code: resCode };
@@ -9732,7 +9743,7 @@ class RCAbstractRoom {
9732
9743
  logger.error(`change subscribe list failed: ${resultCode}`);
9733
9744
  return { code: resultCode };
9734
9745
  }
9735
- logger.debug(`subscribe success: ${subTrackIds.join(',')}`);
9746
+ logger.info(`subscribe success: ${subTrackIds.join(',')}`);
9736
9747
  const resCode = yield this._pc.setRemoteAnswer(answer.sdp);
9737
9748
  if (resCode !== exports.RCRTCCode.SUCCESS) {
9738
9749
  return { code: resCode };
@@ -9794,10 +9805,10 @@ class RCAbstractRoom {
9794
9805
  }
9795
9806
  const { code, data } = yield this._context.joinRTCRoom(this._roomId, this._roomMode, livingType);
9796
9807
  if (code !== engine.ErrorCode.SUCCESS) {
9797
- logger.error(`RTC __onReconnected getRTCRoomInfo failed: ${code}`);
9808
+ logger.warn(`RTC __onReconnected getRTCRoomInfo failed: ${code}`);
9798
9809
  return;
9799
9810
  }
9800
- logger.debug(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(data)}`);
9811
+ logger.info(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(data)}`);
9801
9812
  // 查找新加入人员
9802
9813
  const joinedUserIds = [];
9803
9814
  // 新发布资源
@@ -10706,7 +10717,7 @@ const getCommonHeader = () => ({
10706
10717
  'Content-Type': 'application/json;charset=UTF-8',
10707
10718
  'Cache-Control': 'no-cache',
10708
10719
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
10709
- ClientVersion: "5.2.4-beem.2",
10720
+ ClientVersion: "5.2.4-beem.5",
10710
10721
  'Client-Session-Id': getUUID(),
10711
10722
  'Request-Id': Date.now().toString()
10712
10723
  });
@@ -10781,7 +10792,7 @@ class RCMediaService {
10781
10792
  for (let i = 0; i < urls.length; i += 1) {
10782
10793
  const url = `${urls[i]}${path}`;
10783
10794
  const commonHeader = getCommonHeader();
10784
- logger.debug(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10795
+ logger.info(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10785
10796
  const { status, data } = yield this._runtime.httpReq({
10786
10797
  url,
10787
10798
  body: JSON.stringify(body),
@@ -10797,11 +10808,11 @@ class RCMediaService {
10797
10808
  if (resp.clusterId) {
10798
10809
  this._clusterId = resp.clusterId;
10799
10810
  }
10800
- logger.debug(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10811
+ logger.info(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10801
10812
  return { code: exports.RCRTCCode.SUCCESS, data: resp };
10802
10813
  }
10803
10814
  else {
10804
- logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}, status: ${status}, url: ${url}`);
10815
+ logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}, status: ${status}`);
10805
10816
  // 失败的请求需记录,避免多配置时总是请求无效的地址
10806
10817
  this._failedMs.push(...this._msInNavi.splice(i, 1));
10807
10818
  }
@@ -10864,7 +10875,7 @@ class RCMediaService {
10864
10875
  // mcu 地址默认使用 https 协议
10865
10876
  const url = `${this._configUrl.replace(/^(https?:\/\/)?/, 'https://')}/server/mcu/config`;
10866
10877
  const commonHeader = getCommonHeader();
10867
- logger.debug(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10878
+ logger.info(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10868
10879
  const { status, data: jsonStr } = yield this._runtime.httpReq({
10869
10880
  url,
10870
10881
  headers: Object.assign(Object.assign({}, commonHeader), headers),
@@ -10872,10 +10883,11 @@ class RCMediaService {
10872
10883
  method: engine.HttpMethod.POST
10873
10884
  });
10874
10885
  if (status === 200) {
10875
- logger.debug(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10886
+ logger.info(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10876
10887
  const data = JSON.parse(jsonStr);
10877
10888
  return { code: data.resultCode, res: data };
10878
10889
  }
10890
+ logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}`);
10879
10891
  return { code: exports.RCRTCCode.REQUEST_FAILED };
10880
10892
  });
10881
10893
  }
@@ -12734,7 +12746,7 @@ const installer = {
12734
12746
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
12735
12747
  return false;
12736
12748
  }
12737
- engine.VersionManage.add('plugin-rtc', "5.2.4-beem.2");
12749
+ engine.VersionManage.add('plugin-rtc', "5.2.4-beem.5");
12738
12750
  if (!engine.VersionManage.validEngine("4.6.0-beem.5")) {
12739
12751
  logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.5"}'.`);
12740
12752
  return false;
@@ -12744,7 +12756,7 @@ const installer = {
12744
12756
  setup(context, runtime, options = {}) {
12745
12757
  logger.setLogLevel(options.logLevel);
12746
12758
  logger.setLogStdout(options.logStdout);
12747
- logger.warn(`RCRTC Version: ${"5.2.4-beem.2"}, Commit: ${"51c7e1de9a288f3456394ed2bc6ee9e09c4afa8c"}`);
12759
+ logger.warn(`RCRTC Version: ${"5.2.4-beem.5"}, Commit: ${"13f398c4a680ab6054d831b2e76e51f68a677de9"}`);
12748
12760
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
12749
12761
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
12750
12762
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);
package/dist/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
- * RCRTC - v5.2.4-beem.2
3
- * CommitId - 51c7e1de9a288f3456394ed2bc6ee9e09c4afa8c
4
- * Mon May 16 2022 17:37:30 GMT+0800 (China Standard Time)
2
+ * RCRTC - v5.2.4-beem.5
3
+ * CommitId - 13f398c4a680ab6054d831b2e76e51f68a677de9
4
+ * Mon May 23 2022 11:07:54 GMT+0800 (China Standard Time)
5
5
  * ©2020 RongCloud, Inc. All rights reserved.
6
6
  */
7
7
  (function (global, factory) {
@@ -140,6 +140,7 @@
140
140
  }
141
141
  this.locked = true;
142
142
  const { resolve, task, reject } = this.queue.shift();
143
+ logger.info(`async task queue waiting length -> ${this.queue.length}`);
143
144
  let result;
144
145
  try {
145
146
  result = yield task();
@@ -155,7 +156,8 @@
155
156
  }
156
157
  push(task) {
157
158
  const promise = new Promise((resolve, reject) => {
158
- this.queue.push({ resolve, task, reject });
159
+ const length = this.queue.push({ resolve, task, reject });
160
+ logger.info(`async task queue length -> ${length}`);
159
161
  });
160
162
  this.checkToStart();
161
163
  return promise;
@@ -5622,6 +5624,7 @@
5622
5624
  RCMediaType[RCMediaType["AUDIO_VIDEO"] = 2] = "AUDIO_VIDEO";
5623
5625
  })(exports.RCMediaType || (exports.RCMediaType = {}));
5624
5626
 
5627
+ // export const RongRTCVideoBitrate: { [key: RCResolution]: BitrateConf } = {
5625
5628
  const RongRTCVideoBitrate = {
5626
5629
  [exports.RCResolution.W176_H132]: { width: 176, height: 132, maxBitrate: 150, minBitrate: 80 },
5627
5630
  [exports.RCResolution.W176_H144]: { width: 176, height: 144, maxBitrate: 160, minBitrate: 80 },
@@ -5638,23 +5641,26 @@
5638
5641
  [exports.RCResolution.W1920_H1080]: { width: 1920, height: 1080, maxBitrate: 4000, minBitrate: 400 }
5639
5642
  };
5640
5643
  /**
5641
- * 取最接近的视频分辨率配置
5644
+ * 向上取最接近的视频分辨率配置
5642
5645
  * @param {number} width
5643
5646
  * @param {number} height
5644
5647
  */
5645
5648
  const getNearestResolution = (width, height) => {
5646
- const area = width * height;
5647
- let d = Number.MAX_VALUE;
5648
- let conf = null;
5649
- for (const key in RongRTCVideoBitrate) {
5650
- const item = RongRTCVideoBitrate[key];
5651
- const d2 = Math.abs(item.width * item.height - area);
5652
- if (d2 < d) {
5653
- conf = item;
5654
- d = d2;
5655
- }
5649
+ // 优先精准匹配
5650
+ const conf = RongRTCVideoBitrate[`W${width}_H${height}`];
5651
+ if (conf) {
5652
+ return conf;
5656
5653
  }
5657
- return conf;
5654
+ // 不规则分辨率计算最接近的配置
5655
+ const area = width * height;
5656
+ const confs = Object.keys(RongRTCVideoBitrate)
5657
+ .map(key => RongRTCVideoBitrate[key])
5658
+ // 升序
5659
+ .sort((item, item2) => item.height * item.width - item2.width * item2.height)
5660
+ // 过滤分辨率小于 area 的配置,避免分配带宽不足
5661
+ .filter(item => item.height * item.width >= area);
5662
+ // 若 confs 长度为 0 说明分辨率远大于可支持的分辨率配置,取最大配置
5663
+ return confs[0] || RongRTCVideoBitrate.W1920_H1080;
5658
5664
  };
5659
5665
  const Multiplier = {
5660
5666
  10: 1,
@@ -6220,13 +6226,18 @@
6220
6226
  * @param track
6221
6227
  */
6222
6228
  const getVideoTrackInfo = (track) => {
6229
+ const settings = track.getSettings();
6223
6230
  const constraints = track.getConstraints();
6224
6231
  // firefox 平台不存在 getCapabilities 方法
6225
6232
  // const capabilities = track.getCapabilities()
6226
6233
  // const width = getValue(constraints.width) || getValue(capabilities.width)
6227
6234
  // const height = getValue(constraints.height) || getValue(capabilities.height)
6228
6235
  // const frameRate = getValue(constraints.frameRate) || getValue(capabilities.frameRate)
6229
- return { width: getValue(constraints.width), height: getValue(constraints.height), frameRate: getValue(constraints.frameRate) };
6236
+ return {
6237
+ width: settings.width || getValue(constraints.width),
6238
+ height: settings.height || getValue(constraints.height),
6239
+ frameRate: settings.frameRate || getValue(constraints.frameRate)
6240
+ };
6230
6241
  };
6231
6242
  /**
6232
6243
  * 取视频流动态码率
@@ -6235,8 +6246,8 @@
6235
6246
  */
6236
6247
  const getDynamicBitrate = (track) => {
6237
6248
  const { width, height, frameRate } = getVideoTrackInfo(track);
6238
- // 计算动态码率以备给 answer 使用
6239
- const config = getNearestResolution(width, height);
6249
+ // 计算动态码率,若 videoTrack 的分辨率读取失败,则以 640 * 480 的默认分辨率计算码率
6250
+ const config = getNearestResolution(width || 640, height || 480);
6240
6251
  const multiple = getBitrateMultiple(frameRate);
6241
6252
  return { min: config.minBitrate * multiple, max: config.maxBitrate * multiple };
6242
6253
  };
@@ -7659,6 +7670,7 @@
7659
7670
  return __awaiter(this, void 0, void 0, function* () {
7660
7671
  // 过滤行末的空格,服务可能产生空格数据
7661
7672
  sdp = sdp.replace(/\s+\r\n/g, '\r\n');
7673
+ logger.info(`set remote answer -> ${sdp}`);
7662
7674
  try {
7663
7675
  yield this._peer.setRemoteDescription({ type: 'answer', sdp });
7664
7676
  }
@@ -8067,14 +8079,12 @@
8067
8079
  createOffer(iceRestart) {
8068
8080
  return __awaiter(this, void 0, void 0, function* () {
8069
8081
  const offer = yield this._sdpStrategy.createOffer(iceRestart);
8070
- // logger.debug(`sdpDemantics -> ${offer.semantics}`)
8071
- logger.debug(`offer -> ${JSON.stringify(offer.sdp)}`);
8082
+ logger.info(`create offer -> ${JSON.stringify(offer.sdp)}`);
8072
8083
  return offer;
8073
8084
  });
8074
8085
  }
8075
8086
  setRemoteAnswer(answer) {
8076
8087
  return __awaiter(this, void 0, void 0, function* () {
8077
- logger.debug(`answer -> ${JSON.stringify(answer)}`);
8078
8088
  return this._sdpStrategy.setRemoteAnswer(answer);
8079
8089
  });
8080
8090
  }
@@ -8449,7 +8459,7 @@
8449
8459
  * 加入房间
8450
8460
  */
8451
8461
  sendR1() {
8452
- const rtcVersion = "5.2.4-beem.2";
8462
+ const rtcVersion = "5.2.4-beem.5";
8453
8463
  const imVersion = this._context.getCoreVersion();
8454
8464
  const platform = 'web';
8455
8465
  const pcName = navigator.platform;
@@ -8613,7 +8623,7 @@
8613
8623
  this._initRemoteTracks();
8614
8624
  const crtUserId = this._context.getCurrentId();
8615
8625
  const selfRes = this._roomResources[crtUserId] = this._roomResources[crtUserId] || [];
8616
- logger.debug(`room data -> ${JSON.stringify(this._roomResources)}`);
8626
+ logger.info(`room data -> ${JSON.stringify(this._roomResources)}`);
8617
8627
  /*
8618
8628
  * 加入房间后,若房间中已存在己方发布的资源,表示之前未能完成正常退出流程
8619
8629
  * 需先清除房间内的己方资源,通知房间内其他人己方已取消当前资源的发布
@@ -8691,6 +8701,7 @@
8691
8701
  }
8692
8702
  _callAppListener(eventType, ...attrs) {
8693
8703
  var _a;
8704
+ eventType !== 'onPing' && logger.info(`${eventType} callback ->`, ...attrs);
8694
8705
  const handle = (_a = this._appListener) === null || _a === void 0 ? void 0 : _a[eventType];
8695
8706
  if (!handle) {
8696
8707
  return;
@@ -8728,7 +8739,7 @@
8728
8739
  logger.error(`unpublish prev uris failed -> code: ${code}`);
8729
8740
  }
8730
8741
  else {
8731
- logger.debug('unpublish uris prev login succeed');
8742
+ logger.info('unpublish uris prev login succeed');
8732
8743
  }
8733
8744
  });
8734
8745
  }
@@ -8779,7 +8790,7 @@
8779
8790
  if (this._destroyed) {
8780
8791
  return;
8781
8792
  }
8782
- logger.warn(`onKickOff -> byServer: ${byServer}`);
8793
+ // logger.warn(`onKickOff -> byServer: ${byServer}`)
8783
8794
  this._ntfClearRoomItem();
8784
8795
  this._leaveHandle(!byServer);
8785
8796
  // 扩展字段,备注用户为什么被踢出房间
@@ -8875,7 +8886,7 @@
8875
8886
  // 重新订阅二次发布资源
8876
8887
  if (subedTracks.length) {
8877
8888
  const trackIds = subedTracks.map(item => item.getTrackId());
8878
- logger.debug(`resub tracks -> ${JSON.stringify(trackIds)}`);
8889
+ logger.info(`resub tracks -> ${JSON.stringify(trackIds)}`);
8879
8890
  const { code } = yield push(() => this.__subscribe(subedTracks, true));
8880
8891
  if (code !== exports.RCRTCCode.SUCCESS) {
8881
8892
  logger.error(`resub tracks failed -> code: ${code}, ids: ${JSON.stringify(trackIds)}`);
@@ -8944,7 +8955,7 @@
8944
8955
  const downgrade = [];
8945
8956
  users.forEach(item => {
8946
8957
  if (+item.state === 0) {
8947
- logger.debug(`user joined -> ${item.userId}`);
8958
+ logger.info(`user joined -> ${item.userId}`);
8948
8959
  // 对端 im 重连之后调加入房间信令获取最新数据,服务会给本端下发“对端加入房间”的消息,本端内存已包含对端人员,所以需过滤掉
8949
8960
  if (!this._roomResources[item.userId]) {
8950
8961
  item.switchRoleType ? upgrade.push(item.userId) : joined.push(item.userId);
@@ -8952,7 +8963,7 @@
8952
8963
  this._roomResources[item.userId] = this._roomResources[item.userId] || [];
8953
8964
  }
8954
8965
  else {
8955
- logger.debug(`user left -> ${item.userId}`);
8966
+ logger.info(`user left -> ${item.userId}`);
8956
8967
  item.switchRoleType ? downgrade.push(item.userId) : left.push(item.userId);
8957
8968
  }
8958
8969
  });
@@ -9247,7 +9258,7 @@
9247
9258
  _removePubFailedTracks(tracks) {
9248
9259
  tracks.forEach(item => {
9249
9260
  const track = item instanceof RCLocalTrack ? item : item.track;
9250
- logger.debug(`remove pub failed track from peerconnection -> trackId: ${track.getTrackId()}`);
9261
+ logger.info(`remove pub failed track from peerconnection -> trackId: ${track.getTrackId()}`);
9251
9262
  this._pc.removeLocalTrackById(track.getTrackId());
9252
9263
  });
9253
9264
  }
@@ -9280,7 +9291,7 @@
9280
9291
  logger.error(`publish failed, tracks limit exceeded -> roomId: ${this._roomId}`);
9281
9292
  return { code: exports.RCRTCCode.PUBLISH_TRACK_LIMIT_EXCEEDED };
9282
9293
  }
9283
- logger.debug(`publish tracks -> roomId: ${this._roomId}, tracks: ${tracks.map(getTrackIdFromAttr)}`);
9294
+ logger.info(`publish tracks -> roomId: ${this._roomId}, tracks: ${tracks.map(getTrackIdFromAttr)}`);
9284
9295
  /*
9285
9296
  * 资源发布应先与 mediaserver 交换资源,建 PeerConnection 通道,后通知房间
9286
9297
  * 资源取消发布则应先通知取消发布,后与 mediaServer 协商取消资源发布
@@ -9361,7 +9372,7 @@
9361
9372
  const { track: localTrack } = item instanceof RCLocalTrack ? { track: item } : item;
9362
9373
  localTrack.__innerSetPublished(true);
9363
9374
  });
9364
- logger.debug(`publish success: ${publishTrackIds.join(',')}`);
9375
+ logger.info(`publish success -> ${publishTrackIds.join(',')}`);
9365
9376
  if (this._roomMode === engine.RTCMode.LIVE) {
9366
9377
  return { code: exports.RCRTCCode.SUCCESS, liveUrl: urls === null || urls === void 0 ? void 0 : urls.liveUrl };
9367
9378
  }
@@ -9507,7 +9518,7 @@
9507
9518
  logger.error('send unpublish notification failed:', singalCode);
9508
9519
  return { code: exports.RCRTCCode.SIGNAL_ERROR };
9509
9520
  }
9510
- logger.debug(`unpublish success -> tracks: ${resourceIds.join(',')}`);
9521
+ logger.info(`unpublish success -> tracks: ${resourceIds.join(',')}`);
9511
9522
  const resCode = yield this._pc.setRemoteAnswer(answer.sdp);
9512
9523
  if (resCode !== exports.RCRTCCode.SUCCESS) {
9513
9524
  return { code: resCode };
@@ -9732,7 +9743,7 @@
9732
9743
  logger.error(`change subscribe list failed: ${resultCode}`);
9733
9744
  return { code: resultCode };
9734
9745
  }
9735
- logger.debug(`subscribe success: ${subTrackIds.join(',')}`);
9746
+ logger.info(`subscribe success: ${subTrackIds.join(',')}`);
9736
9747
  const resCode = yield this._pc.setRemoteAnswer(answer.sdp);
9737
9748
  if (resCode !== exports.RCRTCCode.SUCCESS) {
9738
9749
  return { code: resCode };
@@ -9794,10 +9805,10 @@
9794
9805
  }
9795
9806
  const { code, data } = yield this._context.joinRTCRoom(this._roomId, this._roomMode, livingType);
9796
9807
  if (code !== engine.ErrorCode.SUCCESS) {
9797
- logger.error(`RTC __onReconnected getRTCRoomInfo failed: ${code}`);
9808
+ logger.warn(`RTC __onReconnected getRTCRoomInfo failed: ${code}`);
9798
9809
  return;
9799
9810
  }
9800
- logger.debug(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(data)}`);
9811
+ logger.info(`RTC __onReconnected getRTCRoomInfo success: ${JSON.stringify(data)}`);
9801
9812
  // 查找新加入人员
9802
9813
  const joinedUserIds = [];
9803
9814
  // 新发布资源
@@ -10706,7 +10717,7 @@
10706
10717
  'Content-Type': 'application/json;charset=UTF-8',
10707
10718
  'Cache-Control': 'no-cache',
10708
10719
  ClientType: `web|${browserInfo.browser}|${browserInfo.version}`,
10709
- ClientVersion: "5.2.4-beem.2",
10720
+ ClientVersion: "5.2.4-beem.5",
10710
10721
  'Client-Session-Id': getUUID(),
10711
10722
  'Request-Id': Date.now().toString()
10712
10723
  });
@@ -10781,7 +10792,7 @@
10781
10792
  for (let i = 0; i < urls.length; i += 1) {
10782
10793
  const url = `${urls[i]}${path}`;
10783
10794
  const commonHeader = getCommonHeader();
10784
- logger.debug(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10795
+ logger.info(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10785
10796
  const { status, data } = yield this._runtime.httpReq({
10786
10797
  url,
10787
10798
  body: JSON.stringify(body),
@@ -10797,11 +10808,11 @@
10797
10808
  if (resp.clusterId) {
10798
10809
  this._clusterId = resp.clusterId;
10799
10810
  }
10800
- logger.debug(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10811
+ logger.info(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10801
10812
  return { code: exports.RCRTCCode.SUCCESS, data: resp };
10802
10813
  }
10803
10814
  else {
10804
- logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}, status: ${status}, url: ${url}`);
10815
+ logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}, status: ${status}`);
10805
10816
  // 失败的请求需记录,避免多配置时总是请求无效的地址
10806
10817
  this._failedMs.push(...this._msInNavi.splice(i, 1));
10807
10818
  }
@@ -10864,7 +10875,7 @@
10864
10875
  // mcu 地址默认使用 https 协议
10865
10876
  const url = `${this._configUrl.replace(/^(https?:\/\/)?/, 'https://')}/server/mcu/config`;
10866
10877
  const commonHeader = getCommonHeader();
10867
- logger.debug(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10878
+ logger.info(`request -> Request-Id: ${commonHeader['Request-Id']}, url: ${url}`);
10868
10879
  const { status, data: jsonStr } = yield this._runtime.httpReq({
10869
10880
  url,
10870
10881
  headers: Object.assign(Object.assign({}, commonHeader), headers),
@@ -10872,10 +10883,11 @@
10872
10883
  method: engine.HttpMethod.POST
10873
10884
  });
10874
10885
  if (status === 200) {
10875
- logger.debug(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10886
+ logger.info(`request success -> Request-Id: ${commonHeader['Request-Id']}`);
10876
10887
  const data = JSON.parse(jsonStr);
10877
10888
  return { code: data.resultCode, res: data };
10878
10889
  }
10890
+ logger.warn(`request failed -> Request-Id: ${commonHeader['Request-Id']}`);
10879
10891
  return { code: exports.RCRTCCode.REQUEST_FAILED };
10880
10892
  });
10881
10893
  }
@@ -12734,7 +12746,7 @@
12734
12746
  logger.error('Please use the https protocol or use `http://localhost` to open the page!');
12735
12747
  return false;
12736
12748
  }
12737
- engine.VersionManage.add('plugin-rtc', "5.2.4-beem.2");
12749
+ engine.VersionManage.add('plugin-rtc', "5.2.4-beem.5");
12738
12750
  if (!engine.VersionManage.validEngine("4.6.0-beem.5")) {
12739
12751
  logger.error(`The current engine version '${engine.VersionManage.getInfo().engine}' error, plugin-rtc required engine version at least '${"4.6.0-beem.5"}'.`);
12740
12752
  return false;
@@ -12744,7 +12756,7 @@
12744
12756
  setup(context, runtime, options = {}) {
12745
12757
  logger.setLogLevel(options.logLevel);
12746
12758
  logger.setLogStdout(options.logStdout);
12747
- logger.warn(`RCRTC Version: ${"5.2.4-beem.2"}, Commit: ${"51c7e1de9a288f3456394ed2bc6ee9e09c4afa8c"}`);
12759
+ logger.warn(`RCRTC Version: ${"5.2.4-beem.5"}, Commit: ${"13f398c4a680ab6054d831b2e76e51f68a677de9"}`);
12748
12760
  logger.warn(`browserInfo.browser -> ${browserInfo.browser}`);
12749
12761
  logger.warn(`browserInfo.supportsUnifiedPlan -> ${browserInfo.supportsUnifiedPlan}`);
12750
12762
  logger.warn(`browserInfo.version -> ${browserInfo.version}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rongcloud/plugin-rtc",
3
- "version": "5.2.4-beem.2",
3
+ "version": "5.2.4-beem.5",
4
4
  "description": "@rongcloud/plugin-rtc",
5
5
  "main": "./dist/index.js",
6
6
  "__attrs__": {
@@ -33,5 +33,5 @@
33
33
  "peerDependencies": {
34
34
  "@rongcloud/engine": "4.6.0-beem.5"
35
35
  },
36
- "__commit__": "51c7e1de9a288f3456394ed2bc6ee9e09c4afa8c"
36
+ "__commit__": "13f398c4a680ab6054d831b2e76e51f68a677de9"
37
37
  }