Commit 74b43e26 by olly Committed by Oliver Woodman

Allow injection of custom ChunkSources

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=127737169
parent 5360ddc5
...@@ -40,7 +40,9 @@ import com.google.android.exoplayer2.source.TrackGroupArray; ...@@ -40,7 +40,9 @@ import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.source.chunk.FormatEvaluator; import com.google.android.exoplayer2.source.chunk.FormatEvaluator;
import com.google.android.exoplayer2.source.chunk.FormatEvaluator.AdaptiveEvaluator; import com.google.android.exoplayer2.source.chunk.FormatEvaluator.AdaptiveEvaluator;
import com.google.android.exoplayer2.source.dash.DashMediaSource; import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource; import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.source.smoothstreaming.DefaultSmoothStreamingChunkSource;
import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingMediaSource; import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingMediaSource;
import com.google.android.exoplayer2.text.CaptionStyleCompat; import com.google.android.exoplayer2.text.CaptionStyleCompat;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
...@@ -131,7 +133,8 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, ...@@ -131,7 +133,8 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
private SubtitleLayout subtitleLayout; private SubtitleLayout subtitleLayout;
private Button retryButton; private Button retryButton;
private DataSource.Factory dataSourceFactory; private DataSource.Factory manifestDataSourceFactory;
private DataSource.Factory mediaDataSourceFactory;
private FormatEvaluator.Factory formatEvaluatorFactory; private FormatEvaluator.Factory formatEvaluatorFactory;
private SimpleExoPlayer player; private SimpleExoPlayer player;
private MappingTrackSelector trackSelector; private MappingTrackSelector trackSelector;
...@@ -148,8 +151,9 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, ...@@ -148,8 +151,9 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
String userAgent = Util.getUserAgent(this, "ExoPlayerDemo"); String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
manifestDataSourceFactory = new DefaultDataSourceFactory(this, userAgent);
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
dataSourceFactory = new DefaultDataSourceFactory(this, userAgent, bandwidthMeter); mediaDataSourceFactory = new DefaultDataSourceFactory(this, userAgent, bandwidthMeter);
formatEvaluatorFactory = new AdaptiveEvaluator.Factory(bandwidthMeter); formatEvaluatorFactory = new AdaptiveEvaluator.Factory(bandwidthMeter);
mainHandler = new Handler(); mainHandler = new Handler();
...@@ -343,16 +347,21 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, ...@@ -343,16 +347,21 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
int type = Util.inferContentType(lastPathSegment); int type = Util.inferContentType(lastPathSegment);
switch (type) { switch (type) {
case Util.TYPE_SS: case Util.TYPE_SS:
return new SmoothStreamingMediaSource(uri, dataSourceFactory, formatEvaluatorFactory, DefaultSmoothStreamingChunkSource.Factory factory =
mainHandler, eventLogger); new DefaultSmoothStreamingChunkSource.Factory(mediaDataSourceFactory,
formatEvaluatorFactory);
return new SmoothStreamingMediaSource(uri, manifestDataSourceFactory, factory, mainHandler,
eventLogger);
case Util.TYPE_DASH: case Util.TYPE_DASH:
return new DashMediaSource(uri, dataSourceFactory, formatEvaluatorFactory, mainHandler, DefaultDashChunkSource.Factory factory2 = new DefaultDashChunkSource.Factory(
mediaDataSourceFactory, formatEvaluatorFactory);
return new DashMediaSource(uri, mediaDataSourceFactory, factory2, mainHandler,
eventLogger); eventLogger);
case Util.TYPE_HLS: case Util.TYPE_HLS:
return new HlsMediaSource(uri, dataSourceFactory, formatEvaluatorFactory, mainHandler, return new HlsMediaSource(uri, mediaDataSourceFactory, formatEvaluatorFactory, mainHandler,
eventLogger); eventLogger);
case Util.TYPE_OTHER: case Util.TYPE_OTHER:
return new ExtractorMediaSource(uri, dataSourceFactory, new DefaultExtractorsFactory(), return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
mainHandler, eventLogger); mainHandler, eventLogger);
default: default:
throw new IllegalStateException("Unsupported type: " + type); throw new IllegalStateException("Unsupported type: " + type);
......
...@@ -22,7 +22,7 @@ import com.google.android.exoplayer2.util.MimeTypes; ...@@ -22,7 +22,7 @@ import com.google.android.exoplayer2.util.MimeTypes;
import android.test.InstrumentationTestCase; import android.test.InstrumentationTestCase;
/** /**
* Tests {@link DashChunkSource}. * Tests {@link DefaultDashChunkSource}.
*/ */
public class DashChunkSourceTest extends InstrumentationTestCase { public class DashChunkSourceTest extends InstrumentationTestCase {
......
...@@ -25,14 +25,12 @@ import com.google.android.exoplayer2.source.SequenceableLoader; ...@@ -25,14 +25,12 @@ import com.google.android.exoplayer2.source.SequenceableLoader;
import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.source.chunk.ChunkSampleStream; import com.google.android.exoplayer2.source.chunk.ChunkSampleStream;
import com.google.android.exoplayer2.source.chunk.FormatEvaluator;
import com.google.android.exoplayer2.source.dash.mpd.AdaptationSet; import com.google.android.exoplayer2.source.dash.mpd.AdaptationSet;
import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescription; import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescription;
import com.google.android.exoplayer2.source.dash.mpd.Period; import com.google.android.exoplayer2.source.dash.mpd.Period;
import com.google.android.exoplayer2.source.dash.mpd.Representation; import com.google.android.exoplayer2.source.dash.mpd.Representation;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.Loader; import com.google.android.exoplayer2.upstream.Loader;
import android.util.Pair; import android.util.Pair;
...@@ -47,8 +45,7 @@ import java.util.List; ...@@ -47,8 +45,7 @@ import java.util.List;
/* package */ final class DashMediaPeriod implements MediaPeriod, /* package */ final class DashMediaPeriod implements MediaPeriod,
SequenceableLoader.Callback<ChunkSampleStream<DashChunkSource>> { SequenceableLoader.Callback<ChunkSampleStream<DashChunkSource>> {
private final DataSource.Factory dataSourceFactory; private final DashChunkSource.Factory chunkSourceFactory;
private final FormatEvaluator.Factory formatEvaluatorFactory;
private final int minLoadableRetryCount; private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final long elapsedRealtimeOffset; private final long elapsedRealtimeOffset;
...@@ -66,13 +63,11 @@ import java.util.List; ...@@ -66,13 +63,11 @@ import java.util.List;
private Period period; private Period period;
public DashMediaPeriod(MediaPresentationDescription manifest, int index, public DashMediaPeriod(MediaPresentationDescription manifest, int index,
DataSource.Factory dataSourceFactory, FormatEvaluator.Factory formatEvaluatorFactory, DashChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
int minLoadableRetryCount, EventDispatcher eventDispatcher, long elapsedRealtimeOffset, EventDispatcher eventDispatcher, long elapsedRealtimeOffset, Loader loader) {
Loader loader) {
this.manifest = manifest; this.manifest = manifest;
this.index = index; this.index = index;
this.dataSourceFactory = dataSourceFactory; this.chunkSourceFactory = chunkSourceFactory;
this.formatEvaluatorFactory = formatEvaluatorFactory;
this.minLoadableRetryCount = minLoadableRetryCount; this.minLoadableRetryCount = minLoadableRetryCount;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.elapsedRealtimeOffset = elapsedRealtimeOffset; this.elapsedRealtimeOffset = elapsedRealtimeOffset;
...@@ -242,16 +237,12 @@ import java.util.List; ...@@ -242,16 +237,12 @@ import java.util.List;
private ChunkSampleStream<DashChunkSource> buildSampleStream(TrackSelection selection, private ChunkSampleStream<DashChunkSource> buildSampleStream(TrackSelection selection,
long positionUs) { long positionUs) {
int[] selectedTracks = selection.getTracks(); int[] selectedTracks = selection.getTracks();
FormatEvaluator adaptiveEvaluator = selectedTracks.length > 1
? formatEvaluatorFactory.createFormatEvaluator() : null;
int adaptationSetIndex = trackGroupAdaptationSetIndices[selection.group]; int adaptationSetIndex = trackGroupAdaptationSetIndices[selection.group];
AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex); AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex);
int adaptationSetType = adaptationSet.type; DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource(loader, manifest, index,
DataSource dataSource = dataSourceFactory.createDataSource(); adaptationSetIndex, trackGroups.get(selection.group), selectedTracks,
DashChunkSource chunkSource = new DashChunkSource(loader, manifest, index, adaptationSetIndex,
trackGroups.get(selection.group), selectedTracks, dataSource, adaptiveEvaluator,
elapsedRealtimeOffset); elapsedRealtimeOffset);
return new ChunkSampleStream<>(adaptationSetType, chunkSource, this, allocator, positionUs, return new ChunkSampleStream<>(adaptationSet.type, chunkSource, this, allocator, positionUs,
minLoadableRetryCount, eventDispatcher); minLoadableRetryCount, eventDispatcher);
} }
......
...@@ -21,7 +21,6 @@ import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener; ...@@ -21,7 +21,6 @@ import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener;
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher; import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.source.MediaPeriod; import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.chunk.FormatEvaluator;
import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescription; import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescription;
import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescriptionParser; import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescriptionParser;
import com.google.android.exoplayer2.source.dash.mpd.UtcTimingElement; import com.google.android.exoplayer2.source.dash.mpd.UtcTimingElement;
...@@ -56,8 +55,8 @@ public final class DashMediaSource implements MediaSource { ...@@ -56,8 +55,8 @@ public final class DashMediaSource implements MediaSource {
private static final String TAG = "DashMediaSource"; private static final String TAG = "DashMediaSource";
private final DataSource.Factory dataSourceFactory; private final DataSource.Factory manifestDataSourceFactory;
private final FormatEvaluator.Factory formatEvaluatorFactory; private final DashChunkSource.Factory chunkSourceFactory;
private final int minLoadableRetryCount; private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final MediaPresentationDescriptionParser manifestParser; private final MediaPresentationDescriptionParser manifestParser;
...@@ -74,19 +73,19 @@ public final class DashMediaSource implements MediaSource { ...@@ -74,19 +73,19 @@ public final class DashMediaSource implements MediaSource {
private DashMediaPeriod[] periods; private DashMediaPeriod[] periods;
private long elapsedRealtimeOffset; private long elapsedRealtimeOffset;
public DashMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory, public DashMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
FormatEvaluator.Factory formatEvaluatorFactory, Handler eventHandler, DashChunkSource.Factory chunkSourceFactory, Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener) { AdaptiveMediaSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, formatEvaluatorFactory, DEFAULT_MIN_LOADABLE_RETRY_COUNT, this(manifestUri, manifestDataSourceFactory, chunkSourceFactory,
eventHandler, eventListener); DEFAULT_MIN_LOADABLE_RETRY_COUNT, eventHandler, eventListener);
} }
public DashMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory, public DashMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
FormatEvaluator.Factory formatEvaluatorFactory, int minLoadableRetryCount, DashChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) { Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) {
this.manifestUri = manifestUri; this.manifestUri = manifestUri;
this.dataSourceFactory = dataSourceFactory; this.manifestDataSourceFactory = manifestDataSourceFactory;
this.formatEvaluatorFactory = formatEvaluatorFactory; this.chunkSourceFactory = chunkSourceFactory;
this.minLoadableRetryCount = minLoadableRetryCount; this.minLoadableRetryCount = minLoadableRetryCount;
eventDispatcher = new EventDispatcher(eventHandler, eventListener); eventDispatcher = new EventDispatcher(eventHandler, eventListener);
manifestParser = new MediaPresentationDescriptionParser(); manifestParser = new MediaPresentationDescriptionParser();
...@@ -97,7 +96,7 @@ public final class DashMediaSource implements MediaSource { ...@@ -97,7 +96,7 @@ public final class DashMediaSource implements MediaSource {
@Override @Override
public void prepareSource() { public void prepareSource() {
dataSource = dataSourceFactory.createDataSource(); dataSource = manifestDataSourceFactory.createDataSource();
loader = new Loader("Loader:DashMediaSource"); loader = new Loader("Loader:DashMediaSource");
manifestRefreshHandler = new Handler(); manifestRefreshHandler = new Handler();
startLoadingManifest(); startLoadingManifest();
...@@ -244,8 +243,8 @@ public final class DashMediaSource implements MediaSource { ...@@ -244,8 +243,8 @@ public final class DashMediaSource implements MediaSource {
int periodCount = manifest.getPeriodCount(); int periodCount = manifest.getPeriodCount();
periods = new DashMediaPeriod[periodCount]; periods = new DashMediaPeriod[periodCount];
for (int i = 0; i < periodCount; i++) { for (int i = 0; i < periodCount; i++) {
periods[i] = new DashMediaPeriod(manifest, i, dataSourceFactory, formatEvaluatorFactory, periods[i] = new DashMediaPeriod(manifest, i, chunkSourceFactory, minLoadableRetryCount,
minLoadableRetryCount, eventDispatcher, elapsedRealtimeOffset, loader); eventDispatcher, elapsedRealtimeOffset, loader);
} }
scheduleManifestRefresh(); scheduleManifestRefresh();
} }
......
...@@ -29,7 +29,6 @@ import com.google.android.exoplayer2.source.SequenceableLoader; ...@@ -29,7 +29,6 @@ import com.google.android.exoplayer2.source.SequenceableLoader;
import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.source.chunk.ChunkSampleStream; import com.google.android.exoplayer2.source.chunk.ChunkSampleStream;
import com.google.android.exoplayer2.source.chunk.FormatEvaluator;
import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingManifest.ProtectionElement; import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingManifest.ProtectionElement;
import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingManifest.StreamElement; import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingManifest.StreamElement;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
...@@ -66,7 +65,7 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc ...@@ -66,7 +65,7 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc
private final Uri manifestUri; private final Uri manifestUri;
private final DataSource.Factory dataSourceFactory; private final DataSource.Factory dataSourceFactory;
private final FormatEvaluator.Factory formatEvaluatorFactory; private final SmoothStreamingChunkSource.Factory chunkSourceFactory;
private final int minLoadableRetryCount; private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final SmoothStreamingManifestParser manifestParser; private final SmoothStreamingManifestParser manifestParser;
...@@ -88,20 +87,20 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc ...@@ -88,20 +87,20 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc
private TrackGroupArray trackGroups; private TrackGroupArray trackGroups;
private int[] trackGroupElementIndices; private int[] trackGroupElementIndices;
public SmoothStreamingMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory, public SmoothStreamingMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
FormatEvaluator.Factory formatEvaluatorFactory, Handler eventHandler, SmoothStreamingChunkSource.Factory chunkSourceFactory, Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener) { AdaptiveMediaSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, formatEvaluatorFactory, DEFAULT_MIN_LOADABLE_RETRY_COUNT, this(manifestUri, manifestDataSourceFactory, chunkSourceFactory,
eventHandler, eventListener); DEFAULT_MIN_LOADABLE_RETRY_COUNT, eventHandler, eventListener);
} }
public SmoothStreamingMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory, public SmoothStreamingMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory,
FormatEvaluator.Factory formatEvaluatorFactory, int minLoadableRetryCount, SmoothStreamingChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) { Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) {
this.manifestUri = Util.toLowerInvariant(manifestUri.getLastPathSegment()).equals("manifest") this.manifestUri = Util.toLowerInvariant(manifestUri.getLastPathSegment()).equals("manifest")
? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest"); ? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest");
this.dataSourceFactory = dataSourceFactory; this.dataSourceFactory = dataSourceFactory;
this.formatEvaluatorFactory = formatEvaluatorFactory; this.chunkSourceFactory = chunkSourceFactory;
this.minLoadableRetryCount = minLoadableRetryCount; this.minLoadableRetryCount = minLoadableRetryCount;
this.eventDispatcher = new EventDispatcher(eventHandler, eventListener); this.eventDispatcher = new EventDispatcher(eventHandler, eventListener);
manifestParser = new SmoothStreamingManifestParser(); manifestParser = new SmoothStreamingManifestParser();
...@@ -354,17 +353,12 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc ...@@ -354,17 +353,12 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc
private ChunkSampleStream<SmoothStreamingChunkSource> buildSampleStream(TrackSelection selection, private ChunkSampleStream<SmoothStreamingChunkSource> buildSampleStream(TrackSelection selection,
long positionUs) { long positionUs) {
int[] selectedTracks = selection.getTracks(); int[] selectedTracks = selection.getTracks();
FormatEvaluator adaptiveEvaluator = selectedTracks.length > 1
? formatEvaluatorFactory.createFormatEvaluator() : null;
int streamElementIndex = trackGroupElementIndices[selection.group]; int streamElementIndex = trackGroupElementIndices[selection.group];
StreamElement streamElement = manifest.streamElements[streamElementIndex]; SmoothStreamingChunkSource chunkSource = chunkSourceFactory.createChunkSource(manifestLoader,
int streamElementType = streamElement.type; manifest, streamElementIndex, trackGroups.get(selection.group), selectedTracks,
DataSource dataSource = dataSourceFactory.createDataSource(); trackEncryptionBoxes);
SmoothStreamingChunkSource chunkSource = new SmoothStreamingChunkSource(manifestLoader, return new ChunkSampleStream<>(manifest.streamElements[streamElementIndex].type, chunkSource,
manifest, streamElementIndex, trackGroups.get(selection.group), selectedTracks, dataSource, this, allocator, positionUs, minLoadableRetryCount, eventDispatcher);
adaptiveEvaluator, trackEncryptionBoxes);
return new ChunkSampleStream<>(streamElementType, chunkSource, this, allocator, positionUs,
minLoadableRetryCount, eventDispatcher);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
......
...@@ -34,6 +34,7 @@ import com.google.android.exoplayer2.source.TrackGroupArray; ...@@ -34,6 +34,7 @@ import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.source.chunk.FormatEvaluator; import com.google.android.exoplayer2.source.chunk.FormatEvaluator;
import com.google.android.exoplayer2.source.chunk.FormatEvaluator.AdaptiveEvaluator; import com.google.android.exoplayer2.source.chunk.FormatEvaluator.AdaptiveEvaluator;
import com.google.android.exoplayer2.source.dash.DashMediaSource; import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.BandwidthMeter; import com.google.android.exoplayer2.upstream.BandwidthMeter;
...@@ -423,12 +424,15 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit ...@@ -423,12 +424,15 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
@Override @Override
public MediaSource buildSource(HostActivity host, String userAgent) { public MediaSource buildSource(HostActivity host, String userAgent) {
DataSource.Factory manifestDataSourceFactory = new DefaultDataSourceFactory(host, userAgent);
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(host, userAgent, DataSource.Factory mediaDataSourceFactory = new DefaultDataSourceFactory(host, userAgent,
bandwidthMeter); bandwidthMeter);
FormatEvaluator.Factory formatEvaluatorFactory = new AdaptiveEvaluator.Factory( FormatEvaluator.Factory formatEvaluatorFactory = new AdaptiveEvaluator.Factory(
bandwidthMeter); bandwidthMeter);
return new DashMediaSource(manifestUri, dataSourceFactory, formatEvaluatorFactory, DefaultDashChunkSource.Factory chunkSourceFactory = new DefaultDashChunkSource.Factory(
mediaDataSourceFactory, formatEvaluatorFactory);
return new DashMediaSource(manifestUri, manifestDataSourceFactory, chunkSourceFactory,
MIN_LOADABLE_RETRY_COUNT, null, null); MIN_LOADABLE_RETRY_COUNT, null, null);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment