Search in sources :

Example 21 with FakeExtractorInput

use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.

the class DefaultOggSeekerUtilMethodsTest method testSkipToPageOfGranuleAfterTargetPage.

public void testSkipToPageOfGranuleAfterTargetPage() throws IOException, InterruptedException {
    byte[] packet = TestUtil.buildTestData(3 * 254, random);
    byte[] data = TestUtil.joinByteArrays(TestData.buildOggHeader(0x01, 20000, 1000, 0x03), // Laces.
    TestUtil.createByteArray(254, 254, 254), packet, TestData.buildOggHeader(0x04, 40000, 1001, 0x03), // Laces.
    TestUtil.createByteArray(254, 254, 254), packet, TestData.buildOggHeader(0x04, 60000, 1002, 0x03), // Laces.
    TestUtil.createByteArray(254, 254, 254), packet);
    FakeExtractorInput input = new FakeExtractorInput.Builder().setData(data).build();
    skipToPageOfGranule(input, 10000, -1);
    assertEquals(0, input.getPosition());
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput)

Example 22 with FakeExtractorInput

use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.

the class DefaultOggSeekerUtilMethodsTest method testReadGranuleOfLastPage.

public void testReadGranuleOfLastPage() throws IOException, InterruptedException {
    FakeExtractorInput input = TestData.createInput(TestUtil.joinByteArrays(TestUtil.buildTestData(100, random), TestData.buildOggHeader(0x00, 20000, 66, 3), // laces
    TestUtil.createByteArray(254, 254, 254), TestUtil.buildTestData(3 * 254, random), TestData.buildOggHeader(0x00, 40000, 67, 3), // laces
    TestUtil.createByteArray(254, 254, 254), TestUtil.buildTestData(3 * 254, random), TestData.buildOggHeader(0x05, 60000, 68, 3), // laces
    TestUtil.createByteArray(254, 254, 254), TestUtil.buildTestData(3 * 254, random)), false);
    assertReadGranuleOfLastPage(input, 60000);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput)

Example 23 with FakeExtractorInput

use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.

the class OggPacketTest method testReadContinuedPacketOverTwoPages.

public void testReadContinuedPacketOverTwoPages() throws Exception {
    byte[] firstPacket = TestUtil.buildTestData(518);
    FakeExtractorInput input = TestData.createInput(TestUtil.joinByteArrays(// First page.
    TestData.buildOggHeader(0x02, 0, 1000, 0x02), // Laces.
    TestUtil.createByteArray(0xFF, 0xFF), Arrays.copyOf(firstPacket, 510), // Second page (continued packet).
    TestData.buildOggHeader(0x05, 10, 1001, 0x01), // Laces.
    TestUtil.createByteArray(0x08), Arrays.copyOfRange(firstPacket, 510, 510 + 8)), true);
    assertReadPacket(input, firstPacket);
    assertTrue((oggPacket.getPageHeader().type & 0x04) == 0x04);
    assertFalse((oggPacket.getPageHeader().type & 0x02) == 0x02);
    assertEquals(1001, oggPacket.getPageHeader().pageSequenceNumber);
    assertReadEof(input);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput)

Example 24 with FakeExtractorInput

use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.

the class OggPacketTest method testReadDiscardContinuedPacketAtStart.

public void testReadDiscardContinuedPacketAtStart() throws Exception {
    byte[] pageBody = TestUtil.buildTestData(256 + 8);
    FakeExtractorInput input = TestData.createInput(TestUtil.joinByteArrays(// Page with a continued packet at start.
    TestData.buildOggHeader(0x01, 10, 1001, 0x03), // Laces.
    TestUtil.createByteArray(255, 1, 8), pageBody), true);
    // Expect the first partial packet to be discarded.
    assertReadPacket(input, Arrays.copyOfRange(pageBody, 256, 256 + 8));
    assertReadEof(input);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput)

Example 25 with FakeExtractorInput

use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.

the class OggPacketTest method testReadZeroSizedPacketsAtEndOfStream.

public void testReadZeroSizedPacketsAtEndOfStream() throws Exception {
    byte[] firstPacket = TestUtil.buildTestData(8, random);
    byte[] secondPacket = TestUtil.buildTestData(8, random);
    byte[] thirdPacket = TestUtil.buildTestData(8, random);
    FakeExtractorInput input = TestData.createInput(TestUtil.joinByteArrays(TestData.buildOggHeader(0x02, 0, 1000, 0x01), // Laces.
    TestUtil.createByteArray(0x08), firstPacket, TestData.buildOggHeader(0x04, 0, 1001, 0x03), // Laces.
    TestUtil.createByteArray(0x08, 0x00, 0x00), secondPacket, TestData.buildOggHeader(0x04, 0, 1002, 0x03), // Laces.
    TestUtil.createByteArray(0x08, 0x00, 0x00), thirdPacket), true);
    assertReadPacket(input, firstPacket);
    assertReadPacket(input, secondPacket);
    assertReadPacket(input, thirdPacket);
    assertReadEof(input);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput)

Aggregations

FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)24 PositionHolder (com.google.android.exoplayer2.extractor.PositionHolder)3 FakeExtractorOutput (com.google.android.exoplayer2.testutil.FakeExtractorOutput)2 TimestampAdjuster (com.google.android.exoplayer2.util.TimestampAdjuster)2 EOFException (java.io.EOFException)2 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)1 TrackOutput (com.google.android.exoplayer2.extractor.TrackOutput)1 SimulatedIOException (com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException)1 FakeTrackOutput (com.google.android.exoplayer2.testutil.FakeTrackOutput)1 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)1