Remove deprecated ParserException constructor

And replace it with factory method which includes more
context for error code assignment.

PiperOrigin-RevId: 380624625
This commit is contained in:
aquilescanta 2021-06-21 19:28:07 +01:00 committed by Oliver Woodman
parent f609fecf9b
commit 81c542b6a7
6 changed files with 16 additions and 26 deletions

View File

@ -96,21 +96,6 @@ public class ParserException extends IOException {
/** 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,
/* contentIsMalformed= */ true,
C.DATA_TYPE_UNKNOWN);
}
/**
* Creates a new instance.
*

View File

@ -250,7 +250,7 @@ public final class AacUtil {
// For supported containers, bits_to_decode() is always 0.
int channelCount = AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE[channelConfiguration];
if (channelCount == AUDIO_SPECIFIC_CONFIG_CHANNEL_CONFIGURATION_INVALID) {
throw new ParserException();
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
return new Config(sampleRateHz, channelCount, codecs);
}
@ -349,7 +349,7 @@ public final class AacUtil {
} else if (frequencyIndex < 13) {
samplingFrequency = AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE[frequencyIndex];
} else {
throw new ParserException();
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
return samplingFrequency;
}

View File

@ -98,7 +98,10 @@ public final class DefaultLoadErrorHandlingPolicyTest {
@Test
public void getRetryDelayMsFor_dontRetryParserException() {
assertThat(getDefaultPolicyRetryDelayOutputFor(new ParserException(), 1))
assertThat(
getDefaultPolicyRetryDelayOutputFor(
ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null),
1))
.isEqualTo(C.TIME_UNSET);
}

View File

@ -153,7 +153,7 @@ public final class FlacFrameReader {
SampleNumberHolder sampleNumberHolder = new SampleNumberHolder();
if (!checkAndReadFirstSampleNumber(
scratch, flacStreamMetadata, isBlockSizeVariable, sampleNumberHolder)) {
throw new ParserException();
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
return sampleNumberHolder.sampleNumber;

View File

@ -231,7 +231,7 @@ import java.util.List;
for (int i = 0; i < segmentStrings.size(); i++) {
List<String> values = COLON_SPLITTER.splitToList(segmentStrings.get(i));
if (values.size() != 3) {
throw new ParserException();
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
try {
long startTimeMs = Long.parseLong(values.get(0));

View File

@ -164,7 +164,7 @@ public final class LatmReader implements ElementaryStreamReader {
if (audioMuxVersionA == 0) {
if (numSubframes != 0) {
throw new ParserException();
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
int muxSlotLengthBytes = parsePayloadLengthInfo(data);
parsePayloadMux(data, muxSlotLengthBytes);
@ -172,7 +172,8 @@ public final class LatmReader implements ElementaryStreamReader {
data.skipBits((int) otherDataLenBits);
}
} else {
throw new ParserException(); // Not defined by ISO/IEC 14496-3:2009.
// Not defined by ISO/IEC 14496-3:2009.
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
}
@ -186,13 +187,13 @@ public final class LatmReader implements ElementaryStreamReader {
latmGetValue(data); // Skip taraBufferFullness.
}
if (!data.readBit()) {
throw new ParserException();
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
numSubframes = data.readBits(6);
int numProgram = data.readBits(4);
int numLayer = data.readBits(3);
if (numProgram != 0 || numLayer != 0) {
throw new ParserException();
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
if (audioMuxVersion == 0) {
int startPosition = data.getPosition();
@ -239,7 +240,8 @@ public final class LatmReader implements ElementaryStreamReader {
data.skipBits(8); // crcCheckSum.
}
} else {
throw new ParserException(); // This is not defined by ISO/IEC 14496-3:2009.
// This is not defined by ISO/IEC 14496-3:2009.
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
}
@ -286,7 +288,7 @@ public final class LatmReader implements ElementaryStreamReader {
} while (tmp == 255);
return muxSlotLengthBytes;
} else {
throw new ParserException();
throw ParserException.createForMalformedContainer(/* message= */ null, /* cause= */ null);
}
}