Search in sources :

Example 36 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.

the class ActiveCallActionProcessorDelegate method handleLocalHangup.

@Override
@NonNull
protected WebRtcServiceState handleLocalHangup(@NonNull WebRtcServiceState currentState) {
    RemotePeer remotePeer = currentState.getCallInfoState().getActivePeer();
    if (remotePeer == null) {
        Log.i(tag, "handleLocalHangup(): no active peer");
    } else {
        Log.i(tag, "handleLocalHangup(): call_id: " + remotePeer.getCallId());
    }
    ApplicationDependencies.getSignalServiceAccountManager().cancelInFlightRequests();
    ApplicationDependencies.getSignalServiceMessageSender().cancelInFlightRequests();
    try {
        webRtcInteractor.getCallManager().hangup();
        currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).build();
        webRtcInteractor.postStateUpdate(currentState);
        return terminate(currentState, remotePeer);
    } catch (CallException e) {
        return callFailure(currentState, "hangup() failed: ", e);
    }
}
Also used : CallException(org.signal.ringrtc.CallException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Example 37 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.

the class ActiveCallActionProcessorDelegate method handleSetupFailure.

@Override
@NonNull
protected WebRtcServiceState handleSetupFailure(@NonNull WebRtcServiceState currentState, @NonNull CallId callId) {
    Log.i(tag, "handleSetupFailure(): call_id: " + callId);
    RemotePeer activePeer = currentState.getCallInfoState().getActivePeer();
    if (activePeer != null && activePeer.getCallId().equals(callId)) {
        try {
            if (activePeer.getState() == CallState.DIALING || activePeer.getState() == CallState.REMOTE_RINGING) {
                webRtcInteractor.getCallManager().hangup();
            } else {
                webRtcInteractor.getCallManager().drop(callId);
            }
        } catch (CallException e) {
            return callFailure(currentState, "Unable to drop call due to setup failure", e);
        }
        currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.NETWORK_FAILURE).build();
        webRtcInteractor.postStateUpdate(currentState);
        if (activePeer.getState() == CallState.ANSWERING || activePeer.getState() == CallState.LOCAL_RINGING) {
            webRtcInteractor.insertMissedCall(activePeer, activePeer.getCallStartTimestamp(), currentState.getCallSetupState(activePeer).isRemoteVideoOffer());
        }
        return terminate(currentState, activePeer);
    }
    return currentState;
}
Also used : CallException(org.signal.ringrtc.CallException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Example 38 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.

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 39 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.

the class GroupActionProcessor method handleUpdateRenderedResolutions.

@Override
@NonNull
protected WebRtcServiceState handleUpdateRenderedResolutions(@NonNull WebRtcServiceState currentState) {
    Map<CallParticipantId, CallParticipant> participants = currentState.getCallInfoState().getRemoteCallParticipantsMap();
    ArrayList<GroupCall.VideoRequest> resolutionRequests = new ArrayList<>(participants.size());
    for (Map.Entry<CallParticipantId, CallParticipant> entry : participants.entrySet()) {
        BroadcastVideoSink videoSink = entry.getValue().getVideoSink();
        BroadcastVideoSink.RequestedSize maxSize = videoSink.getMaxRequestingSize();
        resolutionRequests.add(new GroupCall.VideoRequest(entry.getKey().getDemuxId(), maxSize.getWidth(), maxSize.getHeight(), null));
        videoSink.setCurrentlyRequestedMaxSize(maxSize);
    }
    try {
        currentState.getCallInfoState().requireGroupCall().requestVideo(resolutionRequests);
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to set rendered resolutions", e);
    }
    return currentState;
}
Also used : CallException(org.signal.ringrtc.CallException) CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) ArrayList(java.util.ArrayList) CallParticipantId(org.thoughtcrime.securesms.events.CallParticipantId) GroupCall(org.signal.ringrtc.GroupCall) Map(java.util.Map) NonNull(androidx.annotation.NonNull)

Example 40 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.

the class GroupActionProcessor method handleGroupRequestUpdateMembers.

@Override
@NonNull
protected WebRtcServiceState handleGroupRequestUpdateMembers(@NonNull WebRtcServiceState currentState) {
    Log.i(tag, "handleGroupRequestUpdateMembers():");
    Recipient group = currentState.getCallInfoState().getCallRecipient();
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    List<GroupCall.GroupMemberInfo> members = Stream.of(GroupManager.getUuidCipherTexts(context, group.requireGroupId().requireV2())).map(entry -> new GroupCall.GroupMemberInfo(entry.getKey(), entry.getValue().serialize())).toList();
    try {
        groupCall.setGroupMembers(new ArrayList<>(members));
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable set group members", e);
    }
    return currentState;
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) OfferMessage(org.whispersystems.signalservice.api.messages.calls.OfferMessage) CallException(org.signal.ringrtc.CallException) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) GroupManager(org.thoughtcrime.securesms.groups.GroupManager) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) CallParticipantId(org.thoughtcrime.securesms.events.CallParticipantId) Map(java.util.Map) Recipient(org.thoughtcrime.securesms.recipients.Recipient) VideoState(org.thoughtcrime.securesms.service.webrtc.state.VideoState) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) ACI(org.whispersystems.signalservice.api.push.ACI) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) Collection(java.util.Collection) BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) Set(java.util.Set) GroupCall(org.signal.ringrtc.GroupCall) Log(org.signal.core.util.logging.Log) List(java.util.List) VideoTrack(org.webrtc.VideoTrack) WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) LongSparseArray(android.util.LongSparseArray) Collections(java.util.Collections) CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) Recipient(org.thoughtcrime.securesms.recipients.Recipient) NonNull(androidx.annotation.NonNull)

Aggregations

CallException (org.signal.ringrtc.CallException)70 NonNull (androidx.annotation.NonNull)62 RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)36 GroupCall (org.signal.ringrtc.GroupCall)34 Recipient (org.thoughtcrime.securesms.recipients.Recipient)16 WebRtcServiceState (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState)12 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)10 Stream (com.annimon.stream.Stream)8 List (java.util.List)8 Log (org.signal.core.util.logging.Log)8 WebRtcViewModel (org.thoughtcrime.securesms.events.WebRtcViewModel)8 VideoState (org.thoughtcrime.securesms.service.webrtc.state.VideoState)8 ResultReceiver (android.os.ResultReceiver)6 Nullable (androidx.annotation.Nullable)6 Collection (java.util.Collection)6 Collections (java.util.Collections)6 Set (java.util.Set)6 UUID (java.util.UUID)6 CallManager (org.signal.ringrtc.CallManager)6 GroupManager (org.thoughtcrime.securesms.groups.GroupManager)6