summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaksim Sukharev <antreesy.web@gmail.com>2023-07-28 10:03:28 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-08-08 11:00:07 +0000
commit2d1cf5e75908a3245594014fc3d90121b501690f (patch)
treef15beef3eab985bfdee8cf3792131a1569afde62
parentd30cfdbeb7c4c7469945aef288fd6ffcfac4f0d6 (diff)
notify users who joined call if currently speaking
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
-rw-r--r--src/utils/webrtc/simplewebrtc/localmedia.js7
-rw-r--r--src/utils/webrtc/webrtc.js10
2 files changed, 15 insertions, 2 deletions
diff --git a/src/utils/webrtc/simplewebrtc/localmedia.js b/src/utils/webrtc/simplewebrtc/localmedia.js
index 916432755..2a287a0e7 100644
--- a/src/utils/webrtc/simplewebrtc/localmedia.js
+++ b/src/utils/webrtc/simplewebrtc/localmedia.js
@@ -63,15 +63,18 @@ function LocalMedia(opts) {
this._blackVideoEnforcer = new BlackVideoEnforcer()
+ this._speaking = undefined
this._speakingMonitor = new SpeakingMonitor()
this._speakingMonitor.on('speaking', () => {
this.emit('speaking')
+ this._speaking = true
})
this._speakingMonitor.on('speakingWhileMuted', () => {
this.emit('speakingWhileMuted')
})
this._speakingMonitor.on('stoppedSpeaking', () => {
this.emit('stoppedSpeaking')
+ this._speaking = false
})
this._speakingMonitor.on('stoppedSpeakingWhileMuted', () => {
this.emit('stoppedSpeakingWhileMuted')
@@ -416,6 +419,10 @@ LocalMedia.prototype._setVideoEnabled = function(bool) {
this._videoTrackEnabler.setEnabled(bool)
}
+LocalMedia.prototype.isSpeaking = function() {
+ return this._speaking
+}
+
// check if all audio streams are enabled
LocalMedia.prototype.isAudioEnabled = function() {
let enabled = true
diff --git a/src/utils/webrtc/webrtc.js b/src/utils/webrtc/webrtc.js
index 526d7b139..71f062bbf 100644
--- a/src/utils/webrtc/webrtc.js
+++ b/src/utils/webrtc/webrtc.js
@@ -211,6 +211,12 @@ function sendCurrentMediaState() {
webrtc.webrtc.emit('audioOff')
} else {
webrtc.webrtc.emit('audioOn')
+
+ if (!webrtc.webrtc.isSpeaking()) {
+ webrtc.webrtc.emit('stoppedSpeaking')
+ } else {
+ webrtc.webrtc.emit('speaking')
+ }
}
}
@@ -1601,7 +1607,7 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local
const name = typeof (data.payload) === 'string' ? data.payload : data.payload.name
webrtc.emit('nick', { id: peer.id, name })
} else if (data.type === 'speaking' || data.type === 'stoppedSpeaking') {
- // Valid known messages, but handled elsewhere
+ // Valid known messages, handled by CallParticipantModel.js
} else {
console.debug('Unknown message type %s from %s datachannel', data.type, label, data, peer.id, peer)
}
@@ -1633,10 +1639,10 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local
}
})
+ // Send the speaking status events via data channel
webrtc.on('speaking', function() {
sendDataChannelToAll('status', 'speaking')
})
-
webrtc.on('stoppedSpeaking', function() {
sendDataChannelToAll('status', 'stoppedSpeaking')
})