mirror of
https://github.com/androidx/media.git
synced 2025-05-10 00:59:51 +08:00
Iso8601Parser improved to be able to parse timestamp offsets from UTC
This commit is contained in:
parent
ad16efdf56
commit
28d709aa8f
@ -963,10 +963,9 @@ 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 = "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_WITH_OFFSET_FORMAT = "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_WITH_OFFSET_FORMAT_REGEX_PATTERN = ".*[+\\-]\\d{2}:\\d{2}$";
|
||||||
private static final String ISO_8601_FORMAT_2_REGEX_PATTERN = ".*[+\\-]\\d{2}:\\d{2}$";
|
private static final String ISO_8601_WITH_OFFSET_FORMAT_REGEX_PATTERN_2 = ".*[+\\-]\\d{4}$";
|
||||||
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 {
|
||||||
@ -975,10 +974,10 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
if (firstLine != null) {
|
if (firstLine != null) {
|
||||||
//determine format pattern
|
//determine format pattern
|
||||||
String formatPattern;
|
String formatPattern;
|
||||||
if (firstLine.matches(ISO_8601_FORMAT_2_REGEX_PATTERN)) {
|
if (firstLine.matches(ISO_8601_WITH_OFFSET_FORMAT_REGEX_PATTERN)) {
|
||||||
formatPattern = ISO_8601_FORMAT_2;
|
formatPattern = ISO_8601_WITH_OFFSET_FORMAT;
|
||||||
} else if (firstLine.matches(ISO_8601_FORMAT_3_REGEX_PATTERN)) {
|
} else if (firstLine.matches(ISO_8601_WITH_OFFSET_FORMAT_REGEX_PATTERN_2)) {
|
||||||
formatPattern = ISO_8601_FORMAT_3;
|
formatPattern = ISO_8601_WITH_OFFSET_FORMAT;
|
||||||
} else {
|
} else {
|
||||||
formatPattern = ISO_8601_FORMAT;
|
formatPattern = ISO_8601_FORMAT;
|
||||||
}
|
}
|
||||||
@ -995,6 +994,7 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
throw new ParserException("Unable to parse ISO 8601. Input value is null");
|
throw new ParserException("Unable to parse ISO 8601. Input value is null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user