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; ...@@ -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));
} }
......
...@@ -152,6 +152,11 @@ public final class ConcatenatingMediaSource implements MediaSource { ...@@ -152,6 +152,11 @@ public final class ConcatenatingMediaSource implements MediaSource {
} }
@Override @Override
public long getAbsoluteStartTime() {
return timelines[0].getAbsoluteStartTime();
}
@Override
public long getPeriodDuration(int index) { public long getPeriodDuration(int index) {
int sourceIndex = getSourceIndexForPeriod(index); int sourceIndex = getSourceIndexForPeriod(index);
int firstPeriodIndexInSource = getFirstPeriodIndexInSource(sourceIndex); int firstPeriodIndexInSource = getFirstPeriodIndexInSource(sourceIndex);
......
...@@ -91,6 +91,11 @@ public final class SinglePeriodTimeline implements Timeline { ...@@ -91,6 +91,11 @@ public final class SinglePeriodTimeline implements Timeline {
} }
@Override @Override
public long getAbsoluteStartTime() {
return 0;
}
@Override
public long getPeriodDuration(int index) { public long getPeriodDuration(int index) {
if (index != 0) { if (index != 0) {
throw new IndexOutOfBoundsException("Index " + index + " out of bounds"); throw new IndexOutOfBoundsException("Index " + index + " out of bounds");
......
...@@ -45,6 +45,11 @@ public interface Timeline { ...@@ -45,6 +45,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.
* *
......
...@@ -504,6 +504,11 @@ public final class DashMediaSource implements MediaSource { ...@@ -504,6 +504,11 @@ public final class DashMediaSource implements MediaSource {
} }
@Override @Override
public long getAbsoluteStartTime() {
return manifest.availabilityStartTime + manifest.getPeriod(0).startMs;
}
@Override
public long getPeriodDuration(int index) { public long getPeriodDuration(int index) {
return manifest.getPeriodDurationMs(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