Search in sources :

Example 1 with BundledChunkExtractor

use of androidx.media3.exoplayer.source.chunk.BundledChunkExtractor in project media by androidx.

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(androidx.media3.exoplayer.dash.manifest.RangedUri) Nullable(androidx.annotation.Nullable)

Example 2 with BundledChunkExtractor

use of androidx.media3.exoplayer.source.chunk.BundledChunkExtractor in project media by androidx.

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(androidx.media3.extractor.mp4.FragmentedMp4Extractor) ChunkExtractor(androidx.media3.exoplayer.source.chunk.ChunkExtractor) Extractor(androidx.media3.extractor.Extractor) BundledChunkExtractor(androidx.media3.exoplayer.source.chunk.BundledChunkExtractor) MatroskaExtractor(androidx.media3.extractor.mkv.MatroskaExtractor) FragmentedMp4Extractor(androidx.media3.extractor.mp4.FragmentedMp4Extractor) BundledChunkExtractor(androidx.media3.exoplayer.source.chunk.BundledChunkExtractor) MatroskaExtractor(androidx.media3.extractor.mkv.MatroskaExtractor)

Aggregations

Nullable (androidx.annotation.Nullable)1 RangedUri (androidx.media3.exoplayer.dash.manifest.RangedUri)1 BundledChunkExtractor (androidx.media3.exoplayer.source.chunk.BundledChunkExtractor)1 ChunkExtractor (androidx.media3.exoplayer.source.chunk.ChunkExtractor)1 Extractor (androidx.media3.extractor.Extractor)1 MatroskaExtractor (androidx.media3.extractor.mkv.MatroskaExtractor)1 FragmentedMp4Extractor (androidx.media3.extractor.mp4.FragmentedMp4Extractor)1