Skip to content

Commit

Permalink
Merge pull request #10913 from nextcloud/fix/6094/safari-mute-unmute
Browse files Browse the repository at this point in the history
Keep track of senders to allow unmutung with Safari
  • Loading branch information
nickvergessen authored Nov 16, 2023
2 parents fa18c0c + bf576c5 commit 3e3ec78
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/utils/webrtc/simplewebrtc/peer.js
Original file line number Diff line number Diff line change
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

0 comments on commit 3e3ec78

Please sign in to comment.