@Test public void getBitratesUsingPastAndFutureInfo_noPastInfo_returnsBitratesUsingOnlyFutureInfo() { FakeMediaChunkIterator iterator1 = new FakeMediaChunkIterator( new long[] {0, 10}, new long[] {10}); FakeMediaChunkIterator iterator2 = new FakeMediaChunkIterator( new long[] {0, 5, 15, 30}, new long[] {10, 20, 30}); int[] bitrates = TrackSelectionUtil.getBitratesUsingPastAndFutureInfo( new Format[] {createFormatWithBitrate(10), createFormatWithBitrate(20)}, Collections.emptyList(), MAX_DURATION_US, new MediaChunkIterator[] {iterator1, iterator2}, MAX_DURATION_US, false, null); assertThat(bitrates).asList().containsExactly(8, 16).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);  }