Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e7d717b9
authored
Apr 08, 2019
by
olly
Committed by
Oliver Woodman
Apr 13, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Sanitize naming of keys variable.
PiperOrigin-RevId: 242460786
parent
a0c21461
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
36 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloaderFactory.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadAction.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadState.java
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadIndexUtilTest.java
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadManagerTest.java
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateBuilder.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloaderFactory.java
View file @
e7d717b9
...
...
@@ -99,7 +99,7 @@ public class DefaultDownloaderFactory implements DownloaderFactory {
}
try
{
// TODO: Support customCacheKey in DASH/HLS/SS, for completeness.
return
constructor
.
newInstance
(
action
.
uri
,
action
.
getKeys
()
,
downloaderConstructorHelper
);
return
constructor
.
newInstance
(
action
.
uri
,
action
.
streamKeys
,
downloaderConstructorHelper
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Failed to instantiate downloader for: "
+
action
.
type
,
e
);
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadAction.java
View file @
e7d717b9
...
...
@@ -48,7 +48,7 @@ public final class DownloadAction {
private
static
final
int
VERSION
=
3
;
/**
* Deserializes a
n
action from the {@code data}.
* Deserializes a
download
action from the {@code data}.
*
* @param data The action data to deserialize.
* @return The deserialized action.
...
...
@@ -62,10 +62,7 @@ public final class DownloadAction {
}
/**
* Deserializes one action that was serialized with {@link #serializeToStream(OutputStream)} from
* the {@code input}.
*
* <p>The caller is responsible for closing the given {@link InputStream}.
* Deserializes a single download action from {@code input}.
*
* @param input The stream from which to read.
* @return The deserialized action.
...
...
@@ -104,35 +101,35 @@ public final class DownloadAction {
public
final
String
type
;
/** The uri being downloaded. */
public
final
Uri
uri
;
/**
Keys of stream
s to be downloaded. If empty, all streams will be downloaded. */
public
final
List
<
StreamKey
>
k
eys
;
/**
A c
ustom key for cache indexing, or null. */
/**
Stream key
s to be downloaded. If empty, all streams will be downloaded. */
public
final
List
<
StreamKey
>
streamK
eys
;
/**
C
ustom key for cache indexing, or null. */
@Nullable
public
final
String
customCacheKey
;
/**
Custom data for this action
. May be empty. */
/**
Application defined data associated with the download
. May be empty. */
public
final
byte
[]
data
;
/**
* @param id
The content id
.
* @param type
The type of the action
.
* @param uri
The uri being downloaded
.
* @param
keys Keys of streams to be downloaded. If empty, all streams will be downloaded
.
* @param customCacheKey
A custom key for cache indexing, or null
.
* @param data
Custom data for this action
.
* @param id
See {@link #id}
.
* @param type
See {@link #type}
.
* @param uri
See {@link #uri}
.
* @param
streamKeys See {@link #streamKeys}
.
* @param customCacheKey
See {@link #customCacheKey}
.
* @param data
See {@link #data}
.
*/
private
DownloadAction
(
String
id
,
String
type
,
Uri
uri
,
List
<
StreamKey
>
k
eys
,
List
<
StreamKey
>
streamK
eys
,
@Nullable
String
customCacheKey
,
@Nullable
byte
[]
data
)
{
this
.
id
=
id
;
this
.
type
=
type
;
this
.
uri
=
uri
;
this
.
customCacheKey
=
customCacheKey
;
ArrayList
<
StreamKey
>
mutableKeys
=
new
ArrayList
<>(
k
eys
);
ArrayList
<
StreamKey
>
mutableKeys
=
new
ArrayList
<>(
streamK
eys
);
Collections
.
sort
(
mutableKeys
);
this
.
k
eys
=
Collections
.
unmodifiableList
(
mutableKeys
);
this
.
streamK
eys
=
Collections
.
unmodifiableList
(
mutableKeys
);
this
.
data
=
data
!=
null
?
Arrays
.
copyOf
(
data
,
data
.
length
)
:
Util
.
EMPTY_BYTE_ARRAY
;
}
...
...
@@ -148,11 +145,6 @@ public final class DownloadAction {
return
output
.
toByteArray
();
}
/** Returns keys of streams to be downloaded. */
public
List
<
StreamKey
>
getKeys
()
{
return
keys
;
}
@Override
public
boolean
equals
(
@Nullable
Object
o
)
{
if
(!(
o
instanceof
DownloadAction
))
{
...
...
@@ -162,7 +154,7 @@ public final class DownloadAction {
return
id
.
equals
(
that
.
id
)
&&
type
.
equals
(
that
.
type
)
&&
uri
.
equals
(
that
.
uri
)
&&
keys
.
equals
(
that
.
k
eys
)
&&
streamKeys
.
equals
(
that
.
streamK
eys
)
&&
Util
.
areEqual
(
customCacheKey
,
that
.
customCacheKey
)
&&
Arrays
.
equals
(
data
,
that
.
data
);
}
...
...
@@ -172,7 +164,7 @@ public final class DownloadAction {
int
result
=
type
.
hashCode
();
result
=
31
*
result
+
id
.
hashCode
();
result
=
31
*
result
+
uri
.
hashCode
();
result
=
31
*
result
+
k
eys
.
hashCode
();
result
=
31
*
result
+
streamK
eys
.
hashCode
();
result
=
31
*
result
+
(
customCacheKey
!=
null
?
customCacheKey
.
hashCode
()
:
0
);
result
=
31
*
result
+
Arrays
.
hashCode
(
data
);
return
result
;
...
...
@@ -194,9 +186,9 @@ public final class DownloadAction {
dataOutputStream
.
writeBoolean
(
false
);
dataOutputStream
.
writeInt
(
data
.
length
);
dataOutputStream
.
write
(
data
);
dataOutputStream
.
writeInt
(
k
eys
.
size
());
for
(
int
i
=
0
;
i
<
k
eys
.
size
();
i
++)
{
StreamKey
key
=
k
eys
.
get
(
i
);
dataOutputStream
.
writeInt
(
streamK
eys
.
size
());
for
(
int
i
=
0
;
i
<
streamK
eys
.
size
();
i
++)
{
StreamKey
key
=
streamK
eys
.
get
(
i
);
dataOutputStream
.
writeInt
(
key
.
periodIndex
);
dataOutputStream
.
writeInt
(
key
.
groupIndex
);
dataOutputStream
.
writeInt
(
key
.
trackIndex
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadState.java
View file @
e7d717b9
...
...
@@ -165,7 +165,7 @@ public final class DownloadState {
/* manualStopReason= */
0
,
/* startTimeMs= */
currentTimeMs
,
/* updateTimeMs= */
currentTimeMs
,
action
.
k
eys
.
toArray
(
new
StreamKey
[
0
]),
action
.
streamK
eys
.
toArray
(
new
StreamKey
[
0
]),
action
.
data
,
new
CachingCounters
());
}
...
...
@@ -289,10 +289,10 @@ public final class DownloadState {
private
static
StreamKey
[]
mergeStreamKeys
(
DownloadState
downloadState
,
DownloadAction
action
)
{
StreamKey
[]
streamKeys
=
downloadState
.
streamKeys
;
if
(
streamKeys
.
length
>
0
)
{
if
(
action
.
k
eys
.
isEmpty
())
{
if
(
action
.
streamK
eys
.
isEmpty
())
{
streamKeys
=
new
StreamKey
[
0
];
}
else
{
HashSet
<
StreamKey
>
keys
=
new
HashSet
<>(
action
.
k
eys
);
HashSet
<
StreamKey
>
keys
=
new
HashSet
<>(
action
.
streamK
eys
);
Collections
.
addAll
(
keys
,
downloadState
.
streamKeys
);
streamKeys
=
keys
.
toArray
(
new
StreamKey
[
0
]);
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java
View file @
e7d717b9
...
...
@@ -398,7 +398,7 @@ public class DownloadHelperTest {
assertThat
(
downloadAction
.
uri
).
isEqualTo
(
testUri
);
assertThat
(
downloadAction
.
customCacheKey
).
isEqualTo
(
TEST_CACHE_KEY
);
assertThat
(
downloadAction
.
data
).
isEqualTo
(
data
);
assertThat
(
downloadAction
.
k
eys
)
assertThat
(
downloadAction
.
streamK
eys
)
.
containsExactly
(
new
StreamKey
(
/* periodIndex= */
0
,
/* groupIndex= */
0
,
/* trackIndex= */
0
),
new
StreamKey
(
/* periodIndex= */
0
,
/* groupIndex= */
0
,
/* trackIndex= */
1
),
...
...
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadIndexUtilTest.java
View file @
e7d717b9
...
...
@@ -147,7 +147,8 @@ public class DownloadIndexUtilTest {
assertThat
(
downloadState
.
cacheKey
).
isEqualTo
(
action
.
customCacheKey
);
assertThat
(
downloadState
.
customMetadata
).
isEqualTo
(
action
.
data
);
assertThat
(
downloadState
.
uri
).
isEqualTo
(
action
.
uri
);
assertThat
(
Arrays
.
asList
(
downloadState
.
streamKeys
)).
containsExactlyElementsIn
(
action
.
keys
);
assertThat
(
Arrays
.
asList
(
downloadState
.
streamKeys
))
.
containsExactlyElementsIn
(
action
.
streamKeys
);
assertThat
(
downloadState
.
state
).
isEqualTo
(
state
);
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadManagerTest.java
View file @
e7d717b9
...
...
@@ -249,7 +249,7 @@ public class DownloadManagerTest {
FakeDownloader
downloader2
=
runner
.
getDownloader
(
1
);
downloader2
.
assertStarted
();
assertThat
(
downloader2
.
action
.
k
eys
).
containsExactly
(
streamKey1
,
streamKey2
);
assertThat
(
downloader2
.
action
.
streamK
eys
).
containsExactly
(
streamKey1
,
streamKey2
);
downloader2
.
unblock
();
runner
.
getTask
().
assertCompleted
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateBuilder.java
View file @
e7d717b9
...
...
@@ -52,7 +52,7 @@ class DownloadStateBuilder {
action
.
uri
,
action
.
customCacheKey
,
action
.
data
,
action
.
k
eys
.
toArray
(
new
StreamKey
[
0
]));
action
.
streamK
eys
.
toArray
(
new
StreamKey
[
0
]));
}
DownloadStateBuilder
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment