Search in sources :

Example 41 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 42 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)

Example 43 with ParsableByteArray

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

the class SectionReaderTest method testFiveSectionsInTwoPackets.

public void testFiveSectionsInTwoPackets() {
    // The first packet includes a pointer_field.
    packetPayload[0] = 0;
    insertTableSection(1, (byte) 101, 10);
    insertTableSection(14, (byte) 102, 10);
    insertTableSection(27, (byte) 103, 10);
    // The second packet includes a pointer_field.
    packetPayload[40] = 0;
    insertTableSection(41, (byte) 104, 10);
    insertTableSection(54, (byte) 105, 10);
    ParsableByteArray firstPacket = new ParsableByteArray(packetPayload, 40);
    reader.consume(firstPacket, true);
    assertEquals(Arrays.asList(101, 102, 103), payloadReader.parsedTableIds);
    ParsableByteArray secondPacket = new ParsableByteArray(packetPayload);
    secondPacket.setPosition(40);
    reader.consume(secondPacket, true);
    assertEquals(Arrays.asList(101, 102, 103, 104, 105), payloadReader.parsedTableIds);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Example 44 with ParsableByteArray

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

the class SectionReaderTest method testHeaderSplitAcrossPackets.

public void testHeaderSplitAcrossPackets() {
    // The first packet includes a pointer_field.
    packetPayload[0] = 3;
    // This section header spreads across both packets.
    insertTableSection(4, (byte) 100, 3);
    ParsableByteArray firstPacket = new ParsableByteArray(packetPayload, 5);
    reader.consume(firstPacket, true);
    assertEquals(Collections.emptyList(), payloadReader.parsedTableIds);
    ParsableByteArray secondPacket = new ParsableByteArray(packetPayload);
    secondPacket.setPosition(5);
    reader.consume(secondPacket, false);
    assertEquals(Collections.singletonList(100), payloadReader.parsedTableIds);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Example 45 with ParsableByteArray

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

the class SectionReaderTest method testLongSectionAcrossFourPackets.

public void testLongSectionAcrossFourPackets() {
    // The first packet includes a pointer_field.
    packetPayload[0] = 13;
    // First section. Should be skipped.
    insertTableSection(1, (byte) 106, 10);
    // Second section spread across four packets. Should be consumed.
    insertTableSection(14, (byte) 107, 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) 108, 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);
    ParsableByteArray fourthPacket = new ParsableByteArray(packetPayload);
    fourthPacket.setPosition(300);
    reader.consume(fourthPacket, true);
    assertEquals(Arrays.asList(107, 108), 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