mirror of
https://github.com/samsonjs/media.git
synced 2026-04-09 11:55:46 +00:00
Replace one of the ParserException constructors with factory method
PiperOrigin-RevId: 377281961
This commit is contained in:
parent
bb2e0bc0ef
commit
36841d4f6f
4 changed files with 24 additions and 19 deletions
|
|
@ -22,6 +22,19 @@ import java.io.IOException;
|
|||
/** Thrown when an error occurs parsing media data and metadata. */
|
||||
public class ParserException extends IOException {
|
||||
|
||||
/**
|
||||
* Creates a new instance for which {@link #contentIsMalformed} is true and {@link #dataType} is
|
||||
* {@link C#DATA_TYPE_UNKNOWN}.
|
||||
*
|
||||
* @param message See {@link #getMessage()}.
|
||||
* @param cause See {@link #getCause()}.
|
||||
* @return The created instance.
|
||||
*/
|
||||
public static ParserException createForMalformedDataOfUnknownType(
|
||||
@Nullable String message, @Nullable Throwable cause) {
|
||||
return new ParserException(message, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance for which {@link #contentIsMalformed} is true and {@link #dataType} is
|
||||
* {@link C#DATA_TYPE_MEDIA}.
|
||||
|
|
@ -91,7 +104,11 @@ public class ParserException extends IOException {
|
|||
*/
|
||||
@Deprecated
|
||||
public ParserException() {
|
||||
this(/* message= */ null, /* cause= */ null);
|
||||
this(
|
||||
/* message= */ null,
|
||||
/* cause= */ null,
|
||||
/* contentIsMalformed= */ true,
|
||||
C.DATA_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -103,7 +120,7 @@ public class ParserException extends IOException {
|
|||
*/
|
||||
@Deprecated
|
||||
public ParserException(String message) {
|
||||
this(message, /* cause= */ null);
|
||||
this(message, /* cause= */ null, /* contentIsMalformed= */ true, C.DATA_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -115,20 +132,7 @@ public class ParserException extends IOException {
|
|||
*/
|
||||
@Deprecated
|
||||
public ParserException(Throwable cause) {
|
||||
this(/* message= */ null, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param message The detail message for the exception.
|
||||
* @param cause The cause for the exception.
|
||||
* @deprecated Use a factory method which initializes {@link #contentIsMalformed}, and {@link
|
||||
* #dataType} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public ParserException(@Nullable String message, @Nullable Throwable cause) {
|
||||
this(message, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_UNKNOWN);
|
||||
this(/* message= */ null, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
private ParserException(
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public final class AvcConfig {
|
|||
pixelWidthAspectRatio,
|
||||
codecs);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new ParserException("Error parsing AVC config", e);
|
||||
throw ParserException.createForMalformedContainer("Error parsing AVC config", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public final class HevcConfig {
|
|||
List<byte[]> initializationData = csdLength == 0 ? null : Collections.singletonList(buffer);
|
||||
return new HevcConfig(initializationData, lengthSizeMinusOne + 1, codecs);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new ParserException("Error parsing HEVC config", e);
|
||||
throw ParserException.createForMalformedContainer("Error parsing HEVC config", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ public final class DataSchemeDataSource extends BaseDataSource {
|
|||
try {
|
||||
data = Base64.decode(dataString, /* flags= */ Base64.DEFAULT);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ParserException("Error while parsing Base64 encoded string: " + dataString, e);
|
||||
throw ParserException.createForMalformedDataOfUnknownType(
|
||||
"Error while parsing Base64 encoded string: " + dataString, e);
|
||||
}
|
||||
} else {
|
||||
// TODO: Add support for other charsets.
|
||||
|
|
|
|||
Loading…
Reference in a new issue