Search in sources :

Example 6 with CallParticipant

use of org.thoughtcrime.securesms.events.CallParticipant in project Signal-Android by signalapp.

the class ActiveCallActionProcessorDelegate method handleRemoteVideoEnable.

@Override
@NonNull
protected WebRtcServiceState handleRemoteVideoEnable(@NonNull WebRtcServiceState currentState, boolean enable) {
    RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
    Log.i(tag, "handleRemoteVideoEnable(): call_id: " + activePeer.getCallId());
    CallParticipant oldParticipant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
    CallParticipant newParticipant = oldParticipant.withVideoEnabled(enable);
    return currentState.builder().changeCallInfoState().putParticipant(activePeer.getRecipient(), newParticipant).build();
}
Also used : CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Example 7 with CallParticipant

use of org.thoughtcrime.securesms.events.CallParticipant in project Signal-Android by signalapp.

the class CallParticipantListUpdateTest method createWrappers.

static CallParticipantListUpdate.Wrapper[] createWrappers(long... recipientIds) {
    CallParticipantListUpdate.Wrapper[] ids = new CallParticipantListUpdate.Wrapper[recipientIds.length];
    Set<Long> primaries = new HashSet<>();
    for (int i = 0; i < recipientIds.length; i++) {
        CallParticipant participant = createParticipant(recipientIds[i], recipientIds[i], primaries.contains(recipientIds[i]) ? CallParticipant.DeviceOrdinal.SECONDARY : CallParticipant.DeviceOrdinal.PRIMARY);
        ids[i] = CallParticipantListUpdate.createWrapper(participant);
    }
    return ids;
}
Also used : CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) HashSet(java.util.HashSet)

Example 8 with CallParticipant

use of org.thoughtcrime.securesms.events.CallParticipant in project Signal-Android by WhisperSystems.

the class WebRtcCallViewModel method updateFromWebRtcViewModel.

@MainThread
public void updateFromWebRtcViewModel(@NonNull WebRtcViewModel webRtcViewModel, boolean enableVideo) {
    canEnterPipMode = !webRtcViewModel.getState().isPreJoinOrNetworkUnavailable();
    if (callStarting && webRtcViewModel.getState().isPassedPreJoin()) {
        callStarting = false;
    }
    CallParticipant localParticipant = webRtcViewModel.getLocalParticipant();
    microphoneEnabled.setValue(localParticipant.isMicrophoneEnabled());
    CallParticipantsState state = participantsState.getValue();
    boolean wasScreenSharing = state.getFocusedParticipant().isScreenSharing();
    CallParticipantsState newState = CallParticipantsState.update(state, webRtcViewModel, enableVideo);
    participantsState.setValue(newState);
    if (switchOnFirstScreenShare && !wasScreenSharing && newState.getFocusedParticipant().isScreenSharing()) {
        switchOnFirstScreenShare = false;
        events.setValue(new Event.SwitchToSpeaker());
    }
    if (webRtcViewModel.getGroupState().isConnected()) {
        if (!containsPlaceholders(previousParticipantsList)) {
            CallParticipantListUpdate update = CallParticipantListUpdate.computeDeltaUpdate(previousParticipantsList, webRtcViewModel.getRemoteParticipants());
            callParticipantListUpdate.setValue(update);
        }
        previousParticipantsList = webRtcViewModel.getRemoteParticipants();
        identityChangedRecipients.setValue(webRtcViewModel.getIdentityChangedParticipants());
    }
    updateWebRtcControls(webRtcViewModel.getState(), webRtcViewModel.getGroupState(), localParticipant.getCameraState().isEnabled(), webRtcViewModel.isRemoteVideoEnabled(), webRtcViewModel.isRemoteVideoOffer(), localParticipant.isMoreThanOneCameraAvailable(), Util.hasItems(webRtcViewModel.getRemoteParticipants()), webRtcViewModel.getActiveDevice(), webRtcViewModel.getAvailableDevices(), webRtcViewModel.getRemoteDevicesCount().orElse(0), webRtcViewModel.getParticipantLimit());
    if (newState.isInOutgoingRingingMode()) {
        cancelTimer();
        if (!wasInOutgoingRingingMode) {
            elapsedTimeHandler.postDelayed(stopOutgoingRingingMode, CallParticipantsState.MAX_OUTGOING_GROUP_RING_DURATION);
        }
        wasInOutgoingRingingMode = true;
    } else {
        if (webRtcViewModel.getState() == WebRtcViewModel.State.CALL_CONNECTED && callConnectedTime == -1) {
            callConnectedTime = wasInOutgoingRingingMode ? System.currentTimeMillis() : webRtcViewModel.getCallConnectedTime();
            startTimer();
        } else if (webRtcViewModel.getState() != WebRtcViewModel.State.CALL_CONNECTED || webRtcViewModel.getGroupState().isNotIdleOrConnected()) {
            cancelTimer();
            callConnectedTime = -1;
        }
    }
    if (localParticipant.getCameraState().isEnabled()) {
        canDisplayTooltipIfNeeded = false;
        hasEnabledLocalVideo = true;
        events.setValue(new Event.DismissVideoTooltip());
    }
    // If remote video is enabled and we a) haven't shown our video and b) have not dismissed the popup
    if (canDisplayTooltipIfNeeded && webRtcViewModel.isRemoteVideoEnabled() && !hasEnabledLocalVideo) {
        canDisplayTooltipIfNeeded = false;
        events.setValue(new Event.ShowVideoTooltip());
    }
}
Also used : CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) SingleLiveEvent(org.thoughtcrime.securesms.util.SingleLiveEvent) MainThread(androidx.annotation.MainThread)

Example 9 with CallParticipant

use of org.thoughtcrime.securesms.events.CallParticipant in project Signal-Android by WhisperSystems.

the class CallParticipantsListDialog method updateList.

private void updateList(@NonNull CallParticipantsState callParticipantsState) {
    List<MappingModel<?>> items = new ArrayList<>();
    boolean includeSelf = callParticipantsState.getGroupCallState() == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
    OptionalLong headerCount = callParticipantsState.getParticipantCount();
    headerCount.executeIfPresent(count -> {
        items.add(new CallParticipantsListHeader((int) count));
        if (includeSelf) {
            items.add(new CallParticipantViewState(callParticipantsState.getLocalParticipant()));
        }
        for (CallParticipant callParticipant : callParticipantsState.getAllRemoteParticipants()) {
            items.add(new CallParticipantViewState(callParticipant));
        }
    });
    adapter.submitList(items);
}
Also used : CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) ArrayList(java.util.ArrayList) OptionalLong(com.annimon.stream.OptionalLong) MappingModel(org.thoughtcrime.securesms.util.adapter.mapping.MappingModel)

Example 10 with CallParticipant

use of org.thoughtcrime.securesms.events.CallParticipant in project Signal-Android by WhisperSystems.

the class GroupActionProcessor method handleUpdateRenderedResolutions.

@Override
@NonNull
protected WebRtcServiceState handleUpdateRenderedResolutions(@NonNull WebRtcServiceState currentState) {
    Map<CallParticipantId, CallParticipant> participants = currentState.getCallInfoState().getRemoteCallParticipantsMap();
    ArrayList<GroupCall.VideoRequest> resolutionRequests = new ArrayList<>(participants.size());
    for (Map.Entry<CallParticipantId, CallParticipant> entry : participants.entrySet()) {
        BroadcastVideoSink videoSink = entry.getValue().getVideoSink();
        BroadcastVideoSink.RequestedSize maxSize = videoSink.getMaxRequestingSize();
        resolutionRequests.add(new GroupCall.VideoRequest(entry.getKey().getDemuxId(), maxSize.getWidth(), maxSize.getHeight(), null));
        videoSink.setCurrentlyRequestedMaxSize(maxSize);
    }
    try {
        currentState.getCallInfoState().requireGroupCall().requestVideo(resolutionRequests);
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to set rendered resolutions", e);
    }
    return currentState;
}
Also used : CallException(org.signal.ringrtc.CallException) CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) ArrayList(java.util.ArrayList) CallParticipantId(org.thoughtcrime.securesms.events.CallParticipantId) GroupCall(org.signal.ringrtc.GroupCall) Map(java.util.Map) NonNull(androidx.annotation.NonNull)

Aggregations

CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)22 NonNull (androidx.annotation.NonNull)16 RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)10 CallException (org.signal.ringrtc.CallException)8 ArrayList (java.util.ArrayList)6 BroadcastVideoSink (org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink)6 HashSet (java.util.HashSet)4 GroupCall (org.signal.ringrtc.GroupCall)4 CallParticipantId (org.thoughtcrime.securesms.events.CallParticipantId)4 VideoState (org.thoughtcrime.securesms.service.webrtc.state.VideoState)4 WebRtcServiceStateBuilder (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder)4 MainThread (androidx.annotation.MainThread)2 OptionalLong (com.annimon.stream.OptionalLong)2 Map (java.util.Map)2 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2 Camera (org.thoughtcrime.securesms.ringrtc.Camera)2 SingleLiveEvent (org.thoughtcrime.securesms.util.SingleLiveEvent)2 MappingModel (org.thoughtcrime.securesms.util.adapter.mapping.MappingModel)2 VideoTrack (org.webrtc.VideoTrack)2