Search in sources :

Example 1 with VideoFrame

use of org.webrtc.VideoFrame in project Signal-Android by WhisperSystems.

the class BroadcastVideoSink method onFrame.

@Override
public synchronized void onFrame(@NonNull VideoFrame videoFrame) {
    boolean isDeviceRotationIgnored = deviceOrientationDegrees == DEVICE_ROTATION_IGNORE;
    boolean isWideVideoFrame = videoFrame.getRotatedHeight() < videoFrame.getRotatedWidth();
    if (!isDeviceRotationIgnored && (isWideVideoFrame || forceRotate)) {
        int rotation = calculateRotation();
        if (rotation > 0) {
            rotation += rotateWithDevice ? videoFrame.getRotation() : 0;
            videoFrame = new VideoFrame(videoFrame.getBuffer(), rotation % 360, videoFrame.getTimestampNs());
        }
    }
    for (VideoSink sink : sinks.keySet()) {
        sink.onFrame(videoFrame);
    }
}
Also used : VideoFrame(org.webrtc.VideoFrame) VideoSink(org.webrtc.VideoSink) Point(android.graphics.Point)

Example 2 with VideoFrame

use of org.webrtc.VideoFrame in project Signal-Android by signalapp.

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 3 with VideoFrame

use of org.webrtc.VideoFrame 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 4 with VideoFrame

use of org.webrtc.VideoFrame in project Signal-Android by signalapp.

the class BroadcastVideoSink method onFrame.

@Override
public synchronized void onFrame(@NonNull VideoFrame videoFrame) {
    boolean isDeviceRotationIgnored = deviceOrientationDegrees == DEVICE_ROTATION_IGNORE;
    boolean isWideVideoFrame = videoFrame.getRotatedHeight() < videoFrame.getRotatedWidth();
    if (!isDeviceRotationIgnored && (isWideVideoFrame || forceRotate)) {
        int rotation = calculateRotation();
        if (rotation > 0) {
            rotation += rotateWithDevice ? videoFrame.getRotation() : 0;
            videoFrame = new VideoFrame(videoFrame.getBuffer(), rotation % 360, videoFrame.getTimestampNs());
        }
    }
    for (VideoSink sink : sinks.keySet()) {
        sink.onFrame(videoFrame);
    }
}
Also used : VideoFrame(org.webrtc.VideoFrame) VideoSink(org.webrtc.VideoSink) Point(android.graphics.Point)

Aggregations

VideoFrame (org.webrtc.VideoFrame)4 VideoSink (org.webrtc.VideoSink)4 Point (android.graphics.Point)2 NonNull (androidx.annotation.NonNull)2 BroadcastVideoSink (org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink)2 Camera (org.thoughtcrime.securesms.ringrtc.Camera)2 CapturerObserver (org.webrtc.CapturerObserver)2