Skip to content

Commit

Permalink
Merge branch 'PBE-5855-feat/react-native-video-design-v2' into add-la…
Browse files Browse the repository at this point in the history
…yout-switcher
  • Loading branch information
kristian-mkd committed Oct 29, 2024
2 parents 7eaa092 + d8f59c1 commit 55a63e4
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 24 deletions.
7 changes: 7 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stream-io/video-client",
"version": "1.9.2",
"version": "1.9.3",
"packageManager": "[email protected]",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
Expand Down
16 changes: 12 additions & 4 deletions packages/client/src/devices/InputMediaDeviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down Expand Up @@ -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,
};

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/devices/__tests__/CameraManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand All @@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('InputMediaDeviceManager.test', () => {

expect(manager.stopPublishStream).toHaveBeenCalledWith(true);
expect(manager.getStream).toHaveBeenCalledWith({
deviceId,
deviceId: { exact: deviceId },
});
expect(manager.publishStream).toHaveBeenCalled();
});
Expand Down
44 changes: 32 additions & 12 deletions packages/client/src/devices/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const getStream = async (constraints: MediaStreamConstraints) => {
*/
export const getAudioStream = async (
trackConstraints?: MediaTrackConstraints,
) => {
): Promise<MediaStream> => {
const constraints: MediaStreamConstraints = {
audio: {
...audioDeviceConstraints.audio,
Expand All @@ -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;
}
};

Expand All @@ -200,7 +210,7 @@ export const getAudioStream = async (
*/
export const getVideoStream = async (
trackConstraints?: MediaTrackConstraints,
) => {
): Promise<MediaStream> => {
const constraints: MediaStreamConstraints = {
video: {
...videoDeviceConstraints.video,
Expand All @@ -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;
}
};

Expand Down
5 changes: 5 additions & 0 deletions packages/react-bindings/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/react-bindings/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stream-io/video-react-bindings",
"version": "1.1.7",
"version": "1.1.8",
"packageManager": "[email protected]",
"main": "./dist/index.cjs.js",
"module": "./dist/index.es.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/react-native-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stream-io/video-react-native-sdk",
"version": "1.2.4",
"version": "1.2.5",
"packageManager": "[email protected]",
"main": "dist/commonjs/index.js",
"module": "dist/module/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/react-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stream-io/video-react-sdk",
"version": "1.7.2",
"version": "1.7.3",
"packageManager": "[email protected]",
"main": "./dist/index.cjs.js",
"module": "./dist/index.es.js",
Expand Down
2 changes: 1 addition & 1 deletion sample-apps/react-native/dogfood/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 55a63e4

Please sign in to comment.