Skip to content

Commit

Permalink
Merge pull request #11032 from nextcloud/backport/11006/stable28
Browse files Browse the repository at this point in the history
[stable28] Fix lost audio track on safari
  • Loading branch information
nickvergessen authored Nov 29, 2023
2 parents f72670a + 1e1df17 commit 562f95c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/utils/webrtc/simplewebrtc/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import util from 'util'
import adapter from 'webrtc-adapter'
import webrtcSupport from 'webrtcsupport'
import WildEmitter from 'wildemitter'
import { isSafari } from '../../../utils/browserCheck.js'

/**
* @param {object} stream the stream object.
Expand Down Expand Up @@ -831,7 +832,10 @@ Peer.prototype._replaceTrack = async function(newTrack, oldTrack, stream) {
return
}

if (sender.track && newTrack && !newTrack.enabled) {
// When replacing with a null track on Safari the reference to the track is
// lost (setting trackDisabled is not enough). Therefore we keep the track
// intact and don't replace it with a null track.
if (sender.track && newTrack && !newTrack.enabled && !isSafari) {
// Replace with a null track to stop the sender.
newTrack = null
}
Expand Down Expand Up @@ -871,6 +875,8 @@ Peer.prototype.handleSentTrackEnabledChanged = function(track, stream) {
this.handleSentTrackReplacedBound(track, track, stream)
} else if (!track.enabled && sender) {
this.handleSentTrackReplacedBound(track, track, stream)
} else if (!sender && !stoppedSender) {
console.error('No sender found to handle localTrackEnabledChanged', track, stream)
}
}

Expand Down

0 comments on commit 562f95c

Please sign in to comment.