use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.
the class DefaultExtractorsFactoryTest method createExtractors_withMediaInfo_startsWithExtractorsMatchingHeadersAndThenUri.
@Test
public void createExtractors_withMediaInfo_startsWithExtractorsMatchingHeadersAndThenUri() {
DefaultExtractorsFactory defaultExtractorsFactory = new DefaultExtractorsFactory();
Uri uri = Uri.parse("test.mp3");
Map<String, List<String>> responseHeaders = new HashMap<>();
responseHeaders.put("Content-Type", Collections.singletonList(MimeTypes.VIDEO_MP4));
Extractor[] extractors = defaultExtractorsFactory.createExtractors(uri, responseHeaders);
List<Class<? extends Extractor>> extractorClasses = getExtractorClasses(extractors);
assertThat(extractorClasses.subList(0, 2)).containsExactly(Mp4Extractor.class, FragmentedMp4Extractor.class);
assertThat(extractorClasses.get(2)).isEqualTo(Mp3Extractor.class);
}
use of com.google.android.exoplayer2.extractor.Extractor 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.Extractor in project ExoPlayer by google.
the class ConstantBitrateSeekerTest method setUp.
@Before
public void setUp() throws Exception {
extractor = new Mp3Extractor();
extractorOutput = new FakeExtractorOutput();
dataSource = new DefaultDataSource.Factory(ApplicationProvider.getApplicationContext()).createDataSource();
}
use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.
the class ConstantBitrateSeekerTest method seeking_handlesSeekToZero.
@Test
public void seeking_handlesSeekToZero() 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 targetSeekTimeUs = 0;
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.Extractor in project ExoPlayer by google.
the class ConstantBitrateSeekerTest method seeking_handlesSeekingBackward.
@Test
public void seeking_handlesSeekingBackward() 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 = 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);
assertFirstFrameAfterSeekIsExactFrame(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
Aggregations