Account for conference in audio route utils

This commit is contained in:
Andrea Gianarda 2021-05-27 14:37:37 +02:00 committed by Sylvain Berfini
parent 7f30e9d874
commit 465ac2db74

View file

@ -32,13 +32,20 @@ class AudioRouteUtils {
return return
} }
val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0]
val conference = coreContext.core.conference
for (audioDevice in coreContext.core.audioDevices) { for (audioDevice in coreContext.core.audioDevices) {
if (audioDevice.type == AudioDevice.Type.Earpiece) { if (audioDevice.type == AudioDevice.Type.Earpiece) {
Log.i("[Audio Route Helper] Found earpiece audio device [${audioDevice.deviceName}], routing audio to it") if (conference != null && conference.isIn) {
currentCall.outputAudioDevice = audioDevice Log.i("[Audio Route Helper] Found earpiece audio device [${audioDevice.deviceName}], routing audio of conference to it")
return 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") 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") Log.e("[Audio Route Helper] No call found, aborting speaker audio route change")
return return
} }
val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0]
val conference = coreContext.core.conference
for (audioDevice in coreContext.core.audioDevices) { for (audioDevice in coreContext.core.audioDevices) {
if (audioDevice.type == AudioDevice.Type.Speaker) { if (audioDevice.type == AudioDevice.Type.Speaker) {
Log.i("[Audio Route Helper] Found speaker audio device [${audioDevice.deviceName}], routing audio to it") if (conference != null && conference.isIn) {
currentCall.outputAudioDevice = audioDevice Log.i("[Audio Route Helper] Found speaker audio device [${audioDevice.deviceName}], routing audio of conference to it")
return 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") Log.e("[Audio Route Helper] Couldn't find speaker audio device")
@ -66,13 +81,20 @@ class AudioRouteUtils {
return return
} }
val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0]
val conference = coreContext.core.conference
for (audioDevice in coreContext.core.audioDevices) { for (audioDevice in coreContext.core.audioDevices) {
if (audioDevice.type == AudioDevice.Type.Bluetooth) { if (audioDevice.type == AudioDevice.Type.Bluetooth) {
if (audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) { if (audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) {
Log.i("[Audio Route Helper] Found bluetooth audio device [${audioDevice.deviceName}], routing audio to it") if (conference != null && conference.isIn) {
currentCall.outputAudioDevice = audioDevice Log.i("[Audio Route Helper] Found bluetooth audio device [${audioDevice.deviceName}], routing audio of conference to it")
return 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 return
} }
val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0]
val conference = coreContext.core.conference
for (audioDevice in coreContext.core.audioDevices) { for (audioDevice in coreContext.core.audioDevices) {
if (audioDevice.type == AudioDevice.Type.Headphones || audioDevice.type == AudioDevice.Type.Headset) { if (audioDevice.type == AudioDevice.Type.Headphones || audioDevice.type == AudioDevice.Type.Headset) {
if (audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) { if (audioDevice.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) {
Log.i("[Audio Route Helper] Found headset audio device [${audioDevice.deviceName}], routing audio to it") if (conference != null && conference.isIn) {
currentCall.outputAudioDevice = audioDevice Log.i("[Audio Route Helper] Found headset audio device [${audioDevice.deviceName}], routing audio of conference to it")
return 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 return false
} }
val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] 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})") Log.i("[Audio Route Helper] Audio device currently in use is [${audioDevice?.deviceName}] with type (${audioDevice?.type})")
return audioDevice?.type == AudioDevice.Type.Speaker return audioDevice?.type == AudioDevice.Type.Speaker
} }
@ -116,8 +146,9 @@ class AudioRouteUtils {
return false return false
} }
val currentCall = call ?: coreContext.core.currentCall ?: coreContext.core.calls[0] 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})") Log.i("[Audio Route Helper] Audio device currently in use is [${audioDevice?.deviceName}] with type (${audioDevice?.type})")
return audioDevice?.type == AudioDevice.Type.Bluetooth return audioDevice?.type == AudioDevice.Type.Bluetooth
} }