delay legacy audio routing until after call has been accepted
fixes #249
This commit is contained in:
parent
9d01af239a
commit
7088c1f507
|
@ -88,15 +88,18 @@ public class AppRTCAudioManager {
|
||||||
AppRTCUtils.logDeviceInfo(Config.LOGTAG);
|
AppRTCUtils.logDeviceInfo(Config.LOGTAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAudioManagerEvents(final AudioManagerEvents audioManagerEvents) {
|
||||||
|
this.audioManagerEvents = audioManagerEvents;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void start(final AudioManagerEvents audioManagerEvents) {
|
public void start() {
|
||||||
Log.d(Config.LOGTAG, AppRTCAudioManager.class.getName() + ".start()");
|
Log.d(Config.LOGTAG, AppRTCAudioManager.class.getName() + ".start()");
|
||||||
ThreadUtils.checkIsOnMainThread();
|
ThreadUtils.checkIsOnMainThread();
|
||||||
if (amState == AudioManagerState.RUNNING) {
|
if (amState == AudioManagerState.RUNNING) {
|
||||||
Log.e(Config.LOGTAG, "AudioManager is already active");
|
Log.e(Config.LOGTAG, "AudioManager is already active");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.audioManagerEvents = audioManagerEvents;
|
|
||||||
amState = AudioManagerState.RUNNING;
|
amState = AudioManagerState.RUNNING;
|
||||||
// Store current audio state so we can restore it when stop() is called.
|
// Store current audio state so we can restore it when stop() is called.
|
||||||
savedIsSpeakerPhoneOn = audioManager.isSpeakerphoneOn();
|
savedIsSpeakerPhoneOn = audioManager.isSpeakerphoneOn();
|
||||||
|
|
|
@ -15,7 +15,6 @@ import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -70,8 +69,7 @@ public class CallIntegration extends Connection {
|
||||||
this.appRTCAudioManager = null;
|
this.appRTCAudioManager = null;
|
||||||
} else {
|
} else {
|
||||||
this.appRTCAudioManager = new AppRTCAudioManager(context);
|
this.appRTCAudioManager = new AppRTCAudioManager(context);
|
||||||
ContextCompat.getMainExecutor(context)
|
this.appRTCAudioManager.setAudioManagerEvents(this::onAudioDeviceChanged);
|
||||||
.execute(() -> this.appRTCAudioManager.start(this::onAudioDeviceChanged));
|
|
||||||
}
|
}
|
||||||
setRingbackRequested(true);
|
setRingbackRequested(true);
|
||||||
}
|
}
|
||||||
|
@ -490,17 +488,19 @@ public class CallIntegration extends Connection {
|
||||||
public void setInitialAudioDevice(final AudioDevice audioDevice) {
|
public void setInitialAudioDevice(final AudioDevice audioDevice) {
|
||||||
Log.d(Config.LOGTAG, "setInitialAudioDevice(" + audioDevice + ")");
|
Log.d(Config.LOGTAG, "setInitialAudioDevice(" + audioDevice + ")");
|
||||||
this.initialAudioDevice = audioDevice;
|
this.initialAudioDevice = audioDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startLegacyAudioRouting() {
|
||||||
if (selfManaged()) {
|
if (selfManaged()) {
|
||||||
// once the 'CallIntegration' gets added to the system we receive calls to update audio
|
|
||||||
// state
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final var audioManager = requireAppRtcAudioManager();
|
final var audioManager = requireAppRtcAudioManager();
|
||||||
audioManager.executeOnMain(
|
audioManager.executeOnMain(
|
||||||
() ->
|
() -> {
|
||||||
this.onAudioDeviceChanged(
|
audioManager.start();
|
||||||
audioManager.getSelectedAudioDevice(),
|
this.onAudioDeviceChanged(
|
||||||
audioManager.getAudioDevices()));
|
audioManager.getSelectedAudioDevice(), audioManager.getAudioDevices());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyCallIntegration() {
|
private void destroyCallIntegration() {
|
||||||
|
|
|
@ -736,6 +736,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
final JingleRtpConnection rtpConnection =
|
final JingleRtpConnection rtpConnection =
|
||||||
new JingleRtpConnection(this, id, account.getJid());
|
new JingleRtpConnection(this, id, account.getJid());
|
||||||
rtpConnection.setProposedMedia(media);
|
rtpConnection.setProposedMedia(media);
|
||||||
|
rtpConnection.getCallIntegration().startLegacyAudioRouting();
|
||||||
this.connections.put(id, rtpConnection);
|
this.connections.put(id, rtpConnection);
|
||||||
rtpConnection.sendSessionInitiate();
|
rtpConnection.sendSessionInitiate();
|
||||||
return rtpConnection;
|
return rtpConnection;
|
||||||
|
@ -776,6 +777,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
? VideoProfile.STATE_AUDIO_ONLY
|
? VideoProfile.STATE_AUDIO_ONLY
|
||||||
: VideoProfile.STATE_BIDIRECTIONAL);
|
: VideoProfile.STATE_BIDIRECTIONAL);
|
||||||
callIntegration.setInitialAudioDevice(CallIntegration.initialAudioDevice(media));
|
callIntegration.setInitialAudioDevice(CallIntegration.initialAudioDevice(media));
|
||||||
|
callIntegration.startLegacyAudioRouting();
|
||||||
final RtpSessionProposal proposal =
|
final RtpSessionProposal proposal =
|
||||||
RtpSessionProposal.of(account, with.asBareJid(), media, callIntegration);
|
RtpSessionProposal.of(account, with.asBareJid(), media, callIntegration);
|
||||||
callIntegration.setCallback(new ProposalStateCallback(proposal));
|
callIntegration.setCallback(new ProposalStateCallback(proposal));
|
||||||
|
|
|
@ -2329,6 +2329,7 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
||||||
private void acceptCallFromProposed() {
|
private void acceptCallFromProposed() {
|
||||||
transitionOrThrow(State.PROCEED);
|
transitionOrThrow(State.PROCEED);
|
||||||
xmppConnectionService.getNotificationService().cancelIncomingCallNotification();
|
xmppConnectionService.getNotificationService().cancelIncomingCallNotification();
|
||||||
|
this.callIntegration.startLegacyAudioRouting();
|
||||||
this.sendJingleMessage("accept", id.account.getJid().asBareJid());
|
this.sendJingleMessage("accept", id.account.getJid().asBareJid());
|
||||||
this.sendJingleMessage("proceed");
|
this.sendJingleMessage("proceed");
|
||||||
}
|
}
|
||||||
|
@ -2397,6 +2398,7 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
||||||
|
|
||||||
private void acceptCallFromSessionInitialized() {
|
private void acceptCallFromSessionInitialized() {
|
||||||
xmppConnectionService.getNotificationService().cancelIncomingCallNotification();
|
xmppConnectionService.getNotificationService().cancelIncomingCallNotification();
|
||||||
|
this.callIntegration.startLegacyAudioRouting();
|
||||||
sendSessionAccept();
|
sendSessionAccept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue