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 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();
}
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();
}
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();
}
Aggregations