use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class IndexSeekerTest method assertFirstFrameAfterSeekIsWithinMinDifference.
private static void assertFirstFrameAfterSeekIsWithinMinDifference(String fileName, FakeTrackOutput trackOutput, long targetSeekTimeUs, int firstFrameIndexAfterSeek) throws IOException {
FakeTrackOutput expectedTrackOutput = getExpectedTrackOutput(fileName);
int exactFrameIndex = getFrameIndex(expectedTrackOutput, targetSeekTimeUs);
long exactFrameTimeUs = expectedTrackOutput.getSampleTimeUs(exactFrameIndex);
long foundTimeUs = trackOutput.getSampleTimeUs(firstFrameIndexAfterSeek);
assertThat(exactFrameTimeUs - foundTimeUs).isAtMost(IndexSeeker.MIN_TIME_BETWEEN_POINTS_US);
}
use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class IndexSeekerTest method assertFirstFrameAfterSeekHasCorrectData.
private static void assertFirstFrameAfterSeekHasCorrectData(String fileName, FakeTrackOutput trackOutput, int firstFrameIndexAfterSeek) throws IOException {
FakeTrackOutput expectedTrackOutput = getExpectedTrackOutput(fileName);
long foundTimeUs = trackOutput.getSampleTimeUs(firstFrameIndexAfterSeek);
int foundFrameIndex = getFrameIndex(expectedTrackOutput, foundTimeUs);
trackOutput.assertSample(firstFrameIndexAfterSeek, expectedTrackOutput.getSampleData(foundFrameIndex), expectedTrackOutput.getSampleTimeUs(foundFrameIndex), expectedTrackOutput.getSampleFlags(foundFrameIndex), expectedTrackOutput.getSampleCryptoData(foundFrameIndex));
}
use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class IndexSeekerTest method seeking_handlesSeekToEof.
@Test
public void seeking_handlesSeekToEof() throws Exception {
String fileName = TEST_FILE_NO_SEEK_TABLE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
long targetSeekTimeUs = TEST_FILE_NO_SEEK_TABLE_DURATION;
int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
assertFirstFrameAfterSeekIsWithinMinDifference(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
assertFirstFrameAfterSeekHasCorrectData(fileName, trackOutput, extractedFrameIndex);
}
use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class IndexSeekerTest method seeking_handlesSeekingForward.
@Test
public void seeking_handlesSeekingForward() throws Exception {
String fileName = TEST_FILE_NO_SEEK_TABLE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
long firstSeekTimeUs = 987_000;
TestUtil.seekToTimeUs(extractor, seekMap, firstSeekTimeUs, dataSource, trackOutput, fileUri);
long targetSeekTimeUs = 1_234_000;
int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
assertFirstFrameAfterSeekIsWithinMinDifference(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
assertFirstFrameAfterSeekHasCorrectData(fileName, trackOutput, extractedFrameIndex);
}
use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class TsExtractorTest method customPesReader.
@Test
public void customPesReader() throws Exception {
CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(true, false);
TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0), factory);
FakeExtractorInput input = new FakeExtractorInput.Builder().setData(TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), "media/ts/sample_h262_mpeg_audio.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);
if (readResult == Extractor.RESULT_SEEK) {
input.setPosition((int) seekPositionHolder.position);
}
}
CustomEsReader reader = factory.esReader;
assertThat(reader.packetsRead).isEqualTo(2);
TrackOutput trackOutput = reader.getTrackOutput();
assertThat(trackOutput == output.trackOutputs.get(257)).isTrue();
assertThat(((FakeTrackOutput) trackOutput).lastFormat).isEqualTo(new Format.Builder().setId("1/257").setSampleMimeType("mime").setLanguage("und").build());
}
Aggregations