diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-02-10 21:27:26 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-12-01 01:04:56 +0100 |
commit | f411881aa8eec342638b9f6a14260e280e7c502a (patch) | |
tree | 1ba5942b252ff7c7b84790f84d7b50b167fc47f8 | |
parent | af835fccaca3017cc1f1c8168400df94f57cc35b (diff) |
Use renegotiations to update publisher connections with the HPB
When the HPB supports the "update-sdp" feature sending an updated offer
for a publisher will propagate the renegotiation to the subscribers as
well. Therefore, in those cases there is no need to force a
reconnection, it is enough to send the new offer to trigger the
renegotiation (given that, in their latest versions, all the clients
will handle the updated offer using the current connection).
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r-- | src/utils/webrtc/webrtc.js | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/utils/webrtc/webrtc.js b/src/utils/webrtc/webrtc.js index c84e83ce5..e6f47c1f4 100644 --- a/src/utils/webrtc/webrtc.js +++ b/src/utils/webrtc/webrtc.js @@ -1034,7 +1034,16 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local // one forced reconnection even if there are several peers. // FIXME: despite all of the above this is a dirty and ugly hack // that should be fixed with proper renegotiation. - forceReconnect(signaling, flags) + if (signaling.hasFeature('mcu') && signaling.hasFeature('update-sdp') && peer === ownPeer) { + // The handler for "localTrackReplaced" already updated the + // flags, so it is not needed to do it again (in the case of + // forced reconnection it is, as otherwise it will reconnect + // with the current flags, which may not have been updated + // yet after the request). + peer.start() + } else { + forceReconnect(signaling, flags) + } } }) } @@ -1126,6 +1135,11 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local // point it is not possible to know if that will happen (getting the // new track is an async operation and it could fail), so the flags // are updated only with the known values. + // + // Note that, when the HPB is used, it is not possible to + // renegotiate the existing connection to remove the sender, as the + // HPB will immediately close the connection as soon as the + // publishing permission of an active media is revoked. forceReconnect(signaling, flags) return @@ -1393,7 +1407,12 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local let flags = signaling.getCurrentCallFlags() flags |= PARTICIPANT.CALL_FLAG.WITH_VIDEO - forceReconnect(signaling, flags) + if (signaling.hasFeature('mcu') && signaling.hasFeature('update-sdp') && ownPeer) { + signaling.updateCurrentCallFlags(flags) + ownPeer.start() + } else { + forceReconnect(signaling, flags) + } }) webrtc.webrtc.on('iceFailed', function(/* peer */) { |