Skip to content

Commit

Permalink
fix(ssrc-rewriting) Update the track owner correctly.
Browse files Browse the repository at this point in the history
Fixes an issue when the track owner is not updated after a p2p->jvb switch right after leaving breakout room.
  • Loading branch information
jallamsetty1 committed Nov 13, 2023
1 parent 4588cc7 commit 6065bc5
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions modules/xmpp/JingleSessionPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -1783,48 +1783,48 @@ export default class JingleSessionPC extends JingleSession {
* @returns {void}
*/
processSourceMap(message, mediaType) {
if (!FeatureFlags.isSsrcRewritingSupported()) {
return;
}
const newSsrcs = [];

for (const src of message.mappedSources) {
// eslint-disable-next-line prefer-const
let { owner, source, ssrc } = src;
const { owner, source, ssrc } = src;
const isNewSsrc = this.peerconnection.addRemoteSsrc(ssrc, source);
let lookupSsrc = ssrc;

if (isNewSsrc) {
newSsrcs.push(src);
logger.debug(`New SSRC signaled ${ssrc}: owner=${owner}, source-name=${source}`);

// Check if there is an old mapping for the given source and clear the owner on the associated track.
const oldSsrc = this.peerconnection.remoteSources.get(source);

if (oldSsrc) {
lookupSsrc = oldSsrc;
owner = undefined;
source = undefined;
}
}
const track = this.peerconnection.getTrackBySSRC(lookupSsrc);
this._signalingLayer.removeSSRCOwners([ oldSsrc ]);
const track = this.peerconnection.getTrackBySSRC(oldSsrc);

if (track) {
logger.debug(`Existing SSRC ${ssrc}: new owner=${owner}, source-name=${source}`);
if (track) {
track.setSourceName(undefined);
track.setOwner(undefined);
track._setVideoType(undefined);
}
}
} else {
logger.debug(`Existing SSRC re-mapped ${ssrc}: new owner=${owner}, source-name=${source}`);
const track = this.peerconnection.getTrackBySSRC(ssrc);

// Update the SSRC owner.
this._signalingLayer.setSSRCOwner(ssrc, owner, source);

// Update the track with all the relevant info.
track.setSourceName(source);
track.setOwner(owner);

// Update the video type based on the type published by peer in its presence.
const { videoType } = this._signalingLayer.getPeerSourceInfo(owner, source);

track._setVideoType(videoType);

// Update the muted state on the track since the presence for this track could have been received
// before the updated source map is received on the bridge channel.
// Update the muted state and the video type on the track since the presence for this track could have
// been received before the updated source map is received on the bridge channel.
const peerMediaInfo = this._signalingLayer.getPeerMediaInfo(owner, mediaType, source);

peerMediaInfo && this.peerconnection._sourceMutedChanged(source, peerMediaInfo.muted);
if (peerMediaInfo) {
track._setVideoType(peerMediaInfo.videoType);
this.peerconnection._sourceMutedChanged(source, peerMediaInfo.muted);
}
}
}

Expand Down

0 comments on commit 6065bc5

Please sign in to comment.