diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java index 7ddc9b52132..724cfb8cf40 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java @@ -28,7 +28,6 @@ import androidx.media3.common.FrameProcessor; import androidx.media3.common.SurfaceInfo; import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.util.GlUtil; import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.ColorInfo; @@ -180,7 +179,7 @@ public void controlledFrameRelease_withLateFrame_dropsFrame() throws Exception { } @Test - public void controlledFrameRelease_withUnsetReleaseTime_dropsFrame() throws Exception { + public void controlledFrameRelease_requestsFrameDropping_dropsFrame() throws Exception { long originalPresentationTimeUs = 1234; AtomicLong actualPresentationTimeUs = new AtomicLong(); setupGlEffectsFrameProcessorWithBlankFrameProducer( @@ -188,7 +187,7 @@ public void controlledFrameRelease_withUnsetReleaseTime_dropsFrame() throws Exce /* onFrameAvailableListener= */ presentationTimeNs -> { actualPresentationTimeUs.set(presentationTimeNs); checkNotNull(glEffectsFrameProcessor) - .releaseOutputFrame(/* releaseTimeNs= */ C.TIME_UNSET); + .releaseOutputFrame(FrameProcessor.DROP_OUTPUT_FRAME); }, /* releaseFramesAutomatically= */ false); diff --git a/google3/third_party/java_src/android_libs/media/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java b/google3/third_party/java_src/android_libs/media/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java index f2a3e72ddde..88bc1eb8873 100644 --- a/google3/third_party/java_src/android_libs/media/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java +++ b/google3/third_party/java_src/android_libs/media/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java @@ -174,6 +174,8 @@ public void releaseOutputFrame(long releaseTimeNs) { if (releaseTimeNs == FrameProcessor.RELEASE_OUTPUT_FRAME_IMMEDIATELY) { dropLateFrame = false; releaseTimeNs = System.nanoTime(); + } else if (releaseTimeNs == FrameProcessor.DROP_OUTPUT_FRAME) { + releaseTimeNs = C.TIME_UNSET; } Pair oldestAvailableFrame = availableFrames.remove(); diff --git a/library/common/src/main/java/androidx/media3/common/FrameProcessor.java b/library/common/src/main/java/androidx/media3/common/FrameProcessor.java index c54b92af091..b79901d79a3 100644 --- a/library/common/src/main/java/androidx/media3/common/FrameProcessor.java +++ b/library/common/src/main/java/androidx/media3/common/FrameProcessor.java @@ -107,6 +107,9 @@ interface Listener { */ long RELEASE_OUTPUT_FRAME_IMMEDIATELY = -1; + /** Indicates the frame should be dropped after {@link #releaseOutputFrame(long)} is invoked. */ + long DROP_OUTPUT_FRAME = -2; + /** Returns the input {@link Surface}, where {@link FrameProcessor} consumes input frames from. */ Surface getInputSurface(); @@ -170,9 +173,9 @@ interface Listener { * {@linkplain Listener#onOutputFrameAvailable(long) available}. * * @param releaseTimeNs The release time to use for the frame, in nanoseconds. Use {@link - * C#TIME_UNSET} to drop the frame, or {@link #RELEASE_OUTPUT_FRAME_IMMEDIATELY} to release - * the frame immediately. If {@code releaseTimeNs} is after {@link System#nanoTime()} at the - * time of the release, the frame is also dropped. + * #DROP_OUTPUT_FRAME} to drop the frame, or {@link #RELEASE_OUTPUT_FRAME_IMMEDIATELY} to + * release the frame immediately. If {@code releaseTimeNs} is after {@link System#nanoTime()} + * at the time of the release, the frame is also dropped. */ void releaseOutputFrame(long releaseTimeNs);