Search in sources :

Example 26 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by signalapp.

the class GroupActionProcessor method handleGroupCallEnded.

@Override
@NonNull
protected WebRtcServiceState handleGroupCallEnded(@NonNull WebRtcServiceState currentState, int groupCallHash, @NonNull GroupCall.GroupCallEndReason groupCallEndReason) {
    Log.i(tag, "handleGroupCallEnded(): reason: " + groupCallEndReason);
    GroupCall groupCall = currentState.getCallInfoState().getGroupCall();
    if (groupCall == null || groupCall.hashCode() != groupCallHash) {
        return currentState;
    }
    try {
        groupCall.disconnect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to disconnect from group call", e);
    }
    if (groupCallEndReason != GroupCall.GroupCallEndReason.DEVICE_EXPLICITLY_DISCONNECTED) {
        Log.i(tag, "Group call ended unexpectedly, reinitializing and dropping back to lobby");
        Recipient currentRecipient = currentState.getCallInfoState().getCallRecipient();
        VideoState videoState = currentState.getVideoState();
        currentState = terminateGroupCall(currentState, false).builder().actionProcessor(new GroupNetworkUnavailableActionProcessor(webRtcInteractor)).changeVideoState().eglBase(videoState.getLockableEglBase()).camera(videoState.getCamera()).localSink(videoState.getLocalSink()).commit().changeCallInfoState().callState(WebRtcViewModel.State.CALL_PRE_JOIN).callRecipient(currentRecipient).build();
        currentState = WebRtcVideoUtil.initializeVanityCamera(WebRtcVideoUtil.reinitializeCamera(context, webRtcInteractor.getCameraEventListener(), currentState));
        return currentState.getActionProcessor().handlePreJoinCall(currentState, new RemotePeer(currentRecipient.getId()));
    }
    currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
    webRtcInteractor.postStateUpdate(currentState);
    return terminateGroupCall(currentState);
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Recipient(org.thoughtcrime.securesms.recipients.Recipient) VideoState(org.thoughtcrime.securesms.service.webrtc.state.VideoState) NonNull(androidx.annotation.NonNull)

Example 27 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by signalapp.

the class MessageContentProcessor method handleCallIceUpdateMessage.

private void handleCallIceUpdateMessage(@NonNull SignalServiceContent content, @NonNull List<IceUpdateMessage> messages, @NonNull Recipient senderRecipient) {
    log(String.valueOf(content), "handleCallIceUpdateMessage... " + messages.size());
    List<byte[]> iceCandidates = new ArrayList<>(messages.size());
    long callId = -1;
    for (IceUpdateMessage iceMessage : messages) {
        iceCandidates.add(iceMessage.getOpaque());
        callId = iceMessage.getId();
    }
    RemotePeer remotePeer = new RemotePeer(senderRecipient.getId(), new CallId(callId));
    ApplicationDependencies.getSignalCallManager().receivedIceCandidates(new WebRtcData.CallMetadata(remotePeer, content.getSenderDevice()), iceCandidates);
}
Also used : IceUpdateMessage(org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage) CallId(org.signal.ringrtc.CallId) ArrayList(java.util.ArrayList) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) WebRtcData(org.thoughtcrime.securesms.service.webrtc.WebRtcData)

Example 28 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.

the class GroupPreJoinActionProcessor method handlePreJoinCall.

@Override
@NonNull
protected WebRtcServiceState handlePreJoinCall(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer) {
    Log.i(TAG, "handlePreJoinCall():");
    byte[] groupId = currentState.getCallInfoState().getCallRecipient().requireGroupId().getDecodedId();
    GroupCall groupCall = webRtcInteractor.getCallManager().createGroupCall(groupId, SignalStore.internalValues().groupCallingServer(), new byte[0], null, AudioProcessingMethodSelector.get(), webRtcInteractor.getGroupCallObserver());
    try {
        groupCall.setOutgoingAudioMuted(true);
        groupCall.setOutgoingVideoMuted(true);
        groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
        Log.i(TAG, "Connecting to group call: " + currentState.getCallInfoState().getCallRecipient().getId());
        groupCall.connect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to connect to group call", e);
    }
    SignalStore.tooltips().markGroupCallingLobbyEntered();
    return currentState.builder().changeCallInfoState().groupCall(groupCall).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).activePeer(new RemotePeer(currentState.getCallInfoState().getCallRecipient().getId(), RemotePeer.GROUP_CALL_ID)).build();
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Example 29 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.

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 30 with RemotePeer

use of org.thoughtcrime.securesms.ringrtc.RemotePeer in project Signal-Android by WhisperSystems.

the class SignalCallManager method processSendMessageFailureWithChangeDetection.

private void processSendMessageFailureWithChangeDetection(@NonNull RemotePeer remotePeer, @NonNull ProcessAction failureProcessAction) {
    process((s, p) -> {
        RemotePeer activePeer = s.getCallInfoState().getActivePeer();
        boolean stateChanged = activePeer == null || remotePeer.getState() != activePeer.getState() || !remotePeer.getCallId().equals(activePeer.getCallId());
        if (stateChanged) {
            return p.handleMessageSentSuccess(s, remotePeer.getCallId());
        } else {
            return failureProcessAction.process(s, p);
        }
    });
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer)

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