Fixed speaker not activated when video call is started + prevent switch to speaker if using wired headset

This commit is contained in:
Sylvain Berfini 2021-03-23 13:53:51 +01:00
parent 39b3b4580a
commit f5c2be45c0
3 changed files with 27 additions and 8 deletions

View file

@ -205,6 +205,20 @@ public class AndroidAudioManager {
return false; return false;
} }
public synchronized boolean isWiredHeadsetAvailable() {
for (AudioDevice audioDevice : LinphoneManager.getCore().getExtendedAudioDevices()) {
Log.e("# AUDIO DEVICE TYPE IS " + audioDevice.getType().name());
if (audioDevice.getType() == AudioDevice.Type.Headphones
|| audioDevice.getType() == AudioDevice.Type.Headset) {
Log.i(
"[Audio Manager] Found headset/headphone device: ",
audioDevice.getDeviceName());
return true;
}
}
return false;
}
public synchronized void routeAudioToBluetooth() { public synchronized void routeAudioToBluetooth() {
if (LinphoneManager.getCore().getCallsNb() == 0) return; if (LinphoneManager.getCore().getCallsNb() == 0) return;
Call currentCall = LinphoneManager.getCore().getCurrentCall(); Call currentCall = LinphoneManager.getCore().getCurrentCall();

View file

@ -407,15 +407,16 @@ public class CallActivity extends LinphoneGenericActivity
} else if (state == Call.State.StreamsRunning) { } else if (state == Call.State.StreamsRunning) {
mCallPausedByRemote.setVisibility(View.GONE); mCallPausedByRemote.setVisibility(View.GONE);
setCurrentCallContactInformation();
updateInterfaceDependingOnVideo();
} else if (state == Call.State.Updating) {
if (call.getCurrentParams().videoEnabled()) { if (call.getCurrentParams().videoEnabled()) {
if (!LinphoneManager.getAudioManager() AndroidAudioManager manager = LinphoneManager.getAudioManager();
.isUsingBluetoothAudioRoute()) { if (!manager.isUsingBluetoothAudioRoute()
&& !manager.isWiredHeadsetAvailable()) {
LinphoneManager.getAudioManager().routeAudioToSpeaker(); LinphoneManager.getAudioManager().routeAudioToSpeaker();
} }
} }
setCurrentCallContactInformation();
updateInterfaceDependingOnVideo();
} else if (state == Call.State.UpdatedByRemote) { } else if (state == Call.State.UpdatedByRemote) {
// If the correspondent asks for video while in audio call // If the correspondent asks for video while in audio call
boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled(); boolean videoEnabled = LinphonePreferences.instance().isVideoEnabled();
@ -464,11 +465,14 @@ public class CallActivity extends LinphoneGenericActivity
if (videoEnabled) { if (videoEnabled) {
mAudioManager = LinphoneManager.getAudioManager(); mAudioManager = LinphoneManager.getAudioManager();
if (!mAudioManager.isWiredHeadsetAvailable()
&& !mAudioManager.isUsingBluetoothAudioRoute()) {
mAudioManager.routeAudioToSpeaker(); mAudioManager.routeAudioToSpeaker();
mSpeaker.setSelected(true); mSpeaker.setSelected(true);
} }
} }
} }
}
@Override @Override
protected void onStart() { protected void onStart() {

View file

@ -145,7 +145,8 @@ public class CallManager {
core.enableVideoCapture(true); core.enableVideoCapture(true);
core.enableVideoDisplay(true); core.enableVideoDisplay(true);
if (!LinphoneManager.getAudioManager().isUsingBluetoothAudioRoute()) { if (!LinphoneManager.getAudioManager().isUsingBluetoothAudioRoute()
&& !LinphoneManager.getAudioManager().isWiredHeadsetAvailable()) {
LinphoneManager.getAudioManager().routeAudioToSpeaker(); LinphoneManager.getAudioManager().routeAudioToSpeaker();
} }
} else { } else {