Search in sources :

Example 36 with Extractor

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

the class DefaultHlsExtractorFactoryTest method createExtractor_onFailedSniff_fallsBackOnFormatInferred.

@Test
public void createExtractor_onFailedSniff_fallsBackOnFormatInferred() throws Exception {
    ExtractorInput emptyExtractorInput = new FakeExtractorInput.Builder().build();
    BundledHlsMediaChunkExtractor result = new DefaultHlsExtractorFactory().createExtractor(URI_WITH_MP4_EXTENSION, webVttFormat, /* muxedCaptionFormats= */
    null, timestampAdjuster, ac3ResponseHeaders, emptyExtractorInput, PlayerId.UNSET);
    // The format indicates WebVTT so we expect a WebVTT extractor.
    assertThat(result.extractor.getClass()).isEqualTo(WebvttExtractor.class);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) ExtractorInput(com.google.android.exoplayer2.extractor.ExtractorInput) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 37 with Extractor

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

the class DefaultHlsExtractorFactoryTest method createExtractor_onFailedSniff_fallsBackOnHttpContentType.

@Test
public void createExtractor_onFailedSniff_fallsBackOnHttpContentType() throws Exception {
    ExtractorInput emptyExtractorInput = new FakeExtractorInput.Builder().build();
    BundledHlsMediaChunkExtractor result = new DefaultHlsExtractorFactory().createExtractor(URI_WITH_MP4_EXTENSION, new Format.Builder().build(), /* muxedCaptionFormats= */
    null, timestampAdjuster, ac3ResponseHeaders, emptyExtractorInput, PlayerId.UNSET);
    // No format info, so we expect an AC-3 Extractor, as per HTTP Content-Type header.
    assertThat(result.extractor.getClass()).isEqualTo(Ac3Extractor.class);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) ExtractorInput(com.google.android.exoplayer2.extractor.ExtractorInput) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 38 with Extractor

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

the class DefaultHlsExtractorFactoryTest method createExtractor_onFailedSniff_fallsBackOnFileExtension.

@Test
public void createExtractor_onFailedSniff_fallsBackOnFileExtension() throws Exception {
    ExtractorInput emptyExtractorInput = new FakeExtractorInput.Builder().build();
    BundledHlsMediaChunkExtractor result = new DefaultHlsExtractorFactory().createExtractor(URI_WITH_MP4_EXTENSION, new Format.Builder().build(), /* muxedCaptionFormats= */
    null, timestampAdjuster, /* responseHeaders= */
    ImmutableMap.of(), emptyExtractorInput, PlayerId.UNSET);
    // No format info, and no HTTP headers, so we expect an fMP4 extractor, as per file extension.
    assertThat(result.extractor.getClass()).isEqualTo(FragmentedMp4Extractor.class);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) ExtractorInput(com.google.android.exoplayer2.extractor.ExtractorInput) FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) Test(org.junit.Test)

Example 39 with Extractor

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

the class DashUtil method newChunkExtractor.

private static ChunkExtractor newChunkExtractor(int trackType, Format format) {
    String mimeType = format.containerMimeType;
    boolean isWebm = mimeType != null && (mimeType.startsWith(MimeTypes.VIDEO_WEBM) || mimeType.startsWith(MimeTypes.AUDIO_WEBM));
    Extractor extractor = isWebm ? new MatroskaExtractor() : new FragmentedMp4Extractor();
    return new BundledChunkExtractor(extractor, trackType, format);
}
Also used : FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) BundledChunkExtractor(com.google.android.exoplayer2.source.chunk.BundledChunkExtractor) ChunkExtractor(com.google.android.exoplayer2.source.chunk.ChunkExtractor) Extractor(com.google.android.exoplayer2.extractor.Extractor) MatroskaExtractor(com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor) BundledChunkExtractor(com.google.android.exoplayer2.source.chunk.BundledChunkExtractor) MatroskaExtractor(com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor)

Example 40 with Extractor

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

the class AtomParsers method parseEdts.

/**
 * Parses the edts atom (defined in ISO/IEC 14496-12 subsection 8.6.5).
 *
 * @param edtsAtom edts (edit box) atom to decode.
 * @return Pair of edit list durations and edit list media times, or {@code null} if they are not
 *     present.
 */
@Nullable
private static Pair<long[], long[]> parseEdts(Atom.ContainerAtom edtsAtom) {
    @Nullable Atom.LeafAtom elstAtom = edtsAtom.getLeafAtomOfType(Atom.TYPE_elst);
    if (elstAtom == null) {
        return null;
    }
    ParsableByteArray elstData = elstAtom.data;
    elstData.setPosition(Atom.HEADER_SIZE);
    int fullAtom = elstData.readInt();
    int version = Atom.parseFullAtomVersion(fullAtom);
    int entryCount = elstData.readUnsignedIntToInt();
    long[] editListDurations = new long[entryCount];
    long[] editListMediaTimes = new long[entryCount];
    for (int i = 0; i < entryCount; i++) {
        editListDurations[i] = version == 1 ? elstData.readUnsignedLongToLong() : elstData.readUnsignedInt();
        editListMediaTimes[i] = version == 1 ? elstData.readLong() : elstData.readInt();
        int mediaRateInteger = elstData.readShort();
        if (mediaRateInteger != 1) {
            // The extractor does not handle dwell edits (mediaRateInteger == 0).
            throw new IllegalArgumentException("Unsupported media rate.");
        }
        elstData.skipBytes(2);
    }
    return Pair.create(editListDurations, editListMediaTimes);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) Nullable(androidx.annotation.Nullable) Nullable(androidx.annotation.Nullable)

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