Search in sources :

Example 66 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class GroupPreJoinActionProcessor method handleOutgoingCall.

@Override
@NonNull
protected WebRtcServiceState handleOutgoingCall(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer, @NonNull OfferMessage.Type offerType) {
    Log.i(TAG, "handleOutgoingCall():");
    GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
    currentState = WebRtcVideoUtil.reinitializeCamera(context, webRtcInteractor.getCameraEventListener(), currentState);
    webRtcInteractor.setCallInProgressNotification(TYPE_OUTGOING_RINGING, currentState.getCallInfoState().getCallRecipient());
    webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context));
    webRtcInteractor.initializeAudioForCall();
    try {
        groupCall.setOutgoingVideoSource(currentState.getVideoState().requireLocalSink(), currentState.getVideoState().requireCamera());
        groupCall.setOutgoingVideoMuted(!currentState.getLocalDeviceState().getCameraState().isEnabled());
        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();
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) NonNull(androidx.annotation.NonNull)

Example 67 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class IncomingCallActionProcessor method handleAcceptCall.

@Override
@NonNull
protected WebRtcServiceState handleAcceptCall(@NonNull WebRtcServiceState currentState, boolean answerWithVideo) {
    RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
    Log.i(TAG, "handleAcceptCall(): call_id: " + activePeer.getCallId());
    SignalDatabase.sms().insertReceivedCall(activePeer.getId(), currentState.getCallSetupState(activePeer).isRemoteVideoOffer());
    currentState = currentState.builder().changeCallSetupState(activePeer.getCallId()).acceptWithVideo(answerWithVideo).build();
    try {
        webRtcInteractor.getCallManager().acceptCall(activePeer.getCallId());
    } catch (CallException e) {
        return callFailure(currentState, "accept() failed: ", e);
    }
    return currentState;
}
Also used : CallException(org.signal.ringrtc.CallException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Example 68 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class IncomingCallActionProcessor method handleDenyCall.

@NonNull
protected WebRtcServiceState handleDenyCall(@NonNull WebRtcServiceState currentState) {
    RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
    if (activePeer.getState() != CallState.LOCAL_RINGING) {
        Log.w(TAG, "Can only deny from ringing!");
        return currentState;
    }
    Log.i(TAG, "handleDenyCall():");
    try {
        webRtcInteractor.getCallManager().hangup();
        SignalDatabase.sms().insertMissedCall(activePeer.getId(), System.currentTimeMillis(), currentState.getCallSetupState(activePeer).isRemoteVideoOffer());
        return terminate(currentState, activePeer);
    } catch (CallException e) {
        return callFailure(currentState, "hangup() failed: ", e);
    }
}
Also used : CallException(org.signal.ringrtc.CallException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Example 69 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class OutgoingCallActionProcessor method handleTurnServerUpdate.

@Override
@NonNull
public WebRtcServiceState handleTurnServerUpdate(@NonNull WebRtcServiceState currentState, @NonNull List<PeerConnection.IceServer> iceServers, boolean isAlwaysTurn) {
    try {
        VideoState videoState = currentState.getVideoState();
        RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
        CallParticipant callParticipant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
        webRtcInteractor.getCallManager().proceed(activePeer.getCallId(), context, videoState.getLockableEglBase().require(), AudioProcessingMethodSelector.get(), videoState.requireLocalSink(), callParticipant.getVideoSink(), videoState.requireCamera(), iceServers, isAlwaysTurn, NetworkUtil.getCallingBandwidthMode(context), null, currentState.getCallSetupState(activePeer).isEnableVideoOnCreate());
    } catch (CallException e) {
        return callFailure(currentState, "Unable to proceed with call: ", e);
    }
    return currentState.builder().changeLocalDeviceState().cameraState(currentState.getVideoState().requireCamera().getCameraState()).build();
}
Also used : CallException(org.signal.ringrtc.CallException) CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) VideoState(org.thoughtcrime.securesms.service.webrtc.state.VideoState) NonNull(androidx.annotation.NonNull)

Example 70 with CallException

use of org.signal.ringrtc.CallException in project Signal-Android by signalapp.

the class SignalCallManager method onStartCall.

@Override
public void onStartCall(@Nullable Remote remote, @NonNull CallId callId, @NonNull Boolean isOutgoing, @Nullable CallManager.CallMediaType callMediaType) {
    Log.i(TAG, "onStartCall(): callId: " + callId + ", outgoing: " + isOutgoing + ", type: " + callMediaType);
    if (callManager == null) {
        Log.w(TAG, "Unable to start call, call manager is not initialized");
        return;
    }
    if (remote == null) {
        return;
    }
    process((s, p) -> {
        RemotePeer remotePeer = (RemotePeer) remote;
        if (s.getCallInfoState().getPeer(remotePeer.hashCode()) == null) {
            Log.w(TAG, "remotePeer not found in map with key: " + remotePeer.hashCode() + "! Dropping.");
            try {
                callManager.drop(callId);
            } catch (CallException e) {
                s = p.callFailure(s, "callManager.drop() failed: ", e);
            }
        }
        remotePeer.setCallId(callId);
        if (isOutgoing) {
            return p.handleStartOutgoingCall(s, remotePeer, WebRtcUtil.getOfferTypeFromCallMediaType(callMediaType));
        } else {
            return p.handleStartIncomingCall(s, remotePeer);
        }
    });
}
Also used : CallException(org.signal.ringrtc.CallException) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer)

Aggregations

CallException (org.signal.ringrtc.CallException)70 NonNull (androidx.annotation.NonNull)62 RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)36 GroupCall (org.signal.ringrtc.GroupCall)34 Recipient (org.thoughtcrime.securesms.recipients.Recipient)16 WebRtcServiceState (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState)12 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)10 Stream (com.annimon.stream.Stream)8 List (java.util.List)8 Log (org.signal.core.util.logging.Log)8 WebRtcViewModel (org.thoughtcrime.securesms.events.WebRtcViewModel)8 VideoState (org.thoughtcrime.securesms.service.webrtc.state.VideoState)8 ResultReceiver (android.os.ResultReceiver)6 Nullable (androidx.annotation.Nullable)6 Collection (java.util.Collection)6 Collections (java.util.Collections)6 Set (java.util.Set)6 UUID (java.util.UUID)6 CallManager (org.signal.ringrtc.CallManager)6 GroupManager (org.thoughtcrime.securesms.groups.GroupManager)6