use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class IncomingCallActionProcessor method handleDenyCall.
@NonNull
protected WebRtcServiceState handleDenyCall(@NonNull WebRtcServiceState currentState) {
RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
if (activePeer.getState() != CallState.LOCAL_RINGING) {
Log.w(TAG, "Can only deny from ringing!");
return currentState;
}
Log.i(TAG, "handleDenyCall():");
try {
webRtcInteractor.getCallManager().hangup();
SignalDatabase.sms().insertMissedCall(activePeer.getId(), System.currentTimeMillis(), currentState.getCallSetupState(activePeer).isRemoteVideoOffer());
return terminate(currentState, activePeer);
} catch (CallException e) {
return callFailure(currentState, "hangup() failed: ", e);
}
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class IncomingCallActionProcessor method handleTurnServerUpdate.
@Override
@NonNull
public WebRtcServiceState handleTurnServerUpdate(@NonNull WebRtcServiceState currentState, @NonNull List<PeerConnection.IceServer> iceServers, boolean isAlwaysTurn) {
RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
boolean hideIp = !activePeer.getRecipient().isSystemContact() || isAlwaysTurn;
VideoState videoState = currentState.getVideoState();
CallParticipant callParticipant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
try {
webRtcInteractor.getCallManager().proceed(activePeer.getCallId(), context, videoState.getLockableEglBase().require(), AudioProcessingMethodSelector.get(), videoState.requireLocalSink(), callParticipant.getVideoSink(), videoState.requireCamera(), iceServers, hideIp, NetworkUtil.getCallingBandwidthMode(context), null, false);
} catch (CallException e) {
return callFailure(currentState, "Unable to proceed with call: ", e);
}
webRtcInteractor.updatePhoneState(LockManager.PhoneState.PROCESSING);
webRtcInteractor.postStateUpdate(currentState);
return currentState;
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class IncomingCallActionProcessor method handleAcceptCall.
@Override
@NonNull
protected WebRtcServiceState handleAcceptCall(@NonNull WebRtcServiceState currentState, boolean answerWithVideo) {
RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
Log.i(TAG, "handleAcceptCall(): call_id: " + activePeer.getCallId());
SignalDatabase.sms().insertReceivedCall(activePeer.getId(), currentState.getCallSetupState(activePeer).isRemoteVideoOffer());
currentState = currentState.builder().changeCallSetupState(activePeer.getCallId()).acceptWithVideo(answerWithVideo).build();
try {
webRtcInteractor.getCallManager().acceptCall(activePeer.getCallId());
} catch (CallException e) {
return callFailure(currentState, "accept() failed: ", e);
}
return currentState;
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class OutgoingCallActionProcessor method handleTurnServerUpdate.
@Override
@NonNull
public WebRtcServiceState handleTurnServerUpdate(@NonNull WebRtcServiceState currentState, @NonNull List<PeerConnection.IceServer> iceServers, boolean isAlwaysTurn) {
try {
VideoState videoState = currentState.getVideoState();
RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
CallParticipant callParticipant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
webRtcInteractor.getCallManager().proceed(activePeer.getCallId(), context, videoState.getLockableEglBase().require(), AudioProcessingMethodSelector.get(), videoState.requireLocalSink(), callParticipant.getVideoSink(), videoState.requireCamera(), iceServers, isAlwaysTurn, NetworkUtil.getCallingBandwidthMode(context), null, currentState.getCallSetupState(activePeer).isEnableVideoOnCreate());
} catch (CallException e) {
return callFailure(currentState, "Unable to proceed with call: ", e);
}
return currentState.builder().changeLocalDeviceState().cameraState(currentState.getVideoState().requireCamera().getCameraState()).build();
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.
the class SignalCallManager method retrieveTurnServers.
public void retrieveTurnServers(@NonNull RemotePeer remotePeer) {
networkExecutor.execute(() -> {
try {
TurnServerInfo turnServerInfo = accountManager.getTurnServerInfo();
List<PeerConnection.IceServer> iceServers = new LinkedList<>();
iceServers.add(PeerConnection.IceServer.builder("stun:stun1.l.google.com:19302").createIceServer());
for (String url : turnServerInfo.getUrls()) {
Log.i(TAG, "ice_server: " + url);
if (url.startsWith("turn")) {
iceServers.add(PeerConnection.IceServer.builder(url).setUsername(turnServerInfo.getUsername()).setPassword(turnServerInfo.getPassword()).createIceServer());
} else {
iceServers.add(PeerConnection.IceServer.builder(url).createIceServer());
}
}
process((s, p) -> {
RemotePeer activePeer = s.getCallInfoState().getActivePeer();
if (activePeer != null && activePeer.getCallId().equals(remotePeer.getCallId())) {
return p.handleTurnServerUpdate(s, iceServers, TextSecurePreferences.isTurnOnly(context));
}
Log.w(TAG, "Ignoring received turn servers for incorrect call id. requesting_call_id: " + remotePeer.getCallId() + " current_call_id: " + (activePeer != null ? activePeer.getCallId() : "null"));
return s;
});
} catch (IOException e) {
Log.w(TAG, "Unable to retrieve turn servers: ", e);
process((s, p) -> p.handleSetupFailure(s, remotePeer.getCallId()));
}
});
}
Aggregations