mirror of
https://github.com/androidx/media.git
synced 2025-05-07 23:50:44 +08:00
Fix an issue where retrying WebM extraction failed.
The ID_SEGMENT can only be read once, as seeing the element a second time is assumed to indicate that the file contains multiple segment elements (which is not supported). This change allows the element to be read twice if it is at the same position, so that retrying loading from the start can succeed.
This commit is contained in:
parent
31e5e0edaf
commit
72d42fbc9f
@ -297,7 +297,7 @@ public final class WebmExtractor implements Extractor {
|
|||||||
throws ParserException {
|
throws ParserException {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case ID_SEGMENT:
|
case ID_SEGMENT:
|
||||||
if (segmentContentPosition != UNKNOWN) {
|
if (segmentContentPosition != UNKNOWN && segmentContentPosition != contentPosition) {
|
||||||
throw new ParserException("Multiple Segment elements not supported");
|
throw new ParserException("Multiple Segment elements not supported");
|
||||||
}
|
}
|
||||||
segmentContentPosition = contentPosition;
|
segmentContentPosition = contentPosition;
|
||||||
|
@ -92,6 +92,21 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
|
|||||||
assertIndex(new IndexPoint(0, 0, TEST_DURATION_US));
|
assertIndex(new IndexPoint(0, 0, TEST_DURATION_US));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testReadSegmentTwice() throws IOException, InterruptedException {
|
||||||
|
byte[] data = new StreamBuilder()
|
||||||
|
.setHeader(WEBM_DOC_TYPE)
|
||||||
|
.setInfo(DEFAULT_TIMECODE_SCALE, TEST_DURATION_US)
|
||||||
|
.addVp9Track(TEST_WIDTH, TEST_HEIGHT, null)
|
||||||
|
.build(1);
|
||||||
|
|
||||||
|
TestUtil.consumeTestData(extractor, data);
|
||||||
|
extractor.seek();
|
||||||
|
TestUtil.consumeTestData(extractor, data);
|
||||||
|
|
||||||
|
assertVp9VideoFormat();
|
||||||
|
assertIndex(new IndexPoint(0, 0, TEST_DURATION_US));
|
||||||
|
}
|
||||||
|
|
||||||
public void testPrepareOpus() throws IOException, InterruptedException {
|
public void testPrepareOpus() throws IOException, InterruptedException {
|
||||||
byte[] data = new StreamBuilder()
|
byte[] data = new StreamBuilder()
|
||||||
.setHeader(WEBM_DOC_TYPE)
|
.setHeader(WEBM_DOC_TYPE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user