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