use of org.signal.ringrtc.GroupCall in project Signal-Android by signalapp.
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);
}
use of org.signal.ringrtc.GroupCall in project Signal-Android by signalapp.
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();
}
use of org.signal.ringrtc.GroupCall in project Signal-Android by signalapp.
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();
}
use of org.signal.ringrtc.GroupCall in project Signal-Android by signalapp.
the class GroupActionProcessor method handleGroupApproveSafetyNumberChange.
@Override
@NonNull
protected WebRtcServiceState handleGroupApproveSafetyNumberChange(@NonNull WebRtcServiceState currentState, @NonNull List<RecipientId> recipientIds) {
Log.i(tag, "handleGroupApproveSafetyNumberChange():");
GroupCall groupCall = currentState.getCallInfoState().getGroupCall();
if (groupCall != null) {
currentState = currentState.builder().changeCallInfoState().removeIdentityChangedRecipients(recipientIds).build();
try {
groupCall.resendMediaKeys();
} catch (CallException e) {
return groupCallFailure(currentState, "Unable to resend media keys", e);
}
}
return currentState;
}
use of org.signal.ringrtc.GroupCall in project Signal-Android by signalapp.
the class GroupJoiningActionProcessor method handleSetEnableVideo.
@Override
@NonNull
protected WebRtcServiceState handleSetEnableVideo(@NonNull WebRtcServiceState currentState, boolean enable) {
GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
Camera camera = currentState.getVideoState().requireCamera();
try {
groupCall.setOutgoingVideoMuted(!enable);
} catch (CallException e) {
return groupCallFailure(currentState, "Unable to set video muted", e);
}
camera.setEnabled(enable);
currentState = currentState.builder().changeLocalDeviceState().cameraState(camera.getCameraState()).build();
WebRtcUtil.enableSpeakerPhoneIfNeeded(webRtcInteractor, currentState);
return currentState;
}
Aggregations