use of org.signal.ringrtc.CallManager 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;
}
Aggregations