summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2021-06-02 22:09:18 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2021-06-07 14:19:11 +0200
commit7936dab5cc0063efe00cdf06d4b6a9d25f025b93 (patch)
tree23989b416f6d0754ef0c0b0a35969dbb5d4591a9
parent7ea382176c4fcf95135557b80a3c2f9632942834 (diff)
Fix call flags not updated when disabling or reenabling devices
When a media device is disabled during a call its track is replaced with a null track in the peers, and if a media device is reenabled the null track is replaced with the new track. In both cases neither a renegotiation nor a reconnection is needed. Therefore the call flags have to be explicitly updated. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r--src/utils/signaling.js31
-rw-r--r--src/utils/webrtc/webrtc.js28
2 files changed, 54 insertions, 5 deletions
diff --git a/src/utils/signaling.js b/src/utils/signaling.js
index ae5f42225..a787805e8 100644
--- a/src/utils/signaling.js
+++ b/src/utils/signaling.js
@@ -176,6 +176,16 @@ Signaling.Base.prototype.leaveCurrentRoom = function() {
}
}
+Signaling.Base.prototype.updateCurrentCallFlags = function(flags) {
+ return new Promise((resolve, reject) => {
+ if (this.currentCallToken) {
+ this.updateCallFlags(this.currentCallToken, flags).then(() => { resolve() }).catch(reason => { reject(reason) })
+ } else {
+ resolve()
+ }
+ })
+}
+
Signaling.Base.prototype.leaveCurrentCall = function() {
return new Promise((resolve, reject) => {
if (this.currentCallToken) {
@@ -266,6 +276,27 @@ Signaling.Base.prototype._leaveCallSuccess = function(/* token */) {
// Override in subclasses if necessary.
}
+Signaling.Base.prototype.updateCallFlags = function(token, flags) {
+ return new Promise((resolve, reject) => {
+ if (!token) {
+ reject(new Error())
+ return
+ }
+
+ axios.put(generateOcsUrl('apps/spreed/api/v4/call/{token}', { token }), {
+ flags: flags,
+ })
+ .then(function() {
+ this.currentCallFlags = flags
+ this._trigger('updateCallFlags', [token, flags])
+ resolve()
+ }.bind(this))
+ .catch(function() {
+ reject(new Error())
+ })
+ })
+}
+
Signaling.Base.prototype.leaveCall = function(token, keepToken) {
return new Promise((resolve, reject) => {
if (!token) {
diff --git a/src/utils/webrtc/webrtc.js b/src/utils/webrtc/webrtc.js
index 28bb22be9..6b184823d 100644
--- a/src/utils/webrtc/webrtc.js
+++ b/src/utils/webrtc/webrtc.js
@@ -968,16 +968,34 @@ export default function initWebRTC(signaling, _callParticipantCollection, _local
}
})
- webrtc.on('localTrackReplaced', function(newTrack /*, oldTrack, stream */) {
- // Device disabled, nothing to do here.
+ webrtc.on('localTrackReplaced', function(newTrack, oldTrack/*, stream */) {
+ // Device disabled, just update the call flags.
if (!newTrack) {
+ if (oldTrack && oldTrack.kind === 'audio') {
+ signaling.updateCurrentCallFlags(signaling.getCurrentCallFlags() & ~PARTICIPANT.CALL_FLAG.WITH_AUDIO)
+ } else if (oldTrack && oldTrack.kind === 'video') {
+ signaling.updateCurrentCallFlags(signaling.getCurrentCallFlags() & ~PARTICIPANT.CALL_FLAG.WITH_VIDEO)
+ }
+
return
}
// If the call was started with media the connections will be already
- // established. If it has not started yet the connections will be
- // established once started.
- if (startedWithMedia || startedWithMedia === undefined) {
+ // established. The flags need to be updated if a device was enabled
+ // (but not if it was switched to another one).
+ if (startedWithMedia) {
+ if (newTrack.kind === 'audio' && !oldTrack) {
+ signaling.updateCurrentCallFlags(signaling.getCurrentCallFlags() | PARTICIPANT.CALL_FLAG.WITH_AUDIO)
+ } else if (newTrack.kind === 'video' && !oldTrack) {
+ signaling.updateCurrentCallFlags(signaling.getCurrentCallFlags() | PARTICIPANT.CALL_FLAG.WITH_VIDEO)
+ }
+
+ return
+ }
+
+ // If the call has not started with media yet the connections will be
+ // established once started, as well as the flags.
+ if (startedWithMedia === undefined) {
return
}