Add absolute start time to Timeline

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129869741
This commit is contained in:
olly 2016-08-10 08:41:38 -07:00 committed by Oliver Woodman
parent 4502a464dd
commit cd4cc1dc14
5 changed files with 23 additions and 3 deletions

View file

@ -95,9 +95,9 @@ import java.util.Locale;
boolean isFinal = timeline.isFinal(); boolean isFinal = timeline.isFinal();
int periodCount = timeline.getPeriodCount(); int periodCount = timeline.getPeriodCount();
int seekWindowCount = timeline.getSeekWindowCount(); int seekWindowCount = timeline.getSeekWindowCount();
Log.d(TAG, "sourceInfo[isFinal=" + isFinal + ", periodCount=" Log.d(TAG, "sourceInfo[isFinal=" + isFinal + ", startTime=" + timeline.getAbsoluteStartTime()
+ (periodCount == Timeline.UNKNOWN_PERIOD_COUNT ? "?" : periodCount) + ", seekWindows: " + ", periodCount=" + (periodCount == Timeline.UNKNOWN_PERIOD_COUNT ? "?" : periodCount)
+ 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

@ -151,6 +151,11 @@ public final class ConcatenatingMediaSource implements MediaSource {
return isFinal; return isFinal;
} }
@Override
public long getAbsoluteStartTime() {
return timelines[0].getAbsoluteStartTime();
}
@Override @Override
public long getPeriodDuration(int index) { public long getPeriodDuration(int index) {
int sourceIndex = getSourceIndexForPeriod(index); int sourceIndex = getSourceIndexForPeriod(index);

View file

@ -90,6 +90,11 @@ public final class SinglePeriodTimeline implements Timeline {
return isFinal; return isFinal;
} }
@Override
public long getAbsoluteStartTime() {
return 0;
}
@Override @Override
public long getPeriodDuration(int index) { public long getPeriodDuration(int index) {
if (index != 0) { if (index != 0) {

View file

@ -44,6 +44,11 @@ public interface Timeline {
*/ */
boolean isFinal(); boolean isFinal();
/**
* Returns the absolute start time of the timeline in milliseconds.
*/
long getAbsoluteStartTime();
/** /**
* Returns the duration of the period at {@code index} in the timeline, in milliseconds, or * Returns the duration of the period at {@code index} in the timeline, in milliseconds, or
* {@link ExoPlayer#UNKNOWN_TIME} if not known. * {@link ExoPlayer#UNKNOWN_TIME} if not known.

View file

@ -503,6 +503,11 @@ public final class DashMediaSource implements MediaSource {
return !manifest.dynamic; return !manifest.dynamic;
} }
@Override
public long getAbsoluteStartTime() {
return manifest.availabilityStartTime + manifest.getPeriod(0).startMs;
}
@Override @Override
public long getPeriodDuration(int index) { public long getPeriodDuration(int index) {
return manifest.getPeriodDurationMs(index); return manifest.getPeriodDurationMs(index);