@webex/web-client-media-engine 3.31.0 → 3.31.2

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/esm/index.js CHANGED
@@ -7203,6 +7203,7 @@ var WcmeErrorType;
7203
7203
  WcmeErrorType["GET_PAYLOAD_TYPE_FAILED"] = "GET_PAYLOAD_TYPE_FAILED";
7204
7204
  WcmeErrorType["SET_NMG_FAILED"] = "SET_NMG_FAILED";
7205
7205
  WcmeErrorType["DATA_CHANNEL_SEND_FAILED"] = "DATA_CHANNEL_SEND_FAILED";
7206
+ WcmeErrorType["RENEW_PEER_CONNECTION_FAILED"] = "RENEW_PEER_CONNECTION_FAILED";
7206
7207
  })(WcmeErrorType || (WcmeErrorType = {}));
7207
7208
  class WcmeError {
7208
7209
  constructor(type, message = '') {
@@ -14824,7 +14825,7 @@ class SendSlot {
14824
14825
  }
14825
14826
  }
14826
14827
 
14827
- const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __awaiter$1(void 0, void 0, void 0, function* () {
14828
+ const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnectionStats) => __awaiter$1(void 0, void 0, void 0, function* () {
14828
14829
  const result = {
14829
14830
  audio: {
14830
14831
  senders: [],
@@ -14852,6 +14853,7 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __await
14852
14853
  currentDirection: 'sendonly',
14853
14854
  localTrackLabel: (_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.label,
14854
14855
  };
14856
+ item.report.set(peerConnectionStats.get('id'), peerConnectionStats);
14855
14857
  if (mediaType === MediaType.AudioMain) {
14856
14858
  result.audio.senders.push(item);
14857
14859
  }
@@ -14874,6 +14876,7 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __await
14874
14876
  currentDirection: 'recvonly',
14875
14877
  localTrackLabel: (_b = t.receiveSlot.stream.getTracks()[0]) === null || _b === void 0 ? void 0 : _b.label,
14876
14878
  };
14879
+ item.report.set(peerConnectionStats.get('id'), peerConnectionStats);
14877
14880
  if (mediaType === MediaType.AudioMain) {
14878
14881
  result.audio.receivers.push(item);
14879
14882
  }
@@ -14963,8 +14966,6 @@ class MultistreamConnection extends EventEmitter$2 {
14963
14966
  this.createSendTransceiver(MediaType.AudioSlides, slidesSceneId);
14964
14967
  }
14965
14968
  initializePeerConnection() {
14966
- var _a;
14967
- (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
14968
14969
  this.pc = new PeerConnection({
14969
14970
  iceServers: this.options.iceServers,
14970
14971
  bundlePolicy: this.options.bundlePolicy,
@@ -15728,38 +15729,47 @@ SCTP Max Message Size: ${maxMessageSize}`);
15728
15729
  }
15729
15730
  }
15730
15731
  renewPeerConnection(userOptions) {
15731
- if (userOptions) {
15732
- this.options = Object.assign(Object.assign({}, this.options), userOptions);
15733
- }
15734
- logger.info(`Renewing multistream connection with options ${JSON.stringify(this.options)}`);
15735
- this.midPredictor.reset();
15736
- this.initializePeerConnection();
15737
- const mainSceneId = generateSceneId();
15738
- const slidesSceneId = generateSceneId();
15739
- this.sendTransceivers.forEach((transceiver, mediaType) => {
15740
- var _a;
15741
- const mediaContent = getMediaContent(mediaType);
15742
- const sceneId = mediaContent === MediaContent.Main ? mainSceneId : slidesSceneId;
15743
- const mid = this.midPredictor.getNextMid(mediaType);
15744
- transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
15745
- direction: 'sendrecv',
15746
- sendEncodings: getMediaFamily(mediaType) === MediaFamily.Video
15747
- ? this.getVideoEncodingOptions(mediaContent)
15748
- : undefined,
15749
- }));
15750
- transceiver.mid = mid;
15751
- transceiver.csi = generateCsi(getMediaFamily(mediaType), sceneId);
15752
- transceiver.resetSdpMunger();
15753
- (_a = this.jmpSessions.get(mediaType)) === null || _a === void 0 ? void 0 : _a.close();
15754
- this.createJmpSession(mediaType);
15755
- });
15756
- this.recvTransceivers.forEach((transceivers, mediaType) => {
15757
- transceivers.forEach((t) => {
15732
+ var _a;
15733
+ return __awaiter$1(this, void 0, void 0, function* () {
15734
+ (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
15735
+ try {
15736
+ if (userOptions) {
15737
+ this.options = Object.assign(Object.assign({}, this.options), (yield userOptions));
15738
+ }
15739
+ }
15740
+ catch (error) {
15741
+ logErrorAndThrow(WcmeErrorType.RENEW_PEER_CONNECTION_FAILED, `Error while awaiting user options: ${error}`);
15742
+ }
15743
+ logger.info(`Renewing multistream connection with options ${JSON.stringify(this.options)}`);
15744
+ this.midPredictor.reset();
15745
+ this.initializePeerConnection();
15746
+ const mainSceneId = generateSceneId();
15747
+ const slidesSceneId = generateSceneId();
15748
+ this.sendTransceivers.forEach((transceiver, mediaType) => {
15749
+ var _a;
15750
+ const mediaContent = getMediaContent(mediaType);
15751
+ const sceneId = mediaContent === MediaContent.Main ? mainSceneId : slidesSceneId;
15758
15752
  const mid = this.midPredictor.getNextMid(mediaType);
15759
- t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
15760
- direction: 'recvonly',
15753
+ transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
15754
+ direction: 'sendrecv',
15755
+ sendEncodings: getMediaFamily(mediaType) === MediaFamily.Video
15756
+ ? this.getVideoEncodingOptions(mediaContent)
15757
+ : undefined,
15761
15758
  }));
15762
- t.mid = mid;
15759
+ transceiver.mid = mid;
15760
+ transceiver.csi = generateCsi(getMediaFamily(mediaType), sceneId);
15761
+ transceiver.resetSdpMunger();
15762
+ (_a = this.jmpSessions.get(mediaType)) === null || _a === void 0 ? void 0 : _a.close();
15763
+ this.createJmpSession(mediaType);
15764
+ });
15765
+ this.recvTransceivers.forEach((transceivers, mediaType) => {
15766
+ transceivers.forEach((t) => {
15767
+ const mid = this.midPredictor.getNextMid(mediaType);
15768
+ t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
15769
+ direction: 'recvonly',
15770
+ }));
15771
+ t.mid = mid;
15772
+ });
15763
15773
  });
15764
15774
  });
15765
15775
  }
@@ -15778,7 +15788,9 @@ SCTP Max Message Size: ${maxMessageSize}`);
15778
15788
  }
15779
15789
  getTransceiverStats() {
15780
15790
  return __awaiter$1(this, void 0, void 0, function* () {
15781
- return organizeTransceiverStats(this.sendTransceivers, this.recvTransceivers);
15791
+ const stats = yield this.getStats();
15792
+ const peerConnectionStats = [...stats.values()].find((stat) => stat.type === 'peer-connection');
15793
+ return organizeTransceiverStats(this.sendTransceivers, this.recvTransceivers, peerConnectionStats);
15782
15794
  });
15783
15795
  }
15784
15796
  preProcessStats(stats) {