Package com.brightcove.player.controller
Class BrightcoveSourceSelector
java.lang.Object
com.brightcove.player.controller.BrightcoveSourceSelector
- All Implemented Interfaces:
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic Source
findBestSourceByBitRate
(SourceCollection sourceCollection, 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.findSourcesByProfileVersion
(SourceCollection sourceCollection, String profileVersion) Find the Sources in the SourceCollection associated to the provided profile version.boolean
Returns whether to prefer HLS sources to otherdelivery types
.selectSource
(Video video) Determines best appropriate Source within given Video object based on logic implemented.static Source
selectSource
(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
.
-
Constructor Details
-
BrightcoveSourceSelector
public BrightcoveSourceSelector()
-
-
Method Details
-
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
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:
IllegalArgumentException
- when the Video passed is nullNoSourceFoundException
- when no validSource
is found
-
findBestSourceByBitRate
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 Set<Source> findSourcesByProfileVersion(@NonNull SourceCollection sourceCollection, @NonNull 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
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
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
-