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(RTC): Set transceiver direction after RTCRtpSender#replaceTrack. #1618

Merged
merged 8 commits into from
May 26, 2021

Conversation

jallamsetty1
Copy link
Member

This fixes the issue where TRACK_REMOVED event is not fired when a remote track is removed from the peerconnection.
Fixes #1612 and jitsi/jitsi-meet#8482.

@jallamsetty1 jallamsetty1 force-pushed the fix-replaceTrack branch 2 times, most recently from 957a6b4 to 37a0e71 Compare May 20, 2021 22:08
@jallamsetty1 jallamsetty1 requested a review from paweldomas May 20, 2021 22:16
modules/RTC/TPCUtils.js Outdated Show resolved Hide resolved
const transceiver = oldTrack.isVideoTrack() && browser.doesVideoMuteByStreamRemove && oldTrack.isMuted()
? this._findTransceiver(mediaType)
: this._findTransceiver(mediaType, oldTrack);
const track = mediaType === MediaType.AUDIO ? stream.getAudioTracks()[0] : stream.getVideoTracks()[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to fetch the track this way? shouldn't it be accessible from the newTrack via getTrack() getter?
Btw. naming of jitsi tracks and webrtc media stream/tracks is very confusing. Maybe it would help to rename the arguments to oldJitsiTrack and newJitsiTrack.

this.pc.localTracks.delete(oldTrack.rtcId);
this.pc.localSSRCs.delete(oldTrack.rtcId);
});
} else if (newTrack && !oldTrack) {
const ssrc = this.pc.localSSRCs.get(newTrack.rtcId);

return this.addTrackUnmute(newTrack)
.then(() => this.setEncodings(newTrack))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is setEncodings needed for the if (oldTrack && newTrack) case as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed if there was a source already and only the stream is being replaced on the sender. However, if the client starts muted and the source is being added on unmute, then the encodings need to be configured.

modules/RTC/TraceablePeerConnection.js Show resolved Hide resolved
This fixes the issue where TRACK_REMOVED event is not fired when a remote track is removed from the peerconnection.
Fixes jitsi#1612 and jitsi/jitsi-meet#8482.
If the msid attribute is missing, then remove the ssrc from the transformed description so that a source-remove is signaled to Jicofo. This happens when the direction of the transceiver (or m-line) is set to 'inactive' or 'recvonly' on Firefox. Not signaling these source updates creates issues with remote track handling on the other endpoints in the call.
The tracks will not be added when the call switches from jvb to p2p for an endpoint that joins muted by focus.
… or 'recvonly'.

This is needed only for JVB connections. Add unit tests for LocalSdpMunger.
…e ssrcs.

The direction was marked as 'inactive' only on Firefox as Safari had audio issues when an inactive mid is re-used. Chrome (in unified-plan) needs the direction of the mid in remote desc to be set to 'inactive' for a 'removetrack' to be fired on the associated media stream whenever a remote source is removed.
@jallamsetty1 jallamsetty1 requested a review from paweldomas May 26, 2021 14:34
!msidExists && mediaSection.ssrcs.push({
id: source,
attribute: 'msid',
value: `${this.localEndpointId}-${mediaSection.mLine?.type}-${pcId} ${trackId}-${pcId}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we extract msid generation into a function? it seems to be duplicated with the logic at line 190?

@jallamsetty1 jallamsetty1 merged commit be3e2a6 into jitsi:master May 26, 2021
@jallamsetty1 jallamsetty1 deleted the fix-replaceTrack branch May 26, 2021 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Safari: RTCRtpTransceiver for video not found
2 participants