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

fix(TPC): Use a default maxHeight for configuring encodings. #2496

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
12 changes: 9 additions & 3 deletions modules/RTC/TraceablePeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,8 @@ TraceablePeerConnection.prototype.configureAudioSenderEncodings = function(local
};

/**
* Configures the stream encodings depending on the video type and the bitrates configured.
* Configures the stream encodings depending on the video type, scalability mode and the bitrate settings for the codec
* that is currently selected.
*
* @param {JitsiLocalTrack} - The local track for which the sender encodings have to configured.
* @returns {Promise} promise that will be resolved when the operation is successful and rejected otherwise.
Expand All @@ -2099,7 +2100,9 @@ TraceablePeerConnection.prototype.configureVideoSenderEncodings = function(local
const promises = [];

for (const track of this.getLocalVideoTracks()) {
promises.push(this.setSenderVideoConstraints(this._senderMaxHeights.get(track.getSourceName()), track));
const maxHeight = this._senderMaxHeights.get(track.getSourceName()) ?? VIDEO_QUALITY_LEVELS[0].height;

promises.push(this.setSenderVideoConstraints(maxHeight, track));
}

return Promise.allSettled(promises);
Expand Down Expand Up @@ -2271,6 +2274,7 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe
const activeState = this.tpcUtils.calculateEncodingsActiveState(localVideoTrack, codec, frameHeight);
const scaleFactors = this.tpcUtils.calculateEncodingsScaleFactor(localVideoTrack, codec, frameHeight);
const scalabilityModes = this.tpcUtils.calculateEncodingsScalabilityMode(localVideoTrack, codec, frameHeight);
const sourceName = localVideoTrack.getSourceName();
let needsUpdate = false;

for (const idx in parameters.encodings) {
Expand Down Expand Up @@ -2320,13 +2324,15 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe
}

if (!needsUpdate) {
this._senderMaxHeights.set(sourceName, frameHeight);

return Promise.resolve();
}

logger.info(`${this} setting max height=${frameHeight},encodings=${JSON.stringify(parameters.encodings)}`);

return videoSender.setParameters(parameters).then(() => {
this._senderMaxHeights.set(localVideoTrack.getSourceName(), frameHeight);
this._senderMaxHeights.set(sourceName, frameHeight);
localVideoTrack.maxEnabledResolution = frameHeight;
this.eventEmitter.emit(RTCEvents.LOCAL_TRACK_MAX_ENABLED_RESOLUTION_CHANGED, localVideoTrack);
});
Expand Down
Loading