use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class DefaultExtractorInputTest method initialPosition.
@Test
public void initialPosition() throws Exception {
FakeDataSource testDataSource = buildDataSource();
DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 123, C.LENGTH_UNSET);
assertThat(input.getPosition()).isEqualTo(123);
}
use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class DefaultExtractorInputTest method largeSkip.
@Test
public void largeSkip() throws Exception {
FakeDataSource testDataSource = buildLargeDataSource();
DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
// Check that skipping the entire data source succeeds.
int bytesToSkip = LARGE_TEST_DATA_LENGTH;
while (bytesToSkip > 0) {
int skipped = input.skip(bytesToSkip);
assertThat(skipped).isGreaterThan(0);
bytesToSkip -= skipped;
}
assertThat(bytesToSkip).isEqualTo(0);
}
use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class DefaultExtractorInputTest method testLargeSkip.
public void testLargeSkip() throws Exception {
FakeDataSource testDataSource = buildLargeDataSource();
DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
// Check that skipping the entire data source succeeds.
int bytesToSkip = LARGE_TEST_DATA_LENGTH;
while (bytesToSkip > 0) {
bytesToSkip -= input.skip(bytesToSkip);
}
}
use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class ExtractorUtilTest method peekFullyQuietly_endNotReached_isTrueAndPeeksData.
@Test
public void peekFullyQuietly_endNotReached_isTrueAndPeeksData() throws Exception {
FakeDataSource testDataSource = new FakeDataSource();
testDataSource.getDataSet().newDefaultData().appendReadData(Arrays.copyOf(TEST_DATA, 3)).appendReadData(Arrays.copyOfRange(TEST_DATA, 3, 6)).appendReadData(Arrays.copyOfRange(TEST_DATA, 6, 9));
testDataSource.open(new DataSpec(Uri.parse(TEST_URI)));
ExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
byte[] target = new byte[TEST_DATA.length];
int offset = 2;
int length = 4;
boolean hasRead = ExtractorUtil.peekFullyQuietly(input, target, offset, length, /* allowEndOfInput= */
false);
assertThat(hasRead).isTrue();
assertThat(input.getPeekPosition()).isEqualTo(length);
assertThat(Arrays.copyOfRange(target, offset, offset + length)).isEqualTo(Arrays.copyOf(TEST_DATA, length));
}
use of com.google.android.exoplayer2.extractor.DefaultExtractorInput in project ExoPlayer by google.
the class ExtractorUtilTest method readFullyQuietly_endReached_isFalse.
@Test
public void readFullyQuietly_endReached_isFalse() throws Exception {
FakeDataSource testDataSource = new FakeDataSource();
testDataSource.getDataSet().newDefaultData().appendReadData(Arrays.copyOf(TEST_DATA, 3));
testDataSource.open(new DataSpec(Uri.parse(TEST_URI)));
ExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
byte[] target = new byte[TEST_DATA.length];
int offset = 0;
int length = TEST_DATA.length + 1;
boolean hasRead = ExtractorUtil.readFullyQuietly(input, target, offset, length);
assertThat(hasRead).isFalse();
assertThat(input.getPosition()).isEqualTo(0);
}
Aggregations