use of org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder in project Signal-Android by WhisperSystems.
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(isVideoCall ? SignalAudioManager.AudioDevice.SPEAKER_PHONE : SignalAudioManager.AudioDevice.EARPIECE, false);
webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context));
webRtcInteractor.initializeAudioForCall();
webRtcInteractor.startOutgoingRinger();
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).commit().changeCallInfoState().activePeer(remotePeer).callState(WebRtcViewModel.State.CALL_OUTGOING).commit().changeLocalDeviceState().build();
}
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();
}
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();
}
use of org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder in project Signal-Android by WhisperSystems.
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.orNull());
builder.changeCallInfoState().callState(WebRtcViewModel.State.UNTRUSTED_IDENTITY).putParticipant(activePeer.getRecipient(), untrusted).commit();
} else {
builder.changeCallInfoState().callState(errorCallState).commit();
}
return builder.build();
}
use of org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder in project Signal-Android by WhisperSystems.
the class WebRtcActionProcessor method callFailure.
// endregion
// region Global call operations
@NonNull
public WebRtcServiceState callFailure(@NonNull WebRtcServiceState currentState, @Nullable String message, @Nullable Throwable error) {
Log.w(tag, "callFailure(): " + message, error);
WebRtcServiceStateBuilder builder = currentState.builder();
if (currentState.getCallInfoState().getActivePeer() != null) {
builder.changeCallInfoState().callState(WebRtcViewModel.State.CALL_DISCONNECTED);
}
try {
webRtcInteractor.getCallManager().reset();
} catch (CallException e) {
Log.w(tag, "Unable to reset call manager: ", e);
}
EglBaseWrapper.forceRelease();
currentState = builder.changeCallInfoState().clearPeerMap().build();
return terminate(currentState, currentState.getCallInfoState().getActivePeer());
}
Aggregations