mirror of
https://github.com/androidx/media.git
synced 2025-05-04 22:20:47 +08:00
Replace java.text.ParseException for ExoPlayer's ParserException
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138628300
This commit is contained in:
parent
8236efe6a5
commit
b1fe274df3
@ -16,7 +16,6 @@
|
||||
package com.google.android.exoplayer2.util;
|
||||
|
||||
import com.google.android.exoplayer2.testutil.TestUtil;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@ -140,7 +139,7 @@ public class UtilTest extends TestCase {
|
||||
assertEquals(1500L, Util.parseXsDuration("PT1.500S"));
|
||||
}
|
||||
|
||||
public void testParseXsDateTime() throws ParseException {
|
||||
public void testParseXsDateTime() throws Exception {
|
||||
assertEquals(1403219262000L, Util.parseXsDateTime("2014-06-19T23:07:42"));
|
||||
assertEquals(1407322800000L, Util.parseXsDateTime("2014-08-06T11:00:00Z"));
|
||||
}
|
||||
|
@ -314,8 +314,8 @@ public final class DashMediaSource implements MediaSource {
|
||||
try {
|
||||
long utcTimestamp = Util.parseXsDateTime(timingElement.value);
|
||||
onUtcTimestampResolved(utcTimestamp - manifestLoadEndTimestamp);
|
||||
} catch (ParseException e) {
|
||||
onUtcTimestampResolutionError(new ParserException(e));
|
||||
} catch (ParserException e) {
|
||||
onUtcTimestampResolutionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -648,11 +648,7 @@ public final class DashMediaSource implements MediaSource {
|
||||
@Override
|
||||
public Long parse(Uri uri, InputStream inputStream) throws IOException {
|
||||
String firstLine = new BufferedReader(new InputStreamReader(inputStream)).readLine();
|
||||
try {
|
||||
return Util.parseXsDateTime(firstLine);
|
||||
} catch (ParseException e) {
|
||||
throw new ParserException(e);
|
||||
}
|
||||
return Util.parseXsDateTime(firstLine);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ import com.google.android.exoplayer2.util.Util;
|
||||
import com.google.android.exoplayer2.util.XmlPullParserUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -98,13 +97,13 @@ public class DashManifestParser extends DefaultHandler
|
||||
"inputStream does not contain a valid media presentation description");
|
||||
}
|
||||
return parseMediaPresentationDescription(xpp, uri.toString());
|
||||
} catch (XmlPullParserException | ParseException e) {
|
||||
} catch (XmlPullParserException e) {
|
||||
throw new ParserException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected DashManifest parseMediaPresentationDescription(XmlPullParser xpp,
|
||||
String baseUrl) throws XmlPullParserException, IOException, ParseException {
|
||||
String baseUrl) throws XmlPullParserException, IOException {
|
||||
long availabilityStartTime = parseDateTime(xpp, "availabilityStartTime", C.TIME_UNSET);
|
||||
long durationMs = parseDuration(xpp, "mediaPresentationDuration", C.TIME_UNSET);
|
||||
long minBufferTimeMs = parseDuration(xpp, "minBufferTime", C.TIME_UNSET);
|
||||
@ -815,7 +814,7 @@ public class DashManifestParser extends DefaultHandler
|
||||
}
|
||||
|
||||
protected static long parseDateTime(XmlPullParser xpp, String name, long defaultValue)
|
||||
throws ParseException {
|
||||
throws ParserException {
|
||||
String value = xpp.getAttributeValue(null, name);
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
|
@ -31,6 +31,7 @@ import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
|
||||
import com.google.android.exoplayer2.ParserException;
|
||||
import com.google.android.exoplayer2.upstream.DataSource;
|
||||
import com.google.android.exoplayer2.upstream.DataSpec;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -40,7 +41,6 @@ import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
@ -433,11 +433,12 @@ public final class Util {
|
||||
*
|
||||
* @param value The attribute value to decode.
|
||||
* @return The parsed timestamp in milliseconds since the epoch.
|
||||
* @throws ParserException if an error occurs parsing the dateTime attribute value.
|
||||
*/
|
||||
public static long parseXsDateTime(String value) throws ParseException {
|
||||
public static long parseXsDateTime(String value) throws ParserException {
|
||||
Matcher matcher = XS_DATE_TIME_PATTERN.matcher(value);
|
||||
if (!matcher.matches()) {
|
||||
throw new ParseException("Invalid date/time format: " + value, 0);
|
||||
throw new ParserException("Invalid date/time format: " + value);
|
||||
}
|
||||
|
||||
int timezoneShift;
|
||||
|
Loading…
x
Reference in New Issue
Block a user