From d4db00e51a91ee2f220c52bff5586b51af05d174 Mon Sep 17 00:00:00 2001 From: tofunmi Date: Fri, 3 Feb 2023 17:21:18 +0000 Subject: [PATCH] Update `FrameProcessor.create()` to accept an input track type. Based on [this conversation thread](https://chat.google.com/room/AAAA--f88ao/76Rem_cRCK8), I've opted to update the existing FrameProcessor.create() rather than deprecate it, as it is unlikely to be in use by apps outside google3. PiperOrigin-RevId: 506920930 --- .../com/google/android/exoplayer2/util/FrameProcessor.java | 3 +++ .../android/exoplayer2/video/MediaCodecVideoRenderer.java | 1 + .../effect/GlEffectsFrameProcessorFrameReleaseTest.java | 2 ++ .../android/exoplayer2/effect/GlEffectsFrameProcessor.java | 1 + .../android/exoplayer2/transformer/VideoSamplePipeline.java | 1 + .../android/exoplayer2/testutil/FrameProcessorTestRunner.java | 2 ++ 6 files changed, 10 insertions(+) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java b/library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java index 06ebd6f6ea..2c958829eb 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/FrameProcessor.java @@ -49,6 +49,8 @@ public interface FrameProcessor { * @param debugViewProvider A {@link DebugViewProvider}. * @param inputColorInfo The {@link ColorInfo} for input frames. * @param outputColorInfo The {@link ColorInfo} for output frames. + * @param inputTrackType The {@link C.TrackType} of the input. Supported track types are {@link + * C#TRACK_TYPE_VIDEO} and {@link C#TRACK_TYPE_IMAGE}. * @param releaseFramesAutomatically If {@code true}, the {@link FrameProcessor} will render * output frames to the {@linkplain #setOutputSurfaceInfo(SurfaceInfo) output surface} * automatically as {@link FrameProcessor} is done processing them. If {@code false}, the @@ -66,6 +68,7 @@ public interface FrameProcessor { DebugViewProvider debugViewProvider, ColorInfo inputColorInfo, ColorInfo outputColorInfo, + @C.TrackType int inputTrackType, boolean releaseFramesAutomatically, Executor executor, Listener listener) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java index 988992d561..d53bfcee77 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java @@ -1982,6 +1982,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { DebugViewProvider.NONE, inputColorInfo, outputColorInfo, + C.TRACK_TYPE_VIDEO, /* releaseFramesAutomatically= */ false, /* executor= */ handler::post, new FrameProcessor.Listener() { diff --git a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorFrameReleaseTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorFrameReleaseTest.java index 1f8a52efea..d43cbfb2ab 100644 --- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorFrameReleaseTest.java +++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessorFrameReleaseTest.java @@ -25,6 +25,7 @@ import android.media.Image; import android.media.ImageReader; import androidx.annotation.Nullable; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.util.DebugViewProvider; import com.google.android.exoplayer2.util.FrameInfo; import com.google.android.exoplayer2.util.FrameProcessingException; @@ -295,6 +296,7 @@ public final class GlEffectsFrameProcessorFrameReleaseTest { DebugViewProvider.NONE, /* inputColorInfo= */ ColorInfo.SDR_BT709_LIMITED, /* outputColorInfo= */ ColorInfo.SDR_BT709_LIMITED, + C.TRACK_TYPE_VIDEO, releaseFramesAutomatically, MoreExecutors.directExecutor(), new FrameProcessor.Listener() { diff --git a/library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java index 36de3cb0fe..a1ae4a41eb 100644 --- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java +++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java @@ -94,6 +94,7 @@ public final class GlEffectsFrameProcessor implements FrameProcessor { DebugViewProvider debugViewProvider, ColorInfo inputColorInfo, ColorInfo outputColorInfo, + @C.TrackType int inputTrackType, boolean releaseFramesAutomatically, Executor listenerExecutor, Listener listener) diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java index 3a72f10884..e5736fd9c7 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/VideoSamplePipeline.java @@ -154,6 +154,7 @@ import org.checkerframework.dataflow.qual.Pure; debugViewProvider, frameProcessorInputColor, frameProcessorOutputColor, + MimeTypes.getTrackType(firstInputFormat.sampleMimeType), /* releaseFramesAutomatically= */ true, MoreExecutors.directExecutor(), new FrameProcessor.Listener() { diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FrameProcessorTestRunner.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FrameProcessorTestRunner.java index 71b9e59057..ca90b1531b 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FrameProcessorTestRunner.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FrameProcessorTestRunner.java @@ -28,6 +28,7 @@ import android.media.Image; import android.media.ImageReader; import android.media.MediaFormat; import androidx.annotation.RequiresApi; +import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.util.DebugViewProvider; import com.google.android.exoplayer2.util.Effect; import com.google.android.exoplayer2.util.FrameInfo; @@ -223,6 +224,7 @@ public final class FrameProcessorTestRunner { DebugViewProvider.NONE, inputColorInfo, outputColorInfo, + C.TRACK_TYPE_VIDEO, /* releaseFramesAutomatically= */ true, MoreExecutors.directExecutor(), new FrameProcessor.Listener() {