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
b4a1d55f
authored
Aug 12, 2019
by
sr1990
Committed by
Toni
Sep 05, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Support negative value of the @r attrbute of S in SegmentTimeline element
parent
b57c5561
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 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/DashManifestParser.java
View file @
b4a1d55f
...
@@ -237,7 +237,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -237,7 +237,7 @@ public class DashManifestParser extends DefaultHandler
seenFirstBaseUrl
=
true
;
seenFirstBaseUrl
=
true
;
}
}
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"AdaptationSet"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"AdaptationSet"
))
{
adaptationSets
.
add
(
parseAdaptationSet
(
xpp
,
baseUrl
,
segmentBase
));
adaptationSets
.
add
(
parseAdaptationSet
(
xpp
,
baseUrl
,
segmentBase
,
durationMs
));
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"EventStream"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"EventStream"
))
{
eventStreams
.
add
(
parseEventStream
(
xpp
));
eventStreams
.
add
(
parseEventStream
(
xpp
));
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentBase"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentBase"
))
{
...
@@ -245,7 +245,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -245,7 +245,7 @@ public class DashManifestParser extends DefaultHandler
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentList"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentList"
))
{
segmentBase
=
parseSegmentList
(
xpp
,
null
);
segmentBase
=
parseSegmentList
(
xpp
,
null
);
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTemplate"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTemplate"
))
{
segmentBase
=
parseSegmentTemplate
(
xpp
,
null
,
Collections
.
emptyList
());
segmentBase
=
parseSegmentTemplate
(
xpp
,
null
,
Collections
.
emptyList
()
,
durationMs
);
}
else
{
}
else
{
maybeSkipTag
(
xpp
);
maybeSkipTag
(
xpp
);
}
}
...
@@ -262,7 +262,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -262,7 +262,7 @@ public class DashManifestParser extends DefaultHandler
// AdaptationSet parsing.
// AdaptationSet parsing.
protected
AdaptationSet
parseAdaptationSet
(
protected
AdaptationSet
parseAdaptationSet
(
XmlPullParser
xpp
,
String
baseUrl
,
@Nullable
SegmentBase
segmentBase
)
XmlPullParser
xpp
,
String
baseUrl
,
@Nullable
SegmentBase
segmentBase
,
long
periodDurationMs
)
throws
XmlPullParserException
,
IOException
{
throws
XmlPullParserException
,
IOException
{
int
id
=
parseInt
(
xpp
,
"id"
,
AdaptationSet
.
ID_UNSET
);
int
id
=
parseInt
(
xpp
,
"id"
,
AdaptationSet
.
ID_UNSET
);
int
contentType
=
parseContentType
(
xpp
);
int
contentType
=
parseContentType
(
xpp
);
...
@@ -328,7 +328,8 @@ public class DashManifestParser extends DefaultHandler
...
@@ -328,7 +328,8 @@ public class DashManifestParser extends DefaultHandler
roleDescriptors
,
roleDescriptors
,
accessibilityDescriptors
,
accessibilityDescriptors
,
supplementalProperties
,
supplementalProperties
,
segmentBase
);
segmentBase
,
periodDurationMs
);
contentType
=
checkContentTypeConsistency
(
contentType
,
contentType
=
checkContentTypeConsistency
(
contentType
,
getContentType
(
representationInfo
.
format
));
getContentType
(
representationInfo
.
format
));
representationInfos
.
add
(
representationInfo
);
representationInfos
.
add
(
representationInfo
);
...
@@ -338,7 +339,8 @@ public class DashManifestParser extends DefaultHandler
...
@@ -338,7 +339,8 @@ public class DashManifestParser extends DefaultHandler
segmentBase
=
parseSegmentList
(
xpp
,
(
SegmentList
)
segmentBase
);
segmentBase
=
parseSegmentList
(
xpp
,
(
SegmentList
)
segmentBase
);
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTemplate"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTemplate"
))
{
segmentBase
=
segmentBase
=
parseSegmentTemplate
(
xpp
,
(
SegmentTemplate
)
segmentBase
,
supplementalProperties
);
parseSegmentTemplate
(
xpp
,
(
SegmentTemplate
)
segmentBase
,
supplementalProperties
,
periodDurationMs
);
}
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
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
))
{
...
@@ -492,7 +494,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -492,7 +494,7 @@ public class DashManifestParser extends DefaultHandler
List
<
Descriptor
>
adaptationSetRoleDescriptors
,
List
<
Descriptor
>
adaptationSetRoleDescriptors
,
List
<
Descriptor
>
adaptationSetAccessibilityDescriptors
,
List
<
Descriptor
>
adaptationSetAccessibilityDescriptors
,
List
<
Descriptor
>
adaptationSetSupplementalProperties
,
List
<
Descriptor
>
adaptationSetSupplementalProperties
,
@Nullable
SegmentBase
segmentBase
)
@Nullable
SegmentBase
segmentBase
,
long
periodDurationMs
)
throws
XmlPullParserException
,
IOException
{
throws
XmlPullParserException
,
IOException
{
String
id
=
xpp
.
getAttributeValue
(
null
,
"id"
);
String
id
=
xpp
.
getAttributeValue
(
null
,
"id"
);
int
bandwidth
=
parseInt
(
xpp
,
"bandwidth"
,
Format
.
NO_VALUE
);
int
bandwidth
=
parseInt
(
xpp
,
"bandwidth"
,
Format
.
NO_VALUE
);
...
@@ -526,7 +528,8 @@ public class DashManifestParser extends DefaultHandler
...
@@ -526,7 +528,8 @@ public class DashManifestParser extends DefaultHandler
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTemplate"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTemplate"
))
{
segmentBase
=
segmentBase
=
parseSegmentTemplate
(
parseSegmentTemplate
(
xpp
,
(
SegmentTemplate
)
segmentBase
,
adaptationSetSupplementalProperties
);
xpp
,
(
SegmentTemplate
)
segmentBase
,
adaptationSetSupplementalProperties
,
periodDurationMs
);
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"ContentProtection"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"ContentProtection"
))
{
Pair
<
String
,
SchemeData
>
contentProtection
=
parseContentProtection
(
xpp
);
Pair
<
String
,
SchemeData
>
contentProtection
=
parseContentProtection
(
xpp
);
if
(
contentProtection
.
first
!=
null
)
{
if
(
contentProtection
.
first
!=
null
)
{
...
@@ -735,7 +738,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -735,7 +738,7 @@ public class DashManifestParser extends DefaultHandler
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"Initialization"
))
{
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"Initialization"
))
{
initialization
=
parseInitialization
(
xpp
);
initialization
=
parseInitialization
(
xpp
);
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTimeline"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTimeline"
))
{
timeline
=
parseSegmentTimeline
(
xpp
);
timeline
=
parseSegmentTimeline
(
xpp
,
timescale
,
duration
);
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentURL"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentURL"
))
{
if
(
segments
==
null
)
{
if
(
segments
==
null
)
{
segments
=
new
ArrayList
<>();
segments
=
new
ArrayList
<>();
...
@@ -771,7 +774,8 @@ public class DashManifestParser extends DefaultHandler
...
@@ -771,7 +774,8 @@ public class DashManifestParser extends DefaultHandler
protected
SegmentTemplate
parseSegmentTemplate
(
protected
SegmentTemplate
parseSegmentTemplate
(
XmlPullParser
xpp
,
XmlPullParser
xpp
,
@Nullable
SegmentTemplate
parent
,
@Nullable
SegmentTemplate
parent
,
List
<
Descriptor
>
adaptationSetSupplementalProperties
)
List
<
Descriptor
>
adaptationSetSupplementalProperties
,
long
periodDurationMs
)
throws
XmlPullParserException
,
IOException
{
throws
XmlPullParserException
,
IOException
{
long
timescale
=
parseLong
(
xpp
,
"timescale"
,
parent
!=
null
?
parent
.
timescale
:
1
);
long
timescale
=
parseLong
(
xpp
,
"timescale"
,
parent
!=
null
?
parent
.
timescale
:
1
);
long
presentationTimeOffset
=
parseLong
(
xpp
,
"presentationTimeOffset"
,
long
presentationTimeOffset
=
parseLong
(
xpp
,
"presentationTimeOffset"
,
...
@@ -794,7 +798,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -794,7 +798,7 @@ public class DashManifestParser extends DefaultHandler
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"Initialization"
))
{
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"Initialization"
))
{
initialization
=
parseInitialization
(
xpp
);
initialization
=
parseInitialization
(
xpp
);
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTimeline"
))
{
}
else
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"SegmentTimeline"
))
{
timeline
=
parseSegmentTimeline
(
xpp
);
timeline
=
parseSegmentTimeline
(
xpp
,
timescale
,
periodDurationMs
);
}
else
{
}
else
{
maybeSkipTag
(
xpp
);
maybeSkipTag
(
xpp
);
}
}
...
@@ -989,7 +993,8 @@ public class DashManifestParser extends DefaultHandler
...
@@ -989,7 +993,8 @@ public class DashManifestParser extends DefaultHandler
return
new
EventMessage
(
schemeIdUri
,
value
,
durationMs
,
id
,
messageData
);
return
new
EventMessage
(
schemeIdUri
,
value
,
durationMs
,
id
,
messageData
);
}
}
protected
List
<
SegmentTimelineElement
>
parseSegmentTimeline
(
XmlPullParser
xpp
)
protected
List
<
SegmentTimelineElement
>
parseSegmentTimeline
(
XmlPullParser
xpp
,
long
timescale
,
long
periodDurationMs
)
throws
XmlPullParserException
,
IOException
{
throws
XmlPullParserException
,
IOException
{
List
<
SegmentTimelineElement
>
segmentTimeline
=
new
ArrayList
<>();
List
<
SegmentTimelineElement
>
segmentTimeline
=
new
ArrayList
<>();
long
elapsedTime
=
0
;
long
elapsedTime
=
0
;
...
@@ -998,7 +1003,12 @@ public class DashManifestParser extends DefaultHandler
...
@@ -998,7 +1003,12 @@ public class DashManifestParser extends DefaultHandler
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"S"
))
{
if
(
XmlPullParserUtil
.
isStartTag
(
xpp
,
"S"
))
{
elapsedTime
=
parseLong
(
xpp
,
"t"
,
elapsedTime
);
elapsedTime
=
parseLong
(
xpp
,
"t"
,
elapsedTime
);
long
duration
=
parseLong
(
xpp
,
"d"
,
C
.
TIME_UNSET
);
long
duration
=
parseLong
(
xpp
,
"d"
,
C
.
TIME_UNSET
);
int
count
=
1
+
parseInt
(
xpp
,
"r"
,
0
);
//if repeat is -1 : length of each segment = duration / timescale and
// number of segments = periodDuration / length of each segment
int
repeat
=
parseInt
(
xpp
,
"r"
,
0
);
int
count
=
repeat
!=
-
1
?
1
+
repeat
:
(
int
)
(((
periodDurationMs
/
1000
)
*
timescale
)
/
duration
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
segmentTimeline
.
add
(
buildSegmentTimelineElement
(
elapsedTime
,
duration
));
segmentTimeline
.
add
(
buildSegmentTimelineElement
(
elapsedTime
,
duration
));
elapsedTime
+=
duration
;
elapsedTime
+=
duration
;
...
...
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