use of com.google.android.exoplayer2.extractor.ExtractorOutput in project ExoPlayer by google.
the class ConstantBitrateSeekerTest method seeking_handlesSeekingForward.
@Test
public void seeking_handlesSeekingForward() throws IOException {
String fileName = CONSTANT_FRAME_SIZE_TEST_FILE;
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);
assertFirstFrameAfterSeekIsExactFrame(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
use of com.google.android.exoplayer2.extractor.ExtractorOutput in project ExoPlayer by google.
the class IndexSeekerTest method setUp.
@Before
public void setUp() throws Exception {
extractor = new Mp3Extractor(FLAG_ENABLE_INDEX_SEEKING);
extractorOutput = new FakeExtractorOutput();
dataSource = new DefaultDataSource.Factory(ApplicationProvider.getApplicationContext()).createDataSource();
}
use of com.google.android.exoplayer2.extractor.ExtractorOutput in project ExoPlayer by google.
the class IndexSeekerTest method seeking_handlesSeekingBackward.
@Test
public void seeking_handlesSeekingBackward() 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 = 1_234_000;
TestUtil.seekToTimeUs(extractor, seekMap, firstSeekTimeUs, dataSource, trackOutput, fileUri);
long targetSeekTimeUs = 987_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.extractor.ExtractorOutput in project ExoPlayer by google.
the class IndexSeekerTest method seeking_handlesSeekToZero.
@Test
public void seeking_handlesSeekToZero() 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 = 0;
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.extractor.ExtractorOutput in project ExoPlayer by google.
the class AmrExtractorSeekTest method seeking_handlesRandomSeeks_extractsCorrectFrames_forNarrowBandAmr.
@Test
public void seeking_handlesRandomSeeks_extractsCorrectFrames_forNarrowBandAmr() throws IOException {
String fileName = NARROW_BAND_AMR_FILE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
AmrExtractor extractor = createAmrExtractor();
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(NARROW_BAND_FILE_DURATION_US + 1);
int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedFrameIndex).isNotEqualTo(-1);
assertFirstFrameAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
}
Aggregations