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): reconfigure the encodings to suspend/resume media after jvb<->p2p switch. #2485

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -1388,11 +1388,6 @@ JitsiConference.prototype._setupNewTrack = function(newTrack) {
this.rtc.addLocalTrack(newTrack);
newTrack.setConference(this);

// Suspend media on the inactive media session since it gets automatically enabled for a newly added source.
if (this.isP2PActive()) {
this._suspendMediaTransferForJvbConnection();
}

// Add event handlers.
newTrack.muteHandler = this._fireMuteChangeEvent.bind(this, newTrack);
newTrack.addEventListener(JitsiTrackEvents.TRACK_MUTE_CHANGED, newTrack.muteHandler);
Expand Down
19 changes: 11 additions & 8 deletions modules/RTC/TPCUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,20 +409,23 @@ export class TPCUtils {
const encodingsState = videoStreamEncodings
.map(encoding => height / encoding.scaleResolutionDownBy)
.map((frameHeight, idx) => {
let activeState = false;

// When video is suspended on the media session.
if (!this.pc.videoTransferActive) {
return activeState;
}

// Single video stream.
if (!this.pc.isSpatialScalabilityOn() || this._isRunningInFullSvcMode(codec)) {
const { active } = this._calculateActiveEncodingParams(localVideoTrack, codec, newHeight);

return idx === 0 ? active : false;
return idx === 0 ? active : activeState;
}

// Multiple video streams.
let active = false;

if (newHeight > 0) {
if (localVideoTrack.getVideoType() === VideoType.CAMERA) {

active = frameHeight <= newHeight
activeState = frameHeight <= newHeight

// Keep the LD stream enabled even when the LD stream's resolution is higher than of the
// requested resolution. This can happen when camera is captured at high resolutions like 4k
Expand All @@ -433,12 +436,12 @@ export class TPCUtils {
} else {
// For screenshare, keep the HD layer enabled always and the lower layers only for high fps
// screensharing.
active = videoStreamEncodings[idx].scaleResolutionDownBy === SIM_LAYERS[2].scaleFactor
activeState = videoStreamEncodings[idx].scaleResolutionDownBy === SIM_LAYERS[2].scaleFactor
|| !this._isScreenshareBitrateCapped(localVideoTrack);
}
}

return active;
return activeState;
});

return encodingsState;
Expand Down
Loading
Loading