Search in sources :

Example 16 with RemotePeer

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();
}
Also used : RecipientDatabase(org.thoughtcrime.securesms.database.RecipientDatabase) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Recipient(org.thoughtcrime.securesms.recipients.Recipient) Uri(android.net.Uri) NonNull(androidx.annotation.NonNull)

Example 17 with RemotePeer

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;
}
Also used : CallException(org.signal.ringrtc.CallException) CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) VideoState(org.thoughtcrime.securesms.service.webrtc.state.VideoState) NonNull(androidx.annotation.NonNull)

Example 18 with RemotePeer

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));
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer)

Example 19 with 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;
    });
}
Also used : CallException(org.signal.ringrtc.CallException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer)

Example 20 with RemotePeer

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);
    }
}
Also used : InvalidInputException(org.signal.zkgroup.InvalidInputException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) GroupId(org.thoughtcrime.securesms.groups.GroupId) GroupIdentifier(org.signal.zkgroup.groups.GroupIdentifier)

Aggregations

RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)70 NonNull (androidx.annotation.NonNull)44 CallException (org.signal.ringrtc.CallException)32 CallId (org.signal.ringrtc.CallId)14 Recipient (org.thoughtcrime.securesms.recipients.Recipient)14 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)10 GroupId (org.thoughtcrime.securesms.groups.GroupId)10 WebRtcData (org.thoughtcrime.securesms.service.webrtc.WebRtcData)10 OfferMessage (org.whispersystems.signalservice.api.messages.calls.OfferMessage)10 Context (android.content.Context)8 Build (android.os.Build)8 Nullable (androidx.annotation.Nullable)8 Stream (com.annimon.stream.Stream)8 IOException (java.io.IOException)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8 LinkedList (java.util.LinkedList)8 List (java.util.List)8 UUID (java.util.UUID)8 Log (org.signal.core.util.logging.Log)8