Skip to content

Commit

Permalink
Stop checking for peer media if audio/video status is received
Browse files Browse the repository at this point in the history
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 <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Sep 25, 2020
1 parent cfdcddb commit 1440652
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit 1440652

Please sign in to comment.