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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations