-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: manual video quality selection (#1486)
Adds APIs to manually override incoming video quality: ## Client ### `call.setPreferredIncomingVideoResolution(resolution?: VideoDimension, sessionIds?: string[])` Specify preference for incoming video resolution. The preference will be matched as close as possible, but actual resolution will depend on the video source quality and client network conditions. Will enable incoming video, if previously disabled. Passing `undefined` resolution clears previously set preferences. Optionally specify session ids of the participants this preference has effect on. Affects all participants by default. ### `call.setIncomingVideoEnabled(enabled: boolean)` Enables or disables incoming video from all remote call participants, and clears any preference for preferred resolution. ## React SDK New call state hook added: ### `useIncomingVideoSettings()` Returns incoming video settings for the current call, including global and per-participant manual video quality overrides. ## Demo App Video quality selector added to the settings modal in `react-dogfood`. On Pronto, it's also visible in call controls: ![](https://github.com/user-attachments/assets/8cf111d5-2924-4067-9aca-59f51dfb1a8e) ![](https://github.com/user-attachments/assets/eac779c0-d120-402d-b7b9-ef3033b56d1e) ## Internal APIs updated ### `callState.updateParticipantTracks` Call class no longer has a slightly incorrectly named `updateSubscriptionsPartial` method. We want to avoid the Call class dealing with subscriptions at all - this is a domain of the DynascaleManager. Instead, the new `updateParticipantTracks` should be used on the CallState object. ### Disabling <Video /> New `enabled` prop has been added to the core Video component. Setting `enabled={false}` allows to force fallback instead of video, even if participant is publishing a video track. --------- Co-authored-by: Santhosh Vaiyapuri <[email protected]>
- Loading branch information
1 parent
0a2b748
commit 3a754af
Showing
33 changed files
with
940 additions
and
304 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...nt/docusaurus/docs/javascript/10-advanced/12-manual-video-quality-selection.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
id: manual-video-quality-selection | ||
title: Manual Video Quality Selection | ||
--- | ||
|
||
By default, our SDK chooses the incoming video quality that best matches the size of a video element for a given participant. It makes less sense to waste bandwidth receiving Full HD video when it's going to be displayed in a 320 by 240 pixel rectangle. | ||
|
||
However, it's still possible to override this behavior and manually request higher resolution video for better quality, or lower resolution to save bandwidth. It's also possible to disable incoming video altogether for an audio-only experience. | ||
|
||
## Overriding Preferred Resolution | ||
|
||
To override the preferred incoming video resolution, use the `call.setPreferredIncomingVideoResolution` method: | ||
|
||
```js | ||
await call.setPreferredIncomingVideoResolution({ width: 640, height: 480 }); | ||
``` | ||
|
||
:::note | ||
Actual incoming video quality depends on a number of factors, such as the quality of the source video, and network conditions. Manual video quality selection allows you to specify your preference, while the actual resolution is automatically selected from the available resolutions to match that preference as closely as possible. | ||
::: | ||
|
||
It's also possible to override the incoming video resolution for only a selected subset of call participants. The `call.setPreferredIncomingVideoResolution` method optionally takes an array of participant session identifiers as its second argument. Session identifiers can be obtained from the call participant state: | ||
|
||
```js | ||
const [firstParticipant, secondParticipant] = call.state.participants; | ||
// Set preferred incoming video resolution for the first two participants only: | ||
await call.setPreferredIncomingVideoResolution({ width: 640, height: 480 }, [ | ||
[firstParticipant.sessionId, secondParticipant.sessionId], | ||
]); | ||
``` | ||
|
||
Calling this method will enable incoming video for the selected participants if it was previously disabled. | ||
|
||
To clear a previously set preference, pass `undefined` instead of resolution: | ||
|
||
```js | ||
// Clear resolution preference for selected participants: | ||
await call.setPreferredIncomingVideoResolution(undefined, [ | ||
participant.sessionId, | ||
]); | ||
// Clear resolution preference for all participants: | ||
await call.setPreferredIncomingVideoResolution(undefined); | ||
``` | ||
|
||
## Disabling Incoming Video | ||
|
||
To completely disable incoming video (either to save data, or for an audio-only experience), use the `call.setIncomingVideoEnabled` method: | ||
|
||
```js | ||
await call.setIncomingVideoEnabled(false); | ||
``` | ||
|
||
To enable incoming video again, pass `true` as an argument: | ||
|
||
```js | ||
await call.setIncomingVideoEnabled(true); | ||
``` | ||
|
||
Calling this method will clear the previously set resolution preferences. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.