mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add contentIsMalformed and dataType to ParserException
PiperOrigin-RevId: 374874272
This commit is contained in:
parent
08259f8987
commit
1c4294175f
1 changed files with 84 additions and 13 deletions
|
|
@ -15,30 +15,101 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2;
|
package com.google.android.exoplayer2;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import com.google.android.exoplayer2.C.DataType;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/** Thrown when an error occurs parsing media data and metadata. */
|
/** Thrown when an error occurs parsing media data and metadata. */
|
||||||
public class ParserException extends IOException {
|
public class ParserException extends IOException {
|
||||||
|
|
||||||
public ParserException() {
|
/**
|
||||||
super();
|
* Creates a new instance for which {@link #contentIsMalformed} is true and {@link #dataType} is
|
||||||
}
|
* {@link C#DATA_TYPE_MEDIA}.
|
||||||
|
*
|
||||||
/** @param message The detail message for the exception. */
|
* @param message See {@link #getMessage()}.
|
||||||
public ParserException(String message) {
|
* @param cause See {@link #getCause()}.
|
||||||
super(message);
|
* @return The created instance.
|
||||||
}
|
*/
|
||||||
|
public static ParserException createForMalformedContainer(
|
||||||
/** @param cause The cause for the exception. */
|
@Nullable String message, @Nullable Throwable cause) {
|
||||||
public ParserException(Throwable cause) {
|
return new ParserException(message, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_MEDIA);
|
||||||
super(cause);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates a new instance for which {@link #contentIsMalformed} is false and {@link #dataType} is
|
||||||
|
* {@link C#DATA_TYPE_MEDIA}.
|
||||||
|
*
|
||||||
|
* @param message See {@link #getMessage()}.
|
||||||
|
* @return The created instance.
|
||||||
|
*/
|
||||||
|
public static ParserException createForUnsupportedContainerFeature(@Nullable String message) {
|
||||||
|
return new ParserException(
|
||||||
|
message, /* cause= */ null, /* contentIsMalformed= */ false, C.DATA_TYPE_MEDIA);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the parsing error was caused by a bitstream not following the expected format. May be
|
||||||
|
* false when a parser encounters a legal condition which it does not support.
|
||||||
|
*/
|
||||||
|
public final boolean contentIsMalformed;
|
||||||
|
/** The {@link DataType data type} of the parsed bitstream. */
|
||||||
|
public final int dataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance.
|
||||||
|
*
|
||||||
|
* @deprecated Use a factory method which initializes {@link #contentIsMalformed}, and {@link
|
||||||
|
* #dataType} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ParserException() {
|
||||||
|
this(/* message= */ null, /* cause= */ null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance.
|
||||||
|
*
|
||||||
|
* @param message The detail message for the exception.
|
||||||
|
* @deprecated Use a factory method which initializes {@link #contentIsMalformed}, and {@link
|
||||||
|
* #dataType} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ParserException(String message) {
|
||||||
|
this(message, /* cause= */ null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance.
|
||||||
|
*
|
||||||
|
* @param cause The cause for the exception.
|
||||||
|
* @deprecated Use a factory method which initializes {@link #contentIsMalformed}, and {@link
|
||||||
|
* #dataType} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ParserException(Throwable cause) {
|
||||||
|
this(/* message= */ null, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance.
|
||||||
|
*
|
||||||
* @param message The detail message for the exception.
|
* @param message The detail message for the exception.
|
||||||
* @param cause The cause for the exception.
|
* @param cause The cause for the exception.
|
||||||
|
* @deprecated Use a factory method which initializes {@link #contentIsMalformed}, and {@link
|
||||||
|
* #dataType} instead.
|
||||||
*/
|
*/
|
||||||
public ParserException(String message, Throwable cause) {
|
@Deprecated
|
||||||
|
public ParserException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
|
this(message, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ParserException(
|
||||||
|
@Nullable String message,
|
||||||
|
@Nullable Throwable cause,
|
||||||
|
boolean contentIsMalformed,
|
||||||
|
@DataType int dataType) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
|
this.contentIsMalformed = contentIsMalformed;
|
||||||
|
this.dataType = dataType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue