@stream-io/video-client 1.37.1 → 1.37.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "1.37.1",
3
+ "version": "1.37.3",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.es.js",
6
6
  "browser": "dist/index.browser.es.js",
@@ -41,7 +41,7 @@
41
41
  "@openapitools/openapi-generator-cli": "^2.25.0",
42
42
  "@rollup/plugin-replace": "^6.0.2",
43
43
  "@rollup/plugin-typescript": "^12.1.4",
44
- "@stream-io/audio-filters-web": "^0.6.0",
44
+ "@stream-io/audio-filters-web": "^0.6.1",
45
45
  "@stream-io/node-sdk": "^0.7.9",
46
46
  "@total-typescript/shoehorn": "^0.1.2",
47
47
  "@types/sdp-transform": "^2.15.0",
@@ -92,7 +92,9 @@ export class MicrophoneManager extends AudioDeviceManager<MicrophoneManagerState
92
92
  })
93
93
  .then((canAutoEnable) => {
94
94
  if (canAutoEnable) {
95
- this.noiseCancellation?.enable();
95
+ this.noiseCancellation?.enable().catch((err) => {
96
+ this.logger.warn('Failed to enable noise cancellation', err);
97
+ });
96
98
  }
97
99
  })
98
100
  .catch((err) => {
@@ -175,7 +177,9 @@ export class MicrophoneManager extends AudioDeviceManager<MicrophoneManagerState
175
177
  canAutoEnable = await noiseCancellation.canAutoEnable();
176
178
  }
177
179
  if (canAutoEnable) {
178
- noiseCancellation.enable();
180
+ noiseCancellation.enable().catch((err) => {
181
+ this.logger.warn('Failed to enable noise cancellation', err);
182
+ });
179
183
  }
180
184
  }
181
185
  } catch (e) {
@@ -268,9 +272,16 @@ export class MicrophoneManager extends AudioDeviceManager<MicrophoneManagerState
268
272
  const disableAudioProcessing =
269
273
  profile === AudioBitrateProfile.MUSIC_HIGH_QUALITY;
270
274
  if (disableAudioProcessing) {
271
- this.noiseCancellation.disable(); // disable for high quality music mode
275
+ this.noiseCancellation.disable().catch((err) => {
276
+ this.logger.warn(
277
+ 'Failed to disable noise cancellation for music mode',
278
+ err,
279
+ );
280
+ }); // disable for high quality music mode
272
281
  } else {
273
- this.noiseCancellation.enable(); // restore it for other modes if available
282
+ this.noiseCancellation.enable().catch((err) => {
283
+ this.logger.warn('Failed to enable noise cancellation', err);
284
+ }); // restore it for other modes if available
274
285
  }
275
286
  }
276
287
  }
@@ -7,8 +7,12 @@ export class NoiseCancellationStub implements INoiseCancellation {
7
7
  isSupported = () => true;
8
8
  init = () => Promise.resolve(undefined);
9
9
  isEnabled = async () => true;
10
- enable = () => this.listeners['change']?.forEach((l) => l(true));
11
- disable = () => this.listeners['change']?.forEach((l) => l(false));
10
+ enable = async () => {
11
+ this.listeners['change']?.forEach((l) => l(true));
12
+ };
13
+ disable = async () => {
14
+ this.listeners['change']?.forEach((l) => l(false));
15
+ };
12
16
  setSuppressionLevel = () => {};
13
17
  dispose = () => Promise.resolve(undefined);
14
18
  toFilter = () => (ms: MediaStream) => ({ output: ms });
@@ -74,6 +74,29 @@ type OrphanedTrack = {
74
74
  track: MediaStream;
75
75
  };
76
76
 
77
+ /**
78
+ * Creates a stable participant filter function, ready to be used in combination
79
+ * with the `useSyncExternalStore` hook.
80
+ *
81
+ * @param predicate the predicate to use.
82
+ */
83
+ const createStableParticipantsFilter = (
84
+ predicate: (p: StreamVideoParticipant) => boolean,
85
+ ) => {
86
+ const empty: StreamVideoParticipant[] = [];
87
+ return (participants: StreamVideoParticipant[]) => {
88
+ // no need to filter if there are no participants
89
+ if (!participants.length) return participants;
90
+
91
+ // return a stable empty array if there are no remote participants
92
+ // instead of creating an empty one
93
+ const filteredParticipants = participants.filter(predicate);
94
+ if (!filteredParticipants.length) return empty;
95
+
96
+ return filteredParticipants;
97
+ };
98
+ };
99
+
77
100
  /**
78
101
  * Holds the state of the current call.
79
102
  * @react You don't have to use this class directly, as we are exposing the state through Hooks.
@@ -353,12 +376,12 @@ export class CallState {
353
376
  );
354
377
 
355
378
  this.remoteParticipants$ = this.participants$.pipe(
356
- map((participants) => participants.filter((p) => !p.isLocalParticipant)),
379
+ map(createStableParticipantsFilter((p) => !p.isLocalParticipant)),
357
380
  shareReplay({ bufferSize: 1, refCount: true }),
358
381
  );
359
382
 
360
383
  this.pinnedParticipants$ = this.participants$.pipe(
361
- map((participants) => participants.filter((p) => !!p.pin)),
384
+ map(createStableParticipantsFilter((p) => !!p.pin)),
362
385
  shareReplay({ bufferSize: 1, refCount: true }),
363
386
  );
364
387