From 7dfebc2e11f4d696e0e729adafe7c8a469bee669 Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Wed, 26 Nov 2014 11:22:54 +0000 Subject: [PATCH 1/2] Make default retry count public. --- .../google/android/exoplayer/chunk/ChunkSampleSource.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java b/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java index 263a47a5a5..f16fc4c4df 100644 --- a/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java +++ b/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java @@ -134,14 +134,17 @@ public class ChunkSampleSource implements SampleSource, Loader.Callback { } + /** + * The default minimum number of times to retry loading data prior to failing. + */ + public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 1; + private static final int STATE_UNPREPARED = 0; private static final int STATE_PREPARED = 1; private static final int STATE_ENABLED = 2; private static final int NO_RESET_PENDING = -1; - private static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 1; - private final int eventSourceId; private final LoadControl loadControl; private final ChunkSource chunkSource; From ab00a4da03bfc5ddcc2ed29b0be31cc6308dabe7 Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Wed, 26 Nov 2014 11:23:15 +0000 Subject: [PATCH 2/2] Allow non-strict webvtt parsing. --- .../exoplayer/text/webvtt/WebvttParser.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttParser.java b/library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttParser.java index baace215f5..036c6116a1 100644 --- a/library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttParser.java +++ b/library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttParser.java @@ -63,6 +63,16 @@ public class WebvttParser implements SubtitleParser { private static final Pattern MEDIA_TIMESTAMP_OFFSET = Pattern.compile(OFFSET + "\\d+"); private static final Pattern MEDIA_TIMESTAMP = Pattern.compile("MPEGTS:\\d+"); + private final boolean strictParsing; + + public WebvttParser() { + this(true); + } + + public WebvttParser(boolean strictParsing) { + this.strictParsing = strictParsing; + } + @Override public WebvttSubtitle parse(InputStream inputStream, String inputEncoding, long startTimeUs) throws IOException { @@ -108,7 +118,7 @@ public class WebvttParser implements SubtitleParser { Matcher matcher = WEBVTT_METADATA_HEADER.matcher(line); if (!matcher.find()) { - throw new ParserException("Expected webvtt metadata header; got: " + line); + handleNoncompliantLine(line); } if (line.startsWith("X-TIMESTAMP-MAP")) { @@ -182,6 +192,12 @@ public class WebvttParser implements SubtitleParser { return startTimeUs; } + protected void handleNoncompliantLine(String line) throws ParserException { + if (strictParsing) { + throw new ParserException("Unexpected line: " + line); + } + } + private static long parseTimestampUs(String s) throws NumberFormatException { if (!s.matches(WEBVTT_TIMESTAMP_STRING)) { throw new NumberFormatException("has invalid format");