@Test public void getBitratesUsingPastAndFutureInfo_noFutureInfo_returnsBitratesUsingOnlyPastInfo() { FakeMediaChunk chunk = createChunk( createFormatWithBitrate(10), 10, 0, 10); int[] bitrates = TrackSelectionUtil.getBitratesUsingPastAndFutureInfo( new Format[] {createFormatWithBitrate(20), createFormatWithBitrate(30)}, Collections.singletonList(chunk), MAX_DURATION_US, new MediaChunkIterator[] {MediaChunkIterator.EMPTY, MediaChunkIterator.EMPTY}, MAX_DURATION_US, false, null); assertThat(bitrates).asList().containsExactly(16, 24).inOrder(); }
public static int[] getBitratesUsingPastAndFutureInfo( Format[] formats, List<? extends MediaChunk> queue, long maxPastDurationUs, MediaChunkIterator[] iterators, long maxFutureDurationUs, boolean useFormatBitrateAsLowerBound, @Nullable int[] bitrates) { bitrates = getBitratesUsingFutureInfo(iterators, formats, maxFutureDurationUs, bitrates); getBitratesUsingPastInfo(queue, formats, maxPastDurationUs, bitrates); for (int i = 0; i < bitrates.length; i++) { int bitrate = bitrates[i]; if (bitrate == Format.NO_VALUE || (useFormatBitrateAsLowerBound && formats[i].bitrate != Format.NO_VALUE && bitrate < formats[i].bitrate)) { bitrates[i] = formats[i].bitrate; } } return bitrates; }
TrackSelectionUtil { public static int[] getBitratesUsingPastAndFutureInfo( Format[] formats, List<? extends MediaChunk> queue, long maxPastDurationUs, MediaChunkIterator[] iterators, long maxFutureDurationUs, boolean useFormatBitrateAsLowerBound, @Nullable int[] bitrates) { bitrates = getBitratesUsingFutureInfo(iterators, formats, maxFutureDurationUs, bitrates); getBitratesUsingPastInfo(queue, formats, maxPastDurationUs, bitrates); for (int i = 0; i < bitrates.length; i++) { int bitrate = bitrates[i]; if (bitrate == Format.NO_VALUE || (useFormatBitrateAsLowerBound && formats[i].bitrate != Format.NO_VALUE && bitrate < formats[i].bitrate)) { bitrates[i] = formats[i].bitrate; } } return bitrates; } }
TrackSelectionUtil { public static int[] getBitratesUsingPastAndFutureInfo( Format[] formats, List<? extends MediaChunk> queue, long maxPastDurationUs, MediaChunkIterator[] iterators, long maxFutureDurationUs, boolean useFormatBitrateAsLowerBound, @Nullable int[] bitrates) { bitrates = getBitratesUsingFutureInfo(iterators, formats, maxFutureDurationUs, bitrates); getBitratesUsingPastInfo(queue, formats, maxPastDurationUs, bitrates); for (int i = 0; i < bitrates.length; i++) { int bitrate = bitrates[i]; if (bitrate == Format.NO_VALUE || (useFormatBitrateAsLowerBound && formats[i].bitrate != Format.NO_VALUE && bitrate < formats[i].bitrate)) { bitrates[i] = formats[i].bitrate; } } return bitrates; } private  TrackSelectionUtil(); }
TrackSelectionUtil { public static int[] getBitratesUsingPastAndFutureInfo( Format[] formats, List<? extends MediaChunk> queue, long maxPastDurationUs, MediaChunkIterator[] iterators, long maxFutureDurationUs, boolean useFormatBitrateAsLowerBound, @Nullable int[] bitrates) { bitrates = getBitratesUsingFutureInfo(iterators, formats, maxFutureDurationUs, bitrates); getBitratesUsingPastInfo(queue, formats, maxPastDurationUs, bitrates); for (int i = 0; i < bitrates.length; i++) { int bitrate = bitrates[i]; if (bitrate == Format.NO_VALUE || (useFormatBitrateAsLowerBound && formats[i].bitrate != Format.NO_VALUE && bitrate < formats[i].bitrate)) { bitrates[i] = formats[i].bitrate; } } 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 { public static int[] getBitratesUsingPastAndFutureInfo( Format[] formats, List<? extends MediaChunk> queue, long maxPastDurationUs, MediaChunkIterator[] iterators, long maxFutureDurationUs, boolean useFormatBitrateAsLowerBound, @Nullable int[] bitrates) { bitrates = getBitratesUsingFutureInfo(iterators, formats, maxFutureDurationUs, bitrates); getBitratesUsingPastInfo(queue, formats, maxPastDurationUs, bitrates); for (int i = 0; i < bitrates.length; i++) { int bitrate = bitrates[i]; if (bitrate == Format.NO_VALUE || (useFormatBitrateAsLowerBound && formats[i].bitrate != Format.NO_VALUE && bitrate < formats[i].bitrate)) { bitrates[i] = formats[i].bitrate; } } 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);  }