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

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
@@ -14153,6 +14153,7 @@ class MultistreamConnection extends EventEmitter$2 {
14153
14153
  this.overuseUpdateCallback = () => { };
14154
14154
  this.midPredictor = new MidPredictor();
14155
14155
  this.offerAnswerQueue = new AsyncQueue();
14156
+ this.currentCreateOfferId = 0;
14156
14157
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
14157
14158
  logger.info(`Creating multistream connection with options ${JSON.stringify(this.options)}`);
14158
14159
  this.initializePeerConnection();
@@ -14516,16 +14517,16 @@ class MultistreamConnection extends EventEmitter$2 {
14516
14517
  if (!this.pc.getLocalDescription()) {
14517
14518
  this.midPredictor.allocateMidForDatachannel();
14518
14519
  }
14520
+ if (this.setAnswerResolve) {
14521
+ logger.info('Canceling previous offer since setAnswer was never called for it');
14522
+ this.setAnswerResolve();
14523
+ this.setAnswerResolve = undefined;
14524
+ }
14525
+ const createOfferId = ++this.currentCreateOfferId;
14519
14526
  return new Promise((createOfferResolve, createOfferReject) => {
14520
14527
  this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
14521
14528
  var _a;
14522
14529
  try {
14523
- if (this.setAnswerResolve !== undefined) {
14524
- throw new Error(`Tried to start a new createOffer flow before the old one had finished`);
14525
- }
14526
- const setAnswerPromise = new Promise((resolve) => {
14527
- this.setAnswerResolve = resolve;
14528
- });
14529
14530
  const offer = yield this.pc.createOffer();
14530
14531
  if (!offer.sdp) {
14531
14532
  throw new Error('No SDP offer');
@@ -14534,11 +14535,17 @@ class MultistreamConnection extends EventEmitter$2 {
14534
14535
  yield this.pc.setLocalDescription(offer);
14535
14536
  const sdpToSend = this.prepareLocalOfferForRemoteServer((_a = this.pc.getLocalDescription()) === null || _a === void 0 ? void 0 : _a.sdp);
14536
14537
  createOfferResolve({ type: 'offer', sdp: sdpToSend });
14537
- yield setAnswerPromise;
14538
+ if (this.currentCreateOfferId > createOfferId) {
14539
+ logger.log('Canceling previous offer since createOffer was called while it was being created');
14540
+ }
14541
+ else {
14542
+ yield new Promise((setAnswerResolve) => {
14543
+ this.setAnswerResolve = setAnswerResolve;
14544
+ });
14545
+ }
14538
14546
  }
14539
14547
  catch (error) {
14540
14548
  createOfferReject(error);
14541
- this.setAnswerResolve = undefined;
14542
14549
  }
14543
14550
  }));
14544
14551
  });