use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.
the class SectionReaderTest method setUp.
@Before
public void setUp() {
packetPayload = new byte[512];
Arrays.fill(packetPayload, (byte) 0xFF);
payloadReader = new CustomSectionPayloadReader();
reader = new SectionReader(payloadReader);
reader.init(new TimestampAdjuster(0), new FakeExtractorOutput(), new TsPayloadReader.TrackIdGenerator(0, 1));
}
use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.
the class TsExtractorSeekTest method tsExtractorReads_nonSeekTableFile_returnSeekableSeekMap.
@Test
public void tsExtractorReads_nonSeekTableFile_returnSeekableSeekMap() throws IOException {
Uri fileUri = TestUtil.buildAssetUri(TEST_FILE);
TsExtractor extractor = new TsExtractor();
SeekMap seekMap = TestUtil.extractSeekMap(extractor, new FakeExtractorOutput(), dataSource, fileUri);
assertThat(seekMap).isNotNull();
assertThat(seekMap.getDurationUs()).isEqualTo(DURATION_US);
assertThat(seekMap.isSeekable()).isTrue();
}
use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.
the class AdtsExtractorSeekTest method seeking_handlesSeekingForward_extractsCorrectSamples.
@Test
public void seeking_handlesSeekingForward_extractsCorrectSamples() throws IOException {
String fileName = TEST_FILE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
AdtsExtractor extractor = createAdtsExtractor();
FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
long firstSeekTimeUs = 980_000;
TestUtil.seekToTimeUs(extractor, seekMap, firstSeekTimeUs, dataSource, trackOutput, fileUri);
long targetSeekTimeUs = 1_200_000;
int extractedSampleIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedSampleIndex).isNotEqualTo(-1);
assertFirstSampleAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedSampleIndex);
}
use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.
the class AdtsExtractorSeekTest method seeking_handlesRandomSeeks_extractsCorrectSamples.
@Test
public void seeking_handlesRandomSeeks_extractsCorrectSamples() throws IOException {
String fileName = TEST_FILE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
AdtsExtractor extractor = createAdtsExtractor();
FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
long numSeek = 100;
for (long i = 0; i < numSeek; i++) {
long targetSeekTimeUs = random.nextInt(FILE_DURATION_US + 1);
int extractedSampleIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedSampleIndex).isNotEqualTo(-1);
assertFirstSampleAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedSampleIndex);
}
}
use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.
the class AdtsExtractorSeekTest method seeking_handlesSeekingToPositionInFile_extractsCorrectSample.
@Test
public void seeking_handlesSeekingToPositionInFile_extractsCorrectSample() throws IOException {
String fileName = TEST_FILE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
AdtsExtractor extractor = createAdtsExtractor();
FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
long targetSeekTimeUs = 980_000;
int extractedSampleIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedSampleIndex).isNotEqualTo(-1);
assertFirstSampleAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedSampleIndex);
}
Aggregations