Package com.castlabs.android.player

# Class BandwidthMeterWrapper

java.lang.Object
com.castlabs.android.player.BandwidthMeterWrapper

All Implemented Interfaces:
  `com.google.android.exoplayer2.upstream.BandwidthMeter`, `com.google.android.exoplayer2.upstream.TransferListener`

public class BandwidthMeterWrapper extends Object implements com.google.android.exoplayer2.upstream.BandwidthMeter, com.google.android.exoplayer2.upstream.TransferListener
Wrapper implementation around the bandwidth meter. We need to allow algorithms and also some plugins to bring their own bandwidth meter. This class is exposed to the track selector as well as to plugin so they can either set a bandwidth meter delegate and/or disable tracking of transfers entirely. In the latter case, the implementations are expected to call the `onTrasferXXX` methods explicitly.

Since:
  4.2.6

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface com.google.android.exoplayer2.upstream.BandwidthMeter

  `com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addEventListener(Handler eventHandler, com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)`
  `long`
  `getBitrateEstimate()`
  `com.google.android.exoplayer2.upstream.BandwidthMeter`
  `getDelegate()`
  Returns the delegate or null if no delegate is set.
  `com.google.android.exoplayer2.upstream.TransferListener`
  `getTransferListener()`
  Return the transfer listener that will delegate to a sub meter if the transfer listener support is enabled.
  `void`
  `logTransferInfo(boolean logTransferInfo)`
  Set whether to log transfer info or not.
  `void`
  `onBytesTransferred(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork, int bytesTransferred)`
  `void`
  `onTransferEnd(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork)`
  `void`
  `onTransferInitializing(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork)`
  `void`
  `onTransferStart(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork)`
  `void`
  `removeEventListener(com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)`
  `void`
  `setDelegate(com.google.android.exoplayer2.upstream.BandwidthMeter delegate)`
  Set the delegate or null

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### getBitrateEstimate

    public long getBitrateEstimate()
    Specified by:
      `getBitrateEstimate` in interface `com.google.android.exoplayer2.upstream.BandwidthMeter`

  - ### getTransferListener

    @Nullable public com.google.android.exoplayer2.upstream.TransferListener getTransferListener()
    Return the transfer listener that will delegate to a sub meter if the transfer listener support is enabled.
    Specified by:
      `getTransferListener` in interface `com.google.android.exoplayer2.upstream.BandwidthMeter`
    Returns:
      The transfer listener or null

  - ### setDelegate

    public void setDelegate(@Nullable com.google.android.exoplayer2.upstream.BandwidthMeter delegate)
    Set the delegate or null

    Note that setting external delegate is valid only for `AbrConfiguration.METHOD_EXO`
    Parameters:
      `delegate` - The delegate

  - ### getDelegate

    @Nullable public com.google.android.exoplayer2.upstream.BandwidthMeter getDelegate()
    Returns the delegate or null if no delegate is set.
    Returns:
      The delegate or null

  - ### addEventListener

    public void addEventListener(Handler eventHandler, com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
    Specified by:
      `addEventListener` in interface `com.google.android.exoplayer2.upstream.BandwidthMeter`

  - ### removeEventListener

    public void removeEventListener(com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
    Specified by:
      `removeEventListener` in interface `com.google.android.exoplayer2.upstream.BandwidthMeter`

  - ### onTransferInitializing

    public void onTransferInitializing(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork)
    Specified by:
      `onTransferInitializing` in interface `com.google.android.exoplayer2.upstream.TransferListener`

  - ### onTransferStart

    public void onTransferStart(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork)
    Specified by:
      `onTransferStart` in interface `com.google.android.exoplayer2.upstream.TransferListener`

  - ### onBytesTransferred

    public void onBytesTransferred(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork, int bytesTransferred)
    Specified by:
      `onBytesTransferred` in interface `com.google.android.exoplayer2.upstream.TransferListener`

  - ### onTransferEnd

    public void onTransferEnd(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork)
    Specified by:
      `onTransferEnd` in interface `com.google.android.exoplayer2.upstream.TransferListener`

  - ### logTransferInfo

    public void logTransferInfo(boolean logTransferInfo)
    Set whether to log transfer info or not.

    This is useful for debugging purposes, but should be disabled in production builds.

    Parameters:
      `logTransferInfo` - Whether to log transfer info