public final class

ExperimentalBandwidthMeter.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.exoplayer.upstream.experimental.ExperimentalBandwidthMeter.Builder

Overview

Builder for a bandwidth meter.

Summary

Constructors
publicBuilder(Context context)

Creates a builder with default parameters and without listener.

Methods
public ExperimentalBandwidthMeterbuild()

Builds the bandwidth meter.

public ExperimentalBandwidthMeter.BuildersetBandwidthEstimator(BandwidthEstimator bandwidthEstimator)

Sets the BandwidthEstimator used.

public ExperimentalBandwidthMeter.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 ExperimentalBandwidthMeter.BuildersetInitialBitrateEstimate(long initialBitrateEstimate)

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

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

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

public ExperimentalBandwidthMeter.BuildersetResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)

Sets whether to reset if the network type changes.

public ExperimentalBandwidthMeter.BuildersetTimeToFirstByteEstimator(TimeToFirstByteEstimator timeToFirstByteEstimator)

Sets the TimeToFirstByteEstimator to be used.

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

initialBitrateEstimate: The initial bitrate estimate in bits per second.

Returns:

This builder.

public ExperimentalBandwidthMeter.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 ExperimentalBandwidthMeter.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 ExperimentalBandwidthMeter.Builder setTimeToFirstByteEstimator(TimeToFirstByteEstimator timeToFirstByteEstimator)

Sets the TimeToFirstByteEstimator to be used.

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

Parameters:

timeToFirstByteEstimator: The TimeToFirstByteEstimator to be used.

Returns:

This builder.

public ExperimentalBandwidthMeter.Builder setBandwidthEstimator(BandwidthEstimator bandwidthEstimator)

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

public ExperimentalBandwidthMeter.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.

Builds the bandwidth meter.

Returns:

A bandwidth meter with the configured properties.