提交 06fd826a 编写于 作者: O olly 提交者: Oliver Woodman

Restore injection of non-default retry count.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=126646585
上级 49a93daf
......@@ -66,15 +66,16 @@ import java.util.TimeZone;
public final class DashSampleSource implements SampleSource,
SequenceableLoader.Callback<ChunkTrackStream<DashChunkSource>> {
private static final String TAG = "DashSampleSource";
/**
* The minimum number of times to retry loading data prior to failing.
* The default minimum number of times to retry loading data prior to failing.
*/
private static final int MIN_LOADABLE_RETRY_COUNT = 3;
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3;
private static final String TAG = "DashSampleSource";
private final DataSourceFactory dataSourceFactory;
private final BandwidthMeter bandwidthMeter;
private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher;
private final Loader loader;
private final DataSource dataSource;
......@@ -101,9 +102,17 @@ public final class DashSampleSource implements SampleSource,
public DashSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
eventHandler, eventListener);
}
public DashSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
this.manifestUri = manifestUri;
this.dataSourceFactory = dataSourceFactory;
this.bandwidthMeter = bandwidthMeter;
this.minLoadableRetryCount = minLoadableRetryCount;
eventDispatcher = new EventDispatcher(eventHandler, eventListener);
dataSource = dataSourceFactory.createDataSource();
loader = new Loader("Loader:DashSampleSource");
......@@ -282,7 +291,7 @@ public final class DashSampleSource implements SampleSource,
private void startLoadingManifest() {
startLoading(new ParsingLoadable<>(dataSource, manifestUri, C.DATA_TYPE_MANIFEST,
manifestParser), manifestCallback, MIN_LOADABLE_RETRY_COUNT);
manifestParser), manifestCallback, minLoadableRetryCount);
}
private void resolveUtcTimingElement(UtcTimingElement timingElement) {
......@@ -402,7 +411,7 @@ public final class DashSampleSource implements SampleSource,
trackGroups.get(selection.group), selectedTracks, dataSource, adaptiveEvaluator,
elapsedRealtimeOffset);
return new ChunkTrackStream<>(adaptationSetType, chunkSource, this, allocator, positionUs,
MIN_LOADABLE_RETRY_COUNT, eventDispatcher);
minLoadableRetryCount, eventDispatcher);
}
@SuppressWarnings("unchecked")
......
......@@ -57,13 +57,14 @@ public final class HlsSampleSource implements SampleSource,
Loader.Callback<ParsingLoadable<HlsPlaylist>>, HlsTrackStreamWrapper.Callback {
/**
* The minimum number of times to retry loading data prior to failing.
* The default minimum number of times to retry loading data prior to failing.
*/
private static final int MIN_LOADABLE_RETRY_COUNT = 3;
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3;
private final Uri manifestUri;
private final DataSourceFactory dataSourceFactory;
private final BandwidthMeter bandwidthMeter;
private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher;
private final IdentityHashMap<TrackStream, HlsTrackStreamWrapper> trackStreamSources;
private final PtsTimestampAdjusterProvider timestampAdjusterProvider;
......@@ -88,9 +89,17 @@ public final class HlsSampleSource implements SampleSource,
public HlsSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
eventHandler, eventListener);
}
public HlsSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
this.manifestUri = manifestUri;
this.dataSourceFactory = dataSourceFactory;
this.bandwidthMeter = bandwidthMeter;
this.minLoadableRetryCount = minLoadableRetryCount;
eventDispatcher = new EventDispatcher(eventHandler, eventListener);
timestampAdjusterProvider = new PtsTimestampAdjusterProvider();
......@@ -109,7 +118,7 @@ public final class HlsSampleSource implements SampleSource,
ParsingLoadable<HlsPlaylist> loadable = new ParsingLoadable<>(manifestDataSource,
manifestUri, C.DATA_TYPE_MANIFEST, manifestParser);
long elapsedRealtimeMs = manifestFetcher.startLoading(loadable, this,
MIN_LOADABLE_RETRY_COUNT);
minLoadableRetryCount);
eventDispatcher.loadStarted(loadable.dataSpec, loadable.type, elapsedRealtimeMs);
}
......@@ -355,7 +364,7 @@ public final class HlsSampleSource implements SampleSource,
HlsChunkSource defaultChunkSource = new HlsChunkSource(baseUri, variants, dataSource,
timestampAdjusterProvider, formatEvaluator);
return new HlsTrackStreamWrapper(trackType, this, defaultChunkSource, allocator,
preparePositionUs, muxedAudioFormat, muxedCaptionFormat, MIN_LOADABLE_RETRY_COUNT,
preparePositionUs, muxedAudioFormat, muxedCaptionFormat, minLoadableRetryCount,
eventDispatcher);
}
......
......@@ -58,9 +58,9 @@ public final class SmoothStreamingSampleSource implements SampleSource,
Loader.Callback<ParsingLoadable<SmoothStreamingManifest>> {
/**
* The minimum number of times to retry loading data prior to failing.
* The default minimum number of times to retry loading data prior to failing.
*/
private static final int MIN_LOADABLE_RETRY_COUNT = 3;
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3;
private static final int MINIMUM_MANIFEST_REFRESH_PERIOD_MS = 5000;
private static final int INITIALIZATION_VECTOR_SIZE = 8;
......@@ -68,6 +68,7 @@ public final class SmoothStreamingSampleSource implements SampleSource,
private final Uri manifestUri;
private final DataSourceFactory dataSourceFactory;
private final BandwidthMeter bandwidthMeter;
private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher;
private final Loader manifestLoader;
private final DataSource manifestDataSource;
......@@ -91,10 +92,18 @@ public final class SmoothStreamingSampleSource implements SampleSource,
public SmoothStreamingSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
eventHandler, eventListener);
}
public SmoothStreamingSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
this.manifestUri = Util.toLowerInvariant(manifestUri.getLastPathSegment()).equals("manifest")
? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest");
this.dataSourceFactory = dataSourceFactory;
this.bandwidthMeter = bandwidthMeter;
this.minLoadableRetryCount = minLoadableRetryCount;
this.eventDispatcher = new EventDispatcher(eventHandler, eventListener);
trackStreams = newTrackStreamArray(0);
sequenceableLoader = new CompositeSequenceableLoader(trackStreams);
......@@ -274,7 +283,7 @@ public final class SmoothStreamingSampleSource implements SampleSource,
private void startLoadingManifest() {
ParsingLoadable<SmoothStreamingManifest> loadable = new ParsingLoadable<>(manifestDataSource,
manifestUri, C.DATA_TYPE_MANIFEST, manifestParser);
long elapsedRealtimeMs = manifestLoader.startLoading(loadable, this, MIN_LOADABLE_RETRY_COUNT);
long elapsedRealtimeMs = manifestLoader.startLoading(loadable, this, minLoadableRetryCount);
eventDispatcher.loadStarted(loadable.dataSpec, loadable.type, elapsedRealtimeMs);
}
......@@ -313,7 +322,7 @@ public final class SmoothStreamingSampleSource implements SampleSource,
manifest, streamElementIndex, trackGroups.get(selection.group), selectedTracks, dataSource,
adaptiveEvaluator, trackEncryptionBoxes);
return new ChunkTrackStream<>(streamElementType, chunkSource, this, allocator, positionUs,
MIN_LOADABLE_RETRY_COUNT, eventDispatcher);
minLoadableRetryCount, eventDispatcher);
}
@SuppressWarnings("unchecked")
......
......@@ -63,7 +63,7 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
private static final int AUDIO_RENDERER_INDEX = 1;
private static final long TEST_TIMEOUT_MS = 5 * 60 * 1000;
private static final int MIN_LOADABLE_RETRY_COUNT = 10; // TODO[REFACTOR]: Use this again.
private static final int MIN_LOADABLE_RETRY_COUNT = 10;
private static final int MAX_CONSECUTIVE_DROPPED_VIDEO_FRAMES = 10;
private static final float MAX_DROPPED_VIDEO_FRAME_FRACTION = 0.01f;
......@@ -420,7 +420,8 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
@Override
public SampleSource buildSource(HostActivity host, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter) {
return new DashSampleSource(manifestUri, dataSourceFactory, bandwidthMeter, null, null);
return new DashSampleSource(manifestUri, dataSourceFactory, bandwidthMeter,
MIN_LOADABLE_RETRY_COUNT, null, null);
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册