diff --git a/bigbluebutton-html5/public/compatibility/kurento-extension.js b/bigbluebutton-html5/public/compatibility/kurento-extension.js index 336a56144dbce7684fe37edd130201d17a25a0df..2c9298c441058b58aa62b849f5cc3d91add04261 100755 --- a/bigbluebutton-html5/public/compatibility/kurento-extension.js +++ b/bigbluebutton-html5/public/compatibility/kurento-extension.js @@ -243,12 +243,11 @@ Kurento.prototype.init = function () { }; this.ws.onerror = (error) => { kurentoManager.exitScreenShare(); - const { errorMessage, errorCode, errorReason } = this.normalizeError(error); this.logger.error({ logCode: 'kurentoextension_websocket_error', - extraInfo: { errorMessage, errorCode, errorReason }, + extraInfo: { errorMessage: error.name || error.message || 'Unknown error' } }, 'Error in the WebSocket connection to SFU, screenshare/listen only will drop'); - self.onFail({ errorMessage, errorCode, errorReason }); + self.onFail('Websocket connection error'); }; this.ws.onopen = function () { self.pingInterval = setInterval(self.ping.bind(self), self.PING_INTERVAL); @@ -302,11 +301,10 @@ Kurento.prototype.processIceQueue = function () { // Just log the error. We can't be sure if a candidate failure on add is // fatal or not, so that's why we have a timeout set up for negotiations and // listeners for ICE state transitioning to failures, so we won't act on it here - const { errorMessage, errorCode, errorReason } = this.normalizeError(error); this.logger.error({ logCode: 'kurentoextension_addicecandidate_error', - extraInfo: { errorMessage, errorCode, errorReason }, - }, `Adding ICE candidate failed due to ${errorMessage}`); + extraInfo: { errorMessage: error.name || error.message || 'Unknown error' }, + }, `Adding ICE candidate failed due to ${error.message}`); } }); } @@ -320,11 +318,10 @@ Kurento.prototype.handleIceCandidate = function (candidate) { // Just log the error. We can't be sure if a candidate failure on add is // fatal or not, so that's why we have a timeout set up for negotiations and // listeners for ICE state transitioning to failures, so we won't act on it here - const { errorMessage, errorCode, errorReason } = this.normalizeError(error); this.logger.error({ logCode: 'kurentoextension_addicecandidate_error', - extraInfo: { errorMessage, errorCode, errorReason }, - }, `Adding ICE candidate failed due to ${errorMessage}`); + extraInfo: { errorMessage: error.name || error.message || 'Unknown error' }, + }, `Adding ICE candidate failed due to ${error.message}`); } }); } else { @@ -336,14 +333,6 @@ Kurento.prototype.handleIceCandidate = function (candidate) { } } -Kurento.prototype.normalizeError = function (error = {}) { - const errorMessage = error.message || error.name || error.reason || 'Unknown error'; - const errorCode = error.code || 'Undefined code'; - const errorReason = error.reason || error.id || 'Undefined reason'; - - return { errorMessage, errorCode, errorReason }; -} - Kurento.prototype.startResponse = function (message) { if (message.response !== 'accepted') { this.handleSFUError(message); @@ -355,13 +344,14 @@ Kurento.prototype.startResponse = function (message) { this.webRtcPeer.processAnswer(message.sdpAnswer, (error) => { if (error) { - const { errorMessage, errorCode, errorReason } = this.normalizeError(error); this.logger.error({ logCode: 'kurentoextension_peerconnection_processanswer_error', - extraInfo: { errorMessage, errorCode, errorReason }, - }, `Processing SDP answer from SFU for failed due to ${errorMessage}`); + extraInfo: { + errorMessage: error.name || error.message || 'Unknown error', + }, + }, `Processing SDP answer from SFU for failed due to ${error.message}`); - return this.onFail({ errorMessage, errorCode, errorReason }); + return this.onFail(error); } // Mark the peer as negotiated and flush the ICE queue this.webRtcPeer.negotiated = true; @@ -400,19 +390,18 @@ Kurento.prototype.handleSFUError = function (sfuResponse) { break; } - this.onFail({ errorMessage: reason, errorCode: code, errorReason: reason }); + this.onFail( { code, reason } ); }; Kurento.prototype.onOfferPresenter = function (error, offerSdp) { const self = this; if (error) { - const { errorMessage, errorCode, errorReason } = this.normalizeError(error); this.logger.error({ logCode: 'kurentoextension_screenshare_presenter_offer_failure', - extraInfo: { errorMessage, errorCode, errorReason }, + extraInfo: { errorMessage: error.name || error.message || 'Unknown error' }, }, `Failed to generate peer connection offer for screenshare presenter with error ${error.message}`); - this.onFail({ errorMessage, errorCode, errorReason }); + this.onFail(error); return; } @@ -472,12 +461,11 @@ Kurento.prototype.startScreensharing = function () { this.webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options, (error) => { if (error) { - const { errorMessage, errorCode, errorReason } = this.normalizeError(error); this.logger.error({ logCode: 'kurentoextension_screenshare_peerconnection_create_error', - extraInfo: { errorMessage, errorCode, errorReason }, + extraInfo: { errorMessage: error.name || error.message || 'Unknown error' }, }, `WebRTC peer constructor for screenshare (presenter) failed due to ${error.message}`); - this.onFail({ errorMessage, errorCode, errorReason }); + this.onFail(error); return kurentoManager.exitScreenShare(); } @@ -577,13 +565,12 @@ Kurento.prototype.viewer = function () { Kurento.prototype.onOfferViewer = function (error, offerSdp) { const self = this; if (error) { - const { errorMessage, errorCode, errorReason } = this.normalizeError(error); this.logger.error({ logCode: 'kurentoextension_screenshare_viewer_offer_failure', - extraInfo: { errorMessage, errorCode, errorReason }, + extraInfo: { errorMessage: error.name || error.message || 'Unknown error' }, }, `Failed to generate peer connection offer for screenshare viewer with error ${error.message}`); - return this.onFail({ errorMessage, errorCode, errorReason }); + return this.onFail(error); } const message = { @@ -660,13 +647,12 @@ Kurento.prototype.onListenOnlyIceCandidate = function (candidate) { Kurento.prototype.onOfferListenOnly = function (error, offerSdp) { const self = this; if (error) { - const { errorMessage, errorCode, errorReason } = this.normalizeError(error); this.logger.error({ logCode: 'kurentoextension_listenonly_offer_failure', - extraInfo: { errorMessage, errorCode, errorReason }, + extraInfo: { errorMessage: error.name || error.message || 'Unknown error' }, }, `Failed to generate peer connection offer for listen only with error ${error.message}`); - return this.onFail({ errorMessage, errorCode, errorReason }); + return this.onFail(error); } const message = {