Adapt InputVideoSink.onInputStreamChanged for CompositionPlayer

The output of CompositionPlayer should be considered as a single clip
(not a playlist) so we should only propagate the first stream change
event in that case.

PiperOrigin-RevId: 752661523
This commit is contained in:
kimvde 2025-04-29 03:22:07 -07:00 committed by Copybara-Service
parent cfa13e9616
commit 293c55e062
2 changed files with 17 additions and 15 deletions

View File

@ -828,20 +828,23 @@ public final class PlaybackVideoGraphWrapper implements VideoGraph.Listener {
finalFramePresentationTimeUs = C.TIME_UNSET;
hasSignaledEndOfVideoGraphOutputStream = false;
registerInputStream(format);
long fromTimestampUs;
if (lastFramePresentationTimeUs == C.TIME_UNSET) {
// Add a stream change info to the queue with a large negative timestamp to always apply it
// as long as it is the only one in the queue.
fromTimestampUs = Long.MIN_VALUE / 2;
} else {
fromTimestampUs = lastFramePresentationTimeUs + 1;
boolean isFirstStream = lastFramePresentationTimeUs == C.TIME_UNSET;
if (enablePlaylistMode || (inputIndex == PRIMARY_SEQUENCE_INDEX && isFirstStream)) {
long fromTimestampUs;
if (isFirstStream) {
// Add a stream change info to the queue with a large negative timestamp to always apply
// it as long as it is the only one in the queue.
fromTimestampUs = Long.MIN_VALUE / 2;
} else {
fromTimestampUs = lastFramePresentationTimeUs + 1;
}
pendingStreamChanges.add(
fromTimestampUs,
new StreamChangeInfo(
/* startPositionUs= */ startPositionUs + inputBufferTimestampAdjustmentUs,
firstFrameReleaseInstruction,
fromTimestampUs));
}
pendingStreamChanges.add(
fromTimestampUs,
new StreamChangeInfo(
/* startPositionUs= */ startPositionUs + inputBufferTimestampAdjustmentUs,
firstFrameReleaseInstruction,
fromTimestampUs));
}
@Override

View File

@ -134,7 +134,7 @@ public class CompositionMultipleSequencePlaybackTest {
}
@Test
@Ignore("TODO: b/391349011 - Re-enable after propagating an EOS signal after each MediaItem")
@Ignore("TODO: b/405966202 - Re-enable after propagating an EOS signal after each MediaItem")
public void playback_sequencesOfVideos_effectsReceiveCorrectTimestamps() throws Exception {
Composition composition =
new Composition.Builder(
@ -165,7 +165,6 @@ public class CompositionMultipleSequencePlaybackTest {
}
@Test
@Ignore("TODO: b/391349011 - Re-enable after adapting rendering logic for multiple sequences")
public void playback_sequencesOfImages_effectsReceiveCorrectTimestamps() throws Exception {
Composition composition =
new Composition.Builder(