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