Merge pull request #13442 from ramonlsouza/port-13321-23

fix(audio): audio controls crash when ending call during breakout audio transfer (2.3)
This commit is contained in:
Anton Georgiev 2021-10-07 16:59:26 -04:00 committed by GitHub
commit 0bb3c606ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 1 deletions

View File

@ -98,6 +98,7 @@ class SIPSession {
this._hangupFlag = false;
this._reconnecting = false;
this._currentSessionState = null;
this._ignoreCallState = false;
}
get inputStream() {
@ -226,6 +227,24 @@ class SIPSession {
this._outputDeviceId = deviceId;
}
/**
* This _ignoreCallState flag is set to true when we want to ignore SIP's
* call state retrieved directly from FreeSWITCH ESL, when doing some checks
* (for example , when checking if call stopped).
* We need to ignore this , for example, when moderator is in
* breakout audio transfer ("Join Audio" button in breakout panel): in this
* case , we will monitor moderator's lifecycle in audio conference by
* using the SIP state taken from SIP.js only (ignoring the ESL's call state).
* @param {boolean} value true to ignore call state, false otherwise.
*/
set ignoreCallState(value) {
this._ignoreCallState = value;
}
get ignoreCallState() {
return this._ignoreCallState;
}
joinAudio({
isListenOnly,
extension,
@ -236,6 +255,8 @@ class SIPSession {
return new Promise((resolve, reject) => {
const callExtension = extension ? `${extension}${this.userData.voiceBridge}` : this.userData.voiceBridge;
this.ignoreCallState = false;
const callback = (message) => {
// There will sometimes we erroneous errors put out like timeouts and improper shutdowns,
// but only the first error ever matters
@ -1068,7 +1089,9 @@ class SIPSession {
};
const checkIfCallStopped = (message) => {
if (fsReady || !sessionTerminated) return null;
if ((!this.ignoreCallState && fsReady) || !sessionTerminated) {
return null;
}
if (!message && !!this.userRequestedHangup) {
return this.callback({
@ -1350,6 +1373,20 @@ export default class SIPBridge extends BaseAudioBridge {
return this.activeSession ? this.activeSession.inputStream : null;
}
/**
* Wrapper for SIPSession's ignoreCallState flag
* @param {boolean} value
*/
set ignoreCallState(value) {
if (this.activeSession) {
this.activeSession.ignoreCallState = value;
}
}
get ignoreCallState() {
return this.activeSession ? this.activeSession.ignoreCallState : false;
}
joinAudio({ isListenOnly, extension, validIceCandidates }, managerCallback) {
const hasFallbackDomain = typeof IPV4_FALLBACK_DOMAIN === 'string' && IPV4_FALLBACK_DOMAIN !== '';

View File

@ -631,6 +631,14 @@ class AudioManager {
if (typeof status === 'string') {
currentStatus.status = status;
if (this.bridge && !this.isListenOnly) {
if (status !== BREAKOUT_AUDIO_TRANSFER_STATES.CONNECTED) {
this.bridge.ignoreCallState = false;
} else {
this.bridge.ignoreCallState = true;
}
}
}
}