From 15946213cf442c19e190dc509baf95f2d6b1e0d5 Mon Sep 17 00:00:00 2001 From: Jaya Allamsetty <54324652+jallamsetty1@users.noreply.github.com> Date: Mon, 2 May 2022 11:14:56 -0400 Subject: [PATCH] fix(presence) Send a presence update on every track replace operation. 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 https://github.com/jitsi/lib-jitsi-meet/issues/1997. --- JitsiConference.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/JitsiConference.js b/JitsiConference.js index 08f5ea9a5d..e143c456b4 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -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()); } @@ -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) {