Search in sources :

Example 26 with CallException

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

the class WebRtcActionProcessor method groupCallFailure.

@NonNull
protected WebRtcServiceState groupCallFailure(@NonNull WebRtcServiceState currentState, @NonNull String message, @NonNull Throwable error) {
    Log.w(tag, "groupCallFailure(): " + message, error);
    GroupCall groupCall = currentState.getCallInfoState().getGroupCall();
    Recipient recipient = currentState.getCallInfoState().getCallRecipient();
    if (recipient != null && currentState.getCallInfoState().getGroupCallState().isConnected()) {
        webRtcInteractor.sendGroupCallMessage(recipient, WebRtcUtil.getGroupCallEraId(groupCall));
    }
    currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
    webRtcInteractor.postStateUpdate(currentState);
    try {
        if (groupCall != null) {
            groupCall.disconnect();
        }
        webRtcInteractor.getCallManager().reset();
    } catch (CallException e) {
        Log.w(tag, "Unable to reset call manager: ", e);
    }
    return terminateGroupCall(currentState);
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) Recipient(org.thoughtcrime.securesms.recipients.Recipient) NonNull(androidx.annotation.NonNull)

Example 27 with CallException

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

the class WebRtcActionProcessor method callFailure.

// endregion
// region Global call operations
@NonNull
public WebRtcServiceState callFailure(@NonNull WebRtcServiceState currentState, @Nullable String message, @Nullable Throwable error) {
    Log.w(tag, "callFailure(): " + message, error);
    WebRtcServiceStateBuilder builder = currentState.builder();
    if (currentState.getCallInfoState().getActivePeer() != null) {
        builder.changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED);
    }
    try {
        webRtcInteractor.getCallManager().reset();
    } catch (CallException e) {
        Log.w(tag, "Unable to reset call manager: ", e);
    }
    EglBaseWrapper.forceRelease();
    currentState = builder.changeCallInfoState().clearPeerMap().build();
    return terminate(currentState, currentState.getCallInfoState().getActivePeer());
}
Also used : CallException(org.signal.ringrtc.CallException) WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) NonNull(androidx.annotation.NonNull)

Example 28 with CallException

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

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)

Example 29 with CallException

use of org.signal.ringrtc.CallException 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 30 with CallException

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

the class GroupActionProcessor method handleGroupRequestMembershipProof.

@Override
@NonNull
protected WebRtcServiceState handleGroupRequestMembershipProof(@NonNull WebRtcServiceState currentState, int groupCallHash, @NonNull byte[] groupMembershipToken) {
    Log.i(tag, "handleGroupRequestMembershipProof():");
    GroupCall groupCall = currentState.getCallInfoState().getGroupCall();
    if (groupCall == null || groupCall.hashCode() != groupCallHash) {
        return currentState;
    }
    try {
        groupCall.setMembershipProof(groupMembershipToken);
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to set group membership proof", e);
    }
    return currentState;
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) 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