Search in sources :

Example 41 with CallException

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

the class GroupActionProcessor method handleGroupApproveSafetyNumberChange.

@Override
@NonNull
protected WebRtcServiceState handleGroupApproveSafetyNumberChange(@NonNull WebRtcServiceState currentState, @NonNull List<RecipientId> recipientIds) {
    Log.i(tag, "handleGroupApproveSafetyNumberChange():");
    GroupCall groupCall = currentState.getCallInfoState().getGroupCall();
    if (groupCall != null) {
        currentState = currentState.builder().changeCallInfoState().removeIdentityChangedRecipients(recipientIds).build();
        try {
            groupCall.resendMediaKeys();
        } catch (CallException e) {
            return groupCallFailure(currentState, "Unable to resend media keys", e);
        }
    }
    return currentState;
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) NonNull(androidx.annotation.NonNull)

Example 42 with CallException

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

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)

Example 43 with CallException

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

the class GroupJoiningActionProcessor method handleGroupLocalDeviceStateChanged.

@Override
@NonNull
protected WebRtcServiceState handleGroupLocalDeviceStateChanged(@NonNull WebRtcServiceState currentState) {
    Log.i(tag, "handleGroupLocalDeviceStateChanged():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    GroupCall.LocalDeviceState device = groupCall.getLocalDeviceState();
    Log.i(tag, "local device changed: " + device.getConnectionState() + " " + device.getJoinState());
    WebRtcServiceStateBuilder builder = currentState.builder();
    switch(device.getConnectionState()) {
        case NOT_CONNECTED:
        case RECONNECTING:
            builder.changeCallInfoState().groupCallState(WebRtcUtil.groupCallStateForConnection(device.getConnectionState())).commit();
            break;
        case CONNECTING:
        case CONNECTED:
            if (device.getJoinState() == GroupCall.JoinState.JOINED) {
                webRtcInteractor.setCallInProgressNotification(TYPE_ESTABLISHED, currentState.getCallInfoState().getCallRecipient());
                webRtcInteractor.startAudioCommunication();
                if (currentState.getLocalDeviceState().getCameraState().isEnabled()) {
                    webRtcInteractor.updatePhoneState(LockManager.PhoneState.IN_VIDEO);
                } else {
                    webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context));
                }
                try {
                    groupCall.setOutgoingVideoMuted(!currentState.getLocalDeviceState().getCameraState().isEnabled());
                    groupCall.setOutgoingAudioMuted(!currentState.getLocalDeviceState().isMicrophoneEnabled());
                    groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, device.getNetworkRoute().getLocalAdapterType()));
                } catch (CallException e) {
                    Log.e(tag, e);
                    throw new RuntimeException(e);
                }
                if (FeatureFlags.groupCallRinging() && currentState.getCallSetupState(RemotePeer.GROUP_CALL_ID).shouldRingGroup()) {
                    try {
                        groupCall.ringAll();
                    } catch (CallException e) {
                        return groupCallFailure(currentState, "Unable to ring group", e);
                    }
                }
                builder.changeCallInfoState().callState(WebRtcViewModel.State.CALL_CONNECTED).groupCallState(WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED).callConnectedTime(System.currentTimeMillis()).commit().changeLocalDeviceState().commit().actionProcessor(new GroupConnectedActionProcessor(webRtcInteractor));
            } else if (device.getJoinState() == GroupCall.JoinState.JOINING) {
                builder.changeCallInfoState().groupCallState(WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINING).commit();
            } else {
                builder.changeCallInfoState().groupCallState(WebRtcUtil.groupCallStateForConnection(device.getConnectionState())).commit();
            }
            break;
    }
    return builder.build();
}
Also used : CallException(org.signal.ringrtc.CallException) WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) GroupCall(org.signal.ringrtc.GroupCall) NonNull(androidx.annotation.NonNull)

Example 44 with CallException

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

the class GroupJoiningActionProcessor method handleSetEnableVideo.

@Override
@NonNull
protected WebRtcServiceState handleSetEnableVideo(@NonNull WebRtcServiceState currentState, boolean enable) {
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    Camera camera = currentState.getVideoState().requireCamera();
    try {
        groupCall.setOutgoingVideoMuted(!enable);
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to set video muted", e);
    }
    camera.setEnabled(enable);
    currentState = currentState.builder().changeLocalDeviceState().cameraState(camera.getCameraState()).build();
    WebRtcUtil.enableSpeakerPhoneIfNeeded(webRtcInteractor, currentState);
    return currentState;
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) Camera(org.thoughtcrime.securesms.ringrtc.Camera) NonNull(androidx.annotation.NonNull)

Example 45 with CallException

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

the class GroupPreJoinActionProcessor method handleOutgoingCall.

@Override
@NonNull
protected WebRtcServiceState handleOutgoingCall(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer, @NonNull OfferMessage.Type offerType) {
    Log.i(TAG, "handleOutgoingCall():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    currentState = WebRtcVideoUtil.reinitializeCamera(context, webRtcInteractor.getCameraEventListener(), currentState);
    webRtcInteractor.setCallInProgressNotification(TYPE_OUTGOING_RINGING, currentState.getCallInfoState().getCallRecipient());
    webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context));
    webRtcInteractor.initializeAudioForCall();
    try {
        groupCall.setOutgoingVideoSource(currentState.getVideoState().requireLocalSink(), currentState.getVideoState().requireCamera());
        groupCall.setOutgoingVideoMuted(!currentState.getLocalDeviceState().getCameraState().isEnabled());
        groupCall.setOutgoingAudioMuted(!currentState.getLocalDeviceState().isMicrophoneEnabled());
        groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
        groupCall.join();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to join group call", e);
    }
    return currentState.builder().actionProcessor(new GroupJoiningActionProcessor(webRtcInteractor)).changeCallInfoState().callState(WebRtcViewModel.State.CALL_OUTGOING).groupCallState(WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINING).commit().changeLocalDeviceState().build();
}
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