Rename AdaptiveVideoTrackSelection to AdaptiveTrackSelection

This will allow us to use the same class for Audio adaptation.

Issue:#1975

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=150302561
This commit is contained in:
aquilescanta 2017-03-16 03:36:02 -07:00 committed by Oliver Woodman
parent cadce0ef3f
commit ce5c0c18f9
5 changed files with 32 additions and 30 deletions

View file

@ -55,7 +55,7 @@ import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.source.smoothstreaming.DefaultSsChunkSource;
import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource;
import com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo;
import com.google.android.exoplayer2.trackselection.TrackSelection;
@ -256,7 +256,7 @@ public class PlayerActivity extends Activity implements OnClickListener, ExoPlay
: SimpleExoPlayer.EXTENSION_RENDERER_MODE_ON)
: SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF;
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
trackSelectionHelper = new TrackSelectionHelper(trackSelector, videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(),

View file

@ -51,7 +51,7 @@ import java.util.Locale;
private static final TrackSelection.Factory RANDOM_FACTORY = new RandomTrackSelection.Factory();
private final MappingTrackSelector selector;
private final TrackSelection.Factory adaptiveVideoTrackSelectionFactory;
private final TrackSelection.Factory adaptiveTrackSelectionFactory;
private MappedTrackInfo trackInfo;
private int rendererIndex;
@ -67,13 +67,13 @@ import java.util.Locale;
/**
* @param selector The track selector.
* @param adaptiveVideoTrackSelectionFactory A factory for adaptive video {@link TrackSelection}s,
* or null if the selection helper should not support adaptive video.
* @param adaptiveTrackSelectionFactory A factory for adaptive {@link TrackSelection}s, or null
* if the selection helper should not support adaptive tracks.
*/
public TrackSelectionHelper(MappingTrackSelector selector,
TrackSelection.Factory adaptiveVideoTrackSelectionFactory) {
TrackSelection.Factory adaptiveTrackSelectionFactory) {
this.selector = selector;
this.adaptiveVideoTrackSelectionFactory = adaptiveVideoTrackSelectionFactory;
this.adaptiveTrackSelectionFactory = adaptiveTrackSelectionFactory;
}
/**
@ -92,7 +92,7 @@ import java.util.Locale;
trackGroups = trackInfo.getTrackGroups(rendererIndex);
trackGroupsAdaptive = new boolean[trackGroups.length];
for (int i = 0; i < trackGroups.length; i++) {
trackGroupsAdaptive[i] = adaptiveVideoTrackSelectionFactory != null
trackGroupsAdaptive[i] = adaptiveTrackSelectionFactory != null
&& trackInfo.getAdaptiveSupport(rendererIndex, i, false)
!= RendererCapabilities.ADAPTIVE_NOT_SUPPORTED
&& trackGroups.get(i).length > 1;
@ -271,7 +271,7 @@ import java.util.Locale;
private void setOverride(int group, int[] tracks, boolean enableRandomAdaptation) {
TrackSelection.Factory factory = tracks.length == 1 ? FIXED_FACTORY
: (enableRandomAdaptation ? RANDOM_FACTORY : adaptiveVideoTrackSelectionFactory);
: (enableRandomAdaptation ? RANDOM_FACTORY : adaptiveTrackSelectionFactory);
override = new SelectionOverride(factory, group, tracks);
}

View file

@ -24,13 +24,13 @@ import com.google.android.exoplayer2.upstream.BandwidthMeter;
import java.util.List;
/**
* A bandwidth based adaptive {@link TrackSelection} for video, whose selected track is updated to
* be the one of highest quality given the current network conditions and the state of the buffer.
* A bandwidth based adaptive {@link TrackSelection}, whose selected track is updated to be the one
* of highest quality given the current network conditions and the state of the buffer.
*/
public class AdaptiveVideoTrackSelection extends BaseTrackSelection {
public class AdaptiveTrackSelection extends BaseTrackSelection {
/**
* Factory for {@link AdaptiveVideoTrackSelection} instances.
* Factory for {@link AdaptiveTrackSelection} instances.
*/
public static final class Factory implements TrackSelection.Factory {
@ -79,8 +79,8 @@ public class AdaptiveVideoTrackSelection extends BaseTrackSelection {
}
@Override
public AdaptiveVideoTrackSelection createTrackSelection(TrackGroup group, int... tracks) {
return new AdaptiveVideoTrackSelection(group, tracks, bandwidthMeter, maxInitialBitrate,
public AdaptiveTrackSelection createTrackSelection(TrackGroup group, int... tracks) {
return new AdaptiveTrackSelection(group, tracks, bandwidthMeter, maxInitialBitrate,
minDurationForQualityIncreaseMs, maxDurationForQualityDecreaseMs,
minDurationToRetainAfterDiscardMs, bandwidthFraction);
}
@ -104,12 +104,12 @@ public class AdaptiveVideoTrackSelection extends BaseTrackSelection {
private int reason;
/**
* @param group The {@link TrackGroup}. Must not be null.
* @param group The {@link TrackGroup}.
* @param tracks The indices of the selected tracks within the {@link TrackGroup}. Must not be
* null or empty. May be in any order.
* empty. May be in any order.
* @param bandwidthMeter Provides an estimate of the currently available bandwidth.
*/
public AdaptiveVideoTrackSelection(TrackGroup group, int[] tracks,
public AdaptiveTrackSelection(TrackGroup group, int[] tracks,
BandwidthMeter bandwidthMeter) {
this (group, tracks, bandwidthMeter, DEFAULT_MAX_INITIAL_BITRATE,
DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS,
@ -118,9 +118,9 @@ public class AdaptiveVideoTrackSelection extends BaseTrackSelection {
}
/**
* @param group The {@link TrackGroup}. Must not be null.
* @param group The {@link TrackGroup}.
* @param tracks The indices of the selected tracks within the {@link TrackGroup}. Must not be
* null or empty. May be in any order.
* empty. May be in any order.
* @param bandwidthMeter Provides an estimate of the currently available bandwidth.
* @param maxInitialBitrate The maximum bitrate in bits per second that should be assumed when a
* bandwidth estimate is unavailable.
@ -136,7 +136,7 @@ public class AdaptiveVideoTrackSelection extends BaseTrackSelection {
* consider available for use. Setting to a value less than 1 is recommended to account
* for inaccuracies in the bandwidth estimator.
*/
public AdaptiveVideoTrackSelection(TrackGroup group, int[] tracks, BandwidthMeter bandwidthMeter,
public AdaptiveTrackSelection(TrackGroup group, int[] tracks, BandwidthMeter bandwidthMeter,
int maxInitialBitrate, long minDurationForQualityIncreaseMs,
long maxDurationForQualityDecreaseMs, long minDurationToRetainAfterDiscardMs,
float bandwidthFraction) {
@ -208,15 +208,18 @@ public class AdaptiveVideoTrackSelection extends BaseTrackSelection {
}
int idealSelectedIndex = determineIdealSelectedIndex(SystemClock.elapsedRealtime());
Format idealFormat = getFormat(idealSelectedIndex);
// Discard from the first SD chunk beyond minDurationToRetainAfterDiscardUs whose resolution and
// bitrate are both lower than the ideal track.
// If the chunks contain video, discard from the first SD chunk beyond
// minDurationToRetainAfterDiscardUs whose resolution and bitrate are both lower than the ideal
// track.
for (int i = 0; i < queueSize; i++) {
MediaChunk chunk = queue.get(i);
Format format = chunk.trackFormat;
long durationBeforeThisChunkUs = chunk.startTimeUs - playbackPositionUs;
if (durationBeforeThisChunkUs >= minDurationToRetainAfterDiscardUs
&& chunk.trackFormat.bitrate < idealFormat.bitrate
&& chunk.trackFormat.height < idealFormat.height
&& chunk.trackFormat.height < 720 && chunk.trackFormat.width < 1280) {
&& format.bitrate < idealFormat.bitrate
&& format.height != Format.NO_VALUE && format.height < 720
&& format.width != Format.NO_VALUE && format.width < 1280
&& format.height < idealFormat.height) {
return i;
}
}

View file

@ -432,8 +432,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
params.maxVideoHeight, params.maxVideoBitrate, params.allowNonSeamlessAdaptiveness,
params.allowMixedMimeAdaptiveness, params.viewportWidth, params.viewportHeight,
params.orientationMayChange, adaptiveVideoTrackSelectionFactory,
params.exceedVideoConstraintsIfNecessary,
params.exceedRendererCapabilitiesIfNecessary);
params.exceedVideoConstraintsIfNecessary, params.exceedRendererCapabilitiesIfNecessary);
}
}

View file

@ -34,7 +34,7 @@ import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.google.android.exoplayer2.playbacktests.util.HostActivity.HostedTest;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
@ -313,7 +313,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
@SuppressWarnings("unused")
protected MappingTrackSelector buildTrackSelector(HostActivity host,
BandwidthMeter bandwidthMeter) {
return new DefaultTrackSelector(new AdaptiveVideoTrackSelection.Factory(bandwidthMeter));
return new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
}
@SuppressWarnings("unused")