Search in sources :

Example 1 with DefaultTsPayloadReaderFactory

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

the class HlsMediaChunk method createExtractor.

private Extractor createExtractor() {
    // Select the extractor that will read the chunk.
    Extractor extractor;
    boolean usingNewExtractor = true;
    if (MimeTypes.TEXT_VTT.equals(hlsUrl.format.sampleMimeType) || lastPathSegment.endsWith(WEBVTT_FILE_EXTENSION) || lastPathSegment.endsWith(VTT_FILE_EXTENSION)) {
        extractor = new WebvttExtractor(trackFormat.language, timestampAdjuster);
    } else if (!needNewExtractor) {
        // Only reuse TS and fMP4 extractors.
        usingNewExtractor = false;
        extractor = previousExtractor;
    } else if (lastPathSegment.endsWith(MP4_FILE_EXTENSION) || lastPathSegment.startsWith(M4_FILE_EXTENSION_PREFIX, lastPathSegment.length() - 4)) {
        extractor = new FragmentedMp4Extractor(0, timestampAdjuster);
    } else {
        // MPEG-2 TS segments, but we need a new extractor.
        // This flag ensures the change of pid between streams does not affect the sample queues.
        @DefaultTsPayloadReaderFactory.Flags int esReaderFactoryFlags = DefaultTsPayloadReaderFactory.FLAG_IGNORE_SPLICE_INFO_STREAM;
        if (!muxedCaptionFormats.isEmpty()) {
            // The playlist declares closed caption renditions, we should ignore descriptors.
            esReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_OVERRIDE_CAPTION_DESCRIPTORS;
        }
        String codecs = trackFormat.codecs;
        if (!TextUtils.isEmpty(codecs)) {
            // explicitly ignore them even if they're declared.
            if (!MimeTypes.AUDIO_AAC.equals(MimeTypes.getAudioMediaMimeType(codecs))) {
                esReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_IGNORE_AAC_STREAM;
            }
            if (!MimeTypes.VIDEO_H264.equals(MimeTypes.getVideoMediaMimeType(codecs))) {
                esReaderFactoryFlags |= DefaultTsPayloadReaderFactory.FLAG_IGNORE_H264_STREAM;
            }
        }
        extractor = new TsExtractor(TsExtractor.MODE_HLS, timestampAdjuster, new DefaultTsPayloadReaderFactory(esReaderFactoryFlags, muxedCaptionFormats));
    }
    if (usingNewExtractor) {
        extractor.init(extractorOutput);
    }
    return extractor;
}
Also used : FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) FragmentedMp4Extractor(com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor) Extractor(com.google.android.exoplayer2.extractor.Extractor) TsExtractor(com.google.android.exoplayer2.extractor.ts.TsExtractor) Mp3Extractor(com.google.android.exoplayer2.extractor.mp3.Mp3Extractor) AdtsExtractor(com.google.android.exoplayer2.extractor.ts.AdtsExtractor) Ac3Extractor(com.google.android.exoplayer2.extractor.ts.Ac3Extractor) TsExtractor(com.google.android.exoplayer2.extractor.ts.TsExtractor) DefaultTsPayloadReaderFactory(com.google.android.exoplayer2.extractor.ts.DefaultTsPayloadReaderFactory)

Aggregations

Extractor (com.google.android.exoplayer2.extractor.Extractor)1 Mp3Extractor (com.google.android.exoplayer2.extractor.mp3.Mp3Extractor)1 FragmentedMp4Extractor (com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor)1 Ac3Extractor (com.google.android.exoplayer2.extractor.ts.Ac3Extractor)1 AdtsExtractor (com.google.android.exoplayer2.extractor.ts.AdtsExtractor)1 DefaultTsPayloadReaderFactory (com.google.android.exoplayer2.extractor.ts.DefaultTsPayloadReaderFactory)1 TsExtractor (com.google.android.exoplayer2.extractor.ts.TsExtractor)1