From 6ba9208eea5a12ecbaf8dcbeb6a0453e5ec5995a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 16 Jan 2024 13:56:39 +0100 Subject: [PATCH] switch audio device when switching to video --- .../eu/siacs/conversations/services/CallIntegration.java | 7 +++++++ .../conversations/xmpp/jingle/JingleRtpConnection.java | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/services/CallIntegration.java b/src/main/java/eu/siacs/conversations/services/CallIntegration.java index fbd3e8c2c..a4dffffaa 100644 --- a/src/main/java/eu/siacs/conversations/services/CallIntegration.java +++ b/src/main/java/eu/siacs/conversations/services/CallIntegration.java @@ -145,6 +145,13 @@ public class CallIntegration extends Connection { } } + public void setAudioDeviceWhenAvailable(final AudioDevice audioDevice) { + final var available = getAudioDevices(); + if (available.contains(audioDevice)) { + this.setAudioDevice(audioDevice); + } + } + @RequiresApi(api = Build.VERSION_CODES.UPSIDE_DOWN_CAKE) private Set getAudioDevicesUpsideDownCake() { return ImmutableSet.copyOf( diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index dc0980e1b..e9d750319 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -2610,6 +2610,8 @@ public class JingleRtpConnection extends AbstractJingleConnection private void modifyLocalContentMap(final RtpContentMap rtpContentMap) { final RtpContentMap activeContents = rtpContentMap.activeContents(); setLocalContentMap(activeContents); + this.callIntegration.setAudioDeviceWhenAvailable( + CallIntegration.initialAudioDevice(activeContents.getMedia())); updateEndUserState(); }