Search in sources :

Example 6 with GroupCall

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

the class GroupPreJoinActionProcessor method handleCancelPreJoinCall.

@Override
@NonNull
protected WebRtcServiceState handleCancelPreJoinCall(@NonNull WebRtcServiceState currentState) {
    Log.i(TAG, "handleCancelPreJoinCall():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    try {
        groupCall.disconnect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to disconnect from group call", e);
    }
    WebRtcVideoUtil.deinitializeVideo(currentState);
    EglBaseWrapper.releaseEglBase(RemotePeer.GROUP_CALL_ID.longValue());
    return new WebRtcServiceState(new IdleActionProcessor(webRtcInteractor));
}
Also used : CallException(org.signal.ringrtc.CallException) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) GroupCall(org.signal.ringrtc.GroupCall) NonNull(androidx.annotation.NonNull)

Example 7 with GroupCall

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

the class GroupJoiningActionProcessor method handleLocalHangup.

@NonNull
protected WebRtcServiceState handleLocalHangup(@NonNull WebRtcServiceState currentState) {
    Log.i(tag, "handleLocalHangup():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    try {
        groupCall.disconnect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to disconnect from group call", e);
    }
    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) NonNull(androidx.annotation.NonNull)

Example 8 with GroupCall

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

the class GroupPreJoinActionProcessor 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());
    return currentState.builder().changeCallInfoState().groupCallState(WebRtcUtil.groupCallStateForConnection(device.getConnectionState())).build();
}
Also used : GroupCall(org.signal.ringrtc.GroupCall) NonNull(androidx.annotation.NonNull)

Example 9 with GroupCall

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

the class GroupJoiningActionProcessor method handleLocalHangup.

@NonNull
protected WebRtcServiceState handleLocalHangup(@NonNull WebRtcServiceState currentState) {
    Log.i(tag, "handleLocalHangup():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    try {
        groupCall.disconnect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to disconnect from group call", e);
    }
    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) NonNull(androidx.annotation.NonNull)

Example 10 with GroupCall

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

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)

Aggregations

GroupCall (org.signal.ringrtc.GroupCall)42 NonNull (androidx.annotation.NonNull)40 CallException (org.signal.ringrtc.CallException)30 Recipient (org.thoughtcrime.securesms.recipients.Recipient)14 RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)10 ArrayList (java.util.ArrayList)8 WebRtcViewModel (org.thoughtcrime.securesms.events.WebRtcViewModel)8 WebRtcServiceState (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState)8 WebRtcServiceStateBuilder (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder)8 Stream (com.annimon.stream.Stream)6 List (java.util.List)6 Log (org.signal.core.util.logging.Log)6 PeekInfo (org.signal.ringrtc.PeekInfo)6 BroadcastVideoSink (org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink)6 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)6 CallParticipantId (org.thoughtcrime.securesms.events.CallParticipantId)6 Camera (org.thoughtcrime.securesms.ringrtc.Camera)6 HashSet (java.util.HashSet)4 UUID (java.util.UUID)4 VideoState (org.thoughtcrime.securesms.service.webrtc.state.VideoState)4