DefaultBandwidthMeter.Builder


class DefaultBandwidthMeter.Builder


Builder for a bandwidth meter.

Summary

Public constructors

Builder(context: Context!)

Creates a builder with default parameters and without listener.

Public functions

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!

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 networkType: Int,
    initialBitrateEstimate: Long
)

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!

Sets whether to reset if the network type changes.

DefaultBandwidthMeter.Builder!

Sets the maximum weight for the sliding window.

Public constructors

Builder

Builder(context: Context!)

Creates a builder with default parameters and without listener.

Parameters
context: Context!

A context.

Public functions

build

fun build(): DefaultBandwidthMeter!

Builds the bandwidth meter.

Returns
DefaultBandwidthMeter!

A bandwidth meter with the configured properties.

setClock

@CanIgnoreReturnValue
fun setClock(clock: Clock!): DefaultBandwidthMeter.Builder!

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
fun setInitialBitrateEstimate(countryCode: String!): DefaultBandwidthMeter.Builder!

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
countryCode: String!

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
fun setInitialBitrateEstimate(initialBitrateEstimate: Long): DefaultBandwidthMeter.Builder!

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

Parameters
initialBitrateEstimate: Long

The initial bitrate estimate in bits per second.

Returns
DefaultBandwidthMeter.Builder!

This builder.

setInitialBitrateEstimate

@CanIgnoreReturnValue
fun setInitialBitrateEstimate(
    @C.NetworkType networkType: Int,
    initialBitrateEstimate: Long
): DefaultBandwidthMeter.Builder!

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 networkType: Int

The C.NetworkType this initial estimate is for.

initialBitrateEstimate: Long

The initial bitrate estimate in bits per second.

Returns
DefaultBandwidthMeter.Builder!

This builder.

setResetOnNetworkTypeChange

@CanIgnoreReturnValue
fun setResetOnNetworkTypeChange(resetOnNetworkTypeChange: Boolean): DefaultBandwidthMeter.Builder!

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

Parameters
resetOnNetworkTypeChange: Boolean

Whether to reset if the network type changes.

Returns
DefaultBandwidthMeter.Builder!

This builder.

setSlidingWindowMaxWeight

@CanIgnoreReturnValue
fun setSlidingWindowMaxWeight(slidingWindowMaxWeight: Int): DefaultBandwidthMeter.Builder!

Sets the maximum weight for the sliding window.

Parameters
slidingWindowMaxWeight: Int

The maximum weight for the sliding window.

Returns
DefaultBandwidthMeter.Builder!

This builder.