Skip to content

Commit

Permalink
Merge branch 'PBE-5855-feat/react-native-video-design-v2' into color-…
Browse files Browse the repository at this point in the history
…consolidation-and-other-fixes
  • Loading branch information
kristian-mkd committed Nov 7, 2024
2 parents 28c03c8 + ff7752b commit 247b701
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 10 deletions.
14 changes: 14 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [1.10.5](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.10.4...@stream-io/video-client-1.10.5) (2024-11-07)


### Bug Fixes

* ignore maxSimulcastLayers override for SVC codecs ([#1564](https://github.com/GetStream/stream-video-js/issues/1564)) ([48f8abe](https://github.com/GetStream/stream-video-js/commit/48f8abe5fd5b48c367a04696febd582573def828))

## [1.10.4](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.10.3...@stream-io/video-client-1.10.4) (2024-11-07)


### Bug Fixes

* max simulcast layers preference ([#1560](https://github.com/GetStream/stream-video-js/issues/1560)) ([2b0bf28](https://github.com/GetStream/stream-video-js/commit/2b0bf2824dce41c2709e361e0521cf85e1b2fd16))

## [1.10.3](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.10.2...@stream-io/video-client-1.10.3) (2024-11-05)


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.10.3",
"version": "1.10.5",
"packageManager": "[email protected]",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/rtc/Publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ export class Publisher {
? // for SVC, we only have one layer (q) and often rid is omitted
enabledLayers[0]
: // for non-SVC, we need to find the layer by rid (simulcast)
enabledLayers.find((l) => l.name === encoder.rid);
enabledLayers.find((l) => l.name === encoder.rid) ??
(params.encodings.length === 1 ? enabledLayers[0] : undefined);

// flip 'active' flag only when necessary
const shouldActivate = !!layer?.active;
Expand Down
39 changes: 39 additions & 0 deletions packages/client/src/rtc/__tests__/Publisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,45 @@ describe('Publisher', () => {
]);
});

it('can dynamically activate/deactivate simulcast layers when rid is missing', async () => {
const transceiver = new RTCRtpTransceiver();
const setParametersSpy = vi
.spyOn(transceiver.sender, 'setParameters')
.mockResolvedValue();
const getParametersSpy = vi
.spyOn(transceiver.sender, 'getParameters')
.mockReturnValue({
// @ts-expect-error incomplete data
codecs: [{ mimeType: 'video/VP8' }],
encodings: [{ active: false }],
});

// inject the transceiver
publisher['transceiverCache'].set(TrackType.VIDEO, transceiver);

await publisher['changePublishQuality']([
{
name: 'q',
active: true,
maxBitrate: 100,
scaleResolutionDownBy: 4,
maxFramerate: 30,
scalabilityMode: '',
},
]);

expect(getParametersSpy).toHaveBeenCalled();
expect(setParametersSpy).toHaveBeenCalled();
expect(setParametersSpy.mock.calls[0][0].encodings).toEqual([
{
active: true,
maxBitrate: 100,
scaleResolutionDownBy: 4,
maxFramerate: 30,
},
]);
});

it('can dynamically update scalability mode in SVC', async () => {
const transceiver = new RTCRtpTransceiver();
const setParametersSpy = vi
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/rtc/bitrateLookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const bitrateLookupTable: Record<
> = {
h264: {
2160: 5_000_000,
1440: 3_500_000,
1080: 2_750_000,
1440: 3_000_000,
1080: 2_000_000,
720: 1_250_000,
540: 750_000,
360: 400_000,
Expand Down
9 changes: 7 additions & 2 deletions packages/client/src/rtc/videoLayers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ export const findOptimalVideoLayers = (
const optimalVideoLayers: OptimalVideoLayer[] = [];
const settings = videoTrack.getSettings();
const { width = 0, height = 0 } = settings;
const { scalabilityMode, bitrateDownscaleFactor = 2 } = publishOptions || {};
const {
scalabilityMode,
bitrateDownscaleFactor = 2,
maxSimulcastLayers = 3,
} = publishOptions || {};
const maxBitrate = getComputedMaxBitrate(
targetResolution,
width,
Expand All @@ -76,7 +80,8 @@ export const findOptimalVideoLayers = (
let downscaleFactor = 1;
let bitrateFactor = 1;
const svcCodec = isSvcCodec(codecInUse);
for (const rid of ['f', 'h', 'q']) {
const totalLayers = svcCodec ? 3 : Math.min(3, maxSimulcastLayers);
for (const rid of ['f', 'h', 'q'].slice(0, totalLayers)) {
const layer: OptimalVideoLayer = {
active: true,
rid,
Expand Down
4 changes: 4 additions & 0 deletions packages/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export type PublishOptions = {
* in simulcast mode (non-SVC).
*/
bitrateDownscaleFactor?: number;
/**
* The maximum number of simulcast layers to use when publishing the video stream.
*/
maxSimulcastLayers?: number;
/**
* Screen share settings.
*/
Expand Down
10 changes: 10 additions & 0 deletions packages/react-bindings/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [1.1.16](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-1.1.15...@stream-io/video-react-bindings-1.1.16) (2024-11-07)

### Dependency Updates

* `@stream-io/video-client` updated to version `1.10.5`
## [1.1.15](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-1.1.14...@stream-io/video-react-bindings-1.1.15) (2024-11-07)

### Dependency Updates

* `@stream-io/video-client` updated to version `1.10.4`
## [1.1.14](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-1.1.13...@stream-io/video-react-bindings-1.1.14) (2024-11-05)

### 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.14",
"version": "1.1.16",
"packageManager": "[email protected]",
"main": "./dist/index.cjs.js",
"module": "./dist/index.es.js",
Expand Down
12 changes: 12 additions & 0 deletions packages/react-native-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [1.2.14](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-1.2.13...@stream-io/video-react-native-sdk-1.2.14) (2024-11-07)

### Dependency Updates

* `@stream-io/video-client` updated to version `1.10.5`
* `@stream-io/video-react-bindings` updated to version `1.1.16`
## [1.2.13](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-1.2.12...@stream-io/video-react-native-sdk-1.2.13) (2024-11-07)

### Dependency Updates

* `@stream-io/video-client` updated to version `1.10.4`
* `@stream-io/video-react-bindings` updated to version `1.1.15`
## [1.2.12](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-1.2.11...@stream-io/video-react-native-sdk-1.2.12) (2024-11-05)

### Dependency Updates
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.12",
"version": "1.2.14",
"packageManager": "[email protected]",
"main": "dist/commonjs/index.js",
"module": "dist/module/index.js",
Expand Down
12 changes: 12 additions & 0 deletions packages/react-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [1.7.11](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.10...@stream-io/video-react-sdk-1.7.11) (2024-11-07)

### Dependency Updates

* `@stream-io/video-client` updated to version `1.10.5`
* `@stream-io/video-react-bindings` updated to version `1.1.16`
## [1.7.10](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.9...@stream-io/video-react-sdk-1.7.10) (2024-11-07)

### Dependency Updates

* `@stream-io/video-client` updated to version `1.10.4`
* `@stream-io/video-react-bindings` updated to version `1.1.15`
## [1.7.9](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.8...@stream-io/video-react-sdk-1.7.9) (2024-11-05)

### 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.9",
"version": "1.7.11",
"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.12",
"version": "4.4.14",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down
6 changes: 6 additions & 0 deletions sample-apps/react/react-dogfood/components/MeetingUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export const MeetingUI = ({ chatClient, mode }: MeetingUIProps) => {
const scalabilityMode = router.query['scalability_mode'] as
| string
| undefined;
const maxSimulcastLayers = router.query['max_simulcast_layers'] as
| string
| undefined;

const onJoin = useCallback(
async ({ fastJoin = false } = {}) => {
Expand All @@ -74,6 +77,9 @@ export const MeetingUI = ({ chatClient, mode }: MeetingUIProps) => {
bitrateDownscaleFactor: bitrateFactorOverride
? parseInt(bitrateFactorOverride, 10)
: 2, // default to 2
maxSimulcastLayers: maxSimulcastLayers
? parseInt(maxSimulcastLayers, 10)
: 3, // default to 3
});

await call.join({ create: true });
Expand Down

0 comments on commit 247b701

Please sign in to comment.