diff --git a/packages/client/CHANGELOG.md b/packages/client/CHANGELOG.md index 604a7eb91e..c512670200 100644 --- a/packages/client/CHANGELOG.md +++ b/packages/client/CHANGELOG.md @@ -2,6 +2,13 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.9.3](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.9.2...@stream-io/video-client-1.9.3) (2024-10-28) + + +### Bug Fixes + +* make device selection by device id exact ([#1538](https://github.com/GetStream/stream-video-js/issues/1538)) ([6274cac](https://github.com/GetStream/stream-video-js/commit/6274cac2ecf155aa6ce0c6d764229e0e9cd39a6a)) + ## [1.9.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.9.1...@stream-io/video-client-1.9.2) (2024-10-21) diff --git a/packages/client/package.json b/packages/client/package.json index fce1e9c3ed..22ddf25a6c 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-client", - "version": "1.9.2", + "version": "1.9.3", "packageManager": "yarn@3.2.4", "main": "dist/index.cjs.js", "module": "dist/index.es.js", diff --git a/packages/client/src/devices/InputMediaDeviceManager.ts b/packages/client/src/devices/InputMediaDeviceManager.ts index 0b13138165..a5cda2df78 100644 --- a/packages/client/src/devices/InputMediaDeviceManager.ts +++ b/packages/client/src/devices/InputMediaDeviceManager.ts @@ -206,11 +206,17 @@ export abstract class InputMediaDeviceManager< 'This method is not supported in React Native. Please visit https://getstream.io/video/docs/reactnative/core/camera-and-microphone/#speaker-management for reference.', ); } - if (deviceId === this.state.selectedDevice) { + const prevDeviceId = this.state.selectedDevice; + if (deviceId === prevDeviceId) { return; } - this.state.setDevice(deviceId); - await this.applySettingsToStream(); + try { + this.state.setDevice(deviceId); + await this.applySettingsToStream(); + } catch (error) { + this.state.setDevice(prevDeviceId); + throw error; + } } /** @@ -308,7 +314,9 @@ export abstract class InputMediaDeviceManager< const defaultConstraints = this.state.defaultConstraints; const constraints: MediaTrackConstraints = { ...defaultConstraints, - deviceId: this.state.selectedDevice, + deviceId: this.state.selectedDevice + ? { exact: this.state.selectedDevice } + : undefined, }; /** diff --git a/packages/client/src/devices/__tests__/CameraManager.test.ts b/packages/client/src/devices/__tests__/CameraManager.test.ts index df7d74b171..e432ba6305 100644 --- a/packages/client/src/devices/__tests__/CameraManager.test.ts +++ b/packages/client/src/devices/__tests__/CameraManager.test.ts @@ -157,7 +157,7 @@ describe('CameraManager', () => { await manager.select(deviceId); expect((getVideoStream as Mock).mock.lastCall[0]).toEqual({ - deviceId, + deviceId: { exact: deviceId }, width: 1280, height: 720, }); @@ -182,7 +182,7 @@ describe('CameraManager', () => { await manager.selectTargetResolution({ width: 640, height: 480 }); expect((getVideoStream as Mock).mock.lastCall[0]).toEqual({ - deviceId: mockVideoDevices[0].deviceId, + deviceId: { exact: mockVideoDevices[0].deviceId }, width: 640, height: 480, }); diff --git a/packages/client/src/devices/__tests__/InputMediaDeviceManager.test.ts b/packages/client/src/devices/__tests__/InputMediaDeviceManager.test.ts index ae3b4743a7..545bb1902e 100644 --- a/packages/client/src/devices/__tests__/InputMediaDeviceManager.test.ts +++ b/packages/client/src/devices/__tests__/InputMediaDeviceManager.test.ts @@ -181,7 +181,7 @@ describe('InputMediaDeviceManager.test', () => { expect(manager.stopPublishStream).toHaveBeenCalledWith(true); expect(manager.getStream).toHaveBeenCalledWith({ - deviceId, + deviceId: { exact: deviceId }, }); expect(manager.publishStream).toHaveBeenCalled(); }); diff --git a/packages/client/src/devices/devices.ts b/packages/client/src/devices/devices.ts index 684da44b14..107d534ffe 100644 --- a/packages/client/src/devices/devices.ts +++ b/packages/client/src/devices/devices.ts @@ -167,7 +167,7 @@ const getStream = async (constraints: MediaStreamConstraints) => { */ export const getAudioStream = async ( trackConstraints?: MediaTrackConstraints, -) => { +): Promise => { const constraints: MediaStreamConstraints = { audio: { ...audioDeviceConstraints.audio, @@ -180,13 +180,23 @@ export const getAudioStream = async ( throwOnNotAllowed: true, forcePrompt: true, }); - return getStream(constraints); - } catch (e) { + return await getStream(constraints); + } catch (error) { + if (error instanceof OverconstrainedError && trackConstraints?.deviceId) { + const { deviceId, ...relaxedContraints } = trackConstraints; + getLogger(['devices'])( + 'warn', + 'Failed to get audio stream, will try again with relaxed contraints', + { error, constraints, relaxedContraints }, + ); + return getAudioStream(relaxedContraints); + } + getLogger(['devices'])('error', 'Failed to get audio stream', { - error: e, - constraints: constraints, + error, + constraints, }); - throw e; + throw error; } }; @@ -200,7 +210,7 @@ export const getAudioStream = async ( */ export const getVideoStream = async ( trackConstraints?: MediaTrackConstraints, -) => { +): Promise => { const constraints: MediaStreamConstraints = { video: { ...videoDeviceConstraints.video, @@ -212,13 +222,23 @@ export const getVideoStream = async ( throwOnNotAllowed: true, forcePrompt: true, }); - return getStream(constraints); - } catch (e) { + return await getStream(constraints); + } catch (error) { + if (error instanceof OverconstrainedError && trackConstraints?.deviceId) { + const { deviceId, ...relaxedContraints } = trackConstraints; + getLogger(['devices'])( + 'warn', + 'Failed to get video stream, will try again with relaxed contraints', + { error, constraints, relaxedContraints }, + ); + return getVideoStream(relaxedContraints); + } + getLogger(['devices'])('error', 'Failed to get video stream', { - error: e, - constraints: constraints, + error, + constraints, }); - throw e; + throw error; } }; diff --git a/packages/react-bindings/CHANGELOG.md b/packages/react-bindings/CHANGELOG.md index b68e05db69..6c0330230a 100644 --- a/packages/react-bindings/CHANGELOG.md +++ b/packages/react-bindings/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.1.8](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-1.1.7...@stream-io/video-react-bindings-1.1.8) (2024-10-28) + +### Dependency Updates + +* `@stream-io/video-client` updated to version `1.9.3` ## [1.1.7](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-1.1.6...@stream-io/video-react-bindings-1.1.7) (2024-10-21) ### Dependency Updates diff --git a/packages/react-bindings/package.json b/packages/react-bindings/package.json index 92385ae772..ea65f2fef2 100644 --- a/packages/react-bindings/package.json +++ b/packages/react-bindings/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-react-bindings", - "version": "1.1.7", + "version": "1.1.8", "packageManager": "yarn@3.2.4", "main": "./dist/index.cjs.js", "module": "./dist/index.es.js", diff --git a/packages/react-native-sdk/CHANGELOG.md b/packages/react-native-sdk/CHANGELOG.md index d409ae4f75..820371adca 100644 --- a/packages/react-native-sdk/CHANGELOG.md +++ b/packages/react-native-sdk/CHANGELOG.md @@ -2,6 +2,12 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.2.5](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-1.2.4...@stream-io/video-react-native-sdk-1.2.5) (2024-10-28) + +### Dependency Updates + +* `@stream-io/video-client` updated to version `1.9.3` +* `@stream-io/video-react-bindings` updated to version `1.1.8` ## [1.2.4](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-1.2.3...@stream-io/video-react-native-sdk-1.2.4) (2024-10-22) diff --git a/packages/react-native-sdk/package.json b/packages/react-native-sdk/package.json index 2305ce0392..260c30f0ea 100644 --- a/packages/react-native-sdk/package.json +++ b/packages/react-native-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-react-native-sdk", - "version": "1.2.4", + "version": "1.2.5", "packageManager": "yarn@3.2.4", "main": "dist/commonjs/index.js", "module": "dist/module/index.js", diff --git a/packages/react-sdk/CHANGELOG.md b/packages/react-sdk/CHANGELOG.md index 625f2d7722..4ea144b6b3 100644 --- a/packages/react-sdk/CHANGELOG.md +++ b/packages/react-sdk/CHANGELOG.md @@ -2,6 +2,12 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.7.3](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.2...@stream-io/video-react-sdk-1.7.3) (2024-10-28) + +### Dependency Updates + +* `@stream-io/video-client` updated to version `1.9.3` +* `@stream-io/video-react-bindings` updated to version `1.1.8` ## [1.7.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.1...@stream-io/video-react-sdk-1.7.2) (2024-10-21) ### Dependency Updates diff --git a/packages/react-sdk/package.json b/packages/react-sdk/package.json index 4517a40599..35a002ed60 100644 --- a/packages/react-sdk/package.json +++ b/packages/react-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-react-sdk", - "version": "1.7.2", + "version": "1.7.3", "packageManager": "yarn@3.2.4", "main": "./dist/index.cjs.js", "module": "./dist/index.es.js", diff --git a/sample-apps/react-native/dogfood/package.json b/sample-apps/react-native/dogfood/package.json index 8888eed99a..724a92472a 100644 --- a/sample-apps/react-native/dogfood/package.json +++ b/sample-apps/react-native/dogfood/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-react-native-dogfood", - "version": "4.4.4", + "version": "4.4.5", "private": true, "scripts": { "android": "react-native run-android",