本文整理汇总了Java中com.google.android.exoplayer2.C.RESULT_MAX_LENGTH_EXCEEDED属性的典型用法代码示例。如果您正苦于以下问题:Java C.RESULT_MAX_LENGTH_EXCEEDED属性的具体用法?Java C.RESULT_MAX_LENGTH_EXCEEDED怎么用?Java C.RESULT_MAX_LENGTH_EXCEEDED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.exoplayer2.C
的用法示例。
在下文中一共展示了C.RESULT_MAX_LENGTH_EXCEEDED属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readUnsignedVarint
/**
* Reads an EBML variable-length integer (varint) from an {@link ExtractorInput} such that
* reading can be resumed later if an error occurs having read only some of it.
* <p>
* If an value is successfully read, then the reader will automatically reset itself ready to
* read another value.
* <p>
* If an {@link IOException} or {@link InterruptedException} is throw, the read can be resumed
* later by calling this method again, passing an {@link ExtractorInput} providing data starting
* where the previous one left off.
*
* @param input The {@link ExtractorInput} from which the integer should be read.
* @param allowEndOfInput True if encountering the end of the input having read no data is
* allowed, and should result in {@link C#RESULT_END_OF_INPUT} being returned. False if it
* should be considered an error, causing an {@link EOFException} to be thrown.
* @param removeLengthMask Removes the variable-length integer length mask from the value.
* @param maximumAllowedLength Maximum allowed length of the variable integer to be read.
* @return The read value, or {@link C#RESULT_END_OF_INPUT} if {@code allowEndOfStream} is true
* and the end of the input was encountered, or {@link C#RESULT_MAX_LENGTH_EXCEEDED} if the
* length of the varint exceeded maximumAllowedLength.
* @throws IOException If an error occurs reading from the input.
* @throws InterruptedException If the thread is interrupted.
*/
public long readUnsignedVarint(ExtractorInput input, boolean allowEndOfInput,
boolean removeLengthMask, int maximumAllowedLength) throws IOException, InterruptedException {
if (state == STATE_BEGIN_READING) {
// Read the first byte to establish the length.
if (!input.readFully(scratch, 0, 1, allowEndOfInput)) {
return C.RESULT_END_OF_INPUT;
}
int firstByte = scratch[0] & 0xFF;
length = parseUnsignedVarintLength(firstByte);
if (length == C.LENGTH_UNSET) {
throw new IllegalStateException("No valid varint length mask found");
}
state = STATE_READ_CONTENTS;
}
if (length > maximumAllowedLength) {
state = STATE_BEGIN_READING;
return C.RESULT_MAX_LENGTH_EXCEEDED;
}
if (length != 1) {
// Read the remaining bytes.
input.readFully(scratch, 1, length - 1);
}
state = STATE_BEGIN_READING;
return assembleVarint(scratch, length, removeLengthMask);
}