当前位置: 首页>>代码示例>>Java>>正文


Java BandwidthMeter.NO_ESTIMATE属性代码示例

本文整理汇总了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;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:19,代码来源:HlsChunkSource.java

示例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;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:34,代码来源:HlsChunkSource.java

示例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];
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:15,代码来源:FormatEvaluator.java

示例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);
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:9,代码来源:DebugTextViewHelper.java

示例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);
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:7,代码来源:FormatEvaluator.java


注:本文中的com.google.android.exoplayer.upstream.BandwidthMeter.NO_ESTIMATE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。