Search in sources :

Example 26 with ParsableByteArray

use of com.google.android.exoplayer2.util.ParsableByteArray in project ExoPlayer by google.

the class AdtsReaderTest method setUp.

@Override
protected void setUp() throws Exception {
    FakeExtractorOutput fakeExtractorOutput = new FakeExtractorOutput();
    adtsOutput = fakeExtractorOutput.track(0, C.TRACK_TYPE_AUDIO);
    id3Output = fakeExtractorOutput.track(1, C.TRACK_TYPE_METADATA);
    adtsReader = new AdtsReader(true);
    TrackIdGenerator idGenerator = new TrackIdGenerator(0, 1);
    adtsReader.createTracks(fakeExtractorOutput, idGenerator);
    data = new ParsableByteArray(TEST_DATA);
    firstFeed = true;
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) TrackIdGenerator(com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput)

Example 27 with ParsableByteArray

use of com.google.android.exoplayer2.util.ParsableByteArray in project ExoPlayer by google.

the class AdtsReaderTest method testSkipToNextSampleResetsState.

public void testSkipToNextSampleResetsState() throws Exception {
    data = new ParsableByteArray(TestUtil.joinByteArrays(ADTS_HEADER, ADTS_CONTENT, // Adts sample missing the first sync byte
    Arrays.copyOfRange(ADTS_HEADER, 1, ADTS_HEADER.length), ADTS_CONTENT));
    feed();
    assertSampleCounts(0, 1);
    adtsOutput.assertSample(0, ADTS_CONTENT, 0, C.BUFFER_FLAG_KEY_FRAME, null);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Example 28 with ParsableByteArray

use of com.google.android.exoplayer2.util.ParsableByteArray in project ExoPlayer by google.

the class SectionReaderTest method testSingleOnePacketSection.

public void testSingleOnePacketSection() {
    packetPayload[0] = 3;
    insertTableSection(4, (byte) 99, 3);
    reader.consume(new ParsableByteArray(packetPayload), true);
    assertEquals(Collections.singletonList(99), payloadReader.parsedTableIds);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Example 29 with ParsableByteArray

use of com.google.android.exoplayer2.util.ParsableByteArray in project ExoPlayer by google.

the class SectionReaderTest method testCrcChecks.

public void testCrcChecks() {
    byte[] correctCrcPat = new byte[] { (byte) 0x0, (byte) 0x0, (byte) 0xb0, (byte) 0xd, (byte) 0x0, (byte) 0x1, (byte) 0xc1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0xe1, (byte) 0x0, (byte) 0xe8, (byte) 0xf9, (byte) 0x5e, (byte) 0x7d };
    byte[] incorrectCrcPat = Arrays.copyOf(correctCrcPat, correctCrcPat.length);
    // Crc field is incorrect, and should not be passed to the payload reader.
    incorrectCrcPat[16]--;
    reader.consume(new ParsableByteArray(correctCrcPat), true);
    assertEquals(Collections.singletonList(0), payloadReader.parsedTableIds);
    reader.consume(new ParsableByteArray(incorrectCrcPat), true);
    assertEquals(Collections.singletonList(0), payloadReader.parsedTableIds);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Example 30 with ParsableByteArray

use of com.google.android.exoplayer2.util.ParsableByteArray in project ExoPlayer by google.

the class SectionReaderTest method testSeek.

public void testSeek() {
    // The first packet includes a pointer_field.
    packetPayload[0] = 13;
    // First section. Should be skipped.
    insertTableSection(1, (byte) 109, 10);
    // Second section spread across four packets. Should be consumed.
    insertTableSection(14, (byte) 110, 300);
    // The third packet includes a pointer_field.
    packetPayload[300] = 17;
    // Third section, at the payload start of the fourth packet. Should be consumed.
    insertTableSection(318, (byte) 111, 10);
    ParsableByteArray firstPacket = new ParsableByteArray(packetPayload, 100);
    reader.consume(firstPacket, true);
    assertEquals(Collections.emptyList(), payloadReader.parsedTableIds);
    ParsableByteArray secondPacket = new ParsableByteArray(packetPayload, 200);
    secondPacket.setPosition(100);
    reader.consume(secondPacket, false);
    assertEquals(Collections.emptyList(), payloadReader.parsedTableIds);
    ParsableByteArray thirdPacket = new ParsableByteArray(packetPayload, 300);
    thirdPacket.setPosition(200);
    reader.consume(thirdPacket, false);
    assertEquals(Collections.emptyList(), payloadReader.parsedTableIds);
    reader.seek();
    ParsableByteArray fourthPacket = new ParsableByteArray(packetPayload);
    fourthPacket.setPosition(300);
    reader.consume(fourthPacket, true);
    assertEquals(Collections.singletonList(111), payloadReader.parsedTableIds);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Aggregations

ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)48 ParserException (com.google.android.exoplayer2.ParserException)11 Format (com.google.android.exoplayer2.Format)6 ArrayList (java.util.ArrayList)4 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)3 Metadata (com.google.android.exoplayer2.metadata.Metadata)3 TrackOutput (com.google.android.exoplayer2.extractor.TrackOutput)2 ContainerAtom (com.google.android.exoplayer2.extractor.mp4.Atom.ContainerAtom)2 FlacStreamInfo (com.google.android.exoplayer2.util.FlacStreamInfo)2 AvcConfig (com.google.android.exoplayer2.video.AvcConfig)2 ByteBuffer (java.nio.ByteBuffer)2 Matcher (java.util.regex.Matcher)2 Spanned (android.text.Spanned)1 ChunkIndex (com.google.android.exoplayer2.extractor.ChunkIndex)1 MpegAudioHeader (com.google.android.exoplayer2.extractor.MpegAudioHeader)1 LeafAtom (com.google.android.exoplayer2.extractor.mp4.Atom.LeafAtom)1 TrackIdGenerator (com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator)1 CommentFrame (com.google.android.exoplayer2.metadata.id3.CommentFrame)1 TextInformationFrame (com.google.android.exoplayer2.metadata.id3.TextInformationFrame)1 FakeExtractorOutput (com.google.android.exoplayer2.testutil.FakeExtractorOutput)1