From 555a8f652209bc936a435867f0a6b70c72b7e3d8 Mon Sep 17 00:00:00 2001 From: prlanzarin <4529051+prlanzarin@users.noreply.github.com> Date: Wed, 10 Apr 2024 21:25:40 -0300 Subject: [PATCH] fix(audio): acquire streams before negotiation when peer is answerer When a sendrecv peer acts as the answerer, gUM is only called _after_ the remote offer is received. This is fine, but the error handling runs different in that scenario in a way that eventual gUM errors are treated as negotiation errors, leading to inconsistencies when surfacing the error to end users. If a peer is acting as answerer and is a transceiver, acquire the local streams _before_ actual negotiation so that gUM errors are surfaced correctly (and we spare uneeded negotiation steps). --- .../ui/services/bbb-webrtc-sfu/audio-broker.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bigbluebutton-html5/imports/ui/services/bbb-webrtc-sfu/audio-broker.js b/bigbluebutton-html5/imports/ui/services/bbb-webrtc-sfu/audio-broker.js index 3d59f35c42..fcfb576e95 100644 --- a/bigbluebutton-html5/imports/ui/services/bbb-webrtc-sfu/audio-broker.js +++ b/bigbluebutton-html5/imports/ui/services/bbb-webrtc-sfu/audio-broker.js @@ -97,11 +97,20 @@ class AudioBroker extends BaseBroker { this.webRtcPeer.peerConnection.onconnectionstatechange = this.handleConnectionStateChange.bind(this); if (this.offering) { + // We are the offerer this.webRtcPeer.generateOffer() .then(this.sendStartReq.bind(this)) .catch(this._handleOfferGenerationFailure.bind(this)); - } else { + } else if (peerRole === 'recvonly') { + // We are the answerer and we are only listening, so we don't need + // to acquire local media this.sendStartReq(); + } else { + // We are the answerer and we are sending audio, so we need to acquire + // local media before sending the start request + this.webRtcPeer.mediaStreamFactory() + .then(() => { this.sendStartReq(); }) + .catch(this._handleOfferGenerationFailure.bind(this)); } resolve();