Class PlayerBandwidthMeter

java.lang.Object
com.brightcove.player.network.PlayerBandwidthMeter
All Implemented Interfaces:
com.google.android.exoplayer2.upstream.BandwidthMeter, com.google.android.exoplayer2.upstream.TransferListener

public class PlayerBandwidthMeter extends Object implements com.google.android.exoplayer2.upstream.BandwidthMeter, com.google.android.exoplayer2.upstream.TransferListener
Provides an implementation of BandwidthMeter that tracks the total number of bytes transferred. By default all work will be delegated to DefaultBandwidthMeter. The caller may override the delegate to another instance any time.
  • Nested Class Summary

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

    com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    long
    Indicates no bandwidth estimate is available.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new instance of the bandwidth meter that will use DefaultBandwidthMeter internally to delegate the work.
    PlayerBandwidthMeter(android.content.Context context, android.os.Handler eventHandler, com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
    Constructs a new instance of the bandwidth meter that will use DefaultBandwidthMeter internally to delegate the work.
    PlayerBandwidthMeter(android.os.Handler eventHandler, com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
    Constructs a new instance of the bandwidth meter that will use DefaultBandwidthMeter internally to delegate the work.
    PlayerBandwidthMeter(com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
    Constructs a new instance of the bandwidth meter that will use given bandwidth meter to delegate the work.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addEventListener(android.os.Handler eventHandler, com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
     
    long
     
    com.google.android.exoplayer2.upstream.BandwidthMeter
    Gets reference to actual bandwidth meter that is currently being delegated to handle bitrate estimate calculations.
    long
    Gets the total number of bytes transferred so far.
    com.google.android.exoplayer2.upstream.TransferListener
     
    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)
     
    Resets the counter for total number of bytes transferred.
    void
    setDelegate(com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
    Sets reference to actual bandwidth meter that must be used to handle bitrate estimate calculations.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.google.android.exoplayer2.upstream.BandwidthMeter

    getTimeToFirstByteEstimateUs
  • Field Details

    • NO_ESTIMATE

      public long NO_ESTIMATE
      Indicates no bandwidth estimate is available.
  • Constructor Details

    • PlayerBandwidthMeter

      public PlayerBandwidthMeter()
      Constructs a new instance of the bandwidth meter that will use DefaultBandwidthMeter internally to delegate the work.
    • PlayerBandwidthMeter

      public PlayerBandwidthMeter(@Nullable android.os.Handler eventHandler, @Nullable com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
      Constructs a new instance of the bandwidth meter that will use DefaultBandwidthMeter internally to delegate the work.
      Parameters:
      eventHandler - reference to the event handler, if any.
      eventListener - reference to the event listener, if any.
    • PlayerBandwidthMeter

      public PlayerBandwidthMeter(@Nullable android.content.Context context, @Nullable android.os.Handler eventHandler, @Nullable com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
      Constructs a new instance of the bandwidth meter that will use DefaultBandwidthMeter internally to delegate the work.
      Parameters:
      eventHandler - reference to the event handler, if any.
      eventListener - reference to the event listener, if any.
    • PlayerBandwidthMeter

      public PlayerBandwidthMeter(@Nullable com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
      Constructs a new instance of the bandwidth meter that will use given bandwidth meter to delegate the work.
      Parameters:
      bandwidthMeter - reference to the bandwidth meter to be used as delegate.
  • 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()
      Specified by:
      getTransferListener in interface com.google.android.exoplayer2.upstream.BandwidthMeter
    • addEventListener

      public void addEventListener(android.os.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
    • getDelegate

      @Nullable public com.google.android.exoplayer2.upstream.BandwidthMeter getDelegate()
      Gets reference to actual bandwidth meter that is currently being delegated to handle bitrate estimate calculations.
      Returns:
      reference to a bandwidth meter, if available
    • setDelegate

      public void setDelegate(@Nullable com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
      Sets reference to actual bandwidth meter that must be used to handle bitrate estimate calculations.
    • 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
    • getTotalBytesTransferred

      public long getTotalBytesTransferred()
      Gets the total number of bytes transferred so far.
      Returns:
      the total number of bytes transferred so far.
    • resetTotalBytesTransferred

      public PlayerBandwidthMeter resetTotalBytesTransferred()
      Resets the counter for total number of bytes transferred.
      Returns:
      reference to the bandwidth meter.