Class DefaultSourceSelectionController

All Implemented Interfaces:
SourceSelector, Component
Direct Known Subclasses:

@ListensFor(events="selectSource") @Emits(events="sourceNotFound") public class DefaultSourceSelectionController extends AbstractComponent implements Component, SourceSelector
Default SourceSelector controller responsible to react to the EventType.SELECT_SOURCE event and call SourceSelector.selectSource(Video) of the SourceSelector set. By default, BrightcoveSourceSelector is used.

The selected Source will be added to the EventType.SELECT_SOURCE event properties with the AbstractEvent.SOURCE key.

  • Field Details

    • TAG

      public static final String TAG
  • Constructor Details

    • DefaultSourceSelectionController

      public DefaultSourceSelectionController(@NonNull EventEmitter eventEmitter)
      Initializes this controller with the given EventEmitter using the default BrightcoveSourceSelector.
      eventEmitter - the EventEmitter through which this controller will interact
  • Method Details

    • create

      public static DefaultSourceSelectionController create(@NonNull EventEmitter eventEmitter)
      Creates the Default Source Selection Controller using the default BrightcoveSourceSelector.
      eventEmitter - the event emitter
      the default source selection controller
    • createWithSourceSelector

      public static DefaultSourceSelectionController createWithSourceSelector(@NonNull EventEmitter eventEmitter, @NonNull SourceSelector sourceSelector)
      Creates the Default Source Selection Controller with a custom SourceSelector.
      eventEmitter - the event emitter
      sourceSelector - the source selector
      the default source selection controller
    • setSourceSelector

      public void setSourceSelector(@NonNull SourceSelector sourceSelector)
    • getSourceSelector

      @NonNull public SourceSelector getSourceSelector()
    • selectSource

      @NonNull public Source selectSource(@NonNull Video video) throws NoSourceFoundException
      Description copied from interface: SourceSelector
      Determines best appropriate Source within given Video object based on logic implemented.
      Specified by:
      selectSource in interface SourceSelector
      video - Video in which to find the most appropriate Source
      the best matched Source based on the currently implemented selection logic
      NoSourceFoundException - when no valid Source is found
      See Also:
    • selectSource

      @Nullable protected Source selectSource(@Nullable 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.

      sources - the source Set.
      the selected source
    • findBestSourceByBitRate

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

      protected void initializeListeners()