Commit 8748646c by tonihei Committed by kim-vde

Remove deprecated constructor from AdaptiveTrackSelection.Factory.

This constructor and the way of passing BandwdithMeter has long been
deprecated now and can be removed.

PiperOrigin-RevId: 320147888
parent b8e9f19b
......@@ -19,7 +19,6 @@ import androidx.annotation.CallSuper;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.chunk.MediaChunk;
import com.google.android.exoplayer2.source.chunk.MediaChunkIterator;
......@@ -41,7 +40,6 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
/** Factory for {@link AdaptiveTrackSelection} instances. */
public static class Factory implements TrackSelection.Factory {
@Nullable private final BandwidthMeter bandwidthMeter;
private final int minDurationForQualityIncreaseMs;
private final int maxDurationForQualityDecreaseMs;
private final int minDurationToRetainAfterDiscardMs;
......@@ -61,23 +59,6 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
}
/**
* @deprecated Use {@link #Factory()} instead. Custom bandwidth meter should be directly passed
* to the player in {@link SimpleExoPlayer.Builder}.
*/
@Deprecated
@SuppressWarnings("deprecation")
public Factory(BandwidthMeter bandwidthMeter) {
this(
bandwidthMeter,
DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS,
DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS,
DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS,
DEFAULT_BANDWIDTH_FRACTION,
DEFAULT_BUFFERED_FRACTION_TO_LIVE_EDGE_FOR_QUALITY_INCREASE,
Clock.DEFAULT);
}
/**
* Creates an adaptive track selection factory.
*
* @param minDurationForQualityIncreaseMs The minimum duration of buffered data required for the
......@@ -107,28 +88,6 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
}
/**
* @deprecated Use {@link #Factory(int, int, int, float)} instead. Custom bandwidth meter should
* be directly passed to the player in {@link SimpleExoPlayer.Builder}.
*/
@Deprecated
@SuppressWarnings("deprecation")
public Factory(
BandwidthMeter bandwidthMeter,
int minDurationForQualityIncreaseMs,
int maxDurationForQualityDecreaseMs,
int minDurationToRetainAfterDiscardMs,
float bandwidthFraction) {
this(
bandwidthMeter,
minDurationForQualityIncreaseMs,
maxDurationForQualityDecreaseMs,
minDurationToRetainAfterDiscardMs,
bandwidthFraction,
DEFAULT_BUFFERED_FRACTION_TO_LIVE_EDGE_FOR_QUALITY_INCREASE,
Clock.DEFAULT);
}
/**
* Creates an adaptive track selection factory.
*
* @param minDurationForQualityIncreaseMs The minimum duration of buffered data required for the
......@@ -150,39 +109,13 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
* quality from happening.
* @param clock A {@link Clock}.
*/
@SuppressWarnings("deprecation")
public Factory(
int minDurationForQualityIncreaseMs,
int maxDurationForQualityDecreaseMs,
int minDurationToRetainAfterDiscardMs,
float bandwidthFraction,
float bufferedFractionToLiveEdgeForQualityIncrease,
Clock clock) {
this(
/* bandwidthMeter= */ null,
minDurationForQualityIncreaseMs,
maxDurationForQualityDecreaseMs,
minDurationToRetainAfterDiscardMs,
bandwidthFraction,
bufferedFractionToLiveEdgeForQualityIncrease,
clock);
}
/**
* @deprecated Use {@link #Factory(int, int, int, float, float, Clock)} instead. Custom
* bandwidth meter should be directly passed to the player in {@link
* SimpleExoPlayer.Builder}.
*/
@Deprecated
public Factory(
@Nullable BandwidthMeter bandwidthMeter,
int minDurationForQualityIncreaseMs,
int maxDurationForQualityDecreaseMs,
int minDurationToRetainAfterDiscardMs,
float bandwidthFraction,
float bufferedFractionToLiveEdgeForQualityIncrease,
Clock clock) {
this.bandwidthMeter = bandwidthMeter;
this.minDurationForQualityIncreaseMs = minDurationForQualityIncreaseMs;
this.maxDurationForQualityDecreaseMs = maxDurationForQualityDecreaseMs;
this.minDurationToRetainAfterDiscardMs = minDurationToRetainAfterDiscardMs;
......@@ -195,9 +128,6 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
@Override
public final @NullableType TrackSelection[] createTrackSelections(
@NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) {
if (this.bandwidthMeter != null) {
bandwidthMeter = this.bandwidthMeter;
}
TrackSelection[] selections = new TrackSelection[definitions.length];
int totalFixedBandwidth = 0;
for (int i = 0; i < definitions.length; i++) {
......
......@@ -36,7 +36,6 @@ import com.google.android.exoplayer2.RendererCapabilities.FormatSupport;
import com.google.android.exoplayer2.RendererConfiguration;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import com.google.common.primitives.Ints;
......@@ -1503,20 +1502,8 @@ public class DefaultTrackSelector extends MappingTrackSelector {
/** @deprecated Use {@link #DefaultTrackSelector(Context)} instead. */
@Deprecated
@SuppressWarnings("deprecation")
public DefaultTrackSelector() {
this(new AdaptiveTrackSelection.Factory());
}
/**
* @deprecated Use {@link #DefaultTrackSelector(Context)} instead. The bandwidth meter should be
* passed directly to the player in {@link
* com.google.android.exoplayer2.SimpleExoPlayer.Builder}.
*/
@Deprecated
@SuppressWarnings("deprecation")
public DefaultTrackSelector(BandwidthMeter bandwidthMeter) {
this(new AdaptiveTrackSelection.Factory(bandwidthMeter));
this(Parameters.DEFAULT_WITHOUT_CONTEXT, new AdaptiveTrackSelection.Factory());
}
/** @deprecated Use {@link #DefaultTrackSelector(Context, TrackSelection.Factory)}. */
......
......@@ -16,10 +16,6 @@
package com.google.android.exoplayer2.trackselection;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
......@@ -30,7 +26,6 @@ import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.chunk.MediaChunkIterator;
import com.google.android.exoplayer2.testutil.FakeClock;
import com.google.android.exoplayer2.testutil.FakeMediaChunk;
import com.google.android.exoplayer2.trackselection.TrackSelection.Definition;
import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.common.collect.ImmutableList;
......@@ -54,8 +49,6 @@ public final class AdaptiveTrackSelectionTest {
@Mock private BandwidthMeter mockBandwidthMeter;
private FakeClock fakeClock;
private AdaptiveTrackSelection adaptiveTrackSelection;
@Before
public void setUp() {
initMocks(this);
......@@ -63,31 +56,6 @@ public final class AdaptiveTrackSelectionTest {
}
@Test
@SuppressWarnings("deprecation")
public void factoryUsesInitiallyProvidedBandwidthMeter() {
BandwidthMeter initialBandwidthMeter = mock(BandwidthMeter.class);
BandwidthMeter injectedBandwidthMeter = mock(BandwidthMeter.class);
Format format1 = videoFormat(/* bitrate= */ 500, /* width= */ 320, /* height= */ 240);
Format format2 = videoFormat(/* bitrate= */ 1000, /* width= */ 640, /* height= */ 480);
TrackSelection[] trackSelections =
new AdaptiveTrackSelection.Factory(initialBandwidthMeter)
.createTrackSelections(
new Definition[] {
new Definition(new TrackGroup(format1, format2), /* tracks=... */ 0, 1)
},
injectedBandwidthMeter);
trackSelections[0].updateSelectedTrack(
/* playbackPositionUs= */ 0,
/* bufferedDurationUs= */ 0,
/* availableDurationUs= */ C.TIME_UNSET,
/* queue= */ Collections.emptyList(),
/* mediaChunkIterators= */ new MediaChunkIterator[] {MediaChunkIterator.EMPTY});
verify(initialBandwidthMeter, atLeastOnce()).getBitrateEstimate();
verifyZeroInteractions(injectedBandwidthMeter);
}
@Test
public void selectInitialIndexUseMaxInitialBitrateIfNoBandwidthEstimate() {
Format format1 = videoFormat(/* bitrate= */ 500, /* width= */ 320, /* height= */ 240);
Format format2 = videoFormat(/* bitrate= */ 1000, /* width= */ 640, /* height= */ 480);
......@@ -95,7 +63,7 @@ public final class AdaptiveTrackSelectionTest {
TrackGroup trackGroup = new TrackGroup(format1, format2, format3);
when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(1000L);
adaptiveTrackSelection = adaptiveTrackSelection(trackGroup);
AdaptiveTrackSelection adaptiveTrackSelection = adaptiveTrackSelection(trackGroup);
assertThat(adaptiveTrackSelection.getSelectedFormat()).isEqualTo(format2);
assertThat(adaptiveTrackSelection.getSelectionReason()).isEqualTo(C.SELECTION_REASON_INITIAL);
......@@ -109,7 +77,7 @@ public final class AdaptiveTrackSelectionTest {
TrackGroup trackGroup = new TrackGroup(format1, format2, format3);
when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(500L);
adaptiveTrackSelection = adaptiveTrackSelection(trackGroup);
AdaptiveTrackSelection adaptiveTrackSelection = adaptiveTrackSelection(trackGroup);
assertThat(adaptiveTrackSelection.getSelectedFormat()).isEqualTo(format1);
assertThat(adaptiveTrackSelection.getSelectionReason()).isEqualTo(C.SELECTION_REASON_INITIAL);
......@@ -125,7 +93,7 @@ public final class AdaptiveTrackSelectionTest {
// The second measurement onward returns 2000L, which prompts the track selection to switch up
// if possible.
when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(1000L, 2000L);
adaptiveTrackSelection =
AdaptiveTrackSelection adaptiveTrackSelection =
adaptiveTrackSelectionWithMinDurationForQualityIncreaseMs(
trackGroup, /* minDurationForQualityIncreaseMs= */ 10_000);
......@@ -153,7 +121,7 @@ public final class AdaptiveTrackSelectionTest {
// The second measurement onward returns 2000L, which prompts the track selection to switch up
// if possible.
when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(1000L, 2000L);
adaptiveTrackSelection =
AdaptiveTrackSelection adaptiveTrackSelection =
adaptiveTrackSelectionWithMinDurationForQualityIncreaseMs(
trackGroup, /* minDurationForQualityIncreaseMs= */ 10_000);
......@@ -181,7 +149,7 @@ public final class AdaptiveTrackSelectionTest {
// The second measurement onward returns 500L, which prompts the track selection to switch down
// if necessary.
when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(1000L, 500L);
adaptiveTrackSelection =
AdaptiveTrackSelection adaptiveTrackSelection =
adaptiveTrackSelectionWithMaxDurationForQualityDecreaseMs(
trackGroup, /* maxDurationForQualityDecreaseMs= */ 25_000);
......@@ -209,7 +177,7 @@ public final class AdaptiveTrackSelectionTest {
// The second measurement onward returns 500L, which prompts the track selection to switch down
// if necessary.
when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(1000L, 500L);
adaptiveTrackSelection =
AdaptiveTrackSelection adaptiveTrackSelection =
adaptiveTrackSelectionWithMaxDurationForQualityDecreaseMs(
trackGroup, /* maxDurationForQualityDecreaseMs= */ 25_000);
......@@ -246,7 +214,7 @@ public final class AdaptiveTrackSelectionTest {
queue.add(chunk3);
when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(500L);
adaptiveTrackSelection = adaptiveTrackSelection(trackGroup);
AdaptiveTrackSelection adaptiveTrackSelection = adaptiveTrackSelection(trackGroup);
int size = adaptiveTrackSelection.evaluateQueueSize(0, queue);
assertThat(size).isEqualTo(3);
......@@ -271,7 +239,7 @@ public final class AdaptiveTrackSelectionTest {
queue.add(chunk3);
when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(500L);
adaptiveTrackSelection =
AdaptiveTrackSelection adaptiveTrackSelection =
adaptiveTrackSelectionWithMinTimeBetweenBufferReevaluationMs(
trackGroup, /* durationToRetainAfterDiscardMs= */ 15_000);
......@@ -311,7 +279,7 @@ public final class AdaptiveTrackSelectionTest {
queue.add(chunk3);
when(mockBandwidthMeter.getBitrateEstimate()).thenReturn(500L);
adaptiveTrackSelection =
AdaptiveTrackSelection adaptiveTrackSelection =
adaptiveTrackSelectionWithMinTimeBetweenBufferReevaluationMs(
trackGroup, /* durationToRetainAfterDiscardMs= */ 15_000);
......@@ -334,7 +302,7 @@ public final class AdaptiveTrackSelectionTest {
Format format1 = videoFormat(/* bitrate= */ 500, /* width= */ 320, /* height= */ 240);
Format format2 = videoFormat(/* bitrate= */ 1000, /* width= */ 640, /* height= */ 480);
TrackGroup trackGroup = new TrackGroup(format1, format2);
adaptiveTrackSelection =
AdaptiveTrackSelection adaptiveTrackSelection =
new AdaptiveTrackSelection.Factory(
/* minDurationForQualityIncreaseMs= */ 10_000,
/* maxDurationForQualityDecreaseMs= */ 10_000,
......@@ -395,7 +363,8 @@ public final class AdaptiveTrackSelectionTest {
Format format1 = videoFormat(/* bitrate= */ 500, /* width= */ 320, /* height= */ 240);
Format format2 = videoFormat(/* bitrate= */ 1000, /* width= */ 640, /* height= */ 480);
TrackGroup trackGroup = new TrackGroup(format1, format2);
adaptiveTrackSelection = prepareTrackSelection(adaptiveTrackSelection(trackGroup));
AdaptiveTrackSelection adaptiveTrackSelection =
prepareTrackSelection(adaptiveTrackSelection(trackGroup));
Format unknownFormat = videoFormat(/* bitrate= */ 42, /* width= */ 300, /* height= */ 123);
FakeMediaChunk chunk =
new FakeMediaChunk(unknownFormat, /* startTimeUs= */ 0, /* endTimeUs= */ 2_000_000);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment