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();
}
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;
}
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());
}
}
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);
}
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;
}
Aggregations