Search in sources :

Example 16 with FakeExtractorInput

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

the class TsExtractorTest method testCustomPesReader.

public void testCustomPesReader() throws Exception {
    CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(true, false);
    TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_NORMAL, new TimestampAdjuster(0), factory);
    FakeExtractorInput input = new FakeExtractorInput.Builder().setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample.ts")).setSimulateIOErrors(false).setSimulateUnknownLength(false).setSimulatePartialReads(false).build();
    FakeExtractorOutput output = new FakeExtractorOutput();
    tsExtractor.init(output);
    PositionHolder seekPositionHolder = new PositionHolder();
    int readResult = Extractor.RESULT_CONTINUE;
    while (readResult != Extractor.RESULT_END_OF_INPUT) {
        readResult = tsExtractor.read(input, seekPositionHolder);
    }
    CustomEsReader reader = factory.esReader;
    assertEquals(2, reader.packetsRead);
    TrackOutput trackOutput = reader.getTrackOutput();
    assertTrue(trackOutput == output.trackOutputs.get(257));
    assertEquals(Format.createTextSampleFormat("1/257", "mime", null, 0, 0, "und", null, 0), ((FakeTrackOutput) trackOutput).format);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) PositionHolder(com.google.android.exoplayer2.extractor.PositionHolder) TimestampAdjuster(com.google.android.exoplayer2.util.TimestampAdjuster) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) TrackOutput(com.google.android.exoplayer2.extractor.TrackOutput) FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput)

Example 17 with FakeExtractorInput

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

the class OggPacketTest method testReadPacketWithZeroSizeTerminator.

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

Example 18 with FakeExtractorInput

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

the class OggPacketTest method assertReadPacket.

private void assertReadPacket(FakeExtractorInput extractorInput, byte[] expected) throws IOException, InterruptedException {
    assertTrue(readPacket(extractorInput));
    ParsableByteArray payload = oggPacket.getPayload();
    MoreAsserts.assertEquals(expected, Arrays.copyOf(payload.data, payload.limit()));
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Example 19 with FakeExtractorInput

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

the class OggPageHeaderTest method testPopulatePageHeader.

public void testPopulatePageHeader() throws IOException, InterruptedException {
    FakeExtractorInput input = TestData.createInput(TestUtil.joinByteArrays(TestData.buildOggHeader(0x01, 123456, 4, 2), TestUtil.createByteArray(2, 2)), true);
    OggPageHeader header = new OggPageHeader();
    populatePageHeader(input, header, false);
    assertEquals(0x01, header.type);
    assertEquals(27 + 2, header.headerSize);
    assertEquals(4, header.bodySize);
    assertEquals(2, header.pageSegmentCount);
    assertEquals(123456, header.granulePosition);
    assertEquals(4, header.pageSequenceNumber);
    assertEquals(0x1000, header.streamSerialNumber);
    assertEquals(0x100000, header.pageChecksum);
    assertEquals(0, header.revision);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput)

Example 20 with FakeExtractorInput

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

the class OggPageHeaderTest method testPopulatePageHeaderQuiteOnExceptionNotOgg.

public void testPopulatePageHeaderQuiteOnExceptionNotOgg() throws IOException, InterruptedException {
    byte[] headerBytes = TestUtil.joinByteArrays(TestData.buildOggHeader(0x01, 123456, 4, 2), TestUtil.createByteArray(2, 2));
    // change from 'O' to 'o'
    headerBytes[0] = 'o';
    FakeExtractorInput input = TestData.createInput(headerBytes, false);
    OggPageHeader header = new OggPageHeader();
    assertFalse(populatePageHeader(input, header, true));
}
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