aboutsummaryrefslogtreecommitdiff
path: root/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
diff options
context:
space:
mode:
authormagjed <magjed@webrtc.org>2015-10-15 05:45:07 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-15 12:45:13 +0000
commit543b6ca30a43eeb069c699291460ce6bacc7959d (patch)
tree986f246ec4993bb1437fbfc9e9842f57d8230c07 /talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
parent27576e0b68cff41d0b28cdd38543e85805ac49bf (diff)
downloadwebrtc-543b6ca30a43eeb069c699291460ce6bacc7959d.tar.gz
Revert of "Android MediaCodecVideoDecoder: Manage lifetime of texture frames" https://codereview.webrtc.org/1378033003/
The code that depends on the reverted CL is disabled but not removed. NativeHandleImpl is reverted to the previous implementation, and the new implementation is renamed to NativeTextureHandleImpl. Texture capture can not be used anymore, because it will crash in peerconnection_jni.cc. Reason for revert: Increased HW decoder latency and crashes related to that. Also suspected cause of video tearing. Original issue's description: > This CL should be the last one in a series to finally > unblock camera texture capture. > > The SurfaceTexture.updateTexImage() calls are moved from > the video renderers into MediaCodecVideoDecoder, and the > destructor of the texture frames will signal > MediaCodecVideoDecoder that the frame has returned. This > CL also removes the SurfaceTexture from the native handle > and only exposes the texture matrix instead, because only > the video source should access the SurfaceTexture. > > BUG=webrtc:4993 > R=glaznev@webrtc.org, perkj@webrtc.org > > Committed: https://crrev.com/91b348c7029d843e06868ed12b728a809c53176c > Cr-Commit-Position: refs/heads/master@{#10203} TBR=glaznev BUG=webrtc:4993 Review URL: https://codereview.webrtc.org/1394103005 Cr-Commit-Position: refs/heads/master@{#10288}
Diffstat (limited to 'talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java')
-rw-r--r--talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
index 1d413b8ece..edb9fd69dc 100644
--- a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
+++ b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
@@ -36,6 +36,7 @@ import javax.microedition.khronos.opengles.GL10;
import android.annotation.SuppressLint;
import android.graphics.Point;
import android.graphics.Rect;
+import android.graphics.SurfaceTexture;
import android.opengl.EGL14;
import android.opengl.EGLContext;
import android.opengl.GLES20;
@@ -245,15 +246,29 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
}
if (isNewFrame) {
- rotatedSamplingMatrix = RendererCommon.rotateTextureMatrix(
- pendingFrame.samplingMatrix, pendingFrame.rotationDegree);
if (pendingFrame.yuvFrame) {
rendererType = RendererType.RENDERER_YUV;
drawer.uploadYuvData(yuvTextures, pendingFrame.width, pendingFrame.height,
pendingFrame.yuvStrides, pendingFrame.yuvPlanes);
+ // The convention in WebRTC is that the first element in a ByteBuffer corresponds to the
+ // top-left corner of the image, but in glTexImage2D() the first element corresponds to
+ // the bottom-left corner. We correct this discrepancy by setting a vertical flip as
+ // sampling matrix.
+ final float[] samplingMatrix = RendererCommon.verticalFlipMatrix();
+ rotatedSamplingMatrix =
+ RendererCommon.rotateTextureMatrix(samplingMatrix, pendingFrame.rotationDegree);
} else {
rendererType = RendererType.RENDERER_TEXTURE;
- // External texture rendering. Make a deep copy of the external texture.
+ // External texture rendering. Update texture image to latest and make a deep copy of
+ // the external texture.
+ // TODO(magjed): Move updateTexImage() to the video source instead.
+ final SurfaceTexture surfaceTexture = (SurfaceTexture) pendingFrame.textureObject;
+ surfaceTexture.updateTexImage();
+ final float[] samplingMatrix = new float[16];
+ surfaceTexture.getTransformMatrix(samplingMatrix);
+ rotatedSamplingMatrix =
+ RendererCommon.rotateTextureMatrix(samplingMatrix, pendingFrame.rotationDegree);
+
// Reallocate offscreen texture if necessary.
textureCopy.setSize(pendingFrame.rotatedWidth(), pendingFrame.rotatedHeight());