Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set degradationPreference to maintain-resolution for screen share tracks #1080

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-rockets-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Set degradationPreference to maintain-resolution for screen share tracks
14 changes: 14 additions & 0 deletions src/room/participant/LocalParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,20 @@ export default class LocalParticipant extends Participant {
}
}

if (track.kind === Track.Kind.Video && track.source === Track.Source.ScreenShare) {
// a few of reasons we are forcing this setting without allowing overrides:
// 1. without this, Chrome seems to aggressively resize the SVC video stating `quality-limitation: bandwidth` even when BW isn't an issue
// 2. since we are overriding contentHint to motion (to workaround L1T3 publishing), it overrides the default degradationPreference to `balanced`
try {
this.log.debug(`setting degradationPreference to maintain-resolution`);
const params = track.sender.getParameters();
params.degradationPreference = 'maintain-resolution';
await track.sender.setParameters(params);
} catch (e) {
this.log.warn(`failed to set degradationPreference: ${e}`);
}
}

await this.engine.negotiate();

if (track instanceof LocalVideoTrack) {
Expand Down
3 changes: 2 additions & 1 deletion src/room/participant/publishUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function computeVideoEncodings(
// to disable when CPU constrained.
// So encodings should be ordered in increasing spatial
// resolution order.
// 2. ion-sfu translates rids into layers. So, all encodings
// 2. livekit-server translates rids into layers. So, all encodings
// should have the base layer `q` and then more added
// based on other conditions.
const size = Math.max(width, height);
Expand Down Expand Up @@ -241,6 +241,7 @@ export function determineAppropriateEncoding(
break;
}
}

// presets are based on the assumption of vp8 as a codec
// for other codecs we adjust the maxBitrate if no specific videoEncoding has been provided
// users should override these with ones that are optimized for their use case
Expand Down
Loading