in src/videouplinkbandwidthpolicy/NScaleVideoUplinkBandwidthPolicy.ts [232:289]
private calculateEncodingParameters(setting: MediaTrackSettings): RTCRtpEncodingParameters {
const maxBitrate = this.maxBandwidthKbps() * 1000;
let scale = 1;
let targetHeight = 720;
if (
setting.height !== undefined &&
setting.width !== undefined &&
this.scaleResolution &&
!this.hasBandwidthPriority &&
this.getNumberOfPublishedVideoSources() > 2
) {
targetHeight =
NScaleVideoUplinkBandwidthPolicy.targetHeightArray[
Math.min(
this.getNumberOfPublishedVideoSources(),
NScaleVideoUplinkBandwidthPolicy.targetHeightArray.length - 1
)
][this.enableHighResolutionFeature ? 1 : 0];
//Workaround for issue https://github.com/aws/amazon-chime-sdk-js/issues/2002
if (targetHeight === 480 && this.browserBehavior?.disable480pResolutionScaleDown()) {
targetHeight = 360;
}
scale = Math.max(Math.min(setting.height, setting.width) / targetHeight, 1);
this.logger?.info(
`Resolution scale factor is ${scale} for capture resolution ${setting.width}x${
setting.height
}. New dimension is ${setting.width / scale}x${setting.height / scale}`
);
}
if (this.enableSVC) {
let scalabilityMode: string;
if ((this.numParticipants >= 0 && this.numParticipants < 3) || !this.isUsingSVCCodec) {
scalabilityMode = 'L1T1';
} else {
// We do not limit the number of layers depending on input resolution, however Chrome will drop anything below around 135p.
scalabilityMode = 'L3T3';
}
this.logger?.info(
`calculateEncodingParameters: SVC: ${this.enableSVC} participants: ${
this.numParticipants
} publishers: ${this.getNumberOfPublishedVideoSources()} bitrate: ${maxBitrate} targetHeight: ${targetHeight} scalabilityMode: ${scalabilityMode} isUsingSVCCodec: ${
this.isUsingSVCCodec
}`
);
return {
scaleResolutionDownBy: scale,
maxBitrate: maxBitrate,
// @ts-ignore
scalabilityMode: scalabilityMode,
};
} else {
return {
scaleResolutionDownBy: scale,
maxBitrate: maxBitrate,
};
}
}