use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class SignalCallManager method onCallConcluded.
@Override
public void onCallConcluded(@Nullable Remote remote) {
if (!(remote instanceof RemotePeer)) {
return;
}
RemotePeer remotePeer = (RemotePeer) remote;
Log.i(TAG, "onCallConcluded: call_id: " + remotePeer.getCallId());
process((s, p) -> p.handleCallConcluded(s, remotePeer));
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class ActiveCallActionProcessorDelegate method handleLocalHangup.
@Override
@NonNull
protected WebRtcServiceState handleLocalHangup(@NonNull WebRtcServiceState currentState) {
RemotePeer remotePeer = currentState.getCallInfoState().getActivePeer();
if (remotePeer == null) {
Log.i(tag, "handleLocalHangup(): no active peer");
} else {
Log.i(tag, "handleLocalHangup(): call_id: " + remotePeer.getCallId());
}
ApplicationDependencies.getSignalServiceAccountManager().cancelInFlightRequests();
ApplicationDependencies.getSignalServiceMessageSender().cancelInFlightRequests();
try {
webRtcInteractor.getCallManager().hangup();
currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).build();
webRtcInteractor.postStateUpdate(currentState);
return terminate(currentState, remotePeer);
} catch (CallException e) {
return callFailure(currentState, "hangup() failed: ", e);
}
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class ActiveCallActionProcessorDelegate method handleSetupFailure.
@Override
@NonNull
protected WebRtcServiceState handleSetupFailure(@NonNull WebRtcServiceState currentState, @NonNull CallId callId) {
Log.i(tag, "handleSetupFailure(): call_id: " + callId);
RemotePeer activePeer = currentState.getCallInfoState().getActivePeer();
if (activePeer != null && activePeer.getCallId().equals(callId)) {
try {
if (activePeer.getState() == CallState.DIALING || activePeer.getState() == CallState.REMOTE_RINGING) {
webRtcInteractor.getCallManager().hangup();
} else {
webRtcInteractor.getCallManager().drop(callId);
}
} catch (CallException e) {
return callFailure(currentState, "Unable to drop call due to setup failure", e);
}
currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.NETWORK_FAILURE).build();
webRtcInteractor.postStateUpdate(currentState);
if (activePeer.getState() == CallState.ANSWERING || activePeer.getState() == CallState.LOCAL_RINGING) {
webRtcInteractor.insertMissedCall(activePeer, activePeer.getCallStartTimestamp(), currentState.getCallSetupState(activePeer).isRemoteVideoOffer());
}
return terminate(currentState, activePeer);
}
return currentState;
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class ActiveCallActionProcessorDelegate method handleReceivedOfferWhileActive.
@Override
@NonNull
protected WebRtcServiceState handleReceivedOfferWhileActive(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer) {
RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
Log.i(tag, "handleReceivedOfferWhileActive(): call_id: " + remotePeer.getCallId());
switch(activePeer.getState()) {
case DIALING:
case REMOTE_RINGING:
webRtcInteractor.setCallInProgressNotification(TYPE_OUTGOING_RINGING, activePeer);
break;
case IDLE:
case ANSWERING:
webRtcInteractor.setCallInProgressNotification(TYPE_INCOMING_CONNECTING, activePeer);
break;
case LOCAL_RINGING:
webRtcInteractor.setCallInProgressNotification(TYPE_INCOMING_RINGING, activePeer);
break;
case CONNECTED:
webRtcInteractor.setCallInProgressNotification(TYPE_ESTABLISHED, activePeer);
break;
default:
throw new IllegalStateException();
}
if (activePeer.getState() == CallState.IDLE) {
webRtcInteractor.stopForegroundService();
}
webRtcInteractor.insertMissedCall(remotePeer, remotePeer.getCallStartTimestamp(), currentState.getCallSetupState(remotePeer).isRemoteVideoOffer());
return terminate(currentState, remotePeer);
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class ActiveCallActionProcessorDelegate method handleEndedRemote.
@Override
@NonNull
protected WebRtcServiceState handleEndedRemote(@NonNull WebRtcServiceState currentState, @NonNull CallEvent endedRemoteEvent, @NonNull RemotePeer remotePeer) {
Log.i(tag, "handleEndedRemote(): call_id: " + remotePeer.getCallId() + " action: " + endedRemoteEvent);
WebRtcViewModel.State state = currentState.getCallInfoState().getCallState();
RemotePeer activePeer = currentState.getCallInfoState().getActivePeer();
boolean remotePeerIsActive = remotePeer.callIdEquals(activePeer);
boolean outgoingBeforeAccept = remotePeer.getState() == CallState.DIALING || remotePeer.getState() == CallState.REMOTE_RINGING;
boolean incomingBeforeAccept = remotePeer.getState() == CallState.ANSWERING || remotePeer.getState() == CallState.LOCAL_RINGING;
if (remotePeerIsActive && ENDED_REMOTE_EVENT_TO_STATE.containsKey(endedRemoteEvent)) {
state = Objects.requireNonNull(ENDED_REMOTE_EVENT_TO_STATE.get(endedRemoteEvent));
}
if (endedRemoteEvent == CallEvent.ENDED_REMOTE_HANGUP) {
if (remotePeerIsActive) {
state = outgoingBeforeAccept ? WebRtcViewModel.State.RECIPIENT_UNAVAILABLE : WebRtcViewModel.State.CALL_DISCONNECTED;
}
if (incomingBeforeAccept) {
webRtcInteractor.insertMissedCall(remotePeer, remotePeer.getCallStartTimestamp(), currentState.getCallSetupState(remotePeer).isRemoteVideoOffer());
}
} else if (endedRemoteEvent == CallEvent.ENDED_REMOTE_BUSY && remotePeerIsActive) {
activePeer.receivedBusy();
OutgoingRinger ringer = new OutgoingRinger(context);
ringer.start(OutgoingRinger.Type.BUSY);
ThreadUtil.runOnMainDelayed(ringer::stop, SignalCallManager.BUSY_TONE_LENGTH);
} else if (endedRemoteEvent == CallEvent.ENDED_REMOTE_GLARE && incomingBeforeAccept) {
webRtcInteractor.insertMissedCall(remotePeer, remotePeer.getCallStartTimestamp(), currentState.getCallSetupState(remotePeer).isRemoteVideoOffer());
}
if (state == WebRtcViewModel.State.CALL_ACCEPTED_ELSEWHERE) {
webRtcInteractor.insertReceivedCall(remotePeer, currentState.getCallSetupState(remotePeer).isRemoteVideoOffer());
}
currentState = currentState.builder().changeCallInfoState().callState(state).build();
webRtcInteractor.postStateUpdate(currentState);
return terminate(currentState, remotePeer);
}
Aggregations