Remove references to renderer from VideoFrameReleaseControl's Javadoc

This is a step towards removing the assumption that there is only one
sequence and therefore one renderer feeding data to DefaultVideoSink and
VideoFrameReleaseControl.

PiperOrigin-RevId: 734062629
This commit is contained in:
kimvde 2025-03-06 02:52:34 -08:00 committed by Copybara-Service
parent 7e6089d3aa
commit ab2affa5a5
3 changed files with 24 additions and 29 deletions

View File

@ -31,7 +31,6 @@ import androidx.media3.common.util.Clock;
import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util; import androidx.media3.common.util.Util;
import androidx.media3.exoplayer.ExoPlaybackException; import androidx.media3.exoplayer.ExoPlaybackException;
import androidx.media3.exoplayer.Renderer;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@ -110,7 +109,7 @@ public final class VideoFrameReleaseControl {
/** Signals that a frame should be ignored. */ /** Signals that a frame should be ignored. */
public static final int FRAME_RELEASE_IGNORE = 4; public static final int FRAME_RELEASE_IGNORE = 4;
/** Signals that a frame should not be released and the renderer should try again later. */ /** Signals that a frame should not be released and the caller should try again later. */
public static final int FRAME_RELEASE_TRY_AGAIN_LATER = 5; public static final int FRAME_RELEASE_TRY_AGAIN_LATER = 5;
/** Per {@link FrameReleaseAction} metadata. */ /** Per {@link FrameReleaseAction} metadata. */
@ -217,7 +216,7 @@ public final class VideoFrameReleaseControl {
* @param frameTimingEvaluator The {@link FrameTimingEvaluator} that will assist in {@linkplain * @param frameTimingEvaluator The {@link FrameTimingEvaluator} that will assist in {@linkplain
* #getFrameReleaseAction(long, long, long, long, boolean, FrameReleaseInfo) frame release * #getFrameReleaseAction(long, long, long, long, boolean, FrameReleaseInfo) frame release
* actions}. * actions}.
* @param allowedJoiningTimeMs The maximum duration in milliseconds for which the renderer can * @param allowedJoiningTimeMs The maximum duration in milliseconds for which the caller can
* attempt to seamlessly join an ongoing playback. * attempt to seamlessly join an ongoing playback.
*/ */
public VideoFrameReleaseControl( public VideoFrameReleaseControl(
@ -256,14 +255,14 @@ public final class VideoFrameReleaseControl {
} }
} }
/** Called when the renderer is started. */ /** Called when rendering starts. */
public void onStarted() { public void onStarted() {
started = true; started = true;
lastReleaseRealtimeUs = msToUs(clock.elapsedRealtime()); lastReleaseRealtimeUs = msToUs(clock.elapsedRealtime());
frameReleaseHelper.onStarted(); frameReleaseHelper.onStarted();
} }
/** Called when the renderer is stopped. */ /** Called when rendering stops. */
public void onStopped() { public void onStopped() {
started = false; started = false;
joiningDeadlineMs = C.TIME_UNSET; joiningDeadlineMs = C.TIME_UNSET;
@ -311,14 +310,11 @@ public final class VideoFrameReleaseControl {
/** /**
* Whether the release control is ready to start playback. * Whether the release control is ready to start playback.
* *
* <p>The renderer should be {@linkplain Renderer#isReady() ready} if and only if the release * @param otherwiseReady Whether the caller is ready except for the release control.
* control is ready.
*
* @param rendererOtherwiseReady Whether the renderer is ready except for the release control.
* @return Whether the release control is ready. * @return Whether the release control is ready.
*/ */
public boolean isReady(boolean rendererOtherwiseReady) { public boolean isReady(boolean otherwiseReady) {
if (rendererOtherwiseReady && firstFrameState == C.FIRST_FRAME_RENDERED) { if (otherwiseReady && firstFrameState == C.FIRST_FRAME_RENDERED) {
// Ready. If we were joining then we've now joined, so clear the joining deadline. // Ready. If we were joining then we've now joined, so clear the joining deadline.
joiningDeadlineMs = C.TIME_UNSET; joiningDeadlineMs = C.TIME_UNSET;
return true; return true;
@ -351,7 +347,7 @@ public final class VideoFrameReleaseControl {
} }
/** /**
* Returns a {@link FrameReleaseAction} for a video frame which instructs a renderer what to do * Returns a {@link FrameReleaseAction} for a video frame which instructs the caller what to do
* with the frame. * with the frame.
* *
* @param presentationTimeUs The presentation time of the video frame, in microseconds. * @param presentationTimeUs The presentation time of the video frame, in microseconds.
@ -363,7 +359,7 @@ public final class VideoFrameReleaseControl {
* @param frameReleaseInfo A {@link FrameReleaseInfo} that will be filled with detailed data only * @param frameReleaseInfo A {@link FrameReleaseInfo} that will be filled with detailed data only
* if the method returns {@link #FRAME_RELEASE_IMMEDIATELY} or {@link * if the method returns {@link #FRAME_RELEASE_IMMEDIATELY} or {@link
* #FRAME_RELEASE_SCHEDULED}. * #FRAME_RELEASE_SCHEDULED}.
* @return A {@link FrameReleaseAction} that should instruct the renderer whether to release the * @return A {@link FrameReleaseAction} that should instruct the caller whether to release the
* frame or not. * frame or not.
*/ */
public @FrameReleaseAction int getFrameReleaseAction( public @FrameReleaseAction int getFrameReleaseAction(
@ -435,7 +431,7 @@ public final class VideoFrameReleaseControl {
frameReleaseHelper.setChangeFrameRateStrategy(changeFrameRateStrategy); frameReleaseHelper.setChangeFrameRateStrategy(changeFrameRateStrategy);
} }
/** Sets the playback speed. Called when the renderer playback speed changes. */ /** Sets the playback speed. */
public void setPlaybackSpeed(@FloatRange(from = 0, fromInclusive = false) float speed) { public void setPlaybackSpeed(@FloatRange(from = 0, fromInclusive = false) float speed) {
checkArgument(speed > 0); checkArgument(speed > 0);
if (speed == playbackSpeed) { if (speed == playbackSpeed) {
@ -462,9 +458,8 @@ public final class VideoFrameReleaseControl {
*/ */
private long calculateEarlyTimeUs( private long calculateEarlyTimeUs(
long positionUs, long elapsedRealtimeUs, long framePresentationTimeUs) { long positionUs, long elapsedRealtimeUs, long framePresentationTimeUs) {
// Calculate how early we are. In other words, the realtime duration that needs to elapse whilst // Calculate how early we are. In other words, calculate the realtime duration that needs to
// the renderer is started before the frame should be rendered. A negative value means that // elapse before the frame should be rendered. A negative value means that we're already late.
// we're already late.
// Note: Use of double rather than float is intentional for accuracy in the calculations below. // Note: Use of double rather than float is intentional for accuracy in the calculations below.
long earlyUs = (long) ((framePresentationTimeUs - positionUs) / (double) playbackSpeed); long earlyUs = (long) ((framePresentationTimeUs - positionUs) / (double) playbackSpeed);
if (started) { if (started) {

View File

@ -102,7 +102,7 @@ import androidx.media3.exoplayer.ExoPlaybackException;
lastPresentationTimeUs = C.TIME_UNSET; lastPresentationTimeUs = C.TIME_UNSET;
} }
/** Flushes the renderer. */ /** Flushes the render control. */
public void flush() { public void flush() {
presentationTimestampsUs.clear(); presentationTimestampsUs.clear();
latestInputPresentationTimeUs = C.TIME_UNSET; latestInputPresentationTimeUs = C.TIME_UNSET;

View File

@ -33,8 +33,8 @@ public class VideoFrameReleaseControlTest {
public void isReady_onNewInstance_returnsFalse() { public void isReady_onNewInstance_returnsFalse() {
VideoFrameReleaseControl videoFrameReleaseControl = createVideoFrameReleaseControl(); VideoFrameReleaseControl videoFrameReleaseControl = createVideoFrameReleaseControl();
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ true)).isFalse(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ true)).isFalse();
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isFalse(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isFalse();
} }
@Test @Test
@ -42,7 +42,7 @@ public class VideoFrameReleaseControlTest {
VideoFrameReleaseControl videoFrameReleaseControl = createVideoFrameReleaseControl(); VideoFrameReleaseControl videoFrameReleaseControl = createVideoFrameReleaseControl();
assertThat(videoFrameReleaseControl.onFrameReleasedIsFirstFrame()).isTrue(); assertThat(videoFrameReleaseControl.onFrameReleasedIsFirstFrame()).isTrue();
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ true)).isTrue(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ true)).isTrue();
} }
@Test @Test
@ -54,7 +54,7 @@ public class VideoFrameReleaseControlTest {
videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ true); videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ true);
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isTrue(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isTrue();
} }
@Test @Test
@ -66,7 +66,7 @@ public class VideoFrameReleaseControlTest {
videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ false); videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ false);
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isTrue(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isTrue();
} }
@Test @Test
@ -77,11 +77,11 @@ public class VideoFrameReleaseControlTest {
videoFrameReleaseControl.setClock(clock); videoFrameReleaseControl.setClock(clock);
videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ true); videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ true);
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isTrue(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isTrue();
clock.advanceTime(/* timeDiffMs= */ 101); clock.advanceTime(/* timeDiffMs= */ 101);
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isFalse(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isFalse();
} }
@Test @Test
@ -92,11 +92,11 @@ public class VideoFrameReleaseControlTest {
videoFrameReleaseControl.setClock(clock); videoFrameReleaseControl.setClock(clock);
videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ false); videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ false);
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isTrue(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isTrue();
clock.advanceTime(/* timeDiffMs= */ 101); clock.advanceTime(/* timeDiffMs= */ 101);
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ false)).isFalse(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ false)).isFalse();
} }
@Test @Test
@ -125,10 +125,10 @@ public class VideoFrameReleaseControlTest {
VideoFrameReleaseControl videoFrameReleaseControl = createVideoFrameReleaseControl(); VideoFrameReleaseControl videoFrameReleaseControl = createVideoFrameReleaseControl();
videoFrameReleaseControl.onFrameReleasedIsFirstFrame(); videoFrameReleaseControl.onFrameReleasedIsFirstFrame();
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ true)).isTrue(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ true)).isTrue();
videoFrameReleaseControl.reset(); videoFrameReleaseControl.reset();
assertThat(videoFrameReleaseControl.isReady(/* rendererOtherwiseReady= */ true)).isFalse(); assertThat(videoFrameReleaseControl.isReady(/* otherwiseReady= */ true)).isFalse();
} }
@Test @Test