Commit 28166d8c by Oliver Woodman

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

parent 321005e4
...@@ -638,7 +638,7 @@ public final class FragmentedMp4Extractor implements Extractor { ...@@ -638,7 +638,7 @@ public final class FragmentedMp4Extractor implements Extractor {
} }
Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption); Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption);
out.initEncryptionData(senc.length() - senc.getPosition()); out.initEncryptionData(senc.bytesLeft());
out.fillEncryptionData(senc); out.fillEncryptionData(senc);
} }
...@@ -696,7 +696,7 @@ public final class FragmentedMp4Extractor implements Extractor { ...@@ -696,7 +696,7 @@ public final class FragmentedMp4Extractor implements Extractor {
offset += sizes[i]; 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) { private int readEncryptionData(NonBlockingInputStream inputStream) {
......
...@@ -113,7 +113,7 @@ import com.google.android.exoplayer.util.ParsableByteArray; ...@@ -113,7 +113,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
* @param length The length in bytes of the encryption data. * @param length The length in bytes of the encryption data.
*/ */
public void initEncryptionData(int length) { public void initEncryptionData(int length) {
if (sampleEncryptionData == null || sampleEncryptionData.length() < length) { if (sampleEncryptionData == null || sampleEncryptionData.limit() < length) {
sampleEncryptionData = new ParsableByteArray(length); sampleEncryptionData = new ParsableByteArray(length);
} }
sampleEncryptionDataLength = length; sampleEncryptionDataLength = length;
......
...@@ -128,7 +128,7 @@ import java.util.Collections; ...@@ -128,7 +128,7 @@ import java.util.Collections;
private boolean skipToNextSync(ParsableByteArray pesBuffer) { private boolean skipToNextSync(ParsableByteArray pesBuffer) {
byte[] adtsData = pesBuffer.data; byte[] adtsData = pesBuffer.data;
int startOffset = pesBuffer.getPosition(); int startOffset = pesBuffer.getPosition();
int endOffset = pesBuffer.length(); int endOffset = pesBuffer.limit();
for (int i = startOffset; i < endOffset; i++) { for (int i = startOffset; i < endOffset; i++) {
boolean byteIsOxFF = (adtsData[i] & 0xFF) == 0xFF; boolean byteIsOxFF = (adtsData[i] & 0xFF) == 0xFF;
boolean found = lastByteWasOxFF && !byteIsOxFF && (adtsData[i] & 0xF0) == 0xF0; boolean found = lastByteWasOxFF && !byteIsOxFF && (adtsData[i] & 0xF0) == 0xF0;
......
...@@ -90,7 +90,7 @@ import java.util.List; ...@@ -90,7 +90,7 @@ import java.util.List;
*/ */
private boolean readToNextAudUnit(ParsableByteArray data, long pesTimeUs) { private boolean readToNextAudUnit(ParsableByteArray data, long pesTimeUs) {
int pesOffset = data.getPosition(); 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 // TODO: We probably need to handle the case where the AUD start code was split across the
// previous and current data buffers. // previous and current data buffers.
......
...@@ -73,9 +73,8 @@ public final class ParsableByteArray { ...@@ -73,9 +73,8 @@ public final class ParsableByteArray {
return limit - position; return limit - position;
} }
/** Returns the number of bytes in the array. */ /** Returns the limit. */
// TODO: Rename to limit. public int limit() {
public int length() {
return limit; return limit;
} }
...@@ -94,6 +93,11 @@ public final class ParsableByteArray { ...@@ -94,6 +93,11 @@ public final class ParsableByteArray {
return position; 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. * Sets the reading offset in the array.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment