public final class

DefaultBandwidthMeter.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.exoplayer.upstream.DefaultBandwidthMeter.Builder

Overview

Builder for a bandwidth meter.

Summary

Constructors
publicBuilder(Context context)

Creates a builder with default parameters and without listener.

Methods
public DefaultBandwidthMeterbuild()

Builds the bandwidth meter.

public DefaultBandwidthMeter.BuildersetClock(Clock clock)

Sets the clock used to estimate bandwidth from data transfers.

public DefaultBandwidthMeter.BuildersetInitialBitrateEstimate(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.

public DefaultBandwidthMeter.BuildersetInitialBitrateEstimate(long initialBitrateEstimate)

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

public DefaultBandwidthMeter.BuildersetInitialBitrateEstimate(java.lang.String countryCode)

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

public DefaultBandwidthMeter.BuildersetResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)

Sets whether to reset if the network type changes.

public DefaultBandwidthMeter.BuildersetSlidingWindowMaxWeight(int slidingWindowMaxWeight)

Sets the maximum weight for the sliding window.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(Context context)

Creates a builder with default parameters and without listener.

Parameters:

context: A context.

Methods

public DefaultBandwidthMeter.Builder setSlidingWindowMaxWeight(int slidingWindowMaxWeight)

Sets the maximum weight for the sliding window.

Parameters:

slidingWindowMaxWeight: The maximum weight for the sliding window.

Returns:

This builder.

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:

initialBitrateEstimate: The initial bitrate estimate in bits per second.

Returns:

This builder.

public DefaultBandwidthMeter.Builder setInitialBitrateEstimate(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:

networkType: The this initial estimate is for.
initialBitrateEstimate: The initial bitrate estimate in bits per second.

Returns:

This builder.

public DefaultBandwidthMeter.Builder setInitialBitrateEstimate(java.lang.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:

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

Returns:

This builder.

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: The clock used to estimate bandwidth from data transfers.

Returns:

This builder.

public DefaultBandwidthMeter.Builder setResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)

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

Parameters:

resetOnNetworkTypeChange: Whether to reset if the network type changes.

Returns:

This builder.

public DefaultBandwidthMeter build()

Builds the bandwidth meter.

Returns:

A bandwidth meter with the configured properties.