Search in sources :

Example 6 with Camera

use of org.thoughtcrime.securesms.ringrtc.Camera 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 7 with Camera

use of org.thoughtcrime.securesms.ringrtc.Camera 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 8 with Camera

use of org.thoughtcrime.securesms.ringrtc.Camera in project Signal-Android by WhisperSystems.

the class WebRtcVideoUtil method initializeVanityCamera.

@NonNull
public static WebRtcServiceState initializeVanityCamera(@NonNull WebRtcServiceState currentState) {
    Camera camera = currentState.getVideoState().requireCamera();
    VideoSink sink = currentState.getVideoState().requireLocalSink();
    if (camera.hasCapturer()) {
        camera.initCapturer(new CapturerObserver() {

            @Override
            public void onFrameCaptured(VideoFrame videoFrame) {
                sink.onFrame(videoFrame);
            }

            @Override
            public void onCapturerStarted(boolean success) {
            }

            @Override
            public void onCapturerStopped() {
            }
        });
        camera.setEnabled(true);
    }
    return currentState.builder().changeLocalDeviceState().cameraState(camera.getCameraState()).build();
}
Also used : VideoFrame(org.webrtc.VideoFrame) CapturerObserver(org.webrtc.CapturerObserver) BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) VideoSink(org.webrtc.VideoSink) Camera(org.thoughtcrime.securesms.ringrtc.Camera) NonNull(androidx.annotation.NonNull)

Example 9 with Camera

use of org.thoughtcrime.securesms.ringrtc.Camera in project Signal-Android by WhisperSystems.

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 10 with Camera

use of org.thoughtcrime.securesms.ringrtc.Camera in project Signal-Android by WhisperSystems.

the class WebRtcActionProcessor method handleOrientationChanged.

@NonNull
protected WebRtcServiceState handleOrientationChanged(@NonNull WebRtcServiceState currentState, boolean isLandscapeEnabled, int orientationDegrees) {
    Camera camera = currentState.getVideoState().getCamera();
    if (camera != null) {
        camera.setOrientation(orientationDegrees);
    }
    int sinkRotationDegrees = isLandscapeEnabled ? BroadcastVideoSink.DEVICE_ROTATION_IGNORE : orientationDegrees;
    int stateRotationDegrees = isLandscapeEnabled ? 0 : orientationDegrees;
    BroadcastVideoSink sink = currentState.getVideoState().getLocalSink();
    if (sink != null) {
        sink.setDeviceOrientationDegrees(sinkRotationDegrees);
    }
    for (CallParticipant callParticipant : currentState.getCallInfoState().getRemoteCallParticipants()) {
        callParticipant.getVideoSink().setDeviceOrientationDegrees(sinkRotationDegrees);
    }
    return currentState.builder().changeLocalDeviceState().setOrientation(Orientation.fromDegrees(stateRotationDegrees)).setLandscapeEnabled(isLandscapeEnabled).setDeviceOrientation(Orientation.fromDegrees(orientationDegrees)).build();
}
Also used : CallParticipant(org.thoughtcrime.securesms.events.CallParticipant) BroadcastVideoSink(org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink) Camera(org.thoughtcrime.securesms.ringrtc.Camera) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)14 Camera (org.thoughtcrime.securesms.ringrtc.Camera)14 BroadcastVideoSink (org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink)6 CallException (org.signal.ringrtc.CallException)4 GroupCall (org.signal.ringrtc.GroupCall)4 WebRtcServiceStateBuilder (org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder)4 EglBaseWrapper (org.thoughtcrime.securesms.components.webrtc.EglBaseWrapper)2 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)2 CapturerObserver (org.webrtc.CapturerObserver)2 VideoFrame (org.webrtc.VideoFrame)2 VideoSink (org.webrtc.VideoSink)2