Commit 2bd5351e by hschlueter Committed by Ian Baker

Track presentation timestamps in FrameEditor.

PiperOrigin-RevId: 428763554
parent 37391a85
...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.transformer; ...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.transformer;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Assertions.checkState; import static com.google.android.exoplayer2.util.Assertions.checkState;
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo; import android.media.MediaCodec.BufferInfo;
...@@ -27,6 +28,7 @@ import androidx.annotation.Nullable; ...@@ -27,6 +28,7 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer; import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
...@@ -312,7 +314,13 @@ public final class Codec { ...@@ -312,7 +314,13 @@ public final class Codec {
public void releaseOutputBuffer(boolean render) throws TransformationException { public void releaseOutputBuffer(boolean render) throws TransformationException {
outputBuffer = null; outputBuffer = null;
try { try {
mediaCodec.releaseOutputBuffer(outputBufferIndex, render); if (render) {
mediaCodec.releaseOutputBuffer(
outputBufferIndex,
/* renderTimestampNs= */ checkStateNotNull(outputBufferInfo).presentationTimeUs * 1000);
} else {
mediaCodec.releaseOutputBuffer(outputBufferIndex, /* render= */ false);
}
} catch (RuntimeException e) { } catch (RuntimeException e) {
throw createTransformationException(e); throw createTransformationException(e);
} }
......
...@@ -325,8 +325,8 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -325,8 +325,8 @@ import java.util.concurrent.atomic.AtomicInteger;
glProgram.bindAttributesAndUniforms(); glProgram.bindAttributesAndUniforms();
focusAndDrawQuad(eglSurface, outputWidth, outputHeight); focusAndDrawQuad(eglSurface, outputWidth, outputHeight);
long surfaceTextureTimestampNs = inputSurfaceTexture.getTimestamp(); long presentationTimeNs = inputSurfaceTexture.getTimestamp();
EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, surfaceTextureTimestampNs); EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, presentationTimeNs);
EGL14.eglSwapBuffers(eglDisplay, eglSurface); EGL14.eglSwapBuffers(eglDisplay, eglSurface);
if (debugPreviewEglSurface != null) { if (debugPreviewEglSurface != null) {
......
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