mirror of
https://github.com/androidx/media.git
synced 2025-04-29 22:36:54 +08:00
Remove references to defaultVideoSink from inputVideoSink
This makes the chain structure (InputVideoSinks, then VideoGraph, then DefaultVideoSink) clearer. PiperOrigin-RevId: 750910247
This commit is contained in:
parent
142496fa16
commit
d9a92e2586
@ -334,7 +334,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
/** The buffer presentation time, in microseconds, of the final frame in the stream. */
|
/** The buffer presentation time, in microseconds, of the final frame in the stream. */
|
||||||
private long finalBufferPresentationTimeUs;
|
private long finalBufferPresentationTimeUs;
|
||||||
|
|
||||||
private boolean hasSignaledEndOfCurrentInputStream;
|
private boolean hasSignaledEndOfVideoGraphOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the buffer timestamp (the player position, with renderer offset) to the composition
|
* Converts the buffer timestamp (the player position, with renderer offset) to the composition
|
||||||
@ -396,6 +396,10 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTotalVideoInputCount(int totalVideoInputCount) {
|
||||||
|
this.totalVideoInputCount = totalVideoInputCount;
|
||||||
|
}
|
||||||
|
|
||||||
/** Starts rendering to the output surface. */
|
/** Starts rendering to the output surface. */
|
||||||
public void startRendering() {
|
public void startRendering() {
|
||||||
defaultVideoSink.startRendering();
|
defaultVideoSink.startRendering();
|
||||||
@ -512,9 +516,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
finalBufferPresentationTimeUs != C.TIME_UNSET
|
finalBufferPresentationTimeUs != C.TIME_UNSET
|
||||||
&& bufferPresentationTimeUs >= finalBufferPresentationTimeUs;
|
&& bufferPresentationTimeUs >= finalBufferPresentationTimeUs;
|
||||||
if (isLastFrame) {
|
if (isLastFrame) {
|
||||||
// TODO b/257464707 - Support extensively modified media.
|
signalEndOfVideoGraphOutputStream();
|
||||||
defaultVideoSink.signalEndOfCurrentInputStream();
|
|
||||||
hasSignaledEndOfCurrentInputStream = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,10 +607,6 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
return state == STATE_INITIALIZED;
|
return state == STATE_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotalVideoInputCount(int totalVideoInputCount) {
|
|
||||||
this.totalVideoInputCount = totalVideoInputCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void maybeSetOutputSurfaceInfo(@Nullable Surface surface, int width, int height) {
|
private void maybeSetOutputSurfaceInfo(@Nullable Surface surface, int width, int height) {
|
||||||
if (videoGraph == null) {
|
if (videoGraph == null) {
|
||||||
return;
|
return;
|
||||||
@ -627,9 +625,15 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
return defaultVideoSink.isReady(/* otherwiseReady= */ otherwiseReady && pendingFlushCount == 0);
|
return defaultVideoSink.isReady(/* otherwiseReady= */ otherwiseReady && pendingFlushCount == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void signalEndOfVideoGraphOutputStream() {
|
||||||
|
// TODO: b/257464707 - Support extensively modified media.
|
||||||
|
defaultVideoSink.signalEndOfCurrentInputStream();
|
||||||
|
hasSignaledEndOfVideoGraphOutputStream = true;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isEnded() {
|
private boolean isEnded() {
|
||||||
return pendingFlushCount == 0
|
return pendingFlushCount == 0
|
||||||
&& hasSignaledEndOfCurrentInputStream
|
&& hasSignaledEndOfVideoGraphOutputStream
|
||||||
&& defaultVideoSink.isEnded();
|
&& defaultVideoSink.isEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,7 +666,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
}
|
}
|
||||||
lastOutputBufferPresentationTimeUs = C.TIME_UNSET;
|
lastOutputBufferPresentationTimeUs = C.TIME_UNSET;
|
||||||
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
||||||
hasSignaledEndOfCurrentInputStream = false;
|
hasSignaledEndOfVideoGraphOutputStream = false;
|
||||||
// Handle pending video graph callbacks to ensure video size changes reach the video render
|
// Handle pending video graph callbacks to ensure video size changes reach the video render
|
||||||
// control.
|
// control.
|
||||||
checkStateNotNull(handler).post(() -> pendingFlushCount--);
|
checkStateNotNull(handler).post(() -> pendingFlushCount--);
|
||||||
@ -672,6 +676,10 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
defaultVideoSink.join(renderNextFrameImmediately);
|
defaultVideoSink.join(renderNextFrameImmediately);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void allowReleaseFirstFrameBeforeStarted() {
|
||||||
|
defaultVideoSink.allowReleaseFirstFrameBeforeStarted();
|
||||||
|
}
|
||||||
|
|
||||||
private void setVideoFrameMetadataListener(
|
private void setVideoFrameMetadataListener(
|
||||||
VideoFrameMetadataListener videoFrameMetadataListener) {
|
VideoFrameMetadataListener videoFrameMetadataListener) {
|
||||||
this.videoFrameMetadataListener = videoFrameMetadataListener;
|
this.videoFrameMetadataListener = videoFrameMetadataListener;
|
||||||
@ -821,8 +829,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
public void signalEndOfCurrentInputStream() {
|
public void signalEndOfCurrentInputStream() {
|
||||||
finalBufferPresentationTimeUs = lastBufferPresentationTimeUs;
|
finalBufferPresentationTimeUs = lastBufferPresentationTimeUs;
|
||||||
if (lastOutputBufferPresentationTimeUs >= finalBufferPresentationTimeUs) {
|
if (lastOutputBufferPresentationTimeUs >= finalBufferPresentationTimeUs) {
|
||||||
defaultVideoSink.signalEndOfCurrentInputStream();
|
PlaybackVideoGraphWrapper.this.signalEndOfVideoGraphOutputStream();
|
||||||
hasSignaledEndOfCurrentInputStream = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -854,7 +861,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
this.inputType = inputType;
|
this.inputType = inputType;
|
||||||
this.inputFormat = format;
|
this.inputFormat = format;
|
||||||
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
||||||
hasSignaledEndOfCurrentInputStream = false;
|
hasSignaledEndOfVideoGraphOutputStream = false;
|
||||||
registerInputStream(format);
|
registerInputStream(format);
|
||||||
// Input timestamps should always be positive because they are offset by ExoPlayer. Adding a
|
// Input timestamps should always be positive because they are offset by ExoPlayer. Adding a
|
||||||
// stream change info to the queue with timestamp 0 should therefore always apply it as long
|
// stream change info to the queue with timestamp 0 should therefore always apply it as long
|
||||||
@ -880,7 +887,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
if (pendingStreamChanges.size() == 0) {
|
if (pendingStreamChanges.size() == 0) {
|
||||||
// All the stream changes have already been processed by the VideoGraph. Delegate to the
|
// All the stream changes have already been processed by the VideoGraph. Delegate to the
|
||||||
// downstream component.
|
// downstream component.
|
||||||
defaultVideoSink.allowReleaseFirstFrameBeforeStarted();
|
PlaybackVideoGraphWrapper.this.allowReleaseFirstFrameBeforeStarted();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TimedValueQueue<StreamChangeInfo> newPendingStreamChanges = new TimedValueQueue<>();
|
TimedValueQueue<StreamChangeInfo> newPendingStreamChanges = new TimedValueQueue<>();
|
||||||
@ -900,7 +907,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
|||||||
} else {
|
} else {
|
||||||
// The first stream change has already been processed by the VideoGraph. Delegate to the
|
// The first stream change has already been processed by the VideoGraph. Delegate to the
|
||||||
// downstream component.
|
// downstream component.
|
||||||
defaultVideoSink.allowReleaseFirstFrameBeforeStarted();
|
PlaybackVideoGraphWrapper.this.allowReleaseFirstFrameBeforeStarted();
|
||||||
}
|
}
|
||||||
isFirstStreamChange = false;
|
isFirstStreamChange = false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user