mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Set TrackStreams to be final on renderers that will be disabled.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125691172
This commit is contained in:
parent
494510d6ad
commit
aa313f234d
1 changed files with 14 additions and 9 deletions
|
|
@ -681,21 +681,26 @@ import java.util.ArrayList;
|
||||||
playingSourceEndPositionUs = C.UNSET_TIME_US;
|
playingSourceEndPositionUs = C.UNSET_TIME_US;
|
||||||
} else if (playingSource.nextSource != null && playingSource.nextSource.prepared) {
|
} else if (playingSource.nextSource != null && playingSource.nextSource.prepared) {
|
||||||
readingSource = playingSource.nextSource;
|
readingSource = playingSource.nextSource;
|
||||||
// Replace enabled renderers' TrackStreams if they will continue to be enabled when the
|
|
||||||
// new source starts playing, so that the transition can be seamless.
|
|
||||||
TrackSelectionArray newTrackSelections = readingSource.trackSelections;
|
TrackSelectionArray newTrackSelections = readingSource.trackSelections;
|
||||||
TrackGroupArray groups = readingSource.sampleSource.getTrackGroups();
|
TrackGroupArray groups = readingSource.sampleSource.getTrackGroups();
|
||||||
for (int i = 0; i < renderers.length; i++) {
|
for (int i = 0; i < renderers.length; i++) {
|
||||||
TrackRenderer renderer = renderers[i];
|
TrackRenderer renderer = renderers[i];
|
||||||
TrackSelection selection = newTrackSelections.get(i);
|
TrackSelection selection = newTrackSelections.get(i);
|
||||||
if (selection != null && renderer.getState() != TrackRenderer.STATE_DISABLED) {
|
if (renderer.getState() != TrackRenderer.STATE_DISABLED) {
|
||||||
// The renderer is enabled and will continue to be enabled after the transition.
|
if (selection != null) {
|
||||||
|
// Replace the renderer's TrackStream so the transition to playing the next source can
|
||||||
|
// be seamless.
|
||||||
Format[] formats = new Format[selection.length];
|
Format[] formats = new Format[selection.length];
|
||||||
for (int j = 0; j < formats.length; j++) {
|
for (int j = 0; j < formats.length; j++) {
|
||||||
formats[j] = groups.get(selection.group).getFormat(selection.getTrack(j));
|
formats[j] = groups.get(selection.group).getFormat(selection.getTrack(j));
|
||||||
}
|
}
|
||||||
renderer.replaceTrackStream(formats, readingSource.trackStreams[i],
|
renderer.replaceTrackStream(formats, readingSource.trackStreams[i],
|
||||||
playingSourceEndPositionUs);
|
playingSourceEndPositionUs);
|
||||||
|
} else {
|
||||||
|
// The renderer will be disabled when transitioning to playing the next source. Send
|
||||||
|
// end-of-stream to play out any remaining data.
|
||||||
|
renderer.setCurrentTrackStreamIsFinal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue