use of org.whispersystems.signalservice.api.messages.calls.AnswerMessage in project Signal-Android by WhisperSystems.
the class WebRtcCallService method handleIncomingCall.
// Handlers
private void handleIncomingCall(final Intent intent) {
Log.w(TAG, "handleIncomingCall()");
if (callState != CallState.STATE_IDLE)
throw new IllegalStateException("Incoming on non-idle");
final String offer = intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION);
this.callState = CallState.STATE_ANSWERING;
this.callId = intent.getLongExtra(EXTRA_CALL_ID, -1);
this.recipient = getRemoteRecipient(intent);
if (isIncomingMessageExpired(intent)) {
insertMissedCall(this.recipient, true);
terminate();
return;
}
timeoutExecutor.schedule(new TimeoutRunnable(this.callId), 2, TimeUnit.MINUTES);
initializeVideo();
retrieveTurnServers().addListener(new SuccessOnlyListener<List<PeerConnection.IceServer>>(this.callState, this.callId) {
@Override
public void onSuccessContinue(List<PeerConnection.IceServer> result) {
try {
boolean isSystemContact = ContactAccessor.getInstance().isSystemContact(WebRtcCallService.this, recipient.getNumber());
boolean isAlwaysTurn = TextSecurePreferences.isTurnOnly(WebRtcCallService.this);
WebRtcCallService.this.peerConnection = new PeerConnectionWrapper(WebRtcCallService.this, peerConnectionFactory, WebRtcCallService.this, localRenderer, result, !isSystemContact || isAlwaysTurn);
WebRtcCallService.this.peerConnection.setRemoteDescription(new SessionDescription(SessionDescription.Type.OFFER, offer));
WebRtcCallService.this.lockManager.updatePhoneState(LockManager.PhoneState.PROCESSING);
SessionDescription sdp = WebRtcCallService.this.peerConnection.createAnswer(new MediaConstraints());
Log.w(TAG, "Answer SDP: " + sdp.description);
WebRtcCallService.this.peerConnection.setLocalDescription(sdp);
ListenableFutureTask<Boolean> listenableFutureTask = sendMessage(recipient, SignalServiceCallMessage.forAnswer(new AnswerMessage(WebRtcCallService.this.callId, sdp.description)));
listenableFutureTask.addListener(new FailureListener<Boolean>(WebRtcCallService.this.callState, WebRtcCallService.this.callId) {
@Override
public void onFailureContinue(Throwable error) {
Log.w(TAG, error);
terminate();
}
});
} catch (PeerConnectionException e) {
Log.w(TAG, e);
terminate();
}
}
});
}
Aggregations