Search in sources :

Example 26 with Clock

use of com.google.android.exoplayer2.util.Clock in project ExoPlayer by google.

the class AdaptiveTrackSelection method determineIdealSelectedIndex.

/**
 * Computes the ideal selected index ignoring buffer health.
 *
 * @param nowMs The current time in the timebase of {@link Clock#elapsedRealtime()}, or {@link
 *     Long#MIN_VALUE} to ignore track exclusion.
 * @param chunkDurationUs The duration of a media chunk in microseconds, or {@link C#TIME_UNSET}
 *     if unknown.
 */
private int determineIdealSelectedIndex(long nowMs, long chunkDurationUs) {
    long effectiveBitrate = getAllocatedBandwidth(chunkDurationUs);
    int lowestBitrateAllowedIndex = 0;
    for (int i = 0; i < length; i++) {
        if (nowMs == Long.MIN_VALUE || !isBlacklisted(i, nowMs)) {
            Format format = getFormat(i);
            if (canSelectFormat(format, format.bitrate, effectiveBitrate)) {
                return i;
            } else {
                lowestBitrateAllowedIndex = i;
            }
        }
    }
    return lowestBitrateAllowedIndex;
}
Also used : Format(com.google.android.exoplayer2.Format)

Aggregations

Test (org.junit.Test)16 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)5 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)5 FakeClock (com.google.android.exoplayer2.testutil.FakeClock)4 FakeMediaClockRenderer (com.google.android.exoplayer2.testutil.FakeMediaClockRenderer)4 Clock (com.google.android.exoplayer2.util.Clock)4 Listener (com.google.android.exoplayer2.Player.Listener)3 MediaSource (com.google.android.exoplayer2.source.MediaSource)2 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)2 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)2 MediaClock (com.google.android.exoplayer2.util.MediaClock)2 StandaloneMediaClock (com.google.android.exoplayer2.util.StandaloneMediaClock)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 HandlerThread (android.os.HandlerThread)1 Nullable (androidx.annotation.Nullable)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)1 DefaultLoadControl (com.google.android.exoplayer2.DefaultLoadControl)1 Format (com.google.android.exoplayer2.Format)1