-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
710 additions
and
237 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
docusaurus/docs/Flutter/05-advanced/10-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,66 @@ | ||
--- | ||
title: Manual Video Quality Selection | ||
slug: /manual-video-quality-selection | ||
sidebar_position: 10 | ||
description: Learn how to manually select the incoming video quality in the Stream Video Flutter SDK. | ||
--- | ||
|
||
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: | ||
|
||
```dart | ||
await call.setPreferredIncomingVideoResolution(VideoResolution(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 a list of participant session identifiers as its optional argument. Session identifiers can be obtained from the call participant state: | ||
|
||
```dart | ||
final [first, second, ..._] = call.state.value.otherParticipants; | ||
// Set preferred incoming video resolution for the first two participants only: | ||
await call.setPreferredIncomingVideoResolution( | ||
VideoResolution(width: 640, height: 480), | ||
sessionIds: [first.sessionId, second.sessionId], | ||
); | ||
``` | ||
|
||
Calling this method will enable incoming video for the selected participants if it was previously disabled. | ||
|
||
To clear a previously set preference, pass `null` instead of resolution: | ||
|
||
```dart | ||
// Clear resolution preference for selected participants: | ||
await call.setPreferredIncomingVideoResolution( | ||
null, | ||
sessionIds: [ | ||
participant.sessionId, | ||
], | ||
); | ||
// Clear resolution preference for all participants: | ||
await call.setPreferredIncomingVideoResolution(null); | ||
``` | ||
|
||
## Disabling Incoming Video | ||
|
||
To completely disable incoming video (either to save data, or for an audio-only experience), use the `call.setIncomingVideoEnabled()` method: | ||
|
||
```dart | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: Session Timers | ||
slug: /session-timers | ||
sidebar_position: 11 | ||
description: Learn how to limit the maximum duration of a call in the Stream Video Flutter SDK. | ||
--- | ||
|
||
A session timer allows you to limit the maximum duration of a call. The duration [can be configured](https://getstream.io/video/docs/api/calls/#session-timers) for all calls of a certain type, or on a per-call basis. When a session timer reaches zero, the call automatically ends. | ||
|
||
## Creating a call with a session timer | ||
|
||
Let's see how to create a single call with a limited duration: | ||
|
||
```dart | ||
final call = client.makeCall(callType: StreamCallType.defaultType(), id: 'REPLACE_WITH_CALL_ID'); | ||
await call.getOrCreate( | ||
limits: const StreamLimitsSettings( | ||
maxDurationSeconds: 3600, | ||
), | ||
); | ||
``` | ||
|
||
This code creates a call with a duration of 3600 seconds (1 hour) from the time the session is starts (a participant joins the call). | ||
|
||
After joining the call with the specified `maxDurationSeconds`, you can examine a call state's `timerEndsAt` field, which provides the timestamp when the call will end. When a call ends, all participants are removed from the call. | ||
|
||
```dart | ||
await call.join(); | ||
print(call.state.value.timerEndsAt); | ||
``` | ||
|
||
## Extending a call | ||
|
||
You can also extend the duration of a call, both before or during the call. To do that, you should use the `call.update` method: | ||
|
||
```dart | ||
final duration = | ||
call.state.value.settings.limits.maxDurationSeconds! + 60; | ||
call.update( | ||
limits: StreamLimitsSettings( | ||
maxDurationSeconds: duration, | ||
), | ||
); | ||
``` | ||
|
||
If the call duration is extended, the `timerEndsAt` is updated to reflect this change. Call participants will receive the `call.updated` event to notify them about this change. |
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.