From e234076fdc7c2937c3fa64f0d32e3145ad427071 Mon Sep 17 00:00:00 2001 From: kimvde Date: Wed, 9 Oct 2024 01:44:36 -0700 Subject: [PATCH] DefaultVideoSink: implement set/clearOutputSurfaceInfo This is part of the effort to handle rendering of the frames output by the VideoGraph in a DefaultVideoSink PiperOrigin-RevId: 683939818 --- .../media3/exoplayer/video/DefaultVideoSink.java | 4 ++-- .../video/PlaybackVideoGraphWrapper.java | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 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 52e835602c..7c87aad50d 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 @@ -128,12 +128,12 @@ import java.util.concurrent.Executor; @Override public void setOutputSurfaceInfo(Surface outputSurface, Size outputResolution) { - throw new UnsupportedOperationException(); + videoFrameReleaseControl.setOutputSurface(outputSurface); } @Override public void clearOutputSurfaceInfo() { - throw new UnsupportedOperationException(); + videoFrameReleaseControl.setOutputSurface(/* outputSurface= */ null); } @Override diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/PlaybackVideoGraphWrapper.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/PlaybackVideoGraphWrapper.java index b7e4120c62..ed681b7df2 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/PlaybackVideoGraphWrapper.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/PlaybackVideoGraphWrapper.java @@ -406,11 +406,16 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video } private void maybeSetOutputSurfaceInfo(@Nullable Surface surface, int width, int height) { - if (videoGraph != null) { - // Update the surface on the video graph and the video frame release control together. - SurfaceInfo surfaceInfo = surface != null ? new SurfaceInfo(surface, width, height) : null; - videoGraph.setOutputSurfaceInfo(surfaceInfo); - videoFrameReleaseControl.setOutputSurface(surface); + if (videoGraph == null) { + return; + } + // Update the surface on the video graph and the default video sink together. + if (surface != null) { + videoGraph.setOutputSurfaceInfo(new SurfaceInfo(surface, width, height)); + defaultVideoSink.setOutputSurfaceInfo(surface, new Size(width, height)); + } else { + videoGraph.setOutputSurfaceInfo(/* outputSurfaceInfo= */ null); + defaultVideoSink.clearOutputSurfaceInfo(); } }