mirror of
https://github.com/androidx/media.git
synced 2025-05-10 00:59:51 +08:00
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:
parent
b61e7cdbc4
commit
28eaa2cb24
@ -112,12 +112,9 @@ import java.io.IOException;
|
|||||||
Assertions.checkArgument(input.getLength() != C.LENGTH_UNBOUNDED); // never read forever!
|
Assertions.checkArgument(input.getLength() != C.LENGTH_UNBOUNDED); // never read forever!
|
||||||
OggUtil.skipToNextPage(input);
|
OggUtil.skipToNextPage(input);
|
||||||
pageHeader.reset();
|
pageHeader.reset();
|
||||||
while ((pageHeader.type & 0x04) != 0x04) {
|
while ((pageHeader.type & 0x04) != 0x04 && input.getPosition() < input.getLength()) {
|
||||||
if (pageHeader.bodySize > 0) {
|
|
||||||
input.skipFully(pageHeader.bodySize);
|
|
||||||
}
|
|
||||||
OggUtil.populatePageHeader(input, pageHeader, headerArray, false);
|
OggUtil.populatePageHeader(input, pageHeader, headerArray, false);
|
||||||
input.skipFully(pageHeader.headerSize);
|
input.skipFully(pageHeader.headerSize + pageHeader.bodySize);
|
||||||
}
|
}
|
||||||
return pageHeader.granulePosition;
|
return pageHeader.granulePosition;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
/* package */ final class VorbisReader extends StreamReader implements SeekMap {
|
/* package */ final class VorbisReader extends StreamReader implements SeekMap {
|
||||||
|
|
||||||
|
private static final long LARGEST_EXPECTED_PAGE_SIZE = 8000;
|
||||||
|
|
||||||
private VorbisSetup vorbisSetup;
|
private VorbisSetup vorbisSetup;
|
||||||
private int previousPacketBlockSize;
|
private int previousPacketBlockSize;
|
||||||
private long elapsedSamples;
|
private long elapsedSamples;
|
||||||
@ -78,7 +80,7 @@ import java.util.ArrayList;
|
|||||||
extractorOutput.seekMap(this);
|
extractorOutput.seekMap(this);
|
||||||
if (inputLength != C.LENGTH_UNBOUNDED) {
|
if (inputLength != C.LENGTH_UNBOUNDED) {
|
||||||
// seek to the end just before the last page of stream to get the duration
|
// 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;
|
return Extractor.RESULT_SEEK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user