Don't splice in if segments don't overlap and segments are independent.

If the sample times don't overlap and are independent, splicing makes no
difference because all samples (starting from the first one, which must be
a keyframe) will be appended to the end of the queue anyway.

PiperOrigin-RevId: 313594372
This commit is contained in:
tonihei 2020-05-28 16:47:46 +01:00 committed by Oliver Woodman
parent a3b721e680
commit 5c52915f0c

View file

@ -62,6 +62,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
* @param format The chunk format.
* @param startOfPlaylistInPeriodUs The position of the playlist in the period in microseconds.
* @param mediaPlaylist The media playlist from which this chunk was obtained.
* @param segmentIndexInPlaylist The index of the segment in the media playlist.
* @param playlistUrl The url of the playlist from which this chunk was obtained.
* @param muxedCaptionFormats List of muxed caption {@link Format}s. Null if no closed caption
* information is available in the master playlist.
@ -137,8 +138,11 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
if (previousChunk != null) {
id3Decoder = previousChunk.id3Decoder;
scratchId3Data = previousChunk.scratchId3Data;
shouldSpliceIn =
!playlistUrl.equals(previousChunk.playlistUrl) || !previousChunk.loadCompleted;
boolean canContinueWithoutSplice =
(playlistUrl.equals(previousChunk.playlistUrl) && previousChunk.loadCompleted)
|| (mediaPlaylist.hasIndependentSegments
&& segmentStartTimeInPeriodUs >= previousChunk.endTimeUs);
shouldSpliceIn = !canContinueWithoutSplice;
if (shouldSpliceIn) {
sampleQueueDiscardFromIndices = previousChunk.sampleQueueDiscardFromIndices;
}