Class BrightcoveSourceSelector

  • All Implemented Interfaces:
    SourceSelector

    public class BrightcoveSourceSelector
    extends java.lang.Object
    implements SourceSelector
    It is the default SourceSelector implementation that will automatically select a Source rendition based on the following rules:
    • If an HLS source rendition exists use it (there should be only one, if any)
    • If no HLS renditions exists, but MP4 renditions exist, use the rendition that is closest to 256 kBps
    • If no HLS or MP4 renditions exist, throw a NoSourceFoundException
    • Constructor Detail

      • BrightcoveSourceSelector

        public BrightcoveSourceSelector()
    • Method Detail

      • isPreferHls

        public boolean isPreferHls()
        Returns whether to prefer HLS sources to other delivery types. By default, this will be true if running on a device with API level greater than or equal to Build.VERSION_CODES.ICE_CREAM_SANDWICH.
        Returns:
        true if HLS is preferred.
      • setPreferHls

        public void setPreferHls​(boolean preferHls)
        Sets whether to prefer HLS sources to other delivery types. By default, this will be true if running on a device with API level greater than or equal to Build.VERSION_CODES.ICE_CREAM_SANDWICH.
        Parameters:
        preferHls - true if HLS is preferred.
      • selectSource

        @NonNull
        public Source selectSource​(@NonNull
                                   Video video)
                            throws NoSourceFoundException
        Determines best appropriate Source within given Video object based on logic implemented.
        Specified by:
        selectSource in interface SourceSelector
        Parameters:
        video - Video in which to find the most appropriate Source
        Returns:
        the best matched Source based on the currently implemented selection logic
        Throws:
        java.lang.IllegalArgumentException - when the Video passed is null
        NoSourceFoundException - when no valid Source is found
      • findBestSourceByBitRate

        public static Source findBestSourceByBitRate​(SourceCollection sourceCollection,
                                                     java.lang.Integer bitRate)
        Given a SourceCollection, finds the Source with the closest bit rate to the given value.
        Parameters:
        sourceCollection - the collection of Sources in which the match should be found
        bitRate - the target bit rate desired for the chosen Source
        Returns:
        the Source that most closely matches the given bit rate, or any Source, if no match can be found
      • findSourcesByProfileVersion

        @NonNull
        public static java.util.Set<Source> findSourcesByProfileVersion​(@NonNull
                                                                        SourceCollection sourceCollection,
                                                                        @NonNull
                                                                        java.lang.String profileVersion)
        Find the Sources in the SourceCollection associated to the provided profile version. Currently this applies only to SourceCollection of typy DeliveryType.HLS, and its profile version, for example Source.EXT_X_VERSION_5 or Source.EXT_X_VERSION_4.

        The Set will be empty when no sources are found.

        Parameters:
        sourceCollection - the source collection
        profileVersion - the profile version
        Returns:
        the source set
      • selectSource

        @Nullable
        public static Source selectSource​(@Nullable
                                          java.util.Set<Source> sources)
        Attempts to select the HTTPS source included in the source Set, if available. Otherwise, it will select the first source given by the Set Iterator.

        It will return null if the sources Set is null or empty.

        Parameters:
        sources - the source Set representing the same media with different protocols, for example, HTTP and HTTPS.
        Returns:
        the selected source