in src/videodownlinkbandwidthpolicy/VideoPriorityBasedPolicy.ts [1120:1160]
private canUpgrade(
bitrateKbps: number,
targetResolution: TargetDisplaySize,
targetBitrateKbps: number,
isContent: boolean
): boolean {
let canUpgrade = false;
// For both video and content, we want to interpret `TargetDisplaySize.High` as a request for the best quality
// video, and should ignore the value of the target bitrate.
if (targetResolution === TargetDisplaySize.High) {
// For both video and content, we want to interpret `TargetDisplaySize.High` as a request for the best quality
// video, and should ignore the value of the target bitrate.
canUpgrade = true;
} else if (!isContent && bitrateKbps <= targetBitrateKbps) {
// For content share, even if the higher quality stream has a high max bitrate of 1200 kbps for example
// the avg bitrate can be way lower so have to make sure that we do not update to a higher bitrate than the
// target value (i.e. if `targetResolution === TargetDisplaySize.Low`).
//
// This does not apply to video as video uplink bandwidth could change the max bitrate value without resubscribing
// so the max bitrate value might not be up-to-date on the downlink side. Also in the case of video, the avg
// bitrate is close to the actual max bitrate.
canUpgrade = true;
} else if (
isContent &&
targetResolution === TargetDisplaySize.Medium &&
bitrateKbps <= targetBitrateKbps
) {
// If the target resolution is medium then fall back to use avg bitrate as video.
canUpgrade = true;
}
if (canUpgrade) {
this.logger.info(
`bwe: canUpgrade: bitrateKbps: ${bitrateKbps} targetBitrateKbps: ${targetBitrateKbps}`
);
return true;
}
this.logger.info(
`bwe: cannot Upgrade: bitrateKbps: ${bitrateKbps} targetBitrateKbps: ${targetBitrateKbps}`
);
return false;
}