Skip to content
Prev Previous commit
Stop checking for peer media if audio/video status is received
As until now the initial media state message was sent just once and it
could be missed the received media was locally checked to enable the
media if needed. Unfortunately those checks were not as reliable as
desirable, so now they are stopped as soon as a media state message from
from the other peer is received. This implicitly fixes things like
never stopping checking the video if the other peer has no camera
enabled.

The checks can not be fully removed yet, as the repeated sending of
initial media state is currently implemented only in the WebUI, but not
in the mobile apps.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and backportbot[bot] committed Oct 15, 2020
commit a664b76eea11a8f422c2505ad55748b6c3a00a03
22 changes: 22 additions & 0 deletions src/utils/webrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,28 @@ export default function initWebRTC(signaling, _callParticipantCollection, _local
peer.check_video_interval = null
}

function stopPeerIdCheckMediaType(peerId, mediaType) {
// There should be just one video peer with that id, but iterating is
// safer.
const peers = webrtc.getPeers(peerId, 'video')
peers.forEach(function(peer) {
if (mediaType === 'audio') {
stopPeerCheckAudioMedia(peer)
} else if (mediaType === 'video') {
stopPeerCheckVideoMedia(peer)
}
})
}

if (signaling.hasFeature('mcu')) {
webrtc.on('mute', function(data) {
stopPeerIdCheckMediaType(data.id, data.name)
})
webrtc.on('unmute', function(data) {
stopPeerIdCheckMediaType(data.id, data.name)
})
}

function stopPeerCheckMedia(peer) {
stopPeerCheckAudioMedia(peer)
stopPeerCheckVideoMedia(peer)
Expand Down