@stream-io/video-client 1.11.8 → 1.11.9

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.11.8",
3
+ "version": "1.11.9",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -215,6 +215,7 @@ export abstract class InputMediaDeviceManager<
215
215
  await this.applySettingsToStream();
216
216
  } catch (error) {
217
217
  this.state.setDevice(prevDeviceId);
218
+ await this.applySettingsToStream();
218
219
  throw error;
219
220
  }
220
221
  }
@@ -184,7 +184,7 @@ export const getAudioStream = async (
184
184
  const constraints: MediaStreamConstraints = {
185
185
  audio: {
186
186
  ...audioDeviceConstraints.audio,
187
- ...trackConstraints,
187
+ ...normalizeContraints(trackConstraints),
188
188
  },
189
189
  };
190
190
 
@@ -195,16 +195,6 @@ export const getAudioStream = async (
195
195
  });
196
196
  return await getStream(constraints);
197
197
  } catch (error) {
198
- if (error instanceof OverconstrainedError && trackConstraints?.deviceId) {
199
- const { deviceId, ...relaxedContraints } = trackConstraints;
200
- getLogger(['devices'])(
201
- 'warn',
202
- 'Failed to get audio stream, will try again with relaxed contraints',
203
- { error, constraints, relaxedContraints },
204
- );
205
- return getAudioStream(relaxedContraints);
206
- }
207
-
208
198
  getLogger(['devices'])('error', 'Failed to get audio stream', {
209
199
  error,
210
200
  constraints,
@@ -227,7 +217,7 @@ export const getVideoStream = async (
227
217
  const constraints: MediaStreamConstraints = {
228
218
  video: {
229
219
  ...videoDeviceConstraints.video,
230
- ...trackConstraints,
220
+ ...normalizeContraints(trackConstraints),
231
221
  },
232
222
  };
233
223
  try {
@@ -237,16 +227,6 @@ export const getVideoStream = async (
237
227
  });
238
228
  return await getStream(constraints);
239
229
  } catch (error) {
240
- if (error instanceof OverconstrainedError && trackConstraints?.deviceId) {
241
- const { deviceId, ...relaxedContraints } = trackConstraints;
242
- getLogger(['devices'])(
243
- 'warn',
244
- 'Failed to get video stream, will try again with relaxed contraints',
245
- { error, constraints, relaxedContraints },
246
- );
247
- return getVideoStream(relaxedContraints);
248
- }
249
-
250
230
  getLogger(['devices'])('error', 'Failed to get video stream', {
251
231
  error,
252
232
  constraints,
@@ -255,6 +235,20 @@ export const getVideoStream = async (
255
235
  }
256
236
  };
257
237
 
238
+ function normalizeContraints(constraints: MediaTrackConstraints | undefined) {
239
+ if (
240
+ constraints?.deviceId === 'default' ||
241
+ (typeof constraints?.deviceId === 'object' &&
242
+ 'exact' in constraints.deviceId &&
243
+ constraints.deviceId.exact === 'default')
244
+ ) {
245
+ const { deviceId, ...contraintsWithoutDeviceId } = constraints;
246
+ return contraintsWithoutDeviceId;
247
+ }
248
+
249
+ return constraints;
250
+ }
251
+
258
252
  /**
259
253
  * Prompts the user for a permission to share a screen.
260
254
  * If the user grants the permission, a screen sharing stream is returned. Throws otherwise.