use of com.google.android.exoplayer2.offline.StreamKey in project ExoPlayer by google.
the class MediaItemTest method builderSetStreamKeys_setsStreamKeys.
@Test
public void builderSetStreamKeys_setsStreamKeys() {
List<StreamKey> streamKeys = new ArrayList<>();
streamKeys.add(new StreamKey(1, 0, 0));
streamKeys.add(new StreamKey(0, 1, 1));
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_STRING).setStreamKeys(streamKeys).build();
assertThat(mediaItem.localConfiguration.streamKeys).isEqualTo(streamKeys);
}
use of com.google.android.exoplayer2.offline.StreamKey in project ExoPlayer by google.
the class SsMediaPeriod method getStreamKeys.
@Override
public List<StreamKey> getStreamKeys(List<ExoTrackSelection> trackSelections) {
List<StreamKey> streamKeys = new ArrayList<>();
for (int selectionIndex = 0; selectionIndex < trackSelections.size(); selectionIndex++) {
ExoTrackSelection trackSelection = trackSelections.get(selectionIndex);
int streamElementIndex = trackGroups.indexOf(trackSelection.getTrackGroup());
for (int i = 0; i < trackSelection.length(); i++) {
streamKeys.add(new StreamKey(streamElementIndex, trackSelection.getIndexInTrackGroup(i)));
}
}
return streamKeys;
}
use of com.google.android.exoplayer2.offline.StreamKey in project ExoPlayer by google.
the class DashDownloadTest method downloadContent.
private DashDownloader downloadContent() throws Exception {
DashManifest dashManifest = DashUtil.loadManifest(httpDataSourceFactory.createDataSource(), MANIFEST_URI);
ArrayList<StreamKey> keys = new ArrayList<>();
for (int pIndex = 0; pIndex < dashManifest.getPeriodCount(); pIndex++) {
List<AdaptationSet> adaptationSets = dashManifest.getPeriod(pIndex).adaptationSets;
for (int aIndex = 0; aIndex < adaptationSets.size(); aIndex++) {
AdaptationSet adaptationSet = adaptationSets.get(aIndex);
List<Representation> representations = adaptationSet.representations;
for (int rIndex = 0; rIndex < representations.size(); rIndex++) {
String id = representations.get(rIndex).format.id;
if (DashTestData.AAC_AUDIO_REPRESENTATION_ID.equals(id) || DashTestData.H264_CDD_FIXED.equals(id)) {
keys.add(new StreamKey(pIndex, aIndex, rIndex));
}
}
}
}
CacheDataSource.Factory cacheDataSourceFactory = new CacheDataSource.Factory().setCache(cache).setUpstreamDataSourceFactory(httpDataSourceFactory);
return new DashDownloader(new MediaItem.Builder().setUri(MANIFEST_URI).setStreamKeys(keys).build(), cacheDataSourceFactory);
}
use of com.google.android.exoplayer2.offline.StreamKey in project ExoPlayer by google.
the class SsManifestTest method copy.
@Test
public void copy() throws Exception {
Format[][] formats = newFormats(2, 3);
SsManifest sourceManifest = createSsManifest(createStreamElement("1", formats[0]), createStreamElement("2", formats[1]));
List<StreamKey> keys = Arrays.asList(new StreamKey(0, 0), new StreamKey(0, 2), new StreamKey(1, 0));
// Keys don't need to be in any particular order
Collections.shuffle(keys, new Random(0));
SsManifest copyManifest = sourceManifest.copy(keys);
SsManifest expectedManifest = createSsManifest(createStreamElement("1", formats[0][0], formats[0][2]), createStreamElement("2", formats[1][0]));
assertManifestEquals(expectedManifest, copyManifest);
}
use of com.google.android.exoplayer2.offline.StreamKey in project ExoPlayer by google.
the class DownloadServiceDashTest method downloadKeys.
private void downloadKeys(StreamKey... keys) {
ArrayList<StreamKey> keysList = new ArrayList<>();
Collections.addAll(keysList, keys);
DownloadRequest action = new DownloadRequest.Builder(TEST_ID, TEST_MPD_URI).setMimeType(MimeTypes.APPLICATION_MPD).setStreamKeys(keysList).build();
testThread.runOnMainThread(() -> {
Intent startIntent = DownloadService.buildAddDownloadIntent(context, DownloadService.class, action, /* foreground= */
false);
dashDownloadService.onStartCommand(startIntent, 0, 0);
});
}
Aggregations