@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/cjs/index.js CHANGED
@@ -7207,6 +7207,7 @@ exports.WcmeErrorType = void 0;
7207
7207
  WcmeErrorType["GET_PAYLOAD_TYPE_FAILED"] = "GET_PAYLOAD_TYPE_FAILED";
7208
7208
  WcmeErrorType["SET_NMG_FAILED"] = "SET_NMG_FAILED";
7209
7209
  WcmeErrorType["DATA_CHANNEL_SEND_FAILED"] = "DATA_CHANNEL_SEND_FAILED";
7210
+ WcmeErrorType["RENEW_PEER_CONNECTION_FAILED"] = "RENEW_PEER_CONNECTION_FAILED";
7210
7211
  })(exports.WcmeErrorType || (exports.WcmeErrorType = {}));
7211
7212
  class WcmeError {
7212
7213
  constructor(type, message = '') {
@@ -14828,7 +14829,7 @@ class SendSlot {
14828
14829
  }
14829
14830
  }
14830
14831
 
14831
- const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __awaiter$1(void 0, void 0, void 0, function* () {
14832
+ const organizeTransceiverStats = (sendTransceivers, recvTransceivers, peerConnectionStats) => __awaiter$1(void 0, void 0, void 0, function* () {
14832
14833
  const result = {
14833
14834
  audio: {
14834
14835
  senders: [],
@@ -14856,6 +14857,7 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __await
14856
14857
  currentDirection: 'sendonly',
14857
14858
  localTrackLabel: (_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.label,
14858
14859
  };
14860
+ item.report.set(peerConnectionStats.get('id'), peerConnectionStats);
14859
14861
  if (mediaType === exports.MediaType.AudioMain) {
14860
14862
  result.audio.senders.push(item);
14861
14863
  }
@@ -14878,6 +14880,7 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __await
14878
14880
  currentDirection: 'recvonly',
14879
14881
  localTrackLabel: (_b = t.receiveSlot.stream.getTracks()[0]) === null || _b === void 0 ? void 0 : _b.label,
14880
14882
  };
14883
+ item.report.set(peerConnectionStats.get('id'), peerConnectionStats);
14881
14884
  if (mediaType === exports.MediaType.AudioMain) {
14882
14885
  result.audio.receivers.push(item);
14883
14886
  }
@@ -14967,8 +14970,6 @@ class MultistreamConnection extends EventEmitter$2 {
14967
14970
  this.createSendTransceiver(exports.MediaType.AudioSlides, slidesSceneId);
14968
14971
  }
14969
14972
  initializePeerConnection() {
14970
- var _a;
14971
- (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
14972
14973
  this.pc = new PeerConnection({
14973
14974
  iceServers: this.options.iceServers,
14974
14975
  bundlePolicy: this.options.bundlePolicy,
@@ -15732,38 +15733,47 @@ SCTP Max Message Size: ${maxMessageSize}`);
15732
15733
  }
15733
15734
  }
15734
15735
  renewPeerConnection(userOptions) {
15735
- if (userOptions) {
15736
- this.options = Object.assign(Object.assign({}, this.options), userOptions);
15737
- }
15738
- logger.info(`Renewing multistream connection with options ${JSON.stringify(this.options)}`);
15739
- this.midPredictor.reset();
15740
- this.initializePeerConnection();
15741
- const mainSceneId = generateSceneId();
15742
- const slidesSceneId = generateSceneId();
15743
- this.sendTransceivers.forEach((transceiver, mediaType) => {
15744
- var _a;
15745
- const mediaContent = getMediaContent(mediaType);
15746
- const sceneId = mediaContent === exports.MediaContent.Main ? mainSceneId : slidesSceneId;
15747
- const mid = this.midPredictor.getNextMid(mediaType);
15748
- transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
15749
- direction: 'sendrecv',
15750
- sendEncodings: getMediaFamily(mediaType) === exports.MediaFamily.Video
15751
- ? this.getVideoEncodingOptions(mediaContent)
15752
- : undefined,
15753
- }));
15754
- transceiver.mid = mid;
15755
- transceiver.csi = generateCsi(getMediaFamily(mediaType), sceneId);
15756
- transceiver.resetSdpMunger();
15757
- (_a = this.jmpSessions.get(mediaType)) === null || _a === void 0 ? void 0 : _a.close();
15758
- this.createJmpSession(mediaType);
15759
- });
15760
- this.recvTransceivers.forEach((transceivers, mediaType) => {
15761
- transceivers.forEach((t) => {
15736
+ var _a;
15737
+ return __awaiter$1(this, void 0, void 0, function* () {
15738
+ (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
15739
+ try {
15740
+ if (userOptions) {
15741
+ this.options = Object.assign(Object.assign({}, this.options), (yield userOptions));
15742
+ }
15743
+ }
15744
+ catch (error) {
15745
+ logErrorAndThrow(exports.WcmeErrorType.RENEW_PEER_CONNECTION_FAILED, `Error while awaiting user options: ${error}`);
15746
+ }
15747
+ logger.info(`Renewing multistream connection with options ${JSON.stringify(this.options)}`);
15748
+ this.midPredictor.reset();
15749
+ this.initializePeerConnection();
15750
+ const mainSceneId = generateSceneId();
15751
+ const slidesSceneId = generateSceneId();
15752
+ this.sendTransceivers.forEach((transceiver, mediaType) => {
15753
+ var _a;
15754
+ const mediaContent = getMediaContent(mediaType);
15755
+ const sceneId = mediaContent === exports.MediaContent.Main ? mainSceneId : slidesSceneId;
15762
15756
  const mid = this.midPredictor.getNextMid(mediaType);
15763
- t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
15764
- direction: 'recvonly',
15757
+ transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
15758
+ direction: 'sendrecv',
15759
+ sendEncodings: getMediaFamily(mediaType) === exports.MediaFamily.Video
15760
+ ? this.getVideoEncodingOptions(mediaContent)
15761
+ : undefined,
15765
15762
  }));
15766
- t.mid = mid;
15763
+ transceiver.mid = mid;
15764
+ transceiver.csi = generateCsi(getMediaFamily(mediaType), sceneId);
15765
+ transceiver.resetSdpMunger();
15766
+ (_a = this.jmpSessions.get(mediaType)) === null || _a === void 0 ? void 0 : _a.close();
15767
+ this.createJmpSession(mediaType);
15768
+ });
15769
+ this.recvTransceivers.forEach((transceivers, mediaType) => {
15770
+ transceivers.forEach((t) => {
15771
+ const mid = this.midPredictor.getNextMid(mediaType);
15772
+ t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
15773
+ direction: 'recvonly',
15774
+ }));
15775
+ t.mid = mid;
15776
+ });
15767
15777
  });
15768
15778
  });
15769
15779
  }
@@ -15782,7 +15792,9 @@ SCTP Max Message Size: ${maxMessageSize}`);
15782
15792
  }
15783
15793
  getTransceiverStats() {
15784
15794
  return __awaiter$1(this, void 0, void 0, function* () {
15785
- return organizeTransceiverStats(this.sendTransceivers, this.recvTransceivers);
15795
+ const stats = yield this.getStats();
15796
+ const peerConnectionStats = [...stats.values()].find((stat) => stat.type === 'peer-connection');
15797
+ return organizeTransceiverStats(this.sendTransceivers, this.recvTransceivers, peerConnectionStats);
15786
15798
  });
15787
15799
  }
15788
15800
  preProcessStats(stats) {