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

Unified Diff: webrtc/sdk/android/api/org/webrtc/SurfaceTextureHelper.java

Issue 2990583002: Move matrix from VideoFrame to TextureBuffer. (Closed)
Patch Set: Fixes. 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/api/org/webrtc/SurfaceTextureHelper.java
diff --git a/webrtc/sdk/android/api/org/webrtc/SurfaceTextureHelper.java b/webrtc/sdk/android/api/org/webrtc/SurfaceTextureHelper.java
index bd3d545a180fe34290dcdd0f61c94bf7a39c7352..a3db84de8aa1c43c6d26fa7c85de7b445f39d5b1 100644
--- a/webrtc/sdk/android/api/org/webrtc/SurfaceTextureHelper.java
+++ b/webrtc/sdk/android/api/org/webrtc/SurfaceTextureHelper.java
@@ -10,6 +10,7 @@
package org.webrtc;
+import android.graphics.Matrix;
import android.graphics.SurfaceTexture;
import android.opengl.GLES11Ext;
import android.opengl.GLES20;
@@ -288,86 +289,13 @@ public class SurfaceTextureHelper {
* The returned TextureBuffer holds a reference to the SurfaceTextureHelper that created it. The
* buffer calls returnTextureFrame() when it is released.
*/
- public TextureBuffer createTextureBuffer(int width, int height, float[] transformMatrix) {
- return new OesTextureBuffer(oesTextureId, width, height, transformMatrix, this);
- }
-
- /**
- * Android OES texture buffer backed by a SurfaceTextureHelper's texture. The buffer calls
- * returnTextureFrame() when it is released.
- */
- private static class OesTextureBuffer implements TextureBuffer {
- private final int id;
- private final int width;
- private final int height;
- private final float[] transformMatrix;
- private final SurfaceTextureHelper helper;
- private int refCount;
-
- OesTextureBuffer(
- int id, int width, int height, float[] transformMatrix, SurfaceTextureHelper helper) {
- this.id = id;
- this.width = width;
- this.height = height;
- this.transformMatrix = transformMatrix;
- this.helper = helper;
- this.refCount = 1; // Creator implicitly holds a reference.
- }
-
- @Override
- public TextureBuffer.Type getType() {
- return TextureBuffer.Type.OES;
- }
-
- @Override
- public int getTextureId() {
- return id;
- }
-
- @Override
- public int getWidth() {
- return width;
- }
-
- @Override
- public int getHeight() {
- return height;
- }
-
- @Override
- public I420Buffer toI420() {
- // SurfaceTextureHelper requires a stride that is divisible by 8. Round width up.
- // See SurfaceTextureHelper for details on the size and format.
- int stride = ((width + 7) / 8) * 8;
- int uvHeight = (height + 1) / 2;
- // Due to the layout used by SurfaceTextureHelper, vPos + stride * uvHeight would overrun the
- // buffer. Add one row at the bottom to compensate for this. There will never be data in the
- // extra row, but now other code does not have to deal with v stride * v height exceeding the
- // buffer's capacity.
- int size = stride * (height + uvHeight + 1);
- ByteBuffer buffer = ByteBuffer.allocateDirect(size);
- helper.textureToYUV(buffer, width, height, stride, id, transformMatrix);
-
- int yPos = 0;
- int uPos = yPos + stride * height;
- // Rows of U and V alternate in the buffer, so V data starts after the first row of U.
- int vPos = yPos + stride / 2;
-
- // SurfaceTextureHelper uses the same stride for Y, U, and V data.
- return new I420BufferImpl(
- buffer, width, height, yPos, stride, uPos, stride, vPos, stride, null);
- }
-
- @Override
- public void retain() {
- ++refCount;
- }
-
- @Override
- public void release() {
- if (--refCount == 0) {
- helper.returnTextureFrame();
- }
- }
+ public TextureBuffer createTextureBuffer(int width, int height, Matrix transformMatrix) {
+ return new TextureBufferImpl(
+ width, height, TextureBuffer.Type.OES, oesTextureId, transformMatrix, this, new Runnable() {
+ @Override
+ public void run() {
+ returnTextureFrame();
+ }
+ });
}
}

Powered by Google App Engine
This is Rietveld 408576698