use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by signalapp.
the class IncomingCallActionProcessor method handleLocalRinging.
@NonNull
protected WebRtcServiceState handleLocalRinging(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer) {
Log.i(TAG, "handleLocalRinging(): call_id: " + remotePeer.getCallId());
RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
Recipient recipient = remotePeer.getRecipient();
activePeer.localRinging();
webRtcInteractor.updatePhoneState(LockManager.PhoneState.INTERACTIVE);
boolean shouldDisturbUserWithCall = DoNotDisturbUtil.shouldDisturbUserWithCall(context.getApplicationContext(), recipient);
if (shouldDisturbUserWithCall) {
boolean started = webRtcInteractor.startWebRtcCallActivityIfPossible();
if (!started) {
Log.i(TAG, "Unable to start call activity due to OS version or not being in the foreground");
ApplicationDependencies.getAppForegroundObserver().addListener(webRtcInteractor.getForegroundListener());
}
}
if (shouldDisturbUserWithCall && SignalStore.settings().isCallNotificationsEnabled()) {
Uri ringtone = recipient.resolve().getCallRingtone();
RecipientDatabase.VibrateState vibrateState = recipient.resolve().getCallVibrate();
if (ringtone == null) {
ringtone = SignalStore.settings().getCallRingtone();
}
webRtcInteractor.startIncomingRinger(ringtone, vibrateState == RecipientDatabase.VibrateState.ENABLED || (vibrateState == RecipientDatabase.VibrateState.DEFAULT && SignalStore.settings().isCallVibrateEnabled()));
}
webRtcInteractor.setCallInProgressNotification(TYPE_INCOMING_RINGING, activePeer);
webRtcInteractor.registerPowerButtonReceiver();
return currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_INCOMING).build();
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by signalapp.
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 signalapp.
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 signalapp.
the class SignalCallManager method onCallEvent.
@Override
public void onCallEvent(@Nullable Remote remote, @NonNull CallManager.CallEvent event) {
if (callManager == null) {
Log.w(TAG, "Unable to process call event, call manager is not initialized");
return;
}
if (!(remote instanceof RemotePeer)) {
return;
}
process((s, p) -> {
RemotePeer remotePeer = (RemotePeer) remote;
if (s.getCallInfoState().getPeer(remotePeer.hashCode()) == null) {
Log.w(TAG, "remotePeer not found in map with key: " + remotePeer.hashCode() + "! Dropping.");
try {
callManager.drop(remotePeer.getCallId());
} catch (CallException e) {
return p.callFailure(s, "callManager.drop() failed: ", e);
}
return s;
}
Log.i(TAG, "onCallEvent(): call_id: " + remotePeer.getCallId() + ", state: " + remotePeer.getState() + ", event: " + event);
switch(event) {
case LOCAL_RINGING:
return p.handleLocalRinging(s, remotePeer);
case REMOTE_RINGING:
return p.handleRemoteRinging(s, remotePeer);
case RECONNECTING:
Log.i(TAG, "Reconnecting: NOT IMPLEMENTED");
break;
case RECONNECTED:
Log.i(TAG, "Reconnected: NOT IMPLEMENTED");
break;
case LOCAL_CONNECTED:
case REMOTE_CONNECTED:
return p.handleCallConnected(s, remotePeer);
case REMOTE_VIDEO_ENABLE:
return p.handleRemoteVideoEnable(s, true);
case REMOTE_VIDEO_DISABLE:
return p.handleRemoteVideoEnable(s, false);
case REMOTE_SHARING_SCREEN_ENABLE:
return p.handleScreenSharingEnable(s, true);
case REMOTE_SHARING_SCREEN_DISABLE:
return p.handleScreenSharingEnable(s, false);
case ENDED_REMOTE_HANGUP:
case ENDED_REMOTE_HANGUP_NEED_PERMISSION:
case ENDED_REMOTE_HANGUP_ACCEPTED:
case ENDED_REMOTE_HANGUP_BUSY:
case ENDED_REMOTE_HANGUP_DECLINED:
case ENDED_REMOTE_BUSY:
case ENDED_REMOTE_GLARE:
return p.handleEndedRemote(s, event, remotePeer);
case ENDED_TIMEOUT:
case ENDED_INTERNAL_FAILURE:
case ENDED_SIGNALING_FAILURE:
case ENDED_CONNECTION_FAILURE:
return p.handleEnded(s, event, remotePeer);
case RECEIVED_OFFER_EXPIRED:
return p.handleReceivedOfferExpired(s, remotePeer);
case RECEIVED_OFFER_WHILE_ACTIVE:
case RECEIVED_OFFER_WITH_GLARE:
return p.handleReceivedOfferWhileActive(s, remotePeer);
case ENDED_LOCAL_HANGUP:
case ENDED_APP_DROPPED_CALL:
Log.i(TAG, "Ignoring event: " + event);
break;
default:
throw new AssertionError("Unexpected event: " + event.toString());
}
return s;
});
}
use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by signalapp.
the class SignalCallManager method onGroupCallRingUpdate.
@Override
public void onGroupCallRingUpdate(@NonNull byte[] groupIdBytes, long ringId, @NonNull UUID uuid, @NonNull CallManager.RingUpdate ringUpdate) {
try {
GroupId.V2 groupId = GroupId.v2(new GroupIdentifier(groupIdBytes));
Optional<GroupDatabase.GroupRecord> group = SignalDatabase.groups().getGroup(groupId);
if (group.isPresent()) {
process((s, p) -> p.handleGroupCallRingUpdate(s, new RemotePeer(group.get().getRecipientId()), groupId, ringId, uuid, ringUpdate));
} else {
Log.w(TAG, "Unable to ring unknown group.");
}
} catch (InvalidInputException e) {
Log.w(TAG, "Unable to ring group due to invalid group id", e);
}
}
Aggregations