Skip to content

Commit

Permalink
Merge pull request #88 from bigbluebutton/development
Browse files Browse the repository at this point in the history
v2.5.0-alpha.5
  • Loading branch information
prlanzarin authored Apr 16, 2021
2 parents c26960e + 24d7345 commit b73bd74
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
32 changes: 27 additions & 5 deletions lib/audio/AudioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const C = require('../bbb/messages/Constants');
const Logger = require('../utils/Logger');
const errors = require('../base/errors');
const config = require('config');
const ERRORS = require('../base/errors.js');

const { handleExternalConnections : FS_HANDLE_EXTERNAL_CONNECTIONS } = config.get('freeswitch');
const EJECT_ON_USER_LEFT = config.get('ejectOnUserLeft');
Expand Down Expand Up @@ -103,8 +104,8 @@ module.exports = class AudioManager extends BaseManager {
}
}

_handleStartError (error, sessionId, rawMessage) {
Logger.error(this._logPrefix, `Listen only listener failed`, {
_handleSessionWideError (error, sessionId, rawMessage) {
Logger.error(this._logPrefix, `Listen only session wide fatal failure`, {
errorMessage: error.message,
errorCode: error.code,
...AudioManager.getMetadataFromMessage(rawMessage),
Expand All @@ -118,6 +119,21 @@ module.exports = class AudioManager extends BaseManager {
}, C.FROM_AUDIO);
}

_handleListenerStartError (session, userConnectionId, error, rawMessage) {
Logger.error(this._logPrefix, `Listen only listener failure`, {
errorMessage: error.message,
errorCode: error.code,
...AudioManager.getMetadataFromMessage(rawMessage),
});

error.id = 'webRTCAudioError';
if (session) session.stopListener(userConnectionId);
this.sendToClient(({
type: 'audio',
...error,
}), C.FROM_AUDIO);
}

async handleStart (message) {
const {
connectionId,
Expand Down Expand Up @@ -147,7 +163,7 @@ module.exports = class AudioManager extends BaseManager {

session.once(C.MEDIA_SERVER_OFFLINE, async (event) => {
const errorMessage = this._handleError(this._logPrefix, connectionId, session.globalAudioBridge, C.RECV_ROLE, errors.MEDIA_SERVER_OFFLINE);
return this._handleStartError(errorMessage, sessionId, message);
return this._handleSessionWideError(errorMessage, sessionId, message);
});

this.sendToClient({
Expand All @@ -162,8 +178,14 @@ module.exports = class AudioManager extends BaseManager {
AudioManager.getMetadataFromMessage(message));
})
.catch(error => {
const errorMessage = this._handleError(this._logPrefix, connectionId, null, C.RECV_ROLE, error);
this._handleStartError(errorMessage, sessionId, message);
const normalizedError = this._handleError(this._logPrefix, connectionId, null, C.RECV_ROLE, error);
// Global audio bridge startup error; notify the listener and roll back session creation
if (error.code=== ERRORS.SFU_GLOBAL_AUDIO_FAILED.code) {
this._handleSessionWideError(normalizedError, sessionId, message);
} else {
// Listener-bound errors; rollback is done internally, just notify the user
this._handleListenerStartError(session, connectionId, normalizedError, message);
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/audio/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ module.exports = class Audio extends BaseProvider {
const normalizedError = this._handleError(LOG_PREFIX, error, "recv", userId);
Logger.error(LOG_PREFIX, `New listen only session failed: GLOBAL_AUDIO unavailable`,
{ ...this._getPartialLogMetadata(), error: normalizedError });
throw normalizedError;
throw errors.SFU_GLOBAL_AUDIO_FAILED;
}

try {
Expand Down
1 change: 1 addition & 0 deletions lib/base/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const errorCodes = {
2211: "MEDIA_NOT_FLOWING",
2300: "SFU_INVALID_REQUEST",
2301: "SFU_UNAUTHORIZED",
2302: "SFU_GLOBAL_AUDIO_FAILED",
}

const expandErrors = () => {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bbb-webrtc-sfu",
"version": "2.5.0-alpha.4",
"version": "2.5.0-alpha.5",
"private": true,
"scripts": {
"start": "node server.js",
Expand Down

0 comments on commit b73bd74

Please sign in to comment.