@Test public void getBitratesUsingPastInfo_trackFormatNoBitrate_returnsNoValue() { FakeMediaChunk chunk = createChunk( createFormatWithBitrate(10), 10, 0, 10); int[] bitrates = TrackSelectionUtil.getBitratesUsingPastInfo( Collections.singletonList(chunk), new Format[] {createFormatWithBitrate(Format.NO_VALUE)}, MAX_DURATION_US, null); assertThat(bitrates).asList().containsExactly(Format.NO_VALUE); }
@VisibleForTesting static int[] getBitratesUsingPastInfo( List<? extends MediaChunk> queue, Format[] formats, long maxDurationUs, @Nullable int[] bitrates) { if (bitrates == null) { bitrates = new int[formats.length]; Arrays.fill(bitrates, Format.NO_VALUE); } if (maxDurationUs == 0) { return bitrates; } int queueAverageBitrate = getAverageQueueBitrate(queue, maxDurationUs); if (queueAverageBitrate == Format.NO_VALUE) { return bitrates; } int queueFormatBitrate = queue.get(queue.size() - 1).trackFormat.bitrate; if (queueFormatBitrate != Format.NO_VALUE) { float queueBitrateRatio = ((float) queueAverageBitrate) / queueFormatBitrate; estimateBitrates( bitrates, formats, new int[] {queueFormatBitrate}, new float[] {queueBitrateRatio}); } return bitrates; }
TrackSelectionUtil { @VisibleForTesting static int[] getBitratesUsingPastInfo( List<? extends MediaChunk> queue, Format[] formats, long maxDurationUs, @Nullable int[] bitrates) { if (bitrates == null) { bitrates = new int[formats.length]; Arrays.fill(bitrates, Format.NO_VALUE); } if (maxDurationUs == 0) { return bitrates; } int queueAverageBitrate = getAverageQueueBitrate(queue, maxDurationUs); if (queueAverageBitrate == Format.NO_VALUE) { return bitrates; } int queueFormatBitrate = queue.get(queue.size() - 1).trackFormat.bitrate; if (queueFormatBitrate != Format.NO_VALUE) { float queueBitrateRatio = ((float) queueAverageBitrate) / queueFormatBitrate; estimateBitrates( bitrates, formats, new int[] {queueFormatBitrate}, new float[] {queueBitrateRatio}); } return bitrates; } }
TrackSelectionUtil { @VisibleForTesting static int[] getBitratesUsingPastInfo( List<? extends MediaChunk> queue, Format[] formats, long maxDurationUs, @Nullable int[] bitrates) { if (bitrates == null) { bitrates = new int[formats.length]; Arrays.fill(bitrates, Format.NO_VALUE); } if (maxDurationUs == 0) { return bitrates; } int queueAverageBitrate = getAverageQueueBitrate(queue, maxDurationUs); if (queueAverageBitrate == Format.NO_VALUE) { return bitrates; } int queueFormatBitrate = queue.get(queue.size() - 1).trackFormat.bitrate; if (queueFormatBitrate != Format.NO_VALUE) { float queueBitrateRatio = ((float) queueAverageBitrate) / queueFormatBitrate; estimateBitrates( bitrates, formats, new int[] {queueFormatBitrate}, new float[] {queueBitrateRatio}); } return bitrates; } private  TrackSelectionUtil(); }
TrackSelectionUtil { @VisibleForTesting static int[] getBitratesUsingPastInfo( List<? extends MediaChunk> queue, Format[] formats, long maxDurationUs, @Nullable int[] bitrates) { if (bitrates == null) { bitrates = new int[formats.length]; Arrays.fill(bitrates, Format.NO_VALUE); } if (maxDurationUs == 0) { return bitrates; } int queueAverageBitrate = getAverageQueueBitrate(queue, maxDurationUs); if (queueAverageBitrate == Format.NO_VALUE) { return bitrates; } int queueFormatBitrate = queue.get(queue.size() - 1).trackFormat.bitrate; if (queueFormatBitrate != Format.NO_VALUE) { float queueBitrateRatio = ((float) queueAverageBitrate) / queueFormatBitrate; estimateBitrates( bitrates, formats, new int[] {queueFormatBitrate}, new float[] {queueBitrateRatio}); } return bitrates; } private  TrackSelectionUtil(); static @NullableType TrackSelection[] createTrackSelectionsForDefinitions(
      @NullableType Definition[] definitions,
      AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory); static DefaultTrackSelector.Parameters updateParametersWithOverride(
      DefaultTrackSelector.Parameters parameters,
      int rendererIndex,
      TrackGroupArray trackGroupArray,
      boolean isDisabled,
      @Nullable SelectionOverride override); static int getAverageBitrate(MediaChunkIterator iterator, long maxDurationUs); static int[] getBitratesUsingPastAndFutureInfo(
      Format[] formats,
      List<? extends MediaChunk> queue,
      long maxPastDurationUs,
      MediaChunkIterator[] iterators,
      long maxFutureDurationUs,
      boolean useFormatBitrateAsLowerBound,
      @Nullable int[] bitrates); static int[] getFormatBitrates(Format[] formats, @Nullable int[] bitrates); }
TrackSelectionUtil { @VisibleForTesting static int[] getBitratesUsingPastInfo( List<? extends MediaChunk> queue, Format[] formats, long maxDurationUs, @Nullable int[] bitrates) { if (bitrates == null) { bitrates = new int[formats.length]; Arrays.fill(bitrates, Format.NO_VALUE); } if (maxDurationUs == 0) { return bitrates; } int queueAverageBitrate = getAverageQueueBitrate(queue, maxDurationUs); if (queueAverageBitrate == Format.NO_VALUE) { return bitrates; } int queueFormatBitrate = queue.get(queue.size() - 1).trackFormat.bitrate; if (queueFormatBitrate != Format.NO_VALUE) { float queueBitrateRatio = ((float) queueAverageBitrate) / queueFormatBitrate; estimateBitrates( bitrates, formats, new int[] {queueFormatBitrate}, new float[] {queueBitrateRatio}); } return bitrates; } private  TrackSelectionUtil(); static @NullableType TrackSelection[] createTrackSelectionsForDefinitions(
      @NullableType Definition[] definitions,
      AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory); static DefaultTrackSelector.Parameters updateParametersWithOverride(
      DefaultTrackSelector.Parameters parameters,
      int rendererIndex,
      TrackGroupArray trackGroupArray,
      boolean isDisabled,
      @Nullable SelectionOverride override); static int getAverageBitrate(MediaChunkIterator iterator, long maxDurationUs); static int[] getBitratesUsingPastAndFutureInfo(
      Format[] formats,
      List<? extends MediaChunk> queue,
      long maxPastDurationUs,
      MediaChunkIterator[] iterators,
      long maxFutureDurationUs,
      boolean useFormatBitrateAsLowerBound,
      @Nullable int[] bitrates); static int[] getFormatBitrates(Format[] formats, @Nullable int[] bitrates);  }