@stream-io/video-client 1.4.3 → 1.4.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [1.4.4](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.4.3...@stream-io/video-client-1.4.4) (2024-07-02)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * refactor background filters ([#1415](https://github.com/GetStream/stream-video-js/issues/1415)) ([deb6da2](https://github.com/GetStream/stream-video-js/commit/deb6da238f541c733451e84b198434671da8dceb))
11
+
5
12
  ### [1.4.3](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.4.2...@stream-io/video-client-1.4.3) (2024-06-25)
6
13
 
7
14
 
@@ -11164,6 +11164,7 @@ class InputMediaDeviceManager {
11164
11164
  this.isTrackStoppedDueToTrackEnd = false;
11165
11165
  this.filters = [];
11166
11166
  this.statusChangeConcurrencyTag = Symbol('statusChangeConcurrencyTag');
11167
+ this.filterRegistrationConcurrencyTag = Symbol('filterRegistrationConcurrencyTag');
11167
11168
  /**
11168
11169
  * Disposes the manager.
11169
11170
  *
@@ -11266,14 +11267,24 @@ class InputMediaDeviceManager {
11266
11267
  * a new stream with the applied filter.
11267
11268
  *
11268
11269
  * @param filter the filter to register.
11269
- * @returns a function that will unregister the filter.
11270
+ * @returns MediaStreamFilterRegistrationResult
11270
11271
  */
11271
- async registerFilter(filter) {
11272
- this.filters.push(filter);
11273
- await this.applySettingsToStream();
11274
- return async () => {
11275
- this.filters = this.filters.filter((f) => f !== filter);
11272
+ registerFilter(filter) {
11273
+ const entry = {
11274
+ start: filter,
11275
+ stop: undefined,
11276
+ };
11277
+ const registered = withoutConcurrency(this.filterRegistrationConcurrencyTag, async () => {
11278
+ this.filters.push(entry);
11276
11279
  await this.applySettingsToStream();
11280
+ });
11281
+ return {
11282
+ registered,
11283
+ unregister: () => withoutConcurrency(this.filterRegistrationConcurrencyTag, async () => {
11284
+ entry.stop?.();
11285
+ this.filters = this.filters.filter((f) => f !== entry);
11286
+ await this.applySettingsToStream();
11287
+ }),
11277
11288
  };
11278
11289
  }
11279
11290
  /**
@@ -11326,6 +11337,7 @@ class InputMediaDeviceManager {
11326
11337
  this.state.mediaStream.release();
11327
11338
  }
11328
11339
  this.state.setMediaStream(undefined, undefined);
11340
+ this.filters.forEach((entry) => entry.stop?.());
11329
11341
  }
11330
11342
  }
11331
11343
  muteTracks() {
@@ -11430,7 +11442,16 @@ class InputMediaDeviceManager {
11430
11442
  // e.g. camera or microphone stream
11431
11443
  rootStream = this.getStream(constraints);
11432
11444
  // we publish the last MediaStream of the chain
11433
- stream = await this.filters.reduce((parent, filter) => parent.then(filter).then(chainWith(parent)), rootStream);
11445
+ stream = await this.filters.reduce((parent, entry) => parent
11446
+ .then((inputStream) => {
11447
+ const { stop, output } = entry.start(inputStream);
11448
+ entry.stop = stop;
11449
+ return output;
11450
+ })
11451
+ .then(chainWith(parent), (error) => {
11452
+ this.logger('warn', 'Fitler failed to start and will be ignored', error);
11453
+ return parent;
11454
+ }), rootStream);
11434
11455
  }
11435
11456
  if (this.call.state.callingState === CallingState.JOINED) {
11436
11457
  await this.publishStream(stream);
@@ -12035,7 +12056,9 @@ class MicrophoneManager extends InputMediaDeviceManager {
12035
12056
  });
12036
12057
  }
12037
12058
  });
12038
- this.noiseCancellationRegistration = this.registerFilter(noiseCancellation.toFilter());
12059
+ const registrationResult = this.registerFilter(noiseCancellation.toFilter());
12060
+ this.noiseCancellationRegistration = registrationResult.registered;
12061
+ this.uregisterNoiseCancellation = registrationResult.unregister;
12039
12062
  await this.noiseCancellationRegistration;
12040
12063
  // handles an edge case where a noise cancellation is enabled after
12041
12064
  // the participant as joined the call -> we immediately enable NC
@@ -12061,8 +12084,7 @@ class MicrophoneManager extends InputMediaDeviceManager {
12061
12084
  if (isReactNative()) {
12062
12085
  throw new Error('Noise cancellation is not supported in React Native');
12063
12086
  }
12064
- await this.noiseCancellationRegistration
12065
- ?.then((unregister) => unregister())
12087
+ await (this.uregisterNoiseCancellation?.() ?? Promise.resolve())
12066
12088
  .then(() => this.noiseCancellation?.disable())
12067
12089
  .then(() => this.noiseCancellationChangeUnsubscribe?.())
12068
12090
  .catch((err) => {
@@ -15484,7 +15506,7 @@ class StreamClient {
15484
15506
  });
15485
15507
  };
15486
15508
  this.getUserAgent = () => {
15487
- const version = "1.4.3" ;
15509
+ const version = "1.4.4" ;
15488
15510
  return (this.userAgent ||
15489
15511
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
15490
15512
  };