Commit a82690a5 by kimvde Committed by bachinger

Use SurfaceTexture.getTimestamp

PiperOrigin-RevId: 399139842
parent 1e6a3aa6
...@@ -71,7 +71,6 @@ import java.nio.ByteBuffer; ...@@ -71,7 +71,6 @@ import java.nio.ByteBuffer;
@Nullable private GlUtil.Uniform decoderTextureTransformUniform; @Nullable private GlUtil.Uniform decoderTextureTransformUniform;
@Nullable private MediaCodecAdapterWrapper encoder; @Nullable private MediaCodecAdapterWrapper encoder;
private long nextEncoderTimeUs;
/** Whether encoder's actual output format is obtained. */ /** Whether encoder's actual output format is obtained. */
private boolean hasEncoderActualOutputFormat; private boolean hasEncoderActualOutputFormat;
...@@ -304,7 +303,6 @@ import java.nio.ByteBuffer; ...@@ -304,7 +303,6 @@ import java.nio.ByteBuffer;
if (!isDecoderSurfacePopulated) { if (!isDecoderSurfacePopulated) {
if (!waitingForPopulatedDecoderSurface) { if (!waitingForPopulatedDecoderSurface) {
if (decoder.getOutputBuffer() != null) { if (decoder.getOutputBuffer() != null) {
nextEncoderTimeUs = checkNotNull(decoder.getOutputBufferInfo()).presentationTimeUs;
decoder.releaseOutputBuffer(/* render= */ true); decoder.releaseOutputBuffer(/* render= */ true);
waitingForPopulatedDecoderSurface = true; waitingForPopulatedDecoderSurface = true;
} }
...@@ -326,7 +324,8 @@ import java.nio.ByteBuffer; ...@@ -326,7 +324,8 @@ import java.nio.ByteBuffer;
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
EGLDisplay eglDisplay = checkNotNull(this.eglDisplay); EGLDisplay eglDisplay = checkNotNull(this.eglDisplay);
EGLSurface eglSurface = checkNotNull(this.eglSurface); EGLSurface eglSurface = checkNotNull(this.eglSurface);
EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, nextEncoderTimeUs * 1000L); long decoderSurfaceTextureTimestampNs = decoderSurfaceTexture.getTimestamp();
EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, decoderSurfaceTextureTimestampNs);
EGL14.eglSwapBuffers(eglDisplay, eglSurface); EGL14.eglSwapBuffers(eglDisplay, eglSurface);
isDecoderSurfacePopulated = false; isDecoderSurfacePopulated = false;
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment