Make sure first frame has effects applied.

`FrameProcessorManager` now reports it's not ready when the output surface is set but not the output resolution. `FrameProcessorManager` allows playback without an output surface, like with ExoPlayer.

PiperOrigin-RevId: 504626088
This commit is contained in:
claincly 2023-01-25 20:06:12 +00:00 committed by christosts
parent 728619018b
commit 44f461a062

View File

@ -583,6 +583,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
@Override @Override
public boolean isReady() { public boolean isReady() {
if (super.isReady() if (super.isReady()
&& (!frameProcessorManager.isEnabled() || frameProcessorManager.isReady())
&& (renderedFirstFrameAfterReset && (renderedFirstFrameAfterReset
|| (placeholderSurface != null && displaySurface == placeholderSurface) || (placeholderSurface != null && displaySurface == placeholderSurface)
|| getCodec() == null || getCodec() == null
@ -725,8 +726,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
@State int state = getState(); @State int state = getState();
@Nullable MediaCodecAdapter codec = getCodec(); @Nullable MediaCodecAdapter codec = getCodec();
// When FrameProcessorManager is enabled, set FrameProcessorManager's display surface when
// surface's resolution is set on receiving MSG_SET_VIDEO_OUTPUT_RESOLUTION.
if (codec != null && !frameProcessorManager.isEnabled()) { if (codec != null && !frameProcessorManager.isEnabled()) {
if (Util.SDK_INT >= 23 && displaySurface != null && !codecNeedsSetOutputSurfaceWorkaround) { if (Util.SDK_INT >= 23 && displaySurface != null && !codecNeedsSetOutputSurfaceWorkaround) {
setOutputSurfaceV23(codec, displaySurface); setOutputSurfaceV23(codec, displaySurface);
@ -744,6 +743,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
// Set joining deadline to report MediaCodecVideoRenderer is ready. // Set joining deadline to report MediaCodecVideoRenderer is ready.
setJoiningDeadlineMs(); setJoiningDeadlineMs();
} }
// When FrameProcessorManager is enabled, set FrameProcessorManager's display surface and an
// unknown size.
if (frameProcessorManager.isEnabled()) {
frameProcessorManager.setOutputSurfaceInfo(displaySurface, Size.UNKNOWN);
}
} else { } else {
// The display surface has been removed. // The display surface has been removed.
clearReportedVideoSize(); clearReportedVideoSize();
@ -1889,6 +1893,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
return frameProcessor != null; return frameProcessor != null;
} }
/** Returns whether {@code FrameProcessorManager} is ready to accept input frames. */
public boolean isReady() {
return currentSurfaceAndSize == null || !currentSurfaceAndSize.second.equals(Size.UNKNOWN);
}
/** Whether the {@link FrameProcessor} has released the last frame in the current stream. */ /** Whether the {@link FrameProcessor} has released the last frame in the current stream. */
public boolean releasedLastFrame() { public boolean releasedLastFrame() {
return releasedLastFrame; return releasedLastFrame;
@ -2101,7 +2110,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
* this method. * this method.
* *
* @param format The {@link Format} associated with the frame. * @param format The {@link Format} associated with the frame.
* @param isLastBuffer Whether the buffer is the last from the deocder to register. * @param isLastBuffer Whether the buffer is the last from the decoder to register.
* @return Whether {@link MediaCodec} should render the frame to {@link FrameProcessor}. * @return Whether {@link MediaCodec} should render the frame to {@link FrameProcessor}.
*/ */
public boolean maybeRegisterFrame( public boolean maybeRegisterFrame(