Commit 8a566fb3 by tonihei Committed by Oliver Woodman

Converge DownloadHelper implementations.

Moving most of the logic to the base DownloaderHelper helps to implement track
selection for downloading in a single place instead of multiple places.

PiperOrigin-RevId: 223964869
parent 8de149eb
...@@ -15,15 +15,21 @@ ...@@ -15,15 +15,21 @@
*/ */
package com.google.android.exoplayer2.offline; package com.google.android.exoplayer2.offline;
import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
/** A helper for initializing and removing downloads. */ /**
public abstract class DownloadHelper { * A helper for initializing and removing downloads.
*
* @param <T> The manifest type.
*/
public abstract class DownloadHelper<T> {
/** A callback to be notified when the {@link DownloadHelper} is prepared. */ /** A callback to be notified when the {@link DownloadHelper} is prepared. */
public interface Callback { public interface Callback {
...@@ -44,6 +50,26 @@ public abstract class DownloadHelper { ...@@ -44,6 +50,26 @@ public abstract class DownloadHelper {
void onPrepareError(DownloadHelper helper, IOException e); void onPrepareError(DownloadHelper helper, IOException e);
} }
private final String downloadType;
private final Uri uri;
@Nullable private final String cacheKey;
@Nullable private T manifest;
@Nullable private TrackGroupArray[] trackGroupArrays;
/**
* Create download helper.
*
* @param downloadType A download type. This value will be used as {@link DownloadAction#type}.
* @param uri A {@link Uri}.
* @param cacheKey An optional cache key.
*/
public DownloadHelper(String downloadType, Uri uri, @Nullable String cacheKey) {
this.downloadType = downloadType;
this.uri = uri;
this.cacheKey = cacheKey;
}
/** /**
* Initializes the helper for starting a download. * Initializes the helper for starting a download.
* *
...@@ -51,14 +77,15 @@ public abstract class DownloadHelper { ...@@ -51,14 +77,15 @@ public abstract class DownloadHelper {
* will be invoked on the calling thread unless that thread does not have an associated {@link * will be invoked on the calling thread unless that thread does not have an associated {@link
* Looper}, in which case it will be called on the application's main thread. * Looper}, in which case it will be called on the application's main thread.
*/ */
public void prepare(final Callback callback) { public final void prepare(final Callback callback) {
final Handler handler = final Handler handler =
new Handler(Looper.myLooper() != null ? Looper.myLooper() : Looper.getMainLooper()); new Handler(Looper.myLooper() != null ? Looper.myLooper() : Looper.getMainLooper());
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
try { try {
prepareInternal(); manifest = loadManifest(uri);
trackGroupArrays = getTrackGroupArrays(manifest);
handler.post(() -> callback.onPrepared(DownloadHelper.this)); handler.post(() -> callback.onPrepared(DownloadHelper.this));
} catch (final IOException e) { } catch (final IOException e) {
handler.post(() -> callback.onPrepareError(DownloadHelper.this, e)); handler.post(() -> callback.onPrepareError(DownloadHelper.this, e));
...@@ -67,18 +94,20 @@ public abstract class DownloadHelper { ...@@ -67,18 +94,20 @@ public abstract class DownloadHelper {
}.start(); }.start();
} }
/** /** Returns the manifest. Must not be called until after preparation completes. */
* Called on a background thread during preparation. public final T getManifest() {
* Assertions.checkNotNull(manifest);
* @throws IOException If preparation fails. return manifest;
*/ }
protected abstract void prepareInternal() throws IOException;
/** /**
* Returns the number of periods for which media is available. Must not be called until after * Returns the number of periods for which media is available. Must not be called until after
* preparation completes. * preparation completes.
*/ */
public abstract int getPeriodCount(); public final int getPeriodCount() {
Assertions.checkNotNull(trackGroupArrays);
return trackGroupArrays.length;
}
/** /**
* Returns the track groups for the given period. Must not be called until after preparation * Returns the track groups for the given period. Must not be called until after preparation
...@@ -88,7 +117,10 @@ public abstract class DownloadHelper { ...@@ -88,7 +117,10 @@ public abstract class DownloadHelper {
* @return The track groups for the period. May be {@link TrackGroupArray#EMPTY} for single stream * @return The track groups for the period. May be {@link TrackGroupArray#EMPTY} for single stream
* content. * content.
*/ */
public abstract TrackGroupArray getTrackGroups(int periodIndex); public final TrackGroupArray getTrackGroups(int periodIndex) {
Assertions.checkNotNull(trackGroupArrays);
return trackGroupArrays[periodIndex];
}
/** /**
* Builds a {@link DownloadAction} for downloading the specified tracks. Must not be called until * Builds a {@link DownloadAction} for downloading the specified tracks. Must not be called until
...@@ -98,12 +130,41 @@ public abstract class DownloadHelper { ...@@ -98,12 +130,41 @@ public abstract class DownloadHelper {
* @param trackKeys The selected tracks. If empty, all streams will be downloaded. * @param trackKeys The selected tracks. If empty, all streams will be downloaded.
* @return The built {@link DownloadAction}. * @return The built {@link DownloadAction}.
*/ */
public abstract DownloadAction getDownloadAction(@Nullable byte[] data, List<TrackKey> trackKeys); public final DownloadAction getDownloadAction(@Nullable byte[] data, List<TrackKey> trackKeys) {
return DownloadAction.createDownloadAction(
downloadType, uri, toStreamKeys(trackKeys), cacheKey, data);
}
/** /**
* Builds a {@link DownloadAction} for removing the media. May be called in any state. * Builds a {@link DownloadAction} for removing the media. May be called in any state.
* *
* @return The built {@link DownloadAction}. * @return The built {@link DownloadAction}.
*/ */
public abstract DownloadAction getRemoveAction(); public final DownloadAction getRemoveAction() {
return DownloadAction.createRemoveAction(downloadType, uri, cacheKey);
}
/**
* Loads the manifest. This method is called on a background thread.
*
* @param uri The manifest uri.
* @throws IOException If loading fails.
*/
protected abstract T loadManifest(Uri uri) throws IOException;
/**
* Returns the track group arrays for each period in the manifest.
*
* @param manifest The manifest.
* @return An array of {@link TrackGroupArray}s. One for each period in the manifest.
*/
protected abstract TrackGroupArray[] getTrackGroupArrays(T manifest);
/**
* Converts a list of {@link TrackKey track keys} to {@link StreamKey stream keys}.
*
* @param trackKeys A list of track keys.
* @return A corresponding list of stream keys.
*/
protected abstract List<StreamKey> toStreamKeys(List<TrackKey> trackKeys);
} }
...@@ -22,47 +22,28 @@ import java.util.Collections; ...@@ -22,47 +22,28 @@ import java.util.Collections;
import java.util.List; import java.util.List;
/** A {@link DownloadHelper} for progressive streams. */ /** A {@link DownloadHelper} for progressive streams. */
public final class ProgressiveDownloadHelper extends DownloadHelper { public final class ProgressiveDownloadHelper extends DownloadHelper<Void> {
private final Uri uri;
private final @Nullable String customCacheKey;
public ProgressiveDownloadHelper(Uri uri) { public ProgressiveDownloadHelper(Uri uri) {
this(uri, null); this(uri, null);
} }
public ProgressiveDownloadHelper(Uri uri, @Nullable String customCacheKey) { public ProgressiveDownloadHelper(Uri uri, @Nullable String customCacheKey) {
this.uri = uri; super(DownloadAction.TYPE_PROGRESSIVE, uri, customCacheKey);
this.customCacheKey = customCacheKey;
}
@Override
protected void prepareInternal() {
// Do nothing.
}
@Override
public int getPeriodCount() {
return 1;
} }
@Override @Override
public TrackGroupArray getTrackGroups(int periodIndex) { protected Void loadManifest(Uri uri) {
return TrackGroupArray.EMPTY; return null;
} }
@Override @Override
public DownloadAction getDownloadAction(@Nullable byte[] data, List<TrackKey> trackKeys) { protected TrackGroupArray[] getTrackGroupArrays(Void manifest) {
return DownloadAction.createDownloadAction( return new TrackGroupArray[] {TrackGroupArray.EMPTY};
DownloadAction.TYPE_PROGRESSIVE,
uri,
/* keys= */ Collections.emptyList(),
customCacheKey,
data);
} }
@Override @Override
public DownloadAction getRemoveAction() { protected List<StreamKey> toStreamKeys(List<TrackKey> trackKeys) {
return DownloadAction.createRemoveAction(DownloadAction.TYPE_PROGRESSIVE, uri, customCacheKey); return Collections.emptyList();
} }
} }
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package com.google.android.exoplayer2.source.dash.offline; package com.google.android.exoplayer2.source.dash.offline;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.offline.DownloadAction; import com.google.android.exoplayer2.offline.DownloadAction;
...@@ -31,74 +30,49 @@ import com.google.android.exoplayer2.source.dash.manifest.DashManifestParser; ...@@ -31,74 +30,49 @@ import com.google.android.exoplayer2.source.dash.manifest.DashManifestParser;
import com.google.android.exoplayer2.source.dash.manifest.Representation; import com.google.android.exoplayer2.source.dash.manifest.Representation;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.ParsingLoadable; import com.google.android.exoplayer2.upstream.ParsingLoadable;
import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** A {@link DownloadHelper} for DASH streams. */ /** A {@link DownloadHelper} for DASH streams. */
public final class DashDownloadHelper extends DownloadHelper { public final class DashDownloadHelper extends DownloadHelper<DashManifest> {
private final Uri uri;
private final DataSource.Factory manifestDataSourceFactory; private final DataSource.Factory manifestDataSourceFactory;
private @MonotonicNonNull DashManifest manifest;
public DashDownloadHelper(Uri uri, DataSource.Factory manifestDataSourceFactory) { public DashDownloadHelper(Uri uri, DataSource.Factory manifestDataSourceFactory) {
this.uri = uri; super(DownloadAction.TYPE_DASH, uri, /* cacheKey= */ null);
this.manifestDataSourceFactory = manifestDataSourceFactory; this.manifestDataSourceFactory = manifestDataSourceFactory;
} }
@Override @Override
protected void prepareInternal() throws IOException { protected DashManifest loadManifest(Uri uri) throws IOException {
DataSource dataSource = manifestDataSourceFactory.createDataSource(); DataSource dataSource = manifestDataSourceFactory.createDataSource();
manifest = return ParsingLoadable.load(dataSource, new DashManifestParser(), uri, C.DATA_TYPE_MANIFEST);
ParsingLoadable.load(dataSource, new DashManifestParser(), uri, C.DATA_TYPE_MANIFEST);
}
/** Returns the DASH manifest. Must not be called until after preparation completes. */
public DashManifest getManifest() {
Assertions.checkNotNull(manifest);
return manifest;
}
@Override
public int getPeriodCount() {
Assertions.checkNotNull(manifest);
return manifest.getPeriodCount();
} }
@Override @Override
public TrackGroupArray getTrackGroups(int periodIndex) { public TrackGroupArray[] getTrackGroupArrays(DashManifest manifest) {
Assertions.checkNotNull(manifest); int periodCount = manifest.getPeriodCount();
List<AdaptationSet> adaptationSets = manifest.getPeriod(periodIndex).adaptationSets; TrackGroupArray[] trackGroupArrays = new TrackGroupArray[periodCount];
TrackGroup[] trackGroups = new TrackGroup[adaptationSets.size()]; for (int periodIndex = 0; periodIndex < periodCount; periodIndex++) {
for (int i = 0; i < trackGroups.length; i++) { List<AdaptationSet> adaptationSets = manifest.getPeriod(periodIndex).adaptationSets;
List<Representation> representations = adaptationSets.get(i).representations; TrackGroup[] trackGroups = new TrackGroup[adaptationSets.size()];
Format[] formats = new Format[representations.size()]; for (int i = 0; i < trackGroups.length; i++) {
int representationsCount = representations.size(); List<Representation> representations = adaptationSets.get(i).representations;
for (int j = 0; j < representationsCount; j++) { Format[] formats = new Format[representations.size()];
formats[j] = representations.get(j).format; int representationsCount = representations.size();
for (int j = 0; j < representationsCount; j++) {
formats[j] = representations.get(j).format;
}
trackGroups[i] = new TrackGroup(formats);
} }
trackGroups[i] = new TrackGroup(formats); trackGroupArrays[periodIndex] = new TrackGroupArray(trackGroups);
} }
return new TrackGroupArray(trackGroups); return trackGroupArrays;
} }
@Override @Override
public DownloadAction getDownloadAction(@Nullable byte[] data, List<TrackKey> trackKeys) { protected List<StreamKey> toStreamKeys(List<TrackKey> trackKeys) {
return DownloadAction.createDownloadAction(
DownloadAction.TYPE_DASH, uri, toStreamKeys(trackKeys), /* customCacheKey= */ null, data);
}
@Override
public DownloadAction getRemoveAction() {
return DownloadAction.createRemoveAction(
DownloadAction.TYPE_DASH, uri, /* customCacheKey= */ null);
}
private static List<StreamKey> toStreamKeys(List<TrackKey> trackKeys) {
List<StreamKey> streamKeys = new ArrayList<>(trackKeys.size()); List<StreamKey> streamKeys = new ArrayList<>(trackKeys.size());
for (int i = 0; i < trackKeys.size(); i++) { for (int i = 0; i < trackKeys.size(); i++) {
TrackKey trackKey = trackKeys.get(i); TrackKey trackKey = trackKeys.get(i);
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package com.google.android.exoplayer2.source.hls.offline; package com.google.android.exoplayer2.source.hls.offline;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.offline.DownloadAction; import com.google.android.exoplayer2.offline.DownloadAction;
...@@ -36,46 +35,31 @@ import java.io.IOException; ...@@ -36,46 +35,31 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** A {@link DownloadHelper} for HLS streams. */ /** A {@link DownloadHelper} for HLS streams. */
public final class HlsDownloadHelper extends DownloadHelper { public final class HlsDownloadHelper extends DownloadHelper<HlsPlaylist> {
private final Uri uri;
private final DataSource.Factory manifestDataSourceFactory; private final DataSource.Factory manifestDataSourceFactory;
private @MonotonicNonNull HlsPlaylist playlist;
private int[] renditionGroups; private int[] renditionGroups;
public HlsDownloadHelper(Uri uri, DataSource.Factory manifestDataSourceFactory) { public HlsDownloadHelper(Uri uri, DataSource.Factory manifestDataSourceFactory) {
this.uri = uri; super(DownloadAction.TYPE_HLS, uri, /* cacheKey= */ null);
this.manifestDataSourceFactory = manifestDataSourceFactory; this.manifestDataSourceFactory = manifestDataSourceFactory;
} }
@Override @Override
protected void prepareInternal() throws IOException { protected HlsPlaylist loadManifest(Uri uri) throws IOException {
DataSource dataSource = manifestDataSourceFactory.createDataSource(); DataSource dataSource = manifestDataSourceFactory.createDataSource();
playlist = ParsingLoadable.load(dataSource, new HlsPlaylistParser(), uri, C.DATA_TYPE_MANIFEST); return ParsingLoadable.load(dataSource, new HlsPlaylistParser(), uri, C.DATA_TYPE_MANIFEST);
}
/** Returns the HLS playlist. Must not be called until after preparation completes. */
public HlsPlaylist getPlaylist() {
Assertions.checkNotNull(playlist);
return playlist;
} }
@Override @Override
public int getPeriodCount() { protected TrackGroupArray[] getTrackGroupArrays(HlsPlaylist playlist) {
Assertions.checkNotNull(playlist);
return 1;
}
@Override
public TrackGroupArray getTrackGroups(int periodIndex) {
Assertions.checkNotNull(playlist); Assertions.checkNotNull(playlist);
if (playlist instanceof HlsMediaPlaylist) { if (playlist instanceof HlsMediaPlaylist) {
renditionGroups = new int[0]; renditionGroups = new int[0];
return TrackGroupArray.EMPTY; return new TrackGroupArray[] {TrackGroupArray.EMPTY};
} }
// TODO: Generate track groups as in playback. Reverse the mapping in getDownloadAction. // TODO: Generate track groups as in playback. Reverse the mapping in getDownloadAction.
HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) playlist; HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) playlist;
...@@ -94,24 +78,18 @@ public final class HlsDownloadHelper extends DownloadHelper { ...@@ -94,24 +78,18 @@ public final class HlsDownloadHelper extends DownloadHelper {
renditionGroups[trackGroupIndex] = HlsMasterPlaylist.GROUP_INDEX_SUBTITLE; renditionGroups[trackGroupIndex] = HlsMasterPlaylist.GROUP_INDEX_SUBTITLE;
trackGroups[trackGroupIndex++] = new TrackGroup(toFormats(masterPlaylist.subtitles)); trackGroups[trackGroupIndex++] = new TrackGroup(toFormats(masterPlaylist.subtitles));
} }
return new TrackGroupArray(Arrays.copyOf(trackGroups, trackGroupIndex)); return new TrackGroupArray[] {new TrackGroupArray(Arrays.copyOf(trackGroups, trackGroupIndex))};
} }
@Override @Override
public DownloadAction getDownloadAction(@Nullable byte[] data, List<TrackKey> trackKeys) { protected List<StreamKey> toStreamKeys(List<TrackKey> trackKeys) {
Assertions.checkNotNull(renditionGroups); List<StreamKey> representationKeys = new ArrayList<>(trackKeys.size());
return DownloadAction.createDownloadAction( for (int i = 0; i < trackKeys.size(); i++) {
DownloadAction.TYPE_HLS, TrackKey trackKey = trackKeys.get(i);
uri, representationKeys.add(
toStreamKeys(trackKeys, renditionGroups), new StreamKey(renditionGroups[trackKey.groupIndex], trackKey.trackIndex));
/* customCacheKey= */ null, }
data); return representationKeys;
}
@Override
public DownloadAction getRemoveAction() {
return DownloadAction.createRemoveAction(
DownloadAction.TYPE_HLS, uri, /* customCacheKey= */ null);
} }
private static Format[] toFormats(List<HlsMasterPlaylist.HlsUrl> hlsUrls) { private static Format[] toFormats(List<HlsMasterPlaylist.HlsUrl> hlsUrls) {
...@@ -121,13 +99,4 @@ public final class HlsDownloadHelper extends DownloadHelper { ...@@ -121,13 +99,4 @@ public final class HlsDownloadHelper extends DownloadHelper {
} }
return formats; return formats;
} }
private static List<StreamKey> toStreamKeys(List<TrackKey> trackKeys, int[] groups) {
List<StreamKey> representationKeys = new ArrayList<>(trackKeys.size());
for (int i = 0; i < trackKeys.size(); i++) {
TrackKey trackKey = trackKeys.get(i);
representationKeys.add(new StreamKey(groups[trackKey.groupIndex], trackKey.trackIndex));
}
return representationKeys;
}
} }
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package com.google.android.exoplayer2.source.smoothstreaming.offline; package com.google.android.exoplayer2.source.smoothstreaming.offline;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.offline.DownloadAction; import com.google.android.exoplayer2.offline.DownloadAction;
import com.google.android.exoplayer2.offline.DownloadHelper; import com.google.android.exoplayer2.offline.DownloadHelper;
...@@ -28,67 +27,38 @@ import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest; ...@@ -28,67 +27,38 @@ import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser; import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.ParsingLoadable; import com.google.android.exoplayer2.upstream.ParsingLoadable;
import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** A {@link DownloadHelper} for SmoothStreaming streams. */ /** A {@link DownloadHelper} for SmoothStreaming streams. */
public final class SsDownloadHelper extends DownloadHelper { public final class SsDownloadHelper extends DownloadHelper<SsManifest> {
private final Uri uri;
private final DataSource.Factory manifestDataSourceFactory; private final DataSource.Factory manifestDataSourceFactory;
private @MonotonicNonNull SsManifest manifest;
public SsDownloadHelper(Uri uri, DataSource.Factory manifestDataSourceFactory) { public SsDownloadHelper(Uri uri, DataSource.Factory manifestDataSourceFactory) {
this.uri = uri; super(DownloadAction.TYPE_SS, uri, /* cacheKey= */ null);
this.manifestDataSourceFactory = manifestDataSourceFactory; this.manifestDataSourceFactory = manifestDataSourceFactory;
} }
@Override @Override
protected void prepareInternal() throws IOException { protected SsManifest loadManifest(Uri uri) throws IOException {
DataSource dataSource = manifestDataSourceFactory.createDataSource(); DataSource dataSource = manifestDataSourceFactory.createDataSource();
manifest = ParsingLoadable.load(dataSource, new SsManifestParser(), uri, C.DATA_TYPE_MANIFEST); return ParsingLoadable.load(dataSource, new SsManifestParser(), uri, C.DATA_TYPE_MANIFEST);
}
/** Returns the SmoothStreaming manifest. Must not be called until after preparation completes. */
public SsManifest getManifest() {
Assertions.checkNotNull(manifest);
return manifest;
}
@Override
public int getPeriodCount() {
Assertions.checkNotNull(manifest);
return 1;
} }
@Override @Override
public TrackGroupArray getTrackGroups(int periodIndex) { protected TrackGroupArray[] getTrackGroupArrays(SsManifest manifest) {
Assertions.checkNotNull(manifest);
SsManifest.StreamElement[] streamElements = manifest.streamElements; SsManifest.StreamElement[] streamElements = manifest.streamElements;
TrackGroup[] trackGroups = new TrackGroup[streamElements.length]; TrackGroup[] trackGroups = new TrackGroup[streamElements.length];
for (int i = 0; i < streamElements.length; i++) { for (int i = 0; i < streamElements.length; i++) {
trackGroups[i] = new TrackGroup(streamElements[i].formats); trackGroups[i] = new TrackGroup(streamElements[i].formats);
} }
return new TrackGroupArray(trackGroups); return new TrackGroupArray[] {new TrackGroupArray(trackGroups)};
} }
@Override @Override
public DownloadAction getDownloadAction(@Nullable byte[] data, List<TrackKey> trackKeys) { protected List<StreamKey> toStreamKeys(List<TrackKey> trackKeys) {
return DownloadAction.createDownloadAction(
DownloadAction.TYPE_SS, uri, toStreamKeys(trackKeys), /* customCacheKey= */ null, data);
}
@Override
public DownloadAction getRemoveAction() {
return DownloadAction.createRemoveAction(
DownloadAction.TYPE_SS, uri, /* customCacheKey= */ null);
}
private static List<StreamKey> toStreamKeys(List<TrackKey> trackKeys) {
List<StreamKey> representationKeys = new ArrayList<>(trackKeys.size()); List<StreamKey> representationKeys = new ArrayList<>(trackKeys.size());
for (int i = 0; i < trackKeys.size(); i++) { for (int i = 0; i < trackKeys.size(); i++) {
TrackKey trackKey = trackKeys.get(i); TrackKey trackKey = trackKeys.get(i);
......
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