/** Returns the reading position of {@code bufferingInput} relative to the extractor's stream. */ private static long getPosition(ExtractorInput extractorInput, BufferingInput bufferingInput) { return extractorInput.getPosition() - bufferingInput.getAvailableByteCount(); }
@Override public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException, InterruptedException { sampleRead = false; boolean continueReading = true; while (continueReading && !sampleRead) { continueReading = reader.read(input); if (continueReading && maybeSeekForCues(seekPosition, input.getPosition())) { return Extractor.RESULT_SEEK; } } return continueReading ? Extractor.RESULT_CONTINUE : Extractor.RESULT_END_OF_INPUT; }
private void readAtomPayload(ExtractorInput input) throws IOException, InterruptedException { int atomPayloadSize = (int) atomSize - atomHeaderBytesRead; if (atomData != null) { input.readFully(atomData.data, Atom.HEADER_SIZE, atomPayloadSize); onLeafAtomRead(new LeafAtom(atomType, atomData), input.getPosition()); } else { input.skipFully(atomPayloadSize); } long currentPosition = input.getPosition(); while (!containerAtoms.isEmpty() && containerAtoms.peek().endPosition == currentPosition) { onContainerAtomRead(containerAtoms.pop()); } enterReadingAtomHeaderState(); }
throws IOException, InterruptedException { long atomPayloadSize = atomSize - atomHeaderBytesRead; long atomEndPosition = input.getPosition() + atomPayloadSize; boolean seekRequired = false; if (atomData != null) { input.skipFully((int) atomPayloadSize); } else { positionHolder.position = input.getPosition() + atomPayloadSize; seekRequired = true;
@Override public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException, InterruptedException { while (true) { switch (parserState) { case STATE_AFTER_SEEK: if (input.getPosition() == 0) { enterReadingAtomHeaderState(); } else { parserState = STATE_READING_SAMPLE; } break; case STATE_READING_ATOM_HEADER: if (!readAtomHeader(input)) { return RESULT_END_OF_INPUT; } break; case STATE_READING_ATOM_PAYLOAD: if (readAtomPayload(input, seekPosition)) { return RESULT_SEEK; } break; default: return readSample(input, seekPosition); } } }
while (true) { if (!masterElementsStack.isEmpty() && input.getPosition() >= masterElementsStack.peek().elementEndPosition) { output.endMasterElement(masterElementsStack.pop().elementId); return true; switch (type) { case TYPE_MASTER: long elementContentPosition = input.getPosition(); long elementEndPosition = elementContentPosition + elementContentSize; masterElementsStack.add(new MasterElement(elementId, elementEndPosition));
@SuppressWarnings("NonAtomicVolatileUpdate") @Override public void load() throws IOException, InterruptedException { DataSpec loadDataSpec = Util.getRemainderDataSpec(dataSpec, bytesLoaded); try { // Create and open the input. ExtractorInput input = new DefaultExtractorInput(dataSource, loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec)); if (bytesLoaded == 0) { // Set the target to ourselves. extractorWrapper.init(this); } // Load and parse the initialization data. try { int result = Extractor.RESULT_CONTINUE; while (result == Extractor.RESULT_CONTINUE && !loadCanceled) { result = extractorWrapper.read(input); } } finally { bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition); } } finally { dataSource.close(); } }
@SuppressWarnings("NonAtomicVolatileUpdate") @Override public final void load() throws IOException, InterruptedException { DataSpec loadDataSpec = Util.getRemainderDataSpec(dataSpec, bytesLoaded); try { // Create and open the input. ExtractorInput input = new DefaultExtractorInput(dataSource, loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec)); if (bytesLoaded == 0) { // Set the target to ourselves. extractorWrapper.init(this); } // Load and parse the initialization data. try { int result = Extractor.RESULT_CONTINUE; while (result == Extractor.RESULT_CONTINUE && !loadCanceled) { result = extractorWrapper.read(input); } } finally { bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition); } } finally { dataSource.close(); } }
bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
long endPosition = input.getPosition() + atomSize - atomHeaderBytesRead; containerAtoms.add(new ContainerAtom(atomType, endPosition)); enterReadingAtomHeaderState();
result = Extractor.RESULT_CONTINUE; } else if (input != null) { positionHolder.position = input.getPosition();
long endPosition = input.getPosition() + atomSize - Atom.HEADER_SIZE; containerAtoms.add(new ContainerAtom(atomType, endPosition)); enterReadingAtomHeaderState();
int sampleIndex = track.sampleIndex; long position = track.sampleTable.offsets[sampleIndex]; long skipAmount = position - input.getPosition() + sampleBytesWritten; if (skipAmount < 0 || skipAmount >= RELOAD_MINIMUM_SEEK_DISTANCE) { positionHolder.position = position;
private long synchronize(ExtractorInput extractorInput) throws IOException, InterruptedException { if (extractorInput.getPosition() == 0) {