ExperimentalBandwidthMeter.Builder


public final class ExperimentalBandwidthMeter.Builder


Builder for a bandwidth meter.

Summary

Public constructors

Builder(Context context)

Creates a builder with default parameters and without listener.

Public methods

ExperimentalBandwidthMeter

Builds the bandwidth meter.

ExperimentalBandwidthMeter.Builder

Sets the BandwidthEstimator used.

ExperimentalBandwidthMeter.Builder

Sets the initial bitrate estimates to the default values of the specified country.

ExperimentalBandwidthMeter.Builder
@CanIgnoreReturnValue
setInitialBitrateEstimate(long initialBitrateEstimate)

Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable.

ExperimentalBandwidthMeter.Builder
@CanIgnoreReturnValue
setInitialBitrateEstimate(
    @C.NetworkType int networkType,
    long initialBitrateEstimate
)

Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable and the current network connection is of the specified type.

ExperimentalBandwidthMeter.Builder
@CanIgnoreReturnValue
setResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)

Sets whether to reset if the network type changes.

ExperimentalBandwidthMeter.Builder

Sets the TimeToFirstByteEstimator to be used.

Public constructors

Builder

public Builder(Context context)

Creates a builder with default parameters and without listener.

Parameters
Context context

A context.

Public methods

build

public ExperimentalBandwidthMeter build()

Builds the bandwidth meter.

Returns
ExperimentalBandwidthMeter

A bandwidth meter with the configured properties.

setBandwidthEstimator

@CanIgnoreReturnValue
public ExperimentalBandwidthMeter.Builder setBandwidthEstimator(BandwidthEstimator bandwidthEstimator)

Sets the BandwidthEstimator used. By default, this is set to a using a .

setInitialBitrateEstimate

@CanIgnoreReturnValue
public ExperimentalBandwidthMeter.Builder setInitialBitrateEstimate(String countryCode)

Sets the initial bitrate estimates to the default values of the specified country. The initial estimates are used when a bandwidth estimate is unavailable.

Parameters
String countryCode

The ISO 3166-1 alpha-2 country code of the country whose default bitrate estimates should be used.

Returns
ExperimentalBandwidthMeter.Builder

This builder.

setInitialBitrateEstimate

@CanIgnoreReturnValue
public ExperimentalBandwidthMeter.Builder setInitialBitrateEstimate(long initialBitrateEstimate)

Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable.

Parameters
long initialBitrateEstimate

The initial bitrate estimate in bits per second.

Returns
ExperimentalBandwidthMeter.Builder

This builder.

setInitialBitrateEstimate

@CanIgnoreReturnValue
public ExperimentalBandwidthMeter.Builder setInitialBitrateEstimate(
    @C.NetworkType int networkType,
    long initialBitrateEstimate
)

Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable and the current network connection is of the specified type.

Parameters
@C.NetworkType int networkType

The C.NetworkType this initial estimate is for.

long initialBitrateEstimate

The initial bitrate estimate in bits per second.

Returns
ExperimentalBandwidthMeter.Builder

This builder.

setResetOnNetworkTypeChange

@CanIgnoreReturnValue
public ExperimentalBandwidthMeter.Builder setResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)

Sets whether to reset if the network type changes. The default value is true.

Parameters
boolean resetOnNetworkTypeChange

Whether to reset if the network type changes.

Returns
ExperimentalBandwidthMeter.Builder

This builder.

setTimeToFirstByteEstimator

@CanIgnoreReturnValue
public ExperimentalBandwidthMeter.Builder setTimeToFirstByteEstimator(
    TimeToFirstByteEstimator timeToFirstByteEstimator
)

Sets the TimeToFirstByteEstimator to be used.

Default is PercentileTimeToFirstByteEstimator with a sliding window size of DEFAULT_TIME_TO_FIRST_BYTE_SAMPLES that uses a percentile of DEFAULT_TIME_TO_FIRST_BYTE_PERCENTILE.

Parameters
TimeToFirstByteEstimator timeToFirstByteEstimator

The TimeToFirstByteEstimator to be used.

Returns
ExperimentalBandwidthMeter.Builder

This builder.