Class DashUtil


  • public final class DashUtil
    extends Object
    Utility methods for DASH streams.
    • Method Detail

      • loadFormatWithDrmInitData

        @Nullable
        public static Format loadFormatWithDrmInitData​(DataSource dataSource,
                                                       Period period)
                                                throws IOException
        Loads a Format for acquiring keys for a given period in a DASH manifest.
        Parameters:
        dataSource - The HttpDataSource from which data should be loaded.
        period - The Period.
        Returns:
        The loaded Format, or null if none is defined.
        Throws:
        IOException - Thrown when there is an error while loading.
      • loadSampleFormat

        @Nullable
        public static Format loadSampleFormat​(DataSource dataSource,
                                              int trackType,
                                              Representation representation,
                                              int baseUrlIndex)
                                       throws IOException
        Loads initialization data for the representation and returns the sample Format.
        Parameters:
        dataSource - The source from which the data should be loaded.
        trackType - The type of the representation. Typically one of the C TRACK_TYPE_* constants.
        representation - The representation which initialization chunk belongs to.
        baseUrlIndex - The index of the base URL to be picked from the list of base URLs.
        Returns:
        the sample Format of the given representation.
        Throws:
        IOException - Thrown when there is an error while loading.
      • loadSampleFormat

        @Nullable
        public static Format loadSampleFormat​(DataSource dataSource,
                                              int trackType,
                                              Representation representation)
                                       throws IOException
        Loads initialization data for the representation and returns the sample Format.

        Uses the first base URL for loading the format.

        Parameters:
        dataSource - The source from which the data should be loaded.
        trackType - The type of the representation. Typically one of the C TRACK_TYPE_* constants.
        representation - The representation which initialization chunk belongs to.
        Returns:
        the sample Format of the given representation.
        Throws:
        IOException - Thrown when there is an error while loading.
      • loadChunkIndex

        @Nullable
        public static ChunkIndex loadChunkIndex​(DataSource dataSource,
                                                int trackType,
                                                Representation representation,
                                                int baseUrlIndex)
                                         throws IOException
        Loads initialization and index data for the representation and returns the ChunkIndex.
        Parameters:
        dataSource - The source from which the data should be loaded.
        trackType - The type of the representation. Typically one of the C TRACK_TYPE_* constants.
        representation - The representation which initialization chunk belongs to.
        baseUrlIndex - The index of the base URL with which to resolve the request URI.
        Returns:
        The ChunkIndex of the given representation, or null if no initialization or index data exists.
        Throws:
        IOException - Thrown when there is an error while loading.
      • loadChunkIndex

        @Nullable
        public static ChunkIndex loadChunkIndex​(DataSource dataSource,
                                                int trackType,
                                                Representation representation)
                                         throws IOException
        Loads initialization and index data for the representation and returns the ChunkIndex.

        Uses the first base URL for loading the index.

        Parameters:
        dataSource - The source from which the data should be loaded.
        trackType - The type of the representation. Typically one of the C TRACK_TYPE_* constants.
        representation - The representation which initialization chunk belongs to.
        Returns:
        The ChunkIndex of the given representation, or null if no initialization or index data exists.
        Throws:
        IOException - Thrown when there is an error while loading.
      • loadInitializationData

        public static void loadInitializationData​(ChunkExtractor chunkExtractor,
                                                  DataSource dataSource,
                                                  Representation representation,
                                                  boolean loadIndex)
                                           throws IOException
        Loads initialization data for the representation and optionally index data then returns a BundledChunkExtractor which contains the output.

        Uses the first base URL for loading the initialization data.

        Parameters:
        chunkExtractor - The ChunkExtractor to use.
        dataSource - The source from which the data should be loaded.
        representation - The representation which initialization chunk belongs to.
        loadIndex - Whether to load index data too.
        Throws:
        IOException - Thrown when there is an error while loading.
      • resolveCacheKey

        public static String resolveCacheKey​(Representation representation,
                                             RangedUri rangedUri)
        Resolves the cache key to be used when requesting the given ranged URI for the given Representation.
        Parameters:
        representation - The Representation to which the URI belongs to.
        rangedUri - The URI for which to resolve the cache key.
        Returns:
        The cache key.