use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class GroupActionProcessor method handleGroupCallEnded.
@Override
@NonNull
protected WebRtcServiceState handleGroupCallEnded(@NonNull WebRtcServiceState currentState, int groupCallHash, @NonNull GroupCall.GroupCallEndReason groupCallEndReason) {
Log.i(tag, "handleGroupCallEnded(): reason: " + groupCallEndReason);
GroupCall groupCall = currentState.getCallInfoState().getGroupCall();
if (groupCall == null || groupCall.hashCode() != groupCallHash) {
return currentState;
}
try {
groupCall.disconnect();
} catch (CallException e) {
return groupCallFailure(currentState, "Unable to disconnect from group call", e);
}
if (groupCallEndReason != GroupCall.GroupCallEndReason.DEVICE_EXPLICITLY_DISCONNECTED) {
Log.i(tag, "Group call ended unexpectedly, reinitializing and dropping back to lobby");
Recipient currentRecipient = currentState.getCallInfoState().getCallRecipient();
VideoState videoState = currentState.getVideoState();
currentState = terminateGroupCall(currentState, false).builder().actionProcessor(new GroupNetworkUnavailableActionProcessor(webRtcInteractor)).changeVideoState().eglBase(videoState.getLockableEglBase()).camera(videoState.getCamera()).localSink(videoState.getLocalSink()).commit().changeCallInfoState().callState(WebRtcViewModel.State.CALL_PRE_JOIN).callRecipient(currentRecipient).build();
currentState = WebRtcVideoUtil.initializeVanityCamera(WebRtcVideoUtil.reinitializeCamera(context, webRtcInteractor.getCameraEventListener(), currentState));
return currentState.getActionProcessor().handlePreJoinCall(currentState, new RemotePeer(currentRecipient.getId()));
}
currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
webRtcInteractor.postStateUpdate(currentState);
return terminateGroupCall(currentState);
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class WebRtcActionProcessor method handleMessageSentError.
@NonNull
protected WebRtcServiceState handleMessageSentError(@NonNull WebRtcServiceState currentState, @NonNull CallId callId, @NonNull WebRtcViewModel.State errorCallState, @NonNull Optional<IdentityKey> identityKey) {
Log.w(tag, "handleMessageSentError():");
try {
webRtcInteractor.getCallManager().messageSendFailure(callId);
} catch (CallException e) {
currentState = callFailure(currentState, "callManager.messageSendFailure() failed: ", e);
}
RemotePeer activePeer = currentState.getCallInfoState().getActivePeer();
if (activePeer == null) {
return currentState;
}
WebRtcServiceStateBuilder builder = currentState.builder();
if (errorCallState == WebRtcViewModel.State.UNTRUSTED_IDENTITY) {
CallParticipant participant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
CallParticipant untrusted = participant.withIdentityKey(identityKey.orNull());
builder.changeCallInfoState().callState(WebRtcViewModel.State.UNTRUSTED_IDENTITY).putParticipant(activePeer.getRecipient(), untrusted).commit();
} else {
builder.changeCallInfoState().callState(errorCallState).commit();
}
return builder.build();
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class CallSetupActionProcessorDelegate method handleCallConnected.
@Override
@NonNull
public WebRtcServiceState handleCallConnected(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer) {
if (!remotePeer.callIdEquals(currentState.getCallInfoState().getActivePeer())) {
Log.w(tag, "handleCallConnected(): Ignoring for inactive call.");
return currentState;
}
Log.i(tag, "handleCallConnected(): call_id: " + remotePeer.getCallId());
RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
ApplicationDependencies.getAppForegroundObserver().removeListener(webRtcInteractor.getForegroundListener());
webRtcInteractor.startAudioCommunication();
activePeer.connected();
if (currentState.getLocalDeviceState().getCameraState().isEnabled()) {
webRtcInteractor.updatePhoneState(LockManager.PhoneState.IN_VIDEO);
} else {
webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context));
}
currentState = currentState.builder().actionProcessor(new ConnectedCallActionProcessor(webRtcInteractor)).changeCallInfoState().callState(WebRtcViewModel.State.CALL_CONNECTED).callConnectedTime(System.currentTimeMillis()).commit().changeLocalDeviceState().build();
webRtcInteractor.setCallInProgressNotification(TYPE_ESTABLISHED, activePeer);
webRtcInteractor.unregisterPowerButtonReceiver();
try {
CallManager callManager = webRtcInteractor.getCallManager();
callManager.setCommunicationMode();
callManager.setAudioEnable(currentState.getLocalDeviceState().isMicrophoneEnabled());
callManager.setVideoEnable(currentState.getLocalDeviceState().getCameraState().isEnabled());
} catch (CallException e) {
return callFailure(currentState, "Enabling audio/video failed: ", e);
}
if (currentState.getCallSetupState(activePeer).isAcceptWithVideo()) {
currentState = currentState.getActionProcessor().handleSetEnableVideo(currentState, true);
}
if (currentState.getCallSetupState(activePeer).isAcceptWithVideo() || currentState.getLocalDeviceState().getCameraState().isEnabled()) {
webRtcInteractor.setDefaultAudioDevice(SignalAudioManager.AudioDevice.SPEAKER_PHONE, false);
} else {
webRtcInteractor.setDefaultAudioDevice(SignalAudioManager.AudioDevice.EARPIECE, false);
}
return currentState;
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class MessageContentProcessor method handleCallOfferMessage.
private void handleCallOfferMessage(@NonNull SignalServiceContent content, @NonNull OfferMessage message, @NonNull Optional<Long> smsMessageId, @NonNull Recipient senderRecipient) {
log(String.valueOf(content.getTimestamp()), "handleCallOfferMessage...");
if (smsMessageId.isPresent()) {
MessageDatabase database = SignalDatabase.sms();
database.markAsMissedCall(smsMessageId.get(), message.getType() == OfferMessage.Type.VIDEO_CALL);
} else {
RemotePeer remotePeer = new RemotePeer(senderRecipient.getId(), new CallId(message.getId()));
byte[] remoteIdentityKey = ApplicationDependencies.getProtocolStore().aci().identities().getIdentityRecord(senderRecipient.getId()).transform(record -> record.getIdentityKey().serialize()).orNull();
ApplicationDependencies.getSignalCallManager().receivedOffer(new WebRtcData.CallMetadata(remotePeer, content.getSenderDevice()), new WebRtcData.OfferMetadata(message.getOpaque(), message.getSdp(), message.getType()), new WebRtcData.ReceivedOfferMetadata(remoteIdentityKey, content.getServerReceivedTimestamp(), content.getServerDeliveredTimestamp(), content.getCallMessage().get().isMultiRing()));
}
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class MessageContentProcessor method handleCallBusyMessage.
private void handleCallBusyMessage(@NonNull SignalServiceContent content, @NonNull BusyMessage message, @NonNull Recipient senderRecipient) {
log(String.valueOf(content.getTimestamp()), "handleCallBusyMessage");
RemotePeer remotePeer = new RemotePeer(senderRecipient.getId(), new CallId(message.getId()));
ApplicationDependencies.getSignalCallManager().receivedCallBusy(new WebRtcData.CallMetadata(remotePeer, content.getSenderDevice()));
}
Aggregations