@stream-io/video-client 1.11.9 → 1.11.11

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.
@@ -174,8 +174,6 @@ export type CallLeaveOptions = {
174
174
  /**
175
175
  * If true, the caller will get a `call.rejected` event.
176
176
  * Has an effect only if the call is in the `ringing` state.
177
- *
178
- * @default `false`.
179
177
  */
180
178
  reject?: boolean;
181
179
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "1.11.9",
3
+ "version": "1.11.11",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
package/src/Call.ts CHANGED
@@ -496,7 +496,7 @@ export class Call {
496
496
  * Leave the call and stop the media streams that were published by the call.
497
497
  */
498
498
  leave = async ({
499
- reject = false,
499
+ reject,
500
500
  reason = 'user is leaving the call',
501
501
  }: CallLeaveOptions = {}) => {
502
502
  await withoutConcurrency(this.joinLeaveConcurrencyTag, async () => {
@@ -516,13 +516,14 @@ export class Call {
516
516
  await waitUntilCallJoined();
517
517
  }
518
518
 
519
- if (callingState === CallingState.RINGING) {
519
+ if (callingState === CallingState.RINGING && reject !== false) {
520
520
  if (reject) {
521
521
  await this.reject(reason);
522
522
  } else {
523
+ // if reject was undefined, we still have to cancel the call automatically
524
+ // when I am the creator and everyone else left the call
523
525
  const hasOtherParticipants = this.state.remoteParticipants.length > 0;
524
526
  if (this.isCreatedByMe && !hasOtherParticipants) {
525
- // I'm the one who started the call, so I should cancel it when there are no other participants.
526
527
  await this.reject('cancel');
527
528
  }
528
529
  }
@@ -215,7 +215,6 @@ export abstract class InputMediaDeviceManager<
215
215
  await this.applySettingsToStream();
216
216
  } catch (error) {
217
217
  this.state.setDevice(prevDeviceId);
218
- await this.applySettingsToStream();
219
218
  throw error;
220
219
  }
221
220
  }
@@ -184,7 +184,7 @@ export const getAudioStream = async (
184
184
  const constraints: MediaStreamConstraints = {
185
185
  audio: {
186
186
  ...audioDeviceConstraints.audio,
187
- ...normalizeContraints(trackConstraints),
187
+ ...trackConstraints,
188
188
  },
189
189
  };
190
190
 
@@ -195,6 +195,20 @@ export const getAudioStream = async (
195
195
  });
196
196
  return await getStream(constraints);
197
197
  } catch (error) {
198
+ if (
199
+ error instanceof DOMException &&
200
+ error.name === 'OverconstrainedError' &&
201
+ trackConstraints?.deviceId
202
+ ) {
203
+ const { deviceId, ...relaxedContraints } = trackConstraints;
204
+ getLogger(['devices'])(
205
+ 'warn',
206
+ 'Failed to get audio stream, will try again with relaxed contraints',
207
+ { error, constraints, relaxedContraints },
208
+ );
209
+ return getAudioStream(relaxedContraints);
210
+ }
211
+
198
212
  getLogger(['devices'])('error', 'Failed to get audio stream', {
199
213
  error,
200
214
  constraints,
@@ -217,7 +231,7 @@ export const getVideoStream = async (
217
231
  const constraints: MediaStreamConstraints = {
218
232
  video: {
219
233
  ...videoDeviceConstraints.video,
220
- ...normalizeContraints(trackConstraints),
234
+ ...trackConstraints,
221
235
  },
222
236
  };
223
237
  try {
@@ -227,6 +241,20 @@ export const getVideoStream = async (
227
241
  });
228
242
  return await getStream(constraints);
229
243
  } catch (error) {
244
+ if (
245
+ error instanceof DOMException &&
246
+ error.name === 'OverconstrainedError' &&
247
+ trackConstraints?.deviceId
248
+ ) {
249
+ const { deviceId, ...relaxedContraints } = trackConstraints;
250
+ getLogger(['devices'])(
251
+ 'warn',
252
+ 'Failed to get video stream, will try again with relaxed contraints',
253
+ { error, constraints, relaxedContraints },
254
+ );
255
+ return getVideoStream(relaxedContraints);
256
+ }
257
+
230
258
  getLogger(['devices'])('error', 'Failed to get video stream', {
231
259
  error,
232
260
  constraints,
@@ -235,20 +263,6 @@ export const getVideoStream = async (
235
263
  }
236
264
  };
237
265
 
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
-
252
266
  /**
253
267
  * Prompts the user for a permission to share a screen.
254
268
  * If the user grants the permission, a screen sharing stream is returned. Throws otherwise.
@@ -79,9 +79,11 @@ export const watchCallEnded = (call: Call) => {
79
79
  callingState !== CallingState.IDLE &&
80
80
  callingState !== CallingState.LEFT
81
81
  ) {
82
- call.leave({ reason: 'call.ended event received' }).catch((err) => {
83
- call.logger('error', 'Failed to leave call after call.ended ', err);
84
- });
82
+ call
83
+ .leave({ reason: 'call.ended event received', reject: false })
84
+ .catch((err) => {
85
+ call.logger('error', 'Failed to leave call after call.ended ', err);
86
+ });
85
87
  }
86
88
  };
87
89
  };
package/src/types.ts CHANGED
@@ -215,8 +215,6 @@ export type CallLeaveOptions = {
215
215
  /**
216
216
  * If true, the caller will get a `call.rejected` event.
217
217
  * Has an effect only if the call is in the `ringing` state.
218
- *
219
- * @default `false`.
220
218
  */
221
219
  reject?: boolean;
222
220