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
9fd575e1
authored
Nov 25, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Allow Representations to have custom cache keys.
parent
632ccc6c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
11 deletions
library/src/main/java/com/google/android/exoplayer/dash/mpd/Representation.java
library/src/main/java/com/google/android/exoplayer/dash/mpd/Representation.java
View file @
9fd575e1
...
...
@@ -53,6 +53,7 @@ public abstract class Representation implements FormatWrapper {
*/
public
final
long
presentationTimeOffsetUs
;
private
final
String
cacheKey
;
private
final
RangedUri
initializationUri
;
/**
...
...
@@ -66,12 +67,27 @@ public abstract class Representation implements FormatWrapper {
*/
public
static
Representation
newInstance
(
String
contentId
,
long
revisionId
,
Format
format
,
SegmentBase
segmentBase
)
{
return
newInstance
(
contentId
,
revisionId
,
format
,
segmentBase
,
null
);
}
/**
* Constructs a new instance.
*
* @param contentId Identifies the piece of content to which this representation belongs.
* @param revisionId Identifies the revision of the content.
* @param format The format of the representation.
* @param segmentBase A segment base element for the representation.
* @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
* @return The constructed instance.
*/
public
static
Representation
newInstance
(
String
contentId
,
long
revisionId
,
Format
format
,
SegmentBase
segmentBase
,
String
customCacheKey
)
{
if
(
segmentBase
instanceof
SingleSegmentBase
)
{
return
new
SingleSegmentRepresentation
(
contentId
,
revisionId
,
format
,
(
SingleSegmentBase
)
segmentBase
,
-
1
);
(
SingleSegmentBase
)
segmentBase
,
customCacheKey
,
-
1
);
}
else
if
(
segmentBase
instanceof
MultiSegmentBase
)
{
return
new
MultiSegmentRepresentation
(
contentId
,
revisionId
,
format
,
(
MultiSegmentBase
)
segmentBase
);
(
MultiSegmentBase
)
segmentBase
,
customCacheKey
);
}
else
{
throw
new
IllegalArgumentException
(
"segmentBase must be of type SingleSegmentBase or "
+
"MultiSegmentBase"
);
...
...
@@ -79,10 +95,12 @@ public abstract class Representation implements FormatWrapper {
}
private
Representation
(
String
contentId
,
long
revisionId
,
Format
format
,
SegmentBase
segmentBase
)
{
SegmentBase
segmentBase
,
String
customCacheKey
)
{
this
.
contentId
=
contentId
;
this
.
revisionId
=
revisionId
;
this
.
format
=
format
;
this
.
cacheKey
=
customCacheKey
!=
null
?
customCacheKey
:
contentId
+
"."
+
format
.
id
+
"."
+
revisionId
;
initializationUri
=
segmentBase
.
getInitialization
(
this
);
presentationTimeOffsetUs
=
segmentBase
.
getPresentationTimeOffsetUs
();
}
...
...
@@ -119,13 +137,13 @@ public abstract class Representation implements FormatWrapper {
public
abstract
DashSegmentIndex
getIndex
();
/**
*
Generates a
cache key for the {@link Representation}, in the format
*
A
cache key for the {@link Representation}, in the format
* {@code contentId + "." + format.id + "." + revisionId}.
*
* @return A cache key.
*/
public
String
getCacheKey
()
{
return
c
ontentId
+
"."
+
format
.
id
+
"."
+
revisionId
;
return
c
acheKey
;
}
/**
...
...
@@ -155,17 +173,18 @@ public abstract class Representation implements FormatWrapper {
* @param initializationEnd The offset of the last byte of initialization data.
* @param indexStart The offset of the first byte of index data.
* @param indexEnd The offset of the last byte of index data.
* @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
* @param contentLength The content length, or -1 if unknown.
*/
public
static
SingleSegmentRepresentation
newInstance
(
String
contentId
,
long
revisionId
,
Format
format
,
String
uri
,
long
initializationStart
,
long
initializationEnd
,
long
indexStart
,
long
indexEnd
,
long
contentLength
)
{
long
indexStart
,
long
indexEnd
,
String
customCacheKey
,
long
contentLength
)
{
RangedUri
rangedUri
=
new
RangedUri
(
uri
,
null
,
initializationStart
,
initializationEnd
-
initializationStart
+
1
);
SingleSegmentBase
segmentBase
=
new
SingleSegmentBase
(
rangedUri
,
1
,
0
,
uri
,
indexStart
,
indexEnd
-
indexStart
+
1
);
return
new
SingleSegmentRepresentation
(
contentId
,
revisionId
,
format
,
segmentBase
,
contentLength
);
format
,
segmentBase
,
c
ustomCacheKey
,
c
ontentLength
);
}
/**
...
...
@@ -173,11 +192,12 @@ public abstract class Representation implements FormatWrapper {
* @param revisionId Identifies the revision of the content.
* @param format The format of the representation.
* @param segmentBase The segment base underlying the representation.
* @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
* @param contentLength The content length, or -1 if unknown.
*/
public
SingleSegmentRepresentation
(
String
contentId
,
long
revisionId
,
Format
format
,
SingleSegmentBase
segmentBase
,
long
contentLength
)
{
super
(
contentId
,
revisionId
,
format
,
segmentBase
);
SingleSegmentBase
segmentBase
,
String
customCacheKey
,
long
contentLength
)
{
super
(
contentId
,
revisionId
,
format
,
segmentBase
,
customCacheKey
);
this
.
uri
=
Uri
.
parse
(
segmentBase
.
uri
);
this
.
indexUri
=
segmentBase
.
getIndex
();
this
.
contentLength
=
contentLength
;
...
...
@@ -212,10 +232,11 @@ public abstract class Representation implements FormatWrapper {
* @param revisionId Identifies the revision of the content.
* @param format The format of the representation.
* @param segmentBase The segment base underlying the representation.
* @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
*/
public
MultiSegmentRepresentation
(
String
contentId
,
long
revisionId
,
Format
format
,
MultiSegmentBase
segmentBase
)
{
super
(
contentId
,
revisionId
,
format
,
segmentBase
);
MultiSegmentBase
segmentBase
,
String
customCacheKey
)
{
super
(
contentId
,
revisionId
,
format
,
segmentBase
,
customCacheKey
);
this
.
segmentBase
=
segmentBase
;
}
...
...
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