Remove Timeline.UNKNOWN_PERIOD_COUNT

It's no longer used.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129870115
This commit is contained in:
olly 2016-08-10 08:45:53 -07:00 committed by Oliver Woodman
parent d10c811bd8
commit 91c7551cc3
5 changed files with 7 additions and 23 deletions

View File

@ -96,8 +96,7 @@ import java.util.Locale;
int periodCount = timeline.getPeriodCount(); int periodCount = timeline.getPeriodCount();
int seekWindowCount = timeline.getSeekWindowCount(); int seekWindowCount = timeline.getSeekWindowCount();
Log.d(TAG, "sourceInfo[isFinal=" + isFinal + ", startTime=" + timeline.getAbsoluteStartTime() Log.d(TAG, "sourceInfo[isFinal=" + isFinal + ", startTime=" + timeline.getAbsoluteStartTime()
+ ", periodCount=" + (periodCount == Timeline.UNKNOWN_PERIOD_COUNT ? "?" : periodCount) + ", periodCount=" + periodCount + ", seekWindows: " + seekWindowCount);
+ ", seekWindows: " + seekWindowCount);
for (int seekWindowIndex = 0; seekWindowIndex < seekWindowCount; seekWindowIndex++) { for (int seekWindowIndex = 0; seekWindowIndex < seekWindowCount; seekWindowIndex++) {
Log.d(TAG, " " + timeline.getSeekWindow(seekWindowIndex)); Log.d(TAG, " " + timeline.getSeekWindow(seekWindowIndex));
} }

View File

@ -18,7 +18,6 @@ package com.google.android.exoplayer2.source;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
/** /**
* Concatenates multiple {@link MediaSource}s. * Concatenates multiple {@link MediaSource}s.
@ -124,26 +123,18 @@ public final class ConcatenatingMediaSource implements MediaSource {
SeekWindow sourceSeekWindow = timeline.getSeekWindow(j); SeekWindow sourceSeekWindow = timeline.getSeekWindow(j);
concatenatedSeekWindows.add(sourceSeekWindow.copyOffsetByPeriodCount(sourceOffset)); concatenatedSeekWindows.add(sourceSeekWindow.copyOffsetByPeriodCount(sourceOffset));
} }
int periodCount = timeline.getPeriodCount(); sourceOffset += timeline.getPeriodCount();
if (periodCount == Timeline.UNKNOWN_PERIOD_COUNT) {
sourceOffsets = Arrays.copyOf(sourceOffsets, i);
isFinal = false;
break;
}
sourceOffset += periodCount;
sourceOffsets[i] = sourceOffset; sourceOffsets[i] = sourceOffset;
} }
this.timelines = timelines; this.timelines = timelines;
this.isFinal = isFinal; this.isFinal = isFinal;
this.sourceOffsets = sourceOffsets; this.sourceOffsets = sourceOffsets;
seekWindows = seekWindows = concatenatedSeekWindows.toArray(new SeekWindow[concatenatedSeekWindows.size()]);
concatenatedSeekWindows.toArray(new SeekWindow[concatenatedSeekWindows.size()]);
} }
@Override @Override
public int getPeriodCount() { public int getPeriodCount() {
return sourceOffsets.length == timelines.length ? sourceOffsets[sourceOffsets.length - 1] return sourceOffsets[sourceOffsets.length - 1];
: UNKNOWN_PERIOD_COUNT;
} }
@Override @Override

View File

@ -39,7 +39,7 @@ public final class SeekWindow {
* @param startTimeUs The start time of the window in microseconds, relative to the start of the * @param startTimeUs The start time of the window in microseconds, relative to the start of the
* specified start period. * specified start period.
* @param endPeriodIndex The index of the period containing the end of the window. * @param endPeriodIndex The index of the period containing the end of the window.
* @param endTimeUs = The end time of the window in microseconds, relative to the start of the * @param endTimeUs The end time of the window in microseconds, relative to the start of the
* specified end period. * specified end period.
*/ */
public static SeekWindow createWindow(int startPeriodIndex, long startTimeUs, public static SeekWindow createWindow(int startPeriodIndex, long startTimeUs,

View File

@ -22,11 +22,6 @@ import com.google.android.exoplayer2.ExoPlayer;
*/ */
public interface Timeline { public interface Timeline {
/**
* Returned by {@link #getPeriodCount()} when the number of periods is not known.
*/
int UNKNOWN_PERIOD_COUNT = -1;
/** /**
* Returned by {@link #getIndexOfPeriod(Object)} if no period index corresponds to the specified * Returned by {@link #getIndexOfPeriod(Object)} if no period index corresponds to the specified
* identifier. * identifier.
@ -34,8 +29,7 @@ public interface Timeline {
int NO_PERIOD_INDEX = -1; int NO_PERIOD_INDEX = -1;
/** /**
* Returns the number of periods in the timeline, or {@link #UNKNOWN_PERIOD_COUNT} if not known. * Returns the number of periods in the timeline.
* If {@link #isFinal()} returns {@code true}, the number of periods must be known.
*/ */
int getPeriodCount(); int getPeriodCount();

View File

@ -142,7 +142,7 @@ public final class DashMediaSource implements MediaSource {
public int getNewPlayingPeriodIndex(int oldPlayingPeriodIndex, Timeline oldTimeline) { public int getNewPlayingPeriodIndex(int oldPlayingPeriodIndex, Timeline oldTimeline) {
int periodIndex = oldPlayingPeriodIndex; int periodIndex = oldPlayingPeriodIndex;
int oldPeriodCount = oldTimeline.getPeriodCount(); int oldPeriodCount = oldTimeline.getPeriodCount();
while (oldPeriodCount == Timeline.UNKNOWN_PERIOD_COUNT || periodIndex < oldPeriodCount) { while (periodIndex < oldPeriodCount) {
Object id = oldTimeline.getPeriodId(periodIndex); Object id = oldTimeline.getPeriodId(periodIndex);
if (id == null) { if (id == null) {
break; break;