Always inject loadable retry count.

Now [DASH/SS]SampleSource instances are creating ChunkTrackStream
instances dynamically, it makes sense to always require that the
min retry count be injected from that level. The SampleSource
implementations should also use the retry count when refreshing
the manifest.

The option to configure the retry count on the SampleSource classes
will arrive in a later CL.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=122424774
This commit is contained in:
olly 2016-05-16 09:00:53 -07:00 committed by Oliver Woodman
parent 6977c8f455
commit 2e8e8aba9d
3 changed files with 14 additions and 24 deletions

View File

@ -40,11 +40,6 @@ import java.util.List;
*/ */
public class ChunkTrackStream implements TrackStream, Loader.Callback { public class ChunkTrackStream implements TrackStream, Loader.Callback {
/**
* The default minimum number of times to retry loading data prior to failing.
*/
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3;
private final Loader loader; private final Loader loader;
private final ChunkSource chunkSource; private final ChunkSource chunkSource;
private final LinkedList<BaseMediaChunk> mediaChunks; private final LinkedList<BaseMediaChunk> mediaChunks;
@ -67,23 +62,6 @@ public class ChunkTrackStream implements TrackStream, Loader.Callback {
private boolean loadingFinished; private boolean loadingFinished;
private boolean released; private boolean released;
/**
* @param chunkSource A {@link ChunkSource} from which chunks to load are obtained.
* @param loadControl Controls when the source is permitted to load data.
* @param bufferSizeContribution The contribution of this source to the media buffer, in bytes.
* @param positionUs The position from which to start loading media.
* @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
* null if delivery of events is not required.
* @param eventListener A listener of events. May be null if delivery of events is not required.
* @param eventSourceId An identifier that gets passed to {@code eventListener} methods.
*/
public ChunkTrackStream(ChunkSource chunkSource, LoadControl loadControl,
int bufferSizeContribution, long positionUs, Handler eventHandler,
ChunkTrackStreamEventListener eventListener, int eventSourceId) {
this(chunkSource, loadControl, bufferSizeContribution, positionUs, eventHandler, eventListener,
eventSourceId, DEFAULT_MIN_LOADABLE_RETRY_COUNT);
}
/** /**
* @param chunkSource A {@link ChunkSource} from which chunks to load are obtained. * @param chunkSource A {@link ChunkSource} from which chunks to load are obtained.
* @param loadControl Controls when the source is permitted to load data. * @param loadControl Controls when the source is permitted to load data.

View File

@ -60,6 +60,12 @@ public final class DashSampleSource implements SampleSource, UtcTimingCallback {
private static final String TAG = "DashSampleSource"; private static final String TAG = "DashSampleSource";
/**
* The minimum number of times to retry loading data prior to failing.
*/
// TODO: Use this for manifest loads as well.
private static final int MIN_LOADABLE_RETRY_COUNT = 3;
private final ManifestFetcher<MediaPresentationDescription> manifestFetcher; private final ManifestFetcher<MediaPresentationDescription> manifestFetcher;
private final DataSourceFactory dataSourceFactory; private final DataSourceFactory dataSourceFactory;
private final BandwidthMeter bandwidthMeter; private final BandwidthMeter bandwidthMeter;
@ -311,7 +317,7 @@ public final class DashSampleSource implements SampleSource, UtcTimingCallback {
trackGroups.get(selection.group), selectedTracks, dataSource, adaptiveEvaluator, trackGroups.get(selection.group), selectedTracks, dataSource, adaptiveEvaluator,
elapsedRealtimeOffset); elapsedRealtimeOffset);
ChunkTrackStream trackStream = new ChunkTrackStream(chunkSource, loadControl, bufferSize, ChunkTrackStream trackStream = new ChunkTrackStream(chunkSource, loadControl, bufferSize,
positionUs, eventHandler, eventListener, adaptationSetType); positionUs, eventHandler, eventListener, adaptationSetType, MIN_LOADABLE_RETRY_COUNT);
return Pair.create(chunkSource, trackStream); return Pair.create(chunkSource, trackStream);
} }

View File

@ -53,6 +53,12 @@ import java.util.List;
*/ */
public final class SmoothStreamingSampleSource implements SampleSource { public final class SmoothStreamingSampleSource implements SampleSource {
/**
* The minimum number of times to retry loading data prior to failing.
*/
// TODO: Use this for manifest loads as well.
private static final int MIN_LOADABLE_RETRY_COUNT = 3;
private static final int MINIMUM_MANIFEST_REFRESH_PERIOD_MS = 5000; private static final int MINIMUM_MANIFEST_REFRESH_PERIOD_MS = 5000;
private static final int INITIALIZATION_VECTOR_SIZE = 8; private static final int INITIALIZATION_VECTOR_SIZE = 8;
@ -275,7 +281,7 @@ public final class SmoothStreamingSampleSource implements SampleSource {
streamElementIndex, trackGroups.get(selection.group), selectedTracks, dataSource, streamElementIndex, trackGroups.get(selection.group), selectedTracks, dataSource,
adaptiveEvaluator, trackEncryptionBoxes); adaptiveEvaluator, trackEncryptionBoxes);
ChunkTrackStream trackStream = new ChunkTrackStream(chunkSource, loadControl, bufferSize, ChunkTrackStream trackStream = new ChunkTrackStream(chunkSource, loadControl, bufferSize,
positionUs, eventHandler, eventListener, streamElementType); positionUs, eventHandler, eventListener, streamElementType, MIN_LOADABLE_RETRY_COUNT);
return Pair.create(chunkSource, trackStream); return Pair.create(chunkSource, trackStream);
} }