@webex/web-client-media-engine 3.7.2 → 3.8.0

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
@@ -14149,6 +14149,7 @@ class MultistreamConnection extends EventEmitter$2 {
14149
14149
  this.overuseUpdateCallback = () => { };
14150
14150
  this.midPredictor = new MidPredictor();
14151
14151
  this.offerAnswerQueue = new AsyncQueue();
14152
+ this.currentCreateOfferId = 0;
14152
14153
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
14153
14154
  logger.info(`Creating multistream connection with options ${JSON.stringify(this.options)}`);
14154
14155
  this.initializePeerConnection();
@@ -14512,16 +14513,16 @@ class MultistreamConnection extends EventEmitter$2 {
14512
14513
  if (!this.pc.getLocalDescription()) {
14513
14514
  this.midPredictor.allocateMidForDatachannel();
14514
14515
  }
14516
+ if (this.setAnswerResolve) {
14517
+ logger.info('Canceling previous offer since setAnswer was never called for it');
14518
+ this.setAnswerResolve();
14519
+ this.setAnswerResolve = undefined;
14520
+ }
14521
+ const createOfferId = ++this.currentCreateOfferId;
14515
14522
  return new Promise((createOfferResolve, createOfferReject) => {
14516
14523
  this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
14517
14524
  var _a;
14518
14525
  try {
14519
- if (this.setAnswerResolve !== undefined) {
14520
- throw new Error(`Tried to start a new createOffer flow before the old one had finished`);
14521
- }
14522
- const setAnswerPromise = new Promise((resolve) => {
14523
- this.setAnswerResolve = resolve;
14524
- });
14525
14526
  const offer = yield this.pc.createOffer();
14526
14527
  if (!offer.sdp) {
14527
14528
  throw new Error('No SDP offer');
@@ -14530,11 +14531,17 @@ class MultistreamConnection extends EventEmitter$2 {
14530
14531
  yield this.pc.setLocalDescription(offer);
14531
14532
  const sdpToSend = this.prepareLocalOfferForRemoteServer((_a = this.pc.getLocalDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
14532
14533
  createOfferResolve({ type: 'offer', sdp: sdpToSend });
14533
- yield setAnswerPromise;
14534
+ if (this.currentCreateOfferId > createOfferId) {
14535
+ logger.log('Canceling previous offer since createOffer was called while it was being created');
14536
+ }
14537
+ else {
14538
+ yield new Promise((setAnswerResolve) => {
14539
+ this.setAnswerResolve = setAnswerResolve;
14540
+ });
14541
+ }
14534
14542
  }
14535
14543
  catch (error) {
14536
14544
  createOfferReject(error);
14537
- this.setAnswerResolve = undefined;
14538
14545
  }
14539
14546
  }));
14540
14547
  });
@@ -14770,13 +14777,18 @@ class MultistreamConnection extends EventEmitter$2 {
14770
14777
  const statsToModify = stats.get(senderStats.id);
14771
14778
  statsToModify.mid = transceiver.mid;
14772
14779
  statsToModify.csi = transceiver.csi;
14773
- statsToModify.mediaType = mediaType;
14780
+ statsToModify.calliopeMediaType = mediaType;
14774
14781
  const trackSettings = (_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.getSettings();
14775
14782
  if (trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate) {
14776
14783
  statsToModify.targetFrameRate = trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate;
14777
14784
  }
14778
14785
  stats.set(senderStats.id, statsToModify);
14779
14786
  }
14787
+ else if (senderStats.type === 'media-source') {
14788
+ const statsToModify = stats.get(senderStats.id);
14789
+ statsToModify.calliopeMediaType = mediaType;
14790
+ stats.set(senderStats.id, statsToModify);
14791
+ }
14780
14792
  });
14781
14793
  })));
14782
14794
  yield Promise.all([...this.recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter(this, void 0, void 0, function* () {
@@ -14787,7 +14799,7 @@ class MultistreamConnection extends EventEmitter$2 {
14787
14799
  const statsToModify = stats.get(receiverStats.id);
14788
14800
  statsToModify.mid = (_a = transceiver.receiveSlot.id) === null || _a === void 0 ? void 0 : _a.mid;
14789
14801
  statsToModify.csi = transceiver.receiveSlot.currentRxCsi;
14790
- statsToModify.mediaType = mediaType;
14802
+ statsToModify.calliopeMediaType = mediaType;
14791
14803
  Object.assign(statsToModify, transceiver.receiverId);
14792
14804
  stats.set(receiverStats.id, statsToModify);
14793
14805
  }