use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.
the class CallSetupActionProcessorDelegate method handleCallConnected.
@Override
@NonNull
public WebRtcServiceState handleCallConnected(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer) {
if (!remotePeer.callIdEquals(currentState.getCallInfoState().getActivePeer())) {
Log.w(tag, "handleCallConnected(): Ignoring for inactive call.");
return currentState;
}
Log.i(tag, "handleCallConnected(): call_id: " + remotePeer.getCallId());
RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
ApplicationDependencies.getAppForegroundObserver().removeListener(webRtcInteractor.getForegroundListener());
webRtcInteractor.startAudioCommunication();
activePeer.connected();
if (currentState.getLocalDeviceState().getCameraState().isEnabled()) {
webRtcInteractor.updatePhoneState(LockManager.PhoneState.IN_VIDEO);
} else {
webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context));
}
currentState = currentState.builder().actionProcessor(new ConnectedCallActionProcessor(webRtcInteractor)).changeCallInfoState().callState(WebRtcViewModel.State.CALL_CONNECTED).callConnectedTime(System.currentTimeMillis()).commit().changeLocalDeviceState().build();
webRtcInteractor.setCallInProgressNotification(TYPE_ESTABLISHED, activePeer);
webRtcInteractor.unregisterPowerButtonReceiver();
try {
CallManager callManager = webRtcInteractor.getCallManager();
callManager.setCommunicationMode();
callManager.setAudioEnable(currentState.getLocalDeviceState().isMicrophoneEnabled());
callManager.setVideoEnable(currentState.getLocalDeviceState().getCameraState().isEnabled());
} catch (CallException e) {
return callFailure(currentState, "Enabling audio/video failed: ", e);
}
if (currentState.getCallSetupState(activePeer).isAcceptWithVideo()) {
currentState = currentState.getActionProcessor().handleSetEnableVideo(currentState, true);
}
if (currentState.getCallSetupState(activePeer).isAcceptWithVideo() || currentState.getLocalDeviceState().getCameraState().isEnabled()) {
webRtcInteractor.setDefaultAudioDevice(SignalAudioManager.AudioDevice.SPEAKER_PHONE, false);
} else {
webRtcInteractor.setDefaultAudioDevice(SignalAudioManager.AudioDevice.EARPIECE, false);
}
return currentState;
}
use of org.signal.ringrtc.CallException 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.CallException in project Signal-Android by signalapp.
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;
}
use of org.signal.ringrtc.CallException 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;
}
use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.
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();
}
Aggregations