Search in sources :

Example 21 with GroupCall

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

the class GroupPreJoinActionProcessor method handlePreJoinCall.

@Override
@NonNull
protected WebRtcServiceState handlePreJoinCall(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer) {
    Log.i(TAG, "handlePreJoinCall():");
    byte[] groupId = currentState.getCallInfoState().getCallRecipient().requireGroupId().getDecodedId();
    GroupCall groupCall = webRtcInteractor.getCallManager().createGroupCall(groupId, SignalStore.internalValues().groupCallingServer(), new byte[0], null, AudioProcessingMethodSelector.get(), webRtcInteractor.getGroupCallObserver());
    try {
        groupCall.setOutgoingAudioMuted(true);
        groupCall.setOutgoingVideoMuted(true);
        groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
        Log.i(TAG, "Connecting to group call: " + currentState.getCallInfoState().getCallRecipient().getId());
        groupCall.connect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to connect to group call", e);
    }
    SignalStore.tooltips().markGroupCallingLobbyEntered();
    return currentState.builder().changeCallInfoState().groupCall(groupCall).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).activePeer(new RemotePeer(currentState.getCallInfoState().getCallRecipient().getId(), RemotePeer.GROUP_CALL_ID)).build();
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Example 22 with GroupCall

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

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 23 with GroupCall

use of org.signal.ringrtc.GroupCall 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 24 with GroupCall

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

the class GroupActionProcessor method handleGroupRemoteDeviceStateChanged.

@Override
@NonNull
protected WebRtcServiceState handleGroupRemoteDeviceStateChanged(@NonNull WebRtcServiceState currentState) {
    Log.i(tag, "handleGroupRemoteDeviceStateChanged():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    Map<CallParticipantId, CallParticipant> participants = currentState.getCallInfoState().getRemoteCallParticipantsMap();
    LongSparseArray<GroupCall.RemoteDeviceState> remoteDevices = groupCall.getRemoteDeviceStates();
    if (remoteDevices == null) {
        Log.w(tag, "Unable to update remote devices with null list.");
        return currentState;
    }
    WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder().changeCallInfoState().clearParticipantMap();
    List<GroupCall.RemoteDeviceState> remoteDeviceStates = new ArrayList<>(remoteDevices.size());
    for (int i = 0; i < remoteDevices.size(); i++) {
        remoteDeviceStates.add(remoteDevices.get(remoteDevices.keyAt(i)));
    }
    Collections.sort(remoteDeviceStates, (a, b) -> Long.compare(a.getAddedTime(), b.getAddedTime()));
    Set<Recipient> seen = new HashSet<>();
    seen.add(Recipient.self());
    for (GroupCall.RemoteDeviceState device : remoteDeviceStates) {
        Recipient recipient = Recipient.externalPush(ACI.from(device.getUserId()), null, false);
        CallParticipantId callParticipantId = new CallParticipantId(device.getDemuxId(), recipient.getId());
        CallParticipant callParticipant = participants.get(callParticipantId);
        BroadcastVideoSink videoSink;
        VideoTrack videoTrack = device.getVideoTrack();
        if (videoTrack != null) {
            videoSink = (callParticipant != null && callParticipant.getVideoSink().getLockableEglBase().getEglBase() != null) ? callParticipant.getVideoSink() : new BroadcastVideoSink(currentState.getVideoState().getLockableEglBase(), true, true, currentState.getLocalDeviceState().getOrientation().getDegrees());
            videoTrack.addSink(videoSink);
        } else {
            videoSink = new BroadcastVideoSink();
        }
        builder.putParticipant(callParticipantId, CallParticipant.createRemote(callParticipantId, recipient, null, videoSink, Boolean.FALSE.equals(device.getAudioMuted()), Boolean.FALSE.equals(device.getVideoMuted()), device.getSpeakerTime(), device.getMediaKeysReceived(), device.getAddedTime(), Boolean.TRUE.equals(device.getPresenting()), seen.contains(recipient) ? CallParticipant.DeviceOrdinal.SECONDARY : CallParticipant.DeviceOrdinal.PRIMARY));
        seen.add(recipient);
    }
    builder.remoteDevicesCount(remoteDevices.size());
    return builder.build();
}
Also used : CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) ArrayList(java.util.ArrayList) CallParticipantId(org.thoughtcrime.securesms.events.CallParticipantId) Recipient(org.thoughtcrime.securesms.recipients.Recipient) WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) VideoTrack(org.webrtc.VideoTrack) GroupCall(org.signal.ringrtc.GroupCall) HashSet(java.util.HashSet) NonNull(androidx.annotation.NonNull)

Example 25 with GroupCall

use of org.signal.ringrtc.GroupCall 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

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