Commit 67cb7d8d by olly Committed by Oliver Woodman

Fix SmoothStreaming Timeline

There were a few things wrong. Specifically the case in
the ref'd issue. Also, the timeline was being marked as
non-dynamic in the empty-but-live case (it should be
marked dynamic as segments may be added later).

Issue: #2760

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=157103727
parent 22137f62
...@@ -287,23 +287,24 @@ public final class SsMediaSource implements MediaSource, ...@@ -287,23 +287,24 @@ public final class SsMediaSource implements MediaSource,
for (int i = 0; i < mediaPeriods.size(); i++) { for (int i = 0; i < mediaPeriods.size(); i++) {
mediaPeriods.get(i).updateManifest(manifest); mediaPeriods.get(i).updateManifest(manifest);
} }
Timeline timeline;
if (manifest.isLive) {
long startTimeUs = Long.MAX_VALUE; long startTimeUs = Long.MAX_VALUE;
long endTimeUs = Long.MIN_VALUE; long endTimeUs = Long.MIN_VALUE;
for (int i = 0; i < manifest.streamElements.length; i++) { for (StreamElement element : manifest.streamElements) {
StreamElement element = manifest.streamElements[i];
if (element.chunkCount > 0) { if (element.chunkCount > 0) {
startTimeUs = Math.min(startTimeUs, element.getStartTimeUs(0)); startTimeUs = Math.min(startTimeUs, element.getStartTimeUs(0));
endTimeUs = Math.max(endTimeUs, element.getStartTimeUs(element.chunkCount - 1) endTimeUs = Math.max(endTimeUs, element.getStartTimeUs(element.chunkCount - 1)
+ element.getChunkDurationUs(element.chunkCount - 1)); + element.getChunkDurationUs(element.chunkCount - 1));
} }
} }
Timeline timeline;
if (startTimeUs == Long.MAX_VALUE) { if (startTimeUs == Long.MAX_VALUE) {
timeline = new SinglePeriodTimeline(C.TIME_UNSET, false); long periodDurationUs = manifest.isLive ? C.TIME_UNSET : 0;
} else { timeline = new SinglePeriodTimeline(periodDurationUs, 0, 0, 0, true /* isSeekable */,
if (manifest.dvrWindowLengthUs != C.TIME_UNSET manifest.isLive /* isDynamic */);
&& manifest.dvrWindowLengthUs > 0) { } else if (manifest.isLive) {
if (manifest.dvrWindowLengthUs != C.TIME_UNSET && manifest.dvrWindowLengthUs > 0) {
startTimeUs = Math.max(startTimeUs, endTimeUs - manifest.dvrWindowLengthUs); startTimeUs = Math.max(startTimeUs, endTimeUs - manifest.dvrWindowLengthUs);
} }
long durationUs = endTimeUs - startTimeUs; long durationUs = endTimeUs - startTimeUs;
...@@ -316,10 +317,11 @@ public final class SsMediaSource implements MediaSource, ...@@ -316,10 +317,11 @@ public final class SsMediaSource implements MediaSource,
} }
timeline = new SinglePeriodTimeline(C.TIME_UNSET, durationUs, startTimeUs, timeline = new SinglePeriodTimeline(C.TIME_UNSET, durationUs, startTimeUs,
defaultStartPositionUs, true /* isSeekable */, true /* isDynamic */); defaultStartPositionUs, true /* isSeekable */, true /* isDynamic */);
}
} else { } else {
boolean isSeekable = manifest.durationUs != C.TIME_UNSET; long durationUs = manifest.durationUs != C.TIME_UNSET ? manifest.durationUs
timeline = new SinglePeriodTimeline(manifest.durationUs, isSeekable); : endTimeUs - startTimeUs;
timeline = new SinglePeriodTimeline(startTimeUs + durationUs, durationUs, startTimeUs, 0,
true /* isSeekable */, false /* isDynamic */);
} }
sourceListener.onSourceInfoRefreshed(timeline, manifest); sourceListener.onSourceInfoRefreshed(timeline, manifest);
} }
......
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