Class ExperimentalBandwidthMeter.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.upstream.experimental.ExperimentalBandwidthMeter.Builder
-
- Enclosing class:
- ExperimentalBandwidthMeter
public static final class ExperimentalBandwidthMeter.Builder extends Object
Builder for a bandwidth meter.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExperimentalBandwidthMeterbuild()Builds the bandwidth meter.ExperimentalBandwidthMeter.BuildersetBandwidthEstimator(BandwidthEstimator bandwidthEstimator)Sets theBandwidthEstimatorused.ExperimentalBandwidthMeter.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.ExperimentalBandwidthMeter.BuildersetInitialBitrateEstimate(long initialBitrateEstimate)Sets the initial bitrate estimate in bits per second that should be assumed when a bandwidth estimate is unavailable.ExperimentalBandwidthMeter.BuildersetInitialBitrateEstimate(String countryCode)Sets the initial bitrate estimates to the default values of the specified country.ExperimentalBandwidthMeter.BuildersetResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange)Sets whether to reset if the network type changes.ExperimentalBandwidthMeter.BuildersetTimeToFirstByteEstimator(TimeToFirstByteEstimator timeToFirstByteEstimator)Sets theTimeToFirstByteEstimatorto be used.
-
-
-
Constructor Detail
-
Builder
public Builder(Context context)
Creates a builder with default parameters and without listener.- Parameters:
context- A context.
-
-
Method Detail
-
setInitialBitrateEstimate
@CanIgnoreReturnValue 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.
-
setInitialBitrateEstimate
@CanIgnoreReturnValue public ExperimentalBandwidthMeter.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 ExperimentalBandwidthMeter.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.
-
setTimeToFirstByteEstimator
@CanIgnoreReturnValue public ExperimentalBandwidthMeter.Builder setTimeToFirstByteEstimator(TimeToFirstByteEstimator timeToFirstByteEstimator)
Sets theTimeToFirstByteEstimatorto be used.Default is
PercentileTimeToFirstByteEstimatorwith a sliding window size ofExperimentalBandwidthMeter.DEFAULT_TIME_TO_FIRST_BYTE_SAMPLESthat uses a percentile ofExperimentalBandwidthMeter.DEFAULT_TIME_TO_FIRST_BYTE_PERCENTILE.- Parameters:
timeToFirstByteEstimator- TheTimeToFirstByteEstimatorto be used.- Returns:
- This builder.
-
setBandwidthEstimator
@CanIgnoreReturnValue public ExperimentalBandwidthMeter.Builder setBandwidthEstimator(BandwidthEstimator bandwidthEstimator)
Sets theBandwidthEstimatorused. By default, this is set to aSplitParallelSampleBandwidthEstimatorusing aSlidingWeightedAverageBandwidthStatistic.
-
setResetOnNetworkTypeChange
@CanIgnoreReturnValue public ExperimentalBandwidthMeter.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 ExperimentalBandwidthMeter build()
Builds the bandwidth meter.- Returns:
- A bandwidth meter with the configured properties.
-
-