delay integrated audio routing on callee end until picked up
This commit is contained in:
parent
32e25e36fc
commit
027a4e139a
|
@ -53,6 +53,8 @@ public class CallIntegration extends Connection {
|
||||||
|
|
||||||
private final AppRTCAudioManager appRTCAudioManager;
|
private final AppRTCAudioManager appRTCAudioManager;
|
||||||
private AudioDevice initialAudioDevice = null;
|
private AudioDevice initialAudioDevice = null;
|
||||||
|
|
||||||
|
private boolean isAudioRoutingRequested = false;
|
||||||
private final AtomicBoolean initialAudioDeviceConfigured = new AtomicBoolean(false);
|
private final AtomicBoolean initialAudioDeviceConfigured = new AtomicBoolean(false);
|
||||||
private final AtomicBoolean delayedDestructionInitiated = new AtomicBoolean(false);
|
private final AtomicBoolean delayedDestructionInitiated = new AtomicBoolean(false);
|
||||||
private final AtomicBoolean isDestroyed = new AtomicBoolean(false);
|
private final AtomicBoolean isDestroyed = new AtomicBoolean(false);
|
||||||
|
@ -446,12 +448,28 @@ public class CallIntegration extends Connection {
|
||||||
private void onAudioDeviceChanged(
|
private void onAudioDeviceChanged(
|
||||||
final CallIntegration.AudioDevice selectedAudioDevice,
|
final CallIntegration.AudioDevice selectedAudioDevice,
|
||||||
final Set<CallIntegration.AudioDevice> availableAudioDevices) {
|
final Set<CallIntegration.AudioDevice> availableAudioDevices) {
|
||||||
if (this.initialAudioDevice != null
|
if (isAudioRoutingRequested) {
|
||||||
&& this.initialAudioDeviceConfigured.compareAndSet(false, true)) {
|
configureInitialAudioDevice(availableAudioDevices);
|
||||||
if (availableAudioDevices.contains(this.initialAudioDevice)
|
}
|
||||||
|
final var callback = this.callback;
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback.onAudioDeviceChanged(selectedAudioDevice, availableAudioDevices);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureInitialAudioDevice(final Set<AudioDevice> availableAudioDevices) {
|
||||||
|
final var initialAudioDevice = this.initialAudioDevice;
|
||||||
|
if (initialAudioDevice == null) {
|
||||||
|
Log.d(Config.LOGTAG, "skipping configureInitialAudioDevice()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final var target = this.initialAudioDevice;
|
||||||
|
if (this.initialAudioDeviceConfigured.compareAndSet(false, true)) {
|
||||||
|
if (availableAudioDevices.contains(target)
|
||||||
&& !availableAudioDevices.contains(AudioDevice.BLUETOOTH)) {
|
&& !availableAudioDevices.contains(AudioDevice.BLUETOOTH)) {
|
||||||
setAudioDevice(this.initialAudioDevice);
|
setAudioDevice(target);
|
||||||
Log.d(Config.LOGTAG, "configured initial audio device");
|
Log.d(Config.LOGTAG, "configured initial audio device: " + target);
|
||||||
} else {
|
} else {
|
||||||
Log.d(
|
Log.d(
|
||||||
Config.LOGTAG,
|
Config.LOGTAG,
|
||||||
|
@ -459,11 +477,6 @@ public class CallIntegration extends Connection {
|
||||||
+ availableAudioDevices);
|
+ availableAudioDevices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final var callback = this.callback;
|
|
||||||
if (callback == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
callback.onAudioDeviceChanged(selectedAudioDevice, availableAudioDevices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean selfManaged() {
|
private boolean selfManaged() {
|
||||||
|
@ -494,8 +507,14 @@ public class CallIntegration extends Connection {
|
||||||
this.initialAudioDevice = audioDevice;
|
this.initialAudioDevice = audioDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startLegacyAudioRouting() {
|
public void startAudioRouting() {
|
||||||
|
this.isAudioRoutingRequested = true;
|
||||||
if (selfManaged()) {
|
if (selfManaged()) {
|
||||||
|
final var devices = getAudioDevices();
|
||||||
|
if (devices.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
configureInitialAudioDevice(devices);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final var audioManager = requireAppRtcAudioManager();
|
final var audioManager = requireAppRtcAudioManager();
|
||||||
|
|
|
@ -736,7 +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();
|
rtpConnection.getCallIntegration().startAudioRouting();
|
||||||
this.connections.put(id, rtpConnection);
|
this.connections.put(id, rtpConnection);
|
||||||
rtpConnection.sendSessionInitiate();
|
rtpConnection.sendSessionInitiate();
|
||||||
return rtpConnection;
|
return rtpConnection;
|
||||||
|
@ -777,7 +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();
|
callIntegration.startAudioRouting();
|
||||||
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,7 +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.callIntegration.startAudioRouting();
|
||||||
this.sendJingleMessage("accept", id.account.getJid().asBareJid());
|
this.sendJingleMessage("accept", id.account.getJid().asBareJid());
|
||||||
this.sendJingleMessage("proceed");
|
this.sendJingleMessage("proceed");
|
||||||
}
|
}
|
||||||
|
@ -2398,7 +2398,7 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
||||||
|
|
||||||
private void acceptCallFromSessionInitialized() {
|
private void acceptCallFromSessionInitialized() {
|
||||||
xmppConnectionService.getNotificationService().cancelIncomingCallNotification();
|
xmppConnectionService.getNotificationService().cancelIncomingCallNotification();
|
||||||
this.callIntegration.startLegacyAudioRouting();
|
this.callIntegration.startAudioRouting();
|
||||||
sendSessionAccept();
|
sendSessionAccept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue