Search in sources :

Example 11 with WebRtcServiceStateBuilder

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

the class WebRtcVideoUtil method initializeVideo.

@NonNull
public static WebRtcServiceState initializeVideo(@NonNull Context context, @NonNull CameraEventListener cameraEventListener, @NonNull WebRtcServiceState currentState, @NonNull Object eglBaseHolder) {
    final WebRtcServiceStateBuilder builder = currentState.builder();
    ThreadUtil.runOnMainSync(() -> {
        EglBaseWrapper eglBase = EglBaseWrapper.acquireEglBase(eglBaseHolder);
        BroadcastVideoSink localSink = new BroadcastVideoSink(eglBase, true, false, currentState.getLocalDeviceState().getOrientation().getDegrees());
        Camera camera = new Camera(context, cameraEventListener, eglBase, CameraState.Direction.FRONT);
        camera.setOrientation(currentState.getLocalDeviceState().getOrientation().getDegrees());
        builder.changeVideoState().eglBase(eglBase).localSink(localSink).camera(camera).commit().changeLocalDeviceState().cameraState(camera.getCameraState()).commit();
    });
    return builder.build();
}
Also used : BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) EglBaseWrapper(org.thoughtcrime.securesms.components.webrtc.EglBaseWrapper) Camera(org.thoughtcrime.securesms.ringrtc.Camera) NonNull(androidx.annotation.NonNull)

Example 12 with WebRtcServiceStateBuilder

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

the class WebRtcVideoUtil method reinitializeCamera.

@NonNull
public static WebRtcServiceState reinitializeCamera(@NonNull Context context, @NonNull CameraEventListener cameraEventListener, @NonNull WebRtcServiceState currentState) {
    final WebRtcServiceStateBuilder builder = currentState.builder();
    ThreadUtil.runOnMainSync(() -> {
        Camera camera = currentState.getVideoState().requireCamera();
        camera.setEnabled(false);
        camera.dispose();
        camera = new Camera(context, cameraEventListener, currentState.getVideoState().getLockableEglBase(), currentState.getLocalDeviceState().getCameraState().getActiveDirection());
        camera.setOrientation(currentState.getLocalDeviceState().getOrientation().getDegrees());
        builder.changeVideoState().camera(camera).commit().changeLocalDeviceState().cameraState(camera.getCameraState()).commit();
    });
    return builder.build();
}
Also used : WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) Camera(org.thoughtcrime.securesms.ringrtc.Camera) NonNull(androidx.annotation.NonNull)

Example 13 with WebRtcServiceStateBuilder

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

the class WebRtcActionProcessor method handleMessageSentError.

@NonNull
protected WebRtcServiceState handleMessageSentError(@NonNull WebRtcServiceState currentState, @NonNull CallId callId, @NonNull WebRtcViewModel.State errorCallState, @NonNull Optional<IdentityKey> identityKey) {
    Log.w(tag, "handleMessageSentError():");
    try {
        webRtcInteractor.getCallManager().messageSendFailure(callId);
    } catch (CallException e) {
        currentState = callFailure(currentState, "callManager.messageSendFailure() failed: ", e);
    }
    RemotePeer activePeer = currentState.getCallInfoState().getActivePeer();
    if (activePeer == null) {
        return currentState;
    }
    WebRtcServiceStateBuilder builder = currentState.builder();
    if (errorCallState == WebRtcViewModel.State.UNTRUSTED_IDENTITY) {
        CallParticipant participant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
        CallParticipant untrusted = participant.withIdentityKey(identityKey.orElse(null));
        builder.changeCallInfoState().callState(WebRtcViewModel.State.UNTRUSTED_IDENTITY).putParticipant(activePeer.getRecipient(), untrusted).commit();
    }
    return builder.build();
}
Also used : CallException(org.signal.ringrtc.CallException) CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) RemotePeer(org.thoughtcrime.securesms.ringrtc.RemotePeer) NonNull(androidx.annotation.NonNull)

Example 14 with WebRtcServiceStateBuilder

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

the class OutgoingCallActionProcessor method handleStartOutgoingCall.

@Override
@NonNull
protected WebRtcServiceState handleStartOutgoingCall(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer, @NonNull OfferMessage.Type offerType) {
    Log.i(TAG, "handleStartOutgoingCall():");
    WebRtcServiceStateBuilder builder = currentState.builder();
    remotePeer.dialing();
    Log.i(TAG, "assign activePeer callId: " + remotePeer.getCallId() + " key: " + remotePeer.hashCode() + " type: " + offerType);
    boolean isVideoCall = offerType == OfferMessage.Type.VIDEO_CALL;
    webRtcInteractor.setCallInProgressNotification(TYPE_OUTGOING_RINGING, remotePeer);
    webRtcInteractor.setDefaultAudioDevice(remotePeer.getId(), isVideoCall ? SignalAudioManager.AudioDevice.SPEAKER_PHONE : SignalAudioManager.AudioDevice.EARPIECE, false);
    webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context));
    webRtcInteractor.initializeAudioForCall();
    webRtcInteractor.startOutgoingRinger();
    if (!webRtcInteractor.addNewOutgoingCall(remotePeer.getId(), remotePeer.getCallId().longValue(), isVideoCall)) {
        Log.i(TAG, "Unable to add new outgoing call");
        return handleDropCall(currentState, remotePeer.getCallId().longValue());
    }
    RecipientUtil.setAndSendUniversalExpireTimerIfNecessary(context, Recipient.resolved(remotePeer.getId()), SignalDatabase.threads().getThreadIdIfExistsFor(remotePeer.getId()));
    SignalDatabase.sms().insertOutgoingCall(remotePeer.getId(), isVideoCall);
    EglBaseWrapper.replaceHolder(EglBaseWrapper.OUTGOING_PLACEHOLDER, remotePeer.getCallId().longValue());
    webRtcInteractor.retrieveTurnServers(remotePeer);
    return builder.changeCallSetupState(remotePeer.getCallId()).enableVideoOnCreate(isVideoCall).waitForTelecom(AndroidTelecomUtil.getTelecomSupported()).telecomApproved(false).commit().changeCallInfoState().activePeer(remotePeer).callState(WebRtcViewModel.State.CALL_OUTGOING).commit().changeLocalDeviceState().build();
}
Also used : WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) NonNull(androidx.annotation.NonNull)

Example 15 with WebRtcServiceStateBuilder

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

the class WebRtcVideoUtil method reinitializeCamera.

@NonNull
public static WebRtcServiceState reinitializeCamera(@NonNull Context context, @NonNull CameraEventListener cameraEventListener, @NonNull WebRtcServiceState currentState) {
    final WebRtcServiceStateBuilder builder = currentState.builder();
    ThreadUtil.runOnMainSync(() -> {
        Camera camera = currentState.getVideoState().requireCamera();
        camera.setEnabled(false);
        camera.dispose();
        camera = new Camera(context, cameraEventListener, currentState.getVideoState().getLockableEglBase(), currentState.getLocalDeviceState().getCameraState().getActiveDirection());
        camera.setOrientation(currentState.getLocalDeviceState().getOrientation().getDegrees());
        builder.changeVideoState().camera(camera).commit().changeLocalDeviceState().cameraState(camera.getCameraState()).commit();
    });
    return builder.build();
}
Also used : WebRtcServiceStateBuilder(org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder) Camera(org.thoughtcrime.securesms.ringrtc.Camera) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)18 WebRtcServiceStateBuilder (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder)18 CallException (org.signal.ringrtc.CallException)9 Camera (org.thoughtcrime.securesms.ringrtc.Camera)6 GroupCall (org.signal.ringrtc.GroupCall)3 BroadcastVideoSink (org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink)3 EglBaseWrapper (org.thoughtcrime.securesms.components.webrtc.EglBaseWrapper)3 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)3 RemotePeer (org.thoughtcrime.securesms.ringrtc.RemotePeer)3