本文整理汇总了Java中com.google.android.exoplayer.upstream.BandwidthMeter.NO_ESTIMATE属性的典型用法代码示例。如果您正苦于以下问题:Java BandwidthMeter.NO_ESTIMATE属性的具体用法?Java BandwidthMeter.NO_ESTIMATE怎么用?Java BandwidthMeter.NO_ESTIMATE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.exoplayer.upstream.BandwidthMeter
的用法示例。
在下文中一共展示了BandwidthMeter.NO_ESTIMATE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVariantIndexForBandwidth
private int getVariantIndexForBandwidth(long bitrateEstimate) {
if (bitrateEstimate == BandwidthMeter.NO_ESTIMATE) {
// Select the lowest quality.
bitrateEstimate = 0;
}
int effectiveBitrate = (int) (bitrateEstimate * BANDWIDTH_FRACTION);
int lowestQualityEnabledVariantIndex = -1;
for (int i = 0; i < variants.length; i++) {
if (variantBlacklistTimes[i] == 0) {
if (variants[i].format.bitrate <= effectiveBitrate) {
return i;
}
lowestQualityEnabledVariantIndex = i;
}
}
// At least one variant should always be enabled.
Assertions.checkState(lowestQualityEnabledVariantIndex != -1);
return lowestQualityEnabledVariantIndex;
}
示例2: getNextVariantIndex
private int getNextVariantIndex(TsChunk previousTsChunk, long playbackPositionUs) {
clearStaleBlacklistedVariants();
long bitrateEstimate = bandwidthMeter.getBitrateEstimate();
if (variantBlacklistTimes[selectedVariantIndex] != 0) {
// The current variant has been blacklisted, so we have no choice but to re-evaluate.
return getVariantIndexForBandwidth(bitrateEstimate);
}
if (previousTsChunk == null) {
// Don't consider switching if we don't have a previous chunk.
return selectedVariantIndex;
}
if (bitrateEstimate == BandwidthMeter.NO_ESTIMATE) {
// Don't consider switching if we don't have a bandwidth estimate.
return selectedVariantIndex;
}
int idealIndex = getVariantIndexForBandwidth(bitrateEstimate);
if (idealIndex == selectedVariantIndex) {
// We're already using the ideal variant.
return selectedVariantIndex;
}
// We're not using the ideal variant for the available bandwidth, but only switch if the
// conditions are appropriate.
long bufferedPositionUs = adaptiveMode == ADAPTIVE_MODE_SPLICE ? previousTsChunk.startTimeUs
: previousTsChunk.endTimeUs;
long bufferedUs = bufferedPositionUs - playbackPositionUs;
if (variantBlacklistTimes[selectedVariantIndex] != 0
|| (idealIndex > selectedVariantIndex && bufferedUs < maxBufferDurationToSwitchDownUs)
|| (idealIndex < selectedVariantIndex && bufferedUs > minBufferDurationToSwitchUpUs)) {
// Switch variant.
return idealIndex;
}
// Stick with the current variant for now.
return selectedVariantIndex;
}
示例3: determineIdealFormat
/**
* Compute the ideal format ignoring buffer health.
*/
private Format determineIdealFormat(Format[] formats, long bitrateEstimate) {
long effectiveBitrate = bitrateEstimate == BandwidthMeter.NO_ESTIMATE
? maxInitialBitrate : (long) (bitrateEstimate * bandwidthFraction);
for (int i = 0; i < formats.length; i++) {
Format format = formats[i];
if (format.bitrate <= effectiveBitrate) {
return format;
}
}
// We didn't manage to calculate a suitable format. Return the lowest quality format.
return formats[formats.length - 1];
}
示例4: getBandwidthString
private String getBandwidthString() {
BandwidthMeter bandwidthMeter = debuggable.getBandwidthMeter();
if (bandwidthMeter == null
|| bandwidthMeter.getBitrateEstimate() == BandwidthMeter.NO_ESTIMATE) {
return "bw:?";
} else {
return "bw:" + (bandwidthMeter.getBitrateEstimate() / 1000);
}
}
示例5: computeEffectiveBitrateEstimate
/**
* Apply overhead factor, or default value in absence of estimate.
*/
protected long computeEffectiveBitrateEstimate(long bitrateEstimate) {
return bitrateEstimate == BandwidthMeter.NO_ESTIMATE
? maxInitialBitrate : (long) (bitrateEstimate * bandwidthFraction);
}