Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: webrtc/sdk/android/src/java/org/webrtc/Camera1Session.java

Issue 2984633002: Add a field trial to produce VideoFrames in camera capturers. (Closed)
Patch Set: Update log message. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/sdk/android/src/java/org/webrtc/Camera1Session.java
diff --git a/webrtc/sdk/android/src/java/org/webrtc/Camera1Session.java b/webrtc/sdk/android/src/java/org/webrtc/Camera1Session.java
index d1950690c34f7f1b10a413e6ab1ca17a42621088..b672dd1e0b8c58e9880328daf9171fa4113f84f5 100644
--- a/webrtc/sdk/android/src/java/org/webrtc/Camera1Session.java
+++ b/webrtc/sdk/android/src/java/org/webrtc/Camera1Session.java
@@ -267,8 +267,12 @@ class Camera1Session implements CameraSession {
transformMatrix = RendererCommon.multiplyMatrices(
transformMatrix, RendererCommon.horizontalFlipMatrix());
}
- events.onTextureFrameCaptured(Camera1Session.this, captureFormat.width,
- captureFormat.height, oesTextureId, transformMatrix, rotation, timestampNs);
+ final VideoFrame.Buffer buffer = surfaceTextureHelper.createTextureBuffer(
+ captureFormat.width, captureFormat.height, transformMatrix);
+ final VideoFrame frame = new VideoFrame(buffer, rotation, timestampNs,
+ RendererCommon.convertMatrixToAndroidGraphicsMatrix(transformMatrix));
+ events.onFrameCaptured(Camera1Session.this, frame);
+ frame.release();
}
});
}
@@ -276,7 +280,7 @@ class Camera1Session implements CameraSession {
private void listenForBytebufferFrames() {
camera.setPreviewCallbackWithBuffer(new android.hardware.Camera.PreviewCallback() {
@Override
- public void onPreviewFrame(byte[] data, android.hardware.Camera callbackCamera) {
+ public void onPreviewFrame(final byte[] data, android.hardware.Camera callbackCamera) {
checkIsOnCameraThread();
if (callbackCamera != camera) {
@@ -298,9 +302,14 @@ class Camera1Session implements CameraSession {
firstFrameReported = true;
}
- events.onByteBufferFrameCaptured(Camera1Session.this, data, captureFormat.width,
- captureFormat.height, getFrameOrientation(), captureTimeNs);
+ final I420BufferImpl frameBuffer =
+ I420BufferImpl.allocate(captureFormat.width, captureFormat.height);
+ nativeNV21ToI420(captureFormat.width, captureFormat.height, data, frameBuffer.getBuffer());
camera.addCallbackBuffer(data);
+ final VideoFrame frame = new VideoFrame(frameBuffer, getFrameOrientation(), captureTimeNs,
+ RendererCommon.convertMatrixToAndroidGraphicsMatrix(RendererCommon.identityMatrix()));
+ events.onFrameCaptured(Camera1Session.this, frame);
+ frame.release();
}
});
}
@@ -340,4 +349,6 @@ class Camera1Session implements CameraSession {
throw new IllegalStateException("Wrong thread");
}
}
+
+ private static native void nativeNV21ToI420(int width, int height, byte[] src, ByteBuffer dst);
}

Powered by Google App Engine
This is Rietveld 408576698