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
f1966308
authored
Dec 03, 2018
by
olly
Committed by
Oliver Woodman
Dec 04, 2018
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove contentId from Representation creators/constructor
PiperOrigin-RevId: 223796377
parent
500b1faf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
102 deletions
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Representation.java
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashUtilTest.java
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestTest.java
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/RepresentationTest.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
View file @
f1966308
...
...
@@ -671,7 +671,6 @@ public class DashManifestParser extends DefaultHandler
ArrayList
<
Descriptor
>
inbandEventStreams
=
representationInfo
.
inbandEventStreams
;
inbandEventStreams
.
addAll
(
extraInbandEventStreams
);
return
Representation
.
newInstance
(
/* contentId= */
null
,
representationInfo
.
revisionId
,
format
,
representationInfo
.
baseUrl
,
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Representation.java
View file @
f1966308
...
...
@@ -35,10 +35,10 @@ public abstract class Representation {
public
static
final
long
REVISION_ID_DEFAULT
=
-
1
;
/**
* Identifies the revision of the media contained within the representation. If the
content
can
* change over time (e.g. as a result of
re-encoding the media with an updated encoder), then this
*
identified can be set to uniquely identify the revision of the media. The timestamp at which
*
the media was encoded is
often a suitable.
* Identifies the revision of the media contained within the representation. If the
media
can
* change over time (e.g. as a result of
it being re-encoded), then this identifier can be set to
*
uniquely identify the revision of the media. The timestamp at which the media was encoded is
* often a suitable.
*/
public
final
long
revisionId
;
/**
...
...
@@ -63,22 +63,20 @@ public abstract class Representation {
/**
* 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 baseUrl The base URL.
* @param segmentBase A segment base element for the representation.
* @return The constructed instance.
*/
public
static
Representation
newInstance
(
String
contentId
,
long
revisionId
,
Format
format
,
String
baseUrl
,
SegmentBase
segmentBase
)
{
return
newInstance
(
contentId
,
revisionId
,
format
,
baseUrl
,
segmentBase
,
null
);
public
static
Representation
newInstance
(
long
revisionId
,
Format
format
,
String
baseUrl
,
SegmentBase
segmentBase
)
{
return
newInstance
(
revisionId
,
format
,
baseUrl
,
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 baseUrl The base URL.
...
...
@@ -86,31 +84,43 @@ public abstract class Representation {
* @param inbandEventStreams The in-band event streams in the representation. May be null.
* @return The constructed instance.
*/
public
static
Representation
newInstance
(
String
contentId
,
long
revisionId
,
Format
format
,
String
baseUrl
,
SegmentBase
segmentBase
,
List
<
Descriptor
>
inbandEventStreams
)
{
return
newInstance
(
contentId
,
revisionId
,
format
,
baseUrl
,
segmentBase
,
inbandEventStreams
,
null
);
public
static
Representation
newInstance
(
long
revisionId
,
Format
format
,
String
baseUrl
,
SegmentBase
segmentBase
,
List
<
Descriptor
>
inbandEventStreams
)
{
return
newInstance
(
revisionId
,
format
,
baseUrl
,
segmentBase
,
inbandEventStreams
,
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 baseUrl The base URL of the representation.
* @param segmentBase A segment base element for the representation.
* @param inbandEventStreams The in-band event streams in the representation. May be null.
* @param c
ustomCacheKey A custom value
to be returned from {@link #getCacheKey()}, or null. This
* @param c
acheKey An optional key
to be returned from {@link #getCacheKey()}, or null. This
* parameter is ignored if {@code segmentBase} consists of multiple segments.
* @return The constructed instance.
*/
public
static
Representation
newInstance
(
String
contentId
,
long
revisionId
,
Format
format
,
String
baseUrl
,
SegmentBase
segmentBase
,
List
<
Descriptor
>
inbandEventStreams
,
String
customCacheKey
)
{
public
static
Representation
newInstance
(
long
revisionId
,
Format
format
,
String
baseUrl
,
SegmentBase
segmentBase
,
List
<
Descriptor
>
inbandEventStreams
,
String
cacheKey
)
{
if
(
segmentBase
instanceof
SingleSegmentBase
)
{
return
new
SingleSegmentRepresentation
(
contentId
,
revisionId
,
format
,
baseUrl
,
(
SingleSegmentBase
)
segmentBase
,
inbandEventStreams
,
customCacheKey
,
C
.
LENGTH_UNSET
);
return
new
SingleSegmentRepresentation
(
revisionId
,
format
,
baseUrl
,
(
SingleSegmentBase
)
segmentBase
,
inbandEventStreams
,
cacheKey
,
C
.
LENGTH_UNSET
);
}
else
if
(
segmentBase
instanceof
MultiSegmentBase
)
{
return
new
MultiSegmentRepresentation
(
revisionId
,
format
,
baseUrl
,
(
MultiSegmentBase
)
segmentBase
,
inbandEventStreams
);
...
...
@@ -156,10 +166,7 @@ public abstract class Representation {
*/
public
abstract
DashSegmentIndex
getIndex
();
/**
* Returns a cache key for the representation if a custom cache key or content id has been
* provided and there is only single segment.
*/
/** Returns a cache key for the representation if set, or null. */
public
abstract
String
getCacheKey
();
/**
...
...
@@ -182,7 +189,6 @@ public abstract class Representation {
private
final
SingleSegmentIndex
segmentIndex
;
/**
* @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 uri The uri of the media.
...
...
@@ -191,39 +197,49 @@ public abstract class Representation {
* @param indexStart The offset of the first byte of index data.
* @param indexEnd The offset of the last byte of index data.
* @param inbandEventStreams The in-band event streams in the representation. May be null.
* @param c
ustomCacheKey A custom value
to be returned from {@link #getCacheKey()}, or null.
* @param c
acheKey An optional key
to be returned from {@link #getCacheKey()}, or null.
* @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown.
*/
public
static
SingleSegmentRepresentation
newInstance
(
String
contentId
,
long
revisionId
,
Format
format
,
String
uri
,
long
initializationStart
,
long
initializationEnd
,
long
indexStart
,
long
indexEnd
,
List
<
Descriptor
>
inbandEventStreams
,
String
customCacheKey
,
public
static
SingleSegmentRepresentation
newInstance
(
long
revisionId
,
Format
format
,
String
uri
,
long
initializationStart
,
long
initializationEnd
,
long
indexStart
,
long
indexEnd
,
List
<
Descriptor
>
inbandEventStreams
,
String
cacheKey
,
long
contentLength
)
{
RangedUri
rangedUri
=
new
RangedUri
(
null
,
initializationStart
,
initializationEnd
-
initializationStart
+
1
);
SingleSegmentBase
segmentBase
=
new
SingleSegmentBase
(
rangedUri
,
1
,
0
,
indexStart
,
indexEnd
-
indexStart
+
1
);
return
new
SingleSegmentRepresentation
(
contentId
,
revisionId
,
format
,
uri
,
segmentBase
,
inbandEventStreams
,
customC
acheKey
,
contentLength
);
return
new
SingleSegmentRepresentation
(
revisionId
,
format
,
uri
,
segmentBase
,
inbandEventStreams
,
c
acheKey
,
contentLength
);
}
/**
* @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 baseUrl The base URL of the representation.
* @param segmentBase The segment base underlying the representation.
* @param inbandEventStreams The in-band event streams in the representation. May be null.
* @param c
ustomCacheKey A custom value
to be returned from {@link #getCacheKey()}, or null.
* @param c
acheKey An optional key
to be returned from {@link #getCacheKey()}, or null.
* @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown.
*/
public
SingleSegmentRepresentation
(
String
contentId
,
long
revisionId
,
Format
format
,
String
baseUrl
,
SingleSegmentBase
segmentBase
,
List
<
Descriptor
>
inbandEventStreams
,
String
customCacheKey
,
long
contentLength
)
{
public
SingleSegmentRepresentation
(
long
revisionId
,
Format
format
,
String
baseUrl
,
SingleSegmentBase
segmentBase
,
List
<
Descriptor
>
inbandEventStreams
,
String
cacheKey
,
long
contentLength
)
{
super
(
revisionId
,
format
,
baseUrl
,
segmentBase
,
inbandEventStreams
);
this
.
uri
=
Uri
.
parse
(
baseUrl
);
this
.
indexUri
=
segmentBase
.
getIndex
();
this
.
cacheKey
=
customCacheKey
!=
null
?
customCacheKey
:
contentId
!=
null
?
contentId
+
"."
+
format
.
id
+
"."
+
revisionId
:
null
;
this
.
cacheKey
=
cacheKey
;
this
.
contentLength
=
contentLength
;
// If we have an index uri then the index is defined externally, and we shouldn't return one
// directly. If we don't, then we can't do better than an index defining a single segment.
...
...
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashUtilTest.java
View file @
f1966308
...
...
@@ -89,7 +89,7 @@ public final class DashUtilTest {
if
(
drmInitData
!=
null
)
{
format
=
format
.
copyWithDrmInitData
(
drmInitData
);
}
return
Representation
.
newInstance
(
""
,
0
,
format
,
""
,
new
SingleSegmentBase
());
return
Representation
.
newInstance
(
0
,
format
,
""
,
new
SingleSegmentBase
());
}
private
static
DrmInitData
newDrmInitData
()
{
...
...
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestTest.java
View file @
f1966308
...
...
@@ -214,7 +214,8 @@ public class DashManifestTest {
}
private
static
Representation
newRepresentation
()
{
return
Representation
.
newInstance
(
""
,
0
,
DUMMY_FORMAT
,
""
,
DUMMY_SEGMENT_BASE
);
return
Representation
.
newInstance
(
/* revisionId= */
0
,
DUMMY_FORMAT
,
/* baseUrl= */
""
,
DUMMY_SEGMENT_BASE
);
}
private
static
DashManifest
newDashManifest
(
int
duration
,
Period
...
periods
)
{
...
...
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/RepresentationTest.java
deleted
100644 → 0
View file @
500b1faf
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer2
.
source
.
dash
.
manifest
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.robolectric.RobolectricTestRunner
;
/** Unit test for {@link Representation}. */
@RunWith
(
RobolectricTestRunner
.
class
)
public
class
RepresentationTest
{
@Test
public
void
testGetCacheKey
()
{
String
uri
=
"http://www.google.com"
;
SegmentBase
base
=
new
SingleSegmentBase
(
new
RangedUri
(
null
,
0
,
1
),
1
,
0
,
1
,
1
);
Format
format
=
createVideoContainerFormat
(
"0"
);
Representation
representation
=
Representation
.
newInstance
(
"test_stream_1"
,
3
,
format
,
uri
,
base
);
assertThat
(
representation
.
getCacheKey
()).
isEqualTo
(
"test_stream_1.0.3"
);
format
=
createVideoContainerFormat
(
"150"
);
representation
=
Representation
.
newInstance
(
"test_stream_1"
,
Representation
.
REVISION_ID_DEFAULT
,
format
,
uri
,
base
);
assertThat
(
representation
.
getCacheKey
()).
isEqualTo
(
"test_stream_1.150.-1"
);
}
private
static
Format
createVideoContainerFormat
(
String
id
)
{
return
Format
.
createVideoContainerFormat
(
id
,
"label"
,
/* containerMimeType= */
MimeTypes
.
APPLICATION_MP4
,
/* sampleMimeType= */
MimeTypes
.
VIDEO_H264
,
/* codecs= */
null
,
/* bitrate= */
2500000
,
/* width= */
1920
,
/* height= */
1080
,
/* frameRate= */
Format
.
NO_VALUE
,
/* initializationData= */
null
,
/* selectionFlags= */
0
);
}
}
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