@webex/web-client-media-engine 2.0.6 → 2.0.7

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
@@ -1126,6 +1126,7 @@ class LocalTrack extends EventEmitter$2 {
1126
1126
  constructor(stream) {
1127
1127
  super();
1128
1128
  this.isPublished = false;
1129
+ this.loadingEffects = new Map();
1129
1130
  this.effects = new Map();
1130
1131
  this.originalStream = stream;
1131
1132
  this.underlyingStream = stream;
@@ -1264,9 +1265,18 @@ class LocalTrack extends EventEmitter$2 {
1264
1265
  */
1265
1266
  addEffect(name, effect) {
1266
1267
  return __awaiter$1(this, void 0, void 0, function* () {
1268
+ // Load the effect
1269
+ this.loadingEffects.set(name, effect);
1267
1270
  yield effect.load(this.underlyingStream);
1271
+ // Check that the loaded effect is the latest one and dispose if not
1272
+ if (effect !== this.loadingEffects.get(name)) {
1273
+ yield effect.dispose();
1274
+ throw new Error(`Effect "${name}" not required after loading`);
1275
+ }
1276
+ // Use the loaded effect
1268
1277
  this.underlyingStream = effect.getUnderlyingStream();
1269
1278
  this.effects.set(name, effect);
1279
+ this.loadingEffects.delete(name);
1270
1280
  this.emit(LocalTrackEvents.UnderlyingTrackChange);
1271
1281
  });
1272
1282
  }
@@ -1296,6 +1306,9 @@ class LocalTrack extends EventEmitter$2 {
1296
1306
  */
1297
1307
  disposeEffects() {
1298
1308
  return __awaiter$1(this, void 0, void 0, function* () {
1309
+ // Clear effects that are loading to indicate that they are not needed
1310
+ this.loadingEffects.clear();
1311
+ // Dispose of any effects currently in use
1299
1312
  if (this.effects.size > 0) {
1300
1313
  yield Promise.all(Array.from(this.effects.values(), (effect) => effect.dispose()));
1301
1314
  this.effects.clear();
@@ -1477,7 +1490,7 @@ class ConnectionStateHandler extends EventEmitter$2 {
1477
1490
  else {
1478
1491
  mediaConnectionState = ConnectionState.Connecting;
1479
1492
  }
1480
- logger$3.log(`iceConnectionState=${iceState} connectionState=${connectionState} => ${this.mediaConnectionState}`);
1493
+ logger$3.log(`iceConnectionState=${iceState} connectionState=${connectionState} => ${mediaConnectionState}`);
1481
1494
  return mediaConnectionState;
1482
1495
  }
1483
1496
  /**