Refactor webrtc audio management

Attempts to:

1) Successfully play ringtone through speaker instead of earpiece
   when possible.

2) Manage bluetooth headset connectivity as well as possible

3) Eliminate notification sounds while in-call when possible

4) Make sure audio is correctly setup when receiving calls

Fixes #6271
Fixes #6248
Fixes #6238
Fixes #6184
Fixes #6169

// FREEBIE
This commit is contained in:
Moxie Marlinspike
2017-03-04 15:48:10 -08:00
parent 3904c76261
commit cd28cd172f
20 changed files with 841 additions and 534 deletions

View File

@@ -32,19 +32,30 @@ public class WebRtcViewModel {
private final boolean remoteVideoEnabled;
private final boolean localVideoEnabled;
public WebRtcViewModel(@NonNull State state, @NonNull Recipient recipient, boolean localVideoEnabled, boolean remoteVideoEnabled) {
this(state, recipient, null, localVideoEnabled, remoteVideoEnabled);
private final boolean isBluetoothAvailable;
private final boolean isMicrophoneEnabled;
public WebRtcViewModel(@NonNull State state, @NonNull Recipient recipient,
boolean localVideoEnabled, boolean remoteVideoEnabled,
boolean isBluetoothAvailable, boolean isMicrophoneEnabled)
{
this(state, recipient, null,
localVideoEnabled, remoteVideoEnabled,
isBluetoothAvailable, isMicrophoneEnabled);
}
public WebRtcViewModel(@NonNull State state, @NonNull Recipient recipient,
@Nullable IdentityKey identityKey,
boolean localVideoEnabled, boolean remoteVideoEnabled)
boolean localVideoEnabled, boolean remoteVideoEnabled,
boolean isBluetoothAvailable, boolean isMicrophoneEnabled)
{
this.state = state;
this.recipient = recipient;
this.identityKey = identityKey;
this.localVideoEnabled = localVideoEnabled;
this.remoteVideoEnabled = remoteVideoEnabled;
this.state = state;
this.recipient = recipient;
this.identityKey = identityKey;
this.localVideoEnabled = localVideoEnabled;
this.remoteVideoEnabled = remoteVideoEnabled;
this.isBluetoothAvailable = isBluetoothAvailable;
this.isMicrophoneEnabled = isMicrophoneEnabled;
}
public @NonNull State getState() {
@@ -68,6 +79,14 @@ public class WebRtcViewModel {
return localVideoEnabled;
}
public boolean isBluetoothAvailable() {
return isBluetoothAvailable;
}
public boolean isMicrophoneEnabled() {
return isMicrophoneEnabled;
}
public String toString() {
return "[State: " + state + ", recipient: " + recipient.getNumber() + ", identity: " + identityKey + ", remoteVideo: " + remoteVideoEnabled + ", localVideo: " + localVideoEnabled + "]";
}