use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.
the class TsExtractorTest method testCustomPesReader.
public void testCustomPesReader() throws Exception {
CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(true, false);
TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_NORMAL, new TimestampAdjuster(0), factory);
FakeExtractorInput input = new FakeExtractorInput.Builder().setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample.ts")).setSimulateIOErrors(false).setSimulateUnknownLength(false).setSimulatePartialReads(false).build();
FakeExtractorOutput output = new FakeExtractorOutput();
tsExtractor.init(output);
PositionHolder seekPositionHolder = new PositionHolder();
int readResult = Extractor.RESULT_CONTINUE;
while (readResult != Extractor.RESULT_END_OF_INPUT) {
readResult = tsExtractor.read(input, seekPositionHolder);
}
CustomEsReader reader = factory.esReader;
assertEquals(2, reader.packetsRead);
TrackOutput trackOutput = reader.getTrackOutput();
assertTrue(trackOutput == output.trackOutputs.get(257));
assertEquals(Format.createTextSampleFormat("1/257", "mime", null, 0, 0, "und", null, 0), ((FakeTrackOutput) trackOutput).format);
}
use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.
the class OggPacketTest method testReadPacketWithZeroSizeTerminator.
public void testReadPacketWithZeroSizeTerminator() throws Exception {
byte[] firstPacket = TestUtil.buildTestData(255, random);
byte[] secondPacket = TestUtil.buildTestData(8, random);
FakeExtractorInput input = TestData.createInput(TestUtil.joinByteArrays(TestData.buildOggHeader(0x06, 0, 1000, 0x04), // Laces.
TestUtil.createByteArray(0xFF, 0x00, 0x00, 0x08), firstPacket, secondPacket), true);
assertReadPacket(input, firstPacket);
assertReadPacket(input, secondPacket);
assertReadEof(input);
}
use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.
the class OggPacketTest method assertReadPacket.
private void assertReadPacket(FakeExtractorInput extractorInput, byte[] expected) throws IOException, InterruptedException {
assertTrue(readPacket(extractorInput));
ParsableByteArray payload = oggPacket.getPayload();
MoreAsserts.assertEquals(expected, Arrays.copyOf(payload.data, payload.limit()));
}
use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.
the class OggPageHeaderTest method testPopulatePageHeader.
public void testPopulatePageHeader() throws IOException, InterruptedException {
FakeExtractorInput input = TestData.createInput(TestUtil.joinByteArrays(TestData.buildOggHeader(0x01, 123456, 4, 2), TestUtil.createByteArray(2, 2)), true);
OggPageHeader header = new OggPageHeader();
populatePageHeader(input, header, false);
assertEquals(0x01, header.type);
assertEquals(27 + 2, header.headerSize);
assertEquals(4, header.bodySize);
assertEquals(2, header.pageSegmentCount);
assertEquals(123456, header.granulePosition);
assertEquals(4, header.pageSequenceNumber);
assertEquals(0x1000, header.streamSerialNumber);
assertEquals(0x100000, header.pageChecksum);
assertEquals(0, header.revision);
}
use of com.google.android.exoplayer2.testutil.FakeExtractorInput in project ExoPlayer by google.
the class OggPageHeaderTest method testPopulatePageHeaderQuiteOnExceptionNotOgg.
public void testPopulatePageHeaderQuiteOnExceptionNotOgg() throws IOException, InterruptedException {
byte[] headerBytes = TestUtil.joinByteArrays(TestData.buildOggHeader(0x01, 123456, 4, 2), TestUtil.createByteArray(2, 2));
// change from 'O' to 'o'
headerBytes[0] = 'o';
FakeExtractorInput input = TestData.createInput(headerBytes, false);
OggPageHeader header = new OggPageHeader();
assertFalse(populatePageHeader(input, header, true));
}
Aggregations