mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Assert customCacheKey is null for DASH, HLS and SmoothStreaming downloads
PiperOrigin-RevId: 243954989
This commit is contained in:
parent
10f3b8db6e
commit
dcb8417a3c
4 changed files with 17 additions and 9 deletions
|
|
@ -52,7 +52,10 @@ public final class DownloadRequest implements Parcelable {
|
||||||
public final Uri uri;
|
public final Uri uri;
|
||||||
/** Stream keys to be downloaded. If empty, all streams will be downloaded. */
|
/** Stream keys to be downloaded. If empty, all streams will be downloaded. */
|
||||||
public final List<StreamKey> streamKeys;
|
public final List<StreamKey> streamKeys;
|
||||||
/** Custom key for cache indexing, or null. */
|
/**
|
||||||
|
* Custom key for cache indexing, or null. Must be null for DASH, HLS and SmoothStreaming
|
||||||
|
* downloads.
|
||||||
|
*/
|
||||||
@Nullable public final String customCacheKey;
|
@Nullable public final String customCacheKey;
|
||||||
/** Application defined data associated with the download. May be empty. */
|
/** Application defined data associated with the download. May be empty. */
|
||||||
public final byte[] data;
|
public final byte[] data;
|
||||||
|
|
@ -72,6 +75,10 @@ public final class DownloadRequest implements Parcelable {
|
||||||
List<StreamKey> streamKeys,
|
List<StreamKey> streamKeys,
|
||||||
@Nullable String customCacheKey,
|
@Nullable String customCacheKey,
|
||||||
@Nullable byte[] data) {
|
@Nullable byte[] data) {
|
||||||
|
if (TYPE_DASH.equals(type) || TYPE_HLS.equals(type) || TYPE_SS.equals(type)) {
|
||||||
|
Assertions.checkArgument(
|
||||||
|
customCacheKey == null, "customCacheKey must be null for type: " + type);
|
||||||
|
}
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.offline;
|
package com.google.android.exoplayer2.offline;
|
||||||
|
|
||||||
import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_DASH;
|
import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_PROGRESSIVE;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
@ -73,7 +73,7 @@ public class ActionFileUpgradeUtilTest {
|
||||||
DownloadRequest expectedRequest1 =
|
DownloadRequest expectedRequest1 =
|
||||||
new DownloadRequest(
|
new DownloadRequest(
|
||||||
"key123",
|
"key123",
|
||||||
TYPE_DASH,
|
/* type= */ "test",
|
||||||
Uri.parse("https://www.test.com/download1"),
|
Uri.parse("https://www.test.com/download1"),
|
||||||
asList(expectedStreamKey1),
|
asList(expectedStreamKey1),
|
||||||
/* customCacheKey= */ "key123",
|
/* customCacheKey= */ "key123",
|
||||||
|
|
@ -81,7 +81,7 @@ public class ActionFileUpgradeUtilTest {
|
||||||
DownloadRequest expectedRequest2 =
|
DownloadRequest expectedRequest2 =
|
||||||
new DownloadRequest(
|
new DownloadRequest(
|
||||||
"key234",
|
"key234",
|
||||||
TYPE_DASH,
|
/* type= */ "test",
|
||||||
Uri.parse("https://www.test.com/download2"),
|
Uri.parse("https://www.test.com/download2"),
|
||||||
asList(expectedStreamKey2),
|
asList(expectedStreamKey2),
|
||||||
/* customCacheKey= */ "key234",
|
/* customCacheKey= */ "key234",
|
||||||
|
|
@ -100,7 +100,7 @@ public class ActionFileUpgradeUtilTest {
|
||||||
DownloadRequest request =
|
DownloadRequest request =
|
||||||
new DownloadRequest(
|
new DownloadRequest(
|
||||||
"id",
|
"id",
|
||||||
TYPE_DASH,
|
TYPE_PROGRESSIVE,
|
||||||
Uri.parse("https://www.test.com/download"),
|
Uri.parse("https://www.test.com/download"),
|
||||||
asList(
|
asList(
|
||||||
new StreamKey(/* periodIndex= */ 0, /* groupIndex= */ 1, /* trackIndex= */ 2),
|
new StreamKey(/* periodIndex= */ 0, /* groupIndex= */ 1, /* trackIndex= */ 2),
|
||||||
|
|
@ -122,7 +122,7 @@ public class ActionFileUpgradeUtilTest {
|
||||||
DownloadRequest request1 =
|
DownloadRequest request1 =
|
||||||
new DownloadRequest(
|
new DownloadRequest(
|
||||||
"id",
|
"id",
|
||||||
TYPE_DASH,
|
TYPE_PROGRESSIVE,
|
||||||
Uri.parse("https://www.test.com/download1"),
|
Uri.parse("https://www.test.com/download1"),
|
||||||
asList(streamKey1),
|
asList(streamKey1),
|
||||||
/* customCacheKey= */ "key123",
|
/* customCacheKey= */ "key123",
|
||||||
|
|
@ -130,7 +130,7 @@ public class ActionFileUpgradeUtilTest {
|
||||||
DownloadRequest request2 =
|
DownloadRequest request2 =
|
||||||
new DownloadRequest(
|
new DownloadRequest(
|
||||||
"id",
|
"id",
|
||||||
TYPE_DASH,
|
TYPE_PROGRESSIVE,
|
||||||
Uri.parse("https://www.test.com/download2"),
|
Uri.parse("https://www.test.com/download2"),
|
||||||
asList(streamKey2),
|
asList(streamKey2),
|
||||||
/* customCacheKey= */ "key123",
|
/* customCacheKey= */ "key123",
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ package com.google.android.exoplayer2.offline;
|
||||||
|
|
||||||
import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_DASH;
|
import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_DASH;
|
||||||
import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_HLS;
|
import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_HLS;
|
||||||
|
import static com.google.android.exoplayer2.offline.DownloadRequest.TYPE_PROGRESSIVE;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
|
@ -139,7 +140,7 @@ public class DownloadRequestTest {
|
||||||
DownloadRequest request1 =
|
DownloadRequest request1 =
|
||||||
new DownloadRequest(
|
new DownloadRequest(
|
||||||
"id1",
|
"id1",
|
||||||
TYPE_DASH,
|
TYPE_PROGRESSIVE,
|
||||||
uri1,
|
uri1,
|
||||||
/* streamKeys= */ Collections.emptyList(),
|
/* streamKeys= */ Collections.emptyList(),
|
||||||
"key1",
|
"key1",
|
||||||
|
|
@ -147,7 +148,7 @@ public class DownloadRequestTest {
|
||||||
DownloadRequest request2 =
|
DownloadRequest request2 =
|
||||||
new DownloadRequest(
|
new DownloadRequest(
|
||||||
"id1",
|
"id1",
|
||||||
TYPE_DASH,
|
TYPE_PROGRESSIVE,
|
||||||
uri2,
|
uri2,
|
||||||
/* streamKeys= */ Collections.emptyList(),
|
/* streamKeys= */ Collections.emptyList(),
|
||||||
"key2",
|
"key2",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue