Clean-ups in VideoSinkProvider Javadoc
PiperOrigin-RevId: 623737397
This commit is contained in:
parent
47964ff696
commit
0b9180aa4f
@ -241,6 +241,42 @@ public final class CompositingVideoSinkProvider
|
|||||||
|
|
||||||
// VideoSinkProvider methods
|
// 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
|
@Override
|
||||||
public void initialize(Format sourceFormat) throws VideoSink.VideoSinkException {
|
public void initialize(Format sourceFormat) throws VideoSink.VideoSinkException {
|
||||||
checkState(state == STATE_CREATED);
|
checkState(state == STATE_CREATED);
|
||||||
@ -291,44 +327,11 @@ public final class CompositingVideoSinkProvider
|
|||||||
return state == STATE_INITIALIZED;
|
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
|
@Override
|
||||||
public VideoSink getSink() {
|
public VideoSink getSink() {
|
||||||
return checkStateNotNull(videoSinkImpl);
|
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
|
@Override
|
||||||
public void setStreamOffsetUs(long streamOffsetUs) {
|
public void setStreamOffsetUs(long streamOffsetUs) {
|
||||||
checkStateNotNull(videoSinkImpl).setStreamOffsetUs(streamOffsetUs);
|
checkStateNotNull(videoSinkImpl).setStreamOffsetUs(streamOffsetUs);
|
||||||
@ -346,14 +349,6 @@ public final class CompositingVideoSinkProvider
|
|||||||
outputSurface, outputResolution.getWidth(), outputResolution.getHeight());
|
outputSurface, outputResolution.getWidth(), outputResolution.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setVideoFrameReleaseControl(VideoFrameReleaseControl videoFrameReleaseControl) {
|
|
||||||
checkState(!isInitialized());
|
|
||||||
this.videoFrameReleaseControl = videoFrameReleaseControl;
|
|
||||||
videoFrameRenderControl =
|
|
||||||
new VideoFrameRenderControl(/* frameRenderer= */ this, videoFrameReleaseControl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearOutputSurfaceInfo() {
|
public void clearOutputSurfaceInfo() {
|
||||||
maybeSetOutputSurfaceInfo(
|
maybeSetOutputSurfaceInfo(
|
||||||
@ -369,15 +364,20 @@ public final class CompositingVideoSinkProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public void release() {
|
||||||
public VideoFrameReleaseControl getVideoFrameReleaseControl() {
|
if (state == STATE_RELEASED) {
|
||||||
return videoFrameReleaseControl;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (handler != null) {
|
||||||
public void setClock(Clock clock) {
|
handler.removeCallbacksAndMessages(/* token= */ null);
|
||||||
checkState(!isInitialized());
|
}
|
||||||
this.clock = clock;
|
|
||||||
|
if (videoGraph != null) {
|
||||||
|
videoGraph.release();
|
||||||
|
}
|
||||||
|
currentSurfaceAndSize = null;
|
||||||
|
state = STATE_RELEASED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// VideoGraph.Listener
|
// VideoGraph.Listener
|
||||||
|
@ -29,67 +29,14 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
@UnstableApi
|
@UnstableApi
|
||||||
public interface VideoSinkProvider {
|
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
|
* Sets the {@link VideoFrameReleaseControl} that will be used for releasing of video frames
|
||||||
* during rendering.
|
* during rendering.
|
||||||
*
|
*
|
||||||
* <p>Must be called before, not after, the sink provider is {@linkplain #initialize(Format)
|
* <p>Must be called before the sink provider is {@linkplain #initialize(Format) initialized}.
|
||||||
* initialized}.
|
|
||||||
*/
|
*/
|
||||||
void setVideoFrameReleaseControl(VideoFrameReleaseControl videoFrameReleaseControl);
|
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
|
* Returns the {@link VideoFrameReleaseControl} that will be used for releasing of video frames
|
||||||
* during rendering.
|
* during rendering.
|
||||||
@ -105,4 +52,52 @@ public interface VideoSinkProvider {
|
|||||||
* <p>Must be called before the sink provider is {@linkplain #initialize(Format) initialized}.
|
* <p>Must be called before the sink provider is {@linkplain #initialize(Format) initialized}.
|
||||||
*/
|
*/
|
||||||
void setClock(Clock clock);
|
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();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user