mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Track presentation timestamps in FrameEditor.
PiperOrigin-RevId: 428763554
This commit is contained in:
parent
238d9ca57b
commit
33afc4760b
@ -18,6 +18,7 @@ package androidx.media3.transformer;
|
|||||||
|
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
import static androidx.media3.common.util.Assertions.checkState;
|
import static androidx.media3.common.util.Assertions.checkState;
|
||||||
|
import static androidx.media3.common.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;
|
|||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.decoder.DecoderInputBuffer;
|
import androidx.media3.decoder.DecoderInputBuffer;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -314,7 +316,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;
|
|||||||
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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user