Search in sources :

Example 1 with VideoState

use of org.thoughtcrime.securesms.service.webrtc.state.VideoState in project Signal-Android by WhisperSystems.

the class IncomingCallActionProcessor method handleTurnServerUpdate.

@Override
@NonNull
public WebRtcServiceState handleTurnServerUpdate(@NonNull WebRtcServiceState currentState, @NonNull List<PeerConnection.IceServer> iceServers, boolean isAlwaysTurn) {
    RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
    boolean hideIp = !activePeer.getRecipient().isSystemContact() || isAlwaysTurn;
    VideoState videoState = currentState.getVideoState();
    CallParticipant callParticipant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
    try {
        webRtcInteractor.getCallManager().proceed(activePeer.getCallId(), context, videoState.getLockableEglBase().require(), AudioProcessingMethodSelector.get(), videoState.requireLocalSink(), callParticipant.getVideoSink(), videoState.requireCamera(), iceServers, hideIp, NetworkUtil.getCallingBandwidthMode(context), null, false);
    } catch (CallException e) {
        return callFailure(currentState, "Unable to proceed with call: ", e);
    }
    webRtcInteractor.updatePhoneState(LockManager.PhoneState.PROCESSING);
    webRtcInteractor.postStateUpdate(currentState);
    return currentState;
}
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 2 with VideoState

use of org.thoughtcrime.securesms.service.webrtc.state.VideoState in project Signal-Android by WhisperSystems.

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 3 with VideoState

use of org.thoughtcrime.securesms.service.webrtc.state.VideoState in project Signal-Android by signalapp.

the class IncomingCallActionProcessor method handleTurnServerUpdate.

@Override
@NonNull
public WebRtcServiceState handleTurnServerUpdate(@NonNull WebRtcServiceState currentState, @NonNull List<PeerConnection.IceServer> iceServers, boolean isAlwaysTurn) {
    RemotePeer activePeer = currentState.getCallInfoState().requireActivePeer();
    boolean hideIp = !activePeer.getRecipient().isSystemContact() || isAlwaysTurn;
    VideoState videoState = currentState.getVideoState();
    CallParticipant callParticipant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
    try {
        webRtcInteractor.getCallManager().proceed(activePeer.getCallId(), context, videoState.getLockableEglBase().require(), AudioProcessingMethodSelector.get(), videoState.requireLocalSink(), callParticipant.getVideoSink(), videoState.requireCamera(), iceServers, hideIp, NetworkUtil.getCallingBandwidthMode(context), null, false);
    } catch (CallException e) {
        return callFailure(currentState, "Unable to proceed with call: ", e);
    }
    webRtcInteractor.updatePhoneState(LockManager.PhoneState.PROCESSING);
    webRtcInteractor.postStateUpdate(currentState);
    return currentState;
}
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 4 with VideoState

use of org.thoughtcrime.securesms.service.webrtc.state.VideoState in project Signal-Android by signalapp.

the class GroupActionProcessor method handleGroupCallEnded.

@Override
@NonNull
protected WebRtcServiceState handleGroupCallEnded(@NonNull WebRtcServiceState currentState, int groupCallHash, @NonNull GroupCall.GroupCallEndReason groupCallEndReason) {
    Log.i(tag, "handleGroupCallEnded(): reason: " + groupCallEndReason);
    GroupCall groupCall = currentState.getCallInfoState().getGroupCall();
    if (groupCall == null || groupCall.hashCode() != groupCallHash) {
        return currentState;
    }
    try {
        groupCall.disconnect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to disconnect from group call", e);
    }
    if (groupCallEndReason != GroupCall.GroupCallEndReason.DEVICE_EXPLICITLY_DISCONNECTED) {
        Log.i(tag, "Group call ended unexpectedly, reinitializing and dropping back to lobby");
        Recipient currentRecipient = currentState.getCallInfoState().getCallRecipient();
        VideoState videoState = currentState.getVideoState();
        currentState = terminateGroupCall(currentState, false).builder().actionProcessor(new GroupNetworkUnavailableActionProcessor(webRtcInteractor)).changeVideoState().eglBase(videoState.getLockableEglBase()).camera(videoState.getCamera()).localSink(videoState.getLocalSink()).commit().changeCallInfoState().callState(WebRtcViewModel.State.CALL_PRE_JOIN).callRecipient(currentRecipient).build();
        currentState = WebRtcVideoUtil.initializeVanityCamera(WebRtcVideoUtil.reinitializeCamera(context, webRtcInteractor.getCameraEventListener(), currentState));
        return currentState.getActionProcessor().handlePreJoinCall(currentState, new RemotePeer(currentRecipient.getId()));
    }
    currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
    webRtcInteractor.postStateUpdate(currentState);
    return terminateGroupCall(currentState);
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Recipient(org.thoughtcrime.securesms.recipients.Recipient) VideoState(org.thoughtcrime.securesms.service.webrtc.state.VideoState) NonNull(androidx.annotation.NonNull)

Example 5 with VideoState

use of org.thoughtcrime.securesms.service.webrtc.state.VideoState in project Signal-Android by WhisperSystems.

the class GroupActionProcessor method handleGroupCallEnded.

@Override
@NonNull
protected WebRtcServiceState handleGroupCallEnded(@NonNull WebRtcServiceState currentState, int groupCallHash, @NonNull GroupCall.GroupCallEndReason groupCallEndReason) {
    Log.i(tag, "handleGroupCallEnded(): reason: " + groupCallEndReason);
    GroupCall groupCall = currentState.getCallInfoState().getGroupCall();
    if (groupCall == null || groupCall.hashCode() != groupCallHash) {
        return currentState;
    }
    try {
        groupCall.disconnect();
    } catch (CallException e) {
        return groupCallFailure(currentState, "Unable to disconnect from group call", e);
    }
    if (groupCallEndReason != GroupCall.GroupCallEndReason.DEVICE_EXPLICITLY_DISCONNECTED) {
        Log.i(tag, "Group call ended unexpectedly, reinitializing and dropping back to lobby");
        Recipient currentRecipient = currentState.getCallInfoState().getCallRecipient();
        VideoState videoState = currentState.getVideoState();
        currentState = terminateGroupCall(currentState, false).builder().actionProcessor(new GroupNetworkUnavailableActionProcessor(webRtcInteractor)).changeVideoState().eglBase(videoState.getLockableEglBase()).camera(videoState.getCamera()).localSink(videoState.getLocalSink()).commit().changeCallInfoState().callState(WebRtcViewModel.State.CALL_PRE_JOIN).callRecipient(currentRecipient).build();
        currentState = WebRtcVideoUtil.initializeVanityCamera(WebRtcVideoUtil.reinitializeCamera(context, webRtcInteractor.getCameraEventListener(), currentState));
        return currentState.getActionProcessor().handlePreJoinCall(currentState, new RemotePeer(currentRecipient.getId()));
    }
    currentState = currentState.builder().changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).build();
    webRtcInteractor.postStateUpdate(currentState);
    return terminateGroupCall(currentState);
}
Also used : CallException(org.signal.ringrtc.CallException) GroupCall(org.signal.ringrtc.GroupCall) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) Recipient(org.thoughtcrime.securesms.recipients.Recipient) VideoState(org.thoughtcrime.securesms.service.webrtc.state.VideoState) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)6 CallException (org.signal.ringrtc.CallException)6 RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)6 VideoState (org.thoughtcrime.securesms.service.webrtc.state.VideoState)6 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)4 GroupCall (org.signal.ringrtc.GroupCall)2 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2