DefaultBandwidthMeter.Builder


public final class DefaultBandwidthMeter.Builder


Builder for a bandwidth meter.

Summary

Public constructors

Builder(Context context)

Creates a builder with default parameters and without listener.

Public methods

DefaultBandwidthMeter

Builds the bandwidth meter.

DefaultBandwidthMeter.Builder

Sets the clock used to estimate bandwidth from data transfers.

DefaultBandwidthMeter.Builder

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

DefaultBandwidthMeter.Builder
@CanIgnoreReturnValue
setInitialBitrateEstimate(long initialBitrateEstimate)

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

DefaultBandwidthMeter.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.

DefaultBandwidthMeter.Builder
@CanIgnoreReturnValue
setResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)

Sets whether to reset if the network type changes.

DefaultBandwidthMeter.Builder
@CanIgnoreReturnValue
setSlidingWindowMaxWeight(int slidingWindowMaxWeight)

Sets the maximum weight for the sliding window.

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 DefaultBandwidthMeter build()

Builds the bandwidth meter.

Returns
DefaultBandwidthMeter

A bandwidth meter with the configured properties.

setClock

@CanIgnoreReturnValue
public DefaultBandwidthMeter.Builder setClock(Clock clock)

Sets the clock used to estimate bandwidth from data transfers. Should only be set for testing purposes.

Parameters
Clock clock

The clock used to estimate bandwidth from data transfers.

Returns
DefaultBandwidthMeter.Builder

This builder.

setInitialBitrateEstimate

@CanIgnoreReturnValue
public DefaultBandwidthMeter.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
DefaultBandwidthMeter.Builder

This builder.

setInitialBitrateEstimate

@CanIgnoreReturnValue
public DefaultBandwidthMeter.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
DefaultBandwidthMeter.Builder

This builder.

setInitialBitrateEstimate

@CanIgnoreReturnValue
public DefaultBandwidthMeter.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
DefaultBandwidthMeter.Builder

This builder.

setResetOnNetworkTypeChange

@CanIgnoreReturnValue
public DefaultBandwidthMeter.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
DefaultBandwidthMeter.Builder

This builder.

setSlidingWindowMaxWeight

@CanIgnoreReturnValue
public DefaultBandwidthMeter.Builder setSlidingWindowMaxWeight(int slidingWindowMaxWeight)

Sets the maximum weight for the sliding window.

Parameters
int slidingWindowMaxWeight

The maximum weight for the sliding window.

Returns
DefaultBandwidthMeter.Builder

This builder.