mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Enable call vanity when joining a video call.
This commit is contained in:
@@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.ringrtc.CallState;
|
||||
import org.thoughtcrime.securesms.ringrtc.Camera;
|
||||
import org.thoughtcrime.securesms.ringrtc.RemotePeer;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.CallSetupState;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.VideoState;
|
||||
@@ -133,6 +134,17 @@ public class IncomingCallActionProcessor extends DeviceAwareActionProcessor {
|
||||
|
||||
Log.i(TAG, "handleAcceptCall(): call_id: " + activePeer.getCallId());
|
||||
|
||||
Camera camera = currentState.getVideoState().requireCamera();
|
||||
camera.setVanitySink(null);
|
||||
|
||||
if (!answerWithVideo && currentState.getLocalDeviceState().getCameraState().isEnabled()) {
|
||||
camera.setEnabled(false);
|
||||
currentState = currentState.builder()
|
||||
.changeLocalDeviceState()
|
||||
.cameraState(camera.getCameraState())
|
||||
.build();
|
||||
}
|
||||
|
||||
currentState = currentState.builder()
|
||||
.changeCallSetupState(activePeer.getCallId())
|
||||
.acceptWithVideo(answerWithVideo)
|
||||
@@ -157,6 +169,11 @@ public class IncomingCallActionProcessor extends DeviceAwareActionProcessor {
|
||||
|
||||
Log.i(TAG, "handleDenyCall():");
|
||||
|
||||
Camera camera = currentState.getVideoState().getCamera();
|
||||
if (camera != null) {
|
||||
camera.setVanitySink(null);
|
||||
}
|
||||
|
||||
webRtcInteractor.sendNotAcceptedCallEventSyncMessage(activePeer,
|
||||
false,
|
||||
currentState.getCallSetupState(activePeer).isRemoteVideoOffer());
|
||||
@@ -170,6 +187,43 @@ public class IncomingCallActionProcessor extends DeviceAwareActionProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull WebRtcServiceState handleSetIncomingRingingVanity(@NonNull WebRtcServiceState currentState, boolean enabled) {
|
||||
RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
|
||||
boolean isVideoOffer = currentState.getCallSetupState(activePeer).isRemoteVideoOffer();
|
||||
|
||||
if (!isVideoOffer) {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
boolean cameraAlreadyEnabled = currentState.getLocalDeviceState().getCameraState().isEnabled();
|
||||
|
||||
if (enabled && cameraAlreadyEnabled) {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
if (!enabled && !cameraAlreadyEnabled) {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
Camera camera = currentState.getVideoState().requireCamera();
|
||||
|
||||
if (enabled) {
|
||||
Log.i(TAG, "handleSetIncomingRingingVanity(): enabling vanity camera");
|
||||
camera.setVanitySink(currentState.getVideoState().requireLocalSink());
|
||||
camera.setEnabled(true);
|
||||
} else {
|
||||
Log.i(TAG, "handleSetIncomingRingingVanity(): disabling vanity camera");
|
||||
camera.setVanitySink(null);
|
||||
camera.setEnabled(false);
|
||||
}
|
||||
|
||||
return currentState.builder()
|
||||
.changeLocalDeviceState()
|
||||
.cameraState(camera.getCameraState())
|
||||
.build();
|
||||
}
|
||||
|
||||
protected @NonNull WebRtcServiceState handleLocalRinging(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer) {
|
||||
Log.i(TAG, "handleLocalRinging(): call_id: " + remotePeer.getCallId());
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.notifications.DoNotDisturbUtil;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.ringrtc.Camera;
|
||||
import org.thoughtcrime.securesms.ringrtc.RemotePeer;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
|
||||
import org.thoughtcrime.securesms.util.AppForegroundObserver;
|
||||
@@ -179,8 +180,41 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull WebRtcServiceState handleSetIncomingRingingVanity(@NonNull WebRtcServiceState currentState, boolean enabled) {
|
||||
boolean cameraAlreadyEnabled = currentState.getLocalDeviceState().getCameraState().isEnabled();
|
||||
|
||||
if (enabled && cameraAlreadyEnabled) {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
if (!enabled && !cameraAlreadyEnabled) {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
Camera camera = currentState.getVideoState().requireCamera();
|
||||
|
||||
if (enabled && !camera.isInitialized()) {
|
||||
Log.i(TAG, "handleSetIncomingRingingVanity(): initializing vanity camera");
|
||||
return WebRtcVideoUtil.initializeVanityCamera(currentState);
|
||||
} else if (enabled) {
|
||||
Log.i(TAG, "handleSetIncomingRingingVanity(): enabling vanity camera");
|
||||
camera.setEnabled(true);
|
||||
} else {
|
||||
Log.i(TAG, "handleSetIncomingRingingVanity(): disabling vanity camera");
|
||||
camera.setEnabled(false);
|
||||
}
|
||||
|
||||
return currentState.builder()
|
||||
.changeLocalDeviceState()
|
||||
.cameraState(camera.getCameraState())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull WebRtcServiceState handleAcceptCall(@NonNull WebRtcServiceState currentState, boolean answerWithVideo) {
|
||||
currentState = WebRtcVideoUtil.reinitializeCamera(context, webRtcInteractor.getCameraEventListener(), currentState);
|
||||
|
||||
byte[] groupId = currentState.getCallInfoState().getCallRecipient().requireGroupId().getDecodedId();
|
||||
GroupCall groupCall = webRtcInteractor.getCallManager().createGroupCall(groupId,
|
||||
SignalStore.internal().getGroupCallingServer(),
|
||||
@@ -220,7 +254,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
|
||||
|
||||
try {
|
||||
groupCall.setOutgoingVideoSource(currentState.getVideoState().requireLocalSink(), currentState.getVideoState().requireCamera());
|
||||
groupCall.setOutgoingVideoMuted(answerWithVideo);
|
||||
groupCall.setOutgoingVideoMuted(!answerWithVideo);
|
||||
groupCall.setOutgoingAudioMuted(!currentState.getLocalDeviceState().isMicrophoneEnabled());
|
||||
groupCall.setDataMode(NetworkUtil.getCallingDataMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
|
||||
|
||||
@@ -229,6 +263,15 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
|
||||
return groupCallFailure(currentState, "Unable to join group call", e);
|
||||
}
|
||||
|
||||
if (answerWithVideo) {
|
||||
Camera camera = currentState.getVideoState().requireCamera();
|
||||
camera.setEnabled(true);
|
||||
currentState = currentState.builder()
|
||||
.changeLocalDeviceState()
|
||||
.cameraState(camera.getCameraState())
|
||||
.build();
|
||||
}
|
||||
|
||||
return currentState.builder()
|
||||
.actionProcessor(MultiPeerActionProcessorFactory.GroupActionProcessorFactory.INSTANCE.createJoiningActionProcessor(webRtcInteractor))
|
||||
.changeCallInfoState()
|
||||
|
||||
@@ -268,6 +268,10 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
process((s, p) -> p.handleSetEnableVideo(s, enabled));
|
||||
}
|
||||
|
||||
public void setIncomingRingingVanity(boolean enabled) {
|
||||
process((s, p) -> p.handleSetIncomingRingingVanity(s, enabled));
|
||||
}
|
||||
|
||||
public void flipCamera() {
|
||||
process((s, p) -> p.handleSetCameraFlip(s));
|
||||
}
|
||||
|
||||
@@ -586,6 +586,10 @@ public abstract class WebRtcActionProcessor {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
protected @NonNull WebRtcServiceState handleSetIncomingRingingVanity(@NonNull WebRtcServiceState currentState, boolean enabled) {
|
||||
Log.i(tag, "handleSetIncomingRingingVanity not processed");
|
||||
return currentState;
|
||||
}
|
||||
|
||||
protected @NonNull WebRtcServiceState handleSelfRaiseHand(@NonNull WebRtcServiceState currentState, boolean raised) {
|
||||
Log.i(tag, "raiseHand not processed");
|
||||
|
||||
Reference in New Issue
Block a user