Rename VideoSink methods

This is following a renaming of registerInputFrame to handleInputFrame.
- queueInputBitmap is renamed to handleInputBitmap for consistency with
  handleInputFrame.
- registerInputStream is renamed to onInputStreamChanged for consistency
  with media3 method names.

PiperOrigin-RevId: 655529699
This commit is contained in:
kimvde 2024-07-24 05:38:23 -07:00 committed by Copybara-Service
parent a1f20de3a9
commit da4c962e09
4 changed files with 28 additions and 28 deletions

View File

@ -580,7 +580,7 @@ public final class CompositingVideoSinkProvider implements VideoSinkProvider, Vi
} }
@Override @Override
public void registerInputStream(@InputType int inputType, Format format) { public void onInputStreamChanged(@InputType int inputType, Format format) {
checkState(isInitialized()); checkState(isInitialized());
switch (inputType) { switch (inputType) {
case INPUT_TYPE_SURFACE: case INPUT_TYPE_SURFACE:
@ -764,7 +764,7 @@ public final class CompositingVideoSinkProvider implements VideoSinkProvider, Vi
} }
@Override @Override
public boolean queueBitmap(Bitmap inputBitmap, TimestampIterator timestampIterator) { public boolean handleInputBitmap(Bitmap inputBitmap, TimestampIterator timestampIterator) {
checkState(isInitialized()); checkState(isInitialized());
if (!maybeRegisterPendingInputStream()) { if (!maybeRegisterPendingInputStream()) {

View File

@ -186,7 +186,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
@Nullable private VideoFrameMetadataListener frameMetadataListener; @Nullable private VideoFrameMetadataListener frameMetadataListener;
private long startPositionUs; private long startPositionUs;
private long periodDurationUs; private long periodDurationUs;
private boolean videoSinkNeedsRegisterInputStream; private boolean pendingVideoSinkInputStreamChange;
/** /**
* @param context A context. * @param context A context.
@ -789,7 +789,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
getOutputStreamOffsetUs(), getOutputStreamOffsetUs(),
getBufferTimestampAdjustmentUs(), getBufferTimestampAdjustmentUs(),
getLastResetPositionUs()); getLastResetPositionUs());
videoSinkNeedsRegisterInputStream = true; pendingVideoSinkInputStreamChange = true;
} }
super.onPositionReset(positionUs, joining); super.onPositionReset(positionUs, joining);
if (videoSink == null) { if (videoSink == null) {
@ -1354,9 +1354,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
} }
decodedVideoSize = new VideoSize(width, height, pixelWidthHeightRatio); decodedVideoSize = new VideoSize(width, height, pixelWidthHeightRatio);
if (videoSink != null && videoSinkNeedsRegisterInputStream) { if (videoSink != null && pendingVideoSinkInputStreamChange) {
onReadyToRegisterVideoSinkInputStream(); onReadyToChangeVideoSinkInputStream();
videoSink.registerInputStream( videoSink.onInputStreamChanged(
/* inputType= */ VideoSink.INPUT_TYPE_SURFACE, /* inputType= */ VideoSink.INPUT_TYPE_SURFACE,
format format
.buildUpon() .buildUpon()
@ -1367,16 +1367,16 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
} else { } else {
videoFrameReleaseControl.setFrameRate(format.frameRate); videoFrameReleaseControl.setFrameRate(format.frameRate);
} }
videoSinkNeedsRegisterInputStream = false; pendingVideoSinkInputStreamChange = false;
} }
/** /**
* Called when ready to {@linkplain VideoSink#registerInputStream(int, Format) register} an input * Called when ready to {@linkplain VideoSink#onInputStreamChanged(int, Format) change} the input
* stream when {@linkplain #setVideoEffects video effects} are enabled. * stream when {@linkplain #setVideoEffects video effects} are enabled.
* *
* <p>The default implementation is a no-op. * <p>The default implementation is a no-op.
*/ */
protected void onReadyToRegisterVideoSinkInputStream() { protected void onReadyToChangeVideoSinkInputStream() {
// do nothing. // do nothing.
} }
@ -1584,7 +1584,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
} else { } else {
videoFrameReleaseControl.onProcessedStreamChange(); videoFrameReleaseControl.onProcessedStreamChange();
} }
videoSinkNeedsRegisterInputStream = true; pendingVideoSinkInputStreamChange = true;
maybeSetupTunnelingForFirstFrame(); maybeSetupTunnelingForFirstFrame();
} }

View File

@ -203,8 +203,8 @@ public interface VideoSink {
void setVideoEffects(List<Effect> videoEffects); void setVideoEffects(List<Effect> videoEffects);
/** /**
* Sets {@linkplain Effect video effects} to apply after the next stream is {@linkplain * Sets {@linkplain Effect video effects} to apply after the next stream {@linkplain
* VideoSink#registerInputStream(int, Format) registered}. * VideoSink#onInputStreamChanged(int, Format) change}.
*/ */
void setPendingVideoEffects(List<Effect> videoEffects); void setPendingVideoEffects(List<Effect> videoEffects);
@ -256,13 +256,13 @@ public interface VideoSink {
* @param inputType The {@link InputType} of the stream. * @param inputType The {@link InputType} of the stream.
* @param format The {@link Format} of the stream. * @param format The {@link Format} of the stream.
*/ */
void registerInputStream(@InputType int inputType, Format format); void onInputStreamChanged(@InputType int inputType, Format format);
/** /**
* Handles a video input frame. * Handles a video input frame.
* *
* <p>Must be called after the corresponding stream is {@linkplain #registerInputStream(int, * <p>Must be called after the corresponding stream is {@linkplain #onInputStreamChanged(int,
* Format) registered}. * Format) signalled}.
* *
* @param framePresentationTimeUs The frame's presentation time, in microseconds. * @param framePresentationTimeUs The frame's presentation time, in microseconds.
* @param isLastFrame Whether this is the last frame of the video stream. * @param isLastFrame Whether this is the last frame of the video stream.
@ -282,18 +282,18 @@ public interface VideoSink {
throws VideoSinkException; throws VideoSinkException;
/** /**
* Provides an input {@link Bitmap} to the video sink. * Handles an input {@link Bitmap}.
* *
* <p>Must be called after the corresponding stream is {@linkplain #registerInputStream(int, * <p>Must be called after the corresponding stream is {@linkplain #onInputStreamChanged(int,
* Format) registered}. * Format) signalled}.
* *
* @param inputBitmap The {@link Bitmap} queued to the video sink. * @param inputBitmap The {@link Bitmap} to queue to the video sink.
* @param timestampIterator The times within the current stream that the bitmap should be shown * @param timestampIterator The times within the current stream that the bitmap should be shown
* at. The timestamps should be monotonically increasing. * at. The timestamps should be monotonically increasing.
* @return Whether the bitmap was queued successfully. If {@code false}, the caller can try again * @return Whether the bitmap was queued successfully. If {@code false}, the caller can try again
* later. * later.
*/ */
boolean queueBitmap(Bitmap inputBitmap, TimestampIterator timestampIterator); boolean handleInputBitmap(Bitmap inputBitmap, TimestampIterator timestampIterator);
/** /**
* Incrementally renders processed video frames to the output surface. * Incrementally renders processed video frames to the output surface.

View File

@ -281,7 +281,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
@Override @Override
protected void onReadyToRegisterVideoSinkInputStream() { protected void onReadyToChangeVideoSinkInputStream() {
@Nullable ImmutableList<Effect> pendingEffect = this.pendingEffect; @Nullable ImmutableList<Effect> pendingEffect = this.pendingEffect;
if (pendingEffect != null) { if (pendingEffect != null) {
videoSink.setPendingVideoEffects(pendingEffect); videoSink.setPendingVideoEffects(pendingEffect);
@ -298,7 +298,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private @MonotonicNonNull ConstantRateTimestampIterator timestampIterator; private @MonotonicNonNull ConstantRateTimestampIterator timestampIterator;
private @MonotonicNonNull EditedMediaItem editedMediaItem; private @MonotonicNonNull EditedMediaItem editedMediaItem;
@Nullable private ExoPlaybackException pendingExoPlaybackException; @Nullable private ExoPlaybackException pendingExoPlaybackException;
private boolean inputStreamPendingRegistration; private boolean inputStreamPending;
private long streamStartPositionUs; private long streamStartPositionUs;
private long streamOffsetUs; private long streamOffsetUs;
private boolean mayRenderStartOfStream; private boolean mayRenderStartOfStream;
@ -405,7 +405,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
sequencePlayerRenderersWrapper.getOffsetToCompositionTimeUs(mediaItemIndex, offsetUs); sequencePlayerRenderersWrapper.getOffsetToCompositionTimeUs(mediaItemIndex, offsetUs);
timestampIterator = createTimestampIterator(/* positionUs= */ startPositionUs); timestampIterator = createTimestampIterator(/* positionUs= */ startPositionUs);
videoEffects = editedMediaItem.effects.videoEffects; videoEffects = editedMediaItem.effects.videoEffects;
inputStreamPendingRegistration = true; inputStreamPending = true;
} }
@Override @Override
@ -427,7 +427,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Override @Override
protected boolean processOutputBuffer( protected boolean processOutputBuffer(
long positionUs, long elapsedRealtimeUs, Bitmap outputImage, long timeUs) { long positionUs, long elapsedRealtimeUs, Bitmap outputImage, long timeUs) {
if (inputStreamPendingRegistration) { if (inputStreamPending) {
checkState(streamStartPositionUs != C.TIME_UNSET); checkState(streamStartPositionUs != C.TIME_UNSET);
checkState(streamOffsetUs != C.TIME_UNSET); checkState(streamOffsetUs != C.TIME_UNSET);
videoSink.setPendingVideoEffects(videoEffects); videoSink.setPendingVideoEffects(videoEffects);
@ -436,7 +436,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
streamOffsetUs, streamOffsetUs,
/* bufferTimestampAdjustmentUs= */ offsetToCompositionTimeUs, /* bufferTimestampAdjustmentUs= */ offsetToCompositionTimeUs,
getLastResetPositionUs()); getLastResetPositionUs());
videoSink.registerInputStream( videoSink.onInputStreamChanged(
VideoSink.INPUT_TYPE_BITMAP, VideoSink.INPUT_TYPE_BITMAP,
new Format.Builder() new Format.Builder()
.setSampleMimeType(MimeTypes.IMAGE_RAW) .setSampleMimeType(MimeTypes.IMAGE_RAW)
@ -445,9 +445,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
.setColorInfo(ColorInfo.SRGB_BT709_FULL) .setColorInfo(ColorInfo.SRGB_BT709_FULL)
.setFrameRate(/* frameRate= */ DEFAULT_FRAME_RATE) .setFrameRate(/* frameRate= */ DEFAULT_FRAME_RATE)
.build()); .build());
inputStreamPendingRegistration = false; inputStreamPending = false;
} }
return videoSink.queueBitmap(outputImage, checkStateNotNull(timestampIterator)); return videoSink.handleInputBitmap(outputImage, checkStateNotNull(timestampIterator));
} }
private ConstantRateTimestampIterator createTimestampIterator(long positionUs) { private ConstantRateTimestampIterator createTimestampIterator(long positionUs) {