Always initialize VideoSink in renderer

Instead of initializing the video sink outside the renderer with an
empty format for composition preview, we initialize it in the renderer
with the input format for video.

PiperOrigin-RevId: 627313708
This commit is contained in:
kimvde 2024-04-23 02:17:58 -07:00 committed by Copybara-Service
parent e3caed1441
commit 8da6938782
2 changed files with 13 additions and 2 deletions

View file

@ -200,7 +200,8 @@ public class ImageRenderer extends BaseRenderer {
}
@Override
protected void onEnabled(boolean joining, boolean mayRenderStartOfStream) {
protected void onEnabled(boolean joining, boolean mayRenderStartOfStream)
throws ExoPlaybackException {
firstFrameState =
mayRenderStartOfStream
? C.FIRST_FRAME_NOT_RENDERED

View file

@ -29,6 +29,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** Utility {@link Player.Listener} for testing. */
public final class PlayerTestListener implements Player.Listener, AnalyticsListener {
private final ConditionVariable playerIdle;
private final ConditionVariable playerReady;
private final ConditionVariable playerEnded;
private final ConditionVariable firstFrameRendered;
@ -43,6 +44,7 @@ public final class PlayerTestListener implements Player.Listener, AnalyticsListe
* #waitUntilPlayerReady()} and {@link #waitUntilPlayerEnded()} waits.
*/
public PlayerTestListener(long testTimeoutMs) {
playerIdle = new ConditionVariable();
playerReady = new ConditionVariable();
playerEnded = new ConditionVariable();
firstFrameRendered = new ConditionVariable();
@ -50,6 +52,11 @@ public final class PlayerTestListener implements Player.Listener, AnalyticsListe
this.testTimeoutMs = testTimeoutMs;
}
/** Waits until the {@link Player player} is {@linkplain Player#STATE_IDLE idle}. */
public void waitUntilPlayerIdle() throws PlaybackException, TimeoutException {
waitOrThrow(playerIdle);
}
/** Waits until the {@link Player player} is {@linkplain Player#STATE_READY ready}. */
public void waitUntilPlayerReady() throws TimeoutException, PlaybackException {
waitOrThrow(playerReady);
@ -81,7 +88,9 @@ public final class PlayerTestListener implements Player.Listener, AnalyticsListe
@Override
public void onPlaybackStateChanged(int playbackState) {
if (playbackState == Player.STATE_READY) {
if (playbackState == Player.STATE_IDLE) {
playerIdle.open();
} else if (playbackState == Player.STATE_READY) {
playerReady.open();
} else if (playbackState == Player.STATE_ENDED) {
playerEnded.open();
@ -96,6 +105,7 @@ public final class PlayerTestListener implements Player.Listener, AnalyticsListe
@Override
public void onPlayerError(PlaybackException error) {
playbackException.set(error);
playerIdle.open();
playerReady.open();
playerEnded.open();
firstFrameRendered.open();