Search in sources :

Example 11 with Camera

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

Example 12 with Camera

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

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)

Example 13 with Camera

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

the class CallSetupActionProcessorDelegate method handleSetEnableVideo.

@Override
@NonNull
protected WebRtcServiceState handleSetEnableVideo(@NonNull WebRtcServiceState currentState, boolean enable) {
    Log.i(tag, "handleSetEnableVideo(): enable: " + enable);
    Camera camera = currentState.getVideoState().requireCamera();
    if (camera.isInitialized()) {
        camera.setEnabled(enable);
    }
    currentState = currentState.builder().changeLocalDeviceState().cameraState(camera.getCameraState()).build();
    WebRtcUtil.enableSpeakerPhoneIfNeeded(webRtcInteractor, currentState);
    return currentState;
}
Also used : Camera(org.thoughtcrime.securesms.ringrtc.Camera) NonNull(androidx.annotation.NonNull)

Example 14 with Camera

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

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)

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