Do TODO in HlsChunkSource

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128190311
This commit is contained in:
olly 2016-07-22 11:00:22 -07:00 committed by Oliver Woodman
parent 9e9634a1a2
commit abcd10513a
2 changed files with 22 additions and 10 deletions

View File

@ -73,7 +73,7 @@ public class HlsChunkSource {
private final String baseUri;
private final DataSource dataSource;
private final FormatEvaluator adaptiveFormatEvaluator;
private final FormatEvaluator formatEvaluator;
private final Evaluation evaluation;
private final HlsPlaylistParser playlistParser;
private final PtsTimestampAdjusterProvider timestampAdjusterProvider;
@ -83,6 +83,7 @@ public class HlsChunkSource {
private final long[] variantLastPlaylistLoadTimesMs;
private boolean seenFirstExternalTrackSelection;
private boolean formatEvaluatorEnabled;
private byte[] scratchSpace;
private boolean live;
private long durationUs;
@ -105,15 +106,14 @@ public class HlsChunkSource {
* @param timestampAdjusterProvider A provider of {@link PtsTimestampAdjuster} instances. If
* multiple {@link HlsChunkSource}s are used for a single playback, they should all share the
* 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,
PtsTimestampAdjusterProvider timestampAdjusterProvider,
FormatEvaluator adaptiveFormatEvaluator) {
PtsTimestampAdjusterProvider timestampAdjusterProvider, FormatEvaluator formatEvaluator) {
this.baseUri = baseUri;
this.variants = variants;
this.dataSource = dataSource;
this.adaptiveFormatEvaluator = adaptiveFormatEvaluator;
this.formatEvaluator = formatEvaluator;
this.timestampAdjusterProvider = timestampAdjusterProvider;
playlistParser = new HlsPlaylistParser();
evaluation = new Evaluation();
@ -126,7 +126,7 @@ public class HlsChunkSource {
variantFormats[i] = variants[i].format;
initialTrackSelection[i] = i;
}
trackGroup = new TrackGroup(adaptiveFormatEvaluator != null, variantFormats);
trackGroup = new TrackGroup(formatEvaluator != null, variantFormats);
selectTracksInternal(new TrackSelection(trackGroup, initialTrackSelection), false);
}
@ -443,6 +443,10 @@ public class HlsChunkSource {
return false;
}
public void release() {
disableFormatEvaluator();
}
// Private methods.
private void selectTracksInternal(TrackSelection trackSelection, boolean isExternal) {
@ -457,10 +461,11 @@ public class HlsChunkSource {
return;
}
disableFormatEvaluator();
if (trackSelection.length > 1) {
// TODO[REFACTOR]: We need to disable this at some point.
Format[] formats = trackSelection.getFormats();
adaptiveFormatEvaluator.enable(formats);
formatEvaluator.enable(formats);
formatEvaluatorEnabled = true;
if (!Util.contains(formats, evaluation.format)) {
evaluation.format = null;
}
@ -500,8 +505,7 @@ public class HlsChunkSource {
} else {
bufferedDurationUs = 0;
}
adaptiveFormatEvaluator.evaluateFormat(bufferedDurationUs, enabledVariantBlacklistFlags,
evaluation);
formatEvaluator.evaluateFormat(bufferedDurationUs, enabledVariantBlacklistFlags, evaluation);
}
private boolean shouldRerequestLiveMediaPlaylist(int variantIndex) {
@ -582,6 +586,13 @@ public class HlsChunkSource {
}
}
private void disableFormatEvaluator() {
if (formatEvaluatorEnabled) {
formatEvaluator.disable();
formatEvaluatorEnabled = false;
}
}
// Private classes.
private static final class MediaPlaylistChunk extends DataChunk {

View File

@ -232,6 +232,7 @@ import java.util.List;
}
public void release() {
chunkSource.release();
int sampleQueueCount = sampleQueues.size();
for (int i = 0; i < sampleQueueCount; i++) {
sampleQueues.valueAt(i).disable();