mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Improve handling of missing camera during calls.
This commit is contained in:
committed by
Cody Henthorne
parent
faf0b630c1
commit
340b94f849
@@ -80,4 +80,23 @@ public abstract class DeviceAwareActionProcessor extends WebRtcActionProcessor {
|
||||
.cameraState(newCameraState)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull WebRtcServiceState handleCameraSwitchFailure(@NonNull WebRtcServiceState currentState, @NonNull CameraState newCameraState) {
|
||||
Log.i(tag, "handleCameraSwitchFailure():");
|
||||
|
||||
BroadcastVideoSink localSink = currentState.getVideoState().getLocalSink();
|
||||
if (localSink != null) {
|
||||
localSink.setRotateToRightSide(false);
|
||||
}
|
||||
if (currentState.getVideoState().getCamera() != null) {
|
||||
// Retry by recreating with the opposite preferred camera
|
||||
currentState.getVideoState().getCamera().disposeAndFlipCamera();
|
||||
}
|
||||
|
||||
return currentState.builder()
|
||||
.changeLocalDeviceState()
|
||||
.cameraState(newCameraState)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,6 @@ import org.thoughtcrime.securesms.service.webrtc.state.WebRtcEphemeralState;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
|
||||
import org.thoughtcrime.securesms.util.AppForegroundObserver;
|
||||
import org.thoughtcrime.securesms.util.RecipientAccessList;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore;
|
||||
@@ -988,8 +987,11 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFullyInitialized() {
|
||||
process((s, p) -> p.handleOrientationChanged(s, s.getLocalDeviceState().isLandscapeEnabled(), s.getLocalDeviceState().getDeviceOrientation().getDegrees()));
|
||||
public void onFullyInitialized(@NonNull final CameraState newCameraState) {
|
||||
process((s, p) -> {
|
||||
WebRtcServiceState s1 = p.handleSetCameraDirection(s, newCameraState);
|
||||
return p.handleOrientationChanged(s1, s.getLocalDeviceState().isLandscapeEnabled(), s.getLocalDeviceState().getDeviceOrientation().getDegrees());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -997,6 +999,11 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
process((s, p) -> p.handleCameraSwitchCompleted(s, newCameraState));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraSwitchFailure(@NonNull final CameraState newCameraState) {
|
||||
process((s, p) -> p.handleCameraSwitchFailure(s, newCameraState));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraStopped() {
|
||||
Log.i(TAG, "Camera error. Muting video.");
|
||||
|
||||
@@ -569,6 +569,11 @@ public abstract class WebRtcActionProcessor {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
public @NonNull WebRtcServiceState handleCameraSwitchFailure(@NonNull WebRtcServiceState currentState, @NonNull CameraState newCameraState) {
|
||||
Log.i(tag, "handleCameraSwitchFailure not processed");
|
||||
return currentState;
|
||||
}
|
||||
|
||||
public @NonNull WebRtcServiceState handleNetworkChanged(@NonNull WebRtcServiceState currentState, boolean available) {
|
||||
Log.i(tag, "handleNetworkChanged not processed");
|
||||
return currentState;
|
||||
@@ -630,6 +635,18 @@ public abstract class WebRtcActionProcessor {
|
||||
.build();
|
||||
}
|
||||
|
||||
protected @NonNull WebRtcServiceState handleSetCameraDirection(@NonNull WebRtcServiceState currentState, CameraState state) {
|
||||
BroadcastVideoSink sink = currentState.getVideoState().getLocalSink();
|
||||
if (sink != null) {
|
||||
sink.setRotateToRightSide(state.getActiveDirection() == CameraState.Direction.BACK);
|
||||
}
|
||||
|
||||
return currentState.builder()
|
||||
.changeLocalDeviceState()
|
||||
.cameraState(state)
|
||||
.build();
|
||||
}
|
||||
|
||||
//endregion Local device
|
||||
|
||||
//region End call
|
||||
|
||||
Reference in New Issue
Block a user