Class DefaultBandwidthMeter.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.upstream.DefaultBandwidthMeter.Builder
-
- Enclosing class:
- DefaultBandwidthMeter
public static final class DefaultBandwidthMeter.Builder extends Object
Builder for a bandwidth meter.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultBandwidthMeterbuild()Builds the bandwidth meter.DefaultBandwidthMeter.BuildersetClock(Clock clock)Sets the clock used to estimate bandwidth from data transfers.DefaultBandwidthMeter.BuildersetInitialBitrateEstimate(@com.google.android.exoplayer2.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.BuildersetInitialBitrateEstimate(long initialBitrateEstimate)Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable.DefaultBandwidthMeter.BuildersetInitialBitrateEstimate(String countryCode)Sets the initial bitrate estimates to the default values of the specified country.DefaultBandwidthMeter.BuildersetResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)Sets whether to reset if the network type changes.DefaultBandwidthMeter.BuildersetSlidingWindowMaxWeight(int slidingWindowMaxWeight)Sets the maximum weight for the sliding window.
-
-
-
Constructor Detail
-
Builder
public Builder(Context context)
Creates a builder with default parameters and without listener.- Parameters:
context- A context.
-
-
Method Detail
-
setSlidingWindowMaxWeight
@CanIgnoreReturnValue 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.
-
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:
initialBitrateEstimate- The initial bitrate estimate in bits per second.- Returns:
- This builder.
-
setInitialBitrateEstimate
@CanIgnoreReturnValue public DefaultBandwidthMeter.Builder setInitialBitrateEstimate(@NetworkType @com.google.android.exoplayer2.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:
networkType- TheC.NetworkTypethis initial estimate is for.initialBitrateEstimate- The initial bitrate estimate in bits per second.- Returns:
- 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:
countryCode- The ISO 3166-1 alpha-2 country code of the country whose default bitrate estimates should be used.- Returns:
- This builder.
-
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- The clock used to estimate bandwidth from data transfers.- Returns:
- This builder.
-
setResetOnNetworkTypeChange
@CanIgnoreReturnValue public DefaultBandwidthMeter.Builder setResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)
Sets whether to reset if the network type changes. The default value istrue.- Parameters:
resetOnNetworkTypeChange- Whether to reset if the network type changes.- Returns:
- This builder.
-
build
public DefaultBandwidthMeter build()
Builds the bandwidth meter.- Returns:
- A bandwidth meter with the configured properties.
-
-