Support Ogg containers without a properly flagged last page.

Such files are slightly off spec but easy to support.(https://github.com/google/ExoPlayer/issues/1506)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=121927762
This commit is contained in:
[]inger 2016-05-10 02:52:30 -07:00 committed by Oliver Woodman
parent b61e7cdbc4
commit 28eaa2cb24
2 changed files with 5 additions and 6 deletions

View File

@ -112,12 +112,9 @@ import java.io.IOException;
Assertions.checkArgument(input.getLength() != C.LENGTH_UNBOUNDED); // never read forever!
OggUtil.skipToNextPage(input);
pageHeader.reset();
while ((pageHeader.type & 0x04) != 0x04) {
if (pageHeader.bodySize > 0) {
input.skipFully(pageHeader.bodySize);
}
while ((pageHeader.type & 0x04) != 0x04 && input.getPosition() < input.getLength()) {
OggUtil.populatePageHeader(input, pageHeader, headerArray, false);
input.skipFully(pageHeader.headerSize);
input.skipFully(pageHeader.headerSize + pageHeader.bodySize);
}
return pageHeader.granulePosition;
}

View File

@ -34,6 +34,8 @@ import java.util.ArrayList;
*/
/* package */ final class VorbisReader extends StreamReader implements SeekMap {
private static final long LARGEST_EXPECTED_PAGE_SIZE = 8000;
private VorbisSetup vorbisSetup;
private int previousPacketBlockSize;
private long elapsedSamples;
@ -78,7 +80,7 @@ import java.util.ArrayList;
extractorOutput.seekMap(this);
if (inputLength != C.LENGTH_UNBOUNDED) {
// seek to the end just before the last page of stream to get the duration
seekPosition.position = input.getLength() - 8000;
seekPosition.position = Math.max(0, input.getLength() - LARGEST_EXPECTED_PAGE_SIZE);
return Extractor.RESULT_SEEK;
}
}