Clean-ups in VideoSinkProvider Javadoc

PiperOrigin-RevId: 623737397
This commit is contained in:
kimvde 2024-04-11 00:51:55 -07:00 committed by Copybara-Service
parent 47964ff696
commit 0b9180aa4f
2 changed files with 98 additions and 103 deletions

View File

@ -241,6 +241,42 @@ public final class CompositingVideoSinkProvider
// VideoSinkProvider methods
@Override
public void setVideoFrameReleaseControl(VideoFrameReleaseControl videoFrameReleaseControl) {
checkState(!isInitialized());
this.videoFrameReleaseControl = videoFrameReleaseControl;
videoFrameRenderControl =
new VideoFrameRenderControl(/* frameRenderer= */ this, videoFrameReleaseControl);
}
@Override
@Nullable
public VideoFrameReleaseControl getVideoFrameReleaseControl() {
return videoFrameReleaseControl;
}
@Override
public void setClock(Clock clock) {
checkState(!isInitialized());
this.clock = clock;
}
@Override
public void setVideoEffects(List<Effect> videoEffects) {
this.videoEffects = videoEffects;
if (isInitialized()) {
checkStateNotNull(videoSinkImpl).setVideoEffects(videoEffects);
}
}
@Override
public void setPendingVideoEffects(List<Effect> videoEffects) {
this.videoEffects = videoEffects;
if (isInitialized()) {
checkStateNotNull(videoSinkImpl).setPendingVideoEffects(videoEffects);
}
}
@Override
public void initialize(Format sourceFormat) throws VideoSink.VideoSinkException {
checkState(state == STATE_CREATED);
@ -291,44 +327,11 @@ public final class CompositingVideoSinkProvider
return state == STATE_INITIALIZED;
}
@Override
public void release() {
if (state == STATE_RELEASED) {
return;
}
if (handler != null) {
handler.removeCallbacksAndMessages(/* token= */ null);
}
if (videoGraph != null) {
videoGraph.release();
}
currentSurfaceAndSize = null;
state = STATE_RELEASED;
}
@Override
public VideoSink getSink() {
return checkStateNotNull(videoSinkImpl);
}
@Override
public void setVideoEffects(List<Effect> videoEffects) {
this.videoEffects = videoEffects;
if (isInitialized()) {
checkStateNotNull(videoSinkImpl).setVideoEffects(videoEffects);
}
}
@Override
public void setPendingVideoEffects(List<Effect> videoEffects) {
this.videoEffects = videoEffects;
if (isInitialized()) {
checkStateNotNull(videoSinkImpl).setPendingVideoEffects(videoEffects);
}
}
@Override
public void setStreamOffsetUs(long streamOffsetUs) {
checkStateNotNull(videoSinkImpl).setStreamOffsetUs(streamOffsetUs);
@ -346,14 +349,6 @@ public final class CompositingVideoSinkProvider
outputSurface, outputResolution.getWidth(), outputResolution.getHeight());
}
@Override
public void setVideoFrameReleaseControl(VideoFrameReleaseControl videoFrameReleaseControl) {
checkState(!isInitialized());
this.videoFrameReleaseControl = videoFrameReleaseControl;
videoFrameRenderControl =
new VideoFrameRenderControl(/* frameRenderer= */ this, videoFrameReleaseControl);
}
@Override
public void clearOutputSurfaceInfo() {
maybeSetOutputSurfaceInfo(
@ -369,15 +364,20 @@ public final class CompositingVideoSinkProvider
}
@Override
@Nullable
public VideoFrameReleaseControl getVideoFrameReleaseControl() {
return videoFrameReleaseControl;
public void release() {
if (state == STATE_RELEASED) {
return;
}
@Override
public void setClock(Clock clock) {
checkState(!isInitialized());
this.clock = clock;
if (handler != null) {
handler.removeCallbacksAndMessages(/* token= */ null);
}
if (videoGraph != null) {
videoGraph.release();
}
currentSurfaceAndSize = null;
state = STATE_RELEASED;
}
// VideoGraph.Listener

View File

@ -29,67 +29,14 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@UnstableApi
public interface VideoSinkProvider {
/**
* Initializes the provider for video frame processing. Can be called up to one time and only
* after video effects are {@linkplain #setVideoEffects(List) set}.
*
* @param sourceFormat The format of the compressed video.
* @throws VideoSink.VideoSinkException If enabling the provider failed.
*/
void initialize(Format sourceFormat) throws VideoSink.VideoSinkException;
/** Returns whether this provider is initialized for frame processing. */
boolean isInitialized();
/** Releases the sink provider. */
void release();
/** Returns a {@link VideoSink} to forward video frames for processing. */
VideoSink getSink();
/** Sets video effects on this provider to apply immediately. */
void setVideoEffects(List<Effect> videoEffects);
/**
* Sets video effects on this provider to apply when the next stream is {@linkplain
* VideoSink#registerInputStream(int, Format) registered} on the {@link #getSink() VideoSink}.
*/
void setPendingVideoEffects(List<Effect> videoEffects);
/**
* Sets the offset, in microseconds, that is added to the video frames presentation timestamps
* from the player.
*
* <p>Must be called after the sink provider is {@linkplain #initialize(Format) initialized}.
*/
void setStreamOffsetUs(long streamOffsetUs);
/**
* Sets the output surface info.
*
* <p>Must be called after the sink provider is {@linkplain #initialize(Format) initialized}.
*/
void setOutputSurfaceInfo(Surface outputSurface, Size outputResolution);
/**
* Sets the {@link VideoFrameReleaseControl} that will be used for releasing of video frames
* during rendering.
*
* <p>Must be called before, not after, the sink provider is {@linkplain #initialize(Format)
* initialized}.
* <p>Must be called before the sink provider is {@linkplain #initialize(Format) initialized}.
*/
void setVideoFrameReleaseControl(VideoFrameReleaseControl videoFrameReleaseControl);
/**
* Clears the set output surface info.
*
* <p>Must be called after the sink provider is {@linkplain #initialize(Format) initialized}.
*/
void clearOutputSurfaceInfo();
/** Sets a {@link VideoFrameMetadataListener} which is used in the returned {@link VideoSink}. */
void setVideoFrameMetadataListener(VideoFrameMetadataListener videoFrameMetadataListener);
/**
* Returns the {@link VideoFrameReleaseControl} that will be used for releasing of video frames
* during rendering.
@ -105,4 +52,52 @@ public interface VideoSinkProvider {
* <p>Must be called before the sink provider is {@linkplain #initialize(Format) initialized}.
*/
void setClock(Clock clock);
/** Sets video effects on this provider to apply immediately. */
void setVideoEffects(List<Effect> videoEffects);
/**
* Sets video effects on this provider to apply when the next stream is {@linkplain
* VideoSink#registerInputStream(int, Format) registered} on the {@link #getSink() VideoSink}.
*/
void setPendingVideoEffects(List<Effect> videoEffects);
/**
* Initializes the provider for video frame processing. Can be called up to one time and only
* after video effects are {@linkplain #setVideoEffects(List) set}.
*
* @param sourceFormat The format of the compressed video.
* @throws VideoSink.VideoSinkException If enabling the provider failed.
*/
void initialize(Format sourceFormat) throws VideoSink.VideoSinkException;
/** Returns whether this provider is initialized for frame processing. */
boolean isInitialized();
/**
* Returns a {@link VideoSink} to forward video frames for processing.
*
* <p>Must be called after the sink provider is {@linkplain #initialize(Format) initialized}.
*/
VideoSink getSink();
/**
* Sets the offset, in microseconds, that is added to the video frames presentation timestamps
* from the player.
*
* <p>Must be called after the sink provider is {@linkplain #initialize(Format) initialized}.
*/
void setStreamOffsetUs(long streamOffsetUs);
/** Sets the output surface info. */
void setOutputSurfaceInfo(Surface outputSurface, Size outputResolution);
/** Clears the set output surface info. */
void clearOutputSurfaceInfo();
/** Sets a {@link VideoFrameMetadataListener} which is used in the returned {@link VideoSink}. */
void setVideoFrameMetadataListener(VideoFrameMetadataListener videoFrameMetadataListener);
/** Releases the sink provider. */
void release();
}