From 8393c2e445e437b26b36d7a3803b461980f4ef5a Mon Sep 17 00:00:00 2001 From: kimvde Date: Wed, 13 Nov 2024 02:30:11 -0800 Subject: [PATCH] Implement/document trivial methods in DefaultVideoSink PiperOrigin-RevId: 696047835 --- .../exoplayer/video/DefaultVideoSink.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/DefaultVideoSink.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/DefaultVideoSink.java index 43e62660ee..3bf88db12f 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/DefaultVideoSink.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/DefaultVideoSink.java @@ -15,8 +15,11 @@ */ package androidx.media3.exoplayer.video; +import static androidx.media3.common.util.Assertions.checkStateNotNull; + import android.graphics.Bitmap; import android.view.Surface; +import androidx.annotation.Nullable; import androidx.media3.common.Effect; import androidx.media3.common.Format; import androidx.media3.common.util.Size; @@ -27,13 +30,24 @@ import java.util.concurrent.Executor; /** * The default {@link VideoSink} implementation. This implementation renders video frames to an - * output surface. Applying {@linkplain Effect video effects} is unsupported. + * output surface. + * + *

The following operations are not supported: + * + *

+ * + *

The {@linkplain #getInputSurface() input} and {@linkplain #setOutputSurfaceInfo(Surface, Size) + * output} surfaces are the same. */ /* package */ final class DefaultVideoSink implements VideoSink { private final VideoFrameReleaseControl videoFrameReleaseControl; private final VideoFrameRenderControl videoFrameRenderControl; + @Nullable private Surface outputSurface; private Format inputFormat; public DefaultVideoSink( @@ -99,7 +113,7 @@ import java.util.concurrent.Executor; @Override public Surface getInputSurface() { - throw new UnsupportedOperationException(); + return checkStateNotNull(outputSurface); } @Override @@ -112,11 +126,21 @@ import java.util.concurrent.Executor; videoFrameReleaseControl.setPlaybackSpeed(speed); } + /** + * {@inheritDoc} + * + *

This method will always throw an {@link UnsupportedOperationException}. + */ @Override public void setVideoEffects(List videoEffects) { throw new UnsupportedOperationException(); } + /** + * {@inheritDoc} + * + *

This method will always throw an {@link UnsupportedOperationException}. + */ @Override public void setPendingVideoEffects(List videoEffects) { throw new UnsupportedOperationException(); @@ -130,11 +154,13 @@ import java.util.concurrent.Executor; @Override public void setOutputSurfaceInfo(Surface outputSurface, Size outputResolution) { + this.outputSurface = outputSurface; videoFrameReleaseControl.setOutputSurface(outputSurface); } @Override public void clearOutputSurfaceInfo() { + outputSurface = null; videoFrameReleaseControl.setOutputSurface(/* outputSurface= */ null); } @@ -169,6 +195,11 @@ import java.util.concurrent.Executor; throw new UnsupportedOperationException(); } + /** + * {@inheritDoc} + * + *

This method will always throw an {@link UnsupportedOperationException}. + */ @Override public boolean handleInputBitmap(Bitmap inputBitmap, TimestampIterator timestampIterator) { throw new UnsupportedOperationException();