Package com.castlabs.android.player

## Class CastlabsBandwidthMeter

- java.lang.Object
- - com.castlabs.abr.gen.BandwidthMeter
  - - com.castlabs.abr.gen.DefaultBandwidthMeter
    - - com.castlabs.android.player.CastlabsBandwidthMeter

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

      public final class CastlabsBandwidthMeter
      extends com.castlabs.abr.gen.DefaultBandwidthMeter
      implements com.google.android.exoplayer2.upstream.BandwidthMeter, com.google.android.exoplayer2.upstream.TransferListener, Disposable

  This class is a `TransferListener` receiving transfer progress and providing bandwidth metering via common ABR `BandwidthMeter` and Exo `BandwidthMeter` interfaces.

  The bandwidth metering uses the default implementation of common ABR `DefaultBandwidthMeter`. The sampling data is pushed via `TransferListener`. The granularity of bandwidth metering is based on both the time and byte thresholds.
  Since:
    4.1.7

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `CastlabsBandwidthMeter.Builder` | Builder for a bandwidth meter.

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

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addEventListener​(Handler eventHandler, com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)` |
    `void` | `dispose()` |
    `long` | `getBitrateEstimate()` |
    `long` | `getLastSegmentDownloadMs()` |
    `com.google.android.exoplayer2.upstream.TransferListener` | `getTransferListener()` |
    `void` | `keep()` |
    `void` | `onBytesTransferred​(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork, int bytes)` |
    `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)` |

    - ### Methods inherited from class com.castlabs.abr.gen.DefaultBandwidthMeter

      `delete, getAverageBps, getBytesSampled, getEstimateBitrateInfo, getEstimateBps, getLastBitrate, getPercentileWeight, getSampleAverage, getSlidingPercentile, push, setPercentileWeight, setSlidingPercentile`

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

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

- - ### Method Detail

    - #### keep

          public void keep()

      Specified by:
        `keep` in interface `Disposable`

    - #### dispose

          public void dispose()

      Specified by:
        `dispose` in interface `Disposable`

    - #### getLastSegmentDownloadMs

          public long getLastSegmentDownloadMs()

    - #### 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()

      Specified by:
        `getTransferListener` in interface `com.google.android.exoplayer2.upstream.BandwidthMeter`

    - #### 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 bytes)

      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`