Rename ParsableByteArray.length() to limit(). Add capacity().

This commit is contained in:
Oliver Woodman 2015-02-13 19:31:01 +00:00
parent 321005e4b1
commit 28166d8c0d
5 changed files with 12 additions and 8 deletions

View File

@ -638,7 +638,7 @@ public final class FragmentedMp4Extractor implements Extractor {
}
Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption);
out.initEncryptionData(senc.length() - senc.getPosition());
out.initEncryptionData(senc.bytesLeft());
out.fillEncryptionData(senc);
}
@ -696,7 +696,7 @@ public final class FragmentedMp4Extractor implements Extractor {
offset += sizes[i];
}
return new SegmentIndex(atom.length(), sizes, offsets, durationsUs, timesUs);
return new SegmentIndex(atom.limit(), sizes, offsets, durationsUs, timesUs);
}
private int readEncryptionData(NonBlockingInputStream inputStream) {

View File

@ -113,7 +113,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
* @param length The length in bytes of the encryption data.
*/
public void initEncryptionData(int length) {
if (sampleEncryptionData == null || sampleEncryptionData.length() < length) {
if (sampleEncryptionData == null || sampleEncryptionData.limit() < length) {
sampleEncryptionData = new ParsableByteArray(length);
}
sampleEncryptionDataLength = length;

View File

@ -128,7 +128,7 @@ import java.util.Collections;
private boolean skipToNextSync(ParsableByteArray pesBuffer) {
byte[] adtsData = pesBuffer.data;
int startOffset = pesBuffer.getPosition();
int endOffset = pesBuffer.length();
int endOffset = pesBuffer.limit();
for (int i = startOffset; i < endOffset; i++) {
boolean byteIsOxFF = (adtsData[i] & 0xFF) == 0xFF;
boolean found = lastByteWasOxFF && !byteIsOxFF && (adtsData[i] & 0xF0) == 0xF0;

View File

@ -90,7 +90,7 @@ import java.util.List;
*/
private boolean readToNextAudUnit(ParsableByteArray data, long pesTimeUs) {
int pesOffset = data.getPosition();
int pesLimit = data.length();
int pesLimit = data.limit();
// TODO: We probably need to handle the case where the AUD start code was split across the
// previous and current data buffers.

View File

@ -73,9 +73,8 @@ public final class ParsableByteArray {
return limit - position;
}
/** Returns the number of bytes in the array. */
// TODO: Rename to limit.
public int length() {
/** Returns the limit. */
public int limit() {
return limit;
}
@ -94,6 +93,11 @@ public final class ParsableByteArray {
return position;
}
/** Returns the capacity of the array, which may be larger than the limit. */
public int capacity() {
return data == null ? 0 : data.length;
}
/**
* Sets the reading offset in the array.
*