MCVR: call VideoSink.setStreamTimestampInfo on stream change

The start position and buffer adjustement are only allowed to change
when the stream changes so it makes more sense to call
setStreamTimestampInfo when the stream changes.

This is part of an effort to simplify stream change notification to the
video sink, to ease implementation of multi sequences preview.

PiperOrigin-RevId: 734062686
This commit is contained in:
kimvde 2025-03-06 02:52:44 -08:00 committed by Copybara-Service
parent ab2affa5a5
commit 377136419d

View File

@ -941,6 +941,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
super.onStreamChanged(formats, startPositionUs, offsetUs, mediaPeriodId);
if (this.startPositionUs == C.TIME_UNSET) {
this.startPositionUs = startPositionUs;
if (videoSink != null) {
videoSink.setStreamTimestampInfo(
getOutputStreamStartPositionUs(), getBufferTimestampAdjustmentUs());
}
}
updatePeriodDurationUs(mediaPeriodId);
}
@ -965,8 +969,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
// MediaCodec once the codec is flushed.
videoSink.flush(/* resetPosition= */ true);
}
videoSink.setStreamTimestampInfo(
getOutputStreamStartPositionUs(), getBufferTimestampAdjustmentUs());
pendingVideoSinkInputStreamChange = true;
}
super.onPositionReset(positionUs, joining);