Skip to content
Prev Previous commit
Next Next commit
Extract function to send current media state
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Sep 25, 2020
commit e3741565dc96073267e506d89f1b01fcf61035a9
25 changes: 15 additions & 10 deletions src/utils/webrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ function checkStartPublishOwnPeer(signaling) {
localCallParticipantModel.setPeer(ownPeer)
}

function sendCurrentMediaState() {
if (!webrtc.webrtc.isVideoEnabled()) {
webrtc.webrtc.emit('videoOff')
} else {
webrtc.webrtc.emit('videoOn')
}
if (!webrtc.webrtc.isAudioEnabled()) {
webrtc.webrtc.emit('audioOff')
} else {
webrtc.webrtc.emit('audioOn')
}
}

function userHasStreams(user) {
let flags = user
if (flags.hasOwnProperty('inCall')) {
Expand Down Expand Up @@ -485,16 +498,8 @@ export default function initWebRTC(signaling, _callParticipantCollection, _local
function handleIceConnectionStateConnected(peer) {
// Send the current information about the video and microphone
// state.
if (!webrtc.webrtc.isVideoEnabled()) {
webrtc.webrtc.emit('videoOff')
} else {
webrtc.webrtc.emit('videoOn')
}
if (!webrtc.webrtc.isAudioEnabled()) {
webrtc.webrtc.emit('audioOff')
} else {
webrtc.webrtc.emit('audioOn')
}
sendCurrentMediaState()

if (signaling.settings.userId === null) {
const currentGuestNick = store.getters.getDisplayName()
sendDataChannelToAll('status', 'nickChanged', currentGuestNick)
Expand Down