use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class FlacExtractorSeekTest method assertFirstFrameAfterSeekPrecedesTargetSeekTime.
private static void assertFirstFrameAfterSeekPrecedesTargetSeekTime(String fileName, FakeTrackOutput trackOutput, long targetSeekTimeUs, int firstFrameIndexAfterSeek) throws IOException {
FakeTrackOutput expectedTrackOutput = getExpectedTrackOutput(fileName);
int maxFrameIndex = getFrameIndex(expectedTrackOutput, targetSeekTimeUs);
long firstFrameAfterSeekTimeUs = trackOutput.getSampleTimeUs(firstFrameIndexAfterSeek);
assertThat(firstFrameAfterSeekTimeUs).isAtMost(targetSeekTimeUs);
boolean frameFound = false;
for (int i = maxFrameIndex; i >= 0; i--) {
if (firstFrameAfterSeekTimeUs == expectedTrackOutput.getSampleTimeUs(i)) {
trackOutput.assertSample(firstFrameIndexAfterSeek, expectedTrackOutput.getSampleData(i), expectedTrackOutput.getSampleTimeUs(i), expectedTrackOutput.getSampleFlags(i), expectedTrackOutput.getSampleCryptoData(i));
frameFound = true;
break;
}
}
assertThat(frameFound).isTrue();
}
use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class FlacExtractorSeekTest method seeking_binarySearch_handlesSeekToEoF.
@Test
public void seeking_binarySearch_handlesSeekToEoF() throws IOException {
String fileName = TEST_FILE_BINARY_SEARCH;
Uri fileUri = TestUtil.buildAssetUri(fileName);
SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
long targetSeekTimeUs = seekMap.getDurationUs();
int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
assertFirstFrameAfterSeekContainsTargetSeekTime(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class FlacExtractorSeekTest method seeking_seekTable_handlesSeekToEoF.
@Test
public void seeking_seekTable_handlesSeekToEoF() throws IOException {
String fileName = TEST_FILE_SEEK_TABLE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
long targetSeekTimeUs = seekMap.getDurationUs();
int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
assertFirstFrameAfterSeekPrecedesTargetSeekTime(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class FlacExtractorSeekTest method seeking_seekTable_handlesSeekingForward.
@Test
public void seeking_seekTable_handlesSeekingForward() throws IOException {
String fileName = TEST_FILE_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);
assertFirstFrameAfterSeekPrecedesTargetSeekTime(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.
the class PsExtractorSeekTest method handlePendingSeek_handlesSeekingForward_extractsCorrectFrame.
@Test
public void handlePendingSeek_handlesSeekingForward_extractsCorrectFrame() throws IOException {
PsExtractor extractor = new PsExtractor();
FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
SeekMap seekMap = extractSeekMapAndTracks(extractor, extractorOutput);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(VIDEO_TRACK_ID);
long firstSeekTimeUs = 987_000;
seekToTimeUs(extractor, seekMap, firstSeekTimeUs, trackOutput);
long targetSeekTimeUs = 1_234_000;
int extractedFrameIndex = seekToTimeUs(extractor, seekMap, targetSeekTimeUs, trackOutput);
assertThat(extractedFrameIndex).isNotEqualTo(-1);
assertFirstFrameAfterSeekContainsTargetSeekTime(trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
Aggregations