From 465ac2db745e8b19bc53af3af8a7efe3e9776acb Mon Sep 17 00:00:00 2001 From: Andrea Gianarda Date: Thu, 27 May 2021 14:37:37 +0200 Subject: [PATCH] Account for conference in audio route utils --- .../org/linphone/utils/AudioRouteUtils.kt | 63 ++++++++++++++----- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/linphone/utils/AudioRouteUtils.kt b/app/src/main/java/org/linphone/utils/AudioRouteUtils.kt index 56a51538c..0e97565eb 100644 --- a/app/src/main/java/org/linphone/utils/AudioRouteUtils.kt +++ b/app/src/main/java/org/linphone/utils/AudioRouteUtils.kt @@ -32,13 +32,20 @@ class AudioRouteUtils { return } val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] + val conference = coreContext.core.conference for (audioDevice in coreContext.core.audioDevices) { - if (audioDevice.type == AudioDevice.Type.Earpiece) { - Log.i("[Audio Route Helper] Found earpiece audio device [${audioDevice.deviceName}], routing audio to it") - currentCall.outputAudioDevice = audioDevice - return - } + if (audioDevice.type == AudioDevice.Type.Earpiece) { + if (conference != null && conference.isIn) { + Log.i("[Audio Route Helper] Found earpiece audio device [${audioDevice.deviceName}], routing audio of conference to it") + conference.outputAudioDevice = audioDevice + return + } else { + Log.i("[Audio Route Helper] Found earpiece audio device [${audioDevice.deviceName}], routing audio of call to it") + currentCall.outputAudioDevice = audioDevice + return + } + } } Log.e("[Audio Route Helper] Couldn't find earpiece audio device") } @@ -48,13 +55,21 @@ class AudioRouteUtils { Log.e("[Audio Route Helper] No call found, aborting speaker audio route change") return } + val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] + val conference = coreContext.core.conference for (audioDevice in coreContext.core.audioDevices) { if (audioDevice.type == AudioDevice.Type.Speaker) { - Log.i("[Audio Route Helper] Found speaker audio device [${audioDevice.deviceName}], routing audio to it") - currentCall.outputAudioDevice = audioDevice - return + if (conference != null && conference.isIn) { + Log.i("[Audio Route Helper] Found speaker audio device [${audioDevice.deviceName}], routing audio of conference to it") + conference.outputAudioDevice = audioDevice + return + } else { + Log.i("[Audio Route Helper] Found speaker audio device [${audioDevice.deviceName}], routing audio of call to it") + currentCall.outputAudioDevice = audioDevice + return + } } } Log.e("[Audio Route Helper] Couldn't find speaker audio device") @@ -66,13 +81,20 @@ class AudioRouteUtils { return } val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] + val conference = coreContext.core.conference for (audioDevice in coreContext.core.audioDevices) { if (audioDevice.type == AudioDevice.Type.Bluetooth) { if (audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) { - Log.i("[Audio Route Helper] Found bluetooth audio device [${audioDevice.deviceName}], routing audio to it") - currentCall.outputAudioDevice = audioDevice - return + if (conference != null && conference.isIn) { + Log.i("[Audio Route Helper] Found bluetooth audio device [${audioDevice.deviceName}], routing audio of conference to it") + conference.outputAudioDevice = audioDevice + return + } else { + Log.i("[Audio Route Helper] Found bluetooth audio device [${audioDevice.deviceName}], routing audio of call to it") + currentCall.outputAudioDevice = audioDevice + return + } } } } @@ -85,13 +107,20 @@ class AudioRouteUtils { return } val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] + val conference = coreContext.core.conference for (audioDevice in coreContext.core.audioDevices) { if (audioDevice.type == AudioDevice.Type.Headphones || audioDevice.type == AudioDevice.Type.Headset) { if (audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) { - Log.i("[Audio Route Helper] Found headset audio device [${audioDevice.deviceName}], routing audio to it") - currentCall.outputAudioDevice = audioDevice - return + if (conference != null && conference.isIn) { + Log.i("[Audio Route Helper] Found headset audio device [${audioDevice.deviceName}], routing audio of conference to it") + conference.outputAudioDevice = audioDevice + return + } else { + Log.i("[Audio Route Helper] Found headset audio device [${audioDevice.deviceName}], routing audio of call to it") + currentCall.outputAudioDevice = audioDevice + return + } } } } @@ -104,8 +133,9 @@ class AudioRouteUtils { return false } val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] + val conference = coreContext.core.conference - val audioDevice = currentCall.outputAudioDevice + val audioDevice = if (conference != null && conference.isIn) conference.outputAudioDevice else currentCall.outputAudioDevice Log.i("[Audio Route Helper] Audio device currently in use is [${audioDevice?.deviceName}] with type (${audioDevice?.type})") return audioDevice?.type == AudioDevice.Type.Speaker } @@ -116,8 +146,9 @@ class AudioRouteUtils { return false } val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] + val conference = coreContext.core.conference - val audioDevice = currentCall.outputAudioDevice + val audioDevice = if (conference != null && conference.isIn) conference.outputAudioDevice else currentCall.outputAudioDevice Log.i("[Audio Route Helper] Audio device currently in use is [${audioDevice?.deviceName}] with type (${audioDevice?.type})") return audioDevice?.type == AudioDevice.Type.Bluetooth }