Skip to content

Commit

Permalink
fix(presence) Send a presence update on every track replace operation.
Browse files Browse the repository at this point in the history
Removing and adding a track back to the conference doesn't generate new source signaling all the time so presence needs to be updated every single time.
Fixes https://community.jitsi.org/t/screen-share-doesnt-work-a-second-time-on-p2p/114024 and possibly #1997.
  • Loading branch information
jallamsetty1 committed May 2, 2022
1 parent 7251f3a commit ccf9ebe
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -1293,11 +1293,9 @@ JitsiConference.prototype.replaceTrack = function(oldTrack, newTrack) {
this._sendBridgeVideoTypeMessage(newTrack);
}

// updates presence when we replace the video tracks desktop with screen and screen with desktop
if (oldTrackBelongsToConference && oldTrack?.isVideoTrack()

// we do not want to send presence update during setEffect switching, which does remove and then add
&& !(oldTrack?._setEffectInProgress || newTrack?._setEffectInProgress)) {
// We do not want to send presence update during setEffect switching, which removes and then adds the same
// track back to the conference.
if (!(oldTrack?._setEffectInProgress || newTrack?._setEffectInProgress)) {
this._updateRoomPresence(this.getActiveMediaSession());
}

Expand Down Expand Up @@ -3649,9 +3647,9 @@ JitsiConference.prototype._updateRoomPresence = function(jingleSession, ctx) {

let presenceChanged = false;
let muteStatusChanged, videoTypeChanged;
const localTracks = this.getLocalTracks();
const localAudioTracks = jingleSession.peerconnection.getLocalTracks(MediaType.AUDIO);
const localVideoTracks = jingleSession.peerconnection.getLocalTracks(MediaType.VIDEO);
const localTracks = jingleSession.peerconnection.getLocalTracks();
const localAudioTracks = localTracks.filter(track => track.getType() === MediaType.AUDIO);
const localVideoTracks = localTracks.filter(track => track.getType() === MediaType.VIDEO);

// Set presence for all the available local tracks.
for (const track of localTracks) {
Expand Down

0 comments on commit ccf9ebe

Please sign in to comment.