Do TODO in HlsChunkSource
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=128190311
This commit is contained in:
parent
9e9634a1a2
commit
abcd10513a
@ -73,7 +73,7 @@ public class HlsChunkSource {
|
|||||||
|
|
||||||
private final String baseUri;
|
private final String baseUri;
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final FormatEvaluator adaptiveFormatEvaluator;
|
private final FormatEvaluator formatEvaluator;
|
||||||
private final Evaluation evaluation;
|
private final Evaluation evaluation;
|
||||||
private final HlsPlaylistParser playlistParser;
|
private final HlsPlaylistParser playlistParser;
|
||||||
private final PtsTimestampAdjusterProvider timestampAdjusterProvider;
|
private final PtsTimestampAdjusterProvider timestampAdjusterProvider;
|
||||||
@ -83,6 +83,7 @@ public class HlsChunkSource {
|
|||||||
private final long[] variantLastPlaylistLoadTimesMs;
|
private final long[] variantLastPlaylistLoadTimesMs;
|
||||||
|
|
||||||
private boolean seenFirstExternalTrackSelection;
|
private boolean seenFirstExternalTrackSelection;
|
||||||
|
private boolean formatEvaluatorEnabled;
|
||||||
private byte[] scratchSpace;
|
private byte[] scratchSpace;
|
||||||
private boolean live;
|
private boolean live;
|
||||||
private long durationUs;
|
private long durationUs;
|
||||||
@ -105,15 +106,14 @@ public class HlsChunkSource {
|
|||||||
* @param timestampAdjusterProvider A provider of {@link PtsTimestampAdjuster} instances. If
|
* @param timestampAdjusterProvider A provider of {@link PtsTimestampAdjuster} instances. If
|
||||||
* multiple {@link HlsChunkSource}s are used for a single playback, they should all share the
|
* multiple {@link HlsChunkSource}s are used for a single playback, they should all share the
|
||||||
* same provider.
|
* same provider.
|
||||||
* @param adaptiveFormatEvaluator For adaptive tracks, selects from the available formats.
|
* @param formatEvaluator For adaptive tracks, selects from the available formats.
|
||||||
*/
|
*/
|
||||||
public HlsChunkSource(String baseUri, Variant[] variants, DataSource dataSource,
|
public HlsChunkSource(String baseUri, Variant[] variants, DataSource dataSource,
|
||||||
PtsTimestampAdjusterProvider timestampAdjusterProvider,
|
PtsTimestampAdjusterProvider timestampAdjusterProvider, FormatEvaluator formatEvaluator) {
|
||||||
FormatEvaluator adaptiveFormatEvaluator) {
|
|
||||||
this.baseUri = baseUri;
|
this.baseUri = baseUri;
|
||||||
this.variants = variants;
|
this.variants = variants;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.adaptiveFormatEvaluator = adaptiveFormatEvaluator;
|
this.formatEvaluator = formatEvaluator;
|
||||||
this.timestampAdjusterProvider = timestampAdjusterProvider;
|
this.timestampAdjusterProvider = timestampAdjusterProvider;
|
||||||
playlistParser = new HlsPlaylistParser();
|
playlistParser = new HlsPlaylistParser();
|
||||||
evaluation = new Evaluation();
|
evaluation = new Evaluation();
|
||||||
@ -126,7 +126,7 @@ public class HlsChunkSource {
|
|||||||
variantFormats[i] = variants[i].format;
|
variantFormats[i] = variants[i].format;
|
||||||
initialTrackSelection[i] = i;
|
initialTrackSelection[i] = i;
|
||||||
}
|
}
|
||||||
trackGroup = new TrackGroup(adaptiveFormatEvaluator != null, variantFormats);
|
trackGroup = new TrackGroup(formatEvaluator != null, variantFormats);
|
||||||
selectTracksInternal(new TrackSelection(trackGroup, initialTrackSelection), false);
|
selectTracksInternal(new TrackSelection(trackGroup, initialTrackSelection), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +443,10 @@ public class HlsChunkSource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void release() {
|
||||||
|
disableFormatEvaluator();
|
||||||
|
}
|
||||||
|
|
||||||
// Private methods.
|
// Private methods.
|
||||||
|
|
||||||
private void selectTracksInternal(TrackSelection trackSelection, boolean isExternal) {
|
private void selectTracksInternal(TrackSelection trackSelection, boolean isExternal) {
|
||||||
@ -457,10 +461,11 @@ public class HlsChunkSource {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disableFormatEvaluator();
|
||||||
if (trackSelection.length > 1) {
|
if (trackSelection.length > 1) {
|
||||||
// TODO[REFACTOR]: We need to disable this at some point.
|
|
||||||
Format[] formats = trackSelection.getFormats();
|
Format[] formats = trackSelection.getFormats();
|
||||||
adaptiveFormatEvaluator.enable(formats);
|
formatEvaluator.enable(formats);
|
||||||
|
formatEvaluatorEnabled = true;
|
||||||
if (!Util.contains(formats, evaluation.format)) {
|
if (!Util.contains(formats, evaluation.format)) {
|
||||||
evaluation.format = null;
|
evaluation.format = null;
|
||||||
}
|
}
|
||||||
@ -500,8 +505,7 @@ public class HlsChunkSource {
|
|||||||
} else {
|
} else {
|
||||||
bufferedDurationUs = 0;
|
bufferedDurationUs = 0;
|
||||||
}
|
}
|
||||||
adaptiveFormatEvaluator.evaluateFormat(bufferedDurationUs, enabledVariantBlacklistFlags,
|
formatEvaluator.evaluateFormat(bufferedDurationUs, enabledVariantBlacklistFlags, evaluation);
|
||||||
evaluation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldRerequestLiveMediaPlaylist(int variantIndex) {
|
private boolean shouldRerequestLiveMediaPlaylist(int variantIndex) {
|
||||||
@ -582,6 +586,13 @@ public class HlsChunkSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void disableFormatEvaluator() {
|
||||||
|
if (formatEvaluatorEnabled) {
|
||||||
|
formatEvaluator.disable();
|
||||||
|
formatEvaluatorEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Private classes.
|
// Private classes.
|
||||||
|
|
||||||
private static final class MediaPlaylistChunk extends DataChunk {
|
private static final class MediaPlaylistChunk extends DataChunk {
|
||||||
|
@ -232,6 +232,7 @@ import java.util.List;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void release() {
|
public void release() {
|
||||||
|
chunkSource.release();
|
||||||
int sampleQueueCount = sampleQueues.size();
|
int sampleQueueCount = sampleQueues.size();
|
||||||
for (int i = 0; i < sampleQueueCount; i++) {
|
for (int i = 0; i < sampleQueueCount; i++) {
|
||||||
sampleQueues.valueAt(i).disable();
|
sampleQueues.valueAt(i).disable();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user