Skip to content

Commit

Permalink
squash: Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jallamsetty1 committed Aug 7, 2024
1 parent 3565e21 commit 9510231
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/RTC/TraceablePeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@ TraceablePeerConnection.prototype.calculateExpectedSendResolution = function(loc
result = encodings.reduce((maxValue, encoding) => {
if (encoding.active) {
// eslint-disable-next-line no-param-reassign
maxValue = Math.max(maxValue, captureResolution / encoding.scaleResolutionDownBy);
maxValue = Math.max(maxValue, Math.floor(captureResolution / encoding.scaleResolutionDownBy));
}

return maxValue;
Expand Down
21 changes: 13 additions & 8 deletions modules/qualitycontrol/QualityController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class QualityController {
private _codecController: CodecSelection;
private _conference: JitsiConference;
private _enableAdaptiveMode: boolean;
private _encodeTimeStats: Map<string, FixedSizeArray>;
private _encodeTimeStats: Map<number, FixedSizeArray>;
private _isLastNRampupBlocked: boolean;
private _lastNRampupTime: number;
private _lastNRampupTimeout: number | undefined;
Expand All @@ -116,7 +116,12 @@ export class QualityController {
* @param {JitsiConference} conference - The JitsiConference instance.
* @param {Object} options - video quality settings passed through config.js.
*/
constructor(conference: JitsiConference, options) {
constructor(conference: JitsiConference, options: {
enableAdaptiveMode: boolean;
jvb: Object;
lastNRampupTime: number;
p2p: Object;
}) {
this._conference = conference;
const { jvb, p2p } = options;
this._codecController = new CodecSelection(conference, { jvb, p2p });
Expand Down Expand Up @@ -177,7 +182,7 @@ export class QualityController {
if (cpuLimited) {
const videoStreamsReceived = this._conference.getForwardedSources().length;

newLastN = videoStreamsReceived / 2;
newLastN = Math.floor(videoStreamsReceived / 2);
if (newLastN < MIN_LAST_N) {
newLastN = MIN_LAST_N;
}
Expand Down Expand Up @@ -231,10 +236,10 @@ export class QualityController {
* Updates the codec preference order for the local endpoint on the active media session and switches the video
* codec if needed.
*
* @param {string} trackId - The track ID of the local video track for which stats have been captured.
* @param {number} trackId - The track ID of the local video track for which stats have been captured.
* @returns {boolean} - Returns true if video codec was changed.
*/
_maybeSwitchVideoCodec(trackId: string): boolean {
_maybeSwitchVideoCodec(trackId: number): boolean {
const stats = this._encodeTimeStats.get(trackId);
const { codec, encodeResolution, localTrack } = stats.get(stats.size() - 1);
const codecsByVideoType = VIDEO_CODECS_BY_COMPLEXITY[localTrack.getVideoType()];
Expand Down Expand Up @@ -277,7 +282,7 @@ export class QualityController {
}

const { encodeResolution, localTrack, qualityLimitationReason, tpc } = sourceStats;
const trackId = localTrack.rtcId.toString();
const trackId = localTrack.rtcId;

if (encodeResolution === tpc.calculateExpectedSendResolution(localTrack)) {
if (this._limitedByCpuTimeout) {
Expand Down Expand Up @@ -357,7 +362,7 @@ export class QualityController {
for (const ssrc of stats.keys()) {
const { codec, encodeTime, qualityLimitationReason, resolution, timestamp } = stats.get(ssrc);
const track = tpc.getTrackBySSRC(ssrc);
const trackId = track.rtcId.toString();
const trackId = track.rtcId;
let existingStats = statsPerTrack.get(trackId);
const encodeResolution = Math.min(resolution.height, resolution.width);
const ssrcStats = {
Expand Down Expand Up @@ -394,7 +399,7 @@ export class QualityController {
const encodeResolution: number = trackStats
.map((stat: ITrackStats) => stat.encodeResolution)
.reduce((resolution: number, currentValue: number) => Math.max(resolution, currentValue), 0);
const localTrack = this._conference.getLocalVideoTracks().find(t => t.rtcId.toString() === trackId);
const localTrack = this._conference.getLocalVideoTracks().find(t => t.rtcId === trackId);

const exisitingStats: FixedSizeArray = this._encodeTimeStats.get(trackId);
const sourceStats = {
Expand Down

0 comments on commit 9510231

Please sign in to comment.