Search in sources :

Example 1 with VorbisSetup

use of com.google.android.exoplayer2.extractor.ogg.VorbisReader.VorbisSetup in project ExoPlayer by google.

the class VorbisReaderTest method testReadSetupHeadersWithIOExceptions.

public void testReadSetupHeadersWithIOExceptions() throws IOException, InterruptedException {
    byte[] data = TestData.getVorbisHeaderPages();
    ExtractorInput input = new FakeExtractorInput.Builder().setData(data).setSimulateIOErrors(true).setSimulateUnknownLength(true).setSimulatePartialReads(true).build();
    VorbisReader reader = new VorbisReader();
    VorbisReader.VorbisSetup vorbisSetup = readSetupHeaders(reader, input);
    assertNotNull(vorbisSetup.idHeader);
    assertNotNull(vorbisSetup.commentHeader);
    assertNotNull(vorbisSetup.setupHeaderData);
    assertNotNull(vorbisSetup.modes);
    assertEquals(45, vorbisSetup.commentHeader.length);
    assertEquals(30, vorbisSetup.idHeader.data.length);
    assertEquals(3597, vorbisSetup.setupHeaderData.length);
    assertEquals(-1, vorbisSetup.idHeader.bitrateMax);
    assertEquals(-1, vorbisSetup.idHeader.bitrateMin);
    assertEquals(66666, vorbisSetup.idHeader.bitrateNominal);
    assertEquals(512, vorbisSetup.idHeader.blockSize0);
    assertEquals(1024, vorbisSetup.idHeader.blockSize1);
    assertEquals(2, vorbisSetup.idHeader.channels);
    assertTrue(vorbisSetup.idHeader.framingFlag);
    assertEquals(22050, vorbisSetup.idHeader.sampleRate);
    assertEquals(0, vorbisSetup.idHeader.version);
    assertEquals("Xiph.Org libVorbis I 20030909", vorbisSetup.commentHeader.vendor);
    assertEquals(1, vorbisSetup.iLogModes);
    assertEquals(data[data.length - 1], vorbisSetup.setupHeaderData[vorbisSetup.setupHeaderData.length - 1]);
    assertFalse(vorbisSetup.modes[0].blockFlag);
    assertTrue(vorbisSetup.modes[1].blockFlag);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) VorbisSetup(com.google.android.exoplayer2.extractor.ogg.VorbisReader.VorbisSetup) ExtractorInput(com.google.android.exoplayer2.extractor.ExtractorInput) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput)

Aggregations

ExtractorInput (com.google.android.exoplayer2.extractor.ExtractorInput)1 VorbisSetup (com.google.android.exoplayer2.extractor.ogg.VorbisReader.VorbisSetup)1 FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)1