diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-02-04 00:46:53 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-04-20 17:02:58 +0300 |
commit | 48a74da64eac1a593116694f8c6ca299058f6304 (patch) | |
tree | 49a4a73c47a1645b98188dcd21bc9f65cb5b7ebb /src | |
parent | c313e70a6ec6180e64f09627172bf2ce9a7d5b2f (diff) |
Update connections rather than create new ones on "negotiationneeded"
When an offer is requested to the HPB the old connection is stopped and
a new one is created. If the HPB has support for updating the
subscribers this is now used instead when negotiation is needed, as this
prevents the existing connection (and thus the media) to be interrupted
during the renegotiation.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/signaling.js | 5 | ||||
-rw-r--r-- | src/utils/webrtc/webrtc.js | 23 |
2 files changed, 23 insertions, 5 deletions
diff --git a/src/utils/signaling.js b/src/utils/signaling.js index 6b6fbab32..c0d1fbb52 100644 --- a/src/utils/signaling.js +++ b/src/utils/signaling.js @@ -1292,7 +1292,7 @@ Signaling.Standalone.prototype.processRoomParticipantsEvent = function(data) { } } -Signaling.Standalone.prototype.requestOffer = function(sessionid, roomType) { +Signaling.Standalone.prototype.requestOffer = function(sessionid, roomType, sid = undefined) { if (!this.hasFeature('mcu')) { console.warn("Can't request an offer without a MCU.") return @@ -1302,7 +1302,7 @@ Signaling.Standalone.prototype.requestOffer = function(sessionid, roomType) { // Got a user object. sessionid = sessionid.sessionId || sessionid.sessionid } - console.debug('Request offer from', sessionid) + console.debug('Request offer from', sessionid, sid) this.doSend({ type: 'message', message: { @@ -1313,6 +1313,7 @@ Signaling.Standalone.prototype.requestOffer = function(sessionid, roomType) { data: { type: 'requestoffer', roomType, + sid, }, }, }) diff --git a/src/utils/webrtc/webrtc.js b/src/utils/webrtc/webrtc.js index c18b587de..c5b97f7ab 100644 --- a/src/utils/webrtc/webrtc.js +++ b/src/utils/webrtc/webrtc.js @@ -937,14 +937,31 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local // to force a full reconnection, it is enough to reconnect only that // peer. if (signaling.hasFeature('mcu') && peer.id !== signaling.getSessionId()) { - signaling.requestOffer(peer.id, 'video') + // If possible update connection rather than creating a new one. + let update = signaling.hasFeature('update-sdp') + + // Create a connection if the current one has failed, as it + // would require an ICE restart rather than update to recover. + if (update && (peer.pc.iceConnectionState === 'failed' || peer.pc.connectionState === 'failed')) { + update = false + } + + // If the connection needs to be updated but a new connection + // (or another update) is already pending ignore the new update. + // If a new connection needs to be created rather than updated + // then force it even if there is another one already pending. + if (update && delayedConnectionToPeer[peer.id]) { + return + } + + signaling.requestOffer(peer.id, 'video', update ? peer.sid : undefined) clearInterval(delayedConnectionToPeer[peer.id]) delayedConnectionToPeer[peer.id] = setInterval(function() { - console.debug('No offer received, request offer again', peer) + console.debug('No offer received, request offer again' + update ? '(update)' : '', peer) - signaling.requestOffer(peer.id, 'video') + signaling.requestOffer(peer.id, 'video', update ? peer.sid : undefined) }, 10000) return |