Search in sources :

Example 61 with CallException

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

Example 62 with CallException

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

Example 63 with CallException

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;
}
Also used : CallException(org.signal.ringrtc.CallException) CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) ArrayList(java.util.ArrayList) CallParticipantId(org.thoughtcrime.securesms.events.CallParticipantId) GroupCall(org.signal.ringrtc.GroupCall) Map(java.util.Map) NonNull(androidx.annotation.NonNull)

Example 64 with CallException

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

Example 65 with CallException

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

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