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
e175bf9e
authored
Dec 04, 2017
by
Pavel Stambrecht
Committed by
Oliver Woodman
Dec 12, 2017
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Iso8601Parser improved to be able to parse timestamp offsets from UTC
parent
d3fd2d1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
8 deletions
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java
View file @
e175bf9e
...
@@ -934,19 +934,39 @@ public final class DashMediaSource implements MediaSource {
...
@@ -934,19 +934,39 @@ public final class DashMediaSource implements MediaSource {
private
static
final
class
Iso8601Parser
implements
ParsingLoadable
.
Parser
<
Long
>
{
private
static
final
class
Iso8601Parser
implements
ParsingLoadable
.
Parser
<
Long
>
{
private
static
final
String
ISO_8601_FORMAT
=
"yyyy-MM-dd'T'HH:mm:ss'Z'"
;
private
static
final
String
ISO_8601_FORMAT_2
=
"yyyy-MM-dd'T'HH:mm:ssZ"
;
private
static
final
String
ISO_8601_FORMAT_3
=
"yyyy-MM-dd'T'HH:mm:ssZ"
;
private
static
final
String
ISO_8601_FORMAT_2_REGEX_PATTERN
=
".*[+\\-]\\d{2}:\\d{2}$"
;
private
static
final
String
ISO_8601_FORMAT_3_REGEX_PATTERN
=
".*[+\\-]\\d{4}$"
;
@Override
@Override
public
Long
parse
(
Uri
uri
,
InputStream
inputStream
)
throws
IOException
{
public
Long
parse
(
Uri
uri
,
InputStream
inputStream
)
throws
IOException
{
String
firstLine
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
)).
readLine
();
String
firstLine
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
)).
readLine
();
try
{
// TODO: It may be necessary to handle timestamp offsets from UTC.
if
(
firstLine
!=
null
)
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
,
Locale
.
US
);
//determine format pattern
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
String
formatPattern
;
return
format
.
parse
(
firstLine
).
getTime
();
if
(
firstLine
.
matches
(
ISO_8601_FORMAT_2_REGEX_PATTERN
))
{
}
catch
(
ParseException
e
)
{
formatPattern
=
ISO_8601_FORMAT_2
;
throw
new
ParserException
(
e
);
}
else
if
(
firstLine
.
matches
(
ISO_8601_FORMAT_3_REGEX_PATTERN
))
{
formatPattern
=
ISO_8601_FORMAT_3
;
}
else
{
formatPattern
=
ISO_8601_FORMAT
;
}
//parse
try
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
formatPattern
,
Locale
.
US
);
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
return
format
.
parse
(
firstLine
).
getTime
();
}
catch
(
ParseException
e
)
{
throw
new
ParserException
(
e
);
}
}
else
{
throw
new
ParserException
(
"Unable to parse ISO 8601. Input value is null"
);
}
}
}
}
}
}
}
}
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