@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/CHANGELOG.md +7 -0
- package/dist/index.browser.es.js +15 -14
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +15 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +15 -14
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/devices/InputMediaDeviceManager.ts +1 -0
- package/src/devices/devices.ts +16 -22
package/package.json
CHANGED
package/src/devices/devices.ts
CHANGED
|
@@ -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.
|