Commit cd4cc1dc by olly Committed by Oliver Woodman

Add absolute start time to Timeline

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129869741
parent 4502a464
......@@ -95,9 +95,9 @@ import java.util.Locale;
boolean isFinal = timeline.isFinal();
int periodCount = timeline.getPeriodCount();
int seekWindowCount = timeline.getSeekWindowCount();
Log.d(TAG, "sourceInfo[isFinal=" + isFinal + ", periodCount="
+ (periodCount == Timeline.UNKNOWN_PERIOD_COUNT ? "?" : periodCount) + ", seekWindows: "
+ seekWindowCount);
Log.d(TAG, "sourceInfo[isFinal=" + isFinal + ", startTime=" + timeline.getAbsoluteStartTime()
+ ", periodCount=" + (periodCount == Timeline.UNKNOWN_PERIOD_COUNT ? "?" : periodCount)
+ ", seekWindows: " + seekWindowCount);
for (int seekWindowIndex = 0; seekWindowIndex < seekWindowCount; seekWindowIndex++) {
Log.d(TAG, " " + timeline.getSeekWindow(seekWindowIndex));
}
......
......@@ -152,6 +152,11 @@ public final class ConcatenatingMediaSource implements MediaSource {
}
@Override
public long getAbsoluteStartTime() {
return timelines[0].getAbsoluteStartTime();
}
@Override
public long getPeriodDuration(int index) {
int sourceIndex = getSourceIndexForPeriod(index);
int firstPeriodIndexInSource = getFirstPeriodIndexInSource(sourceIndex);
......
......@@ -91,6 +91,11 @@ public final class SinglePeriodTimeline implements Timeline {
}
@Override
public long getAbsoluteStartTime() {
return 0;
}
@Override
public long getPeriodDuration(int index) {
if (index != 0) {
throw new IndexOutOfBoundsException("Index " + index + " out of bounds");
......
......@@ -45,6 +45,11 @@ public interface Timeline {
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
* {@link ExoPlayer#UNKNOWN_TIME} if not known.
*
......
......@@ -504,6 +504,11 @@ public final class DashMediaSource implements MediaSource {
}
@Override
public long getAbsoluteStartTime() {
return manifest.availabilityStartTime + manifest.getPeriod(0).startMs;
}
@Override
public long getPeriodDuration(int index) {
return manifest.getPeriodDurationMs(index);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment