diff --git a/demo/src/main/java/com/google/android/exoplayer2/demo/EventLogger.java b/demo/src/main/java/com/google/android/exoplayer2/demo/EventLogger.java index bb61776408..eac68b2f32 100644 --- a/demo/src/main/java/com/google/android/exoplayer2/demo/EventLogger.java +++ b/demo/src/main/java/com/google/android/exoplayer2/demo/EventLogger.java @@ -96,8 +96,7 @@ import java.util.Locale; int periodCount = timeline.getPeriodCount(); int seekWindowCount = timeline.getSeekWindowCount(); Log.d(TAG, "sourceInfo[isFinal=" + isFinal + ", startTime=" + timeline.getAbsoluteStartTime() - + ", periodCount=" + (periodCount == Timeline.UNKNOWN_PERIOD_COUNT ? "?" : periodCount) - + ", seekWindows: " + seekWindowCount); + + ", periodCount=" + periodCount + ", seekWindows: " + seekWindowCount); for (int seekWindowIndex = 0; seekWindowIndex < seekWindowCount; seekWindowIndex++) { Log.d(TAG, " " + timeline.getSeekWindow(seekWindowIndex)); } diff --git a/library/src/main/java/com/google/android/exoplayer2/source/ConcatenatingMediaSource.java b/library/src/main/java/com/google/android/exoplayer2/source/ConcatenatingMediaSource.java index c8a8478304..f97b99b798 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/ConcatenatingMediaSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/ConcatenatingMediaSource.java @@ -18,7 +18,6 @@ package com.google.android.exoplayer2.source; import com.google.android.exoplayer2.util.Util; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; /** * Concatenates multiple {@link MediaSource}s. @@ -124,26 +123,18 @@ public final class ConcatenatingMediaSource implements MediaSource { SeekWindow sourceSeekWindow = timeline.getSeekWindow(j); concatenatedSeekWindows.add(sourceSeekWindow.copyOffsetByPeriodCount(sourceOffset)); } - int periodCount = timeline.getPeriodCount(); - if (periodCount == Timeline.UNKNOWN_PERIOD_COUNT) { - sourceOffsets = Arrays.copyOf(sourceOffsets, i); - isFinal = false; - break; - } - sourceOffset += periodCount; + sourceOffset += timeline.getPeriodCount(); sourceOffsets[i] = sourceOffset; } this.timelines = timelines; this.isFinal = isFinal; this.sourceOffsets = sourceOffsets; - seekWindows = - concatenatedSeekWindows.toArray(new SeekWindow[concatenatedSeekWindows.size()]); + seekWindows = concatenatedSeekWindows.toArray(new SeekWindow[concatenatedSeekWindows.size()]); } @Override public int getPeriodCount() { - return sourceOffsets.length == timelines.length ? sourceOffsets[sourceOffsets.length - 1] - : UNKNOWN_PERIOD_COUNT; + return sourceOffsets[sourceOffsets.length - 1]; } @Override diff --git a/library/src/main/java/com/google/android/exoplayer2/source/SeekWindow.java b/library/src/main/java/com/google/android/exoplayer2/source/SeekWindow.java index 61a5207498..87e0baec5d 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/SeekWindow.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/SeekWindow.java @@ -39,7 +39,7 @@ public final class SeekWindow { * @param startTimeUs The start time of the window in microseconds, relative to the start of the * specified start period. * @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. */ public static SeekWindow createWindow(int startPeriodIndex, long startTimeUs, diff --git a/library/src/main/java/com/google/android/exoplayer2/source/Timeline.java b/library/src/main/java/com/google/android/exoplayer2/source/Timeline.java index 17d7113ebc..0b344d38d5 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/Timeline.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/Timeline.java @@ -22,11 +22,6 @@ import com.google.android.exoplayer2.ExoPlayer; */ 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 * identifier. @@ -34,8 +29,7 @@ public interface Timeline { int NO_PERIOD_INDEX = -1; /** - * Returns the number of periods in the timeline, or {@link #UNKNOWN_PERIOD_COUNT} if not known. - * If {@link #isFinal()} returns {@code true}, the number of periods must be known. + * Returns the number of periods in the timeline. */ int getPeriodCount(); diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java index ee0f0b95bb..7ba1878600 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java @@ -142,7 +142,7 @@ public final class DashMediaSource implements MediaSource { public int getNewPlayingPeriodIndex(int oldPlayingPeriodIndex, Timeline oldTimeline) { int periodIndex = oldPlayingPeriodIndex; int oldPeriodCount = oldTimeline.getPeriodCount(); - while (oldPeriodCount == Timeline.UNKNOWN_PERIOD_COUNT || periodIndex < oldPeriodCount) { + while (periodIndex < oldPeriodCount) { Object id = oldTimeline.getPeriodId(periodIndex); if (id == null) { break;