use of org.signal.ringrtc.GroupCall in project Signal-Android by WhisperSystems.
the class GroupConnectedActionProcessor method handleSetEnableVideo.
@Override
@NonNull
protected WebRtcServiceState handleSetEnableVideo(@NonNull WebRtcServiceState currentState, boolean enable) {
Log.i(TAG, "handleSetEnableVideo():");
GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
Camera camera = currentState.getVideoState().requireCamera();
try {
groupCall.setOutgoingVideoMuted(!enable);
} catch (CallException e) {
return groupCallFailure(currentState, "Unable set video muted", e);
}
camera.setEnabled(enable);
currentState = currentState.builder().changeLocalDeviceState().cameraState(camera.getCameraState()).build();
WebRtcUtil.enableSpeakerPhoneIfNeeded(webRtcInteractor, currentState);
return currentState;
}
use of org.signal.ringrtc.GroupCall in project Signal-Android by WhisperSystems.
the class GroupNetworkUnavailableActionProcessor method handlePreJoinCall.
@Override
@NonNull
protected WebRtcServiceState handlePreJoinCall(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer) {
Log.i(TAG, "handlePreJoinCall():");
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
GroupPreJoinActionProcessor processor = new GroupPreJoinActionProcessor(webRtcInteractor);
return processor.handlePreJoinCall(currentState.builder().actionProcessor(processor).build(), remotePeer);
}
byte[] groupId = currentState.getCallInfoState().getCallRecipient().requireGroupId().getDecodedId();
GroupCall groupCall = webRtcInteractor.getCallManager().createGroupCall(groupId, SignalStore.internalValues().groupCallingServer(), new byte[0], null, AudioProcessingMethodSelector.get(), webRtcInteractor.getGroupCallObserver());
return currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.NETWORK_FAILURE).groupCall(groupCall).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
}
use of org.signal.ringrtc.GroupCall in project Signal-Android by WhisperSystems.
the class IncomingGroupCallActionProcessor method handleAcceptCall.
@Override
@NonNull
protected WebRtcServiceState handleAcceptCall(@NonNull WebRtcServiceState currentState, boolean answerWithVideo) {
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);
}
currentState = currentState.builder().changeCallInfoState().groupCall(groupCall).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).commit().changeCallSetupState(RemotePeer.GROUP_CALL_ID).isRemoteVideoOffer(false).enableVideoOnCreate(answerWithVideo).build();
webRtcInteractor.setCallInProgressNotification(TYPE_INCOMING_CONNECTING, currentState.getCallInfoState().getCallRecipient());
webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context));
webRtcInteractor.initializeAudioForCall();
try {
groupCall.setOutgoingVideoSource(currentState.getVideoState().requireLocalSink(), currentState.getVideoState().requireCamera());
groupCall.setOutgoingVideoMuted(answerWithVideo);
groupCall.setOutgoingAudioMuted(!currentState.getLocalDeviceState().isMicrophoneEnabled());
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
groupCall.join();
} catch (CallException e) {
return groupCallFailure(currentState, "Unable to join group call", e);
}
return currentState.builder().actionProcessor(new GroupJoiningActionProcessor(webRtcInteractor)).changeCallInfoState().callState(WebRtcViewModel.State.CALL_OUTGOING).groupCallState(WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINING).commit().changeLocalDeviceState().build();
}
use of org.signal.ringrtc.GroupCall in project Signal-Android by WhisperSystems.
the class WebRtcActionProcessor method groupCallFailure.
@NonNull
protected WebRtcServiceState groupCallFailure(@NonNull WebRtcServiceState currentState, @NonNull String message, @NonNull Throwable error) {
Log.w(tag, "groupCallFailure(): " + message, error);
GroupCall groupCall = currentState.getCallInfoState().getGroupCall();
Recipient recipient = currentState.getCallInfoState().getCallRecipient();
if (recipient != null && currentState.getCallInfoState().getGroupCallState().isConnected()) {
webRtcInteractor.sendGroupCallMessage(recipient, WebRtcUtil.getGroupCallEraId(groupCall));
}
currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
webRtcInteractor.postStateUpdate(currentState);
try {
if (groupCall != null) {
groupCall.disconnect();
}
webRtcInteractor.getCallManager().reset();
} catch (CallException e) {
Log.w(tag, "Unable to reset call manager: ", e);
}
return terminateGroupCall(currentState);
}
use of org.signal.ringrtc.GroupCall in project Signal-Android by WhisperSystems.
the class GroupPreJoinActionProcessor 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) {
Log.i(tag, "No peek info available");
return currentState;
}
List<Recipient> callParticipants = Stream.of(peekInfo.getJoinedMembers()).map(uuid -> Recipient.externalPush(ACI.from(uuid), null, false)).toList();
WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder().changeCallInfoState().remoteDevicesCount(peekInfo.getDeviceCount()).participantLimit(peekInfo.getMaxDevices()).clearParticipantMap();
for (Recipient recipient : callParticipants) {
builder.putParticipant(recipient, CallParticipant.createRemote(new CallParticipantId(recipient), recipient, null, new BroadcastVideoSink(), true, true, 0, false, 0, false, CallParticipant.DeviceOrdinal.PRIMARY));
}
return builder.build();
}
Aggregations