Package com.brightcove.player.controller
Class BrightcoveSourceSelector
- java.lang.Object
-
- com.brightcove.player.controller.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 Summary
Constructors Constructor Description BrightcoveSourceSelector()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Source
findBestSourceByBitRate(SourceCollection sourceCollection, java.lang.Integer bitRate)
Given a SourceCollection, finds the Source with the closest bit rate to the given value.static SourceCollection
findHEVCSources(SourceCollection sourceCollection)
Searches for HEVC sources in the providedSourceCollection
and creates a newSourceCollection
with the sources found.static SourceCollection
findNonHEVCSources(SourceCollection sourceCollection)
Searches for non HEVC sources in the providedSourceCollection
and creates a newSourceCollection
with the sources found.static java.util.Set<Source>
findSourcesByProfileVersion(SourceCollection sourceCollection, java.lang.String profileVersion)
Find the Sources in the SourceCollection associated to the provided profile version.boolean
isPreferHls()
Returns whether to prefer HLS sources to otherdelivery types
.Source
selectSource(Video video)
Determines best appropriate Source within given Video object based on logic implemented.static Source
selectSource(java.util.Set<Source> sources)
Attempts to select the HTTPS source included in the source Set, if available.void
setPreferHls(boolean preferHls)
Sets whether to prefer HLS sources to otherdelivery types
.
-
-
-
Method Detail
-
isPreferHls
public boolean isPreferHls()
Returns whether to prefer HLS sources to otherdelivery types
. By default, this will be true if running on a device with API level greater than or equal toBuild.VERSION_CODES.ICE_CREAM_SANDWICH
.- Returns:
- true if HLS is preferred.
-
setPreferHls
public void setPreferHls(boolean preferHls)
Sets whether to prefer HLS sources to otherdelivery types
. By default, this will be true if running on a device with API level greater than or equal toBuild.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 interfaceSourceSelector
- 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 nullNoSourceFoundException
- when no validSource
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 foundbitRate
- 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 toSourceCollection
of typyDeliveryType.HLS
, and its profile version, for exampleSource.EXT_X_VERSION_5
orSource.EXT_X_VERSION_4
.The Set will be empty when no sources are found.
- Parameters:
sourceCollection
- the source collectionprofileVersion
- 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
-
findHEVCSources
@NonNull public static SourceCollection findHEVCSources(@NonNull SourceCollection sourceCollection)
Searches for HEVC sources in the providedSourceCollection
and creates a newSourceCollection
with the sources found. If no HEVC sources were found,SourceCollection.EMPTY
is returned.- Parameters:
sourceCollection
- the Source Collection to look for HEVC sources- Returns:
- a new Source Collection with the HEVC sources if any, or
SourceCollection.EMPTY
otherwise
-
findNonHEVCSources
@NonNull public static SourceCollection findNonHEVCSources(@NonNull SourceCollection sourceCollection)
Searches for non HEVC sources in the providedSourceCollection
and creates a newSourceCollection
with the sources found. If only HEVC sources were found,SourceCollection.EMPTY
is returned.- Parameters:
sourceCollection
- the Source Collection to look for HEVC sources- Returns:
- a new Source Collection with the non HEVC sources if any, or
SourceCollection.EMPTY
otherwise
-
-