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