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

Add support for setting subscription priority #598

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
17 changes: 17 additions & 0 deletions src/room/track/RemoteTrackPublication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ export default class RemoteTrackPublication extends TrackPublication {

protected fps?: number;

protected priority: number;

constructor(kind: Track.Kind, ti: TrackInfo, autoSubscribe: boolean | undefined) {
super(kind, ti.sid, ti.name);
this.subscribed = autoSubscribe;
this.priority = 0;
this.updateInfo(ti);
}

Expand Down Expand Up @@ -61,6 +64,19 @@ export default class RemoteTrackPublication extends TrackPublication {
this.emitPermissionUpdateIfChanged(prevPermission);
}

/**
* In cases where downstream bandwidth is constrained, setting a priority on a RemoteTrackPublication allows to (de-)prioritize specific tracks
* @param priority
*/
setSubscriptionPriority(priority: number) {
this.priority = priority;
this.emitTrackUpdate();
}

get subscriptionPriority() {
return this.priority;
}

get subscriptionStatus(): TrackPublication.SubscriptionStatus {
if (this.subscribed === false) {
return TrackPublication.SubscriptionStatus.Unsubscribed;
Expand Down Expand Up @@ -277,6 +293,7 @@ export default class RemoteTrackPublication extends TrackPublication {
trackSids: [this.trackSid],
disabled: this.disabled,
fps: this.fps,
priority: this.priority,
});
if (this.videoDimensions) {
settings.width = this.videoDimensions.width;
Expand Down