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

Keep track of senders to allow unmutung with Safari #10913

Merged
merged 1 commit into from Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/utils/webrtc/simplewebrtc/peer.js
Expand Up @@ -41,6 +41,7 @@ function Peer(options) {
this._pendingReplaceTracksQueue = []
this._processPendingReplaceTracksPromise = null
this._initialStreamSetup = false
this._localSenders = []
this.sid = options.sid || Date.now().toString()
this.pc = new RTCPeerConnection(this.parent.config.peerConnectionConfig)
this.pc.addEventListener('icecandidate', this.onIceCandidate.bind(this))
Expand Down Expand Up @@ -674,6 +675,7 @@ Peer.prototype.end = function() {
}
this.pc.close()
this.handleStreamRemoved()
this._localSenders = []
this.parent.off('sentTrackReplaced', this.handleSentTrackReplacedBound)
this.parent.off('sentTrackEnabledChanged', this.handleSentTrackEnabledChangedBound)

Expand Down Expand Up @@ -770,7 +772,10 @@ Peer.prototype._replaceTrack = async function(newTrack, oldTrack, stream) {
// is used to be on the safe side.
const replaceTrackPromises = []

this.pc.getSenders().forEach(sender => {
for (const sender of this.pc.getSenders()) {
// Keep reference, so that safari does not remove the tracks
this._localSenders.push(sender)

if (sender.track !== oldTrack && sender.trackDisabled !== oldTrack) {
return
}
Expand Down Expand Up @@ -849,7 +854,7 @@ Peer.prototype._replaceTrack = async function(newTrack, oldTrack, stream) {
})

replaceTrackPromises.push(replaceTrackPromise)
})
}

// If the call started when the audio or video device was not active there
// will be no sender for that type. In that case the track needs to be added
Expand Down