Search in sources :

Example 1 with BundledChunkExtractor

use of com.google.android.exoplayer2.source.chunk.BundledChunkExtractor 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 2 with BundledChunkExtractor

use of com.google.android.exoplayer2.source.chunk.BundledChunkExtractor in project ExoPlayer by google.

the class DashUtil method loadInitializationData.

/**
 * Loads initialization data for the {@code representation} and optionally index data then returns
 * a {@link BundledChunkExtractor} which contains the output.
 *
 * @param chunkExtractor The {@link ChunkExtractor} to use.
 * @param dataSource The source from which the data should be loaded.
 * @param representation The representation which initialization chunk belongs to.
 * @param baseUrlIndex The index of the base URL with which to resolve the request URI.
 * @param loadIndex Whether to load index data too.
 * @throws IOException Thrown when there is an error while loading.
 */
private static void loadInitializationData(ChunkExtractor chunkExtractor, DataSource dataSource, Representation representation, int baseUrlIndex, boolean loadIndex) throws IOException {
    RangedUri initializationUri = Assertions.checkNotNull(representation.getInitializationUri());
    @Nullable RangedUri requestUri;
    if (loadIndex) {
        @Nullable RangedUri indexUri = representation.getIndexUri();
        if (indexUri == null) {
            return;
        }
        // It's common for initialization and index data to be stored adjacently. Attempt to merge
        // the two requests together to request both at once.
        requestUri = initializationUri.attemptMerge(indexUri, representation.baseUrls.get(baseUrlIndex).url);
        if (requestUri == null) {
            loadInitializationData(dataSource, representation, baseUrlIndex, chunkExtractor, initializationUri);
            requestUri = indexUri;
        }
    } else {
        requestUri = initializationUri;
    }
    loadInitializationData(dataSource, representation, baseUrlIndex, chunkExtractor, requestUri);
}
Also used : RangedUri(com.google.android.exoplayer2.source.dash.manifest.RangedUri) Nullable(androidx.annotation.Nullable)

Aggregations

Nullable (androidx.annotation.Nullable)1 Extractor (com.google.android.exoplayer2.extractor.Extractor)1 MatroskaExtractor (com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor)1 FragmentedMp4Extractor (com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor)1 BundledChunkExtractor (com.google.android.exoplayer2.source.chunk.BundledChunkExtractor)1 ChunkExtractor (com.google.android.exoplayer2.source.chunk.ChunkExtractor)1 RangedUri (com.google.android.exoplayer2.source.dash.manifest.RangedUri)1