Search in sources :

Example 31 with GroupCall

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

the class GroupConnectedActionProcessor method handleGroupLocalDeviceStateChanged.

@Override
@NonNull
protected WebRtcServiceState handleGroupLocalDeviceStateChanged(@NonNull WebRtcServiceState currentState) {
    Log.i(tag, "handleGroupLocalDeviceStateChanged():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    GroupCall.LocalDeviceState device = groupCall.getLocalDeviceState();
    GroupCall.ConnectionState connectionState = device.getConnectionState();
    GroupCall.JoinState joinState = device.getJoinState();
    Log.i(tag, "local device changed: " + connectionState + " " + joinState);
    WebRtcViewModel.GroupCallState groupCallState = WebRtcUtil.groupCallStateForConnection(connectionState);
    if (connectionState == GroupCall.ConnectionState.CONNECTED || connectionState == GroupCall.ConnectionState.CONNECTING) {
        if (joinState == GroupCall.JoinState.JOINED) {
            groupCallState = WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
        } else if (joinState == GroupCall.JoinState.JOINING) {
            groupCallState = WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINING;
        }
    }
    return currentState.builder().changeCallInfoState().groupCallState(groupCallState).build();
}
Also used : GroupCall(org.signal.ringrtc.GroupCall) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) NonNull(androidx.annotation.NonNull)

Example 32 with GroupCall

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

the class GroupConnectedActionProcessor method handleGroupJoinedMembershipChanged.

@Override
@NonNull
protected WebRtcServiceState handleGroupJoinedMembershipChanged(@NonNull WebRtcServiceState currentState) {
    Log.i(tag, "handleGroupJoinedMembershipChanged():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    PeekInfo peekInfo = groupCall.getPeekInfo();
    if (peekInfo == null) {
        return currentState;
    }
    if (currentState.getCallSetupState(RemotePeer.GROUP_CALL_ID).hasSentJoinedMessage()) {
        return currentState;
    }
    String eraId = WebRtcUtil.getGroupCallEraId(groupCall);
    webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId);
    List<UUID> members = new ArrayList<>(peekInfo.getJoinedMembers());
    if (!members.contains(Recipient.self().requireServiceId().uuid())) {
        members.add(Recipient.self().requireServiceId().uuid());
    }
    webRtcInteractor.updateGroupCallUpdateMessage(currentState.getCallInfoState().getCallRecipient().getId(), eraId, members, WebRtcUtil.isCallFull(peekInfo));
    return currentState.builder().changeCallSetupState(RemotePeer.GROUP_CALL_ID).sentJoinedMessage(true).build();
}
Also used : GroupCall(org.signal.ringrtc.GroupCall) ArrayList(java.util.ArrayList) PeekInfo(org.signal.ringrtc.PeekInfo) UUID(java.util.UUID) NonNull(androidx.annotation.NonNull)

Example 33 with GroupCall

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

the class GroupConnectedActionProcessor method handleLocalHangup.

@Override
@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);
    }
    String eraId = WebRtcUtil.getGroupCallEraId(groupCall);
    webRtcInteractor.sendGroupCallMessage(currentState.getCallInfoState().getCallRecipient(), eraId);
    List<UUID> members = Stream.of(currentState.getCallInfoState().getRemoteCallParticipants()).map(p -> p.getRecipient().requireServiceId().uuid()).toList();
    webRtcInteractor.updateGroupCallUpdateMessage(currentState.getCallInfoState().getCallRecipient().getId(), eraId, members, false);
    currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
    webRtcInteractor.postStateUpdate(currentState);
    return terminateGroupCall(currentState);
}
Also used : RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Stream(com.annimon.stream.Stream) NonNull(androidx.annotation.NonNull) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) UUID(java.util.UUID) CallException(org.signal.ringrtc.CallException) ArrayList(java.util.ArrayList) GroupCall(org.signal.ringrtc.GroupCall) Log(org.signal.core.util.logging.Log) List(java.util.List) Nullable(androidx.annotation.Nullable) PeekInfo(org.signal.ringrtc.PeekInfo) Recipient(org.thoughtcrime.securesms.recipients.Recipient) ResultReceiver(android.os.ResultReceiver) Camera(org.thoughtcrime.securesms.ringrtc.Camera) WebRtcServiceState(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState) CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) UUID(java.util.UUID) NonNull(androidx.annotation.NonNull)

Example 34 with GroupCall

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

the class SignalCallManager method requestMembershipProof.

@Override
public void requestMembershipProof(@NonNull final GroupCall groupCall) {
    Log.i(TAG, "requestMembershipProof():");
    Recipient recipient = serviceState.getCallInfoState().getCallRecipient();
    if (!recipient.isPushV2Group()) {
        Log.i(TAG, "Request membership proof for non-group");
        return;
    }
    GroupCall currentGroupCall = serviceState.getCallInfoState().getGroupCall();
    if (currentGroupCall == null || currentGroupCall.hashCode() != groupCall.hashCode()) {
        Log.i(TAG, "Skipping group membership proof request, requested group call does not match current group call");
        return;
    }
    networkExecutor.execute(() -> {
        try {
            GroupExternalCredential credential = GroupManager.getGroupExternalCredential(context, recipient.getGroupId().get().requireV2());
            process((s, p) -> p.handleGroupRequestMembershipProof(s, groupCall.hashCode(), credential.getTokenBytes().toByteArray()));
        } catch (IOException e) {
            Log.w(TAG, "Unable to get group membership proof from service", e);
            onEnded(groupCall, GroupCall.GroupCallEndReason.SFU_CLIENT_FAILED_TO_JOIN);
        } catch (VerificationFailedException e) {
            Log.w(TAG, "Unable to verify group membership proof", e);
            onEnded(groupCall, GroupCall.GroupCallEndReason.DEVICE_EXPLICITLY_DISCONNECTED);
        }
    });
}
Also used : GroupCall(org.signal.ringrtc.GroupCall) Recipient(org.thoughtcrime.securesms.recipients.Recipient) IOException(java.io.IOException) GroupExternalCredential(org.signal.storageservice.protos.groups.GroupExternalCredential) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Example 35 with GroupCall

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

the class GroupConnectedActionProcessor method handleGroupLocalDeviceStateChanged.

@Override
@NonNull
protected WebRtcServiceState handleGroupLocalDeviceStateChanged(@NonNull WebRtcServiceState currentState) {
    Log.i(tag, "handleGroupLocalDeviceStateChanged():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    GroupCall.LocalDeviceState device = groupCall.getLocalDeviceState();
    GroupCall.ConnectionState connectionState = device.getConnectionState();
    GroupCall.JoinState joinState = device.getJoinState();
    Log.i(tag, "local device changed: " + connectionState + " " + joinState);
    WebRtcViewModel.GroupCallState groupCallState = WebRtcUtil.groupCallStateForConnection(connectionState);
    if (connectionState == GroupCall.ConnectionState.CONNECTED || connectionState == GroupCall.ConnectionState.CONNECTING) {
        if (joinState == GroupCall.JoinState.JOINED) {
            groupCallState = WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
        } else if (joinState == GroupCall.JoinState.JOINING) {
            groupCallState = WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINING;
        }
    }
    return currentState.builder().changeCallInfoState().groupCallState(groupCallState).build();
}
Also used : GroupCall(org.signal.ringrtc.GroupCall) WebRtcViewModel(org.thoughtcrime.securesms.events.WebRtcViewModel) 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