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
0249058c
authored
Oct 07, 2019
by
olly
Committed by
Oliver Woodman
Oct 13, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Parse Label elements for adaptation sets
Issue: #6297 PiperOrigin-RevId: 273297284
parent
904e3f8d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
148 additions
and
13 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/Format.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
library/dash/src/test/assets/sample_mpd_labels
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java
RELEASENOTES.md
View file @
0249058c
...
@@ -5,7 +5,9 @@
...
@@ -5,7 +5,9 @@
*
Add
`Player.onPlaybackSuppressionReasonChanged`
to allow listeners to
*
Add
`Player.onPlaybackSuppressionReasonChanged`
to allow listeners to
detect playbacks suppressions (e.g. audio focus loss) directly
detect playbacks suppressions (e.g. audio focus loss) directly
(
[
#6203
](
https://github.com/google/ExoPlayer/issues/6203
)
).
(
[
#6203
](
https://github.com/google/ExoPlayer/issues/6203
)
).
*
Expose the raw ICY metadata through
`IcyInfo`
*
DASH: Support
`Label`
elements
(
[
#6297
](
https://github.com/google/ExoPlayer/issues/6297
)
).
*
Metadata: Expose the raw ICY metadata through
`IcyInfo`
(
[
#6476
](
https://github.com/google/ExoPlayer/issues/6476
)
).
(
[
#6476
](
https://github.com/google/ExoPlayer/issues/6476
)
).
*
UI
*
UI
*
Setting
`app:played_color`
on
`PlayerView`
and
`PlayerControlView`
no longer
*
Setting
`app:played_color`
on
`PlayerView`
and
`PlayerControlView`
no longer
...
...
library/core/src/main/java/com/google/android/exoplayer2/Format.java
View file @
0249058c
...
@@ -1066,6 +1066,38 @@ public final class Format implements Parcelable {
...
@@ -1066,6 +1066,38 @@ public final class Format implements Parcelable {
accessibilityChannel
);
accessibilityChannel
);
}
}
public
Format
copyWithLabel
(
@Nullable
String
label
)
{
return
new
Format
(
id
,
label
,
selectionFlags
,
roleFlags
,
bitrate
,
codecs
,
metadata
,
containerMimeType
,
sampleMimeType
,
maxInputSize
,
initializationData
,
drmInitData
,
subsampleOffsetUs
,
width
,
height
,
frameRate
,
rotationDegrees
,
pixelWidthHeightRatio
,
projectionData
,
stereoMode
,
colorInfo
,
channelCount
,
sampleRate
,
pcmEncoding
,
encoderDelay
,
encoderPadding
,
language
,
accessibilityChannel
);
}
public
Format
copyWithContainerInfo
(
public
Format
copyWithContainerInfo
(
@Nullable
String
id
,
@Nullable
String
id
,
@Nullable
String
label
,
@Nullable
String
label
,
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
View file @
0249058c
...
@@ -313,7 +313,6 @@ public class DashManifestParser extends DefaultHandler
...
@@ -313,7 +313,6 @@ public class DashManifestParser extends DefaultHandler
parseRepresentation
(
parseRepresentation
(
xpp
,
xpp
,
baseUrl
,
baseUrl
,
label
,
mimeType
,
mimeType
,
codecs
,
codecs
,
width
,
width
,
...
@@ -338,6 +337,8 @@ public class DashManifestParser extends DefaultHandler
...
@@ -338,6 +337,8 @@ public class DashManifestParser extends DefaultHandler
parseSegmentTemplate
(
xpp
,
(
SegmentTemplate
)
segmentBase
,
supplementalProperties
);
parseSegmentTemplate
(
xpp
,
(
SegmentTemplate
)
segmentBase
,
supplementalProperties
);
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"InbandEventStream"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"InbandEventStream"
))
{
inbandEventStreams
.
add
(
parseDescriptor
(
xpp
,
"InbandEventStream"
));
inbandEventStreams
.
add
(
parseDescriptor
(
xpp
,
"InbandEventStream"
));
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"Label"
))
{
label
=
parseLabel
(
xpp
);
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
))
{
parseAdaptationSetChild
(
xpp
);
parseAdaptationSetChild
(
xpp
);
}
}
...
@@ -348,7 +349,11 @@ public class DashManifestParser extends DefaultHandler
...
@@ -348,7 +349,11 @@ public class DashManifestParser extends DefaultHandler
for
(
int
i
=
0
;
i
<
representationInfos
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
representationInfos
.
size
();
i
++)
{
representations
.
add
(
representations
.
add
(
buildRepresentation
(
buildRepresentation
(
representationInfos
.
get
(
i
),
drmSchemeType
,
drmSchemeDatas
,
inbandEventStreams
));
representationInfos
.
get
(
i
),
label
,
drmSchemeType
,
drmSchemeDatas
,
inbandEventStreams
));
}
}
return
buildAdaptationSet
(
id
,
contentType
,
representations
,
accessibilityDescriptors
,
return
buildAdaptationSet
(
id
,
contentType
,
representations
,
accessibilityDescriptors
,
...
@@ -484,7 +489,6 @@ public class DashManifestParser extends DefaultHandler
...
@@ -484,7 +489,6 @@ public class DashManifestParser extends DefaultHandler
protected
RepresentationInfo
parseRepresentation
(
protected
RepresentationInfo
parseRepresentation
(
XmlPullParser
xpp
,
XmlPullParser
xpp
,
String
baseUrl
,
String
baseUrl
,
String
label
,
String
adaptationSetMimeType
,
String
adaptationSetMimeType
,
String
adaptationSetCodecs
,
String
adaptationSetCodecs
,
int
adaptationSetWidth
,
int
adaptationSetWidth
,
...
@@ -551,7 +555,6 @@ public class DashManifestParser extends DefaultHandler
...
@@ -551,7 +555,6 @@ public class DashManifestParser extends DefaultHandler
Format
format
=
Format
format
=
buildFormat
(
buildFormat
(
id
,
id
,
label
,
mimeType
,
mimeType
,
width
,
width
,
height
,
height
,
...
@@ -572,7 +575,6 @@ public class DashManifestParser extends DefaultHandler
...
@@ -572,7 +575,6 @@ public class DashManifestParser extends DefaultHandler
protected
Format
buildFormat
(
protected
Format
buildFormat
(
String
id
,
String
id
,
String
label
,
String
containerMimeType
,
String
containerMimeType
,
int
width
,
int
width
,
int
height
,
int
height
,
...
@@ -596,7 +598,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -596,7 +598,7 @@ public class DashManifestParser extends DefaultHandler
if
(
MimeTypes
.
isVideo
(
sampleMimeType
))
{
if
(
MimeTypes
.
isVideo
(
sampleMimeType
))
{
return
Format
.
createVideoContainerFormat
(
return
Format
.
createVideoContainerFormat
(
id
,
id
,
labe
l
,
/* label= */
nul
l
,
containerMimeType
,
containerMimeType
,
sampleMimeType
,
sampleMimeType
,
codecs
,
codecs
,
...
@@ -611,7 +613,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -611,7 +613,7 @@ public class DashManifestParser extends DefaultHandler
}
else
if
(
MimeTypes
.
isAudio
(
sampleMimeType
))
{
}
else
if
(
MimeTypes
.
isAudio
(
sampleMimeType
))
{
return
Format
.
createAudioContainerFormat
(
return
Format
.
createAudioContainerFormat
(
id
,
id
,
labe
l
,
/* label= */
nul
l
,
containerMimeType
,
containerMimeType
,
sampleMimeType
,
sampleMimeType
,
codecs
,
codecs
,
...
@@ -634,7 +636,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -634,7 +636,7 @@ public class DashManifestParser extends DefaultHandler
}
}
return
Format
.
createTextContainerFormat
(
return
Format
.
createTextContainerFormat
(
id
,
id
,
labe
l
,
/* label= */
nul
l
,
containerMimeType
,
containerMimeType
,
sampleMimeType
,
sampleMimeType
,
codecs
,
codecs
,
...
@@ -647,7 +649,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -647,7 +649,7 @@ public class DashManifestParser extends DefaultHandler
}
}
return
Format
.
createContainerFormat
(
return
Format
.
createContainerFormat
(
id
,
id
,
labe
l
,
/* label= */
nul
l
,
containerMimeType
,
containerMimeType
,
sampleMimeType
,
sampleMimeType
,
codecs
,
codecs
,
...
@@ -659,10 +661,14 @@ public class DashManifestParser extends DefaultHandler
...
@@ -659,10 +661,14 @@ public class DashManifestParser extends DefaultHandler
protected
Representation
buildRepresentation
(
protected
Representation
buildRepresentation
(
RepresentationInfo
representationInfo
,
RepresentationInfo
representationInfo
,
String
label
,
String
extraDrmSchemeType
,
String
extraDrmSchemeType
,
ArrayList
<
SchemeData
>
extraDrmSchemeDatas
,
ArrayList
<
SchemeData
>
extraDrmSchemeDatas
,
ArrayList
<
Descriptor
>
extraInbandEventStreams
)
{
ArrayList
<
Descriptor
>
extraInbandEventStreams
)
{
Format
format
=
representationInfo
.
format
;
Format
format
=
representationInfo
.
format
;
if
(
label
!=
null
)
{
format
=
format
.
copyWithLabel
(
label
);
}
String
drmSchemeType
=
representationInfo
.
drmSchemeType
!=
null
String
drmSchemeType
=
representationInfo
.
drmSchemeType
!=
null
?
representationInfo
.
drmSchemeType
:
extraDrmSchemeType
;
?
representationInfo
.
drmSchemeType
:
extraDrmSchemeType
;
ArrayList
<
SchemeData
>
drmSchemeDatas
=
representationInfo
.
drmSchemeDatas
;
ArrayList
<
SchemeData
>
drmSchemeDatas
=
representationInfo
.
drmSchemeDatas
;
...
@@ -1076,6 +1082,32 @@ public class DashManifestParser extends DefaultHandler
...
@@ -1076,6 +1082,32 @@ public class DashManifestParser extends DefaultHandler
return
new
ProgramInformation
(
title
,
source
,
copyright
,
moreInformationURL
,
lang
);
return
new
ProgramInformation
(
title
,
source
,
copyright
,
moreInformationURL
,
lang
);
}
}
/**
* Parses a Label element.
*
* @param xpp The parser from which to read.
* @throws XmlPullParserException If an error occurs parsing the element.
* @throws IOException If an error occurs reading the element.
* @return The parsed label.
*/
protected
String
parseLabel
(
XmlPullParser
xpp
)
throws
XmlPullParserException
,
IOException
{
return
parseText
(
xpp
,
"Label"
);
}
/**
* Parses a BaseURL element.
*
* @param xpp The parser from which to read.
* @param parentBaseUrl A base URL for resolving the parsed URL.
* @throws XmlPullParserException If an error occurs parsing the element.
* @throws IOException If an error occurs reading the element.
* @return The parsed and resolved URL.
*/
protected
String
parseBaseUrl
(
XmlPullParser
xpp
,
String
parentBaseUrl
)
throws
XmlPullParserException
,
IOException
{
return
UriUtil
.
resolve
(
parentBaseUrl
,
parseText
(
xpp
,
"BaseURL"
));
}
// AudioChannelConfiguration parsing.
// AudioChannelConfiguration parsing.
protected
int
parseAudioChannelConfiguration
(
XmlPullParser
xpp
)
protected
int
parseAudioChannelConfiguration
(
XmlPullParser
xpp
)
...
@@ -1427,10 +1459,18 @@ public class DashManifestParser extends DefaultHandler
...
@@ -1427,10 +1459,18 @@ public class DashManifestParser extends DefaultHandler
}
}
}
}
protected
static
String
parse
BaseUrl
(
XmlPullParser
xpp
,
String
parentBaseUr
l
)
protected
static
String
parse
Text
(
XmlPullParser
xpp
,
String
labe
l
)
throws
XmlPullParserException
,
IOException
{
throws
XmlPullParserException
,
IOException
{
xpp
.
next
();
String
text
=
""
;
return
UriUtil
.
resolve
(
parentBaseUrl
,
xpp
.
getText
());
do
{
xpp
.
next
();
if
(
xpp
.
getEventType
()
==
XmlPullParser
.
TEXT
)
{
text
=
xpp
.
getText
();
}
else
{
maybeSkipTag
(
xpp
);
}
}
while
(!
XmlPullParserUtil
.
isEndTag
(
xpp
,
label
));
return
text
;
}
}
protected
static
int
parseInt
(
XmlPullParser
xpp
,
String
name
,
int
defaultValue
)
{
protected
static
int
parseInt
(
XmlPullParser
xpp
,
String
name
,
int
defaultValue
)
{
...
...
library/dash/src/test/assets/sample_mpd_labels
0 → 100644
View file @
0249058c
<?xml version="1.0" encoding="UTF-8"?>
<MPD
type=
"static"
duration=
"1s"
mediaPresentationDuration=
"PT1S"
>
<Period>
<SegmentTemplate
startNumber=
"0"
timescale=
"1000"
media=
"sq/$Number$"
>
<SegmentTimeline>
<S
d=
"1000"
/>
</SegmentTimeline>
</SegmentTemplate>
<AdaptationSet
id=
"0"
mimeType=
"audio/mp4"
subsegmentAlignment=
"true"
label=
"audio label"
>
<Representation
id=
"0"
codecs=
"mp4a.40.2"
audioSamplingRate=
"48000"
bandwidth=
"144000"
>
<BaseURL>
https://test.com/0
</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet
id=
"1"
mimeType=
"video/mp4"
subsegmentAlignment=
"true"
label=
"ignored label"
>
<Representation
id=
"1"
codecs=
"avc1.4d4015"
width=
"426"
height=
"240"
bandwidth=
"258000"
>
<BaseURL>
https://test.com/1
</BaseURL>
</Representation>
<Label>
video label
</Label>
</AdaptationSet>
</Period>
</MPD>
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java
View file @
0249058c
...
@@ -40,6 +40,7 @@ public class DashManifestParserTest {
...
@@ -40,6 +40,7 @@ public class DashManifestParserTest {
private
static
final
String
SAMPLE_MPD_UNKNOWN_MIME_TYPE
=
"sample_mpd_unknown_mime_type"
;
private
static
final
String
SAMPLE_MPD_UNKNOWN_MIME_TYPE
=
"sample_mpd_unknown_mime_type"
;
private
static
final
String
SAMPLE_MPD_SEGMENT_TEMPLATE
=
"sample_mpd_segment_template"
;
private
static
final
String
SAMPLE_MPD_SEGMENT_TEMPLATE
=
"sample_mpd_segment_template"
;
private
static
final
String
SAMPLE_MPD_EVENT_STREAM
=
"sample_mpd_event_stream"
;
private
static
final
String
SAMPLE_MPD_EVENT_STREAM
=
"sample_mpd_event_stream"
;
private
static
final
String
SAMPLE_MPD_LABELS
=
"sample_mpd_labels"
;
private
static
final
String
NEXT_TAG_NAME
=
"Next"
;
private
static
final
String
NEXT_TAG_NAME
=
"Next"
;
private
static
final
String
NEXT_TAG
=
"<"
+
NEXT_TAG_NAME
+
"/>"
;
private
static
final
String
NEXT_TAG
=
"<"
+
NEXT_TAG_NAME
+
"/>"
;
...
@@ -173,6 +174,21 @@ public class DashManifestParserTest {
...
@@ -173,6 +174,21 @@ public class DashManifestParserTest {
}
}
@Test
@Test
public
void
parseMediaPresentationDescription_labels
()
throws
IOException
{
DashManifestParser
parser
=
new
DashManifestParser
();
DashManifest
manifest
=
parser
.
parse
(
Uri
.
parse
(
"https://example.com/test.mpd"
),
TestUtil
.
getInputStream
(
ApplicationProvider
.
getApplicationContext
(),
SAMPLE_MPD_LABELS
));
List
<
AdaptationSet
>
adaptationSets
=
manifest
.
getPeriod
(
0
).
adaptationSets
;
assertThat
(
adaptationSets
.
get
(
0
).
representations
.
get
(
0
).
format
.
label
).
isEqualTo
(
"audio label"
);
assertThat
(
adaptationSets
.
get
(
1
).
representations
.
get
(
0
).
format
.
label
).
isEqualTo
(
"video label"
);
}
@Test
public
void
parseSegmentTimeline_repeatCount
()
throws
Exception
{
public
void
parseSegmentTimeline_repeatCount
()
throws
Exception
{
DashManifestParser
parser
=
new
DashManifestParser
();
DashManifestParser
parser
=
new
DashManifestParser
();
XmlPullParser
xpp
=
XmlPullParserFactory
.
newInstance
().
newPullParser
();
XmlPullParser
xpp
=
XmlPullParserFactory
.
newInstance
().
newPullParser
();
...
@@ -248,6 +264,30 @@ public class DashManifestParserTest {
...
@@ -248,6 +264,30 @@ public class DashManifestParserTest {
}
}
@Test
@Test
public
void
parseLabel
()
throws
Exception
{
DashManifestParser
parser
=
new
DashManifestParser
();
XmlPullParser
xpp
=
XmlPullParserFactory
.
newInstance
().
newPullParser
();
xpp
.
setInput
(
new
StringReader
(
"<Label>test label</Label>"
+
NEXT_TAG
));
xpp
.
next
();
String
label
=
parser
.
parseLabel
(
xpp
);
assertThat
(
label
).
isEqualTo
(
"test label"
);
assertNextTag
(
xpp
);
}
@Test
public
void
parseLabel_noText
()
throws
Exception
{
DashManifestParser
parser
=
new
DashManifestParser
();
XmlPullParser
xpp
=
XmlPullParserFactory
.
newInstance
().
newPullParser
();
xpp
.
setInput
(
new
StringReader
(
"<Label/>"
+
NEXT_TAG
));
xpp
.
next
();
String
label
=
parser
.
parseLabel
(
xpp
);
assertThat
(
label
).
isEqualTo
(
""
);
assertNextTag
(
xpp
);
}
@Test
public
void
parseCea608AccessibilityChannel
()
{
public
void
parseCea608AccessibilityChannel
()
{
assertThat
(
assertThat
(
DashManifestParser
.
parseCea608AccessibilityChannel
(
DashManifestParser
.
parseCea608AccessibilityChannel
(
...
...
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