Skip to content

Commit

Permalink
fix(TPC): Use a default maxHeight for configuring encodings.
Browse files Browse the repository at this point in the history
This is needed when p2p conn establishes before jvb and no sender constraints have been received before media on jvb conn is suspended.
  • Loading branch information
jallamsetty1 committed Mar 28, 2024
1 parent b564cbf commit 9b5cde3
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit 9b5cde3

Please sign in to comment.