kopia lustrzana https://github.com/ryukoposting/Signal-Android
Use low-bandwidth mode if call is believed to be on cellular
rodzic
60047aecb9
commit
7dc3454b37
|
@ -66,7 +66,6 @@ public class CallSetupActionProcessorDelegate extends WebRtcActionProcessor {
|
|||
callManager.setCommunicationMode();
|
||||
callManager.setAudioEnable(currentState.getLocalDeviceState().isMicrophoneEnabled());
|
||||
callManager.setVideoEnable(currentState.getLocalDeviceState().getCameraState().isEnabled());
|
||||
callManager.updateBandwidthMode(NetworkUtil.getCallingBandwidthMode(context));
|
||||
} catch (CallException e) {
|
||||
return callFailure(currentState, "Enabling audio/video failed: ", e);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class GroupJoiningActionProcessor extends GroupActionProcessor {
|
|||
try {
|
||||
groupCall.setOutgoingVideoMuted(!currentState.getLocalDeviceState().getCameraState().isEnabled());
|
||||
groupCall.setOutgoingAudioMuted(!currentState.getLocalDeviceState().isMicrophoneEnabled());
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context));
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, device.getNetworkRoute().getLocalAdapterType()));
|
||||
} catch (CallException e) {
|
||||
Log.e(tag, e);
|
||||
throw new RuntimeException(e);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
|
|||
try {
|
||||
groupCall.setOutgoingAudioMuted(true);
|
||||
groupCall.setOutgoingVideoMuted(true);
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context));
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
|
||||
|
||||
Log.i(TAG, "Connecting to group call: " + currentState.getCallInfoState().getCallRecipient().getId());
|
||||
groupCall.connect();
|
||||
|
@ -158,7 +158,7 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
|
|||
groupCall.setOutgoingVideoSource(currentState.getVideoState().requireLocalSink(), currentState.getVideoState().requireCamera());
|
||||
groupCall.setOutgoingVideoMuted(!currentState.getLocalDeviceState().getCameraState().isEnabled());
|
||||
groupCall.setOutgoingAudioMuted(!currentState.getLocalDeviceState().isMicrophoneEnabled());
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context));
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
|
||||
|
||||
groupCall.join();
|
||||
} catch (CallException e) {
|
||||
|
|
|
@ -176,7 +176,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
|
|||
try {
|
||||
groupCall.setOutgoingAudioMuted(true);
|
||||
groupCall.setOutgoingVideoMuted(true);
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context));
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
|
||||
|
||||
Log.i(TAG, "Connecting to group call: " + currentState.getCallInfoState().getCallRecipient().getId());
|
||||
groupCall.connect();
|
||||
|
@ -202,7 +202,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
|
|||
groupCall.setOutgoingVideoSource(currentState.getVideoState().requireLocalSink(), currentState.getVideoState().requireCamera());
|
||||
groupCall.setOutgoingVideoMuted(answerWithVideo);
|
||||
groupCall.setOutgoingAudioMuted(!currentState.getLocalDeviceState().isMicrophoneEnabled());
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context));
|
||||
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
|
||||
|
||||
groupCall.join();
|
||||
} catch (CallException e) {
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.thoughtcrime.securesms.ringrtc.RemotePeer;
|
|||
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
|
||||
import org.thoughtcrime.securesms.util.AppForegroundObserver;
|
||||
import org.thoughtcrime.securesms.util.BubbleUtil;
|
||||
import org.thoughtcrime.securesms.util.NetworkUtil;
|
||||
import org.thoughtcrime.securesms.util.RecipientAccessList;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
@ -484,6 +485,11 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
|||
|
||||
@Override public void onNetworkRouteChanged(Remote remote, NetworkRoute networkRoute) {
|
||||
Log.i(TAG, "onNetworkRouteChanged: localAdapterType: " + networkRoute.getLocalAdapterType());
|
||||
try {
|
||||
callManager.updateBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, networkRoute.getLocalAdapterType()));
|
||||
} catch (CallException e) {
|
||||
Log.w(TAG, "Unable to update bandwidth mode on CallManager", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import org.signal.ringrtc.CallManager;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.webrtc.PeerConnection;
|
||||
|
||||
public final class NetworkUtil {
|
||||
|
||||
|
@ -29,13 +30,32 @@ public final class NetworkUtil {
|
|||
}
|
||||
|
||||
public static @NonNull CallManager.BandwidthMode getCallingBandwidthMode(@NonNull Context context) {
|
||||
return useLowBandwidthCalling(context) ? CallManager.BandwidthMode.LOW : CallManager.BandwidthMode.NORMAL;
|
||||
return getCallingBandwidthMode(context, PeerConnection.AdapterType.UNKNOWN);
|
||||
}
|
||||
|
||||
private static boolean useLowBandwidthCalling(@NonNull Context context) {
|
||||
public static @NonNull CallManager.BandwidthMode getCallingBandwidthMode(@NonNull Context context, @NonNull PeerConnection.AdapterType networkAdapter) {
|
||||
return useLowBandwidthCalling(context, networkAdapter) ? CallManager.BandwidthMode.LOW : CallManager.BandwidthMode.NORMAL;
|
||||
}
|
||||
|
||||
private static boolean useLowBandwidthCalling(@NonNull Context context, @NonNull PeerConnection.AdapterType networkAdapter) {
|
||||
switch (SignalStore.settings().getCallBandwidthMode()) {
|
||||
case HIGH_ON_WIFI:
|
||||
return !NetworkUtil.isConnectedWifi(context);
|
||||
switch (networkAdapter) {
|
||||
case UNKNOWN:
|
||||
case VPN:
|
||||
case ADAPTER_TYPE_ANY:
|
||||
return !NetworkUtil.isConnectedWifi(context);
|
||||
case ETHERNET:
|
||||
case WIFI:
|
||||
case LOOPBACK:
|
||||
return false;
|
||||
case CELLULAR:
|
||||
case CELLULAR_2G:
|
||||
case CELLULAR_3G:
|
||||
case CELLULAR_4G:
|
||||
case CELLULAR_5G:
|
||||
return true;
|
||||
}
|
||||
case HIGH_ALWAYS:
|
||||
return false;
|
||||
default:
|
||||
|
|
Ładowanie…
Reference in New Issue