mirror of
https://github.com/androidx/media.git
synced 2025-05-04 06:00:37 +08:00
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:
parent
728619018b
commit
44f461a062
@ -583,6 +583,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
if (super.isReady()
|
||||
&& (!frameProcessorManager.isEnabled() || frameProcessorManager.isReady())
|
||||
&& (renderedFirstFrameAfterReset
|
||||
|| (placeholderSurface != null && displaySurface == placeholderSurface)
|
||||
|| getCodec() == null
|
||||
@ -725,8 +726,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
|
||||
@State int state = getState();
|
||||
@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 (Util.SDK_INT >= 23 && displaySurface != null && !codecNeedsSetOutputSurfaceWorkaround) {
|
||||
setOutputSurfaceV23(codec, displaySurface);
|
||||
@ -744,6 +743,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
// Set joining deadline to report MediaCodecVideoRenderer is ready.
|
||||
setJoiningDeadlineMs();
|
||||
}
|
||||
// When FrameProcessorManager is enabled, set FrameProcessorManager's display surface and an
|
||||
// unknown size.
|
||||
if (frameProcessorManager.isEnabled()) {
|
||||
frameProcessorManager.setOutputSurfaceInfo(displaySurface, Size.UNKNOWN);
|
||||
}
|
||||
} else {
|
||||
// The display surface has been removed.
|
||||
clearReportedVideoSize();
|
||||
@ -1889,6 +1893,11 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
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. */
|
||||
public boolean releasedLastFrame() {
|
||||
return releasedLastFrame;
|
||||
@ -2101,7 +2110,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
* this method.
|
||||
*
|
||||
* @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}.
|
||||
*/
|
||||
public boolean maybeRegisterFrame(
|
||||
|
Loading…
x
Reference in New Issue
Block a user