Search in sources :

Example 76 with Extractor

use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.

the class DefaultExtractorsFactoryTest method createExtractors_withMediaInfo_optimizesSniffingOrder.

@Test
public void createExtractors_withMediaInfo_optimizesSniffingOrder() {
    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(3, extractors.length)).containsExactly(FlvExtractor.class, FlacExtractor.class, WavExtractor.class, AmrExtractor.class, PsExtractor.class, OggExtractor.class, TsExtractor.class, MatroskaExtractor.class, AdtsExtractor.class, Ac3Extractor.class, Ac4Extractor.class, JpegExtractor.class).inOrder();
}
Also used : JpegExtractor(com.google.android.exoplayer2.extractor.jpeg.JpegExtractor) HashMap(java.util.HashMap) AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Ac4Extractor(com.google.android.exoplayer2.extractor.ts.Ac4Extractor) MatroskaExtractor(com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor) Uri(android.net.Uri) TsExtractor(com.google.android.exoplayer2.extractor.ts.TsExtractor) FlacExtractor(com.google.android.exoplayer2.extractor.flac.FlacExtractor) AmrExtractor(com.google.android.exoplayer2.extractor.amr.AmrExtractor) PsExtractor(com.google.android.exoplayer2.extractor.ts.PsExtractor) OggExtractor(com.google.android.exoplayer2.extractor.ogg.OggExtractor) WavExtractor(com.google.android.exoplayer2.extractor.wav.WavExtractor) ArrayList(java.util.ArrayList) List(java.util.List) FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) PsExtractor(com.google.android.exoplayer2.extractor.ts.PsExtractor) FlvExtractor(com.google.android.exoplayer2.extractor.flv.FlvExtractor) OggExtractor(com.google.android.exoplayer2.extractor.ogg.OggExtractor) TsExtractor(com.google.android.exoplayer2.extractor.ts.TsExtractor) JpegExtractor(com.google.android.exoplayer2.extractor.jpeg.JpegExtractor) Mp4Extractor(com.google.android.exoplayer2.extractor.mp4.Mp4Extractor) Mp3Extractor(com.google.android.exoplayer2.extractor.mp3.Mp3Extractor) Ac4Extractor(com.google.android.exoplayer2.extractor.ts.Ac4Extractor) WavExtractor(com.google.android.exoplayer2.extractor.wav.WavExtractor) AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor) AmrExtractor(com.google.android.exoplayer2.extractor.amr.AmrExtractor) MatroskaExtractor(com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor) FlacExtractor(com.google.android.exoplayer2.extractor.flac.FlacExtractor) FlvExtractor(com.google.android.exoplayer2.extractor.flv.FlvExtractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor) Test(org.junit.Test)

Example 77 with Extractor

use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.

the class FlacExtractorSeekTest method seeking_binarySearch_handlesSeekingBackward.

@Test
public void seeking_binarySearch_handlesSeekingBackward() 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 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);
    assertFirstFrameAfterSeekContainsTargetSeekTime(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 78 with Extractor

use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.

the class FlacExtractorSeekTest method seeking_seekTable_handlesSeekingBackward.

@Test
public void seeking_seekTable_handlesSeekingBackward() 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 = 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);
    assertFirstFrameAfterSeekPrecedesTargetSeekTime(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 79 with Extractor

use of com.google.android.exoplayer2.extractor.Extractor 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);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 80 with Extractor

use of com.google.android.exoplayer2.extractor.Extractor in project ExoPlayer by google.

the class FlvExtractorSeekTest method setUp.

@Before
public void setUp() throws Exception {
    extractor = new FlvExtractor();
    extractorOutput = new FakeExtractorOutput();
    dataSource = new DefaultDataSource.Factory(ApplicationProvider.getApplicationContext()).createDataSource();
}
Also used : FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)87 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)74 Uri (android.net.Uri)66 FakeTrackOutput (com.google.android.exoplayer2.testutil.FakeTrackOutput)59 FakeExtractorOutput (com.google.android.exoplayer2.testutil.FakeExtractorOutput)44 ExtractorInput (com.google.android.exoplayer2.extractor.ExtractorInput)14 FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)12 DefaultExtractorInput (com.google.android.exoplayer2.extractor.DefaultExtractorInput)11 Extractor (com.google.android.exoplayer2.extractor.Extractor)11 Nullable (androidx.annotation.Nullable)9 FragmentedMp4Extractor (com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor)9 Mp3Extractor (com.google.android.exoplayer2.extractor.mp3.Mp3Extractor)8 WebvttDecoder (com.google.android.exoplayer2.text.webvtt.WebvttDecoder)8 Format (com.google.android.exoplayer2.Format)7 PositionHolder (com.google.android.exoplayer2.extractor.PositionHolder)7 Ac3Extractor (com.google.android.exoplayer2.extractor.ts.Ac3Extractor)7 AdtsExtractor (com.google.android.exoplayer2.extractor.ts.AdtsExtractor)7 TsExtractor (com.google.android.exoplayer2.extractor.ts.TsExtractor)7 ExtractorsFactory (com.google.android.exoplayer2.extractor.ExtractorsFactory)5 MatroskaExtractor (com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor)5