Skip to content

Commit

Permalink
Fix bitrate overflow
Browse files Browse the repository at this point in the history
Server stores bitrates as Int32, but network bandwidth can exceed 2Gbps.
  • Loading branch information
dmitrylyzo committed Oct 24, 2023
1 parent 6e3ace3 commit 5cf9bd7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/apiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const reportRateLimits = {
volumechange: 3000
};

/** Maximum bitrate (Int32) */
const MAX_BITRATE = 2147483647;

function redetectBitrate(instance) {
stopBitrateDetection(instance);

Expand Down Expand Up @@ -4053,7 +4056,7 @@ function normalizeReturnBitrate(instance, bitrate) {
return Promise.reject();
}

let result = Math.round(bitrate * 0.7);
let result = Math.min(Math.round(bitrate * 0.7), MAX_BITRATE);

// allow configuration of this
if (instance.getMaxBandwidth) {
Expand Down

0 comments on commit 5cf9bd7

Please sign in to comment.