Search in sources :

Example 6 with CallManager

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;
}
Also used : CallManager(org.signal.ringrtc.CallManager) CallException(org.signal.ringrtc.CallException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)6 CallException (org.signal.ringrtc.CallException)6 CallManager (org.signal.ringrtc.CallManager)6 Application (android.app.Application)4 Context (android.content.Context)4 Intent (android.content.Intent)4 Build (android.os.Build)4 ResultReceiver (android.os.ResultReceiver)4 Nullable (androidx.annotation.Nullable)4 Stream (com.annimon.stream.Stream)4 IOException (java.io.IOException)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 Set (java.util.Set)4 UUID (java.util.UUID)4 Executor (java.util.concurrent.Executor)4 ExecutorService (java.util.concurrent.ExecutorService)4 Executors (java.util.concurrent.Executors)4